mirror of
https://github.com/morluto/rea.git
synced 2026-11-09 08:17:02 +00:00
Fixes #5148. Add opt-in durable managed member summaries and authenticated paging while preserving complete default output, original Evidence, cleanup ownership and queued cancellation. Verified with bounded real Newtonsoft/Redux/Rust tasks, independent oracles, 556 focused tests and the expanded domain gate; paired token estimates and latency tradeoffs are recorded in experiments/analysis-efficiency/managed-cli.md.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { createRequire, syncBuiltinESMExports } from "node:module";
|
|
import { writeFileSync } from "node:fs";
|
|
const input = JSON.parse(process.env.REA_TEST_MANAGED_PUBLICATION ?? "null");
|
|
assert.ok(
|
|
input && typeof input.prefix === "string" && typeof input.marker === "string",
|
|
);
|
|
assert.ok(["SIGINT", "SIGTERM"].includes(input.signal));
|
|
assert.ok(["event", "os"].includes(input.delivery));
|
|
const require = createRequire(import.meta.url);
|
|
const fs = require("node:fs/promises");
|
|
const remove = fs.rmdir;
|
|
let queued = false;
|
|
fs.rmdir = async (...arguments_) => {
|
|
const result = await remove(...arguments_);
|
|
if (!queued && String(arguments_[0]).startsWith(input.prefix)) {
|
|
queued = true;
|
|
setImmediate(() => {
|
|
writeFileSync(
|
|
input.marker,
|
|
JSON.stringify({
|
|
signal: input.signal,
|
|
delivery: input.delivery,
|
|
listeners: process.listenerCount(input.signal),
|
|
}),
|
|
);
|
|
if (input.delivery === "os") process.kill(process.pid, input.signal);
|
|
else process.emit(input.signal);
|
|
});
|
|
}
|
|
return result;
|
|
};
|
|
syncBuiltinESMExports();
|