refactor!: simplify runtime tools and remove replay engines (#572)

* 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.
This commit is contained in:
morluto
2026-10-05 21:15:04 +08:00
committed by GitHub
parent c6d3bdf597
commit e07b81649e
258 changed files with 1193 additions and 22444 deletions
+102 -127
View File
@@ -8,125 +8,69 @@ import {
import {
capture,
partialSpecification,
processStarted,
terminal,
values,
websocket,
} from "./processTraceComparison.fixture.js";
describe("process trace comparison: declared schedules", () => {
it("accepts only explicitly declared concurrent schedules without timestamp causality", () => {
const left = capture(values(["terminal", "process", "http", "websocket"]));
const right = capture(values(["terminal", "http", "process", "websocket"]));
const comparison = compareProcessTraces(
left,
right,
partialSpecification(),
);
expect(comparison.verdict).toBe("equivalent");
expect(comparison.left.raw_trace.map(({ event_id }) => event_id)).toEqual([
"ready",
"worker",
"status",
"done",
]);
expect(comparison.right.raw_trace.map(({ event_id }) => event_id)).toEqual([
"ready",
"status",
"worker",
"done",
]);
expect(comparison.left.satisfied_constraints).toContain(
"unordered:worker:status",
);
});
it("returns the minimal journal slice for a reversed required edge", () => {
const baseline = capture(
values(["terminal", "process", "http", "websocket"]),
);
const reversed = capture(
values(["process", "terminal", "http", "websocket"]),
);
const comparison = compareProcessTraces(
baseline,
reversed,
partialSpecification(),
);
expect(comparison).toMatchObject({
describe("generic capture trace comparison", () => {
it("requires explicit partial ordering and never infers causality from timestamps", () => {
const specification = partialSpecification();
const left = capture(values(["terminal", "process"]));
const right = capture(values(["process", "terminal"]));
expect(compareProcessTraces(left, right, specification)).toMatchObject({
verdict: "different",
diagnostic: {
kind: "edge",
side: "right",
event_ids: ["ready", "worker"],
locations: [{ capture_order: 2 }, { capture_order: 1 }],
},
diagnostic: { kind: "edge", side: "right" },
});
expect(
processTraceComparisonResultSchema.safeParse({
...comparison,
right: { ...comparison.right, matched_variant: "invented" },
}).success,
).toBe(false);
});
it("enforces explicit negative not-before constraints", () => {
const specification: ProcessTraceSpecification = {
events: [
{
id: "ready",
source: "terminal_raw",
exact: terminal,
cardinality: { kind: "required" },
},
{
id: "done",
source: "websocket",
exact: websocket,
cardinality: { kind: "required" },
},
],
const concurrent: ProcessTraceSpecification = {
...specification,
language: {
kind: "partial_order",
happens_before: [],
not_before: [{ event: "done", anchor: "ready" }],
unordered_groups: [],
not_before: [],
unordered_groups: [{ events: ["ready", "worker"] }],
prefix: [],
suffix: [],
},
};
const normal = capture(
values(["terminal", "process", "http", "websocket"]),
);
const invalid = capture(
values(["websocket", "terminal", "process", "http"]),
);
expect(compareProcessTraces(normal, invalid, specification)).toMatchObject({
verdict: "different",
diagnostic: {
kind: "edge",
side: "right",
event_ids: ["done", "ready"],
},
expect(compareProcessTraces(left, right, concurrent)).toMatchObject({
verdict: "equivalent",
});
});
it("rejects malformed result contracts", () => {
const result = compareProcessTraces(
capture(values(["terminal", "process"])),
capture(values(["terminal", "process"])),
partialSpecification(),
);
expect(
processTraceComparisonResultSchema.safeParse({
...result,
right: {
...result.right,
status: "fail",
matched_variant: "invented",
},
}).success,
).toBe(false);
});
it("supports declared optional events and bounded duplicates", () => {
const first = { sequence: 0, at_ms: 1, data: "tick" };
const second = { sequence: 1, at_ms: 2, data: "tick" };
const one = capture({
frames: [first],
process_samples: [],
filesystem_checkpoints: [],
protocol_events: [],
shim_events: [],
event_journal: [{ capture_order: 0, collection: "frames", index: 0 }],
event_journal: [{ collection: "frames", index: 0 }],
});
const two = capture({
frames: [first, second],
process_samples: [],
filesystem_checkpoints: [],
protocol_events: [],
shim_events: [],
event_journal: [
{ capture_order: 0, collection: "frames", index: 0 },
{ capture_order: 1, collection: "frames", index: 1 },
{ collection: "frames", index: 0 },
{ collection: "frames", index: 1 },
],
});
const specification: ProcessTraceSpecification = {
@@ -160,8 +104,8 @@ describe("process trace comparison: declared schedules", () => {
});
});
describe("process trace comparison: evidence sufficiency", () => {
it("enforces exact and range cardinality for one repeated predicate", () => {
describe("process trace constraints and evidence sufficiency", () => {
it("enforces exact and range cardinality for a repeated terminal observation", () => {
const repeated = (count: number) =>
capture({
frames: Array.from({ length: count }, (_, sequence) => ({
@@ -170,11 +114,7 @@ describe("process trace comparison: evidence sufficiency", () => {
data: "tick",
})),
process_samples: [],
filesystem_checkpoints: [],
protocol_events: [],
shim_events: [],
event_journal: Array.from({ length: count }, (_, index) => ({
capture_order: index,
collection: "frames" as const,
index,
})),
@@ -214,6 +154,7 @@ describe("process trace comparison: evidence sufficiency", () => {
verdict: "different",
diagnostic: { kind: "cardinality", side: "right" },
});
const exactSpecification: ProcessTraceSpecification = {
events: [{ ...event, cardinality: { kind: "exact", count: 2 } }],
language: {
@@ -231,43 +172,77 @@ describe("process trace comparison: evidence sufficiency", () => {
diagnostic: { kind: "cardinality", side: "left" },
});
});
it("enforces an explicit not-before relation between terminal and process events", () => {
const specification: ProcessTraceSpecification = {
events: [
{
id: "ready",
source: "terminal_raw",
exact: terminal,
cardinality: { kind: "required" },
},
{
id: "worker",
source: "process",
exact: processStarted,
cardinality: { kind: "required" },
},
],
language: {
kind: "partial_order",
happens_before: [],
not_before: [{ event: "ready", anchor: "worker" }],
unordered_groups: [],
prefix: [],
suffix: [],
},
};
const readyFirst = capture(values(["terminal", "process"]));
const workerFirst = capture(values(["process", "terminal"]));
expect(
compareProcessTraces(workerFirst, readyFirst, specification),
).toMatchObject({
verdict: "different",
diagnostic: {
kind: "edge",
side: "right",
event_ids: ["ready", "worker"],
},
});
expect(
compareProcessTraces(workerFirst, workerFirst, specification),
).toMatchObject({ verdict: "equivalent" });
});
it("never proves equivalence from truncated, unknown, or journal-free evidence", () => {
const complete = capture(
values(["terminal", "process", "http", "websocket"]),
);
const truncated = capture(
values(["terminal", "process", "http", "websocket"]),
{ truncated: true },
);
const complete = capture(values(["terminal", "process"]));
const truncated = capture(values(["terminal", "process"]), {
truncated: true,
});
expect(
compareProcessTraces(complete, truncated, partialSpecification()).verdict,
).toBe("unknown");
const unknown = capture(
values(["terminal", "process", "http", "websocket"]),
{ residualUnknowns: [{ scope: "protocol", reason: "gap" }] },
);
const unknown = capture(values(["terminal", "process"]), {
residualUnknowns: [{ scope: "process", reason: "sampled" }],
});
expect(
compareProcessTraces(complete, unknown, partialSpecification()).verdict,
).toBe("unknown");
const noJournal = parseProcessCapture({
...complete,
event_journal: [],
});
const comparison = compareProcessTraces(
complete,
noJournal,
partialSpecification(),
);
expect(comparison).toMatchObject({
const noJournal = parseProcessCapture({ ...complete, event_journal: [] });
expect(
compareProcessTraces(complete, noJournal, partialSpecification()),
).toMatchObject({
verdict: "unknown",
diagnostic: { kind: "journal", side: "right" },
});
const incompleteJournal = {
...complete,
event_journal: (complete.event_journal ?? []).slice(1),
};
expect(() => parseProcessCapture(incompleteJournal)).toThrow(
"Invalid process capture: event_journal.0.capture_order",
);
expect(() =>
parseProcessCapture({
...complete,
event_journal: (complete.event_journal ?? []).slice(1),
}),
).toThrow("event_journal");
});
});