refactor!: enforce canonical evidence and provider boundaries

Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership.

Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers.

BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
This commit is contained in:
morluto
2026-10-09 20:18:52 +08:00
parent 2a7746998d
commit 63bf91405c
514 changed files with 9296 additions and 5825 deletions
@@ -1,11 +1,10 @@
import type { EvidenceMcpServer } from "../EvidenceMcpServer.js";
import { recordSessionEvidenceSources } from "../sessionEvidence.js";
import type { McpServer } from "@modelcontextprotocol/server";
import { verifyManagedNativeBoundariesEvidence } from "../../application/managed/ManagedNativeVerificationService.js";
import { managedNativeVerificationResultSchema } from "../../domain/managed/managedNativeVerification.js";
import { logToolExecution } from "../toolLogging.js";
import { toolRegistrationOptions } from "../toolRegistrationOptions.js";
import { toCallToolResult, toEvidenceToolResult } from "../toolResult.js";
import { managedWorkflowContract } from "./contract.js";
import {
resolveManagedBoundaryEvidence,
@@ -19,7 +18,7 @@ const nativeVerificationContract = managedWorkflowContract(
/** Register the managed/native boundary verification workflow tool. */
export const registerVerifyManagedNativeBoundaries = (
server: McpServer,
server: EvidenceMcpServer,
options: ManagedWorkflowToolRegistration,
): void => {
server.registerTool(
@@ -30,12 +29,18 @@ export const registerVerifyManagedNativeBoundaries = (
input.managed_boundaries,
);
if (!managedBoundaries.ok)
return toCallToolResult(managedBoundaries, nativeVerificationContract);
return server.delivery.toCallToolResult(
managedBoundaries,
nativeVerificationContract,
);
const nativeObservations = resolveNativeEvidence(
input.native_observations,
);
if (!nativeObservations.ok)
return toCallToolResult(nativeObservations, nativeVerificationContract);
return server.delivery.toCallToolResult(
nativeObservations,
nativeVerificationContract,
);
const managedBoundary = managedBoundaries.value[0];
if (managedBoundary === undefined)
throw new TypeError("Managed boundary Evidence resolution failed");
@@ -50,13 +55,19 @@ export const registerVerifyManagedNativeBoundaries = (
() => Promise.resolve(verifyManagedNativeBoundariesEvidence(parsed)),
);
if (!result.ok)
return toCallToolResult(result, nativeVerificationContract);
return server.delivery.toCallToolResult(
result,
nativeVerificationContract,
);
const recordedSources = recordSessionEvidenceSources(
options.recordEvidence,
[parsed.managed_boundaries, ...parsed.native_observations],
);
if (!recordedSources.ok)
return toCallToolResult(recordedSources, nativeVerificationContract);
return server.delivery.toCallToolResult(
recordedSources,
nativeVerificationContract,
);
const verification = managedNativeVerificationResultSchema.parse(
result.value.normalized_result,
);
@@ -90,7 +101,7 @@ export const registerVerifyManagedNativeBoundaries = (
relationships: [],
})
: options.recordEvidence?.(result.value);
return toEvidenceToolResult(
return server.delivery.toEvidenceToolResult(
result.value,
nativeVerificationContract,
output,