fix(work-folders): preserve save status when activity logging fails

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-09-07 13:53:39 -05:00
1 parent 2962ebfdb7
commit b5fca70b80
4 files changed
+27 -6

No files matched your search

@@ -9,7 +9,10 @@ import { DeployedStackApi, loadDeployedStack } from "./deployed-stack.js";
const stack = loadDeployedStack();
const api = new DeployedStackApi(stack);
const folder = (scope: string, ownerId: string) => `/api/companies/${stack.companyId}/work-folders/${scope}/${encodeURIComponent(ownerId)}`;
test.describe.configure({ mode: "serial" });
test.beforeAll(async () => {
const health = await api.json<{ commit: string }>("/api/health");
expect(health.commit, "Only exercise the declared deployed candidate").toBe(stack.commit);
});
test("deployed candidate and complete supported adapter inventory", async ({}, info) => {
const health = await api.json<{ commit: string }>("/api/health");
@@ -77,16 +80,17 @@ for (const profile of stack.profiles) {
"Then complete this task successfully. Do not print credentials or modify unrelated files.",
].join("\n"),
});
await info.attach("task", { contentType: "application/json", body: Buffer.from(JSON.stringify({ profile: profile.id, ...issue })) });
const base = folder("task", issue.id);
await pollUntil({ label: `${profile.id} completed run and durable task file`, deadlineAt: Date.now() + 840_000,
intervalMs: 5_000,
load: async () => ({ issue: await api.json<{ status: string }>(`/api/issues/${issue.id}`),
saves: await api.json<WorkFolderSyncStatus[]>(`${base}/sync`) }),
accept: (state) => state.issue.status === "done" && state.saves.some((save) => !save.active && save.state === "saved" && save.lastSavedAt !== null),
reject: (state) => state.saves.some((save) => save.state === "failed") ? "Work-folder save failed" : undefined,
reject: (state) => state.saves.some((save) => save.state === "failed") ? "Work-folder save failed"
: state.issue.status === "blocked" || state.issue.status === "cancelled" ? `Task ${issue.identifier} ended ${state.issue.status}` : undefined,
});
const content = await api.request(`${base}/content?path=acceptance.txt`);
expect(content.status).toBe(200); expect(await content.text()).toBe(nonce);
await info.attach("task", { contentType: "application/json", body: Buffer.from(JSON.stringify({ profile: profile.id, ...issue })) });
});
}
@@ -8,7 +8,7 @@ if (!output || !path.isAbsolute(output)) throw new Error("PAPERCLIP_DEPLOYED_STA
export default defineConfig({
testDir: ".", testMatch: "deployed-work-folders.spec.ts",
fullyParallel: false, workers: 1, retries: 0, timeout: 900_000,
fullyParallel: true, workers: 2, retries: 0, timeout: 900_000,
use: { baseURL: stack.baseURL, trace: "off", video: "off" },
// No webServer: every operation reaches the deployed tenant and database.
outputDir: path.join(output, "results"),