Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(reconstruction): withhold readiness for manifest references to absent Evidence (#3526)

Kaoru0822c9764084b851
diff --git a/src/application/ReconstructionObligationLedger.closure.test.ts b/src/application/ReconstructionObligationLedger.closure.test.ts
index 34249ac1a..d3404ad13 100644
--- a/src/application/ReconstructionObligationLedger.closure.test.ts
+++ b/src/application/ReconstructionObligationLedger.closure.test.ts
@@ -12,6 +12,62 @@ import {
import { deriveReconstructionObligationCandidates } from "./ReconstructionObligationCandidates.js";
import { evaluateReconstructionObligationLedger } from "./ReconstructionObligationLedgerEvaluation.js";
+/** Build a request whose packaged-process obligation closes as ready. */
+const readyProcessLedgerRequest = () => {
+ const capture = processEvidence();
+ const initial = build(request([capture]));
+ const obligation = initial.obligations[0];
+ if (obligation === undefined) throw new Error("Expected process obligation");
+ const fixtureIds = obligation.required_case_kinds.map(
+ (caseKind) => `packaged.${caseKind}`,
+ );
+ const proof = boundProofEvidence("packaged", {
+ obligation_ids: [obligation.obligation_id],
+ fixture_ids: fixtureIds,
+ case_kinds: obligation.required_case_kinds,
+ verifier_ids: ["verifier.packaged"],
+ claim_ids: ["claim.process"],
+ });
+ const ledgerRequest = request([capture, proof], {
+ manifest: {
+ bindings: [
+ {
+ obligation_id: obligation.obligation_id,
+ owner: {
+ module_path: "src/processOwner.ts",
+ symbol: "runProcess",
+ owner_sha256: "2".repeat(64),
+ },
+ parser_type: null,
+ original_cases: originalCases(obligation, capture.evidence_id),
+ fixtures: obligation.required_case_kinds.map((caseKind) => ({
+ fixture_id: `packaged.${caseKind}`,
+ case_kind: caseKind,
+ authority: "packaged-process",
+ evidence_ids: [proof.evidence_id],
+ })),
+ verifier: {
+ verifier_id: "verifier.packaged",
+ claim_id: "claim.process",
+ command: "npm run verify:package -- process",
+ authority: "packaged-process",
+ status: "pass",
+ result_evidence_id: proof.evidence_id,
+ enumerated_obligation_ids: [obligation.obligation_id],
+ nondeterminism: {
+ mode: "partial-order",
+ specification:
+ "Startup precedes teardown; worker completion is unordered.",
+ },
+ },
+ },
+ ],
+ contradictions: [],
+ },
+ });
+ return ledgerRequest;
+};
+
describe("reconstruction obligation ledger", () => {
it("emits the complete deterministic ledger and closure identity", () => {
const evidence = proofEvidence("review");
@@ -224,58 +280,7 @@ describe("reconstruction obligation ledger case closure", () => {
});
it("closes only when every required case and verifier has comparable authority", () => {
- const capture = processEvidence();
- const initial = build(request([capture]));
- const obligation = initial.obligations[0];
- if (obligation === undefined)
- throw new Error("Expected process obligation");
- const fixtureIds = obligation.required_case_kinds.map(
- (caseKind) => `packaged.${caseKind}`,
- );
- const proof = boundProofEvidence("packaged", {
- obligation_ids: [obligation.obligation_id],
- fixture_ids: fixtureIds,
- case_kinds: obligation.required_case_kinds,
- verifier_ids: ["verifier.packaged"],
- claim_ids: ["claim.process"],
- });
- const ledgerRequest = request([capture, proof], {
- manifest: {
- bindings: [
- {
- obligation_id: obligation.obligation_id,
- owner: {
- module_path: "src/processOwner.ts",
- symbol: "runProcess",
- owner_sha256: "2".repeat(64),
- },
- parser_type: null,
- original_cases: originalCases(obligation, capture.evidence_id),
- fixtures: obligation.required_case_kinds.map((caseKind) => ({
- fixture_id: `packaged.${caseKind}`,
- case_kind: caseKind,
- authority: "packaged-process",
- evidence_ids: [proof.evidence_id],
- })),
- verifier: {
- verifier_id: "verifier.packaged",
- claim_id: "claim.process",
- command: "npm run verify:package -- process",
- authority: "packaged-process",
- status: "pass",
- result_evidence_id: proof.evidence_id,
- enumerated_obligation_ids: [obligation.obligation_id],
- nondeterminism: {
- mode: "partial-order",
- specification:
- "Startup precedes teardown; worker completion is unordered.",
- },
- },
- },
- ],
- contradictions: [],
- },
- });
+ const ledgerRequest = readyProcessLedgerRequest();
const result = build(ledgerRequest);
expect(result.obligations[0]).toMatchObject({
@@ -300,3 +305,54 @@ describe("reconstruction obligation ledger case closure", () => {
expect(limited.coverage.status).toBe("partial");
});
});
+
+describe("reconstruction obligation manifest references", () => {
+ it("withholds readiness when a manifest entry names absent Evidence", () => {
+ const ledgerRequest = readyProcessLedgerRequest();
+ // A valid entry for the same case kind must not hide an absent reference.
+ const absent = `ev_${"a".repeat(64)}`;
+ const binding = ledgerRequest.manifest.bindings[0];
+ if (binding === undefined) throw new Error("Expected binding");
+ const variants: {
+ readonly code: string;
+ readonly binding: typeof binding;
+ }[] = [
+ {
+ code: "missing-original-case",
+ binding: {
+ ...binding,
+ original_cases: [
+ ...binding.original_cases,
+ { kind: "positive", evidence_id: absent, location: "/old" },
+ ],
+ },
+ },
+ {
+ code: "missing-case",
+ binding: {
+ ...binding,
+ fixtures: [
+ ...binding.fixtures,
+ {
+ fixture_id: "packaged.old",
+ case_kind: "positive",
+ authority: "packaged-process",
+ evidence_ids: [absent],
+ },
+ ],
+ },
+ },
+ ];
+ for (const { code, binding: dangling } of variants) {
+ const open = build({
+ ...ledgerRequest,
+ manifest: { ...ledgerRequest.manifest, bindings: [dangling] },
+ });
+ expect(open.status).not.toBe("ready");
+ expect(open.obligations[0]?.status).toBe("implemented");
+ expect(open.obligations[0]?.diagnostics).toEqual([
+ { code, detail: expect.stringContaining(absent) },
+ ]);
+ }
+ });
+});
diff --git a/src/application/ReconstructionObligationLedgerEvaluation.ts b/src/application/ReconstructionObligationLedgerEvaluation.ts
index a9366c331..ea54a3608 100644
--- a/src/application/ReconstructionObligationLedgerEvaluation.ts
+++ b/src/application/ReconstructionObligationLedgerEvaluation.ts
@@ -268,6 +268,14 @@ const evaluateBinding = (
);
continue;
}
+ for (const fixture of fixtures)
+ for (const evidenceId of fixture.evidence_ids)
+ if (!context.evidence.has(evidenceId))
+ addDiagnostic(
+ diagnostics,
+ "missing-case",
+ `${caseKind} fixture ${fixture.fixture_id} references Evidence ${evidenceId}, which is absent from the bundle.`,
+ );
if (
!fixtures.some(
(fixture) =>
diff --git a/src/application/ReconstructionObligationOriginalCases.ts b/src/application/ReconstructionObligationOriginalCases.ts
index 46bb15be5..596090741 100644
--- a/src/application/ReconstructionObligationOriginalCases.ts
+++ b/src/application/ReconstructionObligationOriginalCases.ts
@@ -45,6 +45,14 @@ export const originalCaseDiagnostics = (
});
continue;
}
+ // A valid entry for this case kind does not resolve another entry's
+ // reference; every referenced Evidence ID must be in the bundle.
+ for (const { evidence_id: evidenceId } of cases)
+ if (!evidenceById.has(evidenceId))
+ diagnostics.push({
+ code: "missing-original-case",
+ detail: `Original ${caseKind} case references Evidence ${evidenceId}, which is absent from the bundle.`,
+ });
if (
!cases.some(({ evidence_id: evidenceId }) => {
const evidence = evidenceById.get(evidenceId);