refactor(test): colocate pure-domain tests and reduce test debt (#471)

* refactor(test): colocate pure-domain tests and reduce test debt

Move focused immutable domain/contracts/adapter tests from
tests/composition/** beside their production owners under src/** as
colocated *.test.ts/*.fixture.ts, and relocate persistence-shaped
composition tests under tests/boundary/filesystem/**. Update import
paths, the Vitest project topology (shared worker context for pure
domain/contracts and recording-port service projects), the test
migration ledger, testing docs, and AGENTS.md to match.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: remove test migration ledger

The cutover is complete and the ledger is no longer referenced anywhere
in source, scripts, or the docs gate. Drop the standalone artifact.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: clean up stale migration artifacts

Remove empty directories left by the test migration and replace the
"final cutover" language in docs/testing.md with standing PR guidance
that no longer references the completed migration.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: repair CI failures from schema, knip, and stale generated artifacts

Three root causes fixed:

1. catalog-schemas.mjs: valuesAt only traversed anyOf from Zod's
   toJSONSchema, not oneOf. The webScreenshotDiffSchema change to a
   discriminated union produces oneOf, so the product catalog generator
   could not derive the web_screenshot_diff schema version. Add oneOf
   traversal.

2. conformancePackage.ts: the test rewrite removed the only imports of
   ScenarioManifest, ReplayPlan, ShimPlan, and ExpectedEvidence, making
   them unused exports that knip flags. Remove the dead type aliases.

3. Regenerate stale artifacts (product catalog, MCP tool catalog, skill
   metadata, conformance manifest) that drifted from the source changes.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
morluto
2026-08-10 14:57:44 +08:00
committed by GitHub
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 344b9b6dff
commit e91c8c39c2
302 changed files with 6822 additions and 5781 deletions
+265
View File
@@ -0,0 +1,265 @@
import { describe, expect, it } from "vitest";
import {
completeReconstructionCoverageWorkspace,
RECONSTRUCTION_COVERAGE_NOW,
reconstructionCoverageEvidenceId,
} from "./reconstructionCoverage.fixture.js";
import {
createReconstructionCoverageWorkspace,
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();
expect(
evaluateReconstructionClosure(
workspace,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
),
).toMatchObject({
status: "ready",
summary: { required_surfaces: 1, required_claims: 1, reasons: 0 },
evidence_ids: [
reconstructionCoverageEvidenceId("2"),
reconstructionCoverageEvidenceId("3"),
reconstructionCoverageEvidenceId("4"),
reconstructionCoverageEvidenceId("5"),
].sort(),
});
expect(parseReconstructionCoverageWorkspace(workspace)).toEqual(workspace);
});
it("keeps an incomplete inventory partial despite every registered verifier passing", () => {
const workspace = completeReconstructionCoverageWorkspace();
const {
revision_sha256: _revisionSha256,
workspace_id: _workspaceId,
schema_version: _schemaVersion,
...semantic
} = workspace;
const boundary = workspace.boundaries[0];
if (boundary === undefined) throw new Error("Expected fixture boundary");
const incomplete = createReconstructionCoverageWorkspace({
...semantic,
revision: 2,
previous_revision_sha256: workspace.revision_sha256,
boundaries: [
{
...boundary,
required_surface_ids: ["cli.help", "cli.version"],
},
],
});
expect(
evaluateReconstructionClosure(
incomplete,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
),
).toMatchObject({
status: "partial",
reasons: [
expect.objectContaining({
code: "surface-missing",
subject_id: "cli.version",
}),
],
recommended_probes: [
{
operation: "update_authoritative_inventory",
subject_id: "cli.version",
rationale:
"Required surface is absent from the authoritative inventory.",
},
],
});
});
it("invalidates stale verifier contracts and detected authority routing", () => {
const workspace = completeReconstructionCoverageWorkspace();
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,
schema_version: _schemaVersion,
...semantic
} = workspace;
const changed = createReconstructionCoverageWorkspace({
...semantic,
revision: 2,
previous_revision_sha256: workspace.revision_sha256,
owners: [
{
...owner,
ownership: {
...owner.ownership,
owner_sha256: digest("9"),
path_state: "present",
package_state: "distributed",
authority_route: "detected",
},
},
],
});
const result = evaluateReconstructionClosure(
changed,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
);
expect(result.status).toBe("failed");
expect(result.reasons).toEqual(
expect.arrayContaining([
expect.objectContaining({ code: "authority-routing-detected" }),
expect.objectContaining({ code: "verifier-result-incompatible" }),
]),
);
});
it("never lets mock-strength or stale results satisfy stronger current claims", () => {
const workspace = completeReconstructionCoverageWorkspace();
const {
revision_sha256: _revisionSha256,
workspace_id: _workspaceId,
schema_version: _schemaVersion,
...semantic
} = workspace;
const stale = createReconstructionCoverageWorkspace({
...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",
})),
});
expect(
evaluateReconstructionClosure(
stale,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
),
).toMatchObject({
status: "unknown",
reasons: [expect.objectContaining({ code: "verifier-result-stale" })],
});
});
});
describe("reconstruction coverage verifier observations", () => {
it("orders offset-bearing verifier timestamps chronologically", () => {
const workspace = completeReconstructionCoverageWorkspace();
const result = workspace.verifier_results[0];
if (result === undefined)
throw new Error("Expected fixture verifier result");
const {
revision_sha256: _revisionSha256,
workspace_id: _workspaceId,
schema_version: _schemaVersion,
...semantic
} = workspace;
const changed = createReconstructionCoverageWorkspace({
...semantic,
revision: 2,
previous_revision_sha256: workspace.revision_sha256,
verifier_results: [
{ ...result, observed_at: "2026-07-16T08:00:00.000Z" },
{
...result,
observed_at: "2026-07-16T04:00:00.000-05:00",
status: "fail",
},
],
});
expect(
evaluateReconstructionClosure(
changed,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
),
).toMatchObject({
status: "failed",
reasons: [expect.objectContaining({ code: "verifier-failed" })],
});
});
it("rejects verifier observations from the future", () => {
const workspace = completeReconstructionCoverageWorkspace();
const result = workspace.verifier_results[0];
if (result === undefined)
throw new Error("Expected fixture verifier result");
const {
revision_sha256: _revisionSha256,
workspace_id: _workspaceId,
schema_version: _schemaVersion,
...semantic
} = workspace;
const changed = createReconstructionCoverageWorkspace({
...semantic,
revision: 2,
previous_revision_sha256: workspace.revision_sha256,
verifier_results: [
{ ...result, observed_at: "2026-07-17T12:00:00.000Z" },
],
});
expect(
evaluateReconstructionClosure(
changed,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
),
).toMatchObject({
status: "unknown",
reasons: [expect.objectContaining({ code: "verifier-result-stale" })],
});
});
it("rejects green results and package proofs that omit current commitments", () => {
const workspace = completeReconstructionCoverageWorkspace();
const {
revision_sha256: _revisionSha256,
workspace_id: _workspaceId,
schema_version: _schemaVersion,
...semantic
} = workspace;
const incomplete = createReconstructionCoverageWorkspace({
...semantic,
revision: 2,
previous_revision_sha256: workspace.revision_sha256,
verifier_results: workspace.verifier_results.map((result) => ({
...result,
owner_sha256s: [],
})),
package_proofs: workspace.package_proofs.map((proof) => ({
...proof,
artifact_sha256s: [digest("8")],
})),
});
const result = evaluateReconstructionClosure(
incomplete,
"replacement.cli",
RECONSTRUCTION_COVERAGE_NOW,
);
expect(result.status).toBe("unknown");
expect(result.reasons).toEqual(
expect.arrayContaining([
expect.objectContaining({ code: "verifier-result-incompatible" }),
expect.objectContaining({ code: "package-proof-unknown" }),
]),
);
});
});