Skip to content
Merged
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
23 changes: 6 additions & 17 deletions bin/gstack-no-stop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
/**
* gstack-no-stop — record one of the five no-stop defaults and go on (GSTA-258 K1, docs/review-policy.md#no-stop).
* gstack-no-stop — record one of the four no-stop defaults and go on (GSTA-258 K1, docs/review-policy.md#no-stop).
*
* gstack-no-stop record --class <class> --reason <text> --evidence <ref> [--range-base <sha>] [--json]
* gstack-no-stop import --from <autoplan run>/no-stop.json [--json]
Expand All @@ -19,7 +19,7 @@ import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { appendLedger, checkNoStop, ledgerPath, readLedger } from '../lib/no-stop';
import { runScriptSync } from '../lib/script-invocation';

const HELP = `gstack-no-stop — record one of the five no-stop defaults (docs/review-policy.md#no-stop)
const HELP = `gstack-no-stop — record one of the four no-stop defaults (docs/review-policy.md#no-stop)

record --class <class> --reason <text> --evidence <run id, commit or file> [--range-base <sha>] [--json]
NO_STOP: <class> recorded: go on. NO_STOP: refused (exit 3): the stop stands. Anything else still stops.
Expand All @@ -28,23 +28,19 @@ const HELP = `gstack-no-stop — record one of the five no-stop defaults (docs/r
test-timeout-fix a fix that only raises a test's timeout (--range-base the commit before it): its gate
finding takes the printed GATE_DISPOSITION: kept reason instead of open
pregate-flake-rerun one rerun of a failed pregate case at the same tree (rule 16): green is flaky, red is real
stamp-only-carry carry refused a head whose change is a version stamp (--range-base the receipt head,
--base origin/<base>): go on to Steps 2-16 without waiting; the plan reviews HEAD in full
autoplan-regate gstack-autoplan records it; import --from <run>/no-stop.json adds it here
Step 19's receipt write adds --no-stop @<NO_STOP_FILE> when list shows records.
--range-base: the commit the fix or change is measured from (round 2's PASS_HEAD for scoped-fix-check, which must be
the newest review-log pass row's commit,
the commit before the fix for test-timeout-fix, the receipt head for stamp-only-carry); required for those three
--base <ref> (stamp-only-carry): compare HEAD with the receipt head merged into <ref> (base side on conflict),
so a base merge plus a stamp qualifies and a product conflict resolution does not
the commit before the fix for test-timeout-fix); required for those two
import --from <file> [--json] add an autoplan run's no-stop.json records to the branch's ledger
list [--json] the branch's ledger and its path

${exitTableHelp()}`;

const flag = (args: string[], name: string) => { const i = args.indexOf(name); return i >= 0 ? args[i + 1] : undefined; };
const git = (args: string[]) => spawnSync('git', args, { cwd: process.cwd(), encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 });
const NEEDS_RANGE = ['scoped-fix-check', 'test-timeout-fix', 'stamp-only-carry'];
const NEEDS_RANGE = ['scoped-fix-check', 'test-timeout-fix'];
const K1_BY = 'gstack no-stop default (K1)';
const AUTOPLAN_EVIDENCE = /^autoplan:\S+@gate_rev=\d+$/;

Expand Down Expand Up @@ -74,8 +70,7 @@ function record(args: string[], json: boolean): number {
const cls = flag(args, '--class') ?? '';
const commit = (ref: string | undefined) => { if (!ref) return undefined; const r = git(['rev-parse', '--verify', '--quiet', '--end-of-options', `${ref}^{commit}`]); return r.status === 0 ? r.stdout.trim() : null; };
const rangeBase = commit(flag(args, '--range-base'));
const base = cls === 'stamp-only-carry' ? commit(flag(args, '--base')) : undefined;
if (rangeBase === null || base === null) { process.stderr.write(`gstack-no-stop record: --range-base and --base must name commits\n`); return EXIT.usage; }
if (rangeBase === null) { process.stderr.write(`gstack-no-stop record: --range-base must name a commit\n`); return EXIT.usage; }
if (!cls) { process.stderr.write(`gstack-no-stop record: --class is required\n${HELP}\n`); return EXIT.usage; }
if (NEEDS_RANGE.includes(cls) && !rangeBase) { process.stderr.write(`gstack-no-stop record: --class ${cls} needs --range-base <sha>\n`); return EXIT.usage; }
const file = ledgerPath(process.cwd());
Expand All @@ -94,13 +89,7 @@ function record(args: string[], json: boolean): number {
}
let diff: string | undefined;
if (rangeBase) {
let from = rangeBase;
if (base) {
const merged = git(['merge-tree', '--write-tree', '-X', 'ours', base, rangeBase]);
if (merged.status !== 0) { process.stderr.write(`NO_STOP: refused ${cls} (git merge-tree ${base} ${rangeBase} failed: ${merged.stderr.trim() || 'conflict'}); stop for the owner\n`); return EXIT.refused; }
from = merged.stdout.split('\n')[0]!.trim();
}
const d = git(['diff', '--no-color', '--no-ext-diff', '--no-renames', from, 'HEAD']);
const d = git(['diff', '--no-color', '--no-ext-diff', '--no-renames', rangeBase, 'HEAD']);
if (d.status !== 0) { process.stderr.write(`gstack-no-stop record: git diff ${rangeBase} HEAD failed: ${d.stderr.trim()}\n`); return EXIT.fail; }
diff = d.stdout;
}
Expand Down
10 changes: 6 additions & 4 deletions bin/gstack-ship-receipt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { ghSpawnSync } from '../lib/gh-poll';
import { EXIT, exitTableHelp, type ShipReceipt } from '../lib/headless-artifacts';
import { EXIT, exitTableHelp, NO_STOP_CLASSES, type ShipReceipt } from '../lib/headless-artifacts';
import { resultLine, resultLineWithDocs } from '../lib/result-codes';
import { versionAtRef } from '../lib/restamp';
import { branchSides, stampOnlyLine, type BranchSide } from '../lib/stamp-only';
Expand All @@ -48,7 +48,7 @@ import { installedGstackVersion, isUnavailable, loadPolicyFromBase, matchesAny,
import { approvalForReceipt } from '../lib/approval-citations';
import {
CARRY_METADATA_GLOBS, CARRY_NAMED_PATHS, CARRY_TEST_GLOBS,
bindReceipt, carryReceipt, classifyCarryPath, computeCensus, extractReceipt, landedStackParent, missingIssueLines, orderReceipt, parseReviewLoop, placeReceipt, planCarry, planTreeCarry,
bindReceipt, carryReceipt, recheckCarried, classifyCarryPath, computeCensus, extractReceipt, landedStackParent, missingIssueLines, orderReceipt, parseReviewLoop, placeReceipt, planCarry, planTreeCarry,
receiptIssuesFrom, receiptSummaryLine, renderCensus, renderReceiptBlock, validateReceipt, type CensusPr,
} from '../lib/ship-receipt';
import { checkDocsCaps, docsCapLine, docsExceptionLine, parseReceiptDocs } from '../lib/ship-receipt-docs';
Expand Down Expand Up @@ -139,7 +139,7 @@ write flags: --pr --head --base --version --gated-tree --predecessor --gate <jso
--carry): files the earlier audit edited reset too, to their content before it, when HEAD holds what it left; a carried audit of
another run refuses (GST-1616).
--no-stop <json|@file> (a JSON array of {class, reason, evidence}: each routine stop the run recorded and went on past, class one of
scoped-fix-check, test-timeout-fix, pregate-flake-rerun, stamp-only-carry, autoplan-regate); recorded as no_stop.
scoped-fix-check, test-timeout-fix, pregate-flake-rerun, autoplan-regate); recorded as no_stop.
--declare-risk <classes> (the same list gstack-review-plan --declare-risk took): joins review_depth's risk and only raises
its depth; review_depth.declared and .detected record both lists (GST-1129). An unknown class is RECEIPT_INVALID.
--platform-review <id> (NEXT: platform's PLATFORM_REVIEW: id): records review_depth platform with capy-ai[bot]'s review <id> at HEAD;
Expand Down Expand Up @@ -177,7 +177,8 @@ function noStopArg(raw: string | undefined): ShipReceipt['no_stop'] {
if (raw === undefined) return undefined;
const parsed = JSON.parse(raw.startsWith('@') ? fs.readFileSync(raw.slice(1), 'utf8') : raw);
if (!Array.isArray(parsed)) throw new Error('--no-stop expects a JSON array of {class, reason, evidence}');
return parsed.length ? parsed : undefined;
const kept = parsed.filter(r => (NO_STOP_CLASSES as readonly string[]).includes(r?.class) || void process.stderr.write(`NO_STOP: dropped ${JSON.stringify(r?.class)} from --no-stop: not a current no-stop class (${NO_STOP_CLASSES.join(', ')}), so the receipt leaves it out (GST-2706)\n`));
return kept.length ? kept : undefined;
}
function git(args: string[], cwd?: string): string | undefined {
const r = spawnSync('git', args, { cwd, encoding: 'utf8', timeout: 30_000, maxBuffer: 256 * 1024 * 1024 });
Expand Down Expand Up @@ -710,6 +711,7 @@ function cmdCarry(rest: string[], json: boolean): number {
if (receipt.base_red) return refused('QUEUE_RECEIPT_CONDITIONAL', 'the receipt is paused on a red base, so there is nothing passing to carry; /ship --resume <record> re-runs Step 5 and writes a full receipt');
const from = receipt.head.toLowerCase();
if (!/^[0-9a-f]{40,64}$/.test(from)) return refused('RECEIPT_CARRY_REFUSED', `the receipt's head ${receipt.head.slice(0, 12)} is not a full commit id`);
if (recheckCarried(receipt)) return refused('RECEIPT_CARRY_REFUSED', `the receipt reached ${from.slice(0, 12)} through a scoped re-check (carry: ${receipt.carry!.reason.slice(0, 160)}), which is advice only (GST-2673), so the product code it covered never got a full review; the receipt is unchanged: run /ship on ${head.slice(0, 12)} for the merge head's full review (docs/review-policy.md#rounds-per-pull-request)`);
if (from === head) {
process.stderr.write(receiptSummaryLine(receipt) + '\n');
process.stdout.write(json ? JSON.stringify({ skill: 'ship', status: 'current', head, carry: null }) + '\n' : `CARRY: current (the receipt already names ${head.slice(0, 12)})\n`);
Expand Down
1 change: 1 addition & 0 deletions changelog.d/close-last-recheck-carry-paths.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **A pull request's merge head can no longer keep its `/ship` receipt without a full review.** Three gaps let a receipt through on less than the full review R51 asks for. A head whose own added lines match the reviewed ones but whose removed lines changed with the base (the base took `SAVE_VERSION := 83` under a branch reviewed as `82` to `84`) used to carry after one scoped reader; it's now a product change, so carry refuses and `/ship` reviews the head in full. A receipt an older gstack carried through a scoped re-check no longer carries on through a later base merge or stamp, and `gstack-ship-queue` won't bind it (`QUEUE_RECEIPT_STALE`), until a fresh full review replaces it. And a `/ship` body post keeps the PR body's `gstack-receipt-runs` block, so `gstack-ship-receipt history` counts every run instead of only the last. The read-only review's `PR_ROUND_CAP` stop no longer offers a round grant it can't honor, and the `stamp-only-carry` no-stop class is gone: a refused carry already runs Steps 2-16 without a stop, so a receipt that still lists that class is invalid and its PR runs `/ship` again. See docs/review-policy.md#rounds-per-pull-request.
29 changes: 22 additions & 7 deletions docs/review-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ caught on another crew's PRs.
once) and prints `PR_REVIEW_HISTORY:`, the flag line `PR_REVIEW_FLAGS:
--prior-rounds <rounds> --prior-full <full rounds>` and `PR_REVIEW_ROUTE:`.
`/ship` Step 1 prints all three. A re-check that carried a receipt before
this rule adds no round.
this rule adds no round. The count fails open when the history can't be
read (no `gh`, an unreadable body): Step 1 prints `PR_REVIEW_FLAGS:
--prior-rounds 0` and `PR_REVIEW_ROUTE: first (history unavailable: …)`, so
the plan counts this run's rounds only (`lib/ship-preflight.ts`). Every
run still reviews its head in full; what's lost is the cap on earlier
runs, so check the PR body by hand when that line shows. A `/ship` body
post keeps the live `gstack-receipt-runs` block (`lib/gstack-post.ts`), so
earlier runs and started stubs stay countable.
2. **Runs that stop count too.** After each Step 9 pass, `gstack-ship-receipt
stub --pr <n> --run <id> --review-loop <summary>` writes a `status: started`
entry, so a run that stops before its receipt still counts. The run's receipt
Expand All @@ -166,10 +173,18 @@ caught on another crew's PRs.
before merge), and `read-only` after two. Carry may still print `RECHECK:
advisory … packet=<file>`: one reader may read that packet for advice, but
its verdict never rebinds the receipt, and `carry --recheck` is refused
([scoped re-check](troubleshooting.md#receipt-carry-recheck)).
([scoped re-check](troubleshooting.md#receipt-carry-recheck)). A receipt an
older gstack carried through a re-check (its `carry.reason` names `scoped
re-check by`) carries no further, not even through a base merge or a stamp,
and `gstack-ship-queue` won't bind it (`QUEUE_RECEIPT_STALE`): the code that
hop covered never got a full review, so the head runs `/ship` until a fresh
full review replaces that receipt.
4. **Stop rule.** `gstack-review-plan --prior-full <n>` adds the PR's earlier
full rounds to this run's full passes; fix-checks stay the in-run table's
call, and `--prior-rounds` is printed as `pr_rounds=`. A full pass past two
call, and `--prior-rounds` is printed as `pr_rounds=`. The per-PR cap counts
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
Expand All @@ -178,8 +193,9 @@ caught on another crew's PRs.
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, record a round grant, or park. The count does
not reopen.
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 <n> --head <sha> --kind
extra-round --reason <why> --by <lane or Captain>` records one grant for one
head: one round past the cap, with its fix round, instead of the read-only
Expand Down Expand Up @@ -256,7 +272,7 @@ applies no edits is its exit too.
<a id="no-stop"></a>
### No-stop defaults (K1)

Five routine stops don't wait for a Captain. /ship and /autoplan record each one
Four routine stops don't wait for a Captain. /ship and /autoplan record each one
as `{class, reason, evidence}` in the receipt's `no_stop` field and keep going.
`gstack-no-stop record` (`lib/no-stop.ts`) checks each case before it records it.
When a case doesn't qualify, it prints `NO_STOP: refused` and exits 3, and that
Expand All @@ -267,7 +283,6 @@ stop goes to the owner as before. Every other stop still stops.
| `scoped-fix-check` | Round 2 stops for a fix whose range since round 2's `PASS_HEAD` is docs class only, or only raises timeout values. `--range-base` must be the commit the newest review-log pass row read. One per branch: the ledger keeps every record, so a later /ship on the branch stops for the owner. | It records the standing grant in the approval record (`by: gstack no-stop default (K1)`) and prints `GRANT:`. `gstack-review-plan --grant` plans the one scoped fix-check. A blocking finding there goes to the owner. |
| `test-timeout-fix` | Every changed line is in a test file and only raises a timeout value: the value of a timeout key (`timeout: 5_000`, `setDefaultTimeout(5_000)`, `--timeout=5000`) or bun's and jest's trailing per-test argument, only on the line that opens the test call itself (`test('…', () => {…}, 30_000);`, likewise `it(` and `describe(`). A multi-line test's closing `}, 30_000);` does not qualify and stops for the owner. A line with `expect`, `assert` or a comparison never qualifies. | The gate scan's relaxation finding takes the printed `GATE_DISPOSITION: kept` reason instead of `open`. |
| `pregate-flake-rerun` | One rerun of a failed pregate case at the same tree (CREW rule 16). One per branch. | Green counts as flaky. Red again is a real failure. |
| `stamp-only-carry` | A refused carry, where the receipt head merged into the base (base side on conflict) differs from HEAD only in a version stamp: `VERSION`, the `"version"` line of `package.json`, `CHANGELOG.md`, the agents digest or `changelog.d/` fragments. | Go on to Steps 2–16 without waiting for a Captain: the plan reviews HEAD in full, since a re-check no longer carries a receipt ([rounds per pull request](#rounds-per-pull-request)). |
| `autoplan-regate` | An edit to the plan file made after the owner's answer, or after the revise that took their changes, while the reviewed plan itself is unchanged. The edit only adds lines, all inside the plan's `## ELI5` section (an added `## ELI5` heading opens one), and no added line holds a number or a word for spend, cost, budget, price, cap, credits, limit, max, arm, model, judge, verdict, threshold, bar, trial, sample, stop rule, paid or eval. A removed or reworded line, or a line added anywhere else, goes to the owner. The carry exports the reviewed plan, so the added explanation is never built. | `gstack-autoplan` carries the owner's words (`reason=no-stop autoplan-regate: …`) and writes `<run>/no-stop.json`. `gstack-no-stop import` adds it to the branch's ledger. |

The ledger is one JSON array per branch under the checkout's git directory
Expand Down
23 changes: 10 additions & 13 deletions docs/ship-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ checked-out HEAD, when the receipt records `gstack_version` without

**`no_stop`.** The routine stops the run recorded and went on past, from
`write --no-stop <json|@file>`: an array of `{ class, reason, evidence }`, with
`class` one of the five no-stop defaults. /ship passes the branch's
`class` one of the four no-stop defaults. /ship passes the branch's
`gstack-no-stop` ledger here ([review-policy.md#no-stop](review-policy.md#no-stop)).

**`review_loop_exception`.** The owner's acceptance of a stop after a
Expand Down Expand Up @@ -2279,19 +2279,16 @@ of the branch's own +/- lines, or a packet over the caps, prints `RECHECK: not e
`RECEIPT_CARRY_PRODUCT_CHANGED`. A changed path alone, or context paths alone,
keep the routes above, and their output is unchanged.

The same scoped review also covers a hunk whose only difference from the
reviewed one is the base's edit of the lines the branch replaces. The base took
A hunk whose added lines are the reviewed ones but whose removed lines changed
with the base is a changed path, not a context path (GST-2706). The base took
`SAVE_VERSION := 83` while the branch's `:= 84` line, reviewed against `82`,
stays byte-identical. The branch's added lines must match byte for byte, and
the lines just outside the reviewed hunk's removed range must be lines the base
kept, landing just outside the current hunk's range (`lib/ship-patch.ts`
`comparePath`). The path then counts as a context path. Carry and finish put it
in the scoped-review packet, and the reader checks that the branch's value
still holds next to the base's. It never carries without a reader. A hunk whose
added lines changed, that now also removes a line the base never touched, or
whose range holds a line the base added (a base hunk at or next to the replaced
lines that adds more lines than it removes) stays a changed path. A [mechanical retake](#mechanical-retake) does not apply
here, since the branch retook nothing.
stays byte-identical, so the PR now removes `83`, a line no review read. A head
counts as the reviewed one only when the PR's own added and removed lines are
both byte-identical ([rounds per pull request](review-policy.md#rounds-per-pull-request)),
so carry refuses with `RECEIPT_CARRY_PRODUCT_CHANGED` and the head runs /ship,
whose plan reviews it in full (`lib/ship-patch.ts` `comparePath`). GST-1561 had
sent it to the one scoped reader instead. A [mechanical retake](#mechanical-retake)
does not apply here, since the branch retook nothing.

**Rewritten history.** `write` records `head_tree` (the reviewed head's tree)
and `product_patch_id` (its product patch against the base), and every carry
Expand Down
Loading
Loading