feat(FN-4461): add transition evidence backfill script and tests

Adds a backfill script and its tests for FN-4441 transition evidence, covering two new files totaling 204 lines.

Fusion-Task-Id: FN-4461
This commit is contained in:
Fusion
2026-05-14 05:02:55 -07:00
committed by gsxdsm
parent 6a9e1c0e71
commit c61af579bc
2 changed files with 204 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
import test from "node:test";
import assert from "node:assert/strict";
import { tsImport } from "tsx/esm/api";
import { composeTransitionEvidence } from "../backfill-fn-4441-transition-evidence.mjs";
async function loadTaskStore() {
const moduleUrl = new globalThis.URL("../../packages/core/src/store.ts", import.meta.url).href;
const mod = await tsImport(moduleUrl, import.meta.url);
return mod.TaskStore;
}
test("composeTransitionEvidence includes required evidence fields", () => {
const content = composeTransitionEvidence({
mergeRetries: undefined,
branchTip: {
short: "f57f70165",
full: "f57f70165ac154f1ca79e68510990bc61916660e",
},
mainSHAs: [
{
sha: "00c8739d5",
title: "feat(FN-4441): complete Step 1 — add node_modules cache layer",
ancestorStatus: 0,
ancestorOutput: "ancestor",
},
{
sha: "41070475b",
title: "feat(FN-4441): complete Step 2 — verify cache-hit integrity",
ancestorStatus: 0,
ancestorOutput: "ancestor",
},
],
lastMergeError: "The previous cherry-pick is now empty",
resolutionTaskId: "FN-4450",
postState: {
column: "done",
branchDisposition: "deleted",
},
});
assert.match(content, /f57f70165/);
assert.match(content, /00c8739d5/);
assert.match(content, /41070475b/);
assert.match(content, /FN-4450/);
assert.match(content, /mergeRetries:/i);
assert.match(content, /last merge error:/i);
});
test("TaskStore upsertTaskDocument increments revision and round-trips latest content", async () => {
const TaskStore = await loadTaskStore();
const store = new TaskStore(process.cwd(), undefined, { inMemoryDb: true });
try {
await store.createTaskWithReservedId({ description: "seed" }, { taskId: "FN-4441" });
const first = await store.upsertTaskDocument("FN-4441", {
key: "transition-evidence",
content: "first",
author: "test",
});
const second = await store.upsertTaskDocument("FN-4441", {
key: "transition-evidence",
content: "second",
author: "test",
});
assert.equal(first.revision, 1);
assert.equal(second.revision, 2);
const doc = await store.getTaskDocument("FN-4441", "transition-evidence");
assert.equal(doc?.revision, 2);
assert.equal(doc?.content, "second");
} finally {
await store.close();
}
});