Files
jason.woltje c012b2e0a3 docs(row333): R1 repair packet, receipts and author log appends (#1831)
Commits agents/codex/work/queue-333/r1-repair/ (packet, receipts, review and author files) and the append-only BUILD-LOG.md and docs/SESSIONS.md entries. The packet INDEX.json sha256 is 3eb9b8d10445aa328be3b854385e4792dda2c5712b19d443d485d1b00a18d0f8 and source-tests.patch is a78bc385801b64be270fb9d6e84672c443738a5fce8eb68f7d2a01359a57a770; the product commit for these bytes is 2627321f. Two packet tarballs are deliberately not committed: packet/baseline-input-bytes.tar.gz and packet/fixed-input-bytes.tar.gz. The secret check reported a -----BEGIN marker in each (members packages/bus/src/credentials.mjs and packages/discord/src/tools.mjs, byte-identical to 503b91e56 and with no PEM body). They stay untracked until the lead rules on them.
2026-11-02 13:37:52 -06:00

27 lines
1.9 KiB
JavaScript

import { setPriority, getPriority } from 'node:os';
import { spawn } from 'node:child_process';
import { appendFileSync, readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
const file=process.env.P5_PRIORITY_TRACE;
const capture=(phase,pid=0)=>{let priority=null;try{priority=getPriority(pid);}catch{};const row={phase,pid:pid||process.pid,priority};appendFileSync(file,JSON.stringify(row)+'\n');return priority;};
try{setPriority(0,19);}catch{process.stderr.write('UNVERIFIED/STOP: own wrapper priority setup failed\n');process.exit(78);}
if(capture('wrapper-before')!==19)process.exit(78);
const child=spawn(process.execPath,['--import',fileURLToPath(new URL('./priority-guard.mjs',import.meta.url)),'--test','--test-concurrency=1',...process.argv.slice(2)],{
env:{...process.env,P5_PRIORITY_PARENT:String(process.pid)},stdio:['ignore','inherit','inherit','ipc'],
});
child.on('message',msg=>{
if(!['before','after'].includes(msg?.p5Priority))return;
const priority=capture(`direct-child-${msg.p5Priority}`,child.pid);
child.send({p5Priority:`${msg.p5Priority}-ack`,priority});
});
child.on('error',()=>{process.stderr.write('UNVERIFIED/STOP: native child setup failed\n');process.exitCode=78;});
child.on('close',(code,signal)=>{
capture('wrapper-after');
const rows=readFileSync(file,'utf8').trim().split('\n').map(JSON.parse);
const drift=rows.some(r=>r.priority!==19);
const before=rows.filter(r=>r.phase==='before-modules');
const complete=before.length>0&&before.every(r=>rows.some(x=>x.pid===r.pid&&x.phase==='exit'));
if(drift||!complete||signal){process.stderr.write(`UNVERIFIED/STOP: priority drift or incomplete capture; child=${code}, signal=${signal}\n`);process.exitCode=78;}
else{process.stderr.write(`native strict19 verified: ${before.length} Node processes; direct-child before/after readbacks=19; behavior exit=${code}\n`);process.exitCode=code??78;}
});