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:
@@ -53,7 +53,6 @@ export function browserScenario(browser, origin) {
|
||||
},
|
||||
],
|
||||
},
|
||||
allowed_origins: [origin],
|
||||
environment: {
|
||||
viewport: { width: 1_280, height: 720, device_scale_factor: 1.25 },
|
||||
locale: "en-US",
|
||||
@@ -83,7 +82,6 @@ export function browserScenario(browser, origin) {
|
||||
},
|
||||
],
|
||||
storage: duplicateOriginStorage(origin),
|
||||
request_replay: { mode: "disabled" },
|
||||
secrets: [
|
||||
{
|
||||
secret_id: "verifier_url",
|
||||
|
||||
@@ -77,7 +77,6 @@ export async function verifyLargeScreenshotE2e(endpoint, origin) {
|
||||
name: "capture_web_screenshot",
|
||||
arguments: {
|
||||
cdp_endpoint: endpoint,
|
||||
allowed_origins: [origin],
|
||||
target_id: target.id,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -93,11 +93,6 @@ const sourceOwnedClaims = ({
|
||||
scenarioId: "decompiler-reconstruction-import",
|
||||
targets: [obfuscated.target],
|
||||
}),
|
||||
completionClaim({
|
||||
claimId: "managed.runtime-correlation-admission-plan",
|
||||
scenarioId: "runtime-correlation-admission-plan",
|
||||
targets: [obfuscated.target],
|
||||
}),
|
||||
completionClaim({
|
||||
claimId: "managed.mvid-and-token-drift",
|
||||
scenarioId: "mvid-and-token-drift",
|
||||
|
||||
@@ -82,7 +82,7 @@ try {
|
||||
"depth = 1",
|
||||
],
|
||||
["static", "inferred"],
|
||||
["runtime", "replay"],
|
||||
["runtime", "behavioral probes"],
|
||||
],
|
||||
prompt: `Without directly reading target files, compare the default export in parser.mjs between ${targets.javascriptShapeLeft} and ${targets.javascriptShapeRight}. Use REA to analyze each shipped artifact and then compare its exact static export return shapes. State the exact heading-shape change, cite produced Evidence, and distinguish static inference from runtime semantics.`,
|
||||
},
|
||||
@@ -283,13 +283,13 @@ async function createTargets(root, includeManaged) {
|
||||
mkdir(javascriptShapeRight, { recursive: true }),
|
||||
]);
|
||||
await Promise.all([
|
||||
cp(
|
||||
join(repositoryRoot, "tests/fixtures/replay/parser.mjs"),
|
||||
writeFile(
|
||||
join(javascriptShapeLeft, "parser.mjs"),
|
||||
'export default function parse() { return { heading: "Title" }; }\n',
|
||||
),
|
||||
cp(
|
||||
join(repositoryRoot, "tests/fixtures/replay/parser-v2.mjs"),
|
||||
writeFile(
|
||||
join(javascriptShapeRight, "parser.mjs"),
|
||||
'export default function parse() { return { heading: { text: "Title", level: 1 } }; }\n',
|
||||
),
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import assert from "node:assert/strict";
|
||||
@@ -9,7 +9,6 @@ import { inspectManagedNativeBoundariesBytes } from "../dist/dotnet/ManagedNativ
|
||||
import { compareManagedMemberPaths } from "../dist/application/ManagedMemberComparisonService.js";
|
||||
import { verifyManagedNativeBoundariesEvidence } from "../dist/application/ManagedNativeVerificationService.js";
|
||||
import { importManagedReconstructionEvidence } from "../dist/application/ManagedReconstructionService.js";
|
||||
import { planManagedRuntimeCorrelationEvidence } from "../dist/application/ManagedRuntimeCorrelationService.js";
|
||||
import { projectManagedApplicationGraphEvidence } from "../dist/application/ManagedApplicationGraphService.js";
|
||||
import { traceApplicationFeatureEvidence } from "../dist/application/JavaScriptApplicationWorkflowService.js";
|
||||
import { MANAGED_STATIC_PROVIDER } from "../dist/application/InvestigationProviders.js";
|
||||
@@ -249,9 +248,8 @@ try {
|
||||
assert.equal(obfuscatedMembers.types[0]?.full_name, "Fixture.ꙮType");
|
||||
assert.equal(obfuscatedMembers.methods[0]?.name, "λ⛧");
|
||||
assert.equal(obfuscatedMembers.fields[0]?.name, "字段");
|
||||
const runtimeExecutable = process.execPath;
|
||||
const runtimeMethod = obfuscatedMembers.methods[0];
|
||||
assert.ok(runtimeMethod);
|
||||
const reconstructionMethod = obfuscatedMembers.methods[0];
|
||||
assert.ok(reconstructionMethod);
|
||||
const obfuscatedMembersEvidence = createEvidence(
|
||||
undefined,
|
||||
MANAGED_STATIC_PROVIDER,
|
||||
@@ -274,9 +272,9 @@ try {
|
||||
},
|
||||
methods: [
|
||||
{
|
||||
token: runtimeMethod.token,
|
||||
signature_sha256: runtimeMethod.signature.raw_sha256,
|
||||
normalized_il_sha256: runtimeMethod.body.normalized_il_sha256,
|
||||
token: reconstructionMethod.token,
|
||||
signature_sha256: reconstructionMethod.signature.raw_sha256,
|
||||
normalized_il_sha256: reconstructionMethod.body.normalized_il_sha256,
|
||||
reconstruction: {
|
||||
kind: "decompiled-csharp",
|
||||
language: "csharp",
|
||||
@@ -293,45 +291,6 @@ try {
|
||||
false,
|
||||
);
|
||||
assert.equal(reconstructionImport.value.confidence, "inferred");
|
||||
const runtimePlan = await planManagedRuntimeCorrelationEvidence(
|
||||
{ configuration: () => ({ executablePath: runtimeExecutable }) },
|
||||
{
|
||||
static_members: obfuscatedMembersEvidence,
|
||||
method: {
|
||||
token: runtimeMethod.token,
|
||||
signature_sha256: runtimeMethod.signature.raw_sha256,
|
||||
normalized_il_sha256: runtimeMethod.body.normalized_il_sha256,
|
||||
},
|
||||
requested_effect: "debugger",
|
||||
host: {
|
||||
os: "linux",
|
||||
clr_family: "dotnet",
|
||||
architecture: "x86_64",
|
||||
},
|
||||
bounds: {
|
||||
timeout_ms: 5_000,
|
||||
max_threads: 32,
|
||||
max_output_bytes: 65_536,
|
||||
allow_network: false,
|
||||
allow_ui: false,
|
||||
},
|
||||
},
|
||||
);
|
||||
assert.equal(runtimePlan.ok, true);
|
||||
assert.equal(runtimePlan.value.normalized_result.executed, false);
|
||||
assert.equal(
|
||||
runtimePlan.value.normalized_result.unsupported_until_executor_exists,
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
runtimePlan.value.normalized_result.effect_taxonomy.uses_debugger,
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
runtimePlan.value.normalized_result.requested_runtime.confinement,
|
||||
"not-established",
|
||||
);
|
||||
|
||||
const left = await fixture("token-drift-left.exe", {
|
||||
methodName: "StableSemanticSlice",
|
||||
});
|
||||
@@ -410,7 +369,7 @@ try {
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({
|
||||
verified:
|
||||
12 +
|
||||
11 +
|
||||
(operatorManifest === null ? 0 : 1) +
|
||||
(ilspyOracle === null ? 0 : 1),
|
||||
managedSurfaces: [
|
||||
@@ -420,7 +379,6 @@ try {
|
||||
"compare_managed_members",
|
||||
"verify_managed_native_boundaries",
|
||||
"import_managed_reconstruction",
|
||||
"plan_managed_runtime_correlation",
|
||||
"project_managed_application_graph",
|
||||
],
|
||||
coverage: [
|
||||
@@ -431,7 +389,6 @@ try {
|
||||
"managed-application-graph-projection",
|
||||
"unicode-obfuscated-identifiers",
|
||||
"decompiler-reconstruction-import",
|
||||
"runtime-correlation-admission-plan",
|
||||
"mvid-and-token-drift",
|
||||
"not-managed",
|
||||
"malformed-metadata",
|
||||
|
||||
@@ -115,69 +115,6 @@ const verifyManagedReconstruction = async ({
|
||||
throw new Error("packaged managed reconstruction import CLI failed");
|
||||
};
|
||||
|
||||
const verifyManagedRuntimePlan = async ({
|
||||
cli,
|
||||
managedMembers,
|
||||
managedMethod,
|
||||
workspace,
|
||||
environment,
|
||||
}) => {
|
||||
const managedRuntimePlanInput = {
|
||||
static_members: managedMembers,
|
||||
method: {
|
||||
token: managedMethod.token,
|
||||
signature_sha256: managedMethod.signature.raw_sha256,
|
||||
normalized_il_sha256: managedMethod.body.normalized_il_sha256,
|
||||
},
|
||||
requested_effect: "attach",
|
||||
host: {
|
||||
os: "linux",
|
||||
clr_family: "dotnet",
|
||||
architecture: "x86_64",
|
||||
},
|
||||
bounds: {
|
||||
timeout_ms: 5_000,
|
||||
max_threads: 32,
|
||||
max_output_bytes: 65_536,
|
||||
allow_network: false,
|
||||
allow_ui: false,
|
||||
},
|
||||
};
|
||||
const managedRuntimePlan = json(
|
||||
await run(
|
||||
cli,
|
||||
[
|
||||
"plan-managed-runtime-correlation",
|
||||
JSON.stringify(managedRuntimePlanInput),
|
||||
"--json",
|
||||
],
|
||||
{
|
||||
...environment,
|
||||
REA_MANAGED_RUNTIME_EXECUTABLE_PATH: process.execPath,
|
||||
},
|
||||
),
|
||||
);
|
||||
if (
|
||||
managedRuntimePlan.operation !== "plan_managed_runtime_correlation" ||
|
||||
managedRuntimePlan.provider?.id !== "rea-dotnet-workflows" ||
|
||||
managedRuntimePlan.normalized_result?.executed !== false ||
|
||||
managedRuntimePlan.normalized_result?.unsupported_until_executor_exists !==
|
||||
true ||
|
||||
managedRuntimePlan.normalized_result?.effect_taxonomy?.attaches_process !==
|
||||
true ||
|
||||
managedRuntimePlan.normalized_result?.effect_taxonomy
|
||||
?.invokes_target_code !== false
|
||||
)
|
||||
throw new Error("packaged managed runtime-correlation CLI failed");
|
||||
if (
|
||||
managedRuntimePlan.normalized_result?.requested_runtime?.confinement !==
|
||||
"not-established"
|
||||
)
|
||||
throw new Error(
|
||||
"packaged managed runtime plan claimed unverified confinement",
|
||||
);
|
||||
};
|
||||
|
||||
const verifyManagedBoundaries = async ({ cli, managedPath, environment }) => {
|
||||
const managedBoundaries = json(
|
||||
await run(
|
||||
@@ -363,13 +300,6 @@ export async function verifyManaged({ cli, workspace, environment }) {
|
||||
managedMethod,
|
||||
environment,
|
||||
});
|
||||
await verifyManagedRuntimePlan({
|
||||
cli,
|
||||
managedMembers,
|
||||
managedMethod,
|
||||
workspace,
|
||||
environment,
|
||||
});
|
||||
const managedBoundaries = await verifyManagedBoundaries({
|
||||
cli,
|
||||
managedPath,
|
||||
|
||||
@@ -117,7 +117,7 @@ try {
|
||||
evidenceRoot,
|
||||
});
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({ verifier_run: await completeVerifierRun(verifierRun), cli: true, analysisCli: true, artifactCli: true, managedCli: true, managedReconstructionCli: true, managedNativeVerificationCli: true, managedRuntimePlanCli: true, managedApplicationGraphCli: true, evidenceCli: true, incurMcpCommand: PRODUCT_IDENTITY.mcpCommand, lifecycleScriptsRequired: false, doctor: "platform-appropriate", setup: supportedSetupHost ? "planned-then-idempotent" : "unsupported-host-rejected", setupPlanReadOnly: supportedSetupHost, existingHopperPreserved: supportedSetupHost, clients: supportedSetupHost ? 3 : 0, backupReadback: supportedSetupHost, failureRecovery: supportedSetupHost, configSymlinkLifecycle: supportedSetupHost, skill: supportedSetupHost, skillReferences: supportedSetupHost, mcpTools: TOOL_CONTRACTS.length, mcpPrompts: prompts.names.length, promptCompletion: true, promptCompletionLifecycle: true, evidenceMcp: true, targetFree: true, targetLifecycle: true, boundedRegexBridge: true, mcpStartup, mcpModuleLoading })}\n`,
|
||||
`${JSON.stringify({ verifier_run: await completeVerifierRun(verifierRun), cli: true, analysisCli: true, artifactCli: true, managedCli: true, managedReconstructionCli: true, managedNativeVerificationCli: true, managedApplicationGraphCli: true, evidenceCli: true, incurMcpCommand: PRODUCT_IDENTITY.mcpCommand, lifecycleScriptsRequired: false, doctor: "platform-appropriate", setup: supportedSetupHost ? "planned-then-idempotent" : "unsupported-host-rejected", setupPlanReadOnly: supportedSetupHost, existingHopperPreserved: supportedSetupHost, clients: supportedSetupHost ? 3 : 0, backupReadback: supportedSetupHost, failureRecovery: supportedSetupHost, configSymlinkLifecycle: supportedSetupHost, skill: supportedSetupHost, skillReferences: supportedSetupHost, mcpTools: TOOL_CONTRACTS.length, mcpPrompts: prompts.names.length, promptCompletion: true, promptCompletionLifecycle: true, evidenceMcp: true, targetFree: true, targetLifecycle: true, boundedRegexBridge: true, mcpStartup, mcpModuleLoading })}\n`,
|
||||
);
|
||||
} finally {
|
||||
if (tarball) await rm(join(root, tarball), { force: true });
|
||||
|
||||
@@ -82,7 +82,7 @@ try {
|
||||
});
|
||||
const endpoint = `http://127.0.0.1:${String(port)}`;
|
||||
const provider = new CdpBrowserProvider();
|
||||
const target = await pageTarget(provider, endpoint, site.origin);
|
||||
const target = await pageTarget(provider, endpoint);
|
||||
const observed = await provider.inspectPage(
|
||||
inspectWebPageInputSchema.parse({
|
||||
cdp_endpoint: endpoint,
|
||||
@@ -355,7 +355,7 @@ try {
|
||||
}
|
||||
|
||||
async function verifyPageScopedTransport(provider, proxy, origin) {
|
||||
const target = await pageTarget(provider, proxy.endpoint, origin);
|
||||
const target = await pageTarget(provider, proxy.endpoint);
|
||||
const input = inspectWebPageInputSchema.parse({
|
||||
cdp_endpoint: proxy.endpoint,
|
||||
allowed_origins: [origin],
|
||||
@@ -432,12 +432,11 @@ async function browserExecutable() {
|
||||
);
|
||||
}
|
||||
|
||||
async function pageTarget(provider, endpoint, origin) {
|
||||
async function pageTarget(provider, endpoint) {
|
||||
for (let attempt = 0; attempt < 100; attempt += 1) {
|
||||
const listed = await provider.listTargets(
|
||||
listBrowserTargetsInputSchema.parse({
|
||||
cdp_endpoint: endpoint,
|
||||
allowed_origins: [origin],
|
||||
}),
|
||||
);
|
||||
if (listed.ok && listed.value.targets[0] !== undefined)
|
||||
|
||||
@@ -1,314 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { readFile, realpath } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import { runControlledReplay } from "../dist/application/JavaScriptReplayService.js";
|
||||
import { LinuxJavaScriptReplayRunner } from "../dist/replay/LinuxJavaScriptReplayRunner.js";
|
||||
import { SystemJavaScriptReplayHost } from "../dist/replay/SystemJavaScriptReplayHost.js";
|
||||
import { completeVerifierRun, createVerifierRun } from "./lib/verifier-run.mjs";
|
||||
|
||||
const verifierRun = createVerifierRun();
|
||||
|
||||
const suppliedInputPath = process.env.REA_REPLAY_INPUT_PATH;
|
||||
const suppliedInput =
|
||||
suppliedInputPath === undefined
|
||||
? undefined
|
||||
: JSON.parse(await readFile(await realpath(suppliedInputPath), "utf8"));
|
||||
const canonicalSide = async (side) => ({
|
||||
...side,
|
||||
modules: await Promise.all(
|
||||
side.modules.map(async (module) => ({
|
||||
...module,
|
||||
path: await realpath(module.path),
|
||||
})),
|
||||
),
|
||||
});
|
||||
const leftPath = await realpath(
|
||||
process.env.REA_REPLAY_LEFT_PATH ??
|
||||
resolve("tests/fixtures/replay/parser.mjs"),
|
||||
);
|
||||
const rightPath = await realpath(
|
||||
process.env.REA_REPLAY_RIGHT_PATH ??
|
||||
resolve("tests/fixtures/replay/parser-v2.mjs"),
|
||||
);
|
||||
const suppliedLeft =
|
||||
suppliedInput === undefined
|
||||
? undefined
|
||||
: await canonicalSide(suppliedInput.left);
|
||||
const suppliedRight =
|
||||
suppliedInput?.right === undefined
|
||||
? undefined
|
||||
: await canonicalSide(suppliedInput.right);
|
||||
const configuration = {
|
||||
nodePath: process.execPath,
|
||||
bubblewrapPath:
|
||||
process.env.REA_JAVASCRIPT_REPLAY_BWRAP_PATH ?? "/usr/bin/bwrap",
|
||||
systemdRunPath:
|
||||
process.env.REA_JAVASCRIPT_REPLAY_SYSTEMD_RUN_PATH ??
|
||||
"/usr/bin/systemd-run",
|
||||
systemctlPath:
|
||||
process.env.REA_JAVASCRIPT_REPLAY_SYSTEMCTL_PATH ?? "/usr/bin/systemctl",
|
||||
shellPath: process.env.REA_JAVASCRIPT_REPLAY_SHELL_PATH ?? "/usr/bin/bash",
|
||||
};
|
||||
const dependencies = {
|
||||
configuration: () => configuration,
|
||||
host: new SystemJavaScriptReplayHost(),
|
||||
runner: new LinuxJavaScriptReplayRunner(),
|
||||
};
|
||||
const defaultInput = {
|
||||
mode: "plan",
|
||||
left: {
|
||||
modules: [
|
||||
{
|
||||
alias: "parser",
|
||||
path: leftPath,
|
||||
format: "esm",
|
||||
role: "module",
|
||||
dependencies: {},
|
||||
},
|
||||
],
|
||||
entry_alias: "parser",
|
||||
entry_export: "default",
|
||||
},
|
||||
right: {
|
||||
modules: [
|
||||
{
|
||||
alias: "parser",
|
||||
path: rightPath,
|
||||
format: "esm",
|
||||
role: "module",
|
||||
dependencies: {},
|
||||
},
|
||||
],
|
||||
entry_alias: "parser",
|
||||
entry_export: "default",
|
||||
},
|
||||
cases: [
|
||||
{ case_id: "heading", arguments: ["# Title"] },
|
||||
{ case_id: "plain", arguments: ["plain"] },
|
||||
],
|
||||
generator: { preset: "parser-boundaries", seed: 7, count: 4 },
|
||||
};
|
||||
const suppliedPlanInput =
|
||||
suppliedInput === undefined
|
||||
? undefined
|
||||
: (({ approved: _approved, plan_digest: _planDigest, ...planInput }) =>
|
||||
planInput)(suppliedInput);
|
||||
const input =
|
||||
suppliedPlanInput === undefined
|
||||
? defaultInput
|
||||
: {
|
||||
...suppliedPlanInput,
|
||||
mode: "plan",
|
||||
left: suppliedLeft,
|
||||
...(suppliedRight === undefined ? {} : { right: suppliedRight }),
|
||||
reproducer_export: undefined,
|
||||
};
|
||||
|
||||
const planned = await runControlledReplay(dependencies, input);
|
||||
if (!planned.ok) {
|
||||
if (process.env.REA_REPLAY_ALLOW_UNAVAILABLE === "true") {
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({ verifier_run: await completeVerifierRun(verifierRun), available: false, error_tag: planned.error._tag })}\n`,
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
throw planned.error;
|
||||
}
|
||||
const plan = planned.value.plan;
|
||||
if (plan === null || typeof plan.plan_digest !== "string")
|
||||
throw new Error("Real replay verifier did not receive a plan");
|
||||
const executed = await runControlledReplay(dependencies, {
|
||||
...input,
|
||||
mode: "execute",
|
||||
plan_digest: plan.plan_digest,
|
||||
});
|
||||
if (!executed.ok) throw executed.error;
|
||||
const evidence = executed.value.evidence;
|
||||
if (
|
||||
evidence === null ||
|
||||
evidence.authority !== "controlled-replay" ||
|
||||
evidence.environment?.isolation !== "container" ||
|
||||
evidence.normalized_result.termination !== "completed" ||
|
||||
evidence.normalized_result.cleanup.state !== "complete" ||
|
||||
evidence.normalized_result.comparison?.some(
|
||||
({ status }) => status === "unknown",
|
||||
) === true
|
||||
)
|
||||
throw new Error(
|
||||
`Real replay verifier received incomplete Evidence: ${JSON.stringify({
|
||||
authority: evidence?.authority ?? null,
|
||||
isolation: evidence?.environment?.isolation ?? null,
|
||||
termination: evidence?.normalized_result?.termination ?? null,
|
||||
cleanup: evidence?.normalized_result?.cleanup?.state ?? null,
|
||||
outcomes:
|
||||
evidence?.normalized_result?.outcomes?.map(({ outcome }) => outcome) ??
|
||||
[],
|
||||
stderr: evidence?.normalized_result?.stderr ?? null,
|
||||
comparison_statuses:
|
||||
evidence?.normalized_result?.comparison?.map(({ status }) => status) ??
|
||||
[],
|
||||
})}`,
|
||||
);
|
||||
|
||||
if (suppliedInput !== undefined) {
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({
|
||||
verifier_run: await completeVerifierRun(verifierRun),
|
||||
available: true,
|
||||
supplied_manifest: true,
|
||||
plan_digest: plan.plan_digest,
|
||||
evidence_id: evidence.evidence_id,
|
||||
source_evidence_ids: executed.value.source_evidence.map(
|
||||
({ evidence_id: id }) => id,
|
||||
),
|
||||
left_sha256: plan.left.modules.map(({ sha256 }) => sha256),
|
||||
right_sha256: plan.right?.modules.map(({ sha256 }) => sha256) ?? [],
|
||||
cases: plan.cases.length,
|
||||
comparison:
|
||||
evidence.normalized_result.comparison?.map(({ case_id, status }) => ({
|
||||
case_id,
|
||||
status,
|
||||
})) ?? [],
|
||||
cleanup: evidence.normalized_result.cleanup.state,
|
||||
})}\n`,
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const runSingle = async (path, limits = undefined) => {
|
||||
const manifest = {
|
||||
mode: "plan",
|
||||
left: {
|
||||
modules: [
|
||||
{
|
||||
alias: "entry",
|
||||
path: await realpath(path),
|
||||
format: "esm",
|
||||
role: "module",
|
||||
dependencies: {},
|
||||
},
|
||||
],
|
||||
entry_alias: "entry",
|
||||
entry_export: "default",
|
||||
},
|
||||
cases: [{ case_id: "probe", arguments: [] }],
|
||||
...(limits === undefined ? {} : { limits }),
|
||||
};
|
||||
const proposed = await runControlledReplay(dependencies, manifest);
|
||||
if (!proposed.ok || proposed.value.plan === null)
|
||||
throw new Error("Replay conformance plan failed");
|
||||
const observed = await runControlledReplay(dependencies, {
|
||||
...manifest,
|
||||
mode: "execute",
|
||||
plan_digest: proposed.value.plan.plan_digest,
|
||||
});
|
||||
if (!observed.ok || observed.value.evidence === null)
|
||||
throw new Error("Replay conformance execution failed");
|
||||
return observed.value.evidence.normalized_result;
|
||||
};
|
||||
|
||||
const sideEffects = await runSingle(
|
||||
resolve("tests/fixtures/replay/side-effect-attempt.mjs"),
|
||||
);
|
||||
if (
|
||||
sideEffects.outcomes[0]?.outcome !== "return" ||
|
||||
Object.values(sideEffects.outcomes[0].value).some(
|
||||
(value) => value !== "undefined",
|
||||
)
|
||||
)
|
||||
throw new Error("Ambient side-effect surface was exposed to replay code");
|
||||
|
||||
const timeout = await runSingle(
|
||||
resolve("tests/fixtures/replay/busy-loop.mjs"),
|
||||
{
|
||||
wall_time_ms: 100,
|
||||
},
|
||||
);
|
||||
if (timeout.termination !== "timeout" || timeout.cleanup.state !== "complete")
|
||||
throw new Error("Replay timeout did not kill and clean the complete sandbox");
|
||||
|
||||
const differentialTimeoutInput = {
|
||||
mode: "plan",
|
||||
left: {
|
||||
modules: [
|
||||
{
|
||||
alias: "entry",
|
||||
path: await realpath(resolve("tests/fixtures/replay/busy-loop.mjs")),
|
||||
format: "esm",
|
||||
role: "module",
|
||||
dependencies: {},
|
||||
},
|
||||
],
|
||||
entry_alias: "entry",
|
||||
entry_export: "default",
|
||||
},
|
||||
right: {
|
||||
modules: [
|
||||
{
|
||||
alias: "entry",
|
||||
path: await realpath(resolve("tests/fixtures/replay/parser.mjs")),
|
||||
format: "esm",
|
||||
role: "module",
|
||||
dependencies: {},
|
||||
},
|
||||
],
|
||||
entry_alias: "entry",
|
||||
entry_export: "default",
|
||||
},
|
||||
cases: [{ case_id: "probe", arguments: [] }],
|
||||
limits: { wall_time_ms: 100 },
|
||||
};
|
||||
const differentialTimeoutPlan = await runControlledReplay(
|
||||
dependencies,
|
||||
differentialTimeoutInput,
|
||||
);
|
||||
if (!differentialTimeoutPlan.ok || differentialTimeoutPlan.value.plan === null)
|
||||
throw new Error("Differential timeout plan failed");
|
||||
const differentialTimeout = await runControlledReplay(dependencies, {
|
||||
...differentialTimeoutInput,
|
||||
mode: "execute",
|
||||
plan_digest: differentialTimeoutPlan.value.plan.plan_digest,
|
||||
});
|
||||
if (
|
||||
!differentialTimeout.ok ||
|
||||
differentialTimeout.value.evidence === null ||
|
||||
differentialTimeout.value.source_evidence.length !== 2 ||
|
||||
differentialTimeout.value.evidence.normalized_result.comparison?.[0]
|
||||
?.status !== "unknown" ||
|
||||
differentialTimeout.value.source_evidence.some(
|
||||
(item) => item.normalized_result.outcomes[0]?.outcome !== "timeout",
|
||||
)
|
||||
)
|
||||
throw new Error("Differential termination did not retain both observations");
|
||||
|
||||
const memory = await runSingle(
|
||||
resolve("tests/fixtures/replay/memory-pressure.mjs"),
|
||||
{ wall_time_ms: 3000, memory_bytes: 32 * 1024 * 1024 },
|
||||
);
|
||||
if (memory.termination !== "oom" || memory.cleanup.state !== "complete")
|
||||
throw new Error(
|
||||
`Replay OOM did not report and clean the cgroup limit: ${JSON.stringify(memory)}`,
|
||||
);
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({
|
||||
verifier_run: await completeVerifierRun(verifierRun),
|
||||
available: true,
|
||||
plan_digest: plan.plan_digest,
|
||||
evidence_id: evidence.evidence_id,
|
||||
left_sha256: plan.left.modules[0]?.sha256,
|
||||
right_sha256: plan.right?.modules[0]?.sha256,
|
||||
cases: plan.cases.length,
|
||||
comparison: evidence.normalized_result.comparison?.map(
|
||||
({ case_id, status }) => ({ case_id, status }),
|
||||
),
|
||||
cleanup: evidence.normalized_result.cleanup.state,
|
||||
side_effect_surface: "unavailable",
|
||||
timeout: timeout.termination,
|
||||
differential_timeout:
|
||||
differentialTimeout.value.evidence.normalized_result.comparison[0]
|
||||
?.status,
|
||||
memory: memory.termination,
|
||||
})}\n`,
|
||||
);
|
||||
Reference in New Issue
Block a user