fix(artifacts): compare inventories using declared coverage (#2214)
* fix(artifacts): preserve complete root inventory comparisons * fix(artifacts): declare inventory coverage before comparison * fix(artifacts): preserve traversal omissions and materialization limits * fix(artifacts): preserve coverage declarations and projection scope Remove the duplicate inventory-schema import. Compare original coverage declarations, including field omission, before adapting legacy pages. Require explicit scope for completeness and container-entry coverage for application projections. Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally. * fix(artifacts): require entry coverage for child changes * fix(artifacts): accept source-valid inventory limitations * style(artifacts): format mobile graph projection --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> Co-authored-by: OpenAI Codex <openai-codex@users.noreply.github.com>
This commit is contained in:
co-authored by
morluto
OpenAI Codex
parent
e4186af31b
commit
45a3509db3
@@ -254,8 +254,11 @@ const assertHistoricalInventory = async (
|
||||
const { archive, parent, inventoryEvidence, graph } = input;
|
||||
// Historical records may omit a later inventory field. Input parsing must
|
||||
// not insert defaults inside that authenticated child Evidence.
|
||||
const { integrity_contradictions: _contradictions, ...legacyInventory } =
|
||||
graph;
|
||||
const {
|
||||
integrity_contradictions: _contradictions,
|
||||
coverage: _coverage,
|
||||
...legacyInventory
|
||||
} = graph;
|
||||
const legacyTarget = {
|
||||
path: archive,
|
||||
sha256: graph.manifest.root_sha256,
|
||||
@@ -275,6 +278,9 @@ const assertHistoricalInventory = async (
|
||||
expect(
|
||||
legacyInspection.substeps[0]?.evidence.normalized_result,
|
||||
).not.toHaveProperty("integrity_contradictions");
|
||||
expect(
|
||||
legacyInspection.substeps[0]?.evidence.normalized_result,
|
||||
).not.toHaveProperty("coverage");
|
||||
const legacyParent = createEvidence(legacyTarget, parent.provider, {
|
||||
operation: "inspect_artifact",
|
||||
parameters: {},
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
|
||||
import { parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import { jsonValueSchema } from "../../../src/domain/jsonValue.js";
|
||||
import { artifactInventoryResultSchema } from "../../../src/domain/artifactGraph.js";
|
||||
import { ok as resultOk } from "../../../src/domain/result.js";
|
||||
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
@@ -98,20 +100,6 @@ it.each([
|
||||
20_000,
|
||||
);
|
||||
|
||||
const artifactInventoryResultSchema = z.object({
|
||||
occurrences: z.array(
|
||||
z.object({ logical_path: z.string(), hash_status: z.string() }),
|
||||
),
|
||||
integrity_contradictions: z.array(
|
||||
z.object({
|
||||
logical_path: z.string(),
|
||||
declared_sha256: z.string(),
|
||||
observed_sha256: z.string(),
|
||||
trust: z.literal("observed-untrusted"),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
it("extracts an active archive through MCP when requested", async () => {
|
||||
const root = await createTestTempDirectory("rea-artifact-extract-mcp-");
|
||||
const archive = join(root, "fixture.zip");
|
||||
@@ -318,6 +306,30 @@ it("records an explicitly continued mismatch, preserves verified siblings, and n
|
||||
}),
|
||||
]),
|
||||
});
|
||||
const { coverage: _coverage, ...legacyInventory } = inventory;
|
||||
const historical = createEvidence(
|
||||
{ path: archive, sha256: inventory.manifest.root_sha256, format: "asar" },
|
||||
compact.provider,
|
||||
{
|
||||
operation: "inventory_artifact",
|
||||
parameters: {},
|
||||
result: jsonValueSchema.parse(legacyInventory),
|
||||
},
|
||||
);
|
||||
const retainedComparison = await client.callTool({
|
||||
name: "compare_artifacts",
|
||||
arguments: { left: evidence, right: historical },
|
||||
});
|
||||
expect(
|
||||
retainedComparison.isError,
|
||||
JSON.stringify(retainedComparison),
|
||||
).not.toBe(true);
|
||||
expect(
|
||||
toolEvidence(retainedComparison.structuredContent).normalized_result,
|
||||
).toMatchObject({
|
||||
status: "contradiction",
|
||||
summary: { unchanged: 2, contradiction: 2, unknown: 0 },
|
||||
});
|
||||
} finally {
|
||||
await Promise.allSettled([client.close(), server.close(), session.close()]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user