refactor(domain): encode comparison and lifecycle states exactly (#473)

* refactor(domain): encode comparison states exactly

* refactor(domain): make evidence lifecycles explicit

* refactor(browser): parse capture states once

* test: prefer behavior over implementation seams

* chore: refresh schema-derived metadata

* test(process): preserve lifecycle cleanup coverage

* test(hopper): bind rename cache coverage to dispatch
This commit is contained in:
morluto
2026-08-11 18:04:36 +08:00
committed by GitHub
parent e91c8c39c2
commit d65730c4c2
43 changed files with 1732 additions and 780 deletions
+26
View File
@@ -145,6 +145,7 @@ describe("function comparison", () => {
FUNCTION_COMPARISON_EXAMPLE.left.evidence_id,
FUNCTION_COMPARISON_EXAMPLE.right.evidence_id,
]);
expectFunctionDimensionAlgebra(result);
});
it("normalizes CFG relocation but preserves changed edges and constants", () => {
@@ -272,3 +273,28 @@ describe("function comparison", () => {
expect(pseudocode?.left_digest).not.toBe(pseudocode?.right_digest);
});
});
const expectFunctionDimensionAlgebra = (
result: ReturnType<typeof compareFunctions>,
): void => {
const observed = result.dimensions.find(
({ status }) => status === "unchanged" || status === "changed",
);
expect(observed).toBeDefined();
if (observed === undefined) return;
expect(
functionComparisonResultSchema.safeParse({
...result,
dimensions: [
{ ...observed, left_digest: null, right_digest: null },
...result.dimensions.slice(1),
],
}).success,
).toBe(false);
expect(
functionComparisonResultSchema.safeParse({
...result,
function_match: { ...result.function_match, method: "explicit" },
}).success,
).toBe(false);
};