mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-30 05:16:50 +01:00
fix(cli): stamp quarantined runs with seed epoch
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
2ffd416624
commit
2d0d546734
2 files changed
+30
No files matched your search
@@ -1410,11 +1410,19 @@ describe("worktree helpers", () => {
|
||||
for (const run of quarantinedRuns) {
|
||||
expect(run.status).toBe("cancelled");
|
||||
expect(run.errorCode).toBe("worktree_seed_quarantine");
|
||||
expect(run.seedEpoch).toEqual(expect.any(String));
|
||||
expect(run.processPid).toBeNull();
|
||||
expect(run.processGroupId).toBeNull();
|
||||
expect(run.finishedAt).toBeInstanceOf(Date);
|
||||
}
|
||||
|
||||
const [seededSettings] = await db.select().from(instanceSettings);
|
||||
const seededExperimental = seededSettings?.experimental as Record<string, unknown>;
|
||||
expect(quarantinedRuns.map((run) => run.seedEpoch)).toEqual([
|
||||
seededExperimental.worktreeRunExecutionSeedEpoch,
|
||||
seededExperimental.worktreeRunExecutionSeedEpoch,
|
||||
]);
|
||||
|
||||
const [succeededRun] = await db.select().from(heartbeatRuns).where(eq(heartbeatRuns.id, succeededRunId));
|
||||
expect(succeededRun?.status).toBe("succeeded");
|
||||
expect(succeededRun?.wakeupRequestId).toBe(completedWakeupId);
|
||||
|
||||
@@ -1336,6 +1336,27 @@ export async function quarantineSeededWorktreeExecutionState(
|
||||
try {
|
||||
await db.transaction(async (tx) => {
|
||||
const now = new Date();
|
||||
const [settingsRow] = await tx
|
||||
.select({ id: instanceSettings.id, experimental: instanceSettings.experimental })
|
||||
.from(instanceSettings)
|
||||
.where(eq(instanceSettings.singletonKey, "default"))
|
||||
.limit(1);
|
||||
const experimental = isRecord(settingsRow?.experimental) ? settingsRow.experimental : {};
|
||||
const existingSeedEpoch = experimental.worktreeRunExecutionSeedEpoch;
|
||||
const seedEpoch = typeof existingSeedEpoch === "string" && existingSeedEpoch.length > 0
|
||||
? existingSeedEpoch
|
||||
: randomUUID();
|
||||
|
||||
if (settingsRow && seedEpoch !== existingSeedEpoch) {
|
||||
await tx
|
||||
.update(instanceSettings)
|
||||
.set({
|
||||
experimental: { ...experimental, worktreeRunExecutionSeedEpoch: seedEpoch },
|
||||
updatedAt: now,
|
||||
})
|
||||
.where(eq(instanceSettings.id, settingsRow.id));
|
||||
}
|
||||
|
||||
const pendingWakeups = await tx
|
||||
.select({ id: agentWakeupRequests.id })
|
||||
.from(agentWakeupRequests)
|
||||
@@ -1354,6 +1375,7 @@ export async function quarantineSeededWorktreeExecutionState(
|
||||
.set({
|
||||
status: "cancelled",
|
||||
errorCode: WORKTREE_SEED_QUARANTINE_ERROR_CODE,
|
||||
seedEpoch,
|
||||
processPid: null,
|
||||
processGroupId: null,
|
||||
scheduledRetryAt: null,
|
||||
|
||||
Reference in new issue
Block a user