* 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>
100 lines
3.0 KiB
TypeScript
100 lines
3.0 KiB
TypeScript
import { join } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
import {
|
|
commitReconstructionCoverage,
|
|
queryReconstructionCoverage,
|
|
} from "../../../src/application/ReconstructionCoverageService.js";
|
|
import {
|
|
readReconstructionCoverageWorkspace,
|
|
writeReconstructionCoverageWorkspace,
|
|
} from "../../../src/application/ReconstructionCoverageWorkspaceStore.js";
|
|
import type { EvidenceFilePolicy } from "../../../src/domain/evidenceBundle.js";
|
|
import {
|
|
completeReconstructionCoverageWorkspace,
|
|
RECONSTRUCTION_COVERAGE_NOW,
|
|
} from "../../../src/domain/reconstructionCoverage.fixture.js";
|
|
|
|
const filePolicy = (root: string): EvidenceFilePolicy => ({
|
|
roots: [root],
|
|
maxBytes: 64 * 1024 * 1024,
|
|
maxDepth: 64,
|
|
maxStringLength: 1024 * 1024,
|
|
maxNodes: 1_000_000,
|
|
});
|
|
|
|
describe("reconstruction coverage persistence", () => {
|
|
it("persists owner-only revisions with CAS and digest-chain enforcement", async () => {
|
|
const root = await createTestTempDirectory("rea-coverage-workspace-");
|
|
const path = join(root, "coverage.json");
|
|
const workspace = completeReconstructionCoverageWorkspace();
|
|
const policy = filePolicy(root);
|
|
|
|
const written = await writeReconstructionCoverageWorkspace(
|
|
workspace,
|
|
path,
|
|
null,
|
|
policy,
|
|
);
|
|
expect(written.ok).toBe(true);
|
|
expect(await readReconstructionCoverageWorkspace(path, policy)).toEqual({
|
|
ok: true,
|
|
value: workspace,
|
|
});
|
|
expect(
|
|
await writeReconstructionCoverageWorkspace(workspace, path, null, policy),
|
|
).toMatchObject({
|
|
ok: false,
|
|
error: {
|
|
_tag: "InvestigationWorkspaceError",
|
|
reason: "revision-conflict",
|
|
},
|
|
});
|
|
});
|
|
|
|
it("shares commit and fail-closed query behavior across adapters", async () => {
|
|
const root = await createTestTempDirectory("rea-coverage-service-");
|
|
const path = join(root, "coverage.json");
|
|
const workspace = completeReconstructionCoverageWorkspace();
|
|
const policy = filePolicy(root);
|
|
|
|
const committed = await commitReconstructionCoverage(
|
|
{
|
|
approved: true,
|
|
workspace_path: path,
|
|
expected_revision: null,
|
|
workspace,
|
|
},
|
|
policy,
|
|
);
|
|
expect(committed.ok && committed.value).toMatchObject({
|
|
revision: 1,
|
|
revision_sha256: workspace.revision_sha256,
|
|
evidence_records: 5,
|
|
});
|
|
const queried = await queryReconstructionCoverage(
|
|
{ workspace_path: path, boundary_id: "replacement.cli" },
|
|
policy,
|
|
RECONSTRUCTION_COVERAGE_NOW,
|
|
);
|
|
expect(queried.ok && queried.value).toMatchObject({ status: "ready" });
|
|
|
|
const controller = new AbortController();
|
|
controller.abort();
|
|
expect(
|
|
await queryReconstructionCoverage(
|
|
{ workspace_path: path, boundary_id: "replacement.cli" },
|
|
policy,
|
|
RECONSTRUCTION_COVERAGE_NOW,
|
|
{ signal: controller.signal },
|
|
),
|
|
).toMatchObject({
|
|
ok: false,
|
|
error: { _tag: "AnalysisCancelledError" },
|
|
});
|
|
});
|
|
});
|