mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-17 13:44:32 +01:00
v1.99.5.0 Give the head a pull request merges a full review when its removed lines changed or it was only re-checked (GST-2706) (#4365)
* Count review rounds per pull request across /ship runs (GST-2673) /ship's two-round review cap was counted inside each run, so a pull request shipped many times was reviewed again at every head. Step 1 now reads the rounds the PR body's receipt history records, passes them to the review plan, and sends later heads to the scoped re-check, with a lane or Captain round grant for an extra round. Adds the no-loss replay preregistration. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Cap full review rounds per pull request and keep fix-checks to each run The plan counts a PR's earlier full rounds (--prior-full) against the cap of two, as the approved plan says, and prints every earlier round as pr_rounds=. Renames the troubleshooting anchor to pr-round-cap, lists <SESSION_ID> as a reviewed placeholder, and leaves ship/DRIVER.md at its size cap. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Point the ship driver's review pass at Step 9's plan flags, which carry the PR round count Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Give a pull request's final head a full review and make the diff-only re-check advice only (GST-2673) A scoped re-check that reads only what changed since the last reviewed head caught 22 of 24 planted faults but none of 8 real faults that full rounds had caught, so it no longer carries a /ship receipt. A later head whose own lines changed now gets a fresh full review, the PR's last before merge; a PR already at two full rounds gets one read-only full review with no fix round, whose blocker goes to the lane's Captain. carry prints RECHECK: advisory and refuses --recheck. The drift threshold, the re-check blocker count and the design-change grant kind are removed with the route they fed. Repins lib/review-depth.ts and ship/sections/review-army.md under replay GST-2673 (docs/evals/pr-round-count-results.md; deterministic grid against main: 196,608 of 196,608 plans identical with no prior rounds). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Keep a review round grant usable through its fix round and after a read-only review A grant now holds after the fix round's commits move HEAD past it, counts only the rounds earlier heads spent, and a receipt written without a run keeps other runs' stubs. Review-Finding: p1/specialist-batched#1 reader=state-machines Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p1/red-team#3 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Count every review round at a granted head again, so a grant can't reset the count Reverts the history change that skipped rounds recorded at a round grant's head: the run that hit the cap is recorded at that same head, so skipping it wiped the count. A grant recorded after a read-only review still doesn't buy a fix round (fails closed). Review-Finding: p2/adversarial-native#1 reader=adversarial-native Review-Finding: p2/outside-voice#1 reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Give a merge head a full review when its removed lines changed or its receipt came from a re-check A head whose removed lines changed with the base no longer carries on one scoped reader, a receipt an older gstack carried through a scoped re-check no longer carries on or lands, and a /ship body post keeps the run history. The read-only stop stops offering a round grant it can't honor, and the stamp-only-carry no-stop class is removed because a refused carry never stopped. (GST-2706) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Keep the run history inside Agent notes when the PR text quotes a receipt Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Let a receipt write skip a retired no-stop entry left in an older branch ledger Review-Finding: p3/outside-voice#1 reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Say in troubleshooting that the queue refuses a receipt carried through a re-check Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
800a9269fd
commit
79f6012bbc
23 files changed
+241
-162
No files matched your search
+6
-17
@@ -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]
|
||||
@@ -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.
|
||||
@@ -28,15 +28,11 @@ 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
|
||||
|
||||
@@ -44,7 +40,7 @@ ${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+$/;
|
||||
|
||||
@@ -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());
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
@@ -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';
|
||||
@@ -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;
|
||||
@@ -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 });
|
||||
@@ -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`);
|
||||
|
||||
@@ -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.
|
||||
+22
-7
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
+10
-13
@@ -1381,7 +1381,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
|
||||
@@ -2281,19 +2281,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
|
||||
|
||||
@@ -6482,6 +6482,10 @@ what would merge. The one accepted difference is a train slot's stamp: when
|
||||
the current head is the pinned head's stamp commit (same tree modulo stamp
|
||||
files, or the pin with main merged in at slot 2 and later), the receipt
|
||||
written for the pinned head is the binding one and `verify --train` accepts it.
|
||||
It also refuses a receipt an older gstack carried through a scoped re-check
|
||||
(its `carry.reason` names `scoped re-check by`), even at its own head: the code
|
||||
that hop covered never got a full review (GST-2706,
|
||||
[rounds per pull request](review-policy.md#rounds-per-pull-request)).
|
||||
|
||||
**Fix.** Rerun /ship on the current head so the receipt names it, then rerun
|
||||
`gstack-ship-queue ready --pr <n> --screen|--no-screen`. A lane never stamps
|
||||
@@ -7122,9 +7126,10 @@ the range-diff evidence ([unattended.md](unattended.md#the-terminal-line)).
|
||||
**Meaning.** Every product path the branch touches has the reviewed +/- lines
|
||||
in the same places, but the base edited context lines next to some of them, so
|
||||
the 3-line patches differ (GST-384: main reworded the line above the PR's
|
||||
hunk). A hunk whose added lines are unchanged and whose removed lines differ only
|
||||
by the base's edit of the lines the branch replaces counts too (GST-1561: the base
|
||||
took `SAVE_VERSION := 83` under the branch's `:= 84`). The merge may have spliced the two, as in a JSON entry where the branch
|
||||
hunk). A hunk whose added lines are unchanged but whose removed lines changed with
|
||||
the base (the base took `SAVE_VERSION := 83` under the branch's `:= 84`) doesn't
|
||||
count: the PR's own removed lines changed, so it's `RECEIPT_CARRY_PRODUCT_CHANGED`
|
||||
and a full review (GST-2706). The merge may have spliced the two, as in a JSON entry where the branch
|
||||
changed one key and the base the next, so the receipt does not carry silently.
|
||||
The refusal names the paths and a packet file with the hunks that differ and
|
||||
the base's own change. The same lines moved somewhere else are
|
||||
|
||||
+18
-2
@@ -29,7 +29,7 @@
|
||||
import { createHash } from "crypto";
|
||||
import { scan, type Finding, type RepoVisibility } from "./redact-engine";
|
||||
import { CI_RUN_WORD_BEFORE } from "./redact-patterns";
|
||||
import { agentNotesLines } from "./agent-notes";
|
||||
import { agentNotesLines, splitAgentNotes } from "./agent-notes";
|
||||
import { checkTitle, loadPlainTitlePolicy, PLAIN_TITLE_POLICY_PATH } from "./plain-title";
|
||||
import { RECEIPT_FENCE, RUNS_FENCE, extractReceipt, placeReceipt, renderReceiptBlock, validateReceipt } from "./ship-receipt";
|
||||
import type { ShipReceipt } from "./headless-artifacts";
|
||||
@@ -282,7 +282,7 @@ export function mergeBodySections(current: string, incoming: string): { body: st
|
||||
const next = splitSections(incoming).filter(n => !(n.key.startsWith("text:") && n.text.trim() === ""));
|
||||
const lone = next.find(n => n.key === "receipt");
|
||||
const intoNotes = lone && now.some(s => s.key === NOTES_KEY) && !next.some(n => n.key === NOTES_KEY) ? extractReceipt(lone.text).receipt : undefined;
|
||||
if (!intoNotes) return mergeSplit(now, next, incoming);
|
||||
if (!intoNotes) return keepRuns(current, next, mergeSplit(now, next, incoming));
|
||||
const after = next[next.indexOf(lone!) + 1];
|
||||
const rest = next.filter(n => n !== lone).map(n => n !== after || !n.key.startsWith("text:") ? n : { ...n, key: "text:after-receipt", text: n.text.replace(RUNS_BLOCK_RE, "") });
|
||||
const m = mergeSplit(now, rest.filter(n => !(n.key.startsWith("text:") && n.text.trim() === "")), incoming);
|
||||
@@ -291,6 +291,22 @@ export function mergeBodySections(current: string, incoming: string): { body: st
|
||||
|
||||
const RUNS_BLOCK_RE = new RegExp("^```" + RUNS_FENCE + "[ \\t]*\\r?\\n[\\s\\S]*?\\r?\\n```[ \\t]*(?:\\r?\\n|$)", "m");
|
||||
|
||||
/**
|
||||
* A /ship body post (an Agent notes section holding a receipt) keeps the live body's run history (GST-2706): the merge
|
||||
* replaces the notes, so the runs block placeReceipt would write on the live body (earlier runs, started stubs and the
|
||||
* replaced receipt) goes back right after the posted receipt, and gstack-ship-receipt history still counts every run.
|
||||
*/
|
||||
function keepRuns(current: string, next: Section[], m: ReturnType<typeof mergeSplit>): ReturnType<typeof mergeSplit> {
|
||||
const posted = next.some(n => n.key === NOTES_KEY && extractReceipt(n.text).found) ? extractReceipt(m.body).receipt : undefined;
|
||||
const notesAt = (body: string) => splitAgentNotes(body).notes === null ? 0 : splitAgentNotes(body).readable.length;
|
||||
const placed = posted ? placeReceipt(current, posted) : "";
|
||||
const runs = RUNS_BLOCK_RE.exec(placed.slice(notesAt(placed)))?.[0];
|
||||
const at = notesAt(m.body);
|
||||
const notes = m.body.slice(at).replace(RUNS_BLOCK_RE, "");
|
||||
const end = runs && /```gstack-ship-receipt[ \t]*\r?\n[\s\S]*?\r?\n```[ \t]*(?:\r?\n|$)/.exec(notes);
|
||||
return end ? { ...m, body: m.body.slice(0, at) + notes.slice(0, end.index + end[0].length) + "\n" + runs + notes.slice(end.index + end[0].length) } : m;
|
||||
}
|
||||
|
||||
function mergeSplit(now: Section[], next: Section[], incoming: string): { body: string; replaced: string[]; kept: string[]; added: string[]; dropped: string[] } {
|
||||
const ambiguous = next.filter(n => now.filter(s => s.key === n.key).length > 1).map(n => `"${n.label}"`);
|
||||
if (ambiguous.length) throw new UsageError(`the PR's current body holds ${[...new Set(ambiguous)].join(", ")} more than once, so the file's copy matches no single section; nothing was posted. Rerun with --replace and the whole body`);
|
||||
|
||||
@@ -145,7 +145,7 @@ export interface ShipReceipt {
|
||||
/** Routine stops the run recorded and went on past instead of waiting for a Captain (plan K1; GSTA-258 L5 writes them): one record per stop. */
|
||||
no_stop?: Array<{ class: NoStopClass; reason: string; evidence: string }>;
|
||||
}
|
||||
export const NO_STOP_CLASSES = ['scoped-fix-check', 'test-timeout-fix', 'pregate-flake-rerun', 'stamp-only-carry', 'autoplan-regate'] as const;
|
||||
export const NO_STOP_CLASSES = ['scoped-fix-check', 'test-timeout-fix', 'pregate-flake-rerun', 'autoplan-regate'] as const;
|
||||
export type NoStopClass = typeof NO_STOP_CLASSES[number];
|
||||
|
||||
export const RESULT_STATUSES: readonly ResultStatus[] = ['complete', 'reviewed', 'gate_pending', 'amend_pending', 'incomplete', 'interrupted', 'refused'];
|
||||
|
||||
+3
-23
@@ -1,14 +1,13 @@
|
||||
/**
|
||||
* The five no-stop defaults (GSTA-258 plan K1, docs/review-policy.md#no-stop): routine stops /ship and
|
||||
* The four no-stop defaults (GSTA-258 plan K1, docs/review-policy.md#no-stop): routine stops /ship and
|
||||
* /autoplan record in the receipt's `no_stop` field and go on past instead of waiting for a Captain.
|
||||
* Each class has one deterministic test here; anything that fails it, and any stop outside the five,
|
||||
* Each class has one deterministic test here; anything that fails it, and any stop outside the four,
|
||||
* still stops for the owner.
|
||||
*
|
||||
* - scoped-fix-check: one scoped fix-check past R51's two-round cap when the round-2 fix is docs-only
|
||||
* (docs class, lib/review-depth.ts classifyPath) or timeout-only. One per branch.
|
||||
* - test-timeout-fix: a fix whose every changed line, all in test files, only raises a timeout value.
|
||||
* - pregate-flake-rerun: one rerun of a failed pregate case at the same tree (CREW rule 16). One per branch.
|
||||
* - stamp-only-carry: a refused receipt carry whose changes since the receipt head are version stamps only.
|
||||
* - autoplan-regate: a later autoplan gate revision whose plan-file edit only adds ELI5 lines that name no
|
||||
* number, spend, cap, arm or verdict (lib/autoplan-carry.ts asks notEli5Only before it carries).
|
||||
*
|
||||
@@ -30,9 +29,7 @@ export interface FileDiff { path: string; pairs: Array<[string, string]>; added:
|
||||
/** A number that is a timeout's value: after a timeout key (`timeout: 5`, `timeoutMs = 5`, `setDefaultTimeout(5)`, `--timeout=5`) or bun's and jest's trailing per-test argument (`}, 30_000);`). */
|
||||
const TIMEOUT_VALUE = /(\b[a-z]*timeout\w*\s*(?::|=|\()\s*|--timeout[= ]|\}\s*,\s*)(\d[\d_]*)/gi;
|
||||
const ASSERTION = /\b(?:expect|assert\w*)\b|\s[<>]=?\s/;
|
||||
const VERSION = /\d+\.\d+\.\d+(?:\.\d+)?/g;
|
||||
const TEST_PATH = /(?:^|\/)(?:test|tests|__tests__|spec)\/|\.(?:test|spec)\.[cm]?[jt]sx?$/;
|
||||
const STAMP_PATHS = ['VERSION', 'package.json', 'CHANGELOG.md', 'agents-digest/gstack-AGENTS.md'];
|
||||
/** Words that mean spend, a cap, an eval arm, a model or a verdict: an ELI5 addition naming one goes to the owner. */
|
||||
const REGATE_WORDS = /\$|\b(?:spend|spending|spent|costs?|budgets?|prices?|caps?|capped|credits?|limits?|max|maximum|arms?|models?|judges?|verdicts?|thresholds?|bars?|pass(?:es)? at|trials?|samples?|stop rules?|kill rules?|paid|evals?|opus|sonnet|haiku|gpt[\w.-]*|gemini|claude)\b|\bn\s*=/i;
|
||||
|
||||
@@ -92,19 +89,6 @@ export function notDocsOnly(paths: string[], root: string): string | null {
|
||||
return code.length ? `not docs: ${code.slice(0, 3).join(', ')}` : null;
|
||||
}
|
||||
|
||||
/** Why the diff is not a version stamp, or null: only stamp files change, and in VERSION or package.json only a version string moves. */
|
||||
export function notStampOnly(files: FileDiff[]): string | null {
|
||||
if (!files.length) return 'nothing changed since the receipt head';
|
||||
for (const f of files) {
|
||||
if (!STAMP_PATHS.includes(f.path) && !/^changelog\.d\/[^/]+\.md$/.test(f.path)) return `${f.path} is not a stamp file`;
|
||||
if (f.path !== 'VERSION' && f.path !== 'package.json') continue;
|
||||
if (f.whole || f.added.length || f.removed.length) return `${f.path} adds or removes lines`;
|
||||
const bad = f.pairs.find(([was, now]) => was.replace(VERSION, 'V') !== now.replace(VERSION, 'V') || (f.path === 'package.json' && !/^\s*"version"\s*:/.test(now)));
|
||||
if (bad) return `${f.path} changes more than the version: ${bad[1].trim().slice(0, 80)}`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const HEADING = /^#{1,6}\s+(.*)$/;
|
||||
const ELI5 = /^eli5\b/i;
|
||||
|
||||
@@ -135,7 +119,7 @@ export interface NoStopInput { cls: string; reason: string; evidence: string; pr
|
||||
|
||||
/** The verdict for one stop: the record to add, or why it still stops. */
|
||||
export function checkNoStop(i: NoStopInput): NoStopVerdict {
|
||||
if (!(NO_STOP_CLASSES as readonly string[]).includes(i.cls)) return { ok: false, reason: `${i.cls} is not one of the five no-stop classes (${NO_STOP_CLASSES.join(', ')})` };
|
||||
if (!(NO_STOP_CLASSES as readonly string[]).includes(i.cls)) return { ok: false, reason: `${i.cls} is not one of the four no-stop classes (${NO_STOP_CLASSES.join(', ')})` };
|
||||
const cls = i.cls as NoStopClass;
|
||||
if (!i.reason.trim() || !i.evidence.trim()) return { ok: false, reason: 'a no-stop record needs a reason and evidence that resolves (run id, commit or file)' };
|
||||
const record = { class: cls, reason: i.reason.trim(), evidence: i.evidence.trim() };
|
||||
@@ -144,10 +128,6 @@ export function checkNoStop(i: NoStopInput): NoStopVerdict {
|
||||
if (cls === 'autoplan-regate') return { ok: false, reason: 'gstack-autoplan decides re-gates at the gate (lib/autoplan-carry.ts), never by hand' };
|
||||
const files = parseDiff(i.diff ?? '');
|
||||
const where = files.map(f => f.path).join(', ');
|
||||
if (cls === 'stamp-only-carry') {
|
||||
const why = notStampOnly(files);
|
||||
return why ? { ok: false, reason: why } : { ok: true, record, detail: `version stamp only in ${where}` };
|
||||
}
|
||||
const timeout = notTimeoutOnly(files);
|
||||
if (cls === 'test-timeout-fix') {
|
||||
const outside = files.filter(f => !TEST_PATH.test(f.path)).map(f => f.path);
|
||||
|
||||
+1
-1
@@ -437,7 +437,7 @@ 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, a round grant, or park), 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, or park; a round grant recorded after this read-only review does not buy a fix round), not an owner ask` };
|
||||
}
|
||||
if (!prior || (n.step !== 'full' && n.step !== 'scoped')) return n;
|
||||
const used = prior + h.fullPasses;
|
||||
|
||||
+6
-22
@@ -9,10 +9,10 @@
|
||||
* base merge only shifted line numbers; patch-ids ignore positions, so a block moved to an identical
|
||||
* context elsewhere is changed);
|
||||
* - context: the +/- lines match hunk for hunk, and each hunk sits where the base's own
|
||||
* change (reviewedBase -> currentBase) puts it, so only context lines the base edited differ;
|
||||
* or a hunk's added lines match byte for byte and its removed lines are the base's own edit of
|
||||
* the lines the reviewed hunk replaced (founderstar#563: the base took SAVE_VERSION 83 under the
|
||||
* branch's 84, GST-1561), which the scoped review reads too.
|
||||
* change (reviewedBase -> currentBase) puts it, so only context lines the base edited differ.
|
||||
* A hunk whose added lines match but whose removed lines changed with the base (founderstar#563:
|
||||
* the base took SAVE_VERSION 83 under the branch's 84, GST-1561) is changed: the PR's own added
|
||||
* and removed lines must both be the reviewed bytes for a head to count as reviewed (GST-2673).
|
||||
* The merge may still have spliced the two (a JSON entry where the branch changed one key and
|
||||
* the base the next), so a context path needs a scoped review of its hunks, never a silent pass;
|
||||
* - changed: anything else, including the same lines moved to another place, a file-mode change, and any path whose
|
||||
@@ -127,24 +127,8 @@ export function comparePath(repoRoot: string, s: PatchSides, rel: string): PathV
|
||||
const b0 = zeroHunks(pathDiff(repoRoot, s.reviewedBase, s.currentBase, rel, 0) ?? '');
|
||||
if (!r0?.length || !c0 || !b0 || r0.length !== c0.length) return 'changed';
|
||||
const map = mapper(b0);
|
||||
if (!r0.every((h, i) => h.body === c0[i]!.body ? sameSpot(h, c0[i]!, map) : baseEditOnly(h, c0[i]!, map, b0))) return 'changed';
|
||||
return ids[0] === ids[1] && r0.every((h, i) => h.body === c0[i]!.body) ? 'same' : 'context';
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a hunk whose body changed since review differs only by the base's edit of the lines it replaces: the added
|
||||
* lines are the reviewed ones byte for byte, and the lines just outside the reviewed hunk's removed range are lines the
|
||||
* base kept, landing just outside the current hunk's range, so the current removed lines are the base's version of the
|
||||
* reviewed ones. A hunk that now removes another line, or adds anything else, is not, and neither is one whose range
|
||||
* holds a line the base added before, inside or after the reviewed lines (a base hunk there that adds more lines than
|
||||
* it removes): dropping it deletes base code rather than taking the base's edit.
|
||||
*/
|
||||
function baseEditOnly(r: ZeroHunk, c: ZeroHunk, map: (line: number) => number | null, base: ZeroHunk[]): boolean {
|
||||
const added = (h: ZeroHunk) => h.body.split('\n').filter((l, i, all) => l.startsWith('+') || (l.startsWith('\\') && all[i - 1]?.startsWith('+'))).join('\n');
|
||||
const start = (h: ZeroHunk) => (h.oldCount > 0 ? h.oldStart : h.oldStart + 1);
|
||||
const end = start(r) + r.oldCount;
|
||||
if (base.some(b => b.newCount > b.oldCount && b.oldStart >= start(r) - 1 && b.oldStart < end)) return false;
|
||||
return r.oldCount > 0 && added(r) === added(c) && map(start(r) - 1) === start(c) - 1 && map(end) === start(c) + c.oldCount;
|
||||
if (!r0.every((h, i) => h.body === c0[i]!.body && sameSpot(h, c0[i]!, map))) return 'changed';
|
||||
return ids[0] === ids[1] ? 'same' : 'context';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -114,6 +114,7 @@ export function bindReceipt(body: string, pr: string | undefined, accepted: read
|
||||
const [was, want] = [oneLine(r.base).slice(0, 120), branch(opts.base)];
|
||||
return { ok: false, code: 'QUEUE_RECEIPT_BASE_MISMATCH', message: `${subject} ship receipt was reviewed against ${was}, not ${want}, so it covers only the change since ${was}; land the parent (${was}) first, merge ${want} into this branch and push, then gstack-ship-receipt carry --pr ${pr ?? '<n>'} --base ${want} moves the receipt to ${want}`, line };
|
||||
}
|
||||
if (recheckCarried(r)) return { ok: false, code: 'QUEUE_RECEIPT_STALE', message: `${subject} ship receipt reached ${oneLine(r.head.slice(0, 12))} through a scoped re-check (carry: ${oneLine(r.carry!.reason).slice(0, 160)}), which is advice only, so the product code it covered never got a full review; run /ship on that head for its full review (GST-2673, docs/review-policy.md#rounds-per-pull-request)`, line };
|
||||
if (r.base_red && !opts.conditional) return { ok: false, code: 'QUEUE_RECEIPT_CONDITIONAL', message: `${subject} ship receipt is paused on a red base (${oneLine(r.base_red.cases.join(', ')).slice(0, 160)} fail at ${oneLine(r.base_red.base.slice(0, 12))}); /ship --resume rewrites it once the base passes them`, line };
|
||||
return { ok: true, receipt: r, head, line };
|
||||
}
|
||||
@@ -136,6 +137,8 @@ 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 []; } }) : [];
|
||||
}
|
||||
/** Whether any hop of the receipt's carry was a scoped re-check: gstack before GST-2673 let one carry a receipt across a product change, so the code it covered never got a full review, and no later carry or land takes that receipt (GST-2706). */
|
||||
export const recheckCarried = (r: ShipReceipt): boolean => !!r.carry?.reason.split(' + ').some(hop => hop.includes('scoped re-check by '));
|
||||
export function receiptRun(r: ShipReceipt): ReceiptRun {
|
||||
const { head, version, gstack_version, run, review_loop, review_loop_exception } = r;
|
||||
const hop = r.carry ? r.carry.reason.split(' + ').pop()! : undefined;
|
||||
|
||||
@@ -216,7 +216,7 @@ remote gate (`gstack-pregate --allow-repo-commands`: stage 1 regen, secrets, str
|
||||
stage 2 the selected lanes under pipefail), then the lanes inside the evidence ledger, and prints `PREGATE:`, `LANES:` and
|
||||
one `LANE: <label> <state> exit= tests_ran= log=` line each.
|
||||
`fail` or `incomplete` blocks: fix, rerun. **No-stop** (docs/review-policy.md#no-stop): a pregate flake rerun (one per branch), a
|
||||
timeout-only fix and three other routine stops go through `gstack-no-stop record` (`--help`); `recorded` goes on,
|
||||
timeout-only fix and two other routine stops go through `gstack-no-stop record` (`--help`); `recorded` goes on,
|
||||
`refused` stops. `requires-remote` (other platforms; the remote gate under 8 cores) needs
|
||||
`gstack-pregate clear` or, under a user cap, `--remote --spend-cap <usd>`. Rerun
|
||||
after the final stamp (`gstack-ship-release finish` does); Step 18 refuses a stale one.
|
||||
|
||||
@@ -12,7 +12,7 @@ remote gate (`gstack-pregate --allow-repo-commands`: stage 1 regen, secrets, str
|
||||
stage 2 the selected lanes under pipefail), then the lanes inside the evidence ledger, and prints `PREGATE:`, `LANES:` and
|
||||
one `LANE: <label> <state> exit= tests_ran= log=` line each.
|
||||
`fail` or `incomplete` blocks: fix, rerun. **No-stop** (docs/review-policy.md#no-stop): a pregate flake rerun (one per branch), a
|
||||
timeout-only fix and three other routine stops go through `gstack-no-stop record` (`--help`); `recorded` goes on,
|
||||
timeout-only fix and two other routine stops go through `gstack-no-stop record` (`--help`); `recorded` goes on,
|
||||
`refused` stops. `requires-remote` (other platforms; the remote gate under 8 cores) needs
|
||||
`gstack-pregate clear` or, under a user cap, `--remote --spend-cap <usd>`. Rerun
|
||||
after the final stamp (`gstack-ship-release finish` does); Step 18 refuses a stale one.
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"sha":"554bb5187acbe3eee749d765fd6abf3ee6122a542530bfedc3450504f7a0cd49","replay":"GST-2673"}
|
||||
{"sha":"d29ea5d198f045f18fb77af4c57c2a6a433c6b5ed970314095f2e9e66acd87ce","replay":"GST-2706"}
|
||||
@@ -0,0 +1 @@
|
||||
{"replay":"GST-2706","justification":"GST-2706 (F1+G1 follow-up to #4360): lib/review-depth.ts is the GST-2673 bytes with one string changed, the read-only PR_ROUND_CAP stop's offer, which no longer lists a round grant because a grant recorded after the read-only review can't buy a fix round. Deterministic no-loss replay, no paid run: old (count-review-rounds-per-pr 2f6c371) against new nextStep over 23,887,872 History x depth cases (fullPasses 0-3, every last step, finding, gate, range, depth, grant, lean, fix-check, prior-full 0-4 and round-grant combination): every step is identical (step-sequence sha256 81b1ee0f0983a6a87153befeeb718a5ea328c536fd7463610a2fc386c92f3013 on both), 19,453,312 reasons are byte-identical, and the other 4,434,560 differ only by that one clause, inside the stop or the voices step that quotes it. No reader, depth, dispatch, brief, checklist or finding rule changes."}
|
||||
@@ -861,15 +861,28 @@ describe("gstack-post keeps the Agent notes section last", () => {
|
||||
const RECEIPT = (head: string) => "```gstack-ship-receipt\n{\n \"head\": \"" + head + "\"\n}\n```\n";
|
||||
const NOTES = (content: string) => "<!-- gstack:agent-notes -->\n<details><summary>Agent notes</summary>\n\n" + content + "\n\n</details>\n";
|
||||
const composed = (head: string, summary: string) => "Opening sentence.\n\n## Summary\n\n" + summary + "\n\n## Test plan\n\n- [x] bun test\n\n" + NOTES("Plan: exempt: docs-only\n\n" + RECEIPT(head).trim());
|
||||
/** The run history a /ship body post keeps right after its receipt: the replaced receipt joins the runs block (GST-2706). */
|
||||
const RUNS_AAAA = "\n```gstack-receipt-runs\n" + JSON.stringify({ head: "aaaa" }) + "\n```\n";
|
||||
|
||||
// Value: protects=the body /ship composes since GST-1825 (opening, sections, Agent notes last) reposts byte for byte and replaces the notes as one
|
||||
// section; fails_when=the receipt inside the notes is split out as its own section, or the notes stop being last; why_new=the notes section is new;
|
||||
// seam=none (mergeBodySections); no_claim=the gh round trip
|
||||
test("a full post whose notes section is last reposts byte for byte and replaces the notes, receipt included, as one section", () => {
|
||||
const first = mergeBodySections(composed("aaaa", "old"), composed("bbbb", "new"));
|
||||
expect(first.body).toBe(composed("bbbb", "new"));
|
||||
expect(first.body.replace(RUNS_AAAA, "")).toBe(composed("bbbb", "new"));
|
||||
expect(receiptRuns(first.body).map(r => r.head)).toEqual(["aaaa"]);
|
||||
expect([first.replaced, first.kept, first.added, first.dropped]).toEqual([["leading text", "Summary", "Test plan", "Agent notes"], [], [], []]);
|
||||
expect(mergeBodySections(first.body, composed("bbbb", "new")).body).toBe(composed("bbbb", "new"));
|
||||
expect(mergeBodySections(first.body, composed("bbbb", "new")).body).toBe(first.body);
|
||||
});
|
||||
|
||||
// Value: protects=the kept run history lands in the Agent notes the receipt is read from, and the readable part keeps its bytes;
|
||||
// fails_when=keepRuns searches the whole body and splices the runs block into a receipt fence the Summary quotes; why_new=keepRuns is new
|
||||
// (GST-2706); seam=none (mergeBodySections); no_claim=the gh round trip
|
||||
test("a /ship body post keeps the runs block in Agent notes when the readable part quotes a receipt fence", () => {
|
||||
const ex = "~~~\n" + RECEIPT("example").trim() + "\n~~~";
|
||||
const first = mergeBodySections(composed("aaaa", ex), composed("bbbb", ex));
|
||||
expect(receiptRuns(first.body).map(r => r.head)).toEqual(["aaaa"]);
|
||||
expect(first.body.replace(RUNS_AAAA, "")).toBe(composed("bbbb", ex));
|
||||
});
|
||||
|
||||
// Value: protects=a partial post keeps the current notes and they stay last, above a Capy badge that ends the body; fails_when=a new section is
|
||||
@@ -917,7 +930,8 @@ describe("gstack-post keeps the Agent notes section last", () => {
|
||||
const partial = mergeBodySections(legacy, "## Summary\n\nnew\n");
|
||||
expect(partial.body).toBe(RECEIPT("aaaa") + "\n## Summary\n\nnew\n\n## Approvals\n\nPlan: exempt: docs-only\n");
|
||||
const full = mergeBodySections(legacy, composed("bbbb", "new"));
|
||||
expect(full.body).toBe("Opening sentence.\n\n## Summary\n\nnew\n\n## Approvals\n\nPlan: exempt: docs-only\n\n## Test plan\n\n- [x] bun test\n\n" + NOTES("Plan: exempt: docs-only\n\n" + RECEIPT("bbbb").trim()));
|
||||
expect(receiptRuns(full.body).map(r => r.head)).toEqual(["aaaa"]);
|
||||
expect(full.body.replace(RUNS_AAAA, "")).toBe("Opening sentence.\n\n## Summary\n\nnew\n\n## Approvals\n\nPlan: exempt: docs-only\n\n## Test plan\n\n- [x] bun test\n\n" + NOTES("Plan: exempt: docs-only\n\n" + RECEIPT("bbbb").trim()));
|
||||
expect(full.body.match(/```gstack-ship-receipt/g)).toHaveLength(1);
|
||||
expect(full.replaced).toEqual(["ship receipt", "Summary"]);
|
||||
});
|
||||
|
||||
+21
-39
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* The five no-stop defaults (GSTA-258 K1, lib/no-stop.ts, bin/gstack-no-stop): each routine stop that qualifies is
|
||||
* The four no-stop defaults (GSTA-258 K1, lib/no-stop.ts, bin/gstack-no-stop): each routine stop that qualifies is
|
||||
* recorded as {class, reason, evidence} and the run goes on; anything that does not qualify, and any stop outside
|
||||
* the five, still stops for the owner. The autoplan re-gate is covered in test/autoplan-carry.test.ts.
|
||||
* the four, still stops for the owner. The autoplan re-gate is covered in test/autoplan-carry.test.ts.
|
||||
*/
|
||||
import { afterAll, describe, expect, test } from 'bun:test';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
@@ -11,7 +11,7 @@ import * as path from 'node:path';
|
||||
import { bunIsolationArgs } from '../lib/bun-isolation';
|
||||
import { validateReceipt } from '../lib/ship-receipt';
|
||||
import { lineDiff } from '../lib/autoplan-confirm';
|
||||
import { checkNoStop, notEli5Only, notStampOnly, parseDiff, type NoStopRecord } from '../lib/no-stop';
|
||||
import { checkNoStop, notEli5Only, parseDiff, type NoStopRecord } from '../lib/no-stop';
|
||||
|
||||
const ROOT = path.resolve(import.meta.dir, '..');
|
||||
const BIN = path.join(ROOT, 'bin', 'gstack-no-stop');
|
||||
@@ -54,16 +54,13 @@ describe('lib/no-stop: what qualifies', () => {
|
||||
expect(check('pregate-flake-rerun', undefined, [{ class: 'pregate-flake-rerun', reason: 'x', evidence: 'y' }])).toMatchObject({ ok: false });
|
||||
});
|
||||
|
||||
test('stamp-only-carry: a version-only VERSION or package.json move qualifies; a dependency or a product file stops', () => {
|
||||
test('stamp-only-carry is gone (GST-2706): a refused carry already goes on to Steps 2-16, so there is no stop to record past', () => {
|
||||
const stamp = diff('package.json', [' "version": "1.94.41.0",'], [' "version": "1.94.42.0",']) + diff('VERSION', ['1.94.41.0'], ['1.94.42.0']);
|
||||
expect(check('stamp-only-carry', stamp)).toMatchObject({ ok: true, detail: 'version stamp only in package.json, VERSION' });
|
||||
expect(notStampOnly(parseDiff(diff('package.json', [' "zod": "3.0.0",'], [' "zod": "4.0.0",'])))).toContain('changes more than the version');
|
||||
expect(check('stamp-only-carry', diff('package.json', [' "dev": "bun run a",'], [' "dev": "bun run b",']))).toMatchObject({ ok: false, reason: expect.stringContaining('more than the version') });
|
||||
expect(check('stamp-only-carry', stamp + diff('lib/worker.ts', ['a'], ['b']))).toMatchObject({ ok: false, reason: 'lib/worker.ts is not a stamp file' });
|
||||
expect(check('stamp-only-carry', stamp)).toMatchObject({ ok: false, reason: expect.stringContaining('not one of the four no-stop classes') });
|
||||
});
|
||||
|
||||
test('anything outside the five, a missing reason or evidence, or a hand-recorded re-gate still stops', () => {
|
||||
expect(check('merge-anyway')).toMatchObject({ ok: false, reason: expect.stringContaining('not one of the five') });
|
||||
test('anything outside the four, a missing reason or evidence, or a hand-recorded re-gate still stops', () => {
|
||||
expect(check('merge-anyway')).toMatchObject({ ok: false, reason: expect.stringContaining('not one of the four') });
|
||||
expect(checkNoStop({ cls: 'pregate-flake-rerun', reason: ' ', evidence: 'run 1', prior: [] })).toMatchObject({ ok: false });
|
||||
expect(check('autoplan-regate')).toMatchObject({ ok: false, reason: expect.stringContaining('gstack-autoplan decides') });
|
||||
});
|
||||
@@ -153,13 +150,13 @@ describe('gstack-no-stop record: the ledger, the grant and the receipt', () => {
|
||||
expect(r.stderr).toContain('the approval record already holds this branch\'s K1 grant');
|
||||
});
|
||||
|
||||
test('a class outside the five stops, and the range-based classes need --range-base', () => {
|
||||
test('a class outside the four stops, and the range-based classes need --range-base', () => {
|
||||
expect(run('record', '--class', 'merge-anyway', '--reason', 'r', '--evidence', 'e').status).toBe(3);
|
||||
expect(run('record', '--class', 'stamp-only-carry', '--reason', 'r', '--evidence', 'e').status).toBe(2);
|
||||
expect(run('record', '--class', 'test-timeout-fix', '--reason', 'r', '--evidence', 'e').status).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('gstack-no-stop record --class stamp-only-carry --base, and import', () => {
|
||||
describe('gstack-no-stop record after a base merge and a restamp, and import', () => {
|
||||
const work = path.join(tmp, 'stamp');
|
||||
const env = { ...process.env, ...ID, GSTACK_STATE_ROOT: path.join(tmp, 'state2'), GSTACK_APPROVALS_DIR: path.join(tmp, 'approvals2') };
|
||||
const git = (...args: string[]) => {
|
||||
@@ -182,30 +179,11 @@ describe('gstack-no-stop record --class stamp-only-carry --base, and import', ()
|
||||
spawnSync('git', ['merge', '-q', 'main', '-m', 'merge main'], { cwd: work, encoding: 'utf8', timeout: 30_000, env });
|
||||
write('VERSION', '1.0.3.0\n'); git('add', '-A'); git('commit', '-qm', 'merge main + stamp');
|
||||
|
||||
test('a base merge plus a version stamp qualifies against the receipt head merged into the base', () => {
|
||||
const r = run('record', '--class', 'stamp-only-carry', '--range-base', receiptHead, '--base', 'main', '--reason', 'restamp after the base moved', '--evidence', `commit ${git('rev-parse', 'HEAD').slice(0, 12)}`);
|
||||
expect(r.status, r.stderr).toBe(0);
|
||||
expect(r.stdout).toMatch(/^NO_STOP: stamp-only-carry recorded \(version stamp only in VERSION\)$/m);
|
||||
const plain = run('record', '--class', 'stamp-only-carry', '--range-base', receiptHead, '--reason', 'r', '--evidence', 'e');
|
||||
expect(plain.status).toBe(3);
|
||||
expect(plain.stderr).toContain('other.ts is not a stamp file');
|
||||
});
|
||||
|
||||
test('a product edit inside the stamp commit still stops', () => {
|
||||
write('app.ts', 'export const a = 3;\n'); write('VERSION', '1.0.4.0\n'); git('commit', '-qam', 'stamp plus a sneaky edit');
|
||||
const r = run('record', '--class', 'stamp-only-carry', '--range-base', receiptHead, '--base', 'main', '--reason', 'r', '--evidence', 'e');
|
||||
test('a base merge plus a version stamp records nothing: the refused carry runs Steps 2-16 with no stop to skip (GST-2706)', () => {
|
||||
const r = run('record', '--class', 'stamp-only-carry', '--range-base', receiptHead, '--reason', 'restamp after the base moved', '--evidence', `commit ${git('rev-parse', 'HEAD').slice(0, 12)}`);
|
||||
expect(r.status).toBe(3);
|
||||
expect(r.stderr).toContain('app.ts is not a stamp file');
|
||||
});
|
||||
|
||||
test('a rename into changelog.d with an edit is a deletion plus an add, so it still stops', () => {
|
||||
write('notes.md', 'one\ntwo\nthree\nfour\nfive\nsix\n'); git('add', '-A'); git('commit', '-qm', 'notes');
|
||||
const from = git('rev-parse', 'HEAD');
|
||||
fs.mkdirSync(path.join(work, 'changelog.d'), { recursive: true });
|
||||
git('mv', 'notes.md', 'changelog.d/notes.md'); write('changelog.d/notes.md', 'one\ntwo\nthree\nfour\nfive\nseven\n'); git('add', '-A'); git('commit', '-qm', 'move');
|
||||
const r = run('record', '--class', 'stamp-only-carry', '--range-base', from, '--reason', 'r', '--evidence', 'e');
|
||||
expect(r.status).toBe(3);
|
||||
expect(r.stderr).toContain('notes.md is not a stamp file');
|
||||
expect(r.stderr).toContain('stamp-only-carry is not one of the four no-stop classes');
|
||||
expect(JSON.parse(run('list', '--json').stdout).records).toEqual([]);
|
||||
});
|
||||
|
||||
test('import adds an autoplan run\'s re-gate records once and skips every other class', () => {
|
||||
@@ -215,7 +193,7 @@ describe('gstack-no-stop record --class stamp-only-carry --base, and import', ()
|
||||
expect(first).toMatch(/^NO_STOP: imported 1 record\(s\)/m);
|
||||
expect(first).toMatch(/^NO_STOP: skipped 3 record\(s\): import takes only autoplan-regate records/m);
|
||||
expect(run('import', '--from', src).stdout).toMatch(/^NO_STOP: imported 0 record\(s\)/m);
|
||||
expect(JSON.parse(run('list', '--json').stdout).records.map((r: NoStopRecord) => r.class)).toEqual(['stamp-only-carry', 'autoplan-regate']);
|
||||
expect(JSON.parse(run('list', '--json').stdout).records.map((r: NoStopRecord) => r.class)).toEqual(['autoplan-regate']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -223,12 +201,16 @@ describe('the no-stop defaults in the /ship and /autoplan sources', () => {
|
||||
const read = (rel: string) => fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
||||
const ship = read('ship/sections/tests.md.tmpl');
|
||||
const help = spawnSync('bun', [...bunIsolationArgs(), BIN, '--help'], { encoding: 'utf8', timeout: 60_000 }).stdout;
|
||||
test.each(['scoped-fix-check', 'test-timeout-fix', 'pregate-flake-rerun', 'stamp-only-carry', 'autoplan-regate'])('the bin help and the policy say what to do on %s', cls => {
|
||||
test.each(['scoped-fix-check', 'test-timeout-fix', 'pregate-flake-rerun', 'autoplan-regate'])('the bin help and the policy say what to do on %s', cls => {
|
||||
expect(help).toMatch(new RegExp('^ ' + cls + ' +\\S', 'm'));
|
||||
expect(read('docs/review-policy.md')).toContain('| `' + cls + '` |');
|
||||
});
|
||||
test('neither the bin help nor the policy offers stamp-only-carry any more', () => {
|
||||
expect(help).not.toContain('stamp-only-carry');
|
||||
expect(read('docs/review-policy.md')).not.toContain('| `stamp-only-carry` |');
|
||||
});
|
||||
test('a refused case and any other stop still stop; the receipt write carries the ledger', () => {
|
||||
expect(ship).toContain('three other routine stops go through `gstack-no-stop record` (`--help`); `recorded` goes on,\n`refused` stops.');
|
||||
expect(ship).toContain('two other routine stops go through `gstack-no-stop record` (`--help`); `recorded` goes on,\n`refused` stops.');
|
||||
expect(help).toContain('NO_STOP: refused (exit 3): the stop stands. Anything else still stops.');
|
||||
expect(read('ship/sections/pr-body.md.tmpl')).toContain('${NS:+--no-stop "@$NS"}');
|
||||
expect(read('ship/DRIVER.md.tmpl')).toContain('end the run, except `gstack-no-stop`');
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { historyLine, placeRunEntry, prReviewHistory, reviewRoute } from '../lib/pr-review-history';
|
||||
import { mergeBodySections } from '../lib/gstack-post';
|
||||
import { orderReceipt, placeReceipt, receiptRun, receiptRuns } from '../lib/ship-receipt';
|
||||
import type { ShipReceipt } from '../lib/headless-artifacts';
|
||||
|
||||
@@ -72,6 +73,18 @@ describe('prReviewHistory', () => {
|
||||
expect(prReviewHistory(body)).toMatchObject({ stubs: 1, full: 3 });
|
||||
});
|
||||
|
||||
test('a /ship body post keeps the live runs block, so history still counts every run (GST-2706)', () => {
|
||||
let live = placeReceipt('## Summary\nprose\n', receipt(sha('a'), { passes: 1, rounds: 1 }, { run: 'r1' }));
|
||||
live = placeRunEntry(live, { head: sha('b'), run: 'r2', status: 'started', review_loop: loop({ passes: 1, rounds: 1 }) });
|
||||
live = placeRunEntry(live, { head: sha('b'), run: 'r3', status: 'started', review_loop: loop({ passes: 1, rounds: 1 }) });
|
||||
const composed = placeReceipt('## Summary\nnew prose\n', receipt(sha('c'), { passes: 1, rounds: 1 }, { run: 'r2' }));
|
||||
const posted = mergeBodySections(live, composed).body;
|
||||
expect(posted).toContain('new prose');
|
||||
expect(prReviewHistory(posted)).toMatchObject({ full: 3, runs: 2, stubs: 1, last_full: sha('c') });
|
||||
expect(receiptRuns(posted).map(r => r.run)).toEqual(['r3', 'r1']);
|
||||
expect(prReviewHistory(mergeBodySections(posted, composed).body)).toEqual(prReviewHistory(posted));
|
||||
});
|
||||
|
||||
test('a stub lands in a body with no receipt yet, inside the Agent notes section', () => {
|
||||
const body = placeRunEntry('## Summary\nprose\n', { head: sha('a'), run: 'r1', status: 'started', review_loop: loop({ passes: 1, rounds: 1 }) });
|
||||
expect(body.startsWith('## Summary\nprose\n')).toBe(true);
|
||||
|
||||
@@ -61,6 +61,18 @@ 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', () => {
|
||||
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');
|
||||
}
|
||||
});
|
||||
|
||||
test('a round grant buys one more full round at its head, 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') });
|
||||
|
||||
@@ -3,16 +3,17 @@
|
||||
* bounded route. RECEIPT_CARRY_SCOPED_REVIEW opened only when no path changed, and J1's scoped re-check refused whenever
|
||||
* base context moved, so a base merge that bumped a constant the branch also replaces (SAVE_VERSION := 82 became 83 on
|
||||
* the base; the branch's own `:= 84` line is byte-identical) next to a moved base block forced a full /ship every time.
|
||||
* Here: a hunk whose only difference is a base-side removed line takes the scoped review with the context paths (finish
|
||||
* and carry), a changed path plus context paths take one composed re-check packet bound to range_base, past the size cap
|
||||
* it refuses as before, and a branch-side change to an added line still needs review.
|
||||
* Here: a changed path plus context paths take one composed advisory packet bound to range_base, past the size cap it
|
||||
* refuses as before, and a branch-side change to an added line still needs review. GST-2706: a hunk whose removed lines
|
||||
* changed with the base (82 -> 84 reviewed, then the base took 83) is a changed path, not context, so its head gets a full
|
||||
* review: the PR's own added and removed lines must both be the reviewed bytes for carry to keep the receipt.
|
||||
*/
|
||||
import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { EXIT } from '../lib/headless-artifacts';
|
||||
import { comparePath } from '../lib/ship-patch';
|
||||
import { extractReceipt } from '../lib/ship-receipt';
|
||||
import { bindReceipt, extractReceipt } from '../lib/ship-receipt';
|
||||
import { RECHECK_RANGE_DIFF_CAP } from '../crew/lib/ship-recheck';
|
||||
import { lineOf, RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
|
||||
|
||||
@@ -69,10 +70,10 @@ const scopedPacket = (err: string) => /one fix-check reviewer reads (\S+), then
|
||||
const eligible = (err: string) => /^RECHECK: advisory range_diff_lines=(\d+) range_diff_sha256=([0-9a-f]{64}) packet=(\S+);/m.exec(err);
|
||||
const recordAt = (f: ShipFx, name: string, v: object) => { const file = path.join(f.root, name); fs.writeFileSync(file, JSON.stringify(v)); return file; };
|
||||
|
||||
describe('a base-side removed line next to byte-identical added lines (GST-1561 ask 2)', () => {
|
||||
test('comparePath routes it with the context paths; a branch-side added-line change stays changed', () => {
|
||||
describe('a base-side removed line next to byte-identical added lines (GST-1561 ask 2, GST-2706)', () => {
|
||||
test('comparePath calls it changed, since the PR now removes other lines than the reviewed ones; moved context alone stays context', () => {
|
||||
const same = founderstar();
|
||||
expect(comparePath(same.f.work, same.sides, GAME)).toBe('context');
|
||||
expect(comparePath(same.f.work, same.sides, GAME)).toBe('changed');
|
||||
expect(comparePath(same.f.work, same.sides, VESTING)).toBe('context');
|
||||
const moved = founderstar(85);
|
||||
expect(comparePath(moved.f.work, moved.sides, GAME)).toBe('changed');
|
||||
@@ -100,23 +101,18 @@ describe('a base-side removed line next to byte-identical added lines (GST-1561
|
||||
}
|
||||
});
|
||||
|
||||
describe('carry: the founderstar#563 shape takes one scoped reader, then binds', () => {
|
||||
test('one packet holds the constant hunk and the moved context block; a clean record carries', () => {
|
||||
describe('carry: the founderstar#563 shape gets a full review (GST-2706)', () => {
|
||||
test('a removed line the base changed is a product change: no scoped route, and a clean scoped record carries nothing', () => {
|
||||
const { f, head, carry, body } = founderstar();
|
||||
const before = fs.readFileSync(body, 'utf8');
|
||||
const ask = carry();
|
||||
expect([ask.status, ask.stdout.trim().split('\n')[0]], ask.stderr).toEqual([EXIT.refused, 'CARRY: refused (RECEIPT_CARRY_SCOPED_REVIEW)']);
|
||||
const packet = scopedPacket(ask.stderr);
|
||||
expect(packet, ask.stderr).toBeDefined();
|
||||
const text = fs.readFileSync(packet!, 'utf8');
|
||||
for (const s of ['-const SAVE_VERSION := 82', '-const SAVE_VERSION := 83', '+const SAVE_VERSION := 84', 'was_vesting_clear', 'moved by the base']) expect(text).toContain(s);
|
||||
const partial = recordAt(f, 'partial.json', { head, paths: [VESTING], reviewer: READER, verdict: 'clean' });
|
||||
expect(carry(['--scoped-review', partial]).stderr).toContain(`the scoped review does not cover ${GAME}`);
|
||||
const ok = carry(['--scoped-review', recordAt(f, 'scoped.json', { head, paths: [GAME, VESTING], reviewer: READER, verdict: 'clean' })]);
|
||||
expect([ok.status, ok.stderr.slice(0, 600)]).toEqual([EXIT.ok, expect.any(String)]);
|
||||
const carried = extractReceipt(fs.readFileSync(body, 'utf8')).receipt!;
|
||||
expect(carried.head).toBe(head);
|
||||
expect(carried.carry!.reason).toContain(`scoped review by ${READER}`);
|
||||
expect(carried.carry!.reason).toContain(GAME);
|
||||
expect([ask.status, ask.stdout.trim().split('\n')[0]], ask.stderr).toEqual([EXIT.refused, 'CARRY: refused (RECEIPT_CARRY_PRODUCT_CHANGED)']);
|
||||
expect(ask.stderr).toContain(GAME);
|
||||
expect(scopedPacket(ask.stderr)).toBeUndefined();
|
||||
const r = carry(['--scoped-review', recordAt(f, 'scoped.json', { head, paths: [GAME, VESTING], reviewer: READER, verdict: 'clean' })]);
|
||||
expect([r.status, r.stdout.trim().split('\n')[0]]).toEqual([EXIT.refused, 'CARRY: refused (RECEIPT_CARRY_PRODUCT_CHANGED)']);
|
||||
expect(fs.readFileSync(body, 'utf8')).toBe(before);
|
||||
expect(extractReceipt(before).receipt!.head).not.toBe(head);
|
||||
});
|
||||
|
||||
test('a branch-side change to the added line still forces review (never the scoped context route)', () => {
|
||||
@@ -143,7 +139,7 @@ describe('carry: a changed path plus context paths compose into one bounded re-c
|
||||
const m = eligible(ask.stderr);
|
||||
expect(m, ask.stderr).not.toBeNull();
|
||||
const text = fs.readFileSync(m![3]!, 'utf8');
|
||||
for (const s of ['var score0 := 2', 'was_vesting_clear', 'moved by the base', 'const SAVE_VERSION := 83', `range_base ${reviewedBase}`]) expect(text).toContain(s);
|
||||
for (const s of ['var score0 := 2', 'was_vesting_clear', 'moved by the base', `range_base ${reviewedBase}`]) expect(text).toContain(s);
|
||||
const before = fs.readFileSync(body, 'utf8');
|
||||
const record = { from, head, range_base: reviewedBase, range_diff_sha256: m![2], reader: READER, verdict: 'clean' };
|
||||
const r = carry(['--recheck', recordAt(f, 'recheck.json', record)]);
|
||||
@@ -193,3 +189,45 @@ describe('finish: the founderstar#563 shape takes the scoped reader too', () =>
|
||||
expect(ok.stdout).not.toContain('STOP: behavior');
|
||||
});
|
||||
});
|
||||
|
||||
describe('a receipt a scoped re-check carried never carries on or lands (GST-2706)', () => {
|
||||
/** Reviewed at A, carried to B by a test-only change, then (as old gstack's J1 wrote it) relabelled a re-check hop. */
|
||||
const lineage = (recheck: boolean) => {
|
||||
const x = reviewedBranch({ [SCORE]: 'var score := 1\n' }, { [SCORE]: 'var score := 2\n' });
|
||||
x.f.write({ 'test/score.test.ts': 'test("score", () => {});\n' }); x.f.commit('test: score');
|
||||
const b = x.f.git('rev-parse', 'HEAD').stdout.trim();
|
||||
const hop = x.carry();
|
||||
expect([hop.status, hop.stderr.slice(0, 400)]).toEqual([EXIT.ok, expect.any(String)]);
|
||||
const text = fs.readFileSync(x.body, 'utf8');
|
||||
expect(extractReceipt(text).receipt!.carry!.reason).toBe('test-only change');
|
||||
if (recheck) fs.writeFileSync(x.body, text.replace(/("reason":\s*)"test-only change"/, `$1"scoped re-check by ${READER} (range-diff 12 lines)"`));
|
||||
expect(extractReceipt(fs.readFileSync(x.body, 'utf8')).receipt!.carry!.reason.startsWith('scoped re-check by ')).toBe(recheck);
|
||||
return { ...x, b };
|
||||
};
|
||||
|
||||
test('carry refuses it at its own head and after a base merge, and the receipt stays put; an ordinary carry lineage still carries', () => {
|
||||
for (const recheck of [true, false]) {
|
||||
const { f, b, body, carry } = lineage(recheck);
|
||||
const at = carry();
|
||||
expect(at.stdout.trim().split('\n')[0]).toBe(recheck ? 'CARRY: refused (RECEIPT_CARRY_REFUSED)' : `CARRY: current (the receipt already names ${b.slice(0, 12)})`);
|
||||
f.advanceBase({ 'README.md': '# Fx moved\n' });
|
||||
mergeMain(f, {});
|
||||
const before = fs.readFileSync(body, 'utf8');
|
||||
const r = carry();
|
||||
if (!recheck) { expect([r.status, r.stderr.slice(0, 400)]).toEqual([EXIT.ok, expect.any(String)]); continue; }
|
||||
expect([r.status, r.stdout.trim().split('\n')[0]]).toEqual([EXIT.refused, 'CARRY: refused (RECEIPT_CARRY_REFUSED)']);
|
||||
expect(r.stderr).toContain('through a scoped re-check');
|
||||
expect(r.stderr).toContain('never got a full review');
|
||||
expect(fs.readFileSync(body, 'utf8')).toBe(before);
|
||||
}
|
||||
});
|
||||
|
||||
test('the queue refuses to bind it at its head, so READY and land need a fresh full review', () => {
|
||||
for (const recheck of [true, false]) {
|
||||
const { b, body } = lineage(recheck);
|
||||
const bound = bindReceipt(fs.readFileSync(body, 'utf8'), '5', [b]);
|
||||
if (!recheck) { expect(bound.ok).toBe(true); continue; }
|
||||
expect(bound).toMatchObject({ ok: false, code: 'QUEUE_RECEIPT_STALE', message: expect.stringContaining('through a scoped re-check') });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,10 @@
|
||||
*/
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { extractReceipt, orderReceipt, placeReceipt, readyTailLines, receiptRuns, RECEIPT_RUNS_KEPT, validateReceipt } from '../lib/ship-receipt';
|
||||
import type { ShipReceipt } from '../lib/headless-artifacts';
|
||||
import { EXIT, type ShipReceipt } from '../lib/headless-artifacts';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { cleanup, makeFixtureRepo, runBin } from './helpers/pregate-fixture';
|
||||
|
||||
const receipt = (head: string, loop: Partial<NonNullable<ShipReceipt['review_loop']>> = {}): ShipReceipt =>
|
||||
orderReceipt({ schema_version: 1, head, base: 'main', version: '1.94.1.0', review_loop: { passes: 1, blocking_found: 0, deferred: 0, ...loop } });
|
||||
@@ -68,4 +71,24 @@ describe('no_stop receipt field (K1)', () => {
|
||||
expect(validateReceipt({ ...ok, no_stop: [{ class: 'merge-anyway', reason: 'x', evidence: 'y' }] } as any).length).toBeGreaterThan(0);
|
||||
expect(validateReceipt({ ...ok, no_stop: [{ class: 'stamp-only-carry', reason: 'x' }] } as any).length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('stamp-only-carry is no class any more (GST-2706), so a receipt that records one is invalid and its PR runs /ship again', () => {
|
||||
const ok = orderReceipt({ ...receipt('e'.repeat(40)), no_stop: [{ class: 'pregate-flake-rerun', reason: 'r', evidence: 'run 1' }] });
|
||||
expect(validateReceipt({ ...ok, no_stop: [{ class: 'stamp-only-carry', reason: 'restamp', evidence: 'commit abc' }] } as any)).not.toEqual([]);
|
||||
});
|
||||
|
||||
// Value: protects=a branch whose ledger an older gstack wrote with stamp-only-carry can still write a receipt (p3/outside-voice#1);
|
||||
// fails_when=write passes the retired row through and the receipt is RECEIPT_INVALID on every /ship; why_new=the class was removed here;
|
||||
// seam=none (the real bin on a fixture repo); no_claim=the gh round trip
|
||||
test('write drops a retired ledger row from --no-stop, names it on stderr and keeps the current ones', () => {
|
||||
const repo = makeFixtureRepo();
|
||||
try {
|
||||
const ledger = path.join(repo.root, 'no-stop.json');
|
||||
fs.writeFileSync(ledger, JSON.stringify([{ class: 'stamp-only-carry', reason: 'restamp', evidence: 'commit abc' }, { class: 'pregate-flake-rerun', reason: 'r', evidence: 'run 1' }]));
|
||||
const body = path.join(repo.root, 'body.md');
|
||||
const w = runBin(repo, 'gstack-ship-receipt', ['write', '--pr', '9', '--base', 'main', '--version', '1.0.0', '--session-kind', 'unattended', '--no-stop', `@${ledger}`, '--body', body]);
|
||||
expect([w.status, w.err], w.out).toEqual([EXIT.ok, expect.stringContaining('NO_STOP: dropped "stamp-only-carry"')]);
|
||||
expect(extractReceipt(fs.readFileSync(body, 'utf8')).receipt!.no_stop).toEqual([{ class: 'pregate-flake-rerun', reason: 'r', evidence: 'run 1' }]);
|
||||
} finally { cleanup(repo); }
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"bytes": -2,
|
||||
"why": "GST-2706: one no-stop class fewer in Step 5's no-stop line"
|
||||
}
|
||||
Reference in new issue
Block a user