Files
reverse-engineering-anything/scripts/lib/ghidra-checkpoint-refusal.mjs
T
morluto ea00ca2d46 fix(verify): preserve Ghidra oracle state and coverage (#9994)
* fix(verify): check checkpoint state before restoring fixtures

* fix(verify): require applicable Ghidra decoder controls

* refactor(verify): require explicit instruction fixture facts
2026-11-11 17:21:11 +08:00

34 lines
1.0 KiB
JavaScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
/** Require the CLI's explicit refusal instead of accepting an unrelated failure. */
export async function requireCheckpointCliRefusal(operation, expectedCode) {
let refusal;
try {
await operation();
} catch (cause) {
assert.equal(cause.code, 1, cause.stderr);
refusal = JSON.parse(cause.stdout);
}
assert.ok(refusal, "CLI unexpectedly accepted unavailable checkpoint state");
assert.equal(refusal.code, expectedCode, JSON.stringify(refusal));
return refusal;
}
/** Verify refusal before the caller restores its deliberately invalid manifest. */
export async function assertCheckpointRefusalPreservesManifest(
operation,
manifestPath,
expectedBytes,
) {
const refusal = await requireCheckpointCliRefusal(
operation,
"configuration_invalid",
);
assert.ok(
(await readFile(manifestPath)).equals(expectedBytes),
`Refused CLI command changed the checkpoint manifest: ${manifestPath}`,
);
return refusal;
}