refactor(captures)!: require canonical producer metadata
Require process retention accounting, browser network transaction identity, and all web comparison dimensions. Remove obsolete omission repairs and derive completeness from the owning producer facts. BREAKING CHANGE: Historical captures without current producer accounting or transaction identity, and web diffs missing accessibility or storage dimensions, are rejected.
This commit is contained in:
@@ -91,17 +91,14 @@ describe("web capture diff", () => {
|
||||
scripts: { ...result.dimensions.scripts, total_changes: 2 },
|
||||
},
|
||||
});
|
||||
const {
|
||||
accessibility: _accessibility,
|
||||
storage: _storage,
|
||||
...legacy
|
||||
} = result.dimensions;
|
||||
const parsedLegacy = webCaptureDiffSchema.parse({
|
||||
const { accessibility: _accessibility, ...missingAccessibility } =
|
||||
result.dimensions;
|
||||
expectInvalidDiff({
|
||||
...result,
|
||||
dimensions: legacy,
|
||||
dimensions: missingAccessibility,
|
||||
});
|
||||
expect(parsedLegacy.dimensions.accessibility.status).toBe("unknown");
|
||||
expect(parsedLegacy.dimensions.storage.status).toBe("unknown");
|
||||
const { storage: _storage, ...missingStorage } = result.dimensions;
|
||||
expectInvalidDiff({ ...result, dimensions: missingStorage });
|
||||
});
|
||||
|
||||
it("does not claim unchanged when a relevant section is incomplete", async () => {
|
||||
|
||||
@@ -15,13 +15,25 @@ import { HopperProcessError } from "../../../src/domain/hopperErrors.js";
|
||||
import { processScenarioSchema } from "../../../src/domain/process/processScenario.js";
|
||||
import { ToolResultDelivery } from "../../../src/server/toolResult.js";
|
||||
import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import { emptyProcessCapture } from "../../../src/domain/process/processCapture.fixture.js";
|
||||
import {
|
||||
accountFullyObservedProcessCapture,
|
||||
emptyProcessCapture,
|
||||
} from "../../../src/domain/process/processCapture.fixture.js";
|
||||
import type { JsonValue } from "../../../src/domain/jsonValue.js";
|
||||
import { evidenceResultOf } from "../../../src/contracts/toolOutputSchemaPrimitives.js";
|
||||
import { toolRegistrationOptions } from "../../../src/server/toolRegistrationOptions.js";
|
||||
|
||||
import type { IncompleteProcessCaptureObservations } from "../../../src/domain/process/processCapture.js";
|
||||
const delivery = new ToolResultDelivery(STDIO_DEFAULT_MAX_BUFFER_SIZE);
|
||||
const emptyFilesystemCoverage =
|
||||
emptyProcessCapture().truncation_details.filesystem_before;
|
||||
|
||||
const captureWithObservedOutput = () =>
|
||||
accountFullyObservedProcessCapture({
|
||||
...emptyProcessCapture(),
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "observed output" }],
|
||||
event_journal: [],
|
||||
});
|
||||
|
||||
const contract: ToolContract = {
|
||||
name: "provider_neutral_fixture",
|
||||
@@ -56,11 +68,7 @@ describe("completed partial process capture MCP projection", () => {
|
||||
terminal_renderer: { state: "cleaned" as const, reason: null },
|
||||
temporary_root: { state: "cleaned" as const, reason: null },
|
||||
};
|
||||
const capture = {
|
||||
...emptyProcessCapture(),
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "observed output" }],
|
||||
event_journal: [],
|
||||
};
|
||||
const capture = captureWithObservedOutput();
|
||||
let failure: ProcessCaptureError | undefined;
|
||||
try {
|
||||
resolveProcessResult(
|
||||
@@ -108,11 +116,7 @@ describe("completed partial process capture MCP projection", () => {
|
||||
terminal_renderer: { state: "cleaned" as const, reason: null },
|
||||
temporary_root: { state: "cleaned" as const, reason: null },
|
||||
};
|
||||
const capture = {
|
||||
...emptyProcessCapture(),
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "observed output" }],
|
||||
event_journal: [],
|
||||
};
|
||||
const capture = captureWithObservedOutput();
|
||||
|
||||
let failure: ProcessCaptureError | undefined;
|
||||
try {
|
||||
@@ -228,7 +232,15 @@ describe("incomplete partial process observations MCP projection", () => {
|
||||
],
|
||||
},
|
||||
filesystem_snapshots: {
|
||||
before: { state: "available", value: { files: [], truncated: false } },
|
||||
before: {
|
||||
state: "available",
|
||||
value: {
|
||||
files: [],
|
||||
truncated: false,
|
||||
completeRoots: [],
|
||||
coverage: emptyFilesystemCoverage,
|
||||
},
|
||||
},
|
||||
after: {
|
||||
state: "unavailable",
|
||||
reason: "fixture final snapshot unavailable",
|
||||
|
||||
@@ -6,7 +6,10 @@ import {
|
||||
observeLaunchedExecutable,
|
||||
observeSelectedExecutable,
|
||||
} from "../../../src/process/capture/ProcessCaptureLifecycle.js";
|
||||
import { emptyUnverifiedProcessCapture } from "../../../src/domain/process/processCapture.fixture.js";
|
||||
import {
|
||||
accountFullyObservedProcessCapture,
|
||||
emptyUnverifiedProcessCapture,
|
||||
} from "../../../src/domain/process/processCapture.fixture.js";
|
||||
import { compareProcessCaptures } from "../../../src/domain/process/processComparison.js";
|
||||
import { parseProcessCapture } from "../../../src/domain/process/processCaptureParsing.js";
|
||||
import {
|
||||
@@ -81,18 +84,20 @@ const captureEvidenceForEnvironmentSecret = async (value: string) => {
|
||||
...manifest,
|
||||
normalization_sha256: digestProcessCommitment(scenario.normalization),
|
||||
};
|
||||
const capture = parseProcessCapture({
|
||||
...base,
|
||||
normalization: scenario.normalization,
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "observed-output" }],
|
||||
residual_unknowns: [
|
||||
{
|
||||
scope: "environment",
|
||||
reason: "Inherited host environment variables are not recorded.",
|
||||
},
|
||||
],
|
||||
manifest: scenarioManifest,
|
||||
});
|
||||
const capture = parseProcessCapture(
|
||||
accountFullyObservedProcessCapture({
|
||||
...base,
|
||||
normalization: scenario.normalization,
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "observed-output" }],
|
||||
residual_unknowns: [
|
||||
{
|
||||
scope: "environment",
|
||||
reason: "Inherited host environment variables are not recorded.",
|
||||
},
|
||||
],
|
||||
manifest: scenarioManifest,
|
||||
}),
|
||||
);
|
||||
return createProcessCaptureEvidence(scenario, capture);
|
||||
};
|
||||
|
||||
@@ -135,10 +140,12 @@ it("preserves selected local environment and input values", async () => {
|
||||
rightCapture.manifest.comparison_contract_sha256,
|
||||
);
|
||||
|
||||
const changedOutput = parseProcessCapture({
|
||||
...leftCapture,
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "different-output" }],
|
||||
});
|
||||
const changedOutput = parseProcessCapture(
|
||||
accountFullyObservedProcessCapture({
|
||||
...leftCapture,
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "different-output" }],
|
||||
}),
|
||||
);
|
||||
expect(compareProcessCaptures(leftCapture, changedOutput)).toMatchObject({
|
||||
status: "changed",
|
||||
terminal: "changed",
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
observeSelectedExecutable,
|
||||
} from "../../../src/process/capture/ProcessCaptureLifecycle.js";
|
||||
import { parseProcessScenario } from "../../../src/domain/process/processScenario.js";
|
||||
import { emptyProcessCapture } from "../../../src/domain/process/processCapture.fixture.js";
|
||||
import { type ProcessCapture } from "../../../src/domain/process/processCaptureParsing.js";
|
||||
|
||||
const processFixture = fileURLToPath(
|
||||
@@ -33,6 +34,8 @@ type PartialCapture = Extract<
|
||||
NonNullable<ProcessCaptureError["partialObservation"]>,
|
||||
{ readonly capture: unknown }
|
||||
>["capture"];
|
||||
const emptyFilesystemCoverage =
|
||||
emptyProcessCapture().truncation_details.filesystem_before;
|
||||
const expectUnverifiedHostCleanup = (error: ProcessCaptureError): void => {
|
||||
const report = error.cleanupReport;
|
||||
expect(error.reason, error.message).toBe("cleanup_incomplete");
|
||||
@@ -225,7 +228,12 @@ itWithCaptureCapability(
|
||||
const captureSnapshot: typeof snapshotRoots = async () => {
|
||||
snapshotCalls += 1;
|
||||
if (snapshotCalls === 1)
|
||||
return { files: [], truncated: false, completeRoots: [] };
|
||||
return {
|
||||
files: [],
|
||||
truncated: false,
|
||||
completeRoots: [],
|
||||
coverage: emptyFilesystemCoverage,
|
||||
};
|
||||
throw new Error("fixture final snapshot failure");
|
||||
};
|
||||
const cleanupHost: ProcessCaptureCleanupHost = {
|
||||
|
||||
@@ -125,9 +125,7 @@ it.skipIf(CAPTURE_SKIP_REASON || process.platform === "win32")(
|
||||
scope: "filesystem",
|
||||
reason: expect.any(String),
|
||||
});
|
||||
expect(["unknown", "truncated"]).toContain(
|
||||
compareProcessCaptures(capture, capture).filesystem,
|
||||
);
|
||||
expect(compareProcessCaptures(capture, capture).filesystem).toBe("unknown");
|
||||
},
|
||||
20_000,
|
||||
);
|
||||
|
||||
@@ -3,6 +3,10 @@ import { expect, it, vi } from "vitest";
|
||||
import { snapshotRoots } from "../../../src/process/capture/FilesystemSnapshot.js";
|
||||
import { prepareProcessCapture } from "../../../src/process/capture/ProcessCaptureLifecycle.js";
|
||||
import { parseProcessScenario } from "../../../src/domain/process/processScenario.js";
|
||||
import { emptyProcessCapture } from "../../../src/domain/process/processCapture.fixture.js";
|
||||
|
||||
const emptyFilesystemCoverage =
|
||||
emptyProcessCapture().truncation_details.filesystem_before;
|
||||
|
||||
it("prepares ownership inspection before snapshotting or allocating a target run", async () => {
|
||||
const failure = new Error("native process identity inspection unavailable");
|
||||
@@ -53,7 +57,12 @@ it("cleans the temporary root when cancellation arrives during identity capture"
|
||||
working_directory: "/tmp",
|
||||
}),
|
||||
controller.signal,
|
||||
async () => ({ files: [], truncated: false, completeRoots: [] }),
|
||||
async () => ({
|
||||
files: [],
|
||||
truncated: false,
|
||||
completeRoots: [],
|
||||
coverage: emptyFilesystemCoverage,
|
||||
}),
|
||||
host,
|
||||
),
|
||||
).rejects.toThrow(/cancelled/u);
|
||||
|
||||
@@ -116,12 +116,9 @@ itWithCaptureCapability.each(["cli", "mcp"] as const)(
|
||||
expect(compareProcessTraces(result, result, specification).verdict).toBe(
|
||||
"equivalent",
|
||||
);
|
||||
const legacy = parseProcessCapture({
|
||||
...result,
|
||||
truncation_details: undefined,
|
||||
});
|
||||
expect(compareProcessTraces(legacy, legacy, specification).verdict).toBe(
|
||||
"unknown",
|
||||
const { truncation_details: _details, ...withoutCoverage } = result;
|
||||
expect(() => parseProcessCapture(withoutCoverage)).toThrow(
|
||||
"truncation_details",
|
||||
);
|
||||
expect(compareProcessCaptures(result, result)).toMatchObject({
|
||||
terminal: "unknown",
|
||||
|
||||
Reference in New Issue
Block a user