Files
PaperClipAI/scripts/ci/pi-intel/retain-test-state.mjs
DottaandPaperclip d472a3c95e ci(runner): verify frozen Pi on native Intel macOS
Add an exclusive manual no-provider lane that rebuilds the reviewed Pi 1.0 source and lock closure, checks native Intel execution, and retains unchanged startup/SDK test evidence with owned cleanup.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-01 16:12:38 -05:00

27 lines
1.2 KiB
JavaScript

// Observe only this test's final cleanup; source, assertions, and runtime stay unchanged.
import fs from 'node:fs';
import { syncBuiltinESMExports } from 'node:module';
import { basename, dirname, resolve } from 'node:path';
const original = fs.promises.rm;
const owner = fs.realpathSync(process.env.PI_INTEL_OWNED_TMP);
const retained = fs.realpathSync(process.env.PI_INTEL_RETAINED_STATE);
fs.promises.rm = async function (path, options) {
const absolute = typeof path === 'string' ? resolve(path) : null;
if (!absolute || dirname(absolute) !== owner || !basename(absolute).startsWith('pi-closed-startup-')) {
return original.call(this, path, options);
}
const info = await fs.promises.lstat(absolute);
if (!info.isDirectory() || info.isSymbolicLink() || info.uid !== process.getuid()) {
throw new Error('Refusing unowned Pi startup retention path');
}
try {
await fs.promises.cp(absolute, `${retained}/${basename(absolute)}`, {
recursive: true, errorOnExist: true, force: false, dereference: false,
});
} finally {
// Capturing evidence must never prevent the original test's cleanup.
await original.call(this, path, options);
}
};
syncBuiltinESMExports();