// Decide, before the run ends, whether the model's result is publishable. // // The acceptance gate runs after the transcript closes, so every rejection used // to be terminal: a run that produced a stub body or a fabricated citation // burned its budget and needed a human. This runs the cheap, standalone half of // those checks immediately after the model returns, so the workflow can hand // the reason back and let it try once more. // // Deliberately NOT re-implemented here: the transcript evidence proof. That // lives in the assembler, which stays the single authority on acceptance — this // only decides whether a repair attempt is worth its cost, and a mistake here // costs one extra turn, never a wrong publication. 'use strict'; const fs = require('node:fs'); const path = require('node:path'); const MIN_BODY_CHARS = 200; function main() { const structuredOutput = process.env.STRUCTURED_OUTPUT || ''; const outputPath = process.env.GITHUB_OUTPUT; const emit = (reason) => { fs.appendFileSync(outputPath, `repair_reason< 0) { const detail = citations.invalid .slice(0, 5) .map((entry) => `- ${entry.url} ${entry.reason}`) .join('\n'); emit( `Your review cited ${citations.invalid.length} location(s) that do not exist at the ` + `commits this run analyzed:\n${detail}\nEvery link must point at a real path and a real ` + 'line at the exact analyzed head or merge-base SHA. Re-read the file before citing it.', ); return; } emit(''); } main();