fix(reconstruction): resolve latest verifier observations without input-order bias

Group observations by exact normalized instant, retaining arbitrary fractional precision and offset equivalence. Coalesce equivalent assessments and all supporting Evidence; report conflicting latest assessments as unknown with verifier-result-ambiguous. Use the same instant comparison for freshness and future checks.

Replace first-input-wins coverage with permutation, provenance, offset, sub-millisecond ordering, and future-clock regressions, including the public MCP workflow. Validation: focused reconstruction/offset tests and MCP workflow passed; converted JSON Schema validation, typecheck/lint, and docs checks passed. Full suite and real-provider lanes were not run.
This commit is contained in:
morluto
2026-10-13 13:23:38 +08:00
parent 3c57e1a8b2
commit 1f7f808c4f
7 changed files with 402 additions and 40 deletions
@@ -3,7 +3,10 @@ import { ok as resultOk } from "../../../src/domain/result.js";
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { describe, expect, it } from "vitest";
import { completeReconstructionCoverageData } from "../../../src/domain/reconstructionCoverage.fixture.js";
import {
completeReconstructionCoverageData,
reconstructionCoverageEvidenceId,
} from "../../../src/domain/reconstructionCoverage.fixture.js";
import { createReconstructionCoverageData } from "../../../src/domain/reconstructionCoverage.js";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import { createServer } from "../../../src/server/createServer.js";
@@ -36,6 +39,42 @@ describe("reconstruction coverage MCP", () => {
boundary_id: boundaryId,
summary: { reasons: 0 },
});
const coverage = currentFixtureCoverage(boundaryId);
const latest = coverage.verifier_results[0];
if (latest === undefined)
throw new Error("Expected fixture verifier result");
const ambiguous = await client.callTool({
name: "evaluate_reconstruction_coverage",
arguments: {
coverage: createReconstructionCoverageData({
...coverage,
verifier_results: [
latest,
{
...latest,
status: "fail",
evidence_ids: [reconstructionCoverageEvidenceId("1")],
},
],
}),
boundary_id: boundaryId,
},
});
expect(ambiguous.isError).not.toBe(true);
expect(ambiguous.structuredContent).toMatchObject({
status: "unknown",
boundary_id: boundaryId,
reasons: [
expect.objectContaining({
code: "verifier-result-ambiguous",
subject_id: "claim.cli.help",
}),
],
evidence_ids: expect.arrayContaining([
reconstructionCoverageEvidenceId("3"),
reconstructionCoverageEvidenceId("1"),
]),
});
const unknown = await client.callTool({
name: "evaluate_reconstruction_coverage",
arguments: {