diff --git a/bin/gstack-approvals b/bin/gstack-approvals index 418be9290..c326233e9 100755 --- a/bin/gstack-approvals +++ b/bin/gstack-approvals @@ -13,7 +13,6 @@ * gstack-approvals gate --finding --gate-id --head --reason --words --by [--json] * gstack-approvals dispositions [--branch ] * gstack-approvals lane-exception --head --files --reason --words --by [--json] - * gstack-approvals round-grant --pr --head --kind extra-round|fix-check [--stop-run --findings ] --reason --by [--words ] [--json] * gstack-approvals list [--json] [--branch ] * gstack-approvals sync [--branch ] * gstack-approvals path [--branch ] @@ -29,25 +28,23 @@ import { spawnSync } from 'node:child_process'; import * as path from 'node:path'; import { EXIT, exitTableHelp } from '../lib/headless-artifacts'; import { appendRows, branchExists, buildRow, importAutoplan, locate, readRecord, renderMode, renderRecord, repoVisibility, syncRecord, type RecordError, type StoreLocation } from '../lib/approval-record'; -import { isGstackActor, isGstackActorName, openShipRun, OWNER_REF, OWNER_REF_SHAPE, RULED_NOTE_SCOPE, ruledNoteRow, ruledNoteSource, ruledNotes, ruledNoteText } from '../lib/ruled-notes'; +import { isGstackActor, openShipRun, OWNER_REF, OWNER_REF_SHAPE, RULED_NOTE_SCOPE, ruledNoteRow, ruledNoteSource, ruledNotes, ruledNoteText } from '../lib/ruled-notes'; import { resultLine } from '../lib/result-codes'; import { parsePlanLine, publicPlanLine, resolvePlan } from '../lib/plan-record'; import { TEST_LANE_EXCEPTION_SCOPE, testLaneExceptionRow } from '../lib/test-lane-exception'; -import { FINDING_ID, REVIEW_ROUND_GRANT_SCOPE, reviewRoundGrantRow, ROUND_GRANT_KINDS, STOP_RUN, type RoundGrantKind } from '../lib/review-round-grant'; import { GATE_DISPOSITION_SCOPE, GATE_SOURCE, gateDispositionRow, gateDispositions, gateDispositionText, ONE_LINE, recordGateDisposition, validGateId } from '../lib/gate-dispositions'; const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gstack/captain.md) add --ask --words --by --scope [--pending ] [--outcome approved|rejected|pending|standing] [--date YYYY-MM-DD] [--source ] - [--owner-ref :]: a row naming review_loop_grant is a fix-check grant, - refused inside this checkout's open /ship run unless it relays the lane's or Captain's message with --owner-ref + a review_loop_grant or review_round_grant row is refused: fix-check and round grants were removed (GST-3562 part 4) import --autoplan [--by ] [--stack ] --stack writes the same rows to every branch of a stack; each branch is checked first, and one unknown branch writes none rule --finding --head --reason --words --by [--owner-ref :] [--not-security] - the owner's ruling that a review finding ships as a disclosed note (docs/ship-policy.md#ruled-notes); finish - counts that finding closed on a fix-check whose range_base..commit holds the head, and the receipt and PR body + the owner's ruling that a review finding ships as a disclosed note (docs/ship-policy.md#ruled-notes); the + receipt write counts that finding closed at a head that holds the ruled head, and the receipt and PR body list it; inside this checkout's open /ship run it needs --owner-ref, the message the lane relays the owner's words from, and the row, receipt and Ruled note line then say relayed from it (APPROVAL_RULING_RUN_OPEN without); the ref is ${OWNER_REF_SHAPE}; @@ -64,20 +61,6 @@ const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gs finish prints it, and the receipt, PR body and READY carry it; refused while any worktree holds an open /ship run on the branch; the lander accepts each one with gstack-ship-queue land|verify --accept-gate-disposition dispositions the "Gate disposition: …" lines the Pre-Landing Review and the PR body carry - round-grant --pr --head --kind extra-round|fix-check --reason - --by [--words ] - [--owner-ref :: relays the grant from the lane's or Captain's message, so it - records while a stopped /ship run is still open on this checkout; needs --words; the same shape as rule's] - [--stop-run --findings : fix-check only, the stop gstack-ship-receipt stop recorded and the findings - its fix round is for; it buys one scoped fix-check of the PR's own change since that stop's head. A fix-check - with neither buys one scoped fix-check of the change since --head, the reviewed head: a post-review edit (the - docs audit), or a ruling at the cap whose run recorded no stop. A reason longer than the 300-character ask is - cut there with an ellipsis; its full words stay in --words] - a review round the PR's R51 count would not plan (docs/review-policy.md#rounds-per-pull-request): extra-round is - one round with its fix round past the cap of 2, instead of the read-only final review; it binds - that head of that PR only and is spent by the round; the lane or its Captain records it, never the owner, and - --by is recorded, not enforced; refused inside this checkout's open /ship run, so a run never grants itself; - a stopped run (gstack-ship-run status) records only the fix-check grant naming its own --stop-run and stop --head lane-exception --head --files --reason --words --by the owner's grant that a CI-carried lane counts although exactly those files are in no run's tree.json @@ -181,30 +164,9 @@ function main(argv: string[]): number { const json = bools.has('--json'); const recorded = (where: StoreLocation) => `${where.file}${where.mirror ? ` mirror=${where.mirror}` : ''}`; - if (cmd === 'add' || cmd === 'import' || cmd === 'rule' || cmd === 'lane-exception' || cmd === 'gate' || cmd === 'round-grant') { + if (cmd === 'add' || cmd === 'import' || cmd === 'rule' || cmd === 'lane-exception' || cmd === 'gate') { let rows; - if (cmd === 'round-grant') { - const invalid = (message: string) => fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message }); - const pr = (flags['--pr'] ?? '').trim(), kind = (flags['--kind'] ?? '').trim() as RoundGrantKind, reason = (flags['--reason'] ?? '').trim(), by = (flags['--by'] ?? '').trim(); - if (!/^[1-9]\d*$/.test(pr) || !ROUND_GRANT_KINDS.includes(kind)) return invalid(`round-grant needs --pr and --kind ${ROUND_GRANT_KINDS.join('|')}`); - if (!reason || /[\x00-\x1f\x7f]/.test(reason)) return invalid('round-grant needs --reason '); - const head = spawnSync('git', ['rev-parse', '--verify', '--quiet', `${flags['--head'] ?? ''}^{commit}`], { encoding: 'utf8', timeout: 10_000 }); - if (!flags['--head'] || head.status !== 0) return invalid('round-grant needs --head '); - if (!by || isGstackActorName(by)) return invalid('round-grant needs --by : gstack never grants itself a round'); - const ownerRef = flags['--owner-ref']?.trim(); - if (ownerRef !== undefined && !OWNER_REF.test(ownerRef)) return invalid(`--owner-ref is not ${OWNER_REF_SHAPE}`); - if (ownerRef !== undefined && !(flags['--words'] ?? '').trim()) return invalid('--owner-ref relays the lane\'s or Captain\'s grant, so round-grant needs --words '); - const stopRun = (flags['--stop-run'] ?? '').trim(), findings = [...new Set((flags['--findings'] ?? '').split(',').map(f => f.trim()).filter(Boolean))]; - const open = openShipRun(process.cwd()); - const ownStop = open?.state === 'stopped' && !open.claim && kind === 'fix-check' && stopRun === open.run && open.stop?.head === head.stdout.trim().toLowerCase(); - if (open && ownerRef === undefined && !ownStop) return invalid(`${open.line}: ${open.state !== 'stopped' ? "a round grant is the lane's or its Captain's, never the run's own" : open.claim ? `this run already spent its own stop's fix-check grant (${open.claim.grant}), so a second fix round is the lane's or its Captain's` : `a stopped run records only the fix-check grant for its own stop (--kind fix-check --stop-run ${open.run} --head ${open.stop?.head ?? ''})`}; relay it with --owner-ref : --words , or record it from the lane after the run stops`); - const stopped = flags['--stop-run'] !== undefined || flags['--findings'] !== undefined; - if (kind === 'fix-check' && stopped && (!STOP_RUN.test(stopRun) || !findings.length || !findings.every(f => FINDING_ID.test(f)))) return invalid('round-grant --kind fix-check with a stop needs --stop-run and --findings : it buys the fix round of that one stop; with neither, it buys one scoped fix-check of the change since --head, the reviewed head (a post-review edit, or a stop no stop record holds)'); - if (kind !== 'fix-check' && (flags['--stop-run'] !== undefined || flags['--findings'] !== undefined)) return invalid('--stop-run and --findings belong to --kind fix-check: an extra-round grant names no stop'); - const built = buildRow({ ...reviewRoundGrantRow(head.stdout.trim().toLowerCase(), Number(pr), kind, reason, kind === 'fix-check' && stopped ? { run: stopRun, findings } : undefined), words: flags['--words'] ?? reason, by, date: flags['--date'], source: ruledNoteSource({ ownerRef }) }, loc.branch); - if ('code' in built) return fail(cmd, built); - rows = [built]; - } else if (cmd === 'lane-exception') { + if (cmd === 'lane-exception') { const invalid = (message: string) => fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message }); const files = [...new Set((flags['--files'] ?? '').split(',').map(f => f.trim().replace(/^(\.\/)+/, '')).filter(Boolean))].sort(); const reason = (flags['--reason'] ?? '').trim(); @@ -256,13 +218,8 @@ function main(argv: string[]): number { if (RULED_NOTE_SCOPE.test(flags['--scope'] ?? '')) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a ruled_note scope is recorded with gstack-approvals rule' }); if (GATE_DISPOSITION_SCOPE.test(flags['--scope'] ?? '') || (flags['--source'] ?? '').trim() === GATE_SOURCE) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a gate_disposition scope is recorded with gstack-approvals gate' }); if (TEST_LANE_EXCEPTION_SCOPE.test(flags['--scope'] ?? '')) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a test_lane_exception scope is recorded with gstack-approvals lane-exception' }); - if (REVIEW_ROUND_GRANT_SCOPE.test(flags['--scope'] ?? '')) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a review_round_grant scope is recorded with gstack-approvals round-grant' }); - const ownerRef = flags['--owner-ref']?.trim(); - const grant = `${flags['--ask'] ?? ''} ${flags['--scope'] ?? ''}`.includes('review_loop_grant'); - if (ownerRef !== undefined && (!grant || !OWNER_REF.test(ownerRef) || !(flags['--words'] ?? '').trim())) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: '--owner-ref on add relays a review_loop_grant: :, with --words ' }); - const open = grant ? openShipRun(process.cwd()) : undefined; - if (open && ownerRef === undefined) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: `${open.line}: a review_loop_grant row is a fix-check grant (GST-3546), the lane's or its Captain's, never the run's own; relay it with --owner-ref : --words , or record it after the run ends` }); - const built = buildRow({ ask: flags['--ask'] ?? '', words: flags['--words'] ?? '', by: flags['--by'] ?? '', scope: flags['--scope'] ?? '', pending: flags['--pending'], outcome: flags['--outcome'], date: flags['--date'], source: ownerRef !== undefined ? ruledNoteSource({ ownerRef }) : flags['--source'] }, loc.branch); + if (/\breview_(round|loop)_grant\b/.test(`${flags['--ask'] ?? ''} ${flags['--scope'] ?? ''}`) || flags['--owner-ref'] !== undefined) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'fix-check and round grants were removed (GST-3562 part 4), so add records no review_loop_grant or review_round_grant row and takes no --owner-ref; a PR at its round cap goes to the lane\'s Captain, who ships it with notes (gstack-approvals rule) or parks it' }); + const built = buildRow({ ask: flags['--ask'] ?? '', words: flags['--words'] ?? '', by: flags['--by'] ?? '', scope: flags['--scope'] ?? '', pending: flags['--pending'], outcome: flags['--outcome'], date: flags['--date'], source: flags['--source'] }, loc.branch); if ('code' in built) return fail(cmd, built); rows = [built]; } else { diff --git a/bin/gstack-no-stop b/bin/gstack-no-stop index c508cbb86..ee6f641d3 100755 --- a/bin/gstack-no-stop +++ b/bin/gstack-no-stop @@ -1,6 +1,6 @@ #!/usr/bin/env -S bun --no-env-file --config=/dev/null /** - * gstack-no-stop — record one of the four no-stop defaults and go on (GSTA-258 K1, docs/review-policy.md#no-stop). + * gstack-no-stop — record one of the no-stop defaults and go on (GSTA-258 K1, docs/review-policy.md#no-stop). * * gstack-no-stop record --class --reason --evidence [--range-base ] [--json] * gstack-no-stop import --from /no-stop.json [--json] @@ -8,31 +8,25 @@ * * `record` checks the stop against its class (lib/no-stop.ts) and, when it qualifies, appends * {class, reason, evidence} to the branch's ledger (NO_STOP_FILE:, which /ship passes to - * `gstack-ship-receipt write --no-stop @`). A scoped-fix-check also records the standing grant in - * the approval record and prints GRANT: for `gstack-review-plan --grant`. Anything that does not - * qualify prints `NO_STOP: refused` and exits 3: that stop still goes to the owner. + * `gstack-ship-receipt write --no-stop @`). scoped-fix-check was removed with fix-check grants + * (GST-3562 part 4) and is refused. Anything that does not qualify prints `NO_STOP: refused` and exits 3: that stop still goes to the owner. */ import { spawnSync } from '../lib/spawn-sync'; import * as path from 'node:path'; -import { appendRows, buildRow, locate, readRecord } from '../lib/approval-record'; import { EXIT, exitTableHelp } from '../lib/headless-artifacts'; import { appendLedger, checkNoStop, ledgerPath, readLedger } from '../lib/no-stop'; -import { runScriptSync } from '../lib/script-invocation'; -const HELP = `gstack-no-stop — record one of the four no-stop defaults (docs/review-policy.md#no-stop) +const HELP = `gstack-no-stop — record one of the no-stop defaults (docs/review-policy.md#no-stop) record --class --reason --evidence [--range-base ] [--json] NO_STOP: recorded: go on. NO_STOP: refused (exit 3): the stop stands. Anything else still stops. - scoped-fix-check round 2 stops on a docs-only or timeout-only fix (--range-base round 2's PASS_HEAD): - run the one fix-check its NEXT: names with the printed GRANT: test-timeout-fix a fix that only raises a test's timeout (--range-base the commit before it): its gate finding takes the printed GATE_DISPOSITION: kept reason instead of open pregate-flake-rerun one rerun of a failed pregate case at the same tree (rule 16): green is flaky, red is real autoplan-regate gstack-autoplan records it; import --from /no-stop.json adds it here Step 19's receipt write adds --no-stop @ when list shows records. - --range-base: the commit the fix or change is measured from (round 2's PASS_HEAD for scoped-fix-check, which must be - the newest review-log pass row's commit, - the commit before the fix for test-timeout-fix); required for those two + scoped-fix-check removed with fix-check grants (GST-3562 part 4): refused; a round-2 stop goes to the lane's Captain + --range-base: the commit before the fix, required for test-timeout-fix import --from [--json] add an autoplan run's no-stop.json records to the branch's ledger list [--json] the branch's ledger and its path @@ -40,32 +34,9 @@ ${exitTableHelp()}`; const flag = (args: string[], name: string) => { const i = args.indexOf(name); return i >= 0 ? args[i + 1] : undefined; }; const git = (args: string[]) => spawnSync('git', args, { cwd: process.cwd(), encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }); -const NEEDS_RANGE = ['scoped-fix-check', 'test-timeout-fix']; -const K1_BY = 'gstack no-stop default (K1)'; +const NEEDS_RANGE = ['test-timeout-fix']; const AUTOPLAN_EVIDENCE = /^autoplan:\S+@gate_rev=\d+$/; -/** The commit the newest full or scoped pass reviewed (its review-log row's commit_full): round 2's PASS_HEAD. */ -function lastPassHead(): string | null { - const r = runScriptSync(path.join(import.meta.dir, 'gstack-review-read'), [], { cwd: process.cwd(), encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }); - const rows = (r.stdout ?? '').split('---CONFIG---')[0]!.split('\n').flatMap(l => { try { return [JSON.parse(l)]; } catch { return []; } }); - const pass = rows.filter(x => x.skill === 'review' && typeof x.commit_full === 'string').at(-1); - return pass ? pass.commit_full : null; -} - -function grant(head: string, detail: string, ledger: string): string | { error: string } { - const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim(); - const loc = locate({ cwd: process.cwd(), env: process.env, branch }); - if ('code' in loc) return { error: loc.message }; - const row = buildRow({ - ask: `No-stop default: one scoped fix-check past R51's cap (review_loop_grant ${head})`, - words: `K1 no-stop default, docs/review-policy.md#no-stop: ${detail}`, - by: K1_BY, scope: `review_loop_grant ${head}`, outcome: 'approved', source: `no-stop:${ledger.split('/').pop()}`, - }, branch); - if ('code' in row) return { error: row.message }; - const added = appendRows(loc, [row]); - return 'code' in added ? { error: added.message } : row.id; -} - function record(args: string[], json: boolean): number { const cls = flag(args, '--class') ?? ''; const commit = (ref: string | undefined) => { if (!ref) return undefined; const r = git(['rev-parse', '--verify', '--quiet', '--end-of-options', `${ref}^{commit}`]); return r.status === 0 ? r.stdout.trim() : null; }; @@ -75,18 +46,7 @@ function record(args: string[], json: boolean): number { if (NEEDS_RANGE.includes(cls) && !rangeBase) { process.stderr.write(`gstack-no-stop record: --class ${cls} needs --range-base \n`); return EXIT.usage; } const file = ledgerPath(process.cwd()); if (!file) { process.stderr.write('gstack-no-stop record: not inside a git checkout\n'); return EXIT.fail; } - if (cls === 'scoped-fix-check') { - const pass = lastPassHead(); - if (!pass || pass !== rangeBase) { - process.stderr.write(`NO_STOP: refused ${cls} (--range-base ${rangeBase} is not the commit the last review pass read (${pass ? pass.slice(0, 12) : 'no review-log row'}), so the checked range would not be the range the fix-check covers); stop for the owner\n`); - return EXIT.refused; - } - const loc = locate({ cwd: process.cwd(), env: process.env, branch: git(['rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim() }); - if (!readLedger(file).some(r => r.class === cls) && !('code' in loc) && readRecord(loc).rows.some(r => r.by === K1_BY)) { - process.stderr.write(`NO_STOP: refused ${cls} (the approval record already holds this branch's K1 grant, from this or another checkout; a second goes to the owner); stop for the owner\n`); - return EXIT.refused; - } - } + if (cls === 'scoped-fix-check') { process.stderr.write(`NO_STOP: refused ${cls} (removed with fix-check grants, GST-3562 part 4: a stop after round 2 goes to the lane's Captain, who ships it with notes or parks it); stop for the lane's Captain\n`); return EXIT.refused; } let diff: string | undefined; if (rangeBase) { const d = git(['diff', '--no-color', '--no-ext-diff', '--no-renames', rangeBase, 'HEAD']); @@ -100,17 +60,9 @@ function record(args: string[], json: boolean): number { return EXIT.refused; } const lines = [`NO_STOP: ${cls} recorded (${v.detail})`, `NO_STOP_FILE: ${file}`]; - let grantId: string | undefined; - if (cls === 'scoped-fix-check') { - const head = git(['rev-parse', 'HEAD']).stdout.trim(); - const g = grant(head, v.detail, file); - if (typeof g !== 'string') { process.stderr.write(`gstack-no-stop record: the grant was not recorded (${g.error}); stop for the owner\n`); return EXIT.fail; } - grantId = g; - lines.push(`GRANT: ${g}`, `NEXT: gstack-review-plan --grant ${g} --range-base ${rangeBase} (one scoped fix-check; a blocking finding there goes to the owner)`); - } if (cls === 'test-timeout-fix') lines.push(`GATE_DISPOSITION: kept reason="no-stop test-timeout-fix: ${v.record.reason}"`); appendLedger(file, v.record); - process.stdout.write(json ? JSON.stringify({ ok: true, record: v.record, detail: v.detail, file, ...(grantId ? { grant: grantId } : {}) }) + '\n' : lines.join('\n') + '\n'); + process.stdout.write(json ? JSON.stringify({ ok: true, record: v.record, detail: v.detail, file }) + '\n' : lines.join('\n') + '\n'); return EXIT.ok; } diff --git a/bin/gstack-review-dispatch b/bin/gstack-review-dispatch index 43db384b0..b41f59058 100755 --- a/bin/gstack-review-dispatch +++ b/bin/gstack-review-dispatch @@ -23,7 +23,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { EXIT, exitTableHelp } from '../lib/headless-artifacts'; import { BRIEF_ROLES, BriefError, briefFile, checkReviewedTree, checkoutRoot, checkoutTree, promptHash, renderBrief, sectionTexts, sliceDiff, sliceNote, withWorkspace, type BriefRole, type Slots, type TreeCheck } from '../lib/review-brief'; -import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, parseFindings, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger'; +import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger'; import { buildManifest, checklistFile, chunkCount, chunkOf, manifestPath, markReader, planCyberRetry, readManifest, renderStage, withAuditModel, writeManifest, STAGES, type Extra, type Manifest, type PassReader, type ReaderState, type Stage } from '../lib/review-pass'; import { classifyOutsideReview } from '../lib/outside-review-result'; import { gateOutcomeLine } from '../lib/gate-outcomes'; @@ -39,7 +39,6 @@ import { effectiveReaders, READERS_POLICY_DEFAULT, type EffectiveReaders } from import { defaultRoots, foundLines, ignoredLines, inventory, quarantineStage, rerunBlocked, sweepResult, type Inventory } from '../lib/review-sweep'; import { REVIEW_DIFF_MAX_BYTES, ceilingContext, disclosureDigest, disclosureLine, parseTail, readSelection, tooLargeLine, unreadableLine, type PlanExclude, type ReaderDiff } from '../lib/review-exclude'; import { logShipCall } from '../lib/ship-call-log'; -import { claimedFixCheckHunks, restampFixCheckHunks } from '../lib/review-evidence'; logShipCall('gstack-review-dispatch'); @@ -189,7 +188,7 @@ function render(): number { classes: flag('--classes'), brief, ...(merged ? { checklist: path.join(ROOT, 'review/specialists/targeted.md') } : {}), policy_exclude: policyItems.map(quote).join(' ') || undefined, ...(sel.disclosure ? { disclosure: sel.disclosure, keep: sel.keep?.map(quote).join(' ') || undefined } : {}), ...(sel.disclosure && 'excerpt_file' in sel && sel.excerpt_file ? { excerpt_file: sel.excerpt_file.file, excerpt_bytes: String(sel.excerpt_file.bytes), excerpt_sha256: sel.excerpt_file.sha256, excerpt_files: String(sel.excerpt_file.files) } : {}), - fix_list: readFile(flag('--fix-list'), 'fix list'), hunks: (role === 'fix-check' ? claimedFixCheckHunks(process.cwd())?.text : undefined) ?? readFile(flag('--hunks'), 'hunks'), tests: readFile(flag('--tests'), 'tests'), callers: readFile(flag('--callers'), 'callers'), + fix_list: readFile(flag('--fix-list'), 'fix list'), hunks: readFile(flag('--hunks'), 'hunks'), tests: readFile(flag('--tests'), 'tests'), callers: readFile(flag('--callers'), 'callers'), }; const workdir = checkoutRoot(); const tree = checkoutTree(workdir); @@ -506,15 +505,9 @@ function passStep(cmd: string): number { const token = flag('--token'); if (!token) { process.stderr.write('gstack-review-dispatch mark: --log-start --token \n'); return EXIT.usage; } m.log_starts ??= {}; - const fresh = !m.log_starts[logStart]; m.log_starts[logStart] ??= token; writeManifest(file, m); process.stdout.write(`LOG_START: ${logStart} token=${m.log_starts[logStart]}\n`); - if (fresh && m.fix_check?.hunks && logStart.includes('review-fix-check')) { - let text: string | undefined; - try { text = claimedFixCheckHunks(process.cwd())?.text ?? fs.readFileSync(m.fix_check.hunks, 'utf8'); } catch { /* reported below; the start token is already recorded */ } - process.stdout.write(`FIX_CHECK_HUNKS: ${text === undefined ? 'not restamped (hunks file unreadable)' : restampFixCheckHunks(process.cwd(), text) ? 'restamped' : 'not restamped (no render record with these hunks)'}\n`); - } return EXIT.ok; } const before = flag('--before'); diff --git a/bin/gstack-review-plan b/bin/gstack-review-plan index e9b8bb6a0..6d41e64d2 100755 --- a/bin/gstack-review-plan +++ b/bin/gstack-review-plan @@ -2,11 +2,10 @@ /** * gstack-review-plan — how much review the next /ship step dispatches (docs/review-policy.md#review-depth). * - * gstack-review-plan --base [--pass ] [--last none|full|fix-check] [--fixed-blocking] [--fixed-below] + * gstack-review-plan --base [--pass ] [--last none|full] [--fixed-blocking] [--fixed-below] * [--blocking-open] [--touched-gate] [--critical-found] [--adversarial-ran] [--gate-tagged ] [--gated a,b] [--force a,b|all] * [--reviewed-numbers ] [--depth-floor standard|full] [--range-base ] [--pass1-depth light|standard|full] [--no-tiers] - * [--targeted-ran ] [--grant ] [--fix-checks ] [--post-review] [--pr ] [--json] - * gstack-review-plan --fix-check-prompt --fix-list --hunks --tests [--callers ] + * [--targeted-ran ] [--post-review] [--pr ] [--json] * * Reads the diff against the merge base with (committed, tracked uncommitted * edits and untracked files, through lib/review-collect.ts collectLive), runs @@ -24,8 +23,6 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { spawnSync } from '../lib/spawn-sync'; import { baseContainsHead } from '../lib/default-base'; -import { locate, readRecord } from '../lib/approval-record'; -import { grantForPr, readReviewRoundGrants, reviewRoundGrants } from '../lib/review-round-grant'; import { EXIT, exitTableHelp } from '../lib/headless-artifacts'; import { resultLine } from '../lib/result-codes'; import { gateOutcomeLine } from '../lib/gate-outcomes'; @@ -43,20 +40,16 @@ import { effectiveReaders, READERS_POLICY_DEFAULT } from '../lib/ship-policy-rea import { classifyDiff, diffCommand, keepCommand, planReview, reviewDepthLine, reviewPlanLine, scanNumbers, ROLE_EFFORT, SCOPED_RANGE_LINES, type Depth, type History } from '../lib/review-depth'; import { classList, targetedBriefSha, targetedClasses, targetedPatchId } from '../lib/review-targeted'; import { targetedDelta } from '../lib/review-targeted-delta'; -import { docsChangeSince, ownChangeSince } from '../lib/ship-receipt-depth'; +import { ownChangeSince } from '../lib/ship-receipt-depth'; import { RISK_CLASSES, type RiskClass } from '../lib/review-risk'; -import { renderFixCheckPrompt } from '../scripts/resolvers/fix-check'; -import { bindFixCheckRow, countedFixCheck, grantSpent } from '../lib/fix-check-clearing'; -import { claimedFixCheckHunks, recordFixCheckHunks } from '../lib/review-evidence'; const HELP = `gstack-review-plan — the review depth of the next /ship step (docs/review-policy.md#review-depth) --base the base branch (merge base with HEAD is the diff base); required --pass full review passes already run in this invocation (default 0) - --last none|full|fix-check the step that just finished (default none: plan pass 1) + --last none|full the step that just finished (default none: plan pass 1) --fixed-blocking the finished step fixed a blocking finding (raises light to standard) - --fixed-below the finished step fixed findings below the floor (ignored after a fix-check: below-floor - fixes never repeat review, so only --fixed-blocking or --blocking-open stops there) + --fixed-below the finished step fixed findings below the floor --blocking-open a blocking finding is still open in fix scope --touched-gate a fix touched a gate-class path --critical-found a specialist reported a CRITICAL finding (Red Team on code class; raises light to standard) @@ -69,8 +62,7 @@ const HELP = `gstack-review-plan — the review depth of the next /ship step (do refuses (exit 2): the plan dispatches it itself --reviewed-numbers the numeric-claim fingerprint the outside voice already reviewed --depth-floor standard|full raise the depth to at least this (never lowers it); /ship passes its prompt flag on every run - --range-base the fix range's base (this pass's PASS_HEAD; with --post-review --last fix-check, the last fix-check's - commit): after a fixed blocker, round 2 is a full pass on the range; below full depth, a + --range-base the fix range's base (this pass's PASS_HEAD): after a fixed blocker, round 2 is a full pass on the range; below full depth, a committed range of at most ${SCOPED_RANGE_LINES} runtime lines now also gets a full pass (no scoped pass) that keeps the Red Team and, on a range with runtime lines, the native adversarial; anything unread plans the full pass --no-tiers specialists, audits and watchers at the host's default effort too (as gstack-config review_effort_tiers off does) @@ -80,53 +72,30 @@ const HELP = `gstack-review-plan — the review depth of the next /ship step (do reader last read it: the same patch skips it; any other id, none, or uncommitted edits dispatch it again. With --range-base naming the commit that read happened on, a loop that is done plans NEXT: targeted (one targeted reader on HEAD, TARGETED_DELTA: names the range) when the only change since is docs the - receipt cannot carry the record across (a money, security or numeric claim; GST-1598), or, with a - --grant this invocation checks, any change but plain docs (the granted fix round; GST-1607) - --grant the owner's grant of one scoped fix-check after round 2, recorded with gstack-approvals add (approved, - its ask or scope naming review_loop_grant and the stop head's sha, at or after --range-base and at or - before HEAD; needs --range-base): the stop after a round-2 full pass with a fixed blocking finding or a - gate-class edit plans that fix-check instead; a fix-check never earns another, except that with - --post-review --last fix-check a new grant at a stop head after --range-base (the last fix-check's - commit) plans the next link of the fix-check chain, and in the loop after a fix-check a new grant - naming that fix-check's commit (--range-base) plans the next link; a grant recorded before a later - logged fix-check already bought a link; any other row is refused (exit 3) - --fix-checks fix-checks already run in this invocation: the owner's grant adds one only after the first, in the lean - loop and after a round-2 fix-check in the full loop (GEVA-223) + receipt cannot carry the record across (a money, security or numeric claim; GST-1598) --post-review plan the Step 9 that /ship Step 16 stage 2.1 inserted for edits after the review bound (finish's behavior STOP): they plan as a fix to a gate-class path, never a note, so below the round cap - it is a pass on the range (lean: a fix-check), and at the cap it stops for the owner, whose - --grant adds one scoped fix-check; after a fix-check, each new grant adds one more (a chain link, - --range-base at the last fix-check's commit); pass --pass, --last and --fix-checks as the loop left them. - After a fix-check, edits since --range-base that are only release stamps (the base policy's stamp rule, - line-exact) and docs (docsChangeSince, the receipt's classifier), with no executable, symlink or gitlink mode and no gate-scan - tag in the range, are no gate-class edit: done, or targeted - when a docs claim needs the targeted read on a targeted-class diff (GST-1702) - --pr the PR whose platform review counts under review.platform on (default: this branch's PR); with - --round-grant, the PR the grant must name - --prior-rounds R51 rounds earlier /ship runs on this PR already spent, fix-checks not included (printed as pr_rounds=) + it is a pass on the range, and at the cap it stops for the lane's Captain; pass --pass and --last + as the loop left them + --pr the PR whose platform review counts under review.platform on (default: this branch's PR) + --prior-rounds R51 rounds earlier /ship runs on this PR already spent (printed as pr_rounds=) --prior-full the full rounds among them: with this run's full passes they count against the cap of 2, so pass 1 of a PR with 2 is one read-only full review (no fix round; a blocker is NEXT: stop (PR_ROUND_CAP) for the lane's Captain to decide, never the owner). Both come from the PR_REVIEW_FLAGS: line gstack-ship-preflight prints (gstack-ship-receipt history) (docs/review-policy.md#rounds-per-pull-request; GST-2673) - --round-grant a review round grant at HEAD, recorded with gstack-approvals round-grant by the lane or its Captain: - one more round for the PR at this head; any other row is refused (exit 3) - --stop with a fix-check --round-grant (PR_REVIEW_FLAGS:): the stop record's head that grant names; it is - the fix range's base, and the plan is that stop's one scoped fix-check, never a new full review (GST-2968) --declare-risk risk classes the lane declares for the diff (comma list of ${RISK_CLASSES.join(', ')}): they join the detected classes and only raise the depth; RISK_DECLARED: prints both (GST-1129) - --fix-check-prompt print the fix-check reviewer's prompt from --fix-list, --hunks, --tests and --callers files Mode (R65, the base policy's review key): review.panel all (default) keeps today's panel on every class. review.panel risk (opt-in; its one-reader shape has not passed a no-loss replay) runs lean off risk class, and review.panel off everywhere: lean runs one reader: risk class gets the merged reader on review.risk_model (the native adversarial brief plus the checklists, the Red Team and the targeted brief), non-risk code the single reader at the -lane's reasoning (cross-family when it publishes numbers), docs the core read, tests one batched testing reader (R51); one fix-check after fixes, never more +lane's reasoning (cross-family when it publishes numbers), docs the core read, tests one batched testing reader (R51); a full round 2 after fixes, never more than 2 rounds. review.platform on (any panel): a light diff with no numeric claims whose PR carries capy-ai[bot]'s review at HEAD plans NEXT: platform and a planned SKIP for every reader. Depth (R51, risk not size): full on gate class, a risk class (money, auth, secret, security, data, review.risk_paths) or any DEPTH_ERROR; standard only by --depth-floor or a raise; otherwise light. TARGETED: the money, -gate, auth and secret classes the diff touches; any class dispatches the targeted reader at every depth. NEXT: full, scoped -(a full pass on the range: fix-check, Red Team, native adversarial), fix-check, voices (gate class: Step 11 before any stop, +gate, auth and secret classes the diff touches; any class dispatches the targeted reader at every depth. NEXT: full, voices (gate class: Step 11 before any stop, then ask again with --adversarial-ran), targeted (the targeted-only read after the loop), stop or done. A full plan from an error exits 0; exit 1 means no plan could be built (git could not list the diff). ${exitTableHelp()}`; @@ -139,82 +108,29 @@ const git = (a: string[]) => { const r = spawnSync('git', ['-c', 'core.quotePath function main(): number { if (has('--help') || has('-h')) { process.stdout.write(HELP + '\n'); return EXIT.ok; } - if (has('--fix-check-prompt')) { - const read = (n: string, required: boolean) => { - const f = flag(n); - if (!f) return required ? null : ''; - try { return fs.readFileSync(f, 'utf8'); } catch { return null; } - }; - const built = claimedFixCheckHunks(process.cwd()); - const [fixList, given, testResults, callers] = [read('--fix-list', true), read('--hunks', !built), read('--tests', true), read('--callers', false)]; - if (fixList === null || given === null || testResults === null || callers === null) { process.stderr.write('gstack-review-plan: --fix-check-prompt needs readable --fix-list and --tests files, and --hunks unless this run claimed a fix-check grant (gstack then builds them; --callers optional)\n'); return EXIT.usage; } - if (built && given && given !== built.text) process.stderr.write(`FIX_CHECK_HUNKS: built from git diff ${built.base.slice(0, 12)} HEAD (the claimed grant's head); the --hunks file differs and is not used\n`); - const touchedHunks = built?.text ?? given; - process.stdout.write(renderFixCheckPrompt({ fixList, touchedHunks, testResults, callers })); - recordFixCheckHunks(process.cwd(), touchedHunks, undefined, fixList); - return EXIT.ok; - } const base = flag('--base'); if (!base) { process.stderr.write(`gstack-review-plan: --base is required\n${HELP}\n`); return EXIT.usage; } const last = (flag('--last') ?? 'none') as History['last']; - if (!['none', 'full', 'fix-check'].includes(last)) { process.stderr.write('gstack-review-plan: --last must be none, full or fix-check\n'); return EXIT.usage; } + if (!['none', 'full'].includes(last)) { process.stderr.write(`gstack-review-plan: --last must be none or full${last === 'fix-check' ? ' (fix-checks and their grants were removed in GST-3562 part 4; docs/troubleshooting.md#pr-round-cap)' : ''}\n`); return EXIT.usage; } const pass1Depth = (flag('--pass1-depth') ?? 'full') as Depth; if (!['light', 'standard', 'full'].includes(pass1Depth)) { process.stderr.write('gstack-review-plan: --pass1-depth must be light, standard or full\n'); return EXIT.usage; } - const fixChecks = Number(flag('--fix-checks') ?? (last === 'fix-check' ? '1' : '0')); - if (!Number.isInteger(fixChecks) || fixChecks < 0) { process.stderr.write('gstack-review-plan: --fix-checks needs an integer >= 0\n'); return EXIT.usage; } const pass = Number(flag('--pass') ?? '0'); if (!Number.isInteger(pass) || pass < 0) { process.stderr.write('gstack-review-plan: --pass needs an integer >= 0\n'); return EXIT.usage; } const floor = flag('--depth-floor') as Depth | undefined; if (has('--depth-floor') && floor !== 'standard' && floor !== 'full') { process.stderr.write('gstack-review-plan: --depth-floor must be standard or full (a floor only raises the depth)\n'); return EXIT.usage; } - const grant = flag('--grant'); - if (has('--grant') && (!grant || grant.startsWith('-'))) { process.stderr.write('gstack-review-plan: --grant needs the approval id gstack-approvals add printed\n'); return EXIT.usage; } - const rangeBase = flag('--range-base') ?? flag('--stop'); - if (has('--stop') && (!flag('--stop') || flag('--stop')!.startsWith('-') || !flag('--round-grant') || (has('--range-base') && flag('--range-base') !== flag('--stop') && git(['merge-base', '--is-ancestor', flag('--stop')!, flag('--range-base')!]) === null))) { process.stderr.write('gstack-review-plan: --stop comes with the --round-grant that answers it (PR_REVIEW_FLAGS:), and is the fix range\'s base: a --range-base must be that head or a commit after it (the post-review or targeted re-plan after the granted fix-check)\n'); return EXIT.usage; } - if (has('--range-base') && (!rangeBase || rangeBase.startsWith('-'))) { process.stderr.write('gstack-review-plan: --range-base needs the fix range\'s base commit (this pass\'s PASS_HEAD; with --post-review --last fix-check, the last fix-check\'s commit)\n'); return EXIT.usage; } - if (grant && !rangeBase) { process.stderr.write('gstack-review-plan: --grant needs --range-base (round 2\'s PASS_HEAD; with --post-review --last fix-check, the last fix-check\'s commit), which binds the grant to the stop it answers\n'); return EXIT.usage; } + const rangeBase = flag('--range-base'); + if (has('--range-base') && (!rangeBase || rangeBase.startsWith('-'))) { process.stderr.write('gstack-review-plan: --range-base needs the fix range\'s base commit (this pass\'s PASS_HEAD)\n'); return EXIT.usage; } if (list('--force').includes('targeted')) { process.stderr.write('gstack-review-plan: --force targeted: the targeted reader is no specialist; the plan dispatches it whenever the diff has a targeted class, and after a finished loop for a docs claim added since its read: pass --range-base --targeted-ran (docs/review-policy.md#targeted-only-read-after-the-loop)\n'); return EXIT.usage; } const declared = list('--declare-risk'); if (has('--declare-risk') && (!declared.length || declared.some(c => !(RISK_CLASSES as readonly string[]).includes(c)))) { process.stderr.write(`gstack-review-plan: --declare-risk ${flag('--declare-risk') ?? ''}: each class is one of ${RISK_CLASSES.join(', ')} (a declaration only raises the depth)\n`); return EXIT.usage; } const root = git(['rev-parse', '--show-toplevel'])?.trim(); if (!root) { process.stderr.write('gstack-review-plan: run it inside a git checkout\n'); return EXIT.fail; } process.chdir(root); - let inLoopLink = false; - let recorded: ReturnType | undefined; - const bindRow = (row: Record) => bindFixCheckRow(root, row, recorded ??= readReviewRoundGrants(root), { open: true }).ok; - if (grant) { - const loc = locate({ cwd: root, env: process.env }); - const row = ('file' in loc ? readRecord(loc).rows : []).find(r => r.id === grant && r.outcome === 'approved' && (`${r.ask} ${r.scope}`.includes('review_loop_grant') || reviewRoundGrants([r]).some(x => x.kind === 'fix-check'))); - const named = row ? reviewRoundGrants([row]).find(x => x.kind === 'fix-check' && !x.legacy)?.head : undefined; - const passHead = git(['rev-parse', '--verify', '--quiet', `${rangeBase}^{commit}`])?.trim(); - const ancestor = (a: string, d: string) => git(['merge-base', '--is-ancestor', a, d]) !== null; - const chained = has('--post-review') && last === 'fix-check'; - const stopHead = row && passHead ? (named ? [named] : `${row.ask} ${row.scope}`.match(/\b[0-9a-f]{7,40}\b/g))?.map(s => git(['rev-parse', '--verify', '--quiet', `${s}^{commit}`])?.trim()).find(s => s && ancestor(passHead, s) && ancestor(s, 'HEAD') && !(chained && s === passHead)) : undefined; - inLoopLink = !chained && last === 'fix-check' && stopHead === passHead; - if (!stopHead) { process.stderr.write(`gstack-review-plan: --grant ${grant}: no approved row ${grant} naming review_loop_grant and this invocation's stop head (a commit ${chained ? `after --range-base ${rangeBase}, the last fix-check's commit, whose own grant does not carry over` : `at or after --range-base ${rangeBase}`}, at or before HEAD) in this branch's approval record (${'file' in loc ? 'gstack-approvals list' : loc.message}); record the owner's grant with gstack-approvals add --ask '... (review_loop_grant )' first\n`); return EXIT.refused; } - const logged = inLoopLink ? runScriptSync(path.join(path.dirname(Bun.fileURLToPath(import.meta.url)), 'gstack-review-read'), [], { encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }) : null; - if (logged && logged.status !== 0) { process.stderr.write(`gstack-review-plan: --grant ${grant}: gstack-review-read exited ${logged.status}, so whether a fix-check already spent this grant is unknown; no plan is safer than a fix-check the grant may not buy\n`); return EXIT.fail; } - if (logged && row && (logged.stdout ?? '').split('\n---CONFIG---')[0]!.split('\n').some(l => { try { const v = JSON.parse(l); return countedFixCheck(v, bindRow) && Date.parse(v.timestamp) > Date.parse(row.recorded_at); } catch { return false; } })) { process.stderr.write(`gstack-review-plan: --grant ${grant}: a fix-check was logged after this grant was recorded, so the grant already bought a link of the fix-check chain; the stop at --range-base ${rangeBase} needs a new grant recorded after the last fix-check (gstack-approvals add --ask '... (review_loop_grant ${passHead!.slice(0, 12)})')\n`); return EXIT.refused; } - } + const retired = ['--grant', '--fix-checks', '--round-grant', '--stop', '--fix-check-prompt'].filter(has); + if (retired.length) { process.stderr.write(`gstack-review-plan: ${retired.join(', ')}: fix-checks, round grants and owner grants were removed in GST-3562 part 4; a PR at its round cap goes to the lane's Captain (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.usage; } const priorRounds = Number(flag('--prior-rounds') ?? '0'); const priorFull = Number(flag('--prior-full') ?? '0'); if (![priorRounds, priorFull].every(n => Number.isInteger(n) && n >= 0)) { process.stderr.write('gstack-review-plan: --prior-rounds and --prior-full need integers >= 0 (PR_REVIEW_FLAGS: from gstack-ship-preflight)\n'); return EXIT.usage; } - const roundGrant = flag('--round-grant'); - let grantedStop: string | undefined; - let grantUnspent = false; - if (has('--round-grant')) { - const at = git(['rev-parse', 'HEAD'])?.trim(); - const loc = locate({ cwd: root, env: process.env }); - const g = readReviewRoundGrants(root).find(x => x.approval === roundGrant); - const pr = flag('--pr'); - const stop = has('--stop') ? git(['rev-parse', '--verify', '--quiet', `${flag('--stop')}^{commit}`])?.trim() : undefined; - if (g && (g.kind === 'fix-check') !== has('--stop')) { process.stderr.write(`gstack-review-plan: --round-grant ${roundGrant}: ${g.kind === 'fix-check' ? 'a fix-check grant answers a stop record: pass the --stop PR_REVIEW_FLAGS: prints with it' : 'an extra-round grant names no stop: --stop takes a fix-check grant'} (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.refused; } - if (g && g.kind === 'fix-check' && (stop !== g.head || (pr !== undefined && !grantForPr(g, Number(pr))))) { process.stderr.write(`gstack-review-plan: --round-grant ${roundGrant}: the fix-check grant names the stop at ${g.head.slice(0, 12)} for PR #${g.pr}, not --stop ${(flag('--stop') ?? '').slice(0, 12)}${pr ? ` and PR #${pr}` : ''}; a grant buys the fix round of the one stop it names (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.refused; } - if (g?.kind === 'fix-check') grantedStop = g.approval; - const logged = g?.kind === 'fix-check' && last === 'fix-check' ? runScriptSync(path.join(path.dirname(Bun.fileURLToPath(import.meta.url)), 'gstack-review-read'), [], { encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }) : null; - grantUnspent = !!logged && logged.status === 0 && !grantSpent((logged.stdout ?? '').split('\n---CONFIG---')[0]!.split('\n').flatMap(l => { try { const v = JSON.parse(l); return v && typeof v === 'object' ? [v] : []; } catch { return []; } }), g!, bindRow); - const atOrBefore = !!g && !!at && (g.head === at || git(['merge-base', '--is-ancestor', g.head, at]) !== null); - if (!roundGrant || !g || !atOrBefore || (pr !== undefined && !grantForPr(g, Number(pr)))) { process.stderr.write(`gstack-review-plan: --round-grant ${roundGrant ?? ''}: no approved review_round_grant row ${roundGrant ?? ''} naming HEAD ${(at ?? 'unknown').slice(0, 12)} or a commit before it${pr ? ` and PR #${pr}` : ''} in this branch's approval record; record one with gstack-approvals round-grant (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.refused; } - } const collected = collectLive(root, base); if (collected.errors.length) { for (const e of collected.errors) process.stderr.write(`gstack-review-plan: git could not list the diff (${e.input}: ${e.detail}); fix: ${e.repair}; no plan is safer than a plan for an empty diff\n`); @@ -292,18 +208,12 @@ function main(): number { const brief = targetedBriefSha(); const ran = !['uncommitted', 'none'].includes(patch) && flag('--targeted-ran') === patch; const postReview = has('--post-review'); - const fixCheckAt = postReview && pass > 0 && last === 'fix-check' && fixRange?.runtime_lines != null ? git(['rev-parse', '--verify', '--quiet', `${rangeBase}^{commit}`])?.trim() : undefined; - const afterFixCheck = fixCheckAt ? docsChangeSince(root, fixCheckAt, head, ref) : null; - const rawSince = fixCheckAt && own ? git(['diff', '--raw', '--no-renames', fixCheckAt, own]) : null; - const carried = afterFixCheck && afterFixCheck.verdict !== 'code' && rawSince !== null && !/^:\d+ (100755|120000|160000) /m.test(rawSince) && gateTagsOf(['--commit', own!]) === 0 ? afterFixCheck : null; const plan = planReview({ ...collected, ...exclusionInput, ...riskPaths, declared: declared as RiskClass[], shape: { panel: review.panel, readerModel: review.reader_model, platform: review.platform, head, platformReview: platform?.ok ? platform.review : null }, scope, gateTagged, targeted: { classes: targeted.classes, ran }, numbers: scanNumbers(kept(added)), force, gated: list('--gated'), floor, tiers: auditEffort !== 'host', criticalFound: has('--critical-found'), adversarialRan: has('--adversarial-ran'), reviewedNumbers: flag('--reviewed-numbers'), - history: { priorRounds, priorFull, ...(grantedStop ? { grantedStop } : roundGrant ? { roundGrant } : {}), fullPasses: pass, last: grantUnspent ? 'none' : last, fixedBlocking: has('--fixed-blocking'), fixedBelow: (has('--fixed-below') || (postReview && pass > 0)) && last !== 'fix-check', blockingOpen: has('--blocking-open'), touchedGate: has('--touched-gate') || (!carried && (!!fixRange?.touched_gate || (postReview && pass > 0))), pass1Depth, rangeRuntimeLines: fixRange?.runtime_lines, granted: grant, fixChecks: has('--fix-checks') ? fixChecks : undefined, postReview, chained: inLoopLink }, + history: { priorRounds, priorFull, fullPasses: pass, last, fixedBlocking: has('--fixed-blocking'), fixedBelow: has('--fixed-below') || (postReview && pass > 0), blockingOpen: has('--blocking-open'), touchedGate: has('--touched-gate') || !!fixRange?.touched_gate || (postReview && pass > 0), pass1Depth, rangeRuntimeLines: fixRange?.runtime_lines, postReview }, }); - if (plan.next.reason.startsWith('PR_ROUND_CAP')) plan.next.reason += `: record this stop with gstack-ship-receipt stop --pr ${flag('--pr') ?? ''} --run --since , which prints the fix-check round grant (gstack-approvals round-grant --kind fix-check) that buys its fix round, in this run or the next; once it is recorded, pass the --round-grant and --stop the PR_REVIEW_FLAGS: line prints: in this run from gstack-ship-receipt history --pr ${flag('--pr') ?? ''} --base --run (its preflight already ran, and a second one is refused), in a new run from its preflight (docs/troubleshooting.md#pr-round-cap)`; - if (carried) plan.next.reason = `the edits after the last fix-check ${fixCheckAt!.slice(0, 12)} are ${carried.paths.length ? `${carried.verdict === 'plain' ? 'plain docs' : `docs (${carried.paths.join(', ')})`}${carried.stamps.length ? ' and release stamps' : ''}` : 'release stamps'} (docsChangeSince), no gate-class edit (GST-1702): ${plan.next.reason}`; - else if (postReview && pass > 0) plan.next.reason = `edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path, never a note: ${plan.next.reason}`; + if (postReview && pass > 0) plan.next.reason = `edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path, never a note: ${plan.next.reason}`; if (postReview && plan.next.step === 'stop') { const status = rangeBase ? git(['diff', '-z', '--name-status', '--no-renames', rangeBase, own ?? head])?.split('\0').filter(Boolean) : undefined; const pairs = status ? Array.from({ length: status.length >> 1 }, (_, i) => [status[2 * i]!, status[2 * i + 1]!] as const) : undefined; @@ -316,10 +226,9 @@ function main(): number { } const ranArg = flag('--targeted-ran'); const delta = plan.next.step !== 'done' || !targeted.classes.length || ran ? null - : carried?.verdict === 'claim' ? { state: 'dispatch' as const, range_base: fixCheckAt!, paths: [...carried.paths] } - : rangeBase && ranArg ? targetedDelta(root, ref, rangeBase, ranArg, !!grant) : null; + : rangeBase && ranArg ? targetedDelta(root, ref, rangeBase, ranArg) : null; if (delta?.state === 'dispatch') { - const why = grant ? `the owner's grant ${grant} covers the fix round that changed ${delta.paths.join(', ')}` : `the only change since is docs whose claim the record cannot carry (${delta.paths.join(', ')})`; + const why = `the only change since is docs whose claim the record cannot carry (${delta.paths.join(', ')})`; plan.next = { step: 'targeted', reason: `the loop is done and ${why} after the targeted read at ${delta.range_base.slice(0, 12)}: one targeted reader reads HEAD for ${classList(targeted.classes)}; it is not a review round` }; plan.dispatches.push({ role: 'targeted', name: 'targeted', effort: ROLE_EFFORT.targeted, exclude: active ? [...active.specs] : [], classes: [...targeted.classes], ...(active?.keep.length ? { keep: [...active.keep] } : {}) }); } else if (delta) plan.skipped.push(`targeted-only read (${delta.reason})`); @@ -329,7 +238,7 @@ function main(): number { } const targetedDeltaOut = delta?.state === 'dispatch' ? { range_base: delta.range_base, paths: delta.paths, classes: targeted.classes } : null; const selection = policySelection(active && { state: 'active', specs: active.specs, keep: active.keep, excerpt: active.excerpt }, readers); - plan.dispatches.forEach((d, i) => { if (d.role !== 'fix-check') plan.dispatches[i] = selectFor(d, selection); }); + plan.dispatches.forEach((d, i) => { plan.dispatches[i] = selectFor(d, selection); }); const gateScan = { tagged: gateTagged, head }; if (has('--json')) { const { runtimeLines, stepDepth, depthReasons, ...rest } = plan; diff --git a/bin/gstack-ship-queue b/bin/gstack-ship-queue index ff87ff1ab..4e366c8c8 100755 --- a/bin/gstack-ship-queue +++ b/bin/gstack-ship-queue @@ -3,7 +3,7 @@ * gstack-ship-queue — the shared merge queue, one subcommand per protocol * step (field list 2, W1; docs/ship-policy.md#run-a-shared-merge-queue). * - * gstack-ship-queue ready --pr [--pregate ] [--trail ] [--gate-exit --gate-log ] + * gstack-ship-queue ready --pr [--pregate ] [--gate-exit --gate-log ] * (refused with QUEUE_RECEIPT_MISSING|STALE unless the PR body carries /ship's receipt for HEAD) * gstack-ship-queue stamp --pr --version --expect-gated --expect-base * [--expect-order ] [--allow-repo-commands] [--gate-exit --gate-log ] @@ -48,11 +48,11 @@ logShipCall('gstack-ship-queue'); const HELP = `gstack-ship-queue — the shared merge queue's protocol steps (docs/ship-policy.md#run-a-shared-merge-queue) - ready --pr [--pregate ] [--trail ] [--gate-exit --gate-log ] + ready --pr [--pregate ] [--gate-exit --gate-log ] READY # STAMP_VERSION=, CI at that head, PREGATE, gate state, SHIP_RECEIPT (refused unless the PR body carries /ship's receipt for that head), - TRIAL_MERGES for each open PR sharing a file, and the Attention line: a risk-class - receipt names the --trail's newest trail-read row, or prints MISSING: cross-family trail read + TRIAL_MERGES for each open PR sharing a file, and the Attention section opened by the + receipt's risk class stamp --pr --version --expect-gated --expect-base [--expect-order ] [--allow-repo-commands] [--gate-exit --gate-log ] restamp, commit and prove: QUEUE_STAMP: head= gated= tree= receipt= @@ -249,10 +249,10 @@ async function main(argv: string[]): Promise { if (explicitBase && prBase && prBase !== ctx.base) return finish('ready', { ok: false, lines: [], run: 'none', failure: { code: 'QUEUE_NOT_READY', message: `#${pr} targets ${prBase}, not ${ctx.base}, so a receipt reviewed against ${ctx.base} does not cover it`, fix: `rerun ready without --base, or with --base ${prBase}` } }); const unfetched = refreshBase(ctx); const loaded = loadBasePolicy(ctx); - if (!('message' in loaded) && loaded.policy.train) return (await import('../crew/lib/ship-queue-train-cli')).readyMain(ctx, args, { pr, pregate: flag(args, '--pregate'), trail: flag(args, '--trail'), ...gate }); + if (!('message' in loaded) && loaded.policy.train) return (await import('../crew/lib/ship-queue-train-cli')).readyMain(ctx, args, { pr, pregate: flag(args, '--pregate'), ...gate }); if (unfetched) return finish('ready', { ok: false, lines: [], run: 'none', failure: unfetched }); if (['--screen', '--no-screen', '--broad'].some(f => args.includes(f))) process.stderr.write('gstack-ship-queue ready: --screen/--no-screen/--broad ignored: the base policy declares no train block\n'); - return finish('ready', ready(ctx, { pr, pregate: flag(args, '--pregate'), trail: flag(args, '--trail'), ...gate })); + return finish('ready', ready(ctx, { pr, pregate: flag(args, '--pregate'), ...gate })); } if (cmd === 'stamp') { const version = flag(args, '--version'); diff --git a/bin/gstack-ship-receipt b/bin/gstack-ship-receipt index 32bd39934..2e5fe77f1 100755 --- a/bin/gstack-ship-receipt +++ b/bin/gstack-ship-receipt @@ -17,9 +17,8 @@ * gstack-ship-receipt docs-caps [--base ] [--policy ] [--json] * gstack-ship-receipt history (--pr [--repo ] | --body ) [--head ] [--base ] [--run ] [--json] * gstack-ship-receipt stub (--pr [--repo ] | --body ) --run [--head ] [--review-loop ] [--void] - * gstack-ship-receipt stop (--pr [--repo ] | --body ) --run --since + * gstack-ship-receipt stop [--pr [--repo ] | --body ] --run --since * gstack-ship-receipt abandoned (--pr [--repo ] | --body ) --run --by --reason - * gstack-ship-receipt claim (--pr [--repo ] | --body ) --run --grant * * `write` validates against `gstack-artifact schema ship-receipt`, prints the * fenced block (and SHIP_RECEIPT: on stderr), writes it to --out, @@ -58,7 +57,7 @@ import { import { checkDocsCaps, docsCapLine, docsExceptionLine, parseReceiptDocs } from '../lib/ship-receipt-docs'; import { comparePath, contextPacket, PACKET_SECTION_CAP, readScopedReview, touchedPaths } from '../lib/ship-patch'; import { planRecheck, recheckPacket } from '../crew/lib/ship-recheck'; -import { carryExcludeBinds, deeper, depthBelow, exceptionHead, exceptionLoopProblem, exceptionProblems, parseReviewLoopException, parseReviewTargeted, plainDocsSince, platformReceiptDepth, receiptExclude, receiptExcludeFallback, receiptReviewAtHead, receiptTargetedAtHead, reviewLoopExceptionLine, targetedClassesSince, writeExcludeBinds } from '../lib/ship-receipt-depth'; +import { carryExcludeBinds, deeper, depthBelow, exceptionProblems, parseReviewTargeted, plainDocsSince, platformReceiptDepth, receiptExclude, receiptExcludeFallback, receiptReviewAtHead, receiptTargetedAtHead, targetedClassesSince, writeExcludeBinds } from '../lib/ship-receipt-depth'; import { RISK_CLASSES, type RiskClass } from '../lib/review-risk'; import { checkReceiptProse, proseLine } from '../lib/ship-receipt-prose'; import { resolveStateRoot } from '../lib/state-root'; @@ -67,10 +66,9 @@ import { publicRuledNote, readRuledNotes, ruledNoteText } from '../lib/ruled-not import { appliedGateDispositions, gateDispositionText, publicGateDisposition } from '../lib/gate-dispositions'; import { securityFingerprints } from '../lib/security-findings'; import { laneExceptionBodyLines } from '../lib/test-lane-exception'; -import { abandonMarker, grantedStop, grantMarker, historyLine, placeRunEntry, prReviewHistory, receiptedRun, reviewRoute, runStub, stopFrom, stopMarker } from '../lib/pr-review-history'; -import { changeRunRecord, readRunRecord } from '../lib/ship-run-record'; +import { abandonMarker, historyLine, placeRunEntry, prReviewHistory, receiptedRun, reviewRoute, runStub, stopFrom, stopMarker } from '../lib/pr-review-history'; +import { changeRunRecord } from '../lib/ship-run-record'; import { splitAgentNotes, withAgentNotes } from '../lib/agent-notes'; -import { grantFor, grantForPr, publicRoundGrant, readReviewRoundGrants, type ReviewRoundGrant } from '../lib/review-round-grant'; import { readMechanicalLines } from '../lib/ship-mechanical'; import { patchId, productPatchAgainstBase, productRules, productSpec, verifiedOutputs } from '../lib/ship-receipt-patch'; import { runCalls } from '../lib/ship-clock'; @@ -105,27 +103,22 @@ const HELP = `gstack-ship-receipt — the \`\`\`gstack-ship-receipt\`\`\` block R51 per pull request (docs/review-policy.md#rounds-per-pull-request): sums the review rounds the receipt and its runs block record across every head and /ship run, and prints PR_REVIEW_HISTORY:, PR_REVIEW_FLAGS: (what Step 9 passes to every gstack-review-plan call) and - PR_REVIEW_ROUTE: first|final|read-only|fix-check (why); a PR body gh cannot read prints source=unavailable - with its cause and fix on stderr (exit 1), and the plan then counts as it did before. A fix-check - grant naming the newest stop record adds --round-grant --stop (route fix-check; one - it can't apply prints PR_REVIEW_GRANT: not applied (why)); an extra-round grant at HEAD, or at a head - HEAD only merges --base into with the PR's own lines unchanged, adds --round-grant (GST-2968) + PR_REVIEW_ROUTE: first|final|read-only (why); a PR body gh cannot read prints source=unavailable + with its cause and fix on stderr (exit 1), and the plan then counts as it did before stub --pr | --body --run [--head ] [--review-loop ] [--void] Step 9: record this /ship run's rounds so far in the runs block before its receipt exists, so a run that stops still counts; the run's receipt write (same --run) replaces it; --void marks an - infrastructure failure that counts nothing. stub, stop, claim and carry with --pr edit the PR body + infrastructure failure that counts nothing. stub, stop and carry with --pr edit the PR body through gh; on Capy (GSTACK_CAPY=1) they print HOST_PUBLISH: with the body file instead (GST-3183) - stop --pr | --body --run --since + stop [--pr | --body ] --run --since Step 9, on NEXT: stop: record the review this run stopped on (its commit and tree, from the newest - via:ship review row bound to one committed tree) as a stop record in the runs block, and print the - round-grant command that buys its fix round (STOP_RECORD:, NEXT:); the stopping row is the newest - full pass, fix-check or Step 11 voice, so the stop is the head it read (#4591); it also marks this - checkout's run record stopped at that head and tree; an unbound read prints STOP_UNBOUND (exit 3) - and records nothing (docs/troubleshooting.md#stop-unbound) - claim --pr | --body --run --grant - before the first dispatch of a run whose PR_REVIEW_FLAGS: name --round-grant: record that this run - spends the grant (GRANT_CLAIMED:), in the PR body and in this checkout's run record; a grant - another run claimed is refused (GRANT_SPENT, exit 3) + via:ship review row bound to one committed tree) as a stop record in the runs block, and print what + the lane's Captain decides (STOP_RECORD:, NEXT:); the stopping row is the newest full pass or Step 11 + voice, so the stop is the head it read (#4591); it also marks this checkout's run record stopped at + that head and tree. Before a PR exists (no --pr and no --body), only the run record takes the stop + (pr=none; HARN-138), and a refused run-record write then exits 1 with no STOP_RECORD; a --pr + or --body with no value is a usage error (exit 2). An unbound read prints STOP_UNBOUND (exit 3) and records nothing + (docs/troubleshooting.md#stop-unbound) abandoned --pr | --body --run --by --reason gstack-ship-run abandon's PR-body half: a mark:abandoned entry in the runs block (RUN_ABANDON_MARK:) docs-caps [--base ] /ship Step 14.5: one DOCS_CAP: / ok|over line per docs.caps entry of the @@ -142,10 +135,7 @@ write flags: --pr --head --base --version --gated-tree --predecessor --gate ({passes, blocking_found, deferred[, noted, fixed, scope]}: gstack-review-scope summary --out) --docs ({status: updated|current|blocked, scope[, exception: {accepted_by, date, via, reason}]}: Step 14.5's outcome; blocked without an exception is DOCS_AUDIT_BLOCKED, and with --body the body must carry the exception line verbatim) - --review-loop-exception ({accepted_by, date, via, reason, fix_check: {head, findings[, files]}}: the owner accepted a - stop after a fix-check edit; needs --review-loop with fix_checks >= 1, fix_check.head an ancestor of the head, and with --body the - "Review-loop exception: …" line verbatim; or second_pass: {head, deferred: []} in place of fix_check for a stop after - the second full pass with a finding left open, needing passes >= 2 and deferred >= 1; else REVIEW_LOOP_EXCEPTION_INVALID). Every receipt records gstack_version and + Every receipt records gstack_version and review_depth: the depth HEAD needs, recomputed from the committed range (--head must be HEAD; a dirty checkout or an unreadable input records full). --review-exclude (the digest= on gstack-review-dispatch verify's REVIEW_EXCLUDE_RECORD: line, which the reviewers' briefs @@ -309,19 +299,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise { return EXIT.refused; } } - let loopException: ReturnType | undefined; - if (flag(rest, '--review-loop-exception') !== undefined) { - const refuse = (why: string) => { process.stderr.write(resultLineWithDocs('gstack-ship-receipt write', 'REVIEW_LOOP_EXCEPTION_INVALID', `${why}; nothing written`) + '\n'); return EXIT.fail; }; - try { loopException = parseReviewLoopException(jsonArg(flag(rest, '--review-loop-exception'))); } catch (e: any) { return refuse(`--review-loop-exception: ${e.message}`); } - if (!loopException.ok) return refuse(loopException.message); - let loop: unknown; try { loop = jsonArg(flag(rest, '--review-loop')); } catch {} - const loopProblem = exceptionLoopProblem(loopException.exception, parseReviewLoop(loop)); - if (loopProblem) return refuse(`--review-loop-exception ${loopProblem}`); - const fc = exceptionHead(loopException.exception); - if (spawnSync('git', ['merge-base', '--is-ancestor', fc, head], { cwd: repoRoot }).status !== 0) return refuse(`${loopException.exception.fix_check ? 'fix_check' : 'second_pass'}.head ${fc.slice(0, 12)} is not ${head.slice(0, 12)} or an ancestor of it`); - const line = reviewLoopExceptionLine(loopException.exception); - if (bodyFile && !bodyText.split(/\r?\n/).some(l => l.trim() === line)) return refuse(`${bodyFile} does not carry the exception line verbatim: ${JSON.stringify(line)}`); - } + if (flag(rest, '--review-loop-exception') !== undefined) { process.stderr.write(resultLineWithDocs('gstack-ship-receipt write', 'REVIEW_LOOP_EXCEPTION_INVALID', '--review-loop-exception was removed with fix-check grants (GST-3562 part 4): an open finding at the round cap ships only as a Ruled note the lane\'s Captain records with gstack-approvals rule; nothing written') + '\n'); return EXIT.usage; } const leaked = securityFingerprints(bodyText); if (leaked.length) { process.stderr.write(resultLine('gstack-ship-receipt write', 'RECEIPT_INVALID', `${bodyFile} names security finding ${leaked.join(', ')}: a PR body is public, so a security finding appears only as the redacted line gstack-approvals rulings, dispositions or gstack-review-scope render prints, and its location and reason stay in the private record (docs/troubleshooting.md#security-finding-in-body); nothing written`) + '\n'); return EXIT.fail; } const ruledNotes = readRuledNotes(repoRoot); @@ -395,14 +373,10 @@ async function cmdWrite(rest: string[], json: boolean): Promise { const at = headSha ?? head, baseRef = `origin/${base.replace(/^origin\//, '')}`, run = flag(rest, '--run'), pr = Number(flag(rest, '--pr')); const blockers = (Array.isArray(loopRaw?.open) ? loopRaw.open : []).filter((b: any) => ruledOpen.includes(typeof b === 'string' ? b : b?.id)); const rows = ruledOpen.length ? reviewRows(repoRoot) ?? [] : []; - const grants = ruledOpen.length ? readReviewRoundGrants(repoRoot).filter(g => g.kind === 'fix-check' && grantForPr(g, pr)) : []; - const live = grants.length && !receiptRuns(bodyText).length && flag(rest, '--pr') ? readBody(['--pr', flag(rest, '--pr')!, ...(flag(rest, '--repo') ? ['--repo', flag(rest, '--repo')!] : [])]) : undefined; - const clearing = ruledOpen.length ? await import('../lib/fix-check-clearing') : undefined; - const byGrant = !grants.length || !clearing ? undefined : !run ? { ids: [], why: 'write names no --run, so no run spent the grant' } : clearing.clearByGrant(repoRoot, { pr, run, head: at, baseRef, body: live?.ok ? live.body : bodyText, grants, rows, open: blockers }); + const clearing = ruledOpen.length ? await import('../lib/review-trailer-clearing') : undefined; const byTrailer = clearing ? clearing.clearByTrailer(repoRoot, { head: at, baseRef, rows, open: blockers }) : []; - if (byGrant) process.stderr.write(`FIX_CHECK_CLEAR: ${byGrant.ids.length ? `grant=${byGrant.approval} run=${byGrant.run} closed=${byGrant.ids.join(',')}` : 'none'}${byGrant.why ? ` (${byGrant.why})` : ''}\n`); for (const t of byTrailer) process.stderr.write(`TRAILER_CLEAR: ${t.id} (fixed by ${t.commit.slice(0, 12)}, read clean by the full review at ${t.review.slice(0, 12)})\n`); - const open = ruledOpen.filter(id => !byGrant?.ids.includes(id) && !byTrailer.some(t => t.id === id)); + const open = ruledOpen.filter(id => !byTrailer.some(t => t.id === id)); if (open.length) { process.stderr.write(resultLineWithDocs('gstack-ship-receipt write', 'RECEIPT_BLOCKER_OPEN', `${open.join(', ')}; nothing written`) + '\n'); return EXIT.refused; } input = { schema_version: 1, pr: flag(rest, '--pr') !== undefined ? Number(flag(rest, '--pr')) : undefined, head, @@ -416,7 +390,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise { policy: flag(rest, '--policy') ?? tree?.policy, queue_mode: flag(rest, '--queue-mode'), preregistration: flag(rest, '--preregistration'), history: flag(rest, '--history'), ...pregate, issues: issuesFile ? receiptIssuesFrom(issuesFile) : undefined, approval: approval.kind === 'ok' ? approval.approval : undefined, review_loop: reviewLoop, ...(docs?.ok ? { docs: docs.docs } : {}), ...product, - gstack_version: installedGstackVersion(), review_depth: reviewDepth, review_loop_exception: loopException?.ok ? loopException.exception : undefined, review_round_grants: roundGrantsFor(repoRoot, flag(rest, '--pr'))?.map(g => publicRoundGrant(g, ruledNotes)), cleared_by_grant: byGrant?.ids.length ? { approval: byGrant.approval!, run: byGrant.run!, ids: byGrant.ids } : undefined, cleared_by_trailer: byTrailer.length ? byTrailer : undefined, ruled_notes: ruledNotes.length ? ruledNotes.map(publicRuledNote) : undefined, gate_dispositions: gateDispositions.map(publicGateDisposition), mechanical: mechanical.length ? mechanical : undefined, review_targeted: targeted?.ok ? targeted.targeted : undefined, + gstack_version: installedGstackVersion(), review_depth: reviewDepth, cleared_by_trailer: byTrailer.length ? byTrailer : undefined, ruled_notes: ruledNotes.length ? ruledNotes.map(publicRuledNote) : undefined, gate_dispositions: gateDispositions.map(publicGateDisposition), mechanical: mechanical.length ? mechanical : undefined, review_targeted: targeted?.ok ? targeted.targeted : undefined, design: review.frontend ? { mode: 'static', reason: 'no preview declared' } : undefined, base_red: pause ? receiptBaseRed(pause) : undefined, review_exclude: receiptExclude(review.exclude), @@ -448,8 +422,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise { const block = renderReceiptBlock(receipt); const out = flag(rest, '--out'); if (out) fs.writeFileSync(out, block); - const closed = [...(receipt.cleared_by_grant ? [`Closed by grant ${receipt.cleared_by_grant.approval}: ${receipt.cleared_by_grant.ids.join(', ')} (the granted fix-check of run ${receipt.cleared_by_grant.run} read the fix clean)`] : []), - ...(receipt.cleared_by_trailer ?? []).map(t => `Closed by fix ${t.commit.slice(0, 12)}: ${t.id} (a later full review at ${t.review.slice(0, 12)} read it clean)`)]; + const closed = [...(receipt.cleared_by_trailer ?? []).map(t => `Closed by fix ${t.commit.slice(0, 12)}: ${t.id} (a later full review at ${t.review.slice(0, 12)} read it clean)`)]; if (body) { let text = fs.existsSync(body) ? fs.readFileSync(body, 'utf8') : ''; const pr = flag(rest, '--pr'); @@ -867,8 +840,7 @@ function cmdCarry(rest: string[], json: boolean): number { return refused('RECEIPT_CARRY_PREGATE_STALE', `the receipt records a pregate for ${receipt.head.slice(0, 12)}; run gstack-pregate at HEAD ${head.slice(0, 12)} and pass --pregate `); } let depthField: Partial = {}; - const isAncestor = (commit: string) => !ancestor || spawnSync('git', ['merge-base', '--is-ancestor', commit, head], { cwd: repoRoot, timeout: 30_000 }).status === 0; - const problems = exceptionProblems(body, receipt, isAncestor); + const problems = exceptionProblems(body, receipt); if (problems.length) return refused('RECEIPT_CARRY_REFUSED', `the receipt's owner exception does not stand: ${problems.join('; ')}; run /gstack-ship on ${head.slice(0, 12)}`); if (receipt.review_depth || receipt.gstack_version) { if (!receipt.review_depth) return refused('RECEIPT_CARRY_REFUSED', `the receipt records gstack_version but no review_depth, so the queue would refuse it; run /gstack-ship on ${head.slice(0, 12)}`); @@ -971,13 +943,6 @@ function cmdDocsCaps(rest: string[], json: boolean): number { return EXIT.fail; } -/** The round grants the branch's approval record holds for this PR (the receipt's review_round_grants). */ -function roundGrantsFor(repoRoot: string | undefined, pr: string | undefined): ShipReceipt['review_round_grants'] { - if (!repoRoot || !pr) return undefined; - const grants = readReviewRoundGrants(repoRoot).filter(g => String(g.pr) === pr); - return grants.length ? grants : undefined; -} - /** The PR body from --body or gh, or why it cannot be read. */ function readBody(rest: string[]): { ok: true; body: string; pr?: string } | { ok: false; why: string; fix: string } { const bodyFile = flag(rest, '--body'); @@ -1026,75 +991,37 @@ function cmdHistory(rest: string[], json: boolean): number { const repoRoot = git(['rev-parse', '--show-toplevel']); const head = (flag(rest, '--head') ?? (repoRoot ? git(['rev-parse', 'HEAD'], repoRoot) : undefined))?.toLowerCase(); const h = prReviewHistory(read.body); - const grants = repoRoot && head && /^\d+$/.test(pr) ? readReviewRoundGrants(repoRoot) : []; - const answer = grants.length ? grantedStop(read.body, grants, { pr: Number(pr), head: head!, run: flag(rest, '--run'), isAncestor: ancestorIn(repoRoot!) }) : null; - const base = (flag(rest, '--base') ?? (repoRoot ? resolveBaseBranch(repoRoot) : 'main')).replace(/^origin\//, ''); - const baseRef = repoRoot ? [`origin/${base}`, base].find(ref => git(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], repoRoot)) : undefined; - const found: ReviewRoundGrant | undefined = answer?.ok ? answer.grant : grants.length ? grantFor(repoRoot!, grants, Number(pr), head!, baseRef) : undefined; - const claimed = found && !answer?.ok ? receiptRuns(read.body).find(r => r.mark === 'grant' && r.grant === found.approval && r.run !== flag(rest, '--run')) : undefined; - const grant = claimed ? undefined : found; - const route = answer?.ok ? { route: 'fix-check' as const, reason: `fix-check grant ${answer.grant.approval} answers the stop at ${answer.stop.head.slice(0, 12)} (run ${answer.stop.run}): one scoped fix-check of the PR's own change since it, for ${answer.grant.findings!.join(', ')}, with no new full review` } : reviewRoute(h, { grant: grant?.approval }); - const flagsLine = `PR_REVIEW_FLAGS: --prior-rounds ${h.rounds} --prior-full ${h.full}${grant ? ` --round-grant ${grant.approval}` : ''}${answer?.ok ? ` --stop ${answer.stop.head}` : ''}`; + const route = reviewRoute(h); + const flagsLine = `PR_REVIEW_FLAGS: --prior-rounds ${h.rounds} --prior-full ${h.full}`; const used = flag(rest, '--run') ? receiptedRun(read.body, flag(rest, '--run')!) : undefined; - if (json) { process.stdout.write(JSON.stringify({ pr, ...h, grant: grant ?? null, stop: answer?.ok ? answer.stop : null, route, run_used: used?.head ?? null }) + '\n'); return EXIT.ok; } - process.stdout.write(`${historyLine(pr, h)}\n${flagsLine}\nPR_REVIEW_ROUTE: ${route.route} (${route.reason})\n${answer && !answer.ok ? `PR_REVIEW_GRANT: not applied (${answer.why})\n` : ''}${claimed ? `PR_REVIEW_GRANT: not applied (grant ${claimed.grant} was claimed by run ${claimed.run}: a grant buys one round)\n` : ''}${used ? `PR_REVIEW_RUN_USED: run=${used.run} receipted at ${used.head.slice(0, 12)}\n` : ''}`); + if (json) { process.stdout.write(JSON.stringify({ pr, ...h, route, run_used: used?.head ?? null }) + '\n'); return EXIT.ok; } + process.stdout.write(`${historyLine(pr, h)}\n${flagsLine}\nPR_REVIEW_ROUTE: ${route.route} (${route.reason})\n${used ? `PR_REVIEW_RUN_USED: run=${used.run} receipted at ${used.head.slice(0, 12)}\n` : ''}`); return EXIT.ok; } const ancestorIn = (repoRoot: string) => (a: string, d: string) => a === d || spawnSync('git', ['merge-base', '--is-ancestor', a, d], { cwd: repoRoot, timeout: 30_000 }).status === 0; -/** Step 9 on NEXT: stop (GST-2968): record the review this run stopped on, so a fix-check grant has one stop to answer. */ +/** Step 9 on NEXT: stop (GST-2968): record the review this run stopped on, in the PR body when one exists and in the run record (HARN-138: a stop before any PR records the run record only). */ function cmdStop(rest: string[]): number { const run = flag(rest, '--run'), since = flag(rest, '--since'); if (!run || !/^[\w.:-]{1,120}$/.test(run) || !since) { process.stderr.write('gstack-ship-receipt stop: --run and --since are required\n'); return EXIT.usage; } const repoRoot = git(['rev-parse', '--show-toplevel']); if (!repoRoot) { process.stderr.write('gstack-ship-receipt stop: run it inside the git checkout\n'); return EXIT.usage; } - const read = readBody(rest); - if (!read.ok) { process.stderr.write(`gstack-ship-receipt stop: ${read.why}; fix: ${read.fix}\n`); return EXIT.fail; } + const valueless = ['--pr', '--body'].filter(n => rest.includes(n) && (flag(rest, n) ?? '--').startsWith('--')); + if (valueless.length) { process.stderr.write(`gstack-ship-receipt stop: ${valueless.join(' and ')} needs a value (--pr , --body ); leave both out only before the PR exists\n`); return EXIT.usage; } + const prePr = !rest.includes('--pr') && !rest.includes('--body'); + const read = prePr ? undefined : readBody(rest); + if (read && !read.ok) { process.stderr.write(`gstack-ship-receipt stop: ${read.why}; fix: ${read.fix}\n`); return EXIT.fail; } const rows = reviewRows(repoRoot); if (!rows) { process.stderr.write('gstack-ship-receipt stop: gstack-review-read failed; nothing recorded\n'); return EXIT.fail; } const headNow = git(['rev-parse', 'HEAD'], repoRoot) ?? ''; const found = stopFrom(rows, since, { treeOf: c => git(['rev-parse', '--verify', '--quiet', `${c}^{tree}`], repoRoot), onHead: c => ancestorIn(repoRoot)(c, headNow) }); - if (!found.ok) { process.stderr.write(`${resultLine('gstack-ship-receipt stop', 'STOP_UNBOUND', `${found.why}; no stop record, so no fix-check grant can answer this stop`)}\n`); return EXIT.refused; } - const err = postBody(rest, read.pr, placeRunEntry(read.body, stopMarker({ head: found.head, tree: found.tree, run }))); + if (!found.ok) { process.stderr.write(`${resultLine('gstack-ship-receipt stop', 'STOP_UNBOUND', `${found.why}; no stop record`)}\n`); return EXIT.refused; } + const err = read?.ok ? postBody(rest, read.pr, placeRunEntry(read.body, stopMarker({ head: found.head, tree: found.tree, run }))) : null; if (err) { process.stderr.write(`gstack-ship-receipt stop: ${err}; nothing recorded\n`); return EXIT.fail; } - const pr = read.pr ?? flag(rest, '--pr') ?? ''; const marked = changeRunRecord(repoRoot, 'stop', run, { stop: { head: found.head, tree: found.tree } }); - process.stdout.write(`STOP_RECORD: run=${run} head=${found.head} tree=${found.tree}\n${marked.ok ? '' : `RUN_RECORD: not marked stopped (${marked.why})\n`}NEXT: the lane or its Captain decides: ship with the open notes listed, park, or buy this stop's fix round with gstack-approvals round-grant --pr ${pr} --head ${found.head} --kind fix-check --stop-run ${run} --findings --reason "" --by , then take --round-grant and --stop from the PR_REVIEW_FLAGS: line of gstack-ship-receipt history --pr ${pr} --base --run ${run} in this run, or from a new run's preflight (docs/troubleshooting.md#pr-round-cap)\n`); - return EXIT.ok; -} - -/** Before a granted round's first dispatch: this run spends the grant, so no other run can buy the same round with it. */ -async function cmdClaim(rest: string[]): Promise { - const run = flag(rest, '--run'), id = flag(rest, '--grant'); - if (!run || !/^[\w.:-]{1,120}$/.test(run) || !id) { process.stderr.write('gstack-ship-receipt claim: --run and --grant are required\n'); return EXIT.usage; } - const repoRoot = git(['rev-parse', '--show-toplevel']); - if (!repoRoot) { process.stderr.write('gstack-ship-receipt claim: run it inside the git checkout\n'); return EXIT.usage; } - const read = readBody(rest); - if (!read.ok) { process.stderr.write(`gstack-ship-receipt claim: ${read.why}; fix: ${read.fix}\n`); return EXIT.fail; } - const grants = readReviewRoundGrants(repoRoot), g = grants.find(x => x.approval === id); - if (!g) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_UNKNOWN', `no approved fix-check or round grant ${id} (a gstack-approvals round-grant row, or an owner's review_loop_grant row) in this branch's approval record`)}\n`); return EXIT.refused; } - const other = receiptRuns(read.body).find(r => r.mark === 'grant' && r.grant === id && r.run !== run); - if (other) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_SPENT', `grant ${id} was claimed by run ${other.run}: a grant buys one round; the lane or its Captain records a new one`)}\n`); return EXIT.refused; } - const held = receiptRuns(read.body).some(r => r.mark === 'grant' && r.grant === id && r.run === run); - if (!held && g.kind === 'fix-check') { - const rows = reviewRows(repoRoot); - if (!rows) { process.stderr.write(`gstack-ship-receipt claim: gstack-review-read failed, so whether a fix-check already spent grant ${id} is unknown; not claimed, so do not dispatch\n`); return EXIT.fail; } - const { bindFixCheckRow, grantSpent } = await import('../lib/fix-check-clearing'); - if (grantSpent(rows, g, row => bindFixCheckRow(repoRoot, row, grants, { open: true }).ok)) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_SPENT', `a counted fix-check already read under grant ${id} (it carries the grant, or started after the grant was recorded): a grant buys one round; the lane or its Captain records a new one (docs/troubleshooting.md#pr-round-cap)`)}\n`); return EXIT.refused; } - } - const err = postBody(rest, read.pr, placeRunEntry(read.body, grantMarker({ head: g.head, run, grant: id }))); - if (err) { process.stderr.write(`gstack-ship-receipt claim: ${err}; not claimed, so do not dispatch\n`); return EXIT.fail; } - const handedOff = !flag(rest, '--body') && hostPublishes(); - const again = handedOff ? { ok: true as const, body: placeRunEntry(read.body, grantMarker({ head: g.head, run, grant: id })) } : readBody(rest); - if (!again.ok) { process.stderr.write(`gstack-ship-receipt claim: ${again.why}; the claim is unconfirmed, so do not dispatch\n`); return EXIT.fail; } - const first = receiptRuns(again.body).find(r => r.mark === 'grant' && r.grant === id); - if (first?.run !== run) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_SPENT', `grant ${id} was claimed by run ${first?.run ?? 'another run'} while this run claimed it: a grant buys one round; the lane or its Captain records a new one`)}\n`); return EXIT.refused; } - const bodyPr = read.pr ?? flag(rest, '--pr'); - const claimPr = g.pr || (bodyPr && /^[1-9]\d*$/.test(bodyPr) ? Number(bodyPr) : undefined); - const recorded = changeRunRecord(repoRoot, 'claim', run, { claim: { grant: id, ...(g.stop_run ? { stop_run: g.stop_run } : {}), stop_head: g.head, findings: g.findings ?? [], ...(claimPr ? { pr: claimPr } : {}) } }); - if (!recorded.ok && readRunRecord(repoRoot).kind !== 'none') { process.stderr.write(`gstack-ship-receipt claim: the run record did not take the claim (${recorded.why}); not claimed, so do not dispatch: the PR body already holds run ${run}'s claim, so rerun claim with this same --run once the record is writable (a new run id reads GRANT_SPENT)\n`); return EXIT.fail; } - process.stdout.write(`GRANT_CLAIMED: grant=${id} kind=${g.kind} run=${run} head=${g.head.slice(0, 12)}\n${recorded.ok ? '' : `RUN_RECORD: claim not recorded (${recorded.why})\n`}`); + if (!read && !marked.ok) { process.stderr.write(`gstack-ship-receipt stop: the run record refused the stop (${marked.why}); with no PR nothing else holds it, so nothing is recorded\n`); return EXIT.fail; } + process.stdout.write(`STOP_RECORD: run=${run} head=${found.head} tree=${found.tree}${read ? '' : ' pr=none'}\n${marked.ok ? '' : `RUN_RECORD: not marked stopped (${marked.why})\n`}${read ? '' : `STOP_RECORD: no PR yet, so only this checkout's run record holds the stop; open the PR before the next /gstack-ship run so its rounds count (HARN-138)\n`}NEXT: the lane's Captain decides (R51): ship with the open findings listed as notes (a blocker only as a Ruled note, gstack-approvals rule), park, or keep the fix and run /gstack-ship again for one read-only full review of the final head (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.ok; } @@ -1145,7 +1072,7 @@ async function main(argv: string[]): Promise { if (cmd === 'history') return cmdHistory(rest, json); if (cmd === 'stub') return cmdStub(rest); if (cmd === 'stop') return cmdStop(rest); - if (cmd === 'claim') return cmdClaim(rest); + if (cmd === 'claim') { process.stderr.write('gstack-ship-receipt claim: removed with round and fix-check grants (GST-3562 part 4); a PR at its round cap goes to the lane\'s Captain (docs/troubleshooting.md#pr-round-cap)\n'); return EXIT.usage; } if (cmd === 'abandoned') return cmdAbandoned(rest); process.stderr.write(`gstack-ship-receipt: unknown command ${cmd}\n${HELP}\n`); return EXIT.usage; diff --git a/changelog.d/ship-deletes-retired-grants.md b/changelog.d/ship-deletes-retired-grants.md new file mode 100644 index 000000000..e8780159e --- /dev/null +++ b/changelog.d/ship-deletes-retired-grants.md @@ -0,0 +1,10 @@ +### Removed + +- **/gstack-ship no longer has round grants, fix-check grants or the review-loop exception: after two review rounds a blocker ships only as an owner's ruled note, or the PR parks.** These paths were deprecated last release (fix-checks gave way to full second rounds) and kept breaking: four PRs in one day tried to repair the grant path. `gstack-approvals round-grant` and `gstack-ship-receipt claim` are gone. `gstack-review-plan` refuses `--grant`, `--round-grant`, `--stop`, `--fix-checks`, `--fix-check-prompt` and `--last fix-check`, and `gstack-ship-receipt write` and `gstack-ship-release finish` refuse `--review-loop-exception`; each refusal names the replacement. `gstack-no-stop` no longer records a scoped fix-check. Receipts written before keep their old fields, except that a receipt still recording a review-loop exception is now refused when the queue lands or carries it: run /gstack-ship again on that PR for a fresh receipt. +- **`gstack-ship-queue ready` no longer asks for a cross-family read of the decision trail.** It caught one finding in 17 reads, one the second-model reviewer had already raised. The READY's Attention section now opens with the receipt's risk class, and `--trail` is gone. `gstack-decision-trail` stays for runs that keep a trail. + +### Fixed + +- **`gstack-ship-receipt stop` works before a PR exists.** An unattended run that stopped at round 2 with no PR (harness-evals#592) had nowhere to write its stop. Without `--pr` it now records the stop in the run record and prints `pr=none`. +- **Receipt checks read a path with `*` or `?` in its name as that file.** The receipt's carry and depth checks passed paths to `git ls-tree` as patterns, so such a file could match others. They now pass `--literal-pathspecs`. +- **The /gstack-ship driver records spend at start and close only,** with no budget note after every program; the review pass's own note keeps the cap check. The driver also says that a plan agreed only in conversation must be written to a file the audit can find, or the run reads it as `plan=none` and skips the plan-completion reader (the last release's note said unattended runs skip that reader; that holds only for runs with no plan). diff --git a/crew/docs/captain.md b/crew/docs/captain.md index 5effccdec..de6459fbe 100644 --- a/crew/docs/captain.md +++ b/crew/docs/captain.md @@ -798,8 +798,8 @@ owner pre-approved (train gates, screens, bisects, the backstop, focused paid ca the owner's date and words and the cap per rerun; anything over the cap is a fresh ask. After a PR's two review rounds (`PR_ROUND_CAP`) it ships with its open notes listed, or the controller rules on the blocker; a PR past the cap whose code changed gets one read-only full review of its final head, -never an owner ask ([rounds per pull request](../../docs/review-policy.md#rounds-per-pull-request)). Round and -fix-check grants are deprecated and go in the next release. +never an owner ask ([rounds per pull request](../../docs/review-policy.md#rounds-per-pull-request)). There are no +round or fix-check grants (GST-3562 part 4). **B. The plan ask** ([template](../../captain/templates/plan-ask.md)): before → after, why it matters, what caused this work, the big decisions, and what we need from you in the ask diff --git a/crew/lib/ship-queue-train-cli.ts b/crew/lib/ship-queue-train-cli.ts index 527a8aefc..865967af4 100644 --- a/crew/lib/ship-queue-train-cli.ts +++ b/crew/lib/ship-queue-train-cli.ts @@ -184,7 +184,7 @@ export async function trainMain(ctx: QueueContext, args: string[]): Promise { +export async function readyMain(ctx: QueueContext, args: string[], base: { pr: string; pregate?: string; gateExit?: number; gateLog?: string }): Promise { const screen = args.includes('--screen'); const noScreen = args.includes('--no-screen'); if (screen && noScreen) return usage('pass one of --screen or --no-screen'); diff --git a/crew/lib/ship-queue-train-ready.ts b/crew/lib/ship-queue-train-ready.ts index a1da5ac12..830b60a72 100644 --- a/crew/lib/ship-queue-train-ready.ts +++ b/crew/lib/ship-queue-train-ready.ts @@ -37,7 +37,7 @@ import { finishPlanLine, readyPlan } from '../../lib/plan-record'; const Q = 'gstack-ship-queue'; export interface ReadyOptions { - pr: string; pregate?: string; trail?: string; gateExit?: number; gateLog?: string; screen?: 'screen' | 'no-screen'; broad: boolean; dryRun: boolean; + pr: string; pregate?: string; gateExit?: number; gateLog?: string; screen?: 'screen' | 'no-screen'; broad: boolean; dryRun: boolean; /** `--dispatch-ci`: run these workflows on the PR branch, wait, and clear the matching requires-remote pregate lanes before reading the head. */ dispatchCi?: { workflows: string[]; timeoutSec: number; pollMs: number }; /** `--base-red --fixer `: a conditional READY on a paused receipt, owned by the fixer PR (trains with gates only). */ diff --git a/crew/scripts/review-dispatch-compare.ts b/crew/scripts/review-dispatch-compare.ts index 17abb7fc0..e7c0cdd91 100755 --- a/crew/scripts/review-dispatch-compare.ts +++ b/crew/scripts/review-dispatch-compare.ts @@ -87,7 +87,7 @@ function newShip(f: Fixture, sc: Scenario): { calls: Call[]; ending: string } { adversarialRan ||= plan.dispatches.some(d => d.role === 'adversarial-native'); if (plan.next.step === 'voices') continue; const o = outcomes[sc][Math.min(i, outcomes[sc].length - 1)] ?? {}; - const last = plan.next.step === 'scoped' ? 'full' : plan.next.step; + const last = plan.next.step === 'scoped' || plan.next.step === 'fix-check' ? 'full' : plan.next.step; h = { fullPasses: h.fullPasses + (last === 'full' ? 1 : 0), last, ...o }; } for (const a of FIXED_AUDITS) calls.push({ role: 'audit', effort: 'light', diffBytes: f.diff_bytes / 2 }); diff --git a/crew/test/ship-queue-ready-notes-push.test.ts b/crew/test/ship-queue-ready-notes-push.test.ts index 36605a442..9ea3955d3 100644 --- a/crew/test/ship-queue-ready-notes-push.test.ts +++ b/crew/test/ship-queue-ready-notes-push.test.ts @@ -83,11 +83,11 @@ describe('ready refuses a READY note that never reached origin', () => { }, 120_000); }); -describe('ready under a train policy reads --trail and trial-merges non-ASCII paths (GST-3200 follow-up)', () => { - // Value: protects=gstack's own policy declares a train block, so its READY goes through the train route, which must carry - // --trail and compare sibling paths that git would C-quote; fails_when=the train route drops --trail and prints MISSING, or - // a sibling sharing café.txt reads as none share a file; seam=bin/gstack-ship-queue ready --no-screen with the train gh shim - test('the trail-read row names the reviewer and a sibling sharing café.txt is trial-merged', () => { +describe('ready under a train policy trial-merges non-ASCII paths (GST-3200 follow-up)', () => { + // Value: protects=gstack's own policy declares a train block, so its READY goes through the train route, which must compare + // sibling paths that git would C-quote and ask for no cross-family trail read (GST-3562 part 4); fails_when=a sibling sharing + // café.txt reads as none share a file, or the READY asks for a trail read; seam=bin/gstack-ship-queue ready --no-screen with the train gh shim + test('a sibling sharing café.txt is trial-merged and no trail read is asked for', () => { const fx = trainFixture(); fixtures.push(fx); const sibling = openPr(fx, '2', { file: 'café.txt', text: 'from #2\n', changelog: false }); @@ -96,11 +96,9 @@ describe('ready under a train policy reads --trail and trial-merges non-ASCII pa const tree = runBin(fx.repo, 'gstack-wtree', []).out.trim(); const pregate = path.join(fx.repo.root, 'pregate.json'); fs.writeFileSync(pregate, JSON.stringify({ schema_version: 1, tree, head, verdict: 'pass', checks: FULL_CHECKS })); - const trail = path.join(fx.repo.root, 'decisions.tsv'); - fs.writeFileSync(trail, 'ts\tphase\tdecision\twhy\tevidence\tresult\n2026-11-19T00:00:00Z\tstart\trun x opens this trail\tno earlier rows\trun:x\topen\n2026-11-19T00:01:00Z\ttrail-read\topenai/gpt-6.2-sol (Subagent 4)\trule 27\tflags.md\tNo flags\n'); - const r = queue(fx, ['ready', '--pr', '1', '--pregate', pregate, '--no-screen', '--trail', trail]); - expect(r.out).toContain('reviewed by openai/gpt-6.2-sol (Subagent 4) ('); - expect(r.out).toContain('trail row 2)'); + const r = queue(fx, ['ready', '--pr', '1', '--pregate', pregate, '--no-screen']); + expect(r.out).not.toContain('trail read'); + expect(r.out).toContain('Attention:'); expect(line(r.out, 'TRIAL_MERGES: ')).toStartWith(`TRIAL_MERGES: #2 ${sibling.slice(0, 12)} shares café.txt: `); }, 120_000); }); diff --git a/docs/review-policy.md b/docs/review-policy.md index 80e4d12aa..f60a4be83 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -106,10 +106,9 @@ incomplete coverage, which blocks until the reviewer is rerun. them (GST-967). The cap approves nothing. This cap counts rounds inside one run. Across heads and runs the PR's own count applies ([rounds per pull request](#rounds-per-pull-request)). - Owner grants of a fix-check (`review_loop_exception`, `--grant`, the - [fix-check chain](ship-policy.md#fix-check-chain)) are deprecated: code still - honors a grant recorded before GST-3562 for one release, and the next release - removes them. Record no new one. + Owner grants of a fix-check and round grants are gone (GST-3562 part 4): + `gstack-review-plan` refuses `--grant`, `--round-grant`, `--fix-checks`, + `--stop` and `--last fix-check`, and a grant row recorded earlier buys nothing. Edits that /gstack-ship Step 16 finds after the review bound that are only release stamps under the base policy's stamp rule (line-exact: one other line in a stamp file makes the file an edit) and docs are no gate-class edit: the plan @@ -187,92 +186,35 @@ caught on another crew's PRs. after that review also stops for the Captain (GST-3562 A). The count does not reopen. A new /gstack-ship run on such a PR plans this review as its pass 1, with the same `READ_ONLY:` staging and no fix round as the in-run case. -6. **Round grants (deprecated).** `gstack-approvals round-grant` (`--kind - fix-check` after a stop, `--kind extra-round` before review), `gstack-ship-receipt - claim` and the `--round-grant`/`--stop` flags Step 1 adds for them still work - for one release, so a grant recorded before GST-3562 keeps verifying; the next - release removes them. Record no new grant: after round 2 the PR ships with its - open notes or its Captain rules, and a PR whose code changed after the cap gets - the read-only full review in item 5. gstack never grants itself a round, and the - receipt lists older grants under `review_round_grants`. +6. **No round grants** (GST-3562 part 4 removed them, with `gstack-approvals + round-grant`, `gstack-ship-receipt claim` and the `--round-grant`/`--stop` flags). + After round 2 the PR ships with its open notes or its Captain rules: a blocker + ships only as a [ruled note](ship-policy.md#ruled-notes). A PR whose code + changed after the cap gets the read-only full review in item 5. gstack never + grants a round. ### What closes a finding (GST-3260) -The grant paths in this section are deprecated with the fix-check (GST-3562 A): -they keep a grant recorded before it verifying for one release, and the next -release removes them. /gstack-ship no longer plans a fix-check, so a new finding closes -by a fix that a later full round or the read-only final review reads clean, a -`Review-Finding` trailer, or the Captain's ruled note. +A finding closes by a fix that a later full round or the read-only final review +reads clean, a `Review-Finding` trailer, or the Captain's ruled note. Fix-checks +and the grants that bought them are gone (GST-3562 part 4), and so is the +`cleared_by_grant` closure; a receipt written before keeps the field. -A fix-check that a grant bought and that read the fix clean closes exactly the -findings the grant names, with no owner ruling. `gstack-ship-receipt write` -checks it from records gstack's tools wrote, never from the `--review-loop` -file (`lib/fix-check-clearing.ts`): the grant answers the newest stop record -for this PR; the PR body's first claim of it is this run's; exactly one -`review-fix-check` row carries it, and `gstack-review-log` stamped that row from -the claim (`fix_check_base`, `run`, `grant`, `pr`) with the digest of the hunks -its reader was given, which cover every path the stop-to-fix diff changes, and -the ledger ids, fingerprints and `a-…` approval ids its fix list named; the row read the stop's head to the receipt head (or a -head that only merges the base in) on one committed tree, with nothing open at -any severity; and the stop, the claim and the row's start were recorded in that -order. Each grant id the fix list named closes the one open blocker carrying -that id; a grant id the fix list left out closes nothing, and a fingerprint -shared by two blockers closes neither. Anything less closes nothing, and write -says why on a `FIX_CHECK_CLEAR:` line. The receipt records `cleared_by_grant`, -and the Agent notes section gets one `Closed by grant …` line. A finding whose -fix commit carries its `Review-Finding:` trailer also closes once a later full +A finding whose fix commit carries its `Review-Finding:` trailer closes once a later full round that finished and converged, bound to its committed tree and with that commit inside its range (a pass 1's `range_base: null` is the whole PR), left nothing open at all, by its status, its findings file or an inline finding (`cleared_by_trailer`, #4597). A security finding's raw `path:line:category` -fingerprint, with or without its line, never closes by grant or trailer, so no -closure line puts its location in the PR body, and a fix-check row whose -dispatch ledger can't be read closes nothing. finish counts the same -stamped row, anchored on the grant's stop rather than the newest reviewed tree -(#4612). +fingerprint, with or without its line, never closes by trailer, so no closure +line puts its location in the PR body. -**One grant path after a ruling at the cap (GST-3546).** Every fix-check grant is -the same grant, whichever row records it: - -- **Either row works.** A `gstack-approvals round-grant --kind fix-check` row and - an owner's `review_loop_grant ` approval row are both fix-check grants - for `gstack-review-plan --grant`, `gstack-ship-receipt claim` and write. The - older row names no PR, so it binds to the PR whose run claims it. -- **A grant needs no stop record.** `round-grant --kind fix-check` with no - `--stop-run` and no `--findings` buys one scoped fix-check of the change since - `--head`, the reviewed head. Use it for a post-review edit (a Step 14.5 docs - audit edit that #4708's one-reader packet doesn't take) or a ruling at the cap - whose run recorded no stop (`STOP_UNBOUND`). The run's own claim stands in for - the stop record: the grant, the claim and the fix-check's start must be - recorded in that order. -- **What it closes.** A grant that names findings closes those, as above. A - grant with no findings list closes each open blocker the fix list given to - its clean fix-check names. A blocker that no ruling, grant or fix list covers - still refuses `RECEIPT_BLOCKER_OPEN`, so the Captain's ruling at the cap needs - no hand-written per-finding rows, and nothing is closed that no reader read. -- **gstack builds the packet.** Once a run has claimed a grant, `gstack-review-plan - --fix-check-prompt` and the pass program build the reader's hunks from `git diff - HEAD` themselves (`FIX_CHECK_HUNKS:` says when a `--hunks` - file differed and was not used), so the hunks record always covers the whole - fix range. -- **A grant spends only on a counted fix-check.** A malformed row - (`converged:false`, or a claimed row whose hunks or tree don't bind) leaves the - grant unspent: the same run logs a correct row. A counted read that found - issues spends it like a clean one, so a grant still buys one fix round, and - write reads the first counted row only. -- **Only the lane or its Captain grants.** A row whose ask or scope mentions - `review_loop_grant`, in any spelling or scope, recorded with `gstack-approvals - add` inside this checkout's open /gstack-ship run is refused unless it relays their - message with `--owner-ref` and `--words`, as `round-grant` already required. -- **One read per grant.** Receipt write keeps every distinct read stamped with - the grant (a copied row counts once) and takes the first that counts; a read - whose dispatch ledger collected a finding counts as long as the row records - that finding, open or not. -- **Long reasons fit.** A `--reason` longer than the approval record's - 300-character ask is cut there with an ellipsis; `--words` (the reason by - default) keeps every word. +**A ruling at the cap needs no grant.** The Captain rules a blocker a note with +`gstack-approvals rule` ([ruled notes](ship-policy.md#ruled-notes)); a ruled +note closes it for receipt write, and nothing is closed that no reader read. +The grant path GST-3546 built (`round-grant --kind fix-check`, `review_loop_grant` +rows, `claim`) was removed in GST-3562 part 4. ### Transitions @@ -294,27 +236,16 @@ the same grant, whichever row records it: | round 2 on a light diff whose below-floor fixes change no runtime lines | done: notes in the PR body | | a fix after that read-only review | stop: the lane's Captain rules it a note (one `gstack-approvals rule --finding edit:` per edited path, which finish then routes as `RULED_EDIT`: [ruled edits](ship-policy.md#ruled-edits)), or the fix goes to a new /gstack-ship run's read-only full review | | a full pass that leaves a blocking finding open (fixed or not) | stop: name it for the owner | -| a fix-check (granted before GST-3562) that found nothing blocking | done | -| a fix-check (granted before GST-3562) that found a blocking finding | stop: name it for the owner | | a stop (any row above) on gate class before Step 11's voices ran | Step 11's voices (adversarial, outside, targeted), then ask again with `--adversarial-ran` | -| the stop after a fix-check (granted before GST-3562) that was the run's only one, with the owner's recorded grant (`--grant `) | one more scoped fix-check, after Step 11 on gate class, until a later release removes it; a grant after a round-2 full pass buys nothing, because the read-only full review replaces it | -| a round-2 fix-check that stops the same way, with the owner's recorded grant and `--fix-checks 1` | one scoped fix-check (round 3), after Step 11 on gate class | -| `--post-review` after a fix-check whose later edits are only release stamps and docs (`docsChangeSince`) | done, or the one targeted reader when a docs claim on a targeted-class diff needs it | -| `--post-review` after a fix-check (edits after the review bound), with a new recorded grant at a stop head after the last fix-check's commit | one scoped fix-check, the next link of the fix-check chain, after Step 11 on gate class | -| a fix-check that stops in the loop, with a new recorded grant naming its own commit (`--range-base`, the stop it answers), after any number of fix-checks | one scoped fix-check, the next link of the fix-check chain, after Step 11 on gate class | -GST-3562 A retires the fix-check: `nextStep` plans none, and the rows that name -one serve grants recorded before it, for one release. Its 3,932,160-case replay -against main's table is `test/fixtures/review-pins/replays/GST-3562-A.json`. -A **fix-check** is one reviewer reading the touched hunks, the fix list, the -test results and the callers of every changed symbol, at full effort. It is -logged as a `review-fix-check` row, so it never counts as a pass. No army, no -Red Team and no outside voice run on it. +GST-3562 A retired the fix-check (`nextStep` plans none; its 3,932,160-case replay +against main's table is `test/fixtures/review-pins/replays/GST-3562-A.json`), and +GST-3562 part 4 removed the grants that still planned one. `NEXT: voices` runs Step 11 as `done` does, from the last full pass's manifest; /gstack-ship then asks the plan again with `--adversarial-ran` (a blocking finding the voices queued counts as `--blocking-open`, never a new Step 9), and -the stop or the granted fix-check it names stands. +the stop it names stands. The **scoped pass is retired** (GST-3562 part 3, 2026-11-24): every round 2 is a @@ -356,7 +287,7 @@ stop goes to the owner as before. Every other stop still stops. | Class | Qualifies when | What happens next | |---|---|---| -| `scoped-fix-check` | Round 2 stops for a fix whose range since round 2's `PASS_HEAD` is docs class only, or only raises timeout values. `--range-base` must be the commit the newest review-log pass row read. One per branch: the ledger keeps every record, so a later /gstack-ship on the branch stops for the owner. | It records the standing grant in the approval record (`by: gstack no-stop default (K1)`) and prints `GRANT:`. `gstack-review-plan --grant` plans the one scoped fix-check. A blocking finding there goes to the owner. | +| `scoped-fix-check` | Removed with fix-check grants (GST-3562 part 4). | `record` refuses it (exit 3): a stop after round 2 goes to the lane's Captain, who ships it with notes or parks it. | | `test-timeout-fix` | Every changed line is in a test file and only raises a timeout value: the value of a timeout key (`timeout: 5_000`, `setDefaultTimeout(5_000)`, `--timeout=5000`) or bun's and jest's trailing per-test argument, only on the line that opens the test call itself (`test('…', () => {…}, 30_000);`, likewise `it(` and `describe(`). A multi-line test's closing `}, 30_000);` does not qualify and stops for the owner. A line with `expect`, `assert` or a comparison never qualifies. | The gate scan's relaxation finding takes the printed `GATE_DISPOSITION: kept` reason instead of `open`. | | `pregate-flake-rerun` | One rerun of a failed pregate case at the same tree (CREW rule 16). One per branch. | Green counts as flaky. Red again is a real failure. | | `autoplan-regate` | An edit to the plan file made after the owner's answer, or after the revise that took their changes, while the reviewed plan itself is unchanged. The edit only adds lines, all inside the plan's `## ELI5` section (an added `## ELI5` heading opens one), and no added line holds a number or a word for spend, cost, budget, price, cap, credits, limit, max, arm, model, judge, verdict, threshold, bar, trial, sample, stop rule, paid or eval. A removed or reworded line, or a line added anywhere else, goes to the owner. The carry exports the reviewed plan, so the added explanation is never built. | `gstack-autoplan` carries the owner's words (`reason=no-stop autoplan-regate: …`) and writes `/no-stop.json`. `gstack-no-stop import` adds it to the branch's ledger. | @@ -418,9 +349,6 @@ lane knows the diff has, `gstack-review-plan --declare-risk ` adds it: detected classes, only raises the depth, and prints `RISK_DECLARED: classes= detected=`. The outside voice reads its diff from a file the brief names with its sha256; past 2,000,000 bytes it reads a path-scoped slice whose brief lists the files left out. -For a grant recorded before GST-3562 only (deprecated), `--fix-checks ` tells the loop how many fix-checks ran, so the grant -adds one fix-check after the first and never a second, in the lean loop and after -a round-2 fix-check in the full loop (GEVA-223). **Classes** are unchanged. A mixed diff takes its most restrictive class: **docs** (markdown no agent or gate reads), **tests** (test files and fixtures), **code** @@ -771,32 +699,18 @@ restamp gets the one reader (GST-1689). The reader reads the whole merge-base diff at HEAD, like every targeted reader. It isn't scoped to the docs change, because `render` reads no other base and a record that names HEAD is the one `write` binds. It is read-only -and applies no fix, so it isn't a review round under R51 and needs no grant. -A `--grant` is still checked against the approval record first, and a row -that isn't there refuses (exit 3). `gstack-review-dispatch pass` builds the +and applies no fix, so it isn't a review round under R51. `gstack-review-dispatch pass` builds the manifest: the one reader in the voices stage, with the `TARGETED_DELTA` line among its plan lines. After `verify --targeted-out`, pass the new `targeted_patch_id` and the plan is `done`. Every other case stays `done` and prints `SKIP: targeted-only read -()`. That covers a code or binary change with no `--grant` (the granted -case is below), which takes the review loop as before; plain docs and release stamps, which the record carries; a range_base the +()`, or refuses (`review_required_no_readers`) until the step names its fix. That covers a code or binary change, which takes the review loop as before; plain docs and release stamps, which the record carries; a range_base the `--targeted-ran` patch doesn't match; and uncommitted edits. `--force targeted` refuses (exit 2) and names these flags, because the targeted reader is no specialist (`lib/review-targeted-delta.ts`, `test/review-plan-targeted-delta.test.ts`). -A fix round the owner granted past the cap has the same problem in code -(harness-evals #271, GST-1607). The granted round's fix moves the product -patch the targeted record names, so the receipt asks for a fresh read once -the loop is done. With that grant passed as `--grant` (checked as above: -an approved `review_loop_grant` row naming a stop head inside -range_base..HEAD), any change since the read except plain docs plans the -same `NEXT: targeted`, and the reason names the grant. A head with no -targeted class adds no reader, and the same change with no grant keeps -`done` (`test/review-plan-granted-targeted.test.ts`). The Capy pass program -runs a targeted manifest's voices stage, so this one reader runs there too. - ## What readers read under `review_exclude_paths` @@ -938,42 +852,10 @@ class the lane added shows apart from what the matchers found) and the queue ref (capy-ai[bot]'s review id, reviewer and head); write and the queue accept it only under `review.platform on`, on a docs or tests diff with no numeric, results or prereg claims, with the review at that exact head, so a new head needs `/gstack-ship` again. A stop the owner -accepted after a fix-check edit (deprecated with fix-check grants; removed next release), or after the second full pass with a finding -left open (`second_pass`), goes in `review_loop_exception`, never in prose -under `REVIEW_LOOP:`. Step 16 takes the same record: -`gstack-ship-release finish --review-loop-exception ` routes the -paths the branch touched at `fix_check.head` (narrowed to the record's -`fix_check.files` when it lists them) and changed since as `accepted=` in -`ROUTE:`, prints them on a `REVIEW_LOOP_EXCEPTION:` line, and carries them -through the docs stage. A path outside that scope and a gate-edited test still -route as behavior, with `--reviewed-base` (as /gstack-ship passes it) so does a file -too large for the scoped review, and without the record nothing changes. - -A completed fix-check is a review, not an owner acceptance (GST-1130). Finish -reads the newest `review-fix-check` row from `gstack-review-read`, chained back -through earlier rows whose commit is the next row's `range_base` -([chained fix-checks](ship-policy.md#fix-check-chain), GST-1627). When every link -is a completed clean read on committed content (freshness `CURRENT` against its own -tree; a fix-check that stopped on findings the owner has since ruled notes reads -clean, [ruled notes](ship-policy.md#ruled-notes)) whose commit is on the branch, the oldest link's `range_base` is a branch commit -holding the reviewed tree (or following its commit by docs and release metadata -only, [docs bridge](ship-policy.md#fix-check-docs-bridge)), and for each link an approved `review_loop_grant` in -`gstack-approvals` names a stop head inside its `range_base..commit`, each code or test path inside a link's `range_base..commit` -that is unchanged since, or whose change against the base is still the one the -fix-check read after a base merge also edited it (GST-1195), routes as -`fix_checked=` in `ROUTE:` and is listed on a -`FIX_CHECK: reviewed` line, a gate-edited test included. The line names the -grant whose stop head is newest in that range, the fix-check's own when several -grants fall inside it (GST-1610). A `fix_checked` path the Step 14.5 audit -hashed also doesn't stale that audit at stage 3: `DOCS: fresh` counts it as -`fix_checked=` in its carried list, since a clean fix-check read its current -bytes and the path is unchanged since that read (GST-3560). Authored docs keep the -stage 2.2 recheck, and a path the branch edited after the fix-check still routes by the -rules above. Any other row prints -`FIX_CHECK: not counted ()` and changes nothing. `gstack-review-log` -refuses a `review-fix-check` row without boolean `completed` and `converged`, -before it consumes the start token, because without them the row reads -`UNVERIFIED` and finish cannot count it. +accepts ships as a [ruled note](ship-policy.md#ruled-notes), never in prose under +`REVIEW_LOOP:`; the review-loop exception and finish's fix-check counting +(`FIX_CHECK:`, `fix_checked=`, `REVIEW_LOOP_EXCEPTION:`) were removed with fix-check +grants in GST-3562 part 4. ### Bounded post-review edits (GST-1276, GST-1311) diff --git a/docs/ship-policy.md b/docs/ship-policy.md index c2225d589..b2a84db46 100644 --- a/docs/ship-policy.md +++ b/docs/ship-policy.md @@ -1409,25 +1409,11 @@ checked-out HEAD, when the receipt records `gstack_version` without `class` one of the four no-stop defaults. /gstack-ship passes the branch's `gstack-no-stop` ledger here ([review-policy.md#no-stop](review-policy.md#no-stop)). -**`review_loop_exception`.** Deprecated with fix-check grants (GST-3562 A; write -still takes one for a stop before it, and the next release removes it). The owner's acceptance of a stop after a -fix-check edit under frozen scope (#3559), from `write --review-loop-exception -`: `{ accepted_by, date, via, reason, fix_check: { head, findings[, files] } }`. -It needs `--review-loop` with `fix_checks` of 1 or more, a `fix_check.head` -that is the receipt head or its ancestor, and, with `--body`, the line -`Review-loop exception: accepted by via : (fix-check at , findings)` -word for word. A stop after the second full pass that left a finding open -(TRUT-7) takes `second_pass: { head, deferred: [] }` in place of -`fix_check`, with `--review-loop` counting 2 or more passes and 1 or more -deferred, and the line ends `(second full pass at , deferred )`; -finish does not take it, since it accepts an open finding, not edits. Otherwise -[`REVIEW_LOOP_EXCEPTION_INVALID`](troubleshooting.md#review-loop-exception-invalid) -and nothing is written. The queue checks both owner exceptions the same way -before READY and train build: the record must parse, the body must still -carry its line, and the exception's head (the fix-check's or the second -pass's) must be the bound head or its ancestor (after a carry across rewritten -history the old commit is off the branch, so that check is skipped), or the receipt is -[`QUEUE_RECEIPT_EXCEPTION_INVALID`](troubleshooting.md#queue-receipt-exception-invalid). +**`review_loop_exception`.** Removed in GST-3562 part 4. `write --review-loop-exception` +refuses with [`REVIEW_LOOP_EXCEPTION_INVALID`](troubleshooting.md#review-loop-exception-invalid) +and writes nothing: an open finding at the round cap ships only as a +[ruled note](#ruled-notes). A receipt written before that still records one no +longer stands: carry and the queue refuse it, so run /gstack-ship again. **Prose against the receipt.** `gstack-ship-receipt read --pr --check-prose` (or `--body `) compares every counter the body quotes with the receipt's @@ -1809,38 +1795,35 @@ construction: failed review. 3. **Two rounds is the cap** (R51), stepped by the [transition table](review-policy.md#transitions); a full pass counts as a - round, and /gstack-ship plans neither a fix-check nor a [scoped pass](review-policy.md#scoped-pass): any code change - after round 1 gets a full round 2, with no exception (GST-3562 A and part 3). A pass that applied no edits + round, and every round 2 is a full pass on the range: any code change after + round 1 gets one, with no exception (GST-3562 A and part 3). A pass that applied no edits continues to Step 10: the loop ships with its deferred and noted items named in the PR body. A blocking finding still open after the last allowed step stops the run and names the finding (path, severity, problem) for the lane's Captain instead of a third round: the PR ships with its open notes or the Captain rules. A fix applied in the last allowed round gets one read-only full review of the final head with no fix round (GST-3562 A); a fix after it - stops for the Captain. Fix-check and round grants are deprecated: one recorded - before GST-3562 still answers its stop for one release, and the next release - removes them. + stops for the Captain. There are no fix-check or round grants (GST-3562 part 4). **What ends a /gstack-ship run (GST-3260).** Preflight opens the run in the checkout's run record (`git rev-parse --git-path gstack-ship-run`), and while it is open a -full preflight, round grants, gate dispositions, lane exceptions and rulings +full preflight, gate dispositions, lane exceptions and rulings without `--owner-ref` stop. Only gstack's commands end it: `finish` removes the record (only when the open PR's body names that run), `gstack-ship-receipt stop` -marks it stopped (it may then record the fix-check grant for its own stop, once -per run, and a new run's preflight replaces it), `gstack-skill-end` marks it finished on any +marks it stopped (a new run's preflight replaces it), `gstack-skill-end` marks it finished on any outcome, and `gstack-ship-run abandon` ends a run that stopped working, never within 60 minutes of its last beat unless the harness process it ran under is provably gone (GST-3546). No timer ends a run. A bare marker from an older gstack reads as `legacy` and an unreadable record as `unreadable`; both block until abandoned. The record guards against mistakes, such as a base merge -under a run's readers or a run granting itself a round; it is not proof of who +under a run's readers; it is not proof of who the owner is. **Ruled notes (GST-1537).** R51's other answer to an open finding is the owner's ruling that it ships as a disclosed note, with the note listed. The owner records each ruling, one finding per row, through the approval record, outside the lane's -/gstack-ship run, naming the stop head it ruled at (the commit a `review_loop_grant` names): +/gstack-ship run, naming the stop head it ruled at: ```bash gstack-approvals rule --finding '' --head \ @@ -1866,32 +1849,15 @@ message; without it the refusal is `APPROVAL_RULING_RUN_OPEN`. `add` refuses a ruling: `ruled`, `action: "ruled"` or any other claim the lane writes on its own row is ignored. Step 16's `finish` reads the branch's rulings (`lib/ruled-notes.ts`) and prints each as `RULED_NOTE: at -ruled by at