mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 09:41:04 +01:00
fix(server): scope quarantine count to active seed
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
4969067d62
commit
efa8c6a190
2 files changed
+51
-2
No files matched your search
@@ -170,6 +170,50 @@ describeEmbeddedPostgres("heartbeat worktree suppression", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("counts quarantined runs only for the active seed epoch", async () => {
|
||||
const { companyId, agentId, issueId } = await insertAgentAndIssue();
|
||||
const settings = instanceSettingsService(db, {
|
||||
runtimeEnv: {
|
||||
PAPERCLIP_IN_WORKTREE: "true",
|
||||
PAPERCLIP_INSTANCE_ID: "test-worktree",
|
||||
},
|
||||
});
|
||||
const experimental = await settings.getExperimental();
|
||||
const activeSeedEpoch = experimental.worktreeRunExecutionSeedEpoch;
|
||||
expect(activeSeedEpoch).not.toBeNull();
|
||||
|
||||
await db.insert(heartbeatRuns).values([
|
||||
{
|
||||
id: randomUUID(),
|
||||
companyId,
|
||||
agentId,
|
||||
seedEpoch: activeSeedEpoch,
|
||||
invocationSource: "assignment",
|
||||
triggerDetail: "system",
|
||||
status: "cancelled",
|
||||
errorCode: "worktree_seed_quarantine",
|
||||
responsibleUserId: "responsible-user",
|
||||
contextSnapshot: { issueId },
|
||||
},
|
||||
{
|
||||
id: randomUUID(),
|
||||
companyId,
|
||||
agentId,
|
||||
seedEpoch: randomUUID(),
|
||||
invocationSource: "assignment",
|
||||
triggerDetail: "system",
|
||||
status: "cancelled",
|
||||
errorCode: "worktree_seed_quarantine",
|
||||
responsibleUserId: "responsible-user",
|
||||
contextSnapshot: { issueId },
|
||||
},
|
||||
]);
|
||||
|
||||
await expect(settings.getWorktreeRunEngineStatus()).resolves.toMatchObject({
|
||||
quarantinedRunCount: 1,
|
||||
});
|
||||
});
|
||||
|
||||
async function waitForCompletedRun(runId: string, agentId: string) {
|
||||
let latestStatus: string | null = null;
|
||||
let latestLastRunId: string | null = null;
|
||||
|
||||
@@ -503,11 +503,16 @@ export function instanceSettingsService(db: Db, options: InstanceSettingsService
|
||||
// Only quarantined-run rows survive a seed (P1 deletes the wakeups/monitors
|
||||
// it clears), so this count is the durable evidence of what was neutralized.
|
||||
let quarantinedRunCount = 0;
|
||||
if (inWorktree) {
|
||||
if (inWorktree && experimental.worktreeRunExecutionSeedEpoch) {
|
||||
const [row] = await db
|
||||
.select({ count: sql<number>`count(*)::int` })
|
||||
.from(heartbeatRuns)
|
||||
.where(eq(heartbeatRuns.errorCode, WORKTREE_SEED_QUARANTINE_ERROR_CODE));
|
||||
.where(
|
||||
and(
|
||||
eq(heartbeatRuns.errorCode, WORKTREE_SEED_QUARANTINE_ERROR_CODE),
|
||||
eq(heartbeatRuns.seedEpoch, experimental.worktreeRunExecutionSeedEpoch),
|
||||
),
|
||||
);
|
||||
quarantinedRunCount = row?.count ?? 0;
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user