mirror of
https://github.com/garrytan/gstack.git
synced 2026-12-01 12:25:53 +01:00
/gstack-ship drops bought extra review rounds and the second-model trail check (GST-3829) (#4826)
/gstack-ship no longer lets anyone buy an extra review round or a narrow re-check. After two review rounds, a blocking finding ships only as an owner's recorded ruling, or the PR waits. Why: these paths were switched off last release and kept breaking; four PRs in one day tried to repair them. This is part 4 of the approved /gstack-ship simplification. Nothing to do: each removed flag now refuses with a message that names what replaced it. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=security Review-Finding: p2/outside-voice#3 reader=outside-voice Review-Finding: p2/adversarial-native#1 reader=adversarial-native Review-Finding: p2/adversarial-native#3 reader=adversarial-native Review-Finding: p2/adversarial-native#6 reader=adversarial-native
This commit is contained in:
1 parent
e11a5833bc
commit
ec5d7e6fbd
106 files changed
+933
-5019
No files matched your search
+8
-51
@@ -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 {
|
||||
|
||||
+9
-57
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
+23
-114
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
+37
-110
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user