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:
@@ -1,10 +1,22 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
accountFullyObservedProcessCapture,
|
||||
compareUnverifiedProcessCaptures as compareProcessCaptures,
|
||||
emptyProcessCapture as emptyCapture,
|
||||
} from "./processCapture.fixture.js";
|
||||
|
||||
const compareFullyObserved = (
|
||||
left: Parameters<typeof compareProcessCaptures>[0],
|
||||
right: Parameters<typeof compareProcessCaptures>[1],
|
||||
options?: Parameters<typeof compareProcessCaptures>[2],
|
||||
) =>
|
||||
compareProcessCaptures(
|
||||
accountFullyObservedProcessCapture(left),
|
||||
accountFullyObservedProcessCapture(right),
|
||||
options,
|
||||
);
|
||||
|
||||
it("compares normalized terminal facts while retaining different source text for audit", () => {
|
||||
const capture = emptyCapture();
|
||||
const frame = { sequence: 0, at_ms: 0, data: "listen:<port> score=20" };
|
||||
@@ -16,11 +28,11 @@ it("compares normalized terminal facts while retaining different source text for
|
||||
...capture,
|
||||
frames: [{ ...frame, raw_data: "listen:9090 score=20" }],
|
||||
};
|
||||
expect(compareProcessCaptures(left, right)).toMatchObject({
|
||||
expect(compareFullyObserved(left, right)).toMatchObject({
|
||||
terminal: "unchanged",
|
||||
});
|
||||
expect(
|
||||
compareProcessCaptures(left, {
|
||||
compareFullyObserved(left, {
|
||||
...right,
|
||||
frames: [{ ...frame, data: "listen:<port> score=21" }],
|
||||
}),
|
||||
@@ -29,7 +41,7 @@ it("compares normalized terminal facts while retaining different source text for
|
||||
|
||||
it("distinguishes added evidence from unknown observations", () => {
|
||||
const capture = emptyCapture();
|
||||
const added = compareProcessCaptures(capture, {
|
||||
const added = compareFullyObserved(capture, {
|
||||
...capture,
|
||||
frames: [{ sequence: 0, at_ms: 0, data: "new" }],
|
||||
rendered_frames: [
|
||||
@@ -53,7 +65,7 @@ it("distinguishes added evidence from unknown observations", () => {
|
||||
["interaction", "interaction"],
|
||||
] as const) {
|
||||
expect(
|
||||
compareProcessCaptures(
|
||||
compareFullyObserved(
|
||||
{
|
||||
...capture,
|
||||
residual_unknowns: [{ scope, reason: "observation was partial" }],
|
||||
@@ -71,7 +83,7 @@ it("distinguishes added evidence from unknown observations", () => {
|
||||
it("compares raw terminal and process observations while honoring normalization shape", () => {
|
||||
const capture = emptyCapture();
|
||||
expect(
|
||||
compareProcessCaptures(capture, {
|
||||
compareFullyObserved(capture, {
|
||||
...capture,
|
||||
normalization: {
|
||||
patterns: [],
|
||||
@@ -86,7 +98,7 @@ it("compares raw terminal and process observations while honoring normalization
|
||||
first_divergence: { status: "none" },
|
||||
});
|
||||
|
||||
const terminal = compareProcessCaptures(
|
||||
const terminal = compareFullyObserved(
|
||||
{ ...capture, frames: [{ sequence: 0, at_ms: 0, data: "bar" }] },
|
||||
{ ...capture, frames: [{ sequence: 0, at_ms: 0, data: "foo\rbar" }] },
|
||||
);
|
||||
@@ -96,7 +108,7 @@ it("compares raw terminal and process observations while honoring normalization
|
||||
});
|
||||
|
||||
expect(
|
||||
compareProcessCaptures(
|
||||
compareFullyObserved(
|
||||
{
|
||||
...capture,
|
||||
process_samples: [
|
||||
@@ -135,7 +147,7 @@ it("keeps filesystem comparison unknown without coverage and reports observed ch
|
||||
{ scope: "filesystem" as const, reason: "watcher unavailable" },
|
||||
],
|
||||
};
|
||||
expect(compareProcessCaptures(incomplete, incomplete)).toMatchObject({
|
||||
expect(compareFullyObserved(incomplete, incomplete)).toMatchObject({
|
||||
filesystem: "unknown",
|
||||
status: "unknown",
|
||||
});
|
||||
@@ -149,7 +161,7 @@ it("keeps filesystem comparison unknown without coverage and reports observed ch
|
||||
symlink_target: null,
|
||||
};
|
||||
expect(
|
||||
compareProcessCaptures(capture, {
|
||||
compareFullyObserved(capture, {
|
||||
...capture,
|
||||
filesystem_checkpoints: [
|
||||
{ name: "before", at_ms: 0, files: [], effects: [], truncated: false },
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { compareProcessCaptures } from "./processComparison.js";
|
||||
import { parseProcessCapture } from "./processCaptureParsing.js";
|
||||
import { EMPTY_PROCESS_CAPTURE_EXAMPLE } from "./processCaptureExample.js";
|
||||
import { hasCaptureTruncation } from "./processCaptureCoverage.js";
|
||||
|
||||
import {
|
||||
processCaptureSchema,
|
||||
@@ -14,6 +15,79 @@ export const emptyProcessCapture = () =>
|
||||
export const emptyUnverifiedProcessCapture = (): UnverifiedProcessCapture =>
|
||||
processCaptureSchema.parse(EMPTY_PROCESS_CAPTURE_EXAMPLE);
|
||||
|
||||
/** Account for every observation retained by a fully observed test fixture. */
|
||||
export const accountFullyObservedProcessCapture = (
|
||||
capture: UnverifiedProcessCapture,
|
||||
): UnverifiedProcessCapture => {
|
||||
const rawBytes = capture.frames.reduce(
|
||||
(total, frame) => total + Buffer.byteLength(frame.raw_data ?? frame.data),
|
||||
0,
|
||||
);
|
||||
const renderedBytes = capture.rendered_frames.reduce(
|
||||
(total, frame) =>
|
||||
frame.lines.reduce(
|
||||
(sum, line) => sum + Buffer.byteLength(line),
|
||||
total + Buffer.byteLength(frame.serialized_state),
|
||||
),
|
||||
0,
|
||||
);
|
||||
const filesystemBefore = {
|
||||
...capture.truncation_details.filesystem_before,
|
||||
hashed_bytes: capture.files_before
|
||||
.filter((file) => file.type === "file" && file.sha256 !== null)
|
||||
.reduce((total, file) => total + file.size, 0),
|
||||
};
|
||||
const filesystemAfter = {
|
||||
...capture.truncation_details.filesystem_after,
|
||||
hashed_bytes: capture.files_after
|
||||
.filter((file) => file.type === "file" && file.sha256 !== null)
|
||||
.reduce((total, file) => total + file.size, 0),
|
||||
};
|
||||
const truncationDetails = {
|
||||
...capture.truncation_details,
|
||||
raw_terminal: {
|
||||
...capture.truncation_details.raw_terminal,
|
||||
observed_bytes: rawBytes,
|
||||
retained_bytes: rawBytes,
|
||||
observed_frames: capture.frames.length,
|
||||
retained_frames: capture.frames.length,
|
||||
},
|
||||
rendered_terminal: {
|
||||
...capture.truncation_details.rendered_terminal,
|
||||
observed_bytes: renderedBytes,
|
||||
retained_bytes: renderedBytes,
|
||||
observed_frames: capture.rendered_frames.length,
|
||||
retained_frames: capture.rendered_frames.length,
|
||||
},
|
||||
filesystem_before: filesystemBefore,
|
||||
filesystem_after: filesystemAfter,
|
||||
process: {
|
||||
...capture.truncation_details.process,
|
||||
sample_limit: Math.max(
|
||||
capture.truncation_details.process.sample_limit,
|
||||
capture.process_samples.length,
|
||||
),
|
||||
retained_samples: capture.process_samples.length,
|
||||
},
|
||||
};
|
||||
const filesystemCheckpoints = capture.filesystem_checkpoints.map(
|
||||
(checkpoint, index) => {
|
||||
const coverage = index === 0 ? filesystemBefore : filesystemAfter;
|
||||
return {
|
||||
...checkpoint,
|
||||
truncated:
|
||||
coverage.enumeration_truncated || coverage.hash_omissions.length > 0,
|
||||
};
|
||||
},
|
||||
);
|
||||
return {
|
||||
...capture,
|
||||
filesystem_checkpoints: filesystemCheckpoints,
|
||||
truncation_details: truncationDetails,
|
||||
truncated: hasCaptureTruncation(truncationDetails),
|
||||
};
|
||||
};
|
||||
|
||||
/** Project validation failures without coupling tests to Zod internals. */
|
||||
export const processCaptureIssues = (
|
||||
capture: UnverifiedProcessCapture,
|
||||
|
||||
@@ -4,7 +4,9 @@ import { jsonValueSchema } from "../jsonValue.js";
|
||||
import { normalizationSchema } from "./processScenario.js";
|
||||
import { collectProcessCaptureIssues } from "./processCaptureValidation.js";
|
||||
import {
|
||||
filesystemCoverageSchema,
|
||||
processCaptureTruncationDetailsSchema,
|
||||
type FilesystemCoverage,
|
||||
type ProcessCaptureTruncationDetails,
|
||||
} from "./processCaptureCoverage.js";
|
||||
|
||||
@@ -66,6 +68,15 @@ export type FileState = FileStateIdentity &
|
||||
}
|
||||
);
|
||||
|
||||
/** Complete metadata returned for one root-aliased filesystem checkpoint. */
|
||||
export interface ProcessFilesystemSnapshot {
|
||||
readonly files: readonly FileState[];
|
||||
readonly truncated: boolean;
|
||||
/** Root aliases whose path enumeration was exhausted, regardless of hash coverage. */
|
||||
readonly completeRoots: readonly string[];
|
||||
readonly coverage: FilesystemCoverage;
|
||||
}
|
||||
|
||||
interface FileEffectIdentity {
|
||||
readonly path: string;
|
||||
}
|
||||
@@ -208,8 +219,8 @@ export interface UnverifiedProcessCapture {
|
||||
readonly files_after: readonly FileState[];
|
||||
readonly filesystem_effects: readonly FileEffect[];
|
||||
readonly truncated: boolean;
|
||||
/** Optional on older captures; identifies each producer's actual coverage. */
|
||||
readonly truncation_details?: ProcessCaptureTruncationDetails | undefined;
|
||||
/** Per-source accounting for the producer's actual capture coverage. */
|
||||
readonly truncation_details: ProcessCaptureTruncationDetails;
|
||||
readonly limitations: readonly string[];
|
||||
readonly residual_unknowns: readonly {
|
||||
readonly scope:
|
||||
@@ -265,14 +276,6 @@ export type PartialProcessObservationField<T> =
|
||||
| { readonly state: "available"; readonly value: T }
|
||||
| { readonly state: "unavailable"; readonly reason: string };
|
||||
|
||||
/** Snapshot facts available before filesystem comparison can be completed. */
|
||||
/** Snapshot facts available before filesystem comparison can be completed. */
|
||||
export interface PartialFilesystemSnapshot {
|
||||
readonly files: readonly FileState[];
|
||||
readonly truncated: boolean;
|
||||
}
|
||||
|
||||
/** Available and unavailable fields when a run never becomes a full capture. */
|
||||
/** Available and unavailable fields when a run never becomes a full capture. */
|
||||
export interface IncompleteProcessCaptureObservations {
|
||||
readonly target_pid: PartialProcessObservationField<number>;
|
||||
@@ -296,8 +299,8 @@ export interface IncompleteProcessCaptureObservations {
|
||||
readonly ProcessSample[]
|
||||
>;
|
||||
readonly filesystem_snapshots: {
|
||||
readonly before: PartialProcessObservationField<PartialFilesystemSnapshot>;
|
||||
readonly after: PartialProcessObservationField<PartialFilesystemSnapshot>;
|
||||
readonly before: PartialProcessObservationField<ProcessFilesystemSnapshot>;
|
||||
readonly after: PartialProcessObservationField<ProcessFilesystemSnapshot>;
|
||||
};
|
||||
readonly event_journal: PartialProcessObservationField<
|
||||
readonly ProcessCaptureEventJournalEntry[]
|
||||
@@ -330,6 +333,13 @@ const fileStateSchema = z.discriminatedUnion("type", [
|
||||
symlink_target: z.null(),
|
||||
}),
|
||||
]);
|
||||
/** Canonical checkpoint facts retained even when capture completion fails. */
|
||||
export const processFilesystemSnapshotSchema = z.strictObject({
|
||||
files: z.array(fileStateSchema),
|
||||
truncated: z.boolean(),
|
||||
completeRoots: z.array(z.string()),
|
||||
coverage: filesystemCoverageSchema,
|
||||
});
|
||||
const fileEffectSchema = z.discriminatedUnion("status", [
|
||||
z.object({
|
||||
path: z.string(),
|
||||
@@ -481,7 +491,7 @@ const processCaptureShapeSchema = z.strictObject({
|
||||
files_after: z.array(fileStateSchema),
|
||||
filesystem_effects: z.array(fileEffectSchema),
|
||||
truncated: z.boolean(),
|
||||
truncation_details: processCaptureTruncationDetailsSchema.optional(),
|
||||
truncation_details: processCaptureTruncationDetailsSchema,
|
||||
limitations: z.array(z.string()),
|
||||
residual_unknowns: z.array(
|
||||
z.object({
|
||||
@@ -545,18 +555,8 @@ const incompleteProcessCaptureObservationsSchema = z.strictObject({
|
||||
processCaptureShapeSchema.shape.process_samples,
|
||||
),
|
||||
filesystem_snapshots: z.strictObject({
|
||||
before: partialObservationFieldSchema(
|
||||
z.strictObject({
|
||||
files: z.array(fileStateSchema),
|
||||
truncated: z.boolean(),
|
||||
}),
|
||||
),
|
||||
after: partialObservationFieldSchema(
|
||||
z.strictObject({
|
||||
files: z.array(fileStateSchema),
|
||||
truncated: z.boolean(),
|
||||
}),
|
||||
),
|
||||
before: partialObservationFieldSchema(processFilesystemSnapshotSchema),
|
||||
after: partialObservationFieldSchema(processFilesystemSnapshotSchema),
|
||||
}),
|
||||
event_journal: partialObservationFieldSchema(
|
||||
processCaptureShapeSchema.shape.event_journal,
|
||||
|
||||
@@ -9,35 +9,20 @@ import {
|
||||
} from "./processCapture.fixture.js";
|
||||
|
||||
it("never considers truncated captures equivalent", () => {
|
||||
const complete = emptyCapture();
|
||||
const capture = {
|
||||
manifest: emptyCapture().manifest,
|
||||
settlement: emptyCapture().settlement,
|
||||
normalization: {
|
||||
paths: true,
|
||||
pids: true,
|
||||
ports: true,
|
||||
time_bucket_ms: 10,
|
||||
patterns: [],
|
||||
},
|
||||
frames: [],
|
||||
rendered_frames: [],
|
||||
interaction_events: [],
|
||||
exit: { code: 0, signal: null, reason: "exited" as const },
|
||||
process_samples: [],
|
||||
filesystem_checkpoints: emptyCapture().filesystem_checkpoints,
|
||||
event_journal: [],
|
||||
files_before: [],
|
||||
files_after: [],
|
||||
filesystem_effects: [],
|
||||
...complete,
|
||||
truncated: true,
|
||||
limitations: [],
|
||||
residual_unknowns: [],
|
||||
cleanup: {
|
||||
owned_process_group: "verified" as const,
|
||||
temporary_root: "removed" as const,
|
||||
truncation_details: {
|
||||
...complete.truncation_details,
|
||||
raw_terminal: {
|
||||
...complete.truncation_details.raw_terminal,
|
||||
observed_bytes: 1,
|
||||
observed_frames: 1,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(compareProcessCaptures(capture, capture).status).toBe("truncated");
|
||||
expect(compareProcessCaptures(capture, capture).status).toBe("unknown");
|
||||
});
|
||||
|
||||
it("rejects altered v4 commitments and accepts canonical key reordering", () => {
|
||||
@@ -66,6 +51,14 @@ it("rejects altered v4 commitments and accepts canonical key reordering", () =>
|
||||
).toThrow("executable_identity");
|
||||
});
|
||||
|
||||
it("requires producer coverage accounting in every parsed capture", () => {
|
||||
const capture = emptyCapture();
|
||||
const { truncation_details: _details, ...missingCoverage } = capture;
|
||||
expect(() => parseProcessCapture(missingCoverage)).toThrow(
|
||||
"truncation_details",
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects settlement and cleanup combinations that cannot occur", () => {
|
||||
const capture = emptyCapture();
|
||||
expect(() =>
|
||||
|
||||
@@ -63,7 +63,7 @@ const omitted = (retention: TerminalRetention): boolean =>
|
||||
const filesystemTruncated = (coverage: FilesystemCoverage): boolean =>
|
||||
coverage.enumeration_truncated || coverage.hash_omissions.length > 0;
|
||||
|
||||
/** Derive the legacy aggregate flag from independent producer observations. */
|
||||
/** Derive the aggregate truncation flag from independent producer observations. */
|
||||
export const hasCaptureTruncation = (
|
||||
details: ProcessCaptureTruncationDetails,
|
||||
): boolean =>
|
||||
@@ -73,13 +73,12 @@ export const hasCaptureTruncation = (
|
||||
filesystemTruncated(details.filesystem_after) ||
|
||||
details.process.sampling_partial;
|
||||
|
||||
/** Older truncated captures lack enough information to localize missing observations. */
|
||||
/** Whether producer accounting reports a gap in the selected observation source. */
|
||||
export const processSourceTruncated = (
|
||||
capture: UnverifiedProcessCapture,
|
||||
source: ProcessObservationSource,
|
||||
): boolean => {
|
||||
const details = capture.truncation_details;
|
||||
if (details === undefined) return capture.truncated;
|
||||
switch (source) {
|
||||
case "terminal_raw":
|
||||
return omitted(details.raw_terminal);
|
||||
|
||||
@@ -59,6 +59,49 @@ export const EMPTY_PROCESS_CAPTURE_EXAMPLE = {
|
||||
files_after: [],
|
||||
filesystem_effects: [],
|
||||
truncated: false,
|
||||
truncation_details: {
|
||||
raw_terminal: {
|
||||
budget_bytes: 1_000_000,
|
||||
observed_bytes: 0,
|
||||
retained_bytes: 0,
|
||||
observed_frames: 0,
|
||||
retained_frames: 0,
|
||||
},
|
||||
rendered_terminal: {
|
||||
budget_bytes: 1_000_000,
|
||||
observed_bytes: 0,
|
||||
retained_bytes: 0,
|
||||
observed_frames: 0,
|
||||
retained_frames: 0,
|
||||
},
|
||||
filesystem_before: {
|
||||
files_limit: 10_000,
|
||||
depth_limit: 16,
|
||||
enumeration_truncated: false,
|
||||
enumeration_reasons: [],
|
||||
hash_budget_bytes: 10_000_000,
|
||||
hashed_bytes: 0,
|
||||
hash_omissions: [],
|
||||
},
|
||||
filesystem_after: {
|
||||
files_limit: 10_000,
|
||||
depth_limit: 16,
|
||||
enumeration_truncated: false,
|
||||
enumeration_reasons: [],
|
||||
hash_budget_bytes: 10_000_000,
|
||||
hashed_bytes: 0,
|
||||
hash_omissions: [],
|
||||
},
|
||||
process: {
|
||||
sample_limit: 1_000,
|
||||
sampling_partial: false,
|
||||
retained_samples: 0,
|
||||
sample_limit_reached: false,
|
||||
sampling_failures: 0,
|
||||
first_sampling_failure: null,
|
||||
coverage: "sampled",
|
||||
},
|
||||
},
|
||||
limitations: [],
|
||||
residual_unknowns: [],
|
||||
cleanup: {
|
||||
|
||||
@@ -127,7 +127,6 @@ const validateCoverage = (
|
||||
require: RequireInvariant,
|
||||
): void => {
|
||||
const details = capture.truncation_details;
|
||||
if (details === undefined) return;
|
||||
require(details.process.retained_samples === capture.process_samples.length &&
|
||||
details.process.retained_samples <= details.process.sample_limit &&
|
||||
details.process.sampling_partial ===
|
||||
|
||||
@@ -291,20 +291,6 @@ const differingContractFields = (
|
||||
)
|
||||
.sort();
|
||||
|
||||
const truncatedComparison = (): ProcessCaptureComparison => ({
|
||||
status: "truncated",
|
||||
terminal: "truncated",
|
||||
interaction: "truncated",
|
||||
exit: "truncated",
|
||||
filesystem: "truncated",
|
||||
process: "truncated",
|
||||
first_divergence: {
|
||||
status: "unknown",
|
||||
reason: "At least one capture is truncated.",
|
||||
},
|
||||
limitations: ["At least one capture is truncated."],
|
||||
});
|
||||
|
||||
const applyTraceVerdict = (
|
||||
dimensions: ComparisonDimensions,
|
||||
specification: ProcessTraceSpecification,
|
||||
@@ -427,18 +413,6 @@ export const compareProcessCaptures = (
|
||||
} = {},
|
||||
): ProcessCaptureComparison => {
|
||||
assertComparable(left, right, options);
|
||||
if (
|
||||
(left.truncated && left.truncation_details === undefined) ||
|
||||
(right.truncated && right.truncation_details === undefined)
|
||||
) {
|
||||
const truncated = truncatedComparison();
|
||||
return options.traceSpecification === undefined
|
||||
? truncated
|
||||
: {
|
||||
...truncated,
|
||||
trace: compareProcessTraces(left, right, options.traceSpecification),
|
||||
};
|
||||
}
|
||||
const sameNormalization = sameJsonValue(
|
||||
left.normalization,
|
||||
right.normalization,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { EMPTY_PROCESS_CAPTURE_EXAMPLE } from "./processCaptureExample.js";
|
||||
import { accountFullyObservedProcessCapture } from "./processCapture.fixture.js";
|
||||
import { compareProcessCaptures } from "./processComparison.js";
|
||||
import { parseProcessCapture } from "./processCaptureParsing.js";
|
||||
import type { ProcessTraceSpecification } from "./processTraceSpecification.js";
|
||||
@@ -94,26 +95,29 @@ describe("declared trace comparison nonconformance", () => {
|
||||
});
|
||||
|
||||
it("does not mask distinct payloads when both traces are nonconforming", () => {
|
||||
const parsedCapture = parseProcessCapture(capture);
|
||||
const withTerminal = (data: string) =>
|
||||
parseProcessCapture({
|
||||
...capture,
|
||||
frames: [{ sequence: 0, at_ms: 1, data }],
|
||||
event_journal: [
|
||||
{
|
||||
capture_order: 0,
|
||||
collection: "filesystem_checkpoints",
|
||||
index: 0,
|
||||
},
|
||||
{ capture_order: 1, collection: "frames", index: 0 },
|
||||
{ capture_order: 2, collection: "lifecycle", index: 0 },
|
||||
{ capture_order: 3, collection: "lifecycle", index: 1 },
|
||||
{
|
||||
capture_order: 4,
|
||||
collection: "filesystem_checkpoints",
|
||||
index: 1,
|
||||
},
|
||||
],
|
||||
});
|
||||
parseProcessCapture(
|
||||
accountFullyObservedProcessCapture({
|
||||
...parsedCapture,
|
||||
frames: [{ sequence: 0, at_ms: 1, data }],
|
||||
event_journal: [
|
||||
{
|
||||
capture_order: 0,
|
||||
collection: "filesystem_checkpoints",
|
||||
index: 0,
|
||||
},
|
||||
{ capture_order: 1, collection: "frames", index: 0 },
|
||||
{ capture_order: 2, collection: "lifecycle", index: 0 },
|
||||
{ capture_order: 3, collection: "lifecycle", index: 1 },
|
||||
{
|
||||
capture_order: 4,
|
||||
collection: "filesystem_checkpoints",
|
||||
index: 1,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
const specification: ProcessTraceSpecification = {
|
||||
events: [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { EMPTY_PROCESS_CAPTURE_EXAMPLE } from "./processCaptureExample.js";
|
||||
import { hasCaptureTruncation } from "./processCaptureCoverage.js";
|
||||
import {
|
||||
parseProcessCapture,
|
||||
type ProcessCapture,
|
||||
@@ -24,11 +25,30 @@ export const capture = (
|
||||
>[];
|
||||
},
|
||||
options: {
|
||||
readonly truncated?: boolean;
|
||||
readonly omittedTerminalFrame?: boolean;
|
||||
readonly residualUnknowns?: ProcessCapture["residual_unknowns"];
|
||||
} = {},
|
||||
): ProcessCapture =>
|
||||
parseProcessCapture({
|
||||
): ProcessCapture => {
|
||||
const omittedTerminalFrame = options.omittedTerminalFrame ?? false;
|
||||
const retainedBytes = values.frames.reduce(
|
||||
(total, frame) => total + Buffer.byteLength(frame.raw_data ?? frame.data),
|
||||
0,
|
||||
);
|
||||
const truncationDetails = {
|
||||
...emptyCapture.truncation_details,
|
||||
raw_terminal: {
|
||||
...emptyCapture.truncation_details.raw_terminal,
|
||||
observed_bytes: retainedBytes + (omittedTerminalFrame ? 1 : 0),
|
||||
retained_bytes: retainedBytes,
|
||||
observed_frames: values.frames.length + (omittedTerminalFrame ? 1 : 0),
|
||||
retained_frames: values.frames.length,
|
||||
},
|
||||
process: {
|
||||
...emptyCapture.truncation_details.process,
|
||||
retained_samples: values.process_samples.length,
|
||||
},
|
||||
};
|
||||
return parseProcessCapture({
|
||||
...emptyCapture,
|
||||
frames: values.frames,
|
||||
process_samples: values.process_samples,
|
||||
@@ -54,9 +74,11 @@ export const capture = (
|
||||
index: 1,
|
||||
},
|
||||
],
|
||||
truncated: options.truncated ?? false,
|
||||
truncated: hasCaptureTruncation(truncationDetails),
|
||||
truncation_details: truncationDetails,
|
||||
residual_unknowns: options.residualUnknowns ?? [],
|
||||
});
|
||||
};
|
||||
|
||||
export const values = (
|
||||
order: readonly ("terminal" | "process")[],
|
||||
|
||||
@@ -219,7 +219,7 @@ describe("unknown process trace evidence", () => {
|
||||
it("never proves equivalence from truncated, unknown, or journal-free evidence", () => {
|
||||
const complete = capture(values(["terminal", "process"]));
|
||||
const truncated = capture(values(["terminal", "process"]), {
|
||||
truncated: true,
|
||||
omittedTerminalFrame: true,
|
||||
});
|
||||
expect(
|
||||
compareProcessTraces(complete, truncated, partialSpecification()).verdict,
|
||||
|
||||
Reference in New Issue
Block a user