49 lines
1.9 KiB
JavaScript
49 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { readFile } from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
|
|
import { assertCurrentTreeObservation } from './gate-verify.mjs';
|
|
|
|
const prohibitedReports = [
|
|
'HISTORY PROVENANCE VERIFIED local-ref',
|
|
'COMMIT ANCESTRY VERIFIED origin/main',
|
|
'PROVIDER LINEAGE SUCCESS pipeline-7',
|
|
];
|
|
const accepted = prohibitedReports.filter((report) => {
|
|
try {
|
|
assertCurrentTreeObservation(report);
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
});
|
|
|
|
const verifier = await readFile(path.join(process.cwd(), 'scripts', 'gate-verify.mjs'), 'utf8');
|
|
const stdoutWrites = [...verifier.matchAll(/process\.stdout\.write\s*\(/g)].length;
|
|
const stderrWrites = [...verifier.matchAll(/process\.stderr\.write\s*\(/g)].length;
|
|
const gatedErrorWrites = [...verifier.matchAll(/process\.stderr\.write\(`GATE VERIFY FAILED:/g)]
|
|
.length;
|
|
const currentTreeWriterCalls = [...verifier.matchAll(/writeCurrentTreeOutput\s*\(/g)].length;
|
|
const productionRendererWired =
|
|
stdoutWrites === 1 &&
|
|
stderrWrites === 2 &&
|
|
gatedErrorWrites === 2 &&
|
|
currentTreeWriterCalls === 3 &&
|
|
/function writeCurrentTreeOutput\(output\) \{\s*assertCurrentTreeObservation\(output\);\s*process\.stdout\.write/s.test(
|
|
verifier,
|
|
) &&
|
|
/for \(const observation of observations\) \{\s*writeCurrentTreeOutput\(observation\);\s*\}/s.test(
|
|
verifier,
|
|
) &&
|
|
/writeCurrentTreeOutput\(\s*`REGISTRY SUMMARY open behavior deltas:/s.test(verifier) &&
|
|
!/\bconsole\.(?:log|info|debug|error|warn)\s*\(/.test(verifier);
|
|
|
|
if (accepted.length > 0 || !productionRendererWired) {
|
|
process.stderr.write(
|
|
`HISTORY_PROVENANCE_FORBIDDEN: closed current-tree observation renderer rejected=${prohibitedReports.length - accepted.length}/${prohibitedReports.length} production-wired=${productionRendererWired}\n`,
|
|
);
|
|
process.exit(79);
|
|
}
|
|
process.stdout.write('history provenance reporting capability is absent; owner RM-60\n');
|