Skip to content

Commit a35b933

Browse files
committed
fix(reconstruction): evaluate one effective completion scope
Include required-claim surfaces and reachable dependencies in ownership, verifier commitments, contradiction, package proof and summary checks. Preserve all applicable package outcomes instead of accepting any passing proof. Adds authenticated synthetic scope cases and a shared public CLI/MCP regression workflow. Validation is pending the centrally coordinated lane; single-file formatting and lint completed.
1 parent 8425c36 commit a35b933

7 files changed

Lines changed: 385 additions & 41 deletions

‎docs/reconstruction-coverage.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ record can still be insufficient proof: a passing verifier summary cannot
1111
promote inferred Evidence into a replay observation. That case returns
1212
`unknown`, while a missing or tampered record remains an input error.
1313

14+
## Effective completion scope
15+
16+
The selected boundary requires the union of its explicit surface IDs, the
17+
surfaces of every required claim, and every declared dependency reachable from
18+
those surfaces. Cycles are visited once. Missing reachable dependencies remain
19+
visible as `dependency-surface-missing`; they keep closure partial. The
20+
`required_surfaces` summary counts this complete set, including absent IDs,
21+
and `required_claims` counts unique required claims.
22+
23+
Every reachable surface receives the same ownership, path, distribution,
24+
disposition and authority-independence checks. Active contradictions on any of
25+
these surfaces affect the boundary even when the caller did not repeat the
26+
surface ID in `required_surface_ids`. Package proof must cover the artifacts of
27+
this effective scope. A claim verifier must commit to its own surfaces and
28+
their reachable dependencies, including their artifact and implemented-owner
29+
digests. Callers do not need to duplicate the transitive closure in the request.
30+
1431
## Comparable verifier Evidence
1532

1633
At least one record explicitly cited by the latest verifier observation must
@@ -41,3 +58,9 @@ neither a passing nor a failed package workflow.
4158
The evaluator preserves Evidence provenance and returns an actionable unknown
4259
when qualification is unavailable. It does not change the cited records to
4360
make their authority match a caller's declaration.
61+
62+
All applicable package-proof outcomes participate. A failed applicable proof
63+
fails closure even when another proof passes; unknown, unsupported or skipped
64+
applicable outcomes keep it unknown. The result cites all applicable outcomes.
65+
Proof array order does not establish freshness or supersession. A proof for
66+
unrelated artifact digests does not contradict the selected boundary.

‎src/domain/reconstructionCoverage.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { reconstructionCoverageScopeCases } from "./reconstructionCoverageScope.fixture.js";
12
import { describe, expect, it } from "vitest";
23

34
import {
@@ -608,3 +609,28 @@ describe("reconstruction coverage reference constraints", () => {
608609
},
609610
);
610611
});
612+
613+
describe("effective reconstruction boundary", () => {
614+
for (const {
615+
label,
616+
coverage,
617+
status,
618+
codes,
619+
surfaces,
620+
evidenceIds,
621+
} of reconstructionCoverageScopeCases())
622+
it(label, () => {
623+
const result = assertReconstructionCoverageEvaluation(
624+
coverage,
625+
"replacement.cli",
626+
RECONSTRUCTION_COVERAGE_NOW,
627+
);
628+
expect(result.status).toBe(status);
629+
expect(result.summary.required_surfaces).toBe(surfaces);
630+
expect(result.reasons.map(({ code }) => code).sort()).toEqual(
631+
[...codes].sort(),
632+
);
633+
expect(result.evidence_ids).toEqual(expect.arrayContaining(evidenceIds));
634+
expect(result.recommended_probes).toHaveLength(codes.length);
635+
});
636+
});

‎src/domain/reconstructionCoverage.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { reconstructionCoverageScope } from "./reconstructionCoverageScope.js";
12
import { z } from "zod";
23
import { AnalysisInputError } from "./analysisErrorCore.js";
34
import type { EvidenceIntegrityError } from "./evidenceErrors.js";
@@ -345,6 +346,7 @@ export const evaluateParsedReconstructionClosure = (
345346
const context: ReconstructionEvaluationContext = {
346347
...parsed,
347348
boundary,
349+
scope: reconstructionCoverageScope(parsed, boundary),
348350
nowEpochMs,
349351
nowInstant,
350352
reasons: [],
@@ -360,8 +362,8 @@ export const evaluateParsedReconstructionClosure = (
360362
boundary_id: boundary.boundary_id,
361363
status: closureStatus(reasons),
362364
summary: {
363-
required_surfaces: boundary.required_surface_ids.length,
364-
required_claims: boundary.required_claim_ids.length,
365+
required_surfaces: context.scope.surfaceIds.size,
366+
required_claims: context.scope.claimIds.size,
365367
reasons: reasons.length,
366368
},
367369
reasons,

‎src/domain/reconstructionCoverageEvaluation.ts‎

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ReconstructionCoverageScope } from "./reconstructionCoverageScope.js";
12
import type {
23
ReconstructionClosureResult,
34
ReconstructionCoverageData,
@@ -42,6 +43,7 @@ type Boundary = ReconstructionCoverageData["boundaries"][number];
4243
type ClosureReason = ReconstructionClosureResult["reasons"][number];
4344
export interface ReconstructionEvaluationContext extends ParsedReconstructionCoverage {
4445
readonly boundary: Boundary;
46+
readonly scope: ReconstructionCoverageScope;
4547
readonly nowEpochMs: number;
4648
readonly nowInstant: OffsetDateTimeInstant;
4749
readonly reasons: ClosureReason[];
@@ -51,26 +53,28 @@ export interface ReconstructionEvaluationContext extends ParsedReconstructionCov
5153
export const evaluateReconstructionSurfaces = (
5254
context: ReconstructionEvaluationContext,
5355
): void => {
54-
for (const surfaceId of context.boundary.required_surface_ids) {
56+
for (const surfaceId of context.scope.surfaceIds) {
5557
const surface = context.surfaces.get(surfaceId);
5658
if (surface === undefined) {
57-
addReason(
58-
context,
59-
"surface-missing",
60-
surfaceId,
61-
"Required surface is absent from the authoritative inventory.",
62-
);
63-
continue;
64-
}
65-
addEvidence(context, surface.evidence_ids);
66-
for (const dependencyId of surface.dependency_surface_ids)
67-
if (!context.surfaces.has(dependencyId))
59+
const dependents = context.scope.missingDependencies.get(surfaceId);
60+
if (dependents === undefined)
6861
addReason(
6962
context,
70-
"dependency-surface-missing",
63+
"surface-missing",
7164
surfaceId,
72-
`Declared dependency surface is absent: ${dependencyId}`,
65+
"Required surface is absent from the authoritative inventory.",
7366
);
67+
else
68+
for (const dependentId of dependents)
69+
addReason(
70+
context,
71+
"dependency-surface-missing",
72+
dependentId,
73+
`Declared dependency surface is absent: ${surfaceId}`,
74+
);
75+
continue;
76+
}
77+
addEvidence(context, surface.evidence_ids);
7478
evaluateOwner(context, surfaceId);
7579
}
7680
};
@@ -152,7 +156,7 @@ export const evaluateReconstructionClaims = (
152156
context: ReconstructionEvaluationContext,
153157
): void => {
154158
const indexes = createVerifierIndexes(context);
155-
for (const claimId of context.boundary.required_claim_ids) {
159+
for (const claimId of context.scope.claimIds) {
156160
const claim = context.claims.get(claimId);
157161
if (claim === undefined) {
158162
addReason(
@@ -189,6 +193,7 @@ export const evaluateReconstructionClaims = (
189193
};
190194

191195
interface VerifierIndexes {
196+
readonly claimSurfaceIds: ReconstructionCoverageScope["claimSurfaceIds"];
192197
readonly contractsByClaim: ReadonlyMap<
193198
string,
194199
readonly ReconstructionVerifierContract[]
@@ -226,6 +231,7 @@ const createVerifierIndexes = (
226231
}
227232

228233
return {
234+
claimSurfaceIds: context.scope.claimSurfaceIds,
229235
contractsByClaim,
230236
latestResultsByVerifier: latestVerifierObservationsByVerifier(
231237
coverage.verifier_results,
@@ -342,15 +348,18 @@ const verifierResultMatchesContract = (
342348
result: ReconstructionCoverageData["verifier_results"][number],
343349
indexes: VerifierIndexes,
344350
): boolean => {
345-
const expectedArtifactDigests = claim.surface_ids.flatMap((surfaceId) => {
351+
const requiredSurfaceIds = [
352+
...(indexes.claimSurfaceIds.get(claim.claim_id) ?? []),
353+
];
354+
const expectedArtifactDigests = requiredSurfaceIds.flatMap((surfaceId) => {
346355
const surface = indexes.surfaces.get(surfaceId);
347356
const artifact =
348357
surface === undefined
349358
? undefined
350359
: indexes.artifacts.get(surface.artifact_id);
351360
return artifact === undefined ? [] : [artifact.artifact_sha256];
352361
});
353-
const expectedOwnerDigests = claim.surface_ids.flatMap((surfaceId) =>
362+
const expectedOwnerDigests = requiredSurfaceIds.flatMap((surfaceId) =>
354363
(indexes.ownersBySurface.get(surfaceId) ?? []).flatMap(({ ownership }) =>
355364
ownership.disposition === "implemented" ? [ownership.owner_sha256] : [],
356365
),
@@ -399,11 +408,9 @@ export const evaluateReconstructionCoverageRisks = (
399408
if (
400409
contradiction.status === "active" &&
401410
(contradiction.surface_ids.some((id) =>
402-
context.boundary.required_surface_ids.includes(id),
411+
context.scope.surfaceIds.has(id),
403412
) ||
404-
contradiction.claim_ids.some((id) =>
405-
context.boundary.required_claim_ids.includes(id),
406-
))
413+
contradiction.claim_ids.some((id) => context.scope.claimIds.has(id)))
407414
) {
408415
addEvidence(context, contradiction.evidence_ids);
409416
addReason(
@@ -418,7 +425,7 @@ export const evaluateReconstructionCoverageRisks = (
418425
export const evaluateReconstructionPackageProofs = (
419426
context: ReconstructionEvaluationContext,
420427
): void => {
421-
const requiredArtifactDigests = context.boundary.required_surface_ids.flatMap(
428+
const requiredArtifactDigests = [...context.scope.surfaceIds].flatMap(
422429
(surfaceId) => {
423430
const surface = context.surfaces.get(surfaceId);
424431
const artifact =
@@ -438,34 +445,34 @@ export const evaluateReconstructionPackageProofs = (
438445
requiredArtifactDigests.every((digest) =>
439446
proof.artifact_sha256s.includes(digest),
440447
) && packageProofHasComparableEvidence(proof, context.evidenceById);
441-
const passing = proofs.find(
442-
(proof) => proof.status === "pass" && applicable(proof),
443-
);
444-
if (passing !== undefined) {
445-
addEvidence(context, passing.evidence_ids);
446-
continue;
447-
}
448-
const failing = proofs.find(
449-
(proof) => proof.status === "fail" && applicable(proof),
448+
const applicableProofs = proofs.filter(applicable);
449+
addEvidence(
450+
context,
451+
applicableProofs.flatMap((proof) => proof.evidence_ids),
450452
);
451-
if (failing !== undefined) {
452-
addEvidence(context, failing.evidence_ids);
453+
if (applicableProofs.some((proof) => proof.status === "fail")) {
453454
addReason(
454455
context,
455456
"package-proof-failed",
456457
kind,
457-
"Required package or integration proof failed.",
458+
"Required package or integration proof failed; all applicable outcomes are retained.",
458459
);
460+
} else if (
461+
applicableProofs.length > 0 &&
462+
applicableProofs.every((proof) => proof.status === "pass")
463+
) {
464+
continue;
459465
} else if (proofs.length > 0) {
460-
addEvidence(
461-
context,
462-
proofs.flatMap(({ evidence_ids }) => evidence_ids),
463-
);
466+
if (applicableProofs.length === 0)
467+
addEvidence(
468+
context,
469+
proofs.flatMap((proof) => proof.evidence_ids),
470+
);
464471
addReason(
465472
context,
466473
"package-proof-unknown",
467474
kind,
468-
"Required package or integration proof has no qualifying passing Evidence.",
475+
"Required package or integration proof has unresolved or unqualified outcomes.",
469476
);
470477
} else
471478
addReason(

0 commit comments

Comments
 (0)