1+ import type { ReconstructionCoverageScope } from "./reconstructionCoverageScope.js" ;
12import type {
23 ReconstructionClosureResult ,
34 ReconstructionCoverageData ,
@@ -42,6 +43,7 @@ type Boundary = ReconstructionCoverageData["boundaries"][number];
4243type ClosureReason = ReconstructionClosureResult [ "reasons" ] [ number ] ;
4344export 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
5153export 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
191195interface 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 = (
418425export 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