Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions bin/gstack-approvals
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { spawnSync } from 'node:child_process';
import * as path from 'node:path';
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { appendRows, branchExists, buildRow, importAutoplan, locate, readRecord, renderMode, renderRecord, repoVisibility, syncRecord, type RecordError, type StoreLocation } from '../lib/approval-record';
import { GSTACK_ACTOR, openShipRun, RULED_NOTE_SCOPE, ruledNoteRow, ruledNotes, ruledNoteText } from '../lib/ruled-notes';
import { GSTACK_ACTOR, openShipRun, RULED_NOTE_SCOPE, ruledNoteRow, ruledNotes, ruledNoteText, stopRulingRow } from '../lib/ruled-notes';
import { resultLine } from '../lib/result-codes';
import { parsePlanLine, publicPlanLine, resolvePlan } from '../lib/plan-record';
import { TEST_LANE_EXCEPTION_SCOPE, testLaneExceptionRow } from '../lib/test-lane-exception';
Expand All @@ -43,10 +43,12 @@ const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gs
import --autoplan <run dir> [--by <whose words, e.g. Garry>] [--stack <b1,b2,...>]
--stack writes the same rows to every branch of a stack; each branch is checked first, and one unknown branch writes none
rule --finding <fingerprint> --head <the stop head the owner ruled at> --reason <why it ships as a note, one line>
--words <the owner's exact words> --by <who ruled>
--words <the owner's exact words> --by <who ruled> [--pr <n> --stop-run <run>]
the owner's ruling that a review finding ships as a disclosed note (docs/ship-policy.md#ruled-notes); finish
counts that finding closed on a fix-check whose range_base..commit holds the head, and the receipt and PR body
list it; refused inside this checkout's open /ship run
list it; refused inside this checkout's open /ship run. With --pr and --stop-run, --finding is the ledger id
of one open finding of the stop record that run left at --head (gstack-ship-receipt ruled-stop lists them),
and only that stop's ruled-stop check applies it
rulings the "Ruled note: …" lines the Pre-Landing Review and the PR body carry
gate --finding <the gate finding's fingerprint> --gate-id <its gate_id> --head <the stop head the owner answered at>
--reason <the gate change, one line> --words <the owner's exact words, one line> --by <who recorded them>
Expand Down Expand Up @@ -208,7 +210,11 @@ function main(argv: string[]): number {
if (GSTACK_ACTOR.test((flags['--by'] ?? '').trim())) return invalid('--by names gstack; a ruling is the owner\'s, so --by names who ruled');
const open = openShipRun(process.cwd());
if (open) return invalid(`/ship run ${open} is open on this checkout: a ruling is the owner's, never the lane's own runner's; record it from the owner's session`);
const built = buildRow({ ...ruledNoteRow(finding, head.stdout.trim(), reason), words: flags['--words'] ?? '', by: flags['--by'] ?? '', date: flags['--date'] }, loc.branch);
const stopRun = flags['--stop-run']?.trim(), pr = flags['--pr']?.trim();
if ((stopRun === undefined) !== (pr === undefined)) return invalid('a stop ruling names both --pr <n> and --stop-run <the run gstack-ship-receipt stop named>; omit both for a fix-check ruling by fingerprint');
if (stopRun !== undefined && (!STOP_RUN.test(stopRun) || !/^[1-9]\d*$/.test(pr!) || !FINDING_ID.test(finding))) return invalid('a stop ruling needs --pr <n>, --stop-run <run> and --finding <the open finding\'s ledger id, as gstack-ship-receipt ruled-stop lists it>');
const ruling = stopRun !== undefined ? stopRulingRow(finding, head.stdout.trim(), Number(pr), stopRun, reason) : ruledNoteRow(finding, head.stdout.trim(), reason);
const built = buildRow({ ...ruling, words: flags['--words'] ?? '', by: flags['--by'] ?? '', date: flags['--date'] }, loc.branch);
if ('code' in built) return fail(cmd, built);
rows = [built];
} else if (cmd === 'gate') {
Expand Down
1 change: 1 addition & 0 deletions bin/gstack-doctor-components.sh
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ gstack_result_anchor() {
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' ;;
RULED_STOP_OPEN) printf '%s' 'ruled-stop-open' ;;
GRANT_SPENT) printf '%s' 'grant-spent' ;;
GRANT_UNKNOWN) printf '%s' 'grant-unknown' ;;
RECEIPT_CARRY_SCOPED_REVIEW) printf '%s' 'receipt-carry-scoped-review' ;;
Expand Down
4 changes: 3 additions & 1 deletion bin/gstack-review-plan
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as path from 'node:path';
import { spawnSync } from 'node:child_process';
import { baseContainsHead } from '../lib/default-base';
import { locate, readRecord } from '../lib/approval-record';
import { reviewRoundGrants } from '../lib/review-round-grant';
import { readGrantedStop, reviewRoundGrants } from '../lib/review-round-grant';
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { resultLine } from '../lib/result-codes';
import { runScriptSync } from '../lib/script-invocation';
Expand Down Expand Up @@ -197,6 +197,8 @@ function main(): number {
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 <head> 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; }
const stamp = g?.kind === 'fix-check' && root ? readGrantedStop(root) : undefined;
if (g?.kind === 'fix-check' && (stamp?.grant !== g.approval || stamp.head !== g.head || stamp.pr !== g.pr)) { process.stderr.write(`gstack-review-plan: --round-grant ${roundGrant}: gstack-ship-receipt history on this checkout has not matched this fix-check grant to the PR's newest stop record (its run, head and findings)${stamp ? `; it last matched grant ${stamp.grant}` : ''}: run gstack-ship-receipt history --pr ${g.pr} --base <base> --run <this /ship run> here and pass the --round-grant and --stop its PR_REVIEW_FLAGS: line prints (docs/troubleshooting.md#stop-unbound)\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; }
Expand Down
Loading
Loading