From f87d4325a3f920f5305eafb6abd714dea7d1d683 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 18 Nov 2026 16:34:39 +0800 Subject: [PATCH] A round grant at the review round cap buys the fix round it names (GST-2968) (#4479) When /ship stops at a pull request's review round cap, a grant naming that stop now buys one scoped review of the fix, in the same run or the next, instead of another read-only full review. Before, a grant recorded after the read-only review, or between /ship runs, bought nothing, so teams paid for extra full reviews or second grants (ghome#40: $8.78 against about $3). Nothing to do: /ship prints the grant command when it stops. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=security Review-Finding: p1/specialist-batched#2 reader=state-machines Review-Finding: p1/specialist-batched#3 reader=testing Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p1/red-team#3 reader=red-team --- bin/gstack-approvals | 15 +- bin/gstack-doctor-components.sh | 3 + bin/gstack-review-plan | 14 +- bin/gstack-review-scope | 4 +- bin/gstack-ship-receipt | 90 +++++- ...s-the-fix-round-after-a-review-cap-stop.md | 4 + docs/review-policy.md | 59 +++- docs/troubleshooting.md | 63 +++- lib/headless-artifacts.ts | 4 +- lib/pr-review-history.ts | 60 +++- lib/result-codes-release.ts | 15 + lib/review-depth.ts | 10 +- lib/review-round-grant.ts | 96 +++++- lib/ship-preflight.ts | 2 +- lib/ship-receipt.ts | 9 +- lib/ship-release.ts | 5 +- scripts/lib/windows-curation.ts | 4 + ship/DRIVER.md | 4 +- ship/DRIVER.md.tmpl | 4 +- ship/sections/review-army.md | 9 +- ship/sections/review-army.md.tmpl | 9 +- .../files/lib/review-depth.ts.json | 2 +- .../files/ship/sections/review-army.md.json | 2 +- .../review-pins/replays/GST-2968.json | 1 + test/review-plan-pr-rounds.test.ts | 22 +- test/review-round-grant-own-lines.test.ts | 57 ++++ test/round-cap-granted-stop.test.ts | 276 ++++++++++++++++++ ...the-fix-round-after-a-review-cap-stop.json | 4 + 28 files changed, 761 insertions(+), 86 deletions(-) create mode 100644 changelog.d/round-grant-buys-the-fix-round-after-a-review-cap-stop.md create mode 100644 test/fixtures/review-pins/replays/GST-2968.json create mode 100644 test/review-round-grant-own-lines.test.ts create mode 100644 test/round-cap-granted-stop.test.ts create mode 100644 test/size-ledger/ship/round-grant-buys-the-fix-round-after-a-review-cap-stop.json diff --git a/bin/gstack-approvals b/bin/gstack-approvals index d76c0a4a3..e5b7fd7eb 100755 --- a/bin/gstack-approvals +++ b/bin/gstack-approvals @@ -13,7 +13,7 @@ * 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 --reason --by [--words ] [--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 ] @@ -33,7 +33,7 @@ import { GSTACK_ACTOR, openShipRun, RULED_NOTE_SCOPE, ruledNoteRow, ruledNotes, 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 { REVIEW_ROUND_GRANT_SCOPE, reviewRoundGrantRow, ROUND_GRANT_KINDS, type RoundGrantKind } from '../lib/review-round-grant'; +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) @@ -56,8 +56,10 @@ 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 --reason + round-grant --pr --head --kind extra-round|fix-check --reason --by [--words ] + [--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 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 @@ -88,7 +90,7 @@ Example: ${exitTableHelp()}`; -const VALUE_FLAGS = new Set(['--ask', '--words', '--by', '--scope', '--pending', '--outcome', '--date', '--source', '--branch', '--autoplan', '--stack', '--finding', '--reason', '--head', '--files', '--plan', '--gate-id', '--pr', '--kind']); +const VALUE_FLAGS = new Set(['--ask', '--words', '--by', '--scope', '--pending', '--outcome', '--date', '--source', '--branch', '--autoplan', '--stack', '--finding', '--reason', '--head', '--files', '--plan', '--gate-id', '--pr', '--kind', '--stop-run', '--findings']); function parse(args: string[]): { flags: Record; bools: Set; error?: string } { const flags: Record = {}; @@ -177,7 +179,10 @@ function main(argv: string[]): number { if (!by || GSTACK_ACTOR.test(by)) return invalid('round-grant needs --by : gstack never grants itself a round'); const open = openShipRun(process.cwd()); if (open) return invalid(`/ship run ${open} is open on this checkout: a round grant is the lane's or its Captain's, never the run's own; record it from the lane after the run stops`); - const built = buildRow({ ...reviewRoundGrantRow(head.stdout.trim(), Number(pr), kind, reason), words: flags['--words'] ?? reason, by, date: flags['--date'] }, loc.branch); + const stopRun = (flags['--stop-run'] ?? '').trim(), findings = [...new Set((flags['--findings'] ?? '').split(',').map(f => f.trim()).filter(Boolean))]; + if (kind === 'fix-check' && (!STOP_RUN.test(stopRun) || !findings.length || !findings.every(f => FINDING_ID.test(f)))) return invalid('round-grant --kind fix-check needs --stop-run and --findings : it buys the fix round of that one stop'); + 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' ? { run: stopRun, findings } : undefined), words: flags['--words'] ?? reason, by, date: flags['--date'] }, loc.branch); if ('code' in built) return fail(cmd, built); rows = [built]; } else if (cmd === 'lane-exception') { diff --git a/bin/gstack-doctor-components.sh b/bin/gstack-doctor-components.sh index ed561a833..a66a19b59 100644 --- a/bin/gstack-doctor-components.sh +++ b/bin/gstack-doctor-components.sh @@ -340,6 +340,9 @@ gstack_result_anchor() { CI_CARRY_RERUN_MALFORMED) printf '%s' 'ci-carry-rerun-malformed' ;; RECEIPT_CARRY_TREE_MISMATCH) printf '%s' 'receipt-carry-tree-mismatch' ;; RECEIPT_CARRY_PRODUCT_CHANGED) printf '%s' 'receipt-carry-product-changed' ;; + STOP_UNBOUND) printf '%s' 'stop-unbound' ;; + GRANT_SPENT) printf '%s' 'grant-spent' ;; + GRANT_UNKNOWN) printf '%s' 'grant-unknown' ;; RECEIPT_CARRY_SCOPED_REVIEW) printf '%s' 'receipt-carry-scoped-review' ;; DOCS_AUDIT_BLOCKED) printf '%s' 'docs-audit-blocked' ;; DOCS_RESULT_INVALID) printf '%s' 'docs-result-invalid' ;; diff --git a/bin/gstack-review-plan b/bin/gstack-review-plan index e5bee0122..929edc693 100755 --- a/bin/gstack-review-plan +++ b/bin/gstack-review-plan @@ -107,6 +107,8 @@ const HELP = `gstack-review-plan — the review depth of the next /ship step (do (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 @@ -158,7 +160,8 @@ function main(): number { 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'); + 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; } 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; } @@ -185,11 +188,16 @@ function main(): number { 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; if (has('--round-grant')) { const at = git(['rev-parse', 'HEAD'])?.trim(); const loc = locate({ cwd: root, env: process.env }); const g = reviewRoundGrants('file' in loc ? readRecord(loc).rows : []).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 && String(g.pr) !== 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 atOrBefore = !!g && !!at && (g.head === at || git(['merge-base', '--is-ancestor', g.head, at]) !== null); if (!roundGrant || !g || !atOrBefore || (pr !== undefined && String(g.pr) !== 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; } } @@ -276,9 +284,9 @@ function main(): number { 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, ...(roundGrant ? { roundGrant } : {}), fullPasses: pass, 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, ...(grantedStop ? { grantedStop } : roundGrant ? { roundGrant } : {}), fullPasses: pass, 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 }, }); - if (plan.next.reason.startsWith('PR_ROUND_CAP')) plan.next.reason += `: gstack-approvals round-grant --pr ${flag('--pr') ?? ''} --head ${head} --kind extra-round --reason "" --by , then rerun gstack-ship-preflight and pass the --round-grant id its PR_REVIEW_FLAGS: line prints; the grant buys one round at ${head.slice(0, 12)} and is then spent (docs/troubleshooting.md#pr-round-cap)`; + 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}`; const ranArg = flag('--targeted-ran'); diff --git a/bin/gstack-review-scope b/bin/gstack-review-scope index 5eab9312c..7279baf03 100755 --- a/bin/gstack-review-scope +++ b/bin/gstack-review-scope @@ -217,8 +217,8 @@ function cmdSummary(rest: string[], json: boolean): number { for (const u of summary.unbound ?? []) process.stderr.write(`REVIEW_SCOPE_UNBOUND: ${u}\n`); for (const v of summary.voided ?? []) process.stderr.write(`REVIEW_SCOPE_VOIDED: ${v}\n`); const line = reviewLoopLine(summary); - // A /ship invocation always runs Step 9 once; zero matching rows means the wrong --since or a review log written elsewhere, never a loop to record. - if (summary.passes === 0) return refuse('summary', 'REVIEW_SCOPE_INPUT', `no review-log row of this branch is a via:ship review at or after ${since}; check REVIEW_SINCE (${line})`); + // A /ship invocation always runs Step 9 once, or, answering a stop with a fix-check grant, only that fix-check (GST-2968); no row at all means the wrong --since or a review log written elsewhere, never a loop to record. + if (summary.passes === 0 && !summary.fix_checks) return refuse('summary', 'REVIEW_SCOPE_INPUT', `no review-log row of this branch is a via:ship review at or after ${since}; check REVIEW_SINCE (${line})`); process.stderr.write(line + '\n'); const out = flag(rest, '--out'); if (out) fs.writeFileSync(out, JSON.stringify(summary) + '\n'); diff --git a/bin/gstack-ship-receipt b/bin/gstack-ship-receipt index 607dd3d00..a91041a11 100755 --- a/bin/gstack-ship-receipt +++ b/bin/gstack-ship-receipt @@ -15,8 +15,10 @@ * gstack-ship-receipt census --repo --since [--cohort ] [--limit ] [--json] * gstack-ship-receipt carry (--pr [--repo ] | --body ) [--base ] [--head ] [--pregate ] [--dry-run] [--out ] [--json] * gstack-ship-receipt docs-caps [--base ] [--policy ] [--json] - * gstack-ship-receipt history (--pr [--repo ] | --body ) [--head ] [--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 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, @@ -49,7 +51,7 @@ import { approvalForReceipt } from '../lib/approval-citations'; import { CARRY_METADATA_GLOBS, CARRY_NAMED_PATHS, CARRY_TEST_GLOBS, bindReceipt, carryReceipt, recheckCarried, classifyCarryPath, computeCensus, extractReceipt, landedStackParent, missingIssueLines, orderReceipt, parseReviewLoop, placeReceipt, planCarry, planTreeCarry, - receiptIssuesFrom, receiptSummaryLine, renderCensus, renderReceiptBlock, validateReceipt, type CensusPr, + receiptIssuesFrom, receiptRuns, receiptSummaryLine, renderCensus, renderReceiptBlock, validateReceipt, type CensusPr, } from '../lib/ship-receipt'; import { checkDocsCaps, docsCapLine, docsExceptionLine, parseReceiptDocs } from '../lib/ship-receipt-docs'; import { comparePath, contextPacket, PACKET_SECTION_CAP, readScopedReview, touchedPaths } from '../lib/ship-patch'; @@ -62,8 +64,8 @@ import { readPause, receiptBaseRed } from '../lib/base-red'; import { readRuledNotes, ruledNoteText } from '../lib/ruled-notes'; import { appliedGateDispositions, gateDispositionText } from '../lib/gate-dispositions'; import { laneExceptionBodyLines } from '../lib/test-lane-exception'; -import { historyLine, placeRunEntry, prReviewHistory, reviewRoute, runStub } from '../lib/pr-review-history'; -import { grantAt, readReviewRoundGrants } from '../lib/review-round-grant'; +import { grantedStop, grantMarker, historyLine, placeRunEntry, prReviewHistory, reviewRoute, runStub, stopFrom, stopMarker } from '../lib/pr-review-history'; +import { grantFor, readReviewRoundGrants, type ReviewRoundGrant } from '../lib/review-round-grant'; import { readMechanicalLines } from '../lib/ship-mechanical'; import { isRegistryUnavailable, loadRegistryFromBase } from '../lib/regen'; import { runCalls } from '../lib/ship-clock'; @@ -94,16 +96,27 @@ const HELP = `gstack-ship-receipt — the \`\`\`gstack-ship-receipt\`\`\` block RECHECK: advisory … packet=: one reader may read it for advice; it never carries the receipt, so the head that merges runs /ship (J1, GST-2673); needs git >= 2.39 (RECEIPT_GIT_TOO_OLD) - history --pr [--repo ] | --body [--head ] + history --pr [--repo ] | --body [--head ] [--base ] [--run ] 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 (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 + 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) 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 + 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:); 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:); a grant another run claimed is refused (GRANT_SPENT, exit 3) docs-caps [--base ] /ship Step 14.5: one DOCS_CAP: / ok|over line per docs.caps entry of the reviewed policy (origin/'s .gstack/ship-policy.json; --policy reads that file instead); any over (or absent) file exits 1 (DOCS_AUDIT_BLOCKED) @@ -1074,11 +1087,62 @@ 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 grant = repoRoot && head && /^\d+$/.test(pr) ? grantAt(readReviewRoundGrants(repoRoot), Number(pr), head) : undefined; - const route = reviewRoute(h, { grant: grant?.approval }); - const flagsLine = `PR_REVIEW_FLAGS: --prior-rounds ${h.rounds} --prior-full ${h.full}${grant ? ` --round-grant ${grant.approval}` : ''}`; - if (json) { process.stdout.write(JSON.stringify({ pr, ...h, grant: grant ?? null, route }) + '\n'); return EXIT.ok; } - process.stdout.write(`${historyLine(pr, h)}\n${flagsLine}\nPR_REVIEW_ROUTE: ${route.route} (${route.reason})\n`); + 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}` : ''}`; + if (json) { process.stdout.write(JSON.stringify({ pr, ...h, grant: grant ?? null, stop: answer?.ok ? answer.stop : null, route }) + '\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` : ''}`); + 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. */ +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 log = runScriptSync(path.join(path.dirname(Bun.fileURLToPath(import.meta.url)), 'gstack-review-read'), [], { cwd: repoRoot, encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }); + if (log.status !== 0) { process.stderr.write(`gstack-ship-receipt stop: gstack-review-read exited ${log.status}; nothing recorded\n`); return EXIT.fail; } + const rows = (log.stdout ?? '').split('\n---CONFIG---')[0]!.split('\n').flatMap(l => { try { const v = JSON.parse(l); return v && typeof v === 'object' ? [v] : []; } catch { return []; } }); + 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 (err) { process.stderr.write(`gstack-ship-receipt stop: ${err}; nothing recorded\n`); return EXIT.fail; } + const pr = read.pr ?? flag(rest, '--pr') ?? ''; + process.stdout.write(`STOP_RECORD: run=${run} head=${found.head} tree=${found.tree}\nNEXT: 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. */ +function cmdClaim(rest: string[]): number { + 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 g = readReviewRoundGrants(repoRoot).find(x => x.approval === id); + if (!g) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_UNKNOWN', `no approved review_round_grant row ${id} 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 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 again = 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; } + process.stdout.write(`GRANT_CLAIMED: grant=${id} kind=${g.kind} run=${run} head=${g.head.slice(0, 12)}\n`); return EXIT.ok; } @@ -1112,6 +1176,8 @@ function main(argv: string[]): number { if (cmd === 'docs-caps') return cmdDocsCaps(rest, json); 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); process.stderr.write(`gstack-ship-receipt: unknown command ${cmd}\n${HELP}\n`); return EXIT.usage; } diff --git a/changelog.d/round-grant-buys-the-fix-round-after-a-review-cap-stop.md b/changelog.d/round-grant-buys-the-fix-round-after-a-review-cap-stop.md new file mode 100644 index 000000000..82d36c322 --- /dev/null +++ b/changelog.d/round-grant-buys-the-fix-round-after-a-review-cap-stop.md @@ -0,0 +1,4 @@ +--- +important: blocker +--- +- **A round grant at /ship's review round cap now buys the fix round it names, in the same run or the next (GST-2968).** When a review stops at the cap, /ship records the stop in the PR body (`gstack-ship-receipt stop`), and a `gstack-approvals round-grant --kind fix-check` naming that stop's head, run and findings buys one scoped fix-check of the fix instead of another read-only full review. Before, the read-only review had already counted as the extra round, so the grant bought nothing, and a grant recorded between /ship runs was ignored, so the next run paid for another full review. A grant is spent by the one run that claims it (`gstack-ship-receipt claim`), and an extra-round grant recorded before review keeps its fix round, also across preflight's base merge. diff --git a/docs/review-policy.md b/docs/review-policy.md index 2f73ee8f6..9f381c3d2 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -187,26 +187,55 @@ caught on another crew's PRs. full passes only, by design (`lib/review-depth.ts` `prCapped`): earlier runs' fix-checks and scoped passes show in `pr_rounds=` but don't count against it, because each run's own fix round is the in-run table's call. A full pass past two - stops with `PR_ROUND_CAP` and prints the exact `gstack-approvals - round-grant` command; a below-floor fix at the cap finishes with its notes - listed. The stop is the lane's or Captain's call, never an owner ask + stops with `PR_ROUND_CAP` and says how to record the stop and its grant + (item 6); a below-floor fix at the cap finishes with its notes listed. The stop is the lane's or Captain's call, never an owner ask ([troubleshooting](troubleshooting.md#pr-round-cap)). 5. **Read-only final review.** A PR that already had two full rounds and whose own code changed since still gets one full review of its final head. It has no fix round: below-floor findings ship as notes, and a blocker (open or fixed) or a gate-class edit stops with `PR_ROUND_CAP` for the lane's Captain - to decide: ship with the note, or park. A round grant recorded after the - read-only review doesn't buy a fix round, because that review already spent - the round the grant would add. The count does not reopen. -6. **Round grant.** `gstack-approvals round-grant --pr --head --kind - extra-round --reason --by ` records one grant for one - head: one round past the cap, with its fix round, instead of the read-only - review. Step 1's `PR_REVIEW_FLAGS:` then adds `--round-grant `, which - raises that run's cap by one round, and the plan refuses a grant for another - head or PR. The plan keeps the grant after the fix round's commits move HEAD - past it. gstack never grants itself a round: `--by gstack` and a grant - from inside an open `/ship` run are refused, and `add` refuses the scope. - The receipt lists grants under `review_round_grants`. + to decide: ship with the note, park, or buy that review's fix round with a + fix-check grant (item 6). The count does not reopen. +6. **Round grants.** Two kinds, each recorded with `gstack-approvals round-grant + --pr --head --reason --by `, and each spent + by the one run that claims it. + - **`--kind fix-check`, after a stop** (GST-2968). When a review stops, + `/ship` runs `gstack-ship-receipt stop`, which writes a stop record into + the PR body's runs block: the run, and the commit and tree the stopped review + read. It writes one only when that review finished, read one committed tree + from start to end on a clean checkout, and that commit is HEAD or under it + (`STOP_UNBOUND` otherwise). The grant names that stop's head, its run + (`--stop-run`) and the findings its fix round is for (`--findings`). It + buys the stopped review's fix round: one scoped fix-check of the PR's own + change since the stop's head (a base merge in between is not part of it), in + the same run or a new one on another machine, never a new full review. + Step 1's `PR_REVIEW_FLAGS:` adds `--round-grant --stop ` and the + route is `fix-check`. It answers only the newest stop record, and nothing + once another run reviewed after that stop, HEAD no longer contains the stop's + head, or another run claimed it (`PR_REVIEW_GRANT: not applied (why)`). + A fix-check found nothing to read (an empty, reverted or base-only change) + plans no fix-check. The fix-check never earns another: a blocker there + stops with `PR_ROUND_CAP` again. + - **`--kind extra-round`, before review.** One round past the cap, with its fix + round, at a head no review has stopped at: instead of the read-only review. + Step 1's `PR_REVIEW_FLAGS:` adds `--round-grant ` when the grant names + HEAD, or a head HEAD only merges the base into with the PR's own added and + removed lines byte-identical and in the same places (preflight merges the base + first); the plan raises that run's cap by one round, keeps the round's fix + round, and keeps the grant after the fix round's commits move HEAD past it. + An extra-round grant never answers a stop. + A run whose flags name a grant runs `gstack-ship-receipt claim` before its + first dispatch, which writes a grant record into the runs block; a grant + another run claimed is refused (`GRANT_SPENT`), a voided run's claim still + spends it, and stop and grant records are never trimmed from the block. + gstack never grants itself a round: `--by` naming gstack (any name starting + with "gstack", so a Captain called GStack Minder writes "Captain GStack + Minder") and a grant from inside an open `/ship` run are refused, and `add` + refuses the scope. `--by` is otherwise the caller's own text, recorded and + not checked: a lane that records a grant (or a ruling) from another checkout + under its Captain's name can't be told apart from the Captain doing it, so the + Captain's check of the receipt's `review_round_grants` and the PR body's lines + is the control. The receipt lists grants under `review_round_grants`. ### Transitions diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 9fa1bc80b..ffb1045e9 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -7427,16 +7427,63 @@ final head; this stop then means that review found a blocker or a gate-class edi `PR_REVIEW_FLAGS:`. A fix below the blocking floor finishes with its notes listed instead of stopping. -**Fix.** The lane's Captain decides. Ship with the open notes listed, or, when a finding above the floor is -open in this PR's own change or the design changed, have the lane or Captain -record one round with the command the `NEXT:` line prints, -`gstack-approvals round-grant --pr --head --kind extra-round --reason - --by `, then rerun `gstack-ship-preflight`: its -`PR_REVIEW_FLAGS:` line adds `--round-grant ` for the plan. -The grant names one head; a new push needs a new grant. This is not an owner -ask, and gstack cannot grant itself one (`--by gstack` is refused) +**Fix.** The lane's Captain decides. Ship with the open notes listed, park, or, +when a finding above the floor is open in this PR's own change, buy the stopped +review's fix round: + +1. Record the stop: `gstack-ship-receipt stop --pr --run + --since ` (`/ship` runs it on `NEXT: stop`). It prints + `STOP_RECORD:` and the grant command. +2. The lane or Captain records that grant: `gstack-approvals round-grant --pr + --head --kind fix-check --stop-run --findings + --reason --by `. +3. Commit the fix on top of the stop's head. A new run's `gstack-ship-preflight` + prints `PR_REVIEW_FLAGS:`; the same run, whose preflight already ran, gets + that line from `gstack-ship-receipt history --pr --base --run + `. It adds `--round-grant --stop `, and the plan is one scoped fix-check of the PR's own change + since that head, with no new full review. The run claims the grant first + (`gstack-ship-receipt claim`). + +A head no review has stopped at takes an `--kind extra-round` grant instead: +one full round with its fix round. Each grant is spent by the one run that +claims it. When `PR_REVIEW_GRANT: not applied (...)` prints, the reason names +what doesn't match (another stop or head, a stale stop, a claimed grant). This +is not an owner ask, and gstack cannot grant itself one (`--by` naming gstack +is refused) ([review-policy.md](review-policy.md#rounds-per-pull-request)). + + +### `STOP_UNBOUND` + +**Meaning.** `gstack-ship-receipt stop` found no review of this run that +gstack can tie to one commit: the newest `via:ship` review row since +`--since` is missing, didn't finish, read a tree that moved or wasn't +committed, or its commit isn't HEAD or under it. It recorded no stop record, so +no fix-check grant can buy that review's fix round. + +**Fix.** Nothing for a grant to answer. The lane's Captain ships with the open +notes listed or parks; a fresh `/ship` run gives the head its review ([review-policy.md](review-policy.md#rounds-per-pull-request)). + +### `GRANT_SPENT` + +**Meaning.** `gstack-ship-receipt claim` found another `/ship` run's grant +record for this round grant in the PR body's runs block. A grant buys one round, +and a voided run's claim still spends it. + +**Fix.** Record a new grant for the stop the PR is at now; `gstack-ship-receipt +stop` prints the command ([troubleshooting](#pr-round-cap)). + + +### `GRANT_UNKNOWN` + +**Meaning.** `gstack-ship-receipt claim --grant ` found no approved +`review_round_grant` row with that id in the branch's approval record or its +mirror. + +**Fix.** Pass the id `gstack-approvals round-grant` printed, from a checkout +that sees that record ([troubleshooting](#pr-round-cap)). + ### `RECEIPT_PROSE_MISMATCH` diff --git a/lib/headless-artifacts.ts b/lib/headless-artifacts.ts index e612e1047..bd8df14b8 100644 --- a/lib/headless-artifacts.ts +++ b/lib/headless-artifacts.ts @@ -129,7 +129,7 @@ export interface ShipReceipt { /** The owner's acceptance of a stop after a fix-check edit under frozen scope (#3559); the PR body repeats it word for word. */ review_loop_exception?: { accepted_by: string; date: string; via: string; reason: string; fix_check?: { head: string; findings: number; files?: string[] }; second_pass?: { head: string; deferred: string[] } }; /** Review round grants the lane or its Captain recorded for this PR (gstack-approvals round-grant, lib/review-round-grant.ts; GST-2673): never the owner's, so never in review_loop_exception. */ - review_round_grants?: Array<{ kind: 'extra-round'; head: string; pr: number; by: string; reason: string; at: string; approval: string }>; + review_round_grants?: Array<{ kind: 'extra-round' | 'fix-check'; head: string; pr: number; by: string; reason: string; at: string; approval: string; stop_run?: string; findings?: string[] }>; /** The owner's rulings that a finding ships as a disclosed note (gstack-approvals rule, lib/ruled-notes.ts); the PR body lists each one word for word (GST-1537). */ ruled_notes?: Array<{ finding: string; head: string; by: string; reason: string; at: string; approval: string }>; /** The owner's dispositions of gate findings (gstack-approvals gate, lib/gate-dispositions.ts); the PR body lists each one word for word (GST-2491). */ @@ -283,7 +283,7 @@ export const ARTIFACT_SCHEMAS = { review_targeted: { type: 'object', required: ['classes', 'rules', 'brief_sha', 'product_patch_id', 'status', 'findings', 'raised_by'], properties: { classes: { type: 'array', items: { enum: ['money', 'gate', 'auth', 'secret'] } }, rules: str, brief_sha: str, product_patch_id: str, status: { enum: ['done', 'failed', 'not-run'] }, findings: { type: 'integer', minimum: 0 }, raised_by: str } }, review_exclude: { type: 'object', required: ['source', 'patterns', 'applied', 'excluded', 'excluded_bytes', 'kept', 'gate_tagged', 'patterns_sha256', 'list_sha256', 'digest'], properties: { source: str, patterns: strList, applied: strList, excluded: { type: 'integer', minimum: 0 }, excluded_bytes: { type: 'integer', minimum: 0 }, kept: { type: 'integer', minimum: 0 }, gate_tagged: strList, patterns_sha256: str, list_sha256: str, digest: str } }, review_loop_exception: { type: 'object', required: ['accepted_by', 'date', 'via', 'reason'], properties: { accepted_by: str, date: str, via: str, reason: str, fix_check: { type: 'object', required: ['head', 'findings'], properties: { head: str, findings: { type: 'integer', minimum: 0 }, files: strList } }, second_pass: { type: 'object', required: ['head', 'deferred'], properties: { head: str, deferred: strList } } } }, - review_round_grants: { type: 'array', items: { type: 'object', required: ['kind', 'head', 'pr', 'by', 'reason', 'at', 'approval'], properties: { kind: { enum: ['extra-round'] }, head: str, pr: { type: 'integer', minimum: 1 }, by: str, reason: str, at: str, approval: str } } }, + review_round_grants: { type: 'array', items: { type: 'object', required: ['kind', 'head', 'pr', 'by', 'reason', 'at', 'approval'], properties: { kind: { enum: ['extra-round', 'fix-check'] }, head: str, pr: { type: 'integer', minimum: 1 }, by: str, reason: str, at: str, approval: str, stop_run: str, findings: { type: 'array', items: str } } } }, ruled_notes: { type: 'array', items: { type: 'object', required: ['finding', 'head', 'by', 'reason', 'at', 'approval'], properties: { finding: str, head: str, by: str, reason: str, at: str, approval: str } } }, gate_dispositions: { type: 'array', items: { type: 'object', required: ['finding', 'gate_id', 'head', 'by', 'reason', 'words', 'at', 'approval'], properties: { finding: str, gate_id: str, head: str, by: str, reason: str, words: str, at: str, approval: str } } }, mechanical: strList, diff --git a/lib/pr-review-history.ts b/lib/pr-review-history.ts index 9fc080992..6946cef62 100644 --- a/lib/pr-review-history.ts +++ b/lib/pr-review-history.ts @@ -9,8 +9,9 @@ */ import type { ShipReceipt } from './headless-artifacts'; import { withAgentNotes, splitAgentNotes } from './agent-notes'; -import { extractReceipt, receiptRun, receiptRuns, RECEIPT_RUNS_KEPT, RUNS_FENCE, RUNS_RE, type ReceiptRun } from './ship-receipt'; +import { extractReceipt, keptRuns, receiptRun, receiptRuns, RUNS_FENCE, RUNS_RE, type ReceiptRun } from './ship-receipt'; import { FULL_PASS_CAP } from './review-depth'; +import type { ReviewRoundGrant } from './review-round-grant'; export interface PrReviewHistory { /** /ship runs that reviewed (stubs and carries excluded). */ @@ -39,7 +40,7 @@ function entries(body: string): ReceiptRun[] { } export function prReviewHistory(body: string): PrReviewHistory { - const all = entries(body); + const all = entries(body).filter(e => !e.mark); const reviewed = new Map(); const ordered: Array = []; all.forEach((e, i) => { @@ -69,7 +70,8 @@ export function prReviewHistory(body: string): PrReviewHistory { */ export function placeRunEntry(body: string, entry: ReceiptRun): string { const runs = receiptRuns(body).filter(r => !(entry.status && r.status && r.run === entry.run)); - const kept = [...runs, JSON.parse(JSON.stringify(entry)) as ReceiptRun].slice(-RECEIPT_RUNS_KEPT); + if (entry.mark && runs.some(r => JSON.stringify(r) === JSON.stringify(entry))) return body; + const kept = keptRuns([...runs, JSON.parse(JSON.stringify(entry)) as ReceiptRun]); const block = '```' + RUNS_FENCE + '\n' + kept.map(r => JSON.stringify(r)).join('\n') + '\n```\n'; if (RUNS_RE.test(body)) return body.replace(RUNS_RE, () => block); if (extractReceipt(body).found) { @@ -85,7 +87,57 @@ export function placeRunEntry(body: string, entry: ReceiptRun): string { export const runStub = (o: { head: string; run: string; status: 'started' | 'voided'; loop: NonNullable }): ReceiptRun => ({ head: o.head, run: o.run, status: o.status, review_loop: o.loop }); -export type Route = { route: 'first' | 'final' | 'read-only'; reason: string }; +/** + * A stop record (GST-2968): the review a /ship run stopped on, written by gstack-ship-receipt stop when the plan prints NEXT: stop. + * head is the commit that review read, tree its tree; the review row bound to it (lib/ship-stop.ts). A grant marker records + * that a run claimed a round grant before dispatching the round it buys. Markers count no round and are never trimmed. + */ +export const stopMarker = (o: { head: string; tree: string; run: string }): ReceiptRun => ({ head: o.head, run: o.run, mark: 'stop', tree: o.tree }); +export const grantMarker = (o: { head: string; run: string; grant: string }): ReceiptRun => ({ head: o.head, run: o.run, mark: 'grant', grant: o.grant }); + +/** + * The stop record for the newest via:ship review row of this run (at or after since), or why none binds: the row must be complete, + * bound to one tree from start to end (verified, or incomplete because it stopped) that is its commit's own tree, read on a clean + * worktree, and that commit must be HEAD or an ancestor of it. A read gstack can't tie to a commit gives a grant nothing to answer. + */ +export function stopFrom(rows: readonly Record[], since: string, o: { treeOf: (commit: string) => string | undefined; onHead: (commit: string) => boolean }): { ok: true; head: string; tree: string } | { ok: false; why: string } { + const sinceMs = Date.parse(since); + const row = rows.filter(r => r && r.via === 'ship' && r.skill === 'review' && (!Number.isFinite(sinceMs) || Date.parse(r.timestamp) >= sinceMs)).at(-1); + if (!row) return { ok: false, why: `no via:ship review row at or after ${since}` }; + const b = row.review_binding, head = typeof row.commit_full === 'string' ? row.commit_full.toLowerCase() : ''; + if (row.completed !== true) return { ok: false, why: 'the stopping review is not complete (a reader is missing)' }; + if (!b || (b.state !== 'verified' && b.state !== 'incomplete') || typeof row.tree !== 'string' || b.start_wtree !== row.tree || b.end_wtree !== row.tree || (row.wtree !== undefined && row.wtree !== row.tree)) return { ok: false, why: `the stopping review is not bound to one committed tree (binding ${b?.state ?? 'missing'})` }; + if (!/^[0-9a-f]{40}$/.test(head) || o.treeOf(head) !== row.tree) return { ok: false, why: `the stopping review's commit ${head.slice(0, 12) || 'missing'} does not hold the tree it read` }; + if (!o.onHead(head)) return { ok: false, why: `the stopping review's commit ${head.slice(0, 12)} is not HEAD or an ancestor of it` }; + return { ok: true, head, tree: row.tree }; +} + +export type GrantedStop = { ok: true; grant: ReviewRoundGrant; stop: ReceiptRun } | { ok: false; why: string }; + +/** + * The fix-check grant that answers this PR's stop (GST-2968, GHOM-1): the newest stop record in the body, a fix-check grant naming + * its run and head for this PR, not claimed by another run, and HEAD at or after the stop's head. A stop is stale once a later run + * reviewed (a stub after it with a full pass, or a current receipt past its head): a grant then answers nothing. + */ +export function grantedStop(body: string, grants: readonly ReviewRoundGrant[], o: { pr: number; head: string; run?: string; isAncestor: (a: string, d: string) => boolean }): GrantedStop | null { + const fixChecks = grants.filter(g => g.kind === 'fix-check' && g.pr === o.pr); + if (!fixChecks.length) return null; + const runs = receiptRuns(body); + const at = runs.map(r => r.mark).lastIndexOf('stop'); + if (at < 0) return { ok: false, why: `no stop record in the PR body for grant ${fixChecks.at(-1)!.approval}; a fix-check grant answers the stop gstack-ship-receipt stop recorded` }; + const stop = runs[at]!; + const current = extractReceipt(body).receipt; + const later = runs.slice(at + 1).find(r => !r.mark && r.run !== stop.run && (r.review_loop?.passes ?? 0) > 0); + if (later || (current && typeof current.head === 'string' && current.head !== stop.head && o.isAncestor(stop.head, current.head))) return { ok: false, why: `the stop at ${stop.head.slice(0, 12)} (run ${stop.run}) is stale: run ${later?.run ?? current?.run} reviewed after it` }; + const g = [...fixChecks].reverse().find(x => x.head === stop.head && x.stop_run === stop.run); + if (!g) return { ok: false, why: `no fix-check grant names the newest stop (run ${stop.run} at ${stop.head.slice(0, 12)}): record one with gstack-approvals round-grant --kind fix-check --head ${stop.head} --stop-run ${stop.run}` }; + const claimed = runs.find(r => r.mark === 'grant' && r.grant === g.approval && r.run !== o.run); + if (claimed) return { ok: false, why: `grant ${g.approval} was claimed by run ${claimed.run}: a grant buys one round` }; + if (!o.isAncestor(stop.head, o.head)) return { ok: false, why: `HEAD ${o.head.slice(0, 12)} does not contain the stop's head ${stop.head.slice(0, 12)}: a head move voids grant ${g.approval}` }; + return { ok: true, grant: g, stop }; +} + +export type Route = { route: 'first' | 'final' | 'read-only' | 'fix-check'; reason: string }; /** * What review a head of the PR gets when carry can't keep its receipt (the PR's own lines changed; a head that only diff --git a/lib/result-codes-release.ts b/lib/result-codes-release.ts index 54a4ced8f..e0c2538d8 100644 --- a/lib/result-codes-release.ts +++ b/lib/result-codes-release.ts @@ -435,6 +435,21 @@ export const RELEASE_RESULT_CODES = { summary: 'the product diff against the base changed between the receipt\'s head and HEAD (a product file differs beyond a base merge, a test-only fix, release metadata or a regenerated output), so the reviewed verdict does not cover HEAD', fix: 'run /ship on the new head; the receipt carries only when every changed path is a test, release metadata, a registered output the pregate regen check proved, or the base merge, and the product patch-id is unchanged; base context next to unchanged reviewed hunks is RECEIPT_CARRY_SCOPED_REVIEW instead (one scoped fix-check, no /ship)', }, + STOP_UNBOUND: { + anchor: 'stop-unbound', + summary: 'gstack-ship-receipt stop found no review of this run bound to one committed tree, so it recorded no stop record', + fix: 'nothing for a grant to answer: the lane or its Captain ships with the open notes listed or parks; a fresh /ship run gives the head its review', + }, + GRANT_SPENT: { + anchor: 'grant-spent', + summary: 'another /ship run already claimed this round grant, and a grant buys one round', + fix: 'the lane or its Captain records a new grant for the stop the PR is at now (gstack-ship-receipt stop prints the command)', + }, + GRANT_UNKNOWN: { + anchor: 'grant-unknown', + summary: 'the branch approval record holds no approved review_round_grant row with this id', + fix: 'pass the id gstack-approvals round-grant printed, from a checkout that sees the record or its mirror', + }, RECEIPT_CARRY_SCOPED_REVIEW: { anchor: 'receipt-carry-scoped-review', summary: 'the branch\'s own +/- lines are the reviewed ones, but the base edited context next to them, so the merge may have spliced the two (GST-384); the receipt carries only after a scoped review of those hunks', diff --git a/lib/review-depth.ts b/lib/review-depth.ts index 5453047e3..1dc60ee9a 100644 --- a/lib/review-depth.ts +++ b/lib/review-depth.ts @@ -392,8 +392,10 @@ export interface History { priorRounds?: number; /** The full review rounds among them (--prior-full): the PR cap compares these plus this run's full passes with FULL_PASS_CAP, so a run's own fix rounds stay as the in-run table plans them. */ priorFull?: number; - /** The lane's or Captain's recorded round grant at this head (--round-grant): one more round for the PR, never the owner's. */ + /** The lane's or Captain's recorded round grant at this head (--round-grant): one more round for the PR, with its fix round, never the owner's. */ roundGrant?: string; + /** A fix-check round grant that answers the stop record at --stop (GST-2968): the stopped review's fix round, one scoped fix-check of the PR's own change since the stop's head, in this run or a new one. */ + grantedStop?: string; } export interface NextStep { step: Step; reason: string } @@ -413,6 +415,9 @@ export interface NextStep { step: Step; reason: string } * loop, a grant the CLI bound to the last fix-check's own stop head (`chained`) adds one more the same way (GST-1681). */ export function nextStep(h: History, depth?: Depth): NextStep { + if (h.grantedStop && h.last !== 'fix-check') return h.rangeRuntimeLines == null + ? { step: 'stop', reason: `fix-check grant ${h.grantedStop} answers the stop, but there is no fix to read since its head: commit the fix (a base merge, an empty or reverted change is none), then ask again` } + : { step: 'fix-check', reason: `fix-check grant ${h.grantedStop} buys the stopped review's fix round: one scoped fix-check of the PR's own change since the stop's head, never a new full review and never a second fix-check` }; const n = prCapped(h, h.lean ? leanStep(h, depth) : loopStep(h, depth)); if (n.step !== 'stop') return n; if (h.gate && !h.adversarialRan) return { step: 'voices', reason: `gate class: Step 11's ${h.lean ? 'one reader' : 'voices (adversarial, outside, targeted)'} run${h.lean ? 's' : ''} before the owner's exit, then ask again with --adversarial-ran (${n.reason})` }; @@ -437,11 +442,12 @@ function prCapped(h: History, n: NextStep): NextStep { if (h.last === 'none') return n.step === 'full' || n.step === 'scoped' ? { step: 'full', reason: `read-only final review (R51): this PR already had ${prior} full review rounds on earlier heads, so this head gets one full review with no fix round; a blocker goes to the lane's Captain as a decision and the count does not reopen` } : n; if (n.step === 'done') return n; if (!h.fixedBlocking && !h.blockingOpen && !h.touchedGate && n.step !== 'stop') return { step: 'done', reason: `read-only final review done (R51): its below-floor findings ship as notes in the PR body and receipt, with no fix round` }; - return { step: 'stop', reason: `PR_ROUND_CAP: the read-only final review of a PR that already had ${prior} full review rounds found a blocker; the lane's Captain decides (ship with the note, or park; a round grant recorded after this read-only review does not buy a fix round), not an owner ask` }; + return { step: 'stop', reason: `PR_ROUND_CAP: the read-only final review of a PR that already had ${prior} full review rounds found a blocker; the lane's Captain decides (ship with the note, park, or buy its fix round with a fix-check grant naming the stop gstack-ship-receipt stop records), not an owner ask` }; } if (!prior || (n.step !== 'full' && n.step !== 'scoped')) return n; const used = prior + h.fullPasses; if (used < cap) return { ...n, reason: `${n.reason}; this PR already had ${prior} full review round${prior === 1 ? '' : 's'} on earlier heads, so this is its full round ${used + 1} of ${cap}${used + 1 === cap ? ', the last' : ''}` }; + if (h.roundGrant && used === cap && prior === cap - 1 && h.fullPasses === 1 && h.last === 'full') return { ...n, reason: `${n.reason}; round grant ${h.roundGrant} bought pass 1 as this PR's full round ${cap}, and this is that round's fix round, its last` }; if (h.last !== 'none' && !h.fixedBlocking && !h.blockingOpen && !h.touchedGate) return { step: 'done', reason: `PR round cap ${cap} reached (${prior} on earlier heads): the below-floor fixes ship as notes in the PR body and receipt` }; return { step: 'stop', reason: `PR_ROUND_CAP: this PR already had ${used} full review round${used === 1 ? '' : 's'} across its heads and /ship runs${h.roundGrant ? ` (round grant ${h.roundGrant} included)` : ''}; another needs a reason the lane or its Captain records with gstack-approvals round-grant, not an owner ask` }; } diff --git a/lib/review-round-grant.ts b/lib/review-round-grant.ts index 12f36710e..afd052d0f 100644 --- a/lib/review-round-grant.ts +++ b/lib/review-round-grant.ts @@ -1,22 +1,29 @@ /** * Review round grants (GST-2673, docs/review-policy.md#rounds-per-pull-request): a reason the lane or its Captain * records when a PR needs a review round its R51 count would not plan. kind=extra-round: one round, with its fix - * round, past the PR's cap of two. It binds one head of one PR and is spent by the round it buys. It is recorded with gstack-approvals round-grant, - * is never an owner ask and never a plan approval (lib/plan-record.ts NOT_PLAN_ROW). --by is recorded, not enforced. + * round, past the PR's cap of two, at a head no review has stopped at. kind=fix-check (GST-2968): the fix round of a + * review that already stopped, naming that stop (its run and head, lib/pr-review-history.ts stopRecord) and the + * findings it is for. Each binds one head of one PR and is spent by the run that claims it. It is recorded with + * gstack-approvals round-grant, is never an owner ask and never a plan approval (lib/plan-record.ts NOT_PLAN_ROW). + * --by is recorded, not enforced. */ +import { spawnSync } from 'node:child_process'; import { locate, readRecord, type ApprovalRow, type Env } from './approval-record'; import { GSTACK_ACTOR } from './ruled-notes'; -export const ROUND_GRANT_KINDS = ['extra-round'] as const; +export const ROUND_GRANT_KINDS = ['extra-round', 'fix-check'] as const; export type RoundGrantKind = (typeof ROUND_GRANT_KINDS)[number]; -export interface ReviewRoundGrant { kind: RoundGrantKind; head: string; pr: number; by: string; reason: string; at: string; approval: string } +/** stop_run and findings: a fix-check grant's stop (the run that stopped at head) and the finding ids it is for. */ +export interface ReviewRoundGrant { kind: RoundGrantKind; head: string; pr: number; by: string; reason: string; at: string; approval: string; stop_run?: string; findings?: string[] } -const SCOPE = /^review_round_grant ([0-9a-f]{40}) pr=([1-9]\d*) kind=(extra-round)$/; -const ASK = /^review_round_grant (extra-round) at ([0-9a-f]{40}) for pr ([1-9]\d*): (\S(?:.*\S)?)$/; +export const STOP_RUN = /^[\w.:-]{1,120}$/; +export const FINDING_ID = /^[\w.:/#@-]{1,200}$/; +const SCOPE = /^review_round_grant ([0-9a-f]{40}) pr=([1-9]\d*) kind=(extra-round|fix-check)(?: stop=(\S+) findings=(\S+))?$/; +const ASK = /^review_round_grant (extra-round|fix-check) at ([0-9a-f]{40}) for pr ([1-9]\d*): (\S(?:.*\S)?)$/; export const REVIEW_ROUND_GRANT_SCOPE = /^\s*review_round_grant\b/; -export const reviewRoundGrantRow = (head: string, pr: number, kind: RoundGrantKind, reason: string) => - ({ scope: `review_round_grant ${head} pr=${pr} kind=${kind}`, ask: `review_round_grant ${kind} at ${head} for pr ${pr}: ${reason}` }); +export const reviewRoundGrantRow = (head: string, pr: number, kind: RoundGrantKind, reason: string, stop?: { run: string; findings: readonly string[] }) => + ({ scope: `review_round_grant ${head} pr=${pr} kind=${kind}${stop ? ` stop=${stop.run} findings=${stop.findings.join(',')}` : ''}`, ask: `review_round_grant ${kind} at ${head} for pr ${pr}: ${reason}` }); export function reviewRoundGrants(rows: readonly ApprovalRow[]): ReviewRoundGrant[] { const out: ReviewRoundGrant[] = []; @@ -24,7 +31,9 @@ export function reviewRoundGrants(rows: readonly ApprovalRow[]): ReviewRoundGran const s = SCOPE.exec(r.scope), a = ASK.exec(r.ask); if (r.outcome !== 'approved' || !s || !a || GSTACK_ACTOR.test(r.by)) continue; if (a[1] !== s[3] || a[2] !== s[1] || a[3] !== s[2]) continue; - out.push({ kind: s[3] as RoundGrantKind, head: s[1]!, pr: Number(s[2]), by: r.by, reason: a[4]!, at: r.recorded_at, approval: r.id }); + const findings = s[5]?.split(','); + if ((s[3] === 'fix-check') !== (s[4] !== undefined) || (s[4] !== undefined && (!STOP_RUN.test(s[4]) || !findings!.every(f => FINDING_ID.test(f))))) continue; + out.push({ kind: s[3] as RoundGrantKind, head: s[1]!, pr: Number(s[2]), by: r.by, reason: a[4]!, at: r.recorded_at, approval: r.id, ...(s[4] ? { stop_run: s[4], findings } : {}) }); } return out; } @@ -34,10 +43,73 @@ export function readReviewRoundGrants(cwd: string, env: Env = process.env): Revi return 'code' in loc ? [] : reviewRoundGrants(readRecord(loc).rows); } -/** The newest grant for this PR at exactly this head. */ +/** The newest extra-round grant for this PR at exactly this head (a fix-check grant answers a stop instead: lib/pr-review-history.ts grantedStop). */ export const grantAt = (grants: readonly ReviewRoundGrant[], pr: number, head: string) => - [...grants].reverse().find(g => g.pr === pr && g.head === head.toLowerCase()); + [...grants].reverse().find(g => g.kind === 'extra-round' && g.pr === pr && g.head === head.toLowerCase()); + +/** + * The newest extra-round grant for this PR at this head, or at a head this one only merges the base into or out of (GST-2968): one is + * the other's ancestor and the PR's own added and removed lines against baseRef are byte-identical, in the same places, at both. + * Preflight merges the base before the review, so the head a grant names and the head the next run reads can differ that way. + */ +export function grantFor(repoRoot: string, grants: readonly ReviewRoundGrant[], pr: number, head: string, baseRef?: string): ReviewRoundGrant | undefined { + const exact = grantAt(grants, pr, head); + if (exact || !baseRef) return exact; + return [...grants].reverse().find(g => g.kind === 'extra-round' && g.pr === pr && ownLinesSame(repoRoot, baseRef, g.head, head.toLowerCase())); +} + +interface Hunk { path: string; start: number; len: number; added: number } + +/** A zero-context diff's hunks: the file (its old side, or its new side when created), the old-side start and length, and the added length. */ +function hunks(diff: string): Hunk[] { + const out: Hunk[] = []; + let minus = '', path = ''; + for (const l of diff.split('\n')) { + if (l.startsWith('--- ')) minus = l.slice(4); + else if (l.startsWith('+++ ')) path = minus === '/dev/null' ? l.slice(4) : minus; + const m = /^@@ -(\d+)(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(l); + if (m) out.push({ path, start: +m[1]!, len: m[2] === undefined ? 1 : +m[2], added: m[3] === undefined ? 1 : +m[3] }); + } + return out; +} + +/** + * The old-side line own hunk h starts at once the base's hunks have moved its file, or null when the base edited a line h changes or + * inserted inside or right next to h, so its place can't be carried over. Spans are in half-line steps: 2n is line n, 2n+1 the gap after it. + */ +function carried(base: readonly Hunk[], h: Hunk): number | null { + const span = (x: Hunk, pad: number): [number, number] => x.len ? [2 * x.start - pad, 2 * (x.start + x.len - 1) + pad] : [2 * x.start + 1 - pad, 2 * x.start + 1 + pad]; + const [lo, hi] = span(h, 1); + let shift = 0; + for (const b of base.filter(x => x.path === h.path)) { + const [blo, bhi] = span(b, 0); + if (blo <= hi && lo <= bhi) return null; + if (bhi < lo) shift += b.added - b.len; + } + return h.start + shift; +} + +/** + * Whether a and b are on one line of history and carry byte-identical own lines against baseRef at the same places: equal + * zero-context patch-ids, and each own hunk of a, carried through the base's changes between the two forks, starts where b's does. + * Moving a line to another place in the same file changes no patch-id, so the places are compared too. + */ +export function ownLinesSame(repoRoot: string, baseRef: string, a: string, b: string): boolean { + const git = (args: string[], input?: string) => spawnSync('git', ['-c', 'core.quotepath=off', ...args], { cwd: repoRoot, encoding: 'utf8', input, timeout: 120_000, maxBuffer: 256 * 1024 * 1024 }); + if (git(['merge-base', '--is-ancestor', a, b]).status !== 0 && git(['merge-base', '--is-ancestor', b, a]).status !== 0) return false; + const fork = (c: string) => { const f = git(['merge-base', baseRef, c]); return f.status === 0 ? f.stdout.trim() : null; }; + const diff = (x: string, y: string) => { const d = git(['diff', '--no-color', '--no-ext-diff', '--no-textconv', '--no-renames', '--binary', '--full-index', '-U0', x, y]); return d.status === 0 ? d.stdout : null; }; + const id = (d: string) => { const p = git(['patch-id', '--verbatim'], d); return p.status === 0 ? p.stdout.trim().split(/\s+/)[0] || null : null; }; + const fa = fork(a), fb = fork(b); + if (!fa || !fb) return false; + const da = diff(fa, a), db = diff(fb, b), moved = fa === fb ? '' : diff(fa, fb); + if (!da?.trim() || !db?.trim() || moved === null) return false; + const x = id(da); + if (x === null || x !== id(db)) return false; + const base = hunks(moved), there = hunks(db), here = hunks(da); + return here.length === there.length && here.every((h, i) => h.path === there[i]!.path && h.len === there[i]!.len && carried(base, h) === there[i]!.start); +} /** The text after "Review round grant: " in the PR body. */ export const reviewRoundGrantText = (g: ReviewRoundGrant) => - `${g.kind} at ${g.head.slice(0, 12)} for PR #${g.pr} recorded by ${g.by} at ${g.at}: ${g.reason} (approval ${g.approval})`; + `${g.kind} at ${g.head.slice(0, 12)} for PR #${g.pr}${g.stop_run ? ` (stop ${g.stop_run}, findings ${g.findings!.join(', ')})` : ''} recorded by ${g.by} at ${g.at}: ${g.reason} (approval ${g.approval})`; diff --git a/lib/ship-preflight.ts b/lib/ship-preflight.ts index 197394a2f..6fa322fe9 100644 --- a/lib/ship-preflight.ts +++ b/lib/ship-preflight.ts @@ -104,7 +104,7 @@ function integrate(cwd: string, base: string, run: string | undefined, r: Report r.add(`PR: #${n}`).add(line); // R51 per pull request (GST-2673): the rounds earlier heads spent, which Step 9 passes to every plan, and the review this // head gets: a product change runs Steps 2-16, whose plan is the merge head's full review; a re-check never carries. - const hist = bin(cwd, 'gstack-ship-receipt', ['history', '--pr', n], 120_000); + const hist = bin(cwd, 'gstack-ship-receipt', ['history', '--pr', n, '--base', base, ...(run ? ['--run', run] : [])], 120_000); const histLines = hist.stdout.split('\n').filter(l => /^PR_REVIEW_(HISTORY|FLAGS|ROUTE): /.test(l)); histLines.forEach(l => r.add(l)); if (hist.status !== 0 || !histLines.some(l => l.startsWith('PR_REVIEW_FLAGS: '))) r.add('PR_REVIEW_FLAGS: --prior-rounds 0').add(`PR_REVIEW_ROUTE: first (history unavailable: ${firstLine(hist.stderr) || `gstack-ship-receipt history exit ${hist.status}`}; the plan counts this run's rounds only)`); diff --git a/lib/ship-receipt.ts b/lib/ship-receipt.ts index 4c8aee226..0589785ee 100644 --- a/lib/ship-receipt.ts +++ b/lib/ship-receipt.ts @@ -133,7 +133,12 @@ export const RUNS_RE = /```gstack-receipt-runs[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t] * carries), `carry` for any other hop. status: a /ship run that * started and wrote no receipt yet (`started`, its counters so far) or ended on an infrastructure failure (`voided`). */ -export type ReceiptRun = Pick & { depth?: string; carried_from?: string; carry_kind?: 'carry' | 'recheck'; status?: 'started' | 'voided' }; +export type ReceiptRun = Pick & { depth?: string; carried_from?: string; carry_kind?: 'carry' | 'recheck'; status?: 'started' | 'voided'; mark?: 'stop' | 'grant'; tree?: string; grant?: string }; +/** The runs block keeps the newest RECEIPT_RUNS_KEPT run entries and every stop or grant marker (lib/pr-review-history.ts), in order. */ +export function keptRuns(runs: readonly ReceiptRun[]): ReceiptRun[] { + const keep = new Set(runs.filter(r => !r.mark).slice(-RECEIPT_RUNS_KEPT)); + return runs.filter(r => r.mark || keep.has(r)); +} export function receiptRuns(body: string): ReceiptRun[] { const m = RUNS_RE.exec(receiptSource(body)); return m ? m[1]!.split('\n').flatMap(l => { try { const o = JSON.parse(l); return o && typeof o.head === 'string' ? [o as ReceiptRun] : []; } catch { return []; } }) : []; @@ -164,7 +169,7 @@ export function placeReceipt(body: string, receipt: ShipReceipt): string { const prior = ex.receipt; const runs = receiptRuns(body).filter(r => !r.status || !!receipt.carry || receipt.run === undefined || r.run !== receipt.run); if (prior && typeof prior.head === 'string' && JSON.stringify(prior) !== JSON.stringify(receipt)) runs.push(receiptRun(prior)); - const kept = runs.slice(-RECEIPT_RUNS_KEPT); + const kept = keptRuns(runs); const block = renderReceiptBlock(receipt) + (kept.length ? '\n```' + RUNS_FENCE + '\n' + kept.map(r => JSON.stringify(r)).join('\n') + '\n```\n' : ''); if (ex.found && splitAgentNotes(body).notes === null) { const rest = body.replace(BLOCK_RE, '').replace(RUNS_RE, '').replace(/^\s+/, ''); diff --git a/lib/ship-release.ts b/lib/ship-release.ts index d29664446..8de60aa8f 100644 --- a/lib/ship-release.ts +++ b/lib/ship-release.ts @@ -26,6 +26,7 @@ import { isCriticalFinding, isOpenByAction } from './headless-artifacts'; import { fingerprintPath, normalizePath } from './review-scope'; import { forbidSpecs } from './review-fetch'; import { readRuledNotes, ruledNoteText } from './ruled-notes'; +import { reviewRoundGrants } from './review-round-grant'; import { dispositionedOn, gateDispositionText, gateKey, readGateDispositions } from './gate-dispositions'; import { parseReviewLoopException, type ReviewLoopException } from './ship-receipt-depth'; import { parseReceiptDocs, type ReceiptDocs } from './ship-receipt-docs'; @@ -315,13 +316,13 @@ function fixChecked(cwd: string, o: BridgeOpts & { now: string; parent?: string; const gates = readGateDispositions(cwd); for (const d of gates) r.add(`GATE_DISPOSITION: ${gateDispositionText(d)}${reviewRows.some(v => dispositionedOn(cwd, v, [d]).length) ? '' : ' (no open gate finding at this fingerprint on a review row whose range holds this head; not applied)'}`); const gatedOn = (l: FixLink) => new Set(dispositionedOn(cwd, l.row, gates).map(d => gateKey(d.finding, d.gate_id))); - const grants = chain.length ? (loc => 'file' in loc ? readRecord(loc).rows : [])(locate({ cwd, env: process.env })).filter(g => g.outcome === 'approved' && `${g.ask} ${g.scope}`.includes('review_loop_grant')) : []; + const grants = chain.length ? (loc => 'file' in loc ? readRecord(loc).rows : [])(locate({ cwd, env: process.env })).filter(g => g.outcome === 'approved' && (`${g.ask} ${g.scope}`.includes('review_loop_grant') || reviewRoundGrants([g]).some(x => x.kind === 'fix-check'))) : []; const granted: (typeof grants[number] | undefined)[] = []; const used = new Set(); for (let k = chain.length - 1; k >= 0; k--) { const l = chain[k]!; const g = grants.filter(g => !used.has(g.id)) - .flatMap(g => (`${g.ask} ${g.scope}`.match(/\b[0-9a-f]{7,40}\b/g) ?? []).map(commitOf).filter(c => !!c && inRange(l, c)).map(stop => ({ g, stop }))) + .flatMap(g => { const fc = reviewRoundGrants([g]).find(x => x.kind === 'fix-check'); return (fc ? (commitOf(fc.head) === l.from ? [fc.head] : []) : `${g.ask} ${g.scope}`.match(/\b[0-9a-f]{7,40}\b/g) ?? []).map(commitOf).filter(c => !!c && inRange(l, c)).map(stop => ({ g, stop })); }) .reduce<{ g: typeof grants[number]; stop: string } | undefined>((best, c) => (!best || ancestor(best.stop, c.stop) ? c : best), undefined)?.g; if (g) used.add(g.id); granted[k] = g; diff --git a/scripts/lib/windows-curation.ts b/scripts/lib/windows-curation.ts index e778bb67f..8b2198d8a 100644 --- a/scripts/lib/windows-curation.ts +++ b/scripts/lib/windows-curation.ts @@ -448,6 +448,10 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }> file: 'test/ship-base-side-masks.test.ts', reason: 'drives bin/gstack-ship-release, gstack-docs-candidate and gstack-wtree (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-rereview-triggers.test.ts; windows-latest fails every case at the first bin spawn (windows-scoped-shard, run 41950236362)', }, + { + file: 'test/round-cap-granted-stop.test.ts', + reason: 'drives bin/gstack-ship-receipt, gstack-approvals, gstack-review-plan, gstack-review-log, gstack-review-scope and gstack-ship-release (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-finish-fixed-links.test.ts; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)', + }, { file: 'test/ship-uid-sidecar.test.ts', reason: 'drives bin/gstack-ship-release, gstack-ship-receipt, gstack-docs-candidate and gstack-wtree (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-mechanical-retake.test.ts; windows-latest fails every case at the first bin spawn (windows-scoped-shard, run 42205201312)', diff --git a/ship/DRIVER.md b/ship/DRIVER.md index 0c72699ce..f42ae58e8 100644 --- a/ship/DRIVER.md +++ b/ship/DRIVER.md @@ -91,8 +91,8 @@ pass with `fixCheck: {fix_list, hunks, tests, callers}`; `done` or `voices`: tha ## 5. Voices, bind and version: Steps 11, 11.5, 12 Judge the voices; missing outside coverage is `unavailable`, never clean; queued fixes rerun Phases -3-4. Then `gstack-review-dispatch verify` (`VERIFY: clean`) and `gstack-review-read`: the final Step 9 and Step 11 native rows (or `CURRENT` freshness -after a planned skip) agree on their trees; save that tree and base ``. Then +3-4. Then `gstack-review-dispatch verify` (`VERIFY: clean`) and `gstack-review-read`: the final Step 9 and 11 native rows (or `CURRENT` freshness +after a planned skip) agree on one tree; save it (or `--stop`'s) and base ``. Then `gstack-ship-release version --base [--bump micro|patch] --why ''`; MINOR, MAJOR, `BUMP_ANSWER_REQUIRED`: approvals; `VERSION: skipped|kept`: no write. diff --git a/ship/DRIVER.md.tmpl b/ship/DRIVER.md.tmpl index 24c053d2e..6e48a7755 100644 --- a/ship/DRIVER.md.tmpl +++ b/ship/DRIVER.md.tmpl @@ -89,8 +89,8 @@ pass with `fixCheck: {fix_list, hunks, tests, callers}`; `done` or `voices`: tha ## 5. Voices, bind and version: Steps 11, 11.5, 12 Judge the voices; missing outside coverage is `unavailable`, never clean; queued fixes rerun Phases -3-4. Then `gstack-review-dispatch verify` (`VERIFY: clean`) and `gstack-review-read`: the final Step 9 and Step 11 native rows (or `CURRENT` freshness -after a planned skip) agree on their trees; save that tree and base ``. Then +3-4. Then `gstack-review-dispatch verify` (`VERIFY: clean`) and `gstack-review-read`: the final Step 9 and 11 native rows (or `CURRENT` freshness +after a planned skip) agree on one tree; save it (or `--stop`'s) and base ``. Then `gstack-ship-release version --base [--bump micro|patch] --why ''`; MINOR, MAJOR, `BUMP_ANSWER_REQUIRED`: approvals; `VERSION: skipped|kept`: no write. diff --git a/ship/sections/review-army.md b/ship/sections/review-army.md index add34ef9f..082eab2ef 100644 --- a/ship/sections/review-army.md +++ b/ship/sections/review-army.md @@ -18,7 +18,11 @@ Finish the complete review and QA before applying any fix in Step 9.4. **Review plan.** Pass 1 runs `~/.claude/skills/gstack/bin/gstack-review-plan --base `, plus `--depth-floor ` on every plan run when the /ship prompt gave `--depth-floor ` (it only raises), and Step 1's `PR_REVIEW_FLAGS:` on every plan run (the PR's -earlier rounds and a round grant; past two the plan is one read-only full review, and `PR_ROUND_CAP` stops for the lane, never the owner); add `--declare-risk ` when the diff touches a risk +earlier rounds and a round grant; past two the plan is one read-only full review, and `PR_ROUND_CAP` stops for the lane, never the owner). +When they name `--round-grant `, run `gstack-ship-receipt claim --pr --run --grant ` before the first +dispatch (`GRANT_SPENT` stops the run). With `--stop ` too, the grant buys that stop's fix round: Step 9 is only decision +3.5's fix-check of the PR's own change since ``, for the grant's findings, Step 11.5 saves ``'s tree, and the receipt's +`review_loop_exception` names the grant. Add `--declare-risk ` when the diff touches a risk class the plan's `REVIEW_DEPTH:` misses (spend it reserves or binds: `money`), and give Step 16's receipt write the same flag; a repeat uses the plan run that picked it. A `scoped` repeat is a full pass on the range: its `fix-check` is decision 3.5's @@ -824,7 +828,8 @@ finding makes that PR a draft. After persistence, record missing output, CYCLES and fixes in the invocation record. With a PR open, run `gstack-review-scope summary --since "$REVIEW_SINCE" --no-ledger --out .gstack/tmp/review-loop.json && gstack-ship-receipt stub --pr --run --review-loop @.gstack/tmp/review-loop.json` -so a run that stops still counts its rounds (Step 19's write, same `--run`, replaces it). +so a run that stops still counts its rounds (Step 19's write, same `--run`, replaces it). On `NEXT: stop` with a PR open, also +run `gstack-ship-receipt stop --pr --run --since "$REVIEW_SINCE"` and report its `NEXT:` line with the stop. Decision 1 always applies first. Then, under `frozen`, run `gstack-review-plan --base --pass $PASS --last full` with each flag that holds (`--fixed-blocking`, `--fixed-below`, `--blocking-open`, `--touched-gate` for a fix to an item 2.5 path, `--critical-found` when this pass diff --git a/ship/sections/review-army.md.tmpl b/ship/sections/review-army.md.tmpl index 24800f01a..686aa5151 100644 --- a/ship/sections/review-army.md.tmpl +++ b/ship/sections/review-army.md.tmpl @@ -16,7 +16,11 @@ Finish the complete review and QA before applying any fix in Step 9.4. **Review plan.** Pass 1 runs `~/.claude/skills/gstack/bin/gstack-review-plan --base `, plus `--depth-floor ` on every plan run when the /ship prompt gave `--depth-floor ` (it only raises), and Step 1's `PR_REVIEW_FLAGS:` on every plan run (the PR's -earlier rounds and a round grant; past two the plan is one read-only full review, and `PR_ROUND_CAP` stops for the lane, never the owner); add `--declare-risk ` when the diff touches a risk +earlier rounds and a round grant; past two the plan is one read-only full review, and `PR_ROUND_CAP` stops for the lane, never the owner). +When they name `--round-grant `, run `gstack-ship-receipt claim --pr --run --grant ` before the first +dispatch (`GRANT_SPENT` stops the run). With `--stop ` too, the grant buys that stop's fix round: Step 9 is only decision +3.5's fix-check of the PR's own change since ``, for the grant's findings, Step 11.5 saves ``'s tree, and the receipt's +`review_loop_exception` names the grant. Add `--declare-risk ` when the diff touches a risk class the plan's `REVIEW_DEPTH:` misses (spend it reserves or binds: `money`), and give Step 16's receipt write the same flag; a repeat uses the plan run that picked it. A `scoped` repeat is a full pass on the range: its `fix-check` is decision 3.5's @@ -234,7 +238,8 @@ finding makes that PR a draft. After persistence, record missing output, CYCLES and fixes in the invocation record. With a PR open, run `gstack-review-scope summary --since "$REVIEW_SINCE" --no-ledger --out .gstack/tmp/review-loop.json && gstack-ship-receipt stub --pr --run --review-loop @.gstack/tmp/review-loop.json` -so a run that stops still counts its rounds (Step 19's write, same `--run`, replaces it). +so a run that stops still counts its rounds (Step 19's write, same `--run`, replaces it). On `NEXT: stop` with a PR open, also +run `gstack-ship-receipt stop --pr --run --since "$REVIEW_SINCE"` and report its `NEXT:` line with the stop. Decision 1 always applies first. Then, under `frozen`, run `gstack-review-plan --base --pass $PASS --last full` with each flag that holds (`--fixed-blocking`, `--fixed-below`, `--blocking-open`, `--touched-gate` for a fix to an item 2.5 path, `--critical-found` when this pass diff --git a/test/fixtures/review-pins/files/lib/review-depth.ts.json b/test/fixtures/review-pins/files/lib/review-depth.ts.json index 5312d4ec6..c0832119c 100644 --- a/test/fixtures/review-pins/files/lib/review-depth.ts.json +++ b/test/fixtures/review-pins/files/lib/review-depth.ts.json @@ -1 +1 @@ -{"sha":"d29ea5d198f045f18fb77af4c57c2a6a433c6b5ed970314095f2e9e66acd87ce","replay":"GST-2706"} +{"sha":"e1f36b11928b2310a346f46a031cfa5a955db9c036036f43cc36512c8d772870","replay":"GST-2968"} diff --git a/test/fixtures/review-pins/files/ship/sections/review-army.md.json b/test/fixtures/review-pins/files/ship/sections/review-army.md.json index 205237247..bf41f6013 100644 --- a/test/fixtures/review-pins/files/ship/sections/review-army.md.json +++ b/test/fixtures/review-pins/files/ship/sections/review-army.md.json @@ -1 +1 @@ -{"sha":"41631ea2501711a8a32b3d266540afa52b142a10b37af88980b3186e92340517","replay":"GST-2673"} +{"sha":"3bbbd295c2301c35c253d0ad8a151dad09d731b94019a306a298226bae985fca","replay":"GST-2968"} diff --git a/test/fixtures/review-pins/replays/GST-2968.json b/test/fixtures/review-pins/replays/GST-2968.json new file mode 100644 index 000000000..9e6fb927d --- /dev/null +++ b/test/fixtures/review-pins/replays/GST-2968.json @@ -0,0 +1 @@ +{"replay":"GST-2968","justification":"GST-2968 (GSTA-608 PR 1): lib/review-depth.ts gains a grantedStop History field with one transition at the top of nextStep (a fix-check round grant answering a stop record plans that stop's one fix-check; only gstack-review-plan --stop with a fix-check grant sets it), one prCapped line (an extra-round grant whose pass 1 was the PR's round 3 keeps that round's fix round), and new wording for the read-only PR_ROUND_CAP stop's offer. Deterministic no-loss replay, preregistered before the run (captain drive handoffs/GSTA-608/no-loss-replay-prereg.md), no paid run: main 33b1a96 against new nextStep over 9,830,400 History x depth cases (fullPasses 0-3, every last step, finding, gate, range, depth, loop grant, lean, fix-check count, post-review, chained, prior-full 0-4 and round-grant combination; grantedStop unset): every step outside the granted-round-3 class is identical; inside it 12,800 steps change, all from stop or voices to full or scoped (the fix round the grant buys), none the other way; 2,617,400 reasons differ only by the read-only stop's offer clause or inside that class. Step-sequence sha256 main 72bd00eaf0d1b423d14ceea99ef46a855c52127d758f8dc2013676cf27601b6c, new 63e41d14897294d0647a13690cabeaa5f11f17657ef4b2c181c7a041b3dbc515. No reader, depth, dispatch, brief, checklist or finding rule changes. ship/sections/review-army.md changes only Step 9's /ship bookkeeping prose (gstack-ship-receipt claim before a granted run's first dispatch, gstack-ship-receipt stop on NEXT: stop), which no reviewer reads: every brief body lib/review-brief.ts cuts from the ship sections keeps its pinned hash (test/fixtures/review-pins/brief-bodies unchanged)."} diff --git a/test/review-plan-pr-rounds.test.ts b/test/review-plan-pr-rounds.test.ts index 170e7fa48..0078de6bd 100644 --- a/test/review-plan-pr-rounds.test.ts +++ b/test/review-plan-pr-rounds.test.ts @@ -63,20 +63,30 @@ describe('PR round cap', () => { // Value: protects=the read-only stop offers only what the Captain can do: a grant recorded after that review can't buy a // fix round (GST-2706); fails_when=the stop lists a round grant as an option; seam=nextStep; no_claim=history's grant route - test('the read-only stop offers ship-with-the-note or park, and says a later round grant buys no fix round', () => { + // GST-2968 reverses GST-2706's "a later grant buys no fix round": PR_ROUND_CAP printed the grant command anyway, and two grants + // on gstack#4272 bought nothing. The stop now names the fix-check grant that answers its stop record + // (test/round-cap-granted-stop.test.ts covers what that grant buys). + test('the read-only stop offers ship-with-the-note, park, or a fix-check grant naming the stop', () => { for (const roundGrant of [undefined, 'a-000000000001']) { const stop = nextStep(h({ priorFull: 3, fullPasses: 1, last: 'full', fixedBlocking: true, roundGrant }), 'standard'); expect(stop.step).toBe('stop'); - expect(stop.reason).toContain('(ship with the note, or park;'); - expect(stop.reason).not.toContain('a round grant, or park'); - expect(stop.reason).toContain('does not buy a fix round'); + expect(stop.reason).toContain('(ship with the note, park, or buy its fix round with a fix-check grant naming the stop gstack-ship-receipt stop records)'); + expect(stop.reason).not.toContain('does not buy a fix round'); } }); - test('a round grant buys one more full round at its head, never two', () => { + // GST-2968 (matrix row G3): the granted round keeps its fix round (gstack#4272: the grant raised the cap by one, so a blocker the + // granted pass fixed stopped again at PR_ROUND_CAP), and nothing past it. + test('a round grant buys one more full round at its head with its fix round, never two', () => { expect(nextStep(h({ priorFull: 2, roundGrant: 'a-1' })).step).toBe('full'); expect(nextStep(h({ priorFull: 3, roundGrant: 'a-1' }))).toMatchObject({ step: 'full', reason: expect.stringContaining('read-only final review') }); - expect(nextStep(h({ priorFull: 2, roundGrant: 'a-1', fullPasses: 1, last: 'full', fixedBlocking: true }), 'standard').reason).toStartWith('PR_ROUND_CAP'); + for (const depth of ['standard', 'full'] as const) { + const fix = nextStep(h({ priorFull: 2, roundGrant: 'a-1', fullPasses: 1, last: 'full', fixedBlocking: true }), depth); + expect(['full', 'scoped']).toContain(fix.step); + expect(fix.reason).toContain("round grant a-1 bought pass 1 as this PR's full round 3, and this is that round's fix round"); + } + expect(nextStep(h({ priorFull: 2, roundGrant: 'a-1', fullPasses: 2, last: 'full', fixedBlocking: true }), 'standard').step).toBe('stop'); + expect(nextStep(h({ priorFull: 2, fullPasses: 1, last: 'full', fixedBlocking: true }), 'standard').reason).toStartWith('PR_ROUND_CAP'); }); test('gate class still runs Step 11\'s voices before the PR cap stop', () => { diff --git a/test/review-round-grant-own-lines.test.ts b/test/review-round-grant-own-lines.test.ts new file mode 100644 index 000000000..59b2c425a --- /dev/null +++ b/test/review-round-grant-own-lines.test.ts @@ -0,0 +1,57 @@ +/** + * GST-2968 follow-up (#4449's read-only final review): a round grant applies at another head only when the PR's own lines are + * the same there. ownLinesSame compared zero-context patch-ids, which ignore where a hunk sits, so moving the PR's own audit() + * call from publicTask() into privateTask() kept the grant. It now also compares each own hunk's place, carried through the + * base's changes, so a pure base merge still keeps the grant. + */ +import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test'; +import { ownLinesSame } from '../lib/review-round-grant'; +import { shipFixture, type ShipFx } from './helpers/ship-bin-fixture'; + +setDefaultTimeout(60_000); +const fxs: ShipFx[] = []; +afterEach(() => { while (fxs.length) fxs.pop()!.cleanup(); }); + +const task = (pub: string[], priv: string[], top: string[] = []) => + [...top, 'export function publicTask() {', ...pub, ' return 1;', '}', '', 'export function privateTask() {', ...priv, ' return 2;', '}', ''].join('\n'); +const AUDIT = ' audit();'; + +function granted(): { f: ShipFx; head: string; same: (b: string) => boolean } { + const f = shipFixture({ 'src/task.ts': task([], []) }, { 'src/task.ts': task([AUDIT], []) }); + fxs.push(f); + const head = f.git('rev-parse', 'HEAD').stdout.trim(); + return { f, head, same: b => ownLinesSame(f.work, 'origin/main', head, b) && ownLinesSame(f.work, 'origin/main', b, head) }; +} +const tip = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim(); +const mergeBase = (f: ShipFx, files: Record, resolved?: Record) => { + f.advanceBase(files); + f.git('fetch', '-q', 'origin'); + if (f.git('merge', '-q', '--no-edit', 'origin/main').status === 0) return; + expect(resolved).toBeDefined(); + f.write(resolved!); + f.commit('merge main'); +}; + +describe('a round grant follows the PR\'s own lines, not just their text (GST-2968)', () => { + // Value: protects=a grant recorded at one head does not open a round at a head whose own code moved; fails_when=moving audit() + // between functions with no base change still matches; seam=ownLinesSame as grantFor calls it; no_claim=other grant fields + test('moving the PR\'s own line to another function needs a new grant', () => { + const { f, same } = granted(); + f.write({ 'src/task.ts': task([], [AUDIT]) }); + f.commit('move audit into privateTask'); + expect(same(tip(f))).toBe(false); + }); + + // Value: protects=negative controls: a pure base merge that moves the PR's own hunk down still matches, and a base edit right next + // to that hunk does not; fails_when=the place check breaks base-merge grants (ghome#17) or carries a hunk the base touched; + // seam=ownLinesSame + test('a base merge that only shifts the own line still matches; a base edit beside it does not', () => { + const shifted = granted(); + mergeBase(shifted.f, { 'src/task.ts': task([], [], ['// header', '// added by main', '']), 'src/c.ts': 'export const c = 3;\n' }); + expect(shifted.same(tip(shifted.f))).toBe(true); + const beside = granted(); + const typed = (s: string) => s.replace('export function publicTask() {', 'export function publicTask(): number {'); + mergeBase(beside.f, { 'src/task.ts': typed(task([], [])) }, { 'src/task.ts': typed(task([AUDIT], [])) }); + expect(beside.same(tip(beside.f))).toBe(false); + }); +}); diff --git a/test/round-cap-granted-stop.test.ts b/test/round-cap-granted-stop.test.ts new file mode 100644 index 000000000..c7d52445d --- /dev/null +++ b/test/round-cap-granted-stop.test.ts @@ -0,0 +1,276 @@ +/** + * GST-2968 and GHOM-1 (ghome#40): a round grant recorded at PR_ROUND_CAP could not buy the round the stop names. The read-only + * final review already counted as a full round, so a grant raising the cap from 2 to 3 still equalled the count; and a grant + * recorded between /ship runs was honored only when the current run had used two passes, so the next run fell back to another + * read-only full review ($8.78 against about $3). A stop now leaves a stop record in the PR body (gstack-ship-receipt stop), and a + * fix-check round grant that names that stop's run, head and findings buys its fix round: one scoped fix-check of the PR's own + * change since the stop's head, in the same run or a new one, claimed once (gstack-ship-receipt claim). Row ids are the case + * matrix's (captain drive handoffs/GSTA-608/case-matrix.md). + */ +import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import type { ApprovalRow } from '../lib/approval-record'; +import { grantedStop, grantMarker, placeRunEntry, prReviewHistory, runStub, stopFrom, stopMarker } from '../lib/pr-review-history'; +import { nextStep } from '../lib/review-depth'; +import { reviewRoundGrantRow, reviewRoundGrants } from '../lib/review-round-grant'; +import { receiptRuns } from '../lib/ship-receipt'; +import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture'; + +setDefaultTimeout(90_000); +const BIN = path.dirname(RELEASE); +const fxs: ShipFx[] = []; +afterEach(() => { while (fxs.length) fxs.pop()!.cleanup(); }); + +const S = 'a'.repeat(40), S2 = 'b'.repeat(40), H = 'c'.repeat(40), T = 'd'.repeat(40); +const loop = (passes: number, o: Record = {}) => ({ passes, blocking_found: 1, deferred: 0, rounds: passes + (o.fix_checks ?? 0), ...o }); +const row = (id: string, o: Partial & { scope: string; ask: string }): ApprovalRow => + ({ id, date: '2026-11-18', recorded_at: '2026-11-18T00:00:00Z', words: 'w', by: 'Captain GStack Minder (GSTA-36)', pending: 'none', outcome: 'approved', source: 'manual', branch: 'b', ...o } as ApprovalRow); +const fixGrant = (id: string, o: { head?: string; pr?: number; run?: string; findings?: string[] } = {}) => + row(id, reviewRoundGrantRow(o.head ?? S, o.pr ?? 7, 'fix-check', 'the read-only review found a fixable blocker', { run: o.run ?? 'ro', findings: o.findings ?? ['p1/outside-voice#1'] })); +/** Two full rounds by run r1, then run ro's read-only review that stopped at S (its stub and its stop record). */ +const stopped = () => [runStub({ head: H, run: 'r1', status: 'started', loop: loop(2) }), runStub({ head: S, run: 'ro', status: 'started', loop: loop(1) }), stopMarker({ head: S, tree: T, run: 'ro' })] + .reduce((b, e) => placeRunEntry(b, e), ''); +const anc = (pairs: Array<[string, string]>) => (a: string, d: string) => a === d || pairs.some(([x, y]) => x === a && y === d); +const ON = anc([[S, H], [H, S2], [S, S2]]); +const answer = (body: string, grants: ApprovalRow[], o: { head?: string; run?: string; pr?: number; isAncestor?: (a: string, d: string) => boolean } = {}) => + grantedStop(body, reviewRoundGrants(grants), { pr: o.pr ?? 7, head: o.head ?? S2, run: o.run, isAncestor: o.isAncestor ?? ON }); + +describe('the plan: a fix-check grant answering a stop buys its fix round (GST-2968, GHOM-1)', () => { + // Value: protects=GHOM-1, a new run after a cross-run grant plans the fix-check, not another read-only full review; fails_when=prCapped + // plans read-only full because priorFull >= cap; seam=nextStep + test('G2/G5: a new run with priorFull 3 plans one scoped fix-check, not a read-only full review', () => { + const n = nextStep({ fullPasses: 0, last: 'none', priorFull: 3, priorRounds: 3, grantedStop: 'a-1', rangeRuntimeLines: 4 } as any); + expect(n.step).toBe('fix-check'); + expect(n.reason).toContain('a-1'); + }); + test('G1: the run that stopped plans the fix-check once the grant is recorded', () => { + expect(nextStep({ fullPasses: 1, last: 'full', priorFull: 2, blockingOpen: true, grantedStop: 'a-1', rangeRuntimeLines: 4 } as any).step).toBe('fix-check'); + }); + test('X15: no fix since the stop head (empty, reverted or base-only range) plans no fix-check', () => { + const n = nextStep({ fullPasses: 0, last: 'none', priorFull: 3, grantedStop: 'a-1', rangeRuntimeLines: null } as any); + expect(n.step).toBe('stop'); + expect(n.reason).toContain('commit the fix'); + }); + test('G19: the granted fix-check never earns another; a blocker stops with PR_ROUND_CAP, a clean read is done', () => { + const after = { fullPasses: 0, last: 'fix-check', fixChecks: 1, priorFull: 3, grantedStop: 'a-1' } as const; + expect(nextStep({ ...after, blockingOpen: true } as any).step).toBe('stop'); + expect(nextStep({ ...after, blockingOpen: true } as any).reason).toStartWith('PR_ROUND_CAP'); + expect(nextStep({ ...after } as any).step).toBe('done'); + }); + test('G3: an extra-round grant recorded before review keeps its fix round when the fix needs a pass on the range', () => { + const n = nextStep({ fullPasses: 1, last: 'full', priorFull: 2, roundGrant: 'a-2', fixedBlocking: true, rangeRuntimeLines: 500 } as any, 'full'); + expect(['full', 'scoped', 'fix-check']).toContain(n.step); + }); + test('G4 (guard): the owner\'s in-run loop grant after a round-2 full pass still plans its one fix-check', () => { + expect(nextStep({ fullPasses: 2, last: 'full', fixedBlocking: true, granted: 'a-3' } as any).step).toBe('fix-check'); + }); +}); + +describe('which grant answers which stop (lib/pr-review-history.ts grantedStop)', () => { + test('G1/G2: a fix-check grant naming the newest stop\'s run, head and PR answers it', () => { + expect(answer(stopped(), [fixGrant('a-000000000001')])).toMatchObject({ ok: true, grant: { approval: 'a-000000000001', findings: ['p1/outside-voice#1'] }, stop: { head: S, run: 'ro' } }); + }); + test('G11/X3: a grant another run claimed is spent; the claiming run itself may resume', () => { + const body = placeRunEntry(stopped(), grantMarker({ head: S, run: 'fc1', grant: 'a-000000000001' })); + expect((answer(body, [fixGrant('a-000000000001')]) as any).why).toContain('claimed by run fc1'); + expect(answer(body, [fixGrant('a-000000000001')], { run: 'fc1' })).toMatchObject({ ok: true }); + }); + test('G12/X5: a run voided after claiming still spent the grant', () => { + const body = [grantMarker({ head: S, run: 'fc1', grant: 'a-000000000001' }), runStub({ head: S2, run: 'fc1', status: 'voided', loop: loop(0, { fix_checks: 1 }) })].reduce((b, e) => placeRunEntry(b, e), stopped()); + expect(answer(body, [fixGrant('a-000000000001')])).toMatchObject({ ok: false }); + }); + test('G13: a stop is stale once another run reviewed after it', () => { + const body = placeRunEntry(stopped(), runStub({ head: S2, run: 'r3', status: 'started', loop: loop(1) })); + expect((answer(body, [fixGrant('a-000000000001')]) as any).why).toContain('stale'); + }); + test('X6/G7: a grant naming another stop run or another head answers nothing', () => { + expect(answer(stopped(), [fixGrant('a-000000000001', { run: 'other' })])).toMatchObject({ ok: false }); + expect(answer(stopped(), [fixGrant('a-000000000001', { head: H })])).toMatchObject({ ok: false }); + }); + test('G13b: a newer stop record makes an older stop\'s grant answer nothing', () => { + expect(answer(placeRunEntry(stopped(), stopMarker({ head: S2, tree: T, run: 'fc1' })), [fixGrant('a-000000000001')])).toMatchObject({ ok: false }); + }); + test('G8: a head move off the stop head voids the grant', () => { + expect((answer(stopped(), [fixGrant('a-000000000001')], { isAncestor: anc([]) }) as any).why).toContain('head move'); + }); + test('G17: a grant for another PR is not this PR\'s', () => { + expect(answer(stopped(), [fixGrant('a-000000000001', { pr: 8 })])).toBeNull(); + }); + test('X1/G18: with no stop record a fix-check grant answers nothing, and an extra-round grant never answers a stop', () => { + const noStop = placeRunEntry('', runStub({ head: H, run: 'r1', status: 'started', loop: loop(2) })); + expect(answer(noStop, [fixGrant('a-000000000001')])).toMatchObject({ ok: false }); + expect(answer(stopped(), [row('a-000000000002', reviewRoundGrantRow(S, 7, 'extra-round', 'x'))])).toBeNull(); + }); + test('X2: trimming the runs block keeps stop and grant records; neither counts as a round', () => { + let body = placeRunEntry(stopped(), grantMarker({ head: S, run: 'fc1', grant: 'a-000000000001' })); + for (let i = 0; i < 40; i++) body = placeRunEntry(body, runStub({ head: S2, run: 'x' + i, status: 'voided', loop: loop(0) })); + expect(receiptRuns(body).filter(r => r.mark).map(r => r.mark)).toEqual(['stop', 'grant']); + expect(answer(body, [fixGrant('a-000000000001')])).toMatchObject({ ok: false }); + expect(prReviewHistory(stopped())).toMatchObject({ full: 3, rounds: 3, stubs: 2, heads: 2 }); + }); + test('a fix-check row that lacks its stop, or an extra-round row naming one, is no grant', () => { + const bare = row('a-000000000004', { scope: 'review_round_grant ' + S + ' pr=7 kind=fix-check', ask: 'review_round_grant fix-check at ' + S + ' for pr 7: x' }); + const extra = row('a-000000000005', { scope: 'review_round_grant ' + S + ' pr=7 kind=extra-round stop=ro findings=f#1', ask: 'review_round_grant extra-round at ' + S + ' for pr 7: x' }); + expect(reviewRoundGrants([bare, extra])).toEqual([]); + }); +}); + +describe('the stop record binds only a review gstack can tie to one commit (stopFrom)', () => { + const tree = (c: string) => (c === S ? T : undefined); + const bound = { skill: 'review', via: 'ship', timestamp: '2026-11-18T01:00:00Z', completed: true, converged: false, commit_full: S, tree: T, wtree: T, review_binding: { state: 'incomplete', start_wtree: T, end_wtree: T } }; + const from = (rows: Record[]) => stopFrom(rows, '2026-11-18T00:00:00Z', { treeOf: tree, onHead: c => c === S }); + test('X11: a completed stopped pass (incomplete because it did not converge) on a clean committed tree binds', () => { + expect(from([bound])).toEqual({ ok: true, head: S, tree: T }); + }); + test('S1/S7/X11: a moved, dirty, unfinished or uncommitted read binds nothing', () => { + expect(from([{ ...bound, review_binding: { state: 'changed', start_wtree: T, end_wtree: S2 } }]).ok).toBe(false); + expect(from([{ ...bound, wtree: S2, review_binding: { state: 'incomplete', start_wtree: S2, end_wtree: S2 } }]).ok).toBe(false); + expect(from([{ ...bound, completed: false }]).ok).toBe(false); + expect(from([{ ...bound, commit_full: H }]).ok).toBe(false); + }); + test('S5: a non-ship row or a fix-check row is not the stopping review; an earlier run\'s row is out of range', () => { + expect(from([bound, { ...bound, via: 'manual', commit_full: H }])).toMatchObject({ ok: true, head: S }); + expect(from([bound, { ...bound, skill: 'review-fix-check', commit_full: H }])).toMatchObject({ ok: true, head: S }); + expect(from([{ ...bound, timestamp: '2026-11-17T00:00:00Z' }]).ok).toBe(false); + }); +}); + +/** A fixture repository at the stop head with a PR body file, and the bins run against it. */ +function stopRepo() { + const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' }); + fxs.push(f); + const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' }); + const head = () => f.git('rev-parse', 'HEAD').stdout.trim(); + const body = path.join(f.root, 'body.md'); + fs.writeFileSync(body, 'Fixes a thing.\n'); + return { f, run, head, body }; +} +const grantId = (out: string) => /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(out)?.[1]; + +describe('the CLI seams', () => { + test('G15-G18/X24: round-grant --kind fix-check records the stop run and findings at the full head; misuse is refused', () => { + const r = stopRepo(); + const s = r.head(); + const ok = r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s.slice(0, 10), '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/outside-voice#1,p1/red-team#2', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)']); + expect(ok.status, ok.stderr).toBe(0); + expect(r.run('gstack-approvals', ['list', '--json']).stdout).toContain('review_round_grant ' + s + ' pr=7 kind=fix-check stop=ro findings=p1/outside-voice#1,p1/red-team#2'); + expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--reason', 'x', '--by', 'Captain GStack Minder']).status).toBe(2); + expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'extra-round', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).status).toBe(2); + expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'gstack']).status).toBe(2); + }); + + // Value: protects=GST-2968's own shape end to end: the read-only run stops, the stop is recorded, a fix-check grant is recorded after + // it, history (as preflight runs it) routes the fix-check and the plan plans it; fails_when=history prints read-only and the plan + // prints next=full; seam=gstack-ship-receipt stop/history/claim, gstack-review-plan + test('G1/G2: stop, grant, history and plan route one fix-check; a second run cannot claim the same grant', () => { + const r = stopRepo(); + const s = r.head(); + const start = r.run('gstack-review-log', ['--start', 'review']); + expect(start.status, start.stderr).toBe(0); + const logged = r.run('gstack-review-log', [JSON.stringify({ skill: 'review', timestamp: new Date().toISOString(), via: 'ship', pass: 1, review_scope: 'frozen', completed: true, converged: false, status: 'issues_found', issues_found: 1, critical: 1, informational: 0, findings: [{ fingerprint: 'src/x.ts:1:outside-voice', severity: 'CRITICAL', action: 'open', blocking: true, ledger_id: 'p1/outside-voice#1', raised_by: 'outside-voice' }] }), '--finish', start.stdout.trim()]); + expect(logged.status, logged.stderr).toBe(0); + fs.writeFileSync(r.body, placeRunEntry('Fixes a thing.\n', runStub({ head: H, run: 'r1', status: 'started', loop: loop(2) }))); + expect(r.run('gstack-ship-receipt', ['stub', '--body', r.body, '--run', 'ro', '--review-loop', JSON.stringify(loop(1))]).status).toBe(0); + const stop = r.run('gstack-ship-receipt', ['stop', '--body', r.body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']); + expect(stop.status, stop.stderr).toBe(0); + expect(stop.stdout).toContain('STOP_RECORD: run=ro head=' + s); + expect(stop.stdout).toContain('--kind fix-check --stop-run ro'); + const g = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/outside-voice#1', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)']).stdout); + expect(g).toBeDefined(); + r.f.write({ 'src/x.ts': 'export const x = 3;\n' }); r.f.commit('fix the blocker'); + const hist = r.run('gstack-ship-receipt', ['history', '--body', r.body, '--pr', '7', '--base', 'main', '--run', 'fc1']); + expect(hist.status, hist.stderr).toBe(0); + expect(hist.stdout).toContain('--round-grant ' + g + ' --stop ' + s); + expect(hist.stdout).toMatch(/^PR_REVIEW_ROUTE: fix-check /m); + const plan = r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '3', '--pr', '7', '--round-grant', g!, '--stop', s]); + expect(plan.status, plan.stderr).toBe(0); + expect(plan.stdout).toContain('next=fix-check'); + expect(r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'fc1', '--grant', g!]).stdout).toContain('GRANT_CLAIMED: grant=' + g); + const twice = r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'fc2', '--grant', g!]); + expect(twice.status).toBe(3); + expect(twice.stderr).toContain('(GRANT_SPENT)'); + expect(r.run('gstack-ship-receipt', ['history', '--body', r.body, '--pr', '7', '--base', 'main', '--run', 'fc2']).stdout).toContain('PR_REVIEW_GRANT: not applied (grant ' + g + ' was claimed by run fc1'); + }); + + test('X15/G7: the plan refuses a fix-check grant for another stop head and an extra-round grant with --stop, and plans no fix-check without a fix', () => { + const r = stopRepo(); + const s = r.head(); + const g = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!; + const plan = (extra: string[]) => r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '3', '--pr', '7', '--round-grant', g, ...extra]); + expect(plan(['--stop', s]).stdout).toContain('next=stop'); + expect(plan([]).status).toBe(3); + r.f.write({ 'src/x.ts': 'export const x = 3;\n' }); r.f.commit('fix'); + expect(plan(['--stop', r.head()]).status).toBe(3); + const x = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', r.head(), '--kind', 'extra-round', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!; + expect(r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-full', '3', '--pr', '7', '--round-grant', x, '--stop', s]).status).toBe(3); + }); + + test('S1: stop records nothing for an unbound read (STOP_UNBOUND)', () => { + const r = stopRepo(); + const out = r.run('gstack-ship-receipt', ['stop', '--body', r.body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']); + expect(out.status).toBe(3); + expect(out.stderr).toContain('(STOP_UNBOUND)'); + expect(fs.readFileSync(r.body, 'utf8')).not.toContain('"mark":"stop"'); + }); + + // Value: protects=a claim names a real grant, an extra-round grant is claimed once, and a fresh run at the same head plans without a + // grant another run spent instead of stopping on GRANT_SPENT; fails_when=claim marks an unknown id or history keeps the claimed + // grant in PR_REVIEW_FLAGS; seam=gstack-ship-receipt claim/history + test('claim refuses an unknown grant; history leaves out an extra-round grant another run claimed', () => { + const r = stopRepo(); + const unknown = r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'fc1', '--grant', 'a-000000000000']); + expect(unknown.status).toBe(3); + expect(unknown.stderr).toContain('(GRANT_UNKNOWN)'); + const x = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', r.head(), '--kind', 'extra-round', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!; + const history = (run: string) => r.run('gstack-ship-receipt', ['history', '--body', r.body, '--pr', '7', '--base', 'main', '--run', run]).stdout; + expect(history('r1')).toContain('--round-grant ' + x); + expect(r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'r1', '--grant', x]).stdout).toContain('GRANT_CLAIMED: grant=' + x + ' kind=extra-round'); + expect(history('r1')).toContain('--round-grant ' + x); + expect(history('r2')).not.toContain('--round-grant'); + expect(history('r2')).toContain('PR_REVIEW_GRANT: not applied (grant ' + x + ' was claimed by run r1'); + }); + + // Value: protects=the re-plans after a granted fix-check (post-review, targeted) keep PR_REVIEW_FLAGS' --stop with their own + // --range-base after the stop's head; fails_when=any --range-base other than --stop exits 2; seam=gstack-review-plan + test('the plan takes a --range-base at or after the --stop head and refuses one before it', () => { + const r = stopRepo(); + const s = r.head(); + const g = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!; + r.f.write({ 'src/x.ts': 'export const x = 3;\n' }); r.f.commit('fix'); + const fixed = r.head(); + const plan = (rangeBase: string) => r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '3', '--pr', '7', '--round-grant', g, '--stop', s, '--post-review', '--last', 'fix-check', '--range-base', rangeBase]); + const after = plan(fixed); + expect(after.status, after.stderr).toBe(0); + expect(plan(s + '~1').status).toBe(2); + }); +}); + +describe('finish and the summary count a run whose only round is the granted fix-check (X14)', () => { + // Value: protects=GHOM-1's new run reaches its receipt: finish chains the fix-check to the stop's tree under a fix-check round grant, + // and the summary takes a run with no full pass of its own; fails_when=finish reads only review_loop_grant rows or the summary + // refuses passes=0; seam=gstack-ship-release finish, gstack-review-scope summary + test('a fresh run: fix-check from the stop head, granted by a fix-check round grant', () => { + const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n" }); + fxs.push(f); + const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' }); + const s = f.git('rev-parse', 'HEAD').stdout.trim(); + const reviewed = run('gstack-wtree', []).stdout.trim(); + const reviewedBase = f.git('merge-base', 'origin/main', 'HEAD').stdout.trim(); + const g = run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/outside-voice#1', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)']); + expect(g.status, g.stderr).toBe(0); + f.write({ 'src/x.ts': 'export const x = 3;\n' }); f.commit('fix the read-only review blocker'); + const since = new Date(Date.now() - 1000).toISOString(); + const start = run('gstack-review-log', ['--start', 'review-fix-check']); + expect(start.status, start.stderr).toBe(0); + const logged = run('gstack-review-log', [JSON.stringify({ skill: 'review-fix-check', timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', range_base: s, completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] }), '--finish', start.stdout.trim()]); + expect(logged.status, logged.stderr).toBe(0); + const summary = run('gstack-review-scope', ['summary', '--since', since, '--no-ledger', '--json']); + expect(summary.status, summary.stderr).toBe(0); + expect(JSON.parse(summary.stdout)).toMatchObject({ passes: 0, fix_checks: 1 }); + const post = path.join(f.root, 'post.json'); + expect(run('gstack-docs-candidate', ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0); + const fin = f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--reviewed-base', reviewedBase, '--lane', 'tests=printf " 3 pass\\n 0 fail\\nRan 3 tests across 1 file. [5.00ms]\\n"'], { GSTACK_APPROVALS_MIRROR: '0' }); + expect(fin.stdout).toMatch(/^FIX_CHECK: reviewed .*src\/x\.ts.*grant a-[0-9a-f]{12}\)$/m); + }); +}); diff --git a/test/size-ledger/ship/round-grant-buys-the-fix-round-after-a-review-cap-stop.json b/test/size-ledger/ship/round-grant-buys-the-fix-round-after-a-review-cap-stop.json new file mode 100644 index 000000000..7c2d7c292 --- /dev/null +++ b/test/size-ledger/ship/round-grant-buys-the-fix-round-after-a-review-cap-stop.json @@ -0,0 +1,4 @@ +{ + "bytes": 591, + "why": "GST-2968: /ship records its stop and claims a round grant before dispatch" +}