Fix /ship review counting, cleared reviewer notes and security findings in the posted PR description (GST-3343) (#4595)

/ship no longer stalls on summary notes a reviewer already cleared,
counts only full review passes as rounds, records a round approval
relayed during a stopped run, and keeps security findings out of the
ship record it posts in the PR description.

These four bugs each stopped a real /ship run until someone edited a
record by hand; the goal is unattended shipping that finishes on its
own.

Nothing to do as a reader.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: s11/outside-voice#1 reader=outside-voice
Review-Finding: s11/adversarial-native#2 reader=adversarial-native
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-21 08:51:13 +00:00
1 parent 387a65c9a2
commit b281effa07
18 files changed
+178 -38

No files matched your search

+6 -2
View File
@@ -61,6 +61,8 @@ const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gs
dispositions the "Gate disposition: …" lines the Pre-Landing Review and the PR body carry
round-grant --pr <n> --head <the head that needs the round> --kind extra-round|fix-check --reason <why, one line>
--by <the lane or its Captain> [--words <their words; default the reason>]
[--owner-ref <thread code>:<message id or timestamp>: relays the grant from the lane's or Captain's message, so it
records while a stopped /ship run is still open on this checkout; needs --words]
[--stop-run <run> --findings <ids>: 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
@@ -180,12 +182,14 @@ function main(argv: string[]): number {
const head = spawnSync('git', ['rev-parse', '--verify', '--quiet', `${flags['--head'] ?? ''}^{commit}`], { encoding: 'utf8', timeout: 10_000 });
if (!flags['--head'] || head.status !== 0) return invalid('round-grant needs --head <the head that needs the round, a commit in this repository>');
if (!by || isGstackActorName(by)) return invalid('round-grant needs --by <the lane or its Captain>: gstack never grants itself a round');
const ownerRef = flags['--owner-ref']?.trim();
if (ownerRef !== undefined && (!OWNER_REF.test(ownerRef) || !(flags['--words'] ?? '').trim())) return invalid('--owner-ref relays the lane\'s or Captain\'s grant: <thread code>:<message id or timestamp> (GSTA-36:2026-11-19T12:29:59Z), with --words <their exact words>');
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`);
if (open && ownerRef === undefined) 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; relay it with --owner-ref <thread code>:<message id or timestamp> --words <their exact words>, or record it from the lane after the run stops`);
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 <the run gstack-ship-receipt stop named> and --findings <the open finding ids it is for, comma-separated>: 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);
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'], source: ruledNoteSource({ ownerRef }) }, loc.branch);
if ('code' in built) return fail(cmd, built);
rows = [built];
} else if (cmd === 'lane-exception') {
+1 -1
View File
@@ -100,7 +100,7 @@ const HELP = `gstack-review-plan — the review depth of the next /ship step (do
when a docs claim needs the targeted read on a targeted-class diff (GST-1702)
--pr <n> the PR whose platform review counts under review.platform on (default: this branch's PR); with
--round-grant, the PR the grant must name
--prior-rounds <n> R51 rounds earlier /ship runs on this PR already spent, fix-checks included (printed as pr_rounds=)
--prior-rounds <n> R51 rounds earlier /ship runs on this PR already spent, fix-checks not included (printed as pr_rounds=)
--prior-full <n> the full rounds among them: with this run's full passes they count against the cap of 2, so pass 1
of a PR with 2 is one read-only full review (no fix round; a blocker is NEXT: stop (PR_ROUND_CAP)
for the lane's Captain to decide, never the owner).
+3 -3
View File
@@ -67,7 +67,7 @@ import { appliedGateDispositions, gateDispositionText, publicGateDisposition } f
import { securityFingerprints } from '../lib/security-findings';
import { laneExceptionBodyLines } from '../lib/test-lane-exception';
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 { grantFor, publicRoundGrant, readReviewRoundGrants, type ReviewRoundGrant } from '../lib/review-round-grant';
import { readMechanicalLines } from '../lib/ship-mechanical';
import { patchId, productPatchAgainstBase, productRules, productSpec, verifiedOutputs } from '../lib/ship-receipt-patch';
import { runCalls } from '../lib/ship-clock';
@@ -386,7 +386,7 @@ function cmdWrite(rest: string[], json: boolean): number {
policy: flag(rest, '--policy') ?? tree?.policy, queue_mode: flag(rest, '--queue-mode'), preregistration: flag(rest, '--preregistration'), history: flag(rest, '--history'),
...pregate, issues: issuesFile ? receiptIssuesFrom(issuesFile) : undefined, approval: approval.kind === 'ok' ? approval.approval : undefined,
review_loop: reviewLoop, ...(docs?.ok ? { docs: docs.docs } : {}), ...product,
gstack_version: installedGstackVersion(), review_depth: reviewDepth, review_loop_exception: loopException?.ok ? loopException.exception : undefined, review_round_grants: roundGrantsFor(repoRoot, flag(rest, '--pr')), ruled_notes: ruledNotes.length ? ruledNotes.map(publicRuledNote) : undefined, gate_dispositions: gateDispositions.map(publicGateDisposition), mechanical: mechanical.length ? mechanical : undefined, review_targeted: targeted?.ok ? targeted.targeted : undefined,
gstack_version: installedGstackVersion(), review_depth: reviewDepth, review_loop_exception: loopException?.ok ? loopException.exception : undefined, review_round_grants: roundGrantsFor(repoRoot, flag(rest, '--pr'))?.map(g => publicRoundGrant(g, ruledNotes)), ruled_notes: ruledNotes.length ? ruledNotes.map(publicRuledNote) : undefined, gate_dispositions: gateDispositions.map(publicGateDisposition), mechanical: mechanical.length ? mechanical : undefined, review_targeted: targeted?.ok ? targeted.targeted : undefined,
design: review.frontend ? { mode: 'static', reason: 'no preview declared' } : undefined,
base_red: pause ? receiptBaseRed(pause) : undefined,
review_exclude: receiptExclude(review.exclude),
@@ -1044,7 +1044,7 @@ function cmdStub(rest: string[]): number {
const status = rest.includes('--void') ? 'voided' : 'started';
const err = postBody(rest, read.pr, placeRunEntry(read.body, runStub({ head, run, status, loop })));
if (err) { process.stderr.write(`gstack-ship-receipt stub: ${err}; the run is not recorded\n`); return EXIT.fail; }
process.stdout.write(`RUN_STUB: run=${run} status=${status} rounds=${loop.rounds ?? loop.passes + (loop.fix_checks ?? 0)} head=${head.slice(0, 12)}\n`);
process.stdout.write(`RUN_STUB: run=${run} status=${status} rounds=${loop.passes} head=${head.slice(0, 12)}\n`);
return EXIT.ok;
}