refactor(coverage): evaluate inline without workspaces
This commit is contained in:
@@ -12,8 +12,6 @@ export const PERMISSION_CAPABILITIES = [
|
||||
"v8_inspector_observe",
|
||||
"evidence_read",
|
||||
"evidence_write",
|
||||
"reconstruction_coverage_read",
|
||||
"reconstruction_coverage_write",
|
||||
"snapshot_read",
|
||||
"snapshot_write",
|
||||
"artifact_extract",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createEvidence } from "./evidence.js";
|
||||
import { createEvidenceBundle } from "./evidenceBundle.js";
|
||||
import {
|
||||
createReconstructionCoverageWorkspace,
|
||||
createReconstructionCoverageData,
|
||||
createReconstructionVerifierContract,
|
||||
} from "./reconstructionCoverage.js";
|
||||
|
||||
@@ -35,7 +35,7 @@ export const reconstructionCoverageEvidenceId = (character: string): string => {
|
||||
};
|
||||
|
||||
/** Build one fully closed reconstruction-coverage workspace. */
|
||||
export const completeReconstructionCoverageWorkspace = () => {
|
||||
export const completeReconstructionCoverageData = () => {
|
||||
const contract = createReconstructionVerifierContract({
|
||||
verifier_id: "verify.cli.help",
|
||||
claim_ids: ["claim.cli.help"],
|
||||
@@ -46,10 +46,7 @@ export const completeReconstructionCoverageWorkspace = () => {
|
||||
normalization_sha256: digest("4"),
|
||||
normalization_removes_dimensions: false,
|
||||
});
|
||||
return createReconstructionCoverageWorkspace({
|
||||
name: "fixture",
|
||||
revision: 1,
|
||||
previous_revision_sha256: null,
|
||||
return createReconstructionCoverageData({
|
||||
evidence_bundle: createEvidenceBundle(EVIDENCE_RECORDS),
|
||||
artifacts: [
|
||||
{
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
completeReconstructionCoverageWorkspace,
|
||||
completeReconstructionCoverageData,
|
||||
RECONSTRUCTION_COVERAGE_NOW,
|
||||
reconstructionCoverageEvidenceId,
|
||||
} from "./reconstructionCoverage.fixture.js";
|
||||
import {
|
||||
createReconstructionCoverageWorkspace,
|
||||
createReconstructionCoverageData,
|
||||
evaluateReconstructionClosure,
|
||||
parseReconstructionCoverageWorkspace,
|
||||
} from "./reconstructionCoverage.js";
|
||||
|
||||
const digest = (character: string): string => character.repeat(64);
|
||||
|
||||
describe("reconstruction coverage closure", () => {
|
||||
it("returns ready only when ownership, verification, package, and authority closure pass", () => {
|
||||
const workspace = completeReconstructionCoverageWorkspace();
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
|
||||
expect(
|
||||
evaluateReconstructionClosure(
|
||||
@@ -33,22 +32,16 @@ describe("reconstruction coverage closure", () => {
|
||||
reconstructionCoverageEvidenceId("5"),
|
||||
].sort(),
|
||||
});
|
||||
expect(parseReconstructionCoverageWorkspace(workspace)).toEqual(workspace);
|
||||
expect(createReconstructionCoverageData(workspace)).toEqual(workspace);
|
||||
});
|
||||
|
||||
it("keeps an incomplete inventory partial despite every registered verifier passing", () => {
|
||||
const workspace = completeReconstructionCoverageWorkspace();
|
||||
const {
|
||||
revision_sha256: _revisionSha256,
|
||||
workspace_id: _workspaceId,
|
||||
...semantic
|
||||
} = workspace;
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
const semantic = workspace;
|
||||
const boundary = workspace.boundaries[0];
|
||||
if (boundary === undefined) throw new Error("Expected fixture boundary");
|
||||
const incomplete = createReconstructionCoverageWorkspace({
|
||||
const incomplete = createReconstructionCoverageData({
|
||||
...semantic,
|
||||
revision: 2,
|
||||
previous_revision_sha256: workspace.revision_sha256,
|
||||
boundaries: [
|
||||
{
|
||||
...boundary,
|
||||
@@ -83,19 +76,13 @@ describe("reconstruction coverage closure", () => {
|
||||
});
|
||||
|
||||
it("invalidates stale verifier contracts and detected authority routing", () => {
|
||||
const workspace = completeReconstructionCoverageWorkspace();
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
const owner = workspace.owners[0];
|
||||
if (owner === undefined || owner.ownership.disposition !== "implemented")
|
||||
throw new Error("Expected implemented fixture owner");
|
||||
const {
|
||||
revision_sha256: _revisionSha256,
|
||||
workspace_id: _workspaceId,
|
||||
...semantic
|
||||
} = workspace;
|
||||
const changed = createReconstructionCoverageWorkspace({
|
||||
const semantic = workspace;
|
||||
const changed = createReconstructionCoverageData({
|
||||
...semantic,
|
||||
revision: 2,
|
||||
previous_revision_sha256: workspace.revision_sha256,
|
||||
owners: [
|
||||
{
|
||||
...owner,
|
||||
@@ -125,16 +112,10 @@ describe("reconstruction coverage closure", () => {
|
||||
});
|
||||
|
||||
it("never lets mock-strength or stale results satisfy stronger current claims", () => {
|
||||
const workspace = completeReconstructionCoverageWorkspace();
|
||||
const {
|
||||
revision_sha256: _revisionSha256,
|
||||
workspace_id: _workspaceId,
|
||||
...semantic
|
||||
} = workspace;
|
||||
const stale = createReconstructionCoverageWorkspace({
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
const semantic = workspace;
|
||||
const stale = createReconstructionCoverageData({
|
||||
...semantic,
|
||||
revision: 2,
|
||||
previous_revision_sha256: workspace.revision_sha256,
|
||||
verifier_results: workspace.verifier_results.map((result) => ({
|
||||
...result,
|
||||
observed_at: "2026-07-01T00:00:00.000Z",
|
||||
@@ -156,19 +137,13 @@ describe("reconstruction coverage closure", () => {
|
||||
|
||||
describe("reconstruction coverage verifier observations", () => {
|
||||
it("orders offset-bearing verifier timestamps chronologically", () => {
|
||||
const workspace = completeReconstructionCoverageWorkspace();
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
const result = workspace.verifier_results[0];
|
||||
if (result === undefined)
|
||||
throw new Error("Expected fixture verifier result");
|
||||
const {
|
||||
revision_sha256: _revisionSha256,
|
||||
workspace_id: _workspaceId,
|
||||
...semantic
|
||||
} = workspace;
|
||||
const changed = createReconstructionCoverageWorkspace({
|
||||
const semantic = workspace;
|
||||
const changed = createReconstructionCoverageData({
|
||||
...semantic,
|
||||
revision: 2,
|
||||
previous_revision_sha256: workspace.revision_sha256,
|
||||
verifier_results: [
|
||||
{ ...result, observed_at: "2026-07-16T08:00:00.000Z" },
|
||||
{
|
||||
@@ -192,19 +167,13 @@ describe("reconstruction coverage verifier observations", () => {
|
||||
});
|
||||
|
||||
it("rejects verifier observations from the future", () => {
|
||||
const workspace = completeReconstructionCoverageWorkspace();
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
const result = workspace.verifier_results[0];
|
||||
if (result === undefined)
|
||||
throw new Error("Expected fixture verifier result");
|
||||
const {
|
||||
revision_sha256: _revisionSha256,
|
||||
workspace_id: _workspaceId,
|
||||
...semantic
|
||||
} = workspace;
|
||||
const changed = createReconstructionCoverageWorkspace({
|
||||
const semantic = workspace;
|
||||
const changed = createReconstructionCoverageData({
|
||||
...semantic,
|
||||
revision: 2,
|
||||
previous_revision_sha256: workspace.revision_sha256,
|
||||
verifier_results: [
|
||||
{ ...result, observed_at: "2026-07-17T12:00:00.000Z" },
|
||||
],
|
||||
@@ -223,16 +192,10 @@ describe("reconstruction coverage verifier observations", () => {
|
||||
});
|
||||
|
||||
it("rejects green results and package proofs that omit current commitments", () => {
|
||||
const workspace = completeReconstructionCoverageWorkspace();
|
||||
const {
|
||||
revision_sha256: _revisionSha256,
|
||||
workspace_id: _workspaceId,
|
||||
...semantic
|
||||
} = workspace;
|
||||
const incomplete = createReconstructionCoverageWorkspace({
|
||||
const workspace = completeReconstructionCoverageData();
|
||||
const semantic = workspace;
|
||||
const incomplete = createReconstructionCoverageData({
|
||||
...semantic,
|
||||
revision: 2,
|
||||
previous_revision_sha256: workspace.revision_sha256,
|
||||
verifier_results: workspace.verifier_results.map((result) => ({
|
||||
...result,
|
||||
owner_sha256s: [],
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
evaluateReconstructionClaims,
|
||||
evaluateReconstructionPackageProofs,
|
||||
evaluateReconstructionSurfaces,
|
||||
evaluateReconstructionWorkspaceRisks,
|
||||
evaluateReconstructionCoverageRisks,
|
||||
recommendedReconstructionProbes,
|
||||
type ReconstructionEvaluationContext,
|
||||
} from "./reconstructionCoverageEvaluation.js";
|
||||
@@ -158,11 +158,7 @@ const boundarySchema = z.strictObject({
|
||||
allowed_unknown_ids: z.array(stableIdSchema).max(1_000),
|
||||
});
|
||||
|
||||
const workspaceSemanticSchema = z.strictObject({
|
||||
workspace_id: z.string().regex(/^rcw_[a-f0-9]{64}$/u),
|
||||
name: z.string().trim().min(1).max(200),
|
||||
revision: z.number().int().min(1),
|
||||
previous_revision_sha256: digestSchema.nullable(),
|
||||
export const reconstructionCoverageDataSchema = z.strictObject({
|
||||
evidence_bundle: evidenceBundleSchema,
|
||||
artifacts: z.array(artifactSchema).max(1_000),
|
||||
surfaces: z.array(surfaceSchema).max(10_000),
|
||||
@@ -176,16 +172,22 @@ const workspaceSemanticSchema = z.strictObject({
|
||||
boundaries: z.array(boundarySchema).max(1_000),
|
||||
});
|
||||
|
||||
export const reconstructionCoverageWorkspaceSchema =
|
||||
workspaceSemanticSchema.extend({ revision_sha256: digestSchema });
|
||||
|
||||
export type ReconstructionCoverageWorkspace = z.infer<
|
||||
typeof reconstructionCoverageWorkspaceSchema
|
||||
export type ReconstructionCoverageData = z.infer<
|
||||
typeof reconstructionCoverageDataSchema
|
||||
>;
|
||||
export type ReconstructionVerifierContract = z.infer<
|
||||
typeof verifierContractSchema
|
||||
>;
|
||||
|
||||
/** Parse inline coverage data and validate every evidence and authority link. */
|
||||
export const createReconstructionCoverageData = (
|
||||
input: unknown,
|
||||
): ReconstructionCoverageData => {
|
||||
const coverage = reconstructionCoverageDataSchema.parse(input);
|
||||
validateCoverageReferences(coverage);
|
||||
return coverage;
|
||||
};
|
||||
|
||||
const closureReasonSchema = z.strictObject({
|
||||
code: z.enum([
|
||||
"surface-missing",
|
||||
@@ -220,7 +222,6 @@ const closureReasonSchema = z.strictObject({
|
||||
export const reconstructionClosureResultSchema = z.strictObject({
|
||||
boundary_id: stableIdSchema,
|
||||
status: z.enum(["partial", "failed", "unknown", "ready"]),
|
||||
workspace_revision_sha256: digestSchema,
|
||||
summary: z.strictObject({
|
||||
required_surfaces: z.number().int().min(0),
|
||||
required_claims: z.number().int().min(0),
|
||||
@@ -243,7 +244,7 @@ export type ReconstructionClosureResult = z.infer<
|
||||
typeof reconstructionClosureResultSchema
|
||||
>;
|
||||
|
||||
type WorkspaceSemantic = z.infer<typeof workspaceSemanticSchema>;
|
||||
type CoverageData = z.infer<typeof reconstructionCoverageDataSchema>;
|
||||
type ClosureReason = z.infer<typeof closureReasonSchema>;
|
||||
|
||||
/** Build a verifier contract whose digest prevents retrospective coverage edits. */
|
||||
@@ -257,80 +258,20 @@ export const createReconstructionVerifierContract = (
|
||||
});
|
||||
};
|
||||
|
||||
/** Build one canonical immutable coverage-workspace revision. */
|
||||
export const createReconstructionCoverageWorkspace = (
|
||||
input: Omit<z.input<typeof workspaceSemanticSchema>, "workspace_id">,
|
||||
): ReconstructionCoverageWorkspace => {
|
||||
const semanticInput = {
|
||||
workspace_id: `rcw_${digest({ name: input.name })}`,
|
||||
...input,
|
||||
};
|
||||
const semantic = canonicalWorkspace(
|
||||
workspaceSemanticSchema.parse(semanticInput),
|
||||
);
|
||||
validateWorkspaceReferences(semantic);
|
||||
return reconstructionCoverageWorkspaceSchema.parse({
|
||||
...semantic,
|
||||
revision_sha256: digest(semantic),
|
||||
});
|
||||
};
|
||||
|
||||
/** Parse persisted coverage state and verify canonical order, references, and digests. */
|
||||
export const parseReconstructionCoverageWorkspace = (
|
||||
input: unknown,
|
||||
): ReconstructionCoverageWorkspace => {
|
||||
const parsed = reconstructionCoverageWorkspaceSchema.parse(input);
|
||||
const rebuilt = createReconstructionCoverageWorkspace({
|
||||
name: parsed.name,
|
||||
revision: parsed.revision,
|
||||
previous_revision_sha256: parsed.previous_revision_sha256,
|
||||
evidence_bundle: parsed.evidence_bundle,
|
||||
artifacts: parsed.artifacts,
|
||||
surfaces: parsed.surfaces,
|
||||
owners: parsed.owners,
|
||||
claims: parsed.claims,
|
||||
verifier_contracts: parsed.verifier_contracts,
|
||||
verifier_results: parsed.verifier_results,
|
||||
residual_unknown_ids: parsed.residual_unknown_ids,
|
||||
contradictions: parsed.contradictions,
|
||||
package_proofs: parsed.package_proofs,
|
||||
boundaries: parsed.boundaries,
|
||||
});
|
||||
if (
|
||||
parsed.workspace_id !== rebuilt.workspace_id ||
|
||||
parsed.revision_sha256 !== rebuilt.revision_sha256 ||
|
||||
JSON.stringify(parsed) !== JSON.stringify(rebuilt)
|
||||
)
|
||||
throw new TypeError("Reconstruction coverage workspace is not canonical");
|
||||
return rebuilt;
|
||||
};
|
||||
|
||||
/** Serialize one validated coverage revision as byte-stable canonical JSON. */
|
||||
export const serializeReconstructionCoverageWorkspace = (
|
||||
workspace: ReconstructionCoverageWorkspace,
|
||||
): string => {
|
||||
const encoded = canonicalize(parseReconstructionCoverageWorkspace(workspace));
|
||||
if (encoded === undefined)
|
||||
throw new TypeError(
|
||||
"Reconstruction coverage workspace is not canonical JSON",
|
||||
);
|
||||
return encoded;
|
||||
};
|
||||
|
||||
/** Evaluate one named completion boundary without inferring undiscovered coverage. */
|
||||
/** Evaluate inline coverage data against one named fail-closed boundary. */
|
||||
export const evaluateReconstructionClosure = (
|
||||
workspaceInput: unknown,
|
||||
coverageInput: unknown,
|
||||
boundaryId: string,
|
||||
nowEpochMs: number,
|
||||
): ReconstructionClosureResult => {
|
||||
const workspace = parseReconstructionCoverageWorkspace(workspaceInput);
|
||||
const boundary = workspace.boundaries.find(
|
||||
const coverage = createReconstructionCoverageData(coverageInput);
|
||||
const boundary = coverage.boundaries.find(
|
||||
({ boundary_id: id }) => id === boundaryId,
|
||||
);
|
||||
if (boundary === undefined)
|
||||
throw new TypeError(`Unknown reconstruction boundary: ${boundaryId}`);
|
||||
const context: ReconstructionEvaluationContext = {
|
||||
workspace,
|
||||
coverage,
|
||||
boundary,
|
||||
nowEpochMs,
|
||||
reasons: [],
|
||||
@@ -338,13 +279,12 @@ export const evaluateReconstructionClosure = (
|
||||
};
|
||||
evaluateReconstructionSurfaces(context);
|
||||
evaluateReconstructionClaims(context);
|
||||
evaluateReconstructionWorkspaceRisks(context);
|
||||
evaluateReconstructionCoverageRisks(context);
|
||||
evaluateReconstructionPackageProofs(context);
|
||||
const reasons = [...context.reasons].sort(reasonOrder);
|
||||
return reconstructionClosureResultSchema.parse({
|
||||
boundary_id: boundary.boundary_id,
|
||||
status: closureStatus(reasons),
|
||||
workspace_revision_sha256: workspace.revision_sha256,
|
||||
summary: {
|
||||
required_surfaces: boundary.required_surface_ids.length,
|
||||
required_claims: boundary.required_claim_ids.length,
|
||||
@@ -356,7 +296,7 @@ export const evaluateReconstructionClosure = (
|
||||
});
|
||||
};
|
||||
|
||||
const validateWorkspaceReferences = (workspace: WorkspaceSemantic): void => {
|
||||
const validateCoverageReferences = (workspace: CoverageData): void => {
|
||||
const evidenceBundle = parseEvidenceBundle(workspace.evidence_bundle);
|
||||
const evidenceIds = new Set(
|
||||
evidenceBundle.records.map(({ evidence_id: id }) => id),
|
||||
@@ -418,34 +358,6 @@ const validateWorkspaceReferences = (workspace: WorkspaceSemantic): void => {
|
||||
);
|
||||
};
|
||||
|
||||
const canonicalWorkspace = (
|
||||
workspace: WorkspaceSemantic,
|
||||
): WorkspaceSemantic => ({
|
||||
...workspace,
|
||||
artifacts: sorted(workspace.artifacts, "artifact_id"),
|
||||
surfaces: sorted(workspace.surfaces, "surface_id"),
|
||||
owners: [...workspace.owners].sort((left, right) =>
|
||||
left.surface_id.localeCompare(right.surface_id),
|
||||
),
|
||||
claims: sorted(workspace.claims, "claim_id"),
|
||||
verifier_contracts: sorted(workspace.verifier_contracts, "verifier_id"),
|
||||
verifier_results: [...workspace.verifier_results].sort((left, right) =>
|
||||
`${left.verifier_id}:${left.observed_at}`.localeCompare(
|
||||
`${right.verifier_id}:${right.observed_at}`,
|
||||
),
|
||||
),
|
||||
residual_unknown_ids: [...new Set(workspace.residual_unknown_ids)].sort(),
|
||||
contradictions: sorted(workspace.contradictions, "contradiction_id"),
|
||||
package_proofs: sorted(workspace.package_proofs, "proof_id"),
|
||||
boundaries: sorted(workspace.boundaries, "boundary_id"),
|
||||
});
|
||||
|
||||
const sorted = <Item extends Record<Key, string>, Key extends keyof Item>(
|
||||
items: readonly Item[],
|
||||
key: Key,
|
||||
): Item[] =>
|
||||
[...items].sort((left, right) => left[key].localeCompare(right[key]));
|
||||
|
||||
const assertUnique = <Item extends Record<Key, string>, Key extends keyof Item>(
|
||||
items: readonly Item[],
|
||||
key: Key,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {
|
||||
ReconstructionClosureResult,
|
||||
ReconstructionCoverageWorkspace,
|
||||
ReconstructionCoverageData,
|
||||
ReconstructionVerifierContract,
|
||||
} from "./reconstructionCoverage.js";
|
||||
|
||||
@@ -23,10 +23,10 @@ const probeOperation = (code: ClosureReason["code"]): string => {
|
||||
return "update_authoritative_inventory";
|
||||
};
|
||||
|
||||
type Boundary = ReconstructionCoverageWorkspace["boundaries"][number];
|
||||
type Boundary = ReconstructionCoverageData["boundaries"][number];
|
||||
type ClosureReason = ReconstructionClosureResult["reasons"][number];
|
||||
export interface ReconstructionEvaluationContext {
|
||||
readonly workspace: ReconstructionCoverageWorkspace;
|
||||
readonly coverage: ReconstructionCoverageData;
|
||||
readonly boundary: Boundary;
|
||||
readonly nowEpochMs: number;
|
||||
readonly reasons: ClosureReason[];
|
||||
@@ -36,7 +36,7 @@ export interface ReconstructionEvaluationContext {
|
||||
export const evaluateReconstructionSurfaces = (
|
||||
context: ReconstructionEvaluationContext,
|
||||
): void => {
|
||||
const surfaces = indexUnique(context.workspace.surfaces, "surface_id");
|
||||
const surfaces = indexUnique(context.coverage.surfaces, "surface_id");
|
||||
for (const surfaceId of context.boundary.required_surface_ids) {
|
||||
const surface = surfaces.get(surfaceId);
|
||||
if (surface === undefined) {
|
||||
@@ -65,7 +65,7 @@ const evaluateOwner = (
|
||||
context: ReconstructionEvaluationContext,
|
||||
surfaceId: string,
|
||||
): void => {
|
||||
const owners = context.workspace.owners.filter(
|
||||
const owners = context.coverage.owners.filter(
|
||||
({ surface_id: id }) => id === surfaceId,
|
||||
);
|
||||
if (owners.length === 0) {
|
||||
@@ -139,7 +139,7 @@ const evaluateOwner = (
|
||||
export const evaluateReconstructionClaims = (
|
||||
context: ReconstructionEvaluationContext,
|
||||
): void => {
|
||||
const claims = indexUnique(context.workspace.claims, "claim_id");
|
||||
const claims = indexUnique(context.coverage.claims, "claim_id");
|
||||
for (const claimId of context.boundary.required_claim_ids) {
|
||||
const claim = claims.get(claimId);
|
||||
if (claim === undefined) {
|
||||
@@ -151,7 +151,7 @@ export const evaluateReconstructionClaims = (
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const contracts = context.workspace.verifier_contracts.filter(
|
||||
const contracts = context.coverage.verifier_contracts.filter(
|
||||
({ claim_ids: ids }) => ids.includes(claimId),
|
||||
);
|
||||
if (contracts.length === 0) {
|
||||
@@ -180,10 +180,10 @@ export const evaluateReconstructionClaims = (
|
||||
|
||||
const evaluateVerifierResult = (
|
||||
context: ReconstructionEvaluationContext,
|
||||
claim: ReconstructionCoverageWorkspace["claims"][number],
|
||||
claim: ReconstructionCoverageData["claims"][number],
|
||||
contract: ReconstructionVerifierContract,
|
||||
): void => {
|
||||
const results = context.workspace.verifier_results
|
||||
const results = context.coverage.verifier_results
|
||||
.filter(({ verifier_id: id }) => id === contract.verifier_id)
|
||||
.sort(
|
||||
(left, right) =>
|
||||
@@ -240,23 +240,23 @@ const evaluateVerifierResult = (
|
||||
|
||||
const verifierResultIsCompatible = (
|
||||
context: ReconstructionEvaluationContext,
|
||||
claim: ReconstructionCoverageWorkspace["claims"][number],
|
||||
claim: ReconstructionCoverageData["claims"][number],
|
||||
contract: ReconstructionVerifierContract,
|
||||
result: ReconstructionCoverageWorkspace["verifier_results"][number],
|
||||
result: ReconstructionCoverageData["verifier_results"][number],
|
||||
): boolean => {
|
||||
const artifactDigests = new Set(
|
||||
context.workspace.artifacts.map(({ artifact_sha256: value }) => value),
|
||||
context.coverage.artifacts.map(({ artifact_sha256: value }) => value),
|
||||
);
|
||||
const ownerDigests = new Set(
|
||||
context.workspace.owners.flatMap(({ ownership }) =>
|
||||
context.coverage.owners.flatMap(({ ownership }) =>
|
||||
ownership.disposition === "implemented" ? [ownership.owner_sha256] : [],
|
||||
),
|
||||
);
|
||||
const surfaces = new Map(
|
||||
context.workspace.surfaces.map((surface) => [surface.surface_id, surface]),
|
||||
context.coverage.surfaces.map((surface) => [surface.surface_id, surface]),
|
||||
);
|
||||
const artifacts = new Map(
|
||||
context.workspace.artifacts.map((artifact) => [
|
||||
context.coverage.artifacts.map((artifact) => [
|
||||
artifact.artifact_id,
|
||||
artifact,
|
||||
]),
|
||||
@@ -267,7 +267,7 @@ const verifierResultIsCompatible = (
|
||||
surface === undefined ? undefined : artifacts.get(surface.artifact_id);
|
||||
return artifact === undefined ? [] : [artifact.artifact_sha256];
|
||||
});
|
||||
const expectedOwnerDigests = context.workspace.owners.flatMap(
|
||||
const expectedOwnerDigests = context.coverage.owners.flatMap(
|
||||
({ surface_id: surfaceId, ownership }) =>
|
||||
claim.surface_ids.includes(surfaceId) &&
|
||||
ownership.disposition === "implemented"
|
||||
@@ -301,10 +301,10 @@ const verifierResultIsCompatible = (
|
||||
);
|
||||
};
|
||||
|
||||
export const evaluateReconstructionWorkspaceRisks = (
|
||||
export const evaluateReconstructionCoverageRisks = (
|
||||
context: ReconstructionEvaluationContext,
|
||||
): void => {
|
||||
for (const unknownId of context.workspace.residual_unknown_ids)
|
||||
for (const unknownId of context.coverage.residual_unknown_ids)
|
||||
if (!context.boundary.allowed_unknown_ids.includes(unknownId))
|
||||
addReason(
|
||||
context,
|
||||
@@ -312,7 +312,7 @@ export const evaluateReconstructionWorkspaceRisks = (
|
||||
unknownId,
|
||||
"Active residual unknown is not permitted by the completion boundary.",
|
||||
);
|
||||
for (const contradiction of context.workspace.contradictions)
|
||||
for (const contradiction of context.coverage.contradictions)
|
||||
if (
|
||||
contradiction.status === "active" &&
|
||||
(contradiction.surface_ids.some((id) =>
|
||||
@@ -336,10 +336,10 @@ export const evaluateReconstructionPackageProofs = (
|
||||
context: ReconstructionEvaluationContext,
|
||||
): void => {
|
||||
const surfaces = new Map(
|
||||
context.workspace.surfaces.map((surface) => [surface.surface_id, surface]),
|
||||
context.coverage.surfaces.map((surface) => [surface.surface_id, surface]),
|
||||
);
|
||||
const artifacts = new Map(
|
||||
context.workspace.artifacts.map((artifact) => [
|
||||
context.coverage.artifacts.map((artifact) => [
|
||||
artifact.artifact_id,
|
||||
artifact,
|
||||
]),
|
||||
@@ -353,7 +353,7 @@ export const evaluateReconstructionPackageProofs = (
|
||||
},
|
||||
);
|
||||
for (const kind of context.boundary.required_package_proof_kinds) {
|
||||
const proofs = context.workspace.package_proofs.filter(
|
||||
const proofs = context.coverage.package_proofs.filter(
|
||||
(proof) => proof.kind === kind,
|
||||
);
|
||||
const passing = proofs.find(
|
||||
|
||||
@@ -77,14 +77,6 @@ export const reconstructionSpecificationSchema = z
|
||||
/** Bounded reconstruction-verification input. */
|
||||
export const reconstructionVerificationInputSchema = z.strictObject({
|
||||
specification: reconstructionSpecificationSchema,
|
||||
coverage: z
|
||||
.strictObject({
|
||||
workspace_id: z.string().regex(/^rcw_[a-f0-9]{64}$/u),
|
||||
revision: z.number().int().min(1),
|
||||
revision_sha256: digestSchema,
|
||||
boundary_id: z.string().min(1).max(200),
|
||||
})
|
||||
.optional(),
|
||||
unknown_registry_approved: z.literal(true).optional(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user