mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 21:53:51 +00:00
* refactor(verify): run Ghidra verifier commands through the supervised owner (2 of 2) Route the remaining Ghidra verifier compiler and CLI launches through createVerifierCommands, close that owner before lineage observation, and assert the raw arm64 alignment refusal from its structured error. * fix(verify): stop detached Ghidra verifier commands on interrupt SIGINT and SIGTERM abort the command owner and the scripts wait for its cleanup, so a compiler started in its own process group cannot outlive the verifier. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(verify): stop Ghidra verifier analysis when interrupted Pass the verifier interruption signal into MCP and Ghidra waits, and stop waiting for calls that cannot observe it, so SIGINT does not continue the analysis before cleanup. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(verify): stop the switch evidence probe when the verifier is interrupted Pass the verifier interruption signal into the detached Ghidra control probe and end its wait so supervisor.stop() runs before a later SIGKILL. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(verify): observe work already started when a verifier interrupt wins untilInterrupted now settles the caller's promise after the signal has already aborted, so a connection started just before the check cannot reject with nobody listening. Co-authored-by: morluto <morluto@users.noreply.github.com> * refactor(verify): share verifier interrupt handling and keep it through release Move the SIGINT/SIGTERM abort wiring into bindVerifierCommandInterruption. Handlers stay installed until after fixture release, and untilInterrupted still observes a promise that was already started. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(verify): keep diagnostic workspaces and stop fixture builds on interrupt Check the interruption signal after finalization and before the fixture root is removed. MIPS and RISC-V fixture compilers and readers now run through the verifier command owner, so SIGTERM aborts them instead of waiting out their execFile deadline. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
80 lines
2.9 KiB
JavaScript
80 lines
2.9 KiB
JavaScript
/**
|
|
* SIGINT and SIGTERM for one verifier command owner.
|
|
*
|
|
* Owned commands run in their own process group, so the terminal signal does
|
|
* not reach them. These handlers abort that work instead of letting Node exit.
|
|
* They stay installed until `finish`, which is after fixture release: removing
|
|
* them earlier restores Node's default termination while cleanup is still
|
|
* closing a detached process.
|
|
*
|
|
* `untilInterrupted` always observes the promise the caller already started.
|
|
* When the signal is already aborted, that interrupt is the result and a later
|
|
* settlement of the started promise is ignored.
|
|
*
|
|
* @param {{
|
|
* exec: (
|
|
* command: string,
|
|
* args: readonly string[],
|
|
* options?: object,
|
|
* ) => Promise<unknown>;
|
|
* }} commands
|
|
*/
|
|
export function bindVerifierCommandInterruption(commands) {
|
|
const controller = new AbortController();
|
|
const interrupt = (signal) =>
|
|
controller.abort(new Error(`Verifier interrupted by ${signal}`));
|
|
process.on("SIGINT", interrupt);
|
|
process.on("SIGTERM", interrupt);
|
|
const signal = controller.signal;
|
|
|
|
return {
|
|
signal,
|
|
exec: (command, args, options = {}) =>
|
|
commands.exec(command, args, { ...options, signal }),
|
|
throwIfInterrupted: () => {
|
|
if (signal.aborted) throw signal.reason;
|
|
},
|
|
/**
|
|
* The interrupt reason without removing the handlers. Fixture release still
|
|
* needs them so a late signal cannot skip cleanup.
|
|
*/
|
|
reason: () => (signal.aborted ? signal.reason : undefined),
|
|
/** Remove the handlers after fixture release has finished. */
|
|
finish: () => {
|
|
process.off("SIGINT", interrupt);
|
|
process.off("SIGTERM", interrupt);
|
|
return signal.aborted ? signal.reason : undefined;
|
|
},
|
|
/**
|
|
* Register this after every other release callback. It runs after those
|
|
* checks and before the fixture root is removed, so a signal during
|
|
* finalization keeps the diagnostic workspace.
|
|
*/
|
|
retainWorkspaceIfInterrupted: (fixture) => {
|
|
fixture.releaseAfter(() => {
|
|
if (signal.aborted) throw signal.reason;
|
|
});
|
|
},
|
|
untilInterrupted: (promise) =>
|
|
new Promise((resolve, reject) => {
|
|
let settled = false;
|
|
const finish = (settle, value) => {
|
|
if (settled) return;
|
|
settled = true;
|
|
signal.removeEventListener("abort", onAbort);
|
|
settle(value);
|
|
};
|
|
const onAbort = () => finish(reject, signal.reason);
|
|
// The caller starts `promise` before this check. Observe it even when
|
|
// the signal is already aborted so its later rejection cannot end the
|
|
// process. The interrupt wins.
|
|
if (signal.aborted) finish(reject, signal.reason);
|
|
else signal.addEventListener("abort", onAbort, { once: true });
|
|
Promise.resolve(promise).then(
|
|
(value) => finish(resolve, value),
|
|
(cause) => finish(reject, cause),
|
|
);
|
|
}),
|
|
};
|
|
}
|