* fix(hopper): report unavailable procedure body coverage * refactor!: simplify runtime tools and remove replay engines Keep direct inspection, capture, and comparison tools. Bind handlers to named contracts and let agents compose experiments with commands and local fixture servers. BREAKING CHANGE: Remove controlled replay, Node characterization, finite replay-machine, managed runtime planning, and redundant string-tracing tools. Retire process replay, shims, reactive scenarios, custom checkpoints, and active browser replay and origin-scope inputs.
145 lines
3.7 KiB
TypeScript
145 lines
3.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { EMPTY_PROCESS_CAPTURE_EXAMPLE } from "./processCapture.fixture.js";
|
|
import {
|
|
compareProcessCaptures,
|
|
parseProcessCapture,
|
|
} from "./processCapture.js";
|
|
import type { ProcessTraceSpecification } from "./processTraceComparison.js";
|
|
const beforeCheckpoint = {
|
|
name: "before",
|
|
at_ms: 0,
|
|
files: [],
|
|
effects: [],
|
|
truncated: false,
|
|
};
|
|
const afterCheckpoint = {
|
|
name: "after_settlement",
|
|
at_ms: 50,
|
|
files: [],
|
|
effects: [],
|
|
truncated: false,
|
|
};
|
|
|
|
const capture = {
|
|
...EMPTY_PROCESS_CAPTURE_EXAMPLE,
|
|
event_journal: [
|
|
{ capture_order: 0, collection: "filesystem_checkpoints", index: 0 },
|
|
{ capture_order: 1, collection: "lifecycle", index: 0 },
|
|
{ capture_order: 2, collection: "lifecycle", index: 1 },
|
|
{ capture_order: 3, collection: "filesystem_checkpoints", index: 1 },
|
|
],
|
|
} as const;
|
|
|
|
const traceSpecification: ProcessTraceSpecification = {
|
|
events: [
|
|
{
|
|
id: "before",
|
|
source: "filesystem",
|
|
exact: beforeCheckpoint,
|
|
cardinality: { kind: "required" },
|
|
},
|
|
{
|
|
id: "exit",
|
|
source: "lifecycle",
|
|
exact: { event: "exit", ...capture.exit },
|
|
cardinality: { kind: "required" },
|
|
},
|
|
{
|
|
id: "settlement",
|
|
source: "lifecycle",
|
|
exact: { event: "settlement", ...capture.settlement },
|
|
cardinality: { kind: "required" },
|
|
},
|
|
{
|
|
id: "after",
|
|
source: "filesystem",
|
|
exact: afterCheckpoint,
|
|
cardinality: { kind: "required" },
|
|
},
|
|
],
|
|
language: {
|
|
kind: "finite_traces",
|
|
variants: [
|
|
{
|
|
id: "normal",
|
|
trace: ["before", "exit", "settlement", "after"],
|
|
},
|
|
],
|
|
},
|
|
};
|
|
|
|
describe("declared trace comparison nonconformance", () => {
|
|
it("does not call identical captures changed when both violate the language", () => {
|
|
const parsedCapture = parseProcessCapture(capture);
|
|
const specification: ProcessTraceSpecification = {
|
|
...traceSpecification,
|
|
language: {
|
|
kind: "finite_traces",
|
|
variants: [
|
|
{
|
|
id: "reversed",
|
|
trace: ["after", "settlement", "exit", "before"],
|
|
},
|
|
],
|
|
},
|
|
};
|
|
|
|
expect(
|
|
compareProcessCaptures(parsedCapture, parsedCapture, {
|
|
traceSpecification: specification,
|
|
}),
|
|
).toMatchObject({
|
|
status: "unchanged",
|
|
trace: { verdict: "nonconforming" },
|
|
});
|
|
});
|
|
|
|
it("does not mask distinct payloads when both traces are nonconforming", () => {
|
|
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,
|
|
},
|
|
],
|
|
});
|
|
const specification: ProcessTraceSpecification = {
|
|
events: [
|
|
{
|
|
id: "expected",
|
|
source: "terminal_raw",
|
|
exact: { sequence: 0, at_ms: 1, data: "expected" },
|
|
cardinality: { kind: "required" },
|
|
},
|
|
],
|
|
language: {
|
|
kind: "finite_traces",
|
|
variants: [{ id: "expected", trace: ["expected"] }],
|
|
},
|
|
};
|
|
|
|
expect(
|
|
compareProcessCaptures(withTerminal("left"), withTerminal("right"), {
|
|
traceSpecification: specification,
|
|
}),
|
|
).toMatchObject({
|
|
status: "changed",
|
|
terminal: "changed",
|
|
trace: { verdict: "nonconforming" },
|
|
});
|
|
});
|
|
});
|