feat(FN-4973): complete Step 1 — add stale self-owned registry reconcile helper

Fusion-Task-Id: FN-4973
Fusion-Task-Lineage: 2edb5479-a01a-4775-b121-f4be32792e7a
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 17:51:19 -07:00
committed by gsxdsm
parent b53172befd
commit 3a53c6778c
2 changed files with 45 additions and 0 deletions

View File

@@ -35,4 +35,31 @@ describe("activeSessionRegistry", () => {
warnSpy.mockRestore();
});
it("reconcileStaleSelfOwned returns no-entry when path is unregistered", () => {
expect(activeSessionRegistry.reconcileStaleSelfOwned("/tmp/missing", "FN-1")).toEqual({
reconciled: false,
reason: "no-entry",
});
});
it("reconcileStaleSelfOwned returns foreign-task for mismatched owner", () => {
activeSessionRegistry.registerPath("/tmp/w1", { taskId: "FN-2", kind: "executor", ownerKey: "FN-2" });
expect(activeSessionRegistry.reconcileStaleSelfOwned("/tmp/w1", "FN-1")).toEqual({
reconciled: false,
reason: "foreign-task",
});
expect(activeSessionRegistry.lookupByPath("/tmp/w1")?.taskId).toBe("FN-2");
});
it("reconcileStaleSelfOwned unregisters matching self-owned entry", () => {
activeSessionRegistry.registerPath("/tmp/w1", { taskId: "FN-1", kind: "executor", ownerKey: "FN-1" });
expect(activeSessionRegistry.reconcileStaleSelfOwned("/tmp/w1", "FN-1")).toEqual({
reconciled: true,
reason: "reconciled",
});
expect(activeSessionRegistry.lookupByPath("/tmp/w1")).toBeNull();
});
});