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:
@@ -7,7 +7,7 @@ import { GHIDRA_INVENTORY_OPERATIONS } from "./GhidraInventoryValues.js";
|
||||
import { GhidraProvider } from "./GhidraProvider.js";
|
||||
|
||||
describe("Ghidra provider capabilities", () => {
|
||||
it("publishes only admitted immutable read-only operations", () => {
|
||||
it("publishes only admitted read-only operations and resists caller mutation", () => {
|
||||
const config = parseConfig({});
|
||||
expect(config.ok).toBe(true);
|
||||
if (!config.ok) return;
|
||||
@@ -17,10 +17,10 @@ describe("Ghidra provider capabilities", () => {
|
||||
probeJava: () => undefined,
|
||||
});
|
||||
const capabilities = provider.capabilities();
|
||||
const published = structuredClone(capabilities);
|
||||
expect(capabilities.map(({ operation }) => operation).sort()).toEqual(
|
||||
[...GHIDRA_INVENTORY_OPERATIONS, ...GHIDRA_FUNCTION_OPERATIONS].sort(),
|
||||
);
|
||||
expect(Object.isFrozen(capabilities)).toBe(true);
|
||||
for (const descriptor of capabilities) {
|
||||
expect(descriptor).toMatchObject({
|
||||
available: true,
|
||||
@@ -33,10 +33,15 @@ describe("Ghidra provider capabilities", () => {
|
||||
requiresRoot: false,
|
||||
},
|
||||
});
|
||||
expect(Object.isFrozen(descriptor)).toBe(true);
|
||||
expect(Object.isFrozen(descriptor.effects)).toBe(true);
|
||||
expect(Object.isFrozen(descriptor.limits)).toBe(true);
|
||||
expect(Object.isFrozen(descriptor.limitations)).toBe(true);
|
||||
}
|
||||
const first = capabilities[0];
|
||||
if (first === undefined) throw new Error("Ghidra capabilities are empty");
|
||||
Reflect.set(capabilities, 0, { ...first, available: false });
|
||||
Reflect.set(first, "available", false);
|
||||
Reflect.set(first.effects, "mutatesArtifact", true);
|
||||
Reflect.set(first.limits, "maxResults", 0);
|
||||
Reflect.set(first.limitations, 0, "forged limitation");
|
||||
|
||||
expect(provider.capabilities()).toEqual(published);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user