mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 10:25:42 +00:00
Expose one plan/execute replay contract through both CLI and MCP with exact source, input, runtime, sandbox, limit, and export commitments. Run selected ESM and extracted CommonJS/Rspack factories in a disposable Linux x64 Bubblewrap namespace with a content-addressed Node ELF closure, architecture-checked seccomp, delegated systemd cgroup limits, bounded protocol capture, cancellation, and observable cleanup. Preserve left and right observations as Evidence, derive differential comparisons without erasing unknowns, add optional separately authorized reproducers, and fail closed on stale plans or unavailable host boundaries. Add source-owned parser, sanitizer, clipboard, denial, timeout, OOM, protocol-forgery, and cancellation coverage; a real Linux verifier and workflow; regenerated catalogs and TypeDoc; and updated the packaged REA analysis skill for the 83-tool inventory.
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { parseReplayWorkerResponse } from "../src/replay/ReplayWorkerProtocol.js";
|
|
|
|
const digest = "1".repeat(64);
|
|
const cases = [{ case_id: "case-1", sha256: digest }];
|
|
const outcome = {
|
|
case_id: "case-1",
|
|
outcome: "return" as const,
|
|
value: { parsed: true },
|
|
input_sha256: digest,
|
|
output_sha256: null,
|
|
truncated: false as const,
|
|
};
|
|
|
|
describe("replay worker protocol", () => {
|
|
it("accepts only the exact committed case sequence", () => {
|
|
expect(
|
|
parseReplayWorkerResponse(
|
|
{ schema_version: 1, left: [outcome] },
|
|
cases,
|
|
false,
|
|
),
|
|
).toMatchObject({ left: [outcome] });
|
|
expect(() =>
|
|
parseReplayWorkerResponse(
|
|
{ schema_version: 1, left: [{ ...outcome, case_id: "forged" }] },
|
|
cases,
|
|
false,
|
|
),
|
|
).toThrow("case identity changed");
|
|
expect(() =>
|
|
parseReplayWorkerResponse(
|
|
{
|
|
schema_version: 1,
|
|
left: [{ ...outcome, input_sha256: "2".repeat(64) }],
|
|
},
|
|
cases,
|
|
false,
|
|
),
|
|
).toThrow("case identity changed");
|
|
});
|
|
|
|
it("requires the exact differential shape and strict outcomes", () => {
|
|
expect(() =>
|
|
parseReplayWorkerResponse(
|
|
{ schema_version: 1, left: [outcome] },
|
|
cases,
|
|
true,
|
|
),
|
|
).toThrow("differential response is incomplete");
|
|
expect(() =>
|
|
parseReplayWorkerResponse(
|
|
{
|
|
schema_version: 1,
|
|
left: [{ ...outcome, unexpected: true }],
|
|
},
|
|
cases,
|
|
false,
|
|
),
|
|
).toThrow();
|
|
expect(() =>
|
|
parseReplayWorkerResponse(
|
|
{
|
|
schema_version: 1,
|
|
left: [{ ...outcome, outcome: "exception", value: undefined }],
|
|
},
|
|
cases,
|
|
false,
|
|
),
|
|
).toThrow("Exception is missing");
|
|
});
|
|
});
|