From a65404886b02987ee1b22df430f06efc41fab109 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 18:56:02 -0800 Subject: [PATCH 1/6] v1.93.38.0 fix(review): one record per native finding at its stated severity; blocker count keys on Blocks; fix-check is never a pass (GST-1031) (#3894) * fix(review): one record per native finding at its stated severity; blocker count keys on Blocks; fix-check start; harness re-pin is metadata (GST-1031) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review): summary candidates need a denied or fixed label; only a Blocks: field lowers the count (GST-1031 review pass 1) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review): JSON findings state no Blocks field; the code-class FIXABLE check takes only a Blocks: field (GST-1031 review pass 2) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review): a Blocks yes in any form vetoes unblocking; summary candidates need a closing noun and cover label lists (GST-1031 Step 11) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * revert(review): keep the pinned adversarial brief files at their no-loss bytes (GST-1031) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 4 + VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- bin/gstack-review-dispatch | 4 +- docs/review-policy.md | 27 ++-- lib/capy-review-pass.js | 5 +- lib/review-ledger.ts | 69 ++++++--- lib/review-scope.ts | 14 +- lib/ship-release.ts | 16 +- package.json | 2 +- .../review-ledger/gst-1031-fix-check.txt | 6 + .../review-ledger/gst-1031-native.txt | 34 ++++ test/prose-voice-floor.test.ts | 8 +- test/review-dispatch.test.ts | 14 +- test/review-fixable-class.test.ts | 8 +- test/review-gst1031.test.ts | 145 ++++++++++++++++++ test/review-ledger-invariant.test.ts | 5 +- test/review-pass.test.ts | 15 ++ test/ship-release.test.ts | 23 +++ 19 files changed, 347 insertions(+), 56 deletions(-) create mode 100644 test/fixtures/review-ledger/gst-1031-fix-check.txt create mode 100644 test/fixtures/review-ledger/gst-1031-native.txt create mode 100644 test/review-gst1031.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index dae015abc..0740836fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [1.93.38.0] - 2026-11-03 + +- **Review collector and blocker count follow what the reader said (GST-1031).** A native adversarial finding that states `Blocks: no` and one Severity now collects once, at that severity, on every review class; a numbered finding heading keeps its body (located or numbered bullets, a bold subheading, a located paragraph) so its Severity line no longer splits off as a second CRITICAL record. A closing summary such as "so nothing is CRITICAL" is marked `summary_candidate`, and lead judgment may lower it with a reason that `judge` records as `dismissed`. A CRITICAL whose reader writes the field `Blocks: no` no longer counts as a blocker in `REVIEW_LOOP`'s ledger count (classify does the same for a finding that carries `stated`; Step 9.4 does not copy it yet). Decision 3.5's fix-check pass takes a `review-fix-check` start token even when given `logStart: ["review"]`, so it is never counted as a pass. `gstack-ship-release finish` routes a `scripts/harness-version.json` edit that only records non-behavioral pins at the same version as release metadata. + ## [1.93.37.0] - 2026-11-03 **Eval planning prices Claude Haiku 5.5, GPT-6 Luna and Gemini 4 Argon, and the Codex docs name the current OpenAI tiers (#3640, #2943).** Before, `gstack-eval-plan arms --arms claude-haiku-5-5` stopped with EVAL_PRICE_MISSING because `lib/pricing.ts` had no row for it. docs/hosts.md and the /codex example still named gpt-5.6-sol as the current Sol model. diff --git a/VERSION b/VERSION index c6dda2541..499e69b38 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.93.37.0 +1.93.38.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index 75530d6d5..ad4f63936 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.93.37.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.93.38.0 — regenerate/re-copy after upgrading gstack Behavioral rules from gstack (https://github.com/garrytan/gstack), compressed for agent hosts without a full skill install. The full skills add workflows, diff --git a/bin/gstack-review-dispatch b/bin/gstack-review-dispatch index fd121faf1..b5b00be12 100755 --- a/bin/gstack-review-dispatch +++ b/bin/gstack-review-dispatch @@ -414,8 +414,8 @@ function main(): number { const judged = flag('--judged'); if (!merged || !judged) { process.stderr.write('gstack-review-dispatch judge: needs --merged and --judged \n'); return EXIT.usage; } const r = recordJudgment(ledger, readJsonl(merged), readJsonl(judged), judged, merged); - process.stdout.write(r.ok ? `JUDGMENT: ok added=${r.added.length} promoted=${r.promoted.length} folded=${r.folded.length}\n` - : `JUDGMENT_REJECTED: dropped=${JSON.stringify(r.dropped)} downgraded=${JSON.stringify(r.downgraded)} unexplained=${JSON.stringify(r.unexplained)} invalid=${JSON.stringify(r.invalid)} (lead judgment may add or promote a finding, never drop or downgrade one)\n`); + process.stdout.write(r.ok ? `JUDGMENT: ok added=${r.added.length} promoted=${r.promoted.length} folded=${r.folded.length}${r.dismissed.length ? ` dismissed=${r.dismissed.length}` : ''}\n` + : `JUDGMENT_REJECTED: dropped=${JSON.stringify(r.dropped)} downgraded=${JSON.stringify(r.downgraded)} unexplained=${JSON.stringify(r.unexplained)} invalid=${JSON.stringify(r.invalid)} (lead judgment may add or promote a finding, never drop or downgrade one; a summary_candidate line may be lowered with a reason)\n`); return r.ok ? EXIT.ok : EXIT.fail; } if (cmd === 'verify') { diff --git a/docs/review-policy.md b/docs/review-policy.md index b886d927b..89e4681d0 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -601,22 +601,30 @@ ones, and the arm lost blockers. `bin/gstack-review-dispatch` closes both ends: second line for the same field starts another: `Severity` sets its label (a label leading the finding stays its floor), `Blocks: yes` makes it CRITICAL and `Blocks: no` never lowers it; an inline `Blocks: yes` is CRITICAL too, and with no finding above it is one. The native - adversarial voice's FIXABLE collects as CRITICAL (normalizer v2, GSTA-167) unless collect `--manifest` names this - ledger's pass and its plan is the code or docs class with only `runtime=` depth reasons (no `risk:`, `error:`, - `history:` or `floor:` reason). On such a plan a native finding's own `Severity` field decides and FIXABLE beside it - raises nothing once it also states `Blocks: no`; a native FIXABLE finding without `Blocks: no`, with no `Severity` field, - or whose field names only FIXABLE or INVESTIGATE still collects as CRITICAL (GST-987). An unnumbered, unlabeled bullet with no file:line + adversarial voice's FIXABLE collects as CRITICAL (normalizer v2, GSTA-167), except that on every class a native + finding that states `Blocks: no` and one `Severity` field collects at that field (GST-1031 ruling A); a native FIXABLE + finding without `Blocks: no`, with no `Severity` field, or whose field names only FIXABLE or INVESTIGATE still collects + as CRITICAL. On a code or docs plan with only `runtime=` depth reasons (collect `--manifest` naming this ledger's + pass; GST-987) FIXABLE also raises nothing through a label heading or a leading tag. A numbered finding heading keeps + every unlabeled line under it (located or numbered bullets, a bold subheading, a located paragraph) until its + `Severity` or `Blocks` line comes, so those fields never split off as a second record (GST-1031). An unnumbered, unlabeled bullet with no file:line under a paragraph finding whose Severity or Blocks line has not come yet is that finding's detail, so the field line after it lands on the finding; a numbered item is its own finding. A negated severity word still collects at its label ("found nothing CRITICAL", "No P0/P1 issues"), so a reader's - closing summary is a known phantom: it stays at that label in the judged set, lead judgment can fold it only into a - finding at least as severe, and it counts toward what blocks. GST-766 skipped negated labels and lost + closing summary is a known phantom: it collects at that label. When it is a summary candidate (no lead label, no + `Severity` or `Blocks` field, and no file:line or exception clause in any sentence naming a label: "so nothing is + CRITICAL", "the test covers the CRITICAL fix"), collect marks it `summary_candidate` and lead judgment may lower it + with a reason, which judge records as `dismissed` (GST-1031); otherwise lead judgment can fold it only into a finding + at least as severe, and it counts toward what blocks. GST-766 skipped negated labels and lost real blockers named in an exception clause ("No CRITICAL issues except the token leak in log.ts:3"); GSTA-167 reverted that. Each prose finding's line also records the Severity and Blocks its own text states as `stated`, beside the collected label and never in its place; a classified finding that carries `stated` shows it in its deferred-review issue next to the label ("CRITICAL (the reviewer wrote Severity: Low, Blocks: no)"). /ship's Step 9.4 does not copy `stated` into its findings file yet: that - instruction lives in a reviewer brief that changes only after a no-loss replay. What blocks is unchanged. + instruction lives in a reviewer brief that changes only after a no-loss replay. A CRITICAL whose own text writes the + field `Blocks: no` (colon required, and no `Blocks: yes`) is not counted as a blocker by the ledger count, nor by the + review-log count or classify when the finding carries `stated` (GST-1031); lead judgment that raises such a line above + its label counts it again. A phantom finding costs a fold; a lost one costs the gate. A reply with no finding counts as a review only with the clean marker its own brief asks for: `NO FINDINGS` alone on a line for the specialists, the batched specialist, the targeted reader, the Red Team and fix-check, the `Recommendation:` @@ -690,7 +698,8 @@ ones, and the arm lost blockers. `bin/gstack-review-dispatch` closes both ends: working directory) and stops when that is another checkout or cannot be read: run /ship in the thread's own checkout. A start directory outside any checkout, such as a multi-repo workspace root, holds no tree to review by mistake and dispatches. Step 11's voices take the `adversarial-review` start - token by default, and a `logStart` list without it stops before anything runs. + token by default, and a `logStart` list without it stops before anything runs. Decision 3.5's fix-check pass turns a + `review` start into `review-fix-check`, so its row is never a pass (GST-1031). ## Where this is enforced diff --git a/lib/capy-review-pass.js b/lib/capy-review-pass.js index 886976f34..033cce32d 100644 --- a/lib/capy-review-pass.js +++ b/lib/capy-review-pass.js @@ -1,7 +1,7 @@ // gstack /ship review pass program for Capy (lib/capy-review-pass.js, GSTA-167 calls PR 2). // The body of an async function (tools, sleep, now, input), loaded verbatim by the loader in // ship/DRIVER.md from `gstack-review-dispatch program`; never retyped. One call runs one pass (decision 3.5's -// fix-check with its plan's voices included) or Step 11's voices from the manifest `gstack-review-dispatch pass` writes: render, chunked brief transport, `sent`, +// fix-check with its plan's voices included, whose `review` start becomes `review-fix-check`, never a pass: GST-1031) or Step 11's voices from the manifest `gstack-review-dispatch pass` writes: render, chunked brief transport, `sent`, // intent before create, create, poll, collect. It returns 200 s after the loader's first line // (input.startedAt) at most; the next call resumes from the manifest. A failed, stuck or ambiguous // reader, a brief mismatch or a failing bin returns `STOP:` for the parent; nothing is dropped. @@ -145,8 +145,9 @@ try { if (start.exit_code !== 0) return stop('cannot read the directory readers on the shared machine start in: ' + got.slice(-300) + '; no start token was taken and no reader was dispatched'); if (got !== 'NOT_A_CHECKOUT' && got !== want) return stop('readers on the shared machine start in ' + got + ', not in ' + want + ', the checkout this pass ships, and Capy cannot start a subagent in another directory; no start token was taken and no reader was dispatched. Run /ship in ' + got + " (the thread's working directory) on this branch, with a fresh --out"); } + const starts = input.stage !== 'voices' && m.next === 'fix-check' ? logStart.map((s) => (s.split(' ')[0] === 'review' ? 'review-fix-check' + s.slice(6) : s)) : logStart; const seen = {}; - for (const s of logStart) { + for (const s of starts) { const nth = (seen[s] = (seen[s] || 0) + 1); const key = (input.stage === 'voices' ? 'voices:' : 'pass:') + s + (nth > 1 ? '#' + nth : ''); if ((m.log_starts || {})[key]) continue; diff --git a/lib/review-ledger.ts b/lib/review-ledger.ts index dce6fde5d..7ace70d5b 100644 --- a/lib/review-ledger.ts +++ b/lib/review-ledger.ts @@ -59,7 +59,6 @@ const NUMBERED_HEAD = /^(?:#{1,6}\s+|\*\*\s*)\d+[.)]\s/; const stronger = (a: string, b: string) => ((rank(a) ?? 0) >= (rank(b) ?? 0) ? a : b); /** A prose voice's `Blocks: yes` (GSTA-167 normalizer v2): the finding is CRITICAL whatever its label; `Blocks: no` never lowers one. */ const BLOCKS_YES = /(?]\\s+|\\d+[.)]\\s+)?\\**\\s*Sever const FIELD_LABELS = new RegExp(ANY_LABEL.source, 'gi'); const LEAD_LABEL = new RegExp(`^(?:[^\\p{L}\\p{N}\\s]\\s*|\\d+[.)]\\s*)*(?:\\w[\\w./-]*:\\d+(?:[-–:,]\\s*\\d+)*[^\\p{L}\\p{N}\\s]*\\s+(?:[^\\p{L}\\p{N}\\s]\\s*)*)?(${LABELS})(?=[*_\`\\])]|\\s*[:|—–]|\\s+-\\s|\\s*$|(?<=[A-Z]{3})[\\s,(.])`, 'u'); const STATED_BLOCKS = /(? { if (raw.startsWith('{') || BLOCKS_YES.test(raw)) return false; const said = [...raw.matchAll(BLOCKS_FIELD)].map(m => m[1]!.toLowerCase()); return said.length > 0 && !said.includes('yes'); }; +/** + * A summary candidate (GST-1031): a prose finding whose every severity word is denied ("so nothing is CRITICAL", "No CRITICAL issues") + * or names a fix ("the test covers the CRITICAL fix"), with no lead label, no Severity or Blocks field, no FIXABLE or INVESTIGATE tag, + * and no file:line or exception clause in any sentence naming a label. A defect called CRITICAL ("this is CRITICAL") is none. It still collects at its label (a blocker named in another sentence stays on record, GST-435); lead + * judgment may lower it with a reason, which judge records as dismissed. "No CRITICAL issues except the token leak in log.ts:3" is no candidate. + */ +const SENTENCE = /(?<=[.!?])\s+/; +const EXCEPTION = /(? ANY_LABEL.test(t) && !ANY_LABEL.test(t.replace(DENIED_OR_FIXED, ' ')) && !t.startsWith('{') && !t.startsWith('**') && !LIST_ITEM.test(t) && !HEADING.test(t) && !LEAD_LABEL.test(t) + && !t.match(SEVERITY_FIELD) && !t.match(STATED_BLOCKS) && [...t.matchAll(ALL_LABELS)].every(m => !!rank(m[1])) + && t.split(SENTENCE).filter(s => ANY_LABEL.test(s)).every(s => !PATH_LOCUS.test(s) && !EXCEPTION.test(s)); +export function stated(raw: string): Stated | undefined { if (raw.startsWith('{')) return undefined; const severity = [...raw.matchAll(STATED_SEVERITY)].at(-1)?.[1]; - const blocks = [...raw.matchAll(STATED_BLOCKS)].at(-1)?.[1]?.toLowerCase(); + const said = [...raw.matchAll(BLOCKS_FIELD)].map(m => m[1]!.toLowerCase()); + const blocks = said.includes('yes') || (said.length && BLOCKS_YES.test(raw)) ? 'yes' : said.at(-1); return severity || blocks ? { ...(severity ? { severity } : {}), ...(blocks ? { blocks } : {}) } : undefined; } -export interface MergedLine { id: string; reader: string; label: string; stated?: Stated; raw: string; output_sha256: string } +export interface MergedLine { id: string; reader: string; label: string; stated?: Stated; summary_candidate?: true; raw: string; output_sha256: string } /** * One reader's findings as written: a JSON object per line (severity kept as written); else each prose line carrying a severity or @@ -104,8 +121,11 @@ export interface MergedLine { id: string; reader: string; label: string; stated? * starts the next finding, except an unlabeled, unnumbered bullet with no file:line under a paragraph finding whose fields have not * come yet, which is its detail and joins its text (GSTA-196: 4 findings with detail bullets collected as 8). An inline * `Blocks: yes` is CRITICAL too. The native voice's FIXABLE collects as CRITICAL; other labels stay as written for lead judgment. When in doubt the parser merges rather than drops: a lost blocker costs the gate. - * With fixableRaises false (a code or docs review with no risk, error, history or floor reason, GST-987) a native FIXABLE finding that - * states `Blocks: no` collects at its own Severity field; one with no Blocks: no, no Severity field or only a FIXABLE field stays CRITICAL. + * A numbered finding heading keeps every unlabeled line under it, located or listed or bold, until its fields come (GST-1031), so its + * Severity and Blocks never split off as a second record; a prose line that only names a severity in passing is a summary (summaryLine). + * A native FIXABLE finding that states `Blocks: no` and one Severity field collects at that field on every class (GST-1031 ruling A); + * one with no Blocks: no, no Severity field or only a FIXABLE field stays CRITICAL. fixableRaises false (a code or docs review with no + * risk, error, history or floor reason, GST-987) also drops FIXABLE's raise from label headings and leads. */ export function parseFindings(reader: string, output: string, fixableRaises = true): Array<{ label: string; raw: string }> { type Finding = { label: string; raw: string; fields: Set; list: boolean; lead?: string; fixable?: boolean; heading?: boolean }; @@ -155,6 +175,7 @@ export function parseFindings(reader: string, output: string, fixableRaises = tr } const heading = LABEL_HEADING.exec(t); if (heading) { section = fixableRaises ? named(heading[1]!) : heading[1]!; current = null; head = ''; continue; } + if (current?.heading && !current.fields.size && !label && !blocks && !/^#{1,6}\s/.test(t) && !NUMBERED_HEAD.test(t) && !t.startsWith('{')) { current.raw += ` | ${t}`; continue; } if (!indented && HEADING.test(t)) { section = null; current = null; } if (t.startsWith('{')) { try { @@ -188,8 +209,13 @@ export function parseFindings(reader: string, output: string, fixableRaises = tr } if (!fresh && !current && (!LIST_ITEM.test(head) || locus)) head = t; } - const unblocked = (f: Finding) => fixableRaises || role !== 'adversarial-native' || !(f.fixable || f.label.toUpperCase() === 'FIXABLE' || /(? ({ label: unblocked(f) ? f.label : 'CRITICAL', raw: f.raw })); + const unblocked = (f: Finding) => fixableRaises || role !== 'adversarial-native' || !(f.fixable || f.label.toUpperCase() === 'FIXABLE' || /(? { const ls = [...raw.matchAll(SEVERITY_FIELD)].flatMap(m => (m[1] ?? m[2]!).match(FIELD_LABELS)!); return ls.length === 1 && !!rank(ls[0]); }; + return out.map((f, i) => { + const own = relaxed?.length === out.length && relaxed[i]!.raw === f.raw && statesNoBlocks(f.raw) && statesSeverity(f.raw) ? relaxed[i]!.label : undefined; + return { label: own ?? (unblocked(f) ? f.label : 'CRITICAL'), raw: f.raw }; + }); } /** @@ -232,7 +258,7 @@ export function collect(ledger: string, reader: string, output: string, mergedFi const wrongTree = !unavailable && tree !== undefined && !tree.ok; const lines = unavailable || wrongTree ? [] : parseFindings(reader, output, raises).map((f, i) => { const s = stated(f.raw); - return { id: `${reader}#${prior ? `${prior + 1}.` : ''}${i + 1}`, reader, label: f.label, ...(s ? { stated: s } : {}), raw: f.raw, output_sha256: sha }; + return { id: `${reader}#${prior ? `${prior + 1}.` : ''}${i + 1}`, reader, label: f.label, ...(s ? { stated: s } : {}), ...(summaryCandidate(f.raw) ? { summary_candidate: true as const } : {}), raw: f.raw, output_sha256: sha }; }); const review = !unavailable && !wrongTree && (lines.length > 0 || hasCleanMarker(reader, output)); fs.appendFileSync(mergedFile, lines.map(l => JSON.stringify(l) + '\n').join(''), { mode: 0o600 }); @@ -249,13 +275,13 @@ export function readJsonl(file: string): T[] { } export interface JudgedLine { id: string; severity: string; reason?: string; duplicate_of?: string } -export interface Judgment { ok: boolean; dropped: string[]; downgraded: string[]; unexplained: string[]; invalid: string[]; added: string[]; promoted: string[]; folded: string[] } +export interface Judgment { ok: boolean; dropped: string[]; downgraded: string[]; unexplained: string[]; invalid: string[]; added: string[]; promoted: string[]; folded: string[]; dismissed: string[] } -/** The lead-judgment rule: every merged finding survives at its severity or above; additions and promotions carry a reason. */ +/** The lead-judgment rule: every merged finding survives at its severity or above, except a summary candidate lowered with a reason (dismissed); additions and promotions carry a reason. */ export function judge(merged: MergedLine[], judged: JudgedLine[]): Judgment { const byId = new Map(judged.map(j => [j.id, j])); const mergedIds = new Set(merged.map(m => m.id)); - const res: Judgment = { ok: true, dropped: [], downgraded: [], unexplained: [], invalid: [], added: [], promoted: [], folded: [] }; + const res: Judgment = { ok: true, dropped: [], downgraded: [], unexplained: [], invalid: [], added: [], promoted: [], folded: [], dismissed: [] }; for (const j of judged) if (rank(j.severity) === null) res.invalid.push(j.id); for (const m of merged) { const j = byId.get(m.id); @@ -266,7 +292,7 @@ export function judge(merged: MergedLine[], judged: JudgedLine[]): Judgment { const from = rank(m.label) ?? 0; const to = rank(target.severity); if (to === null) continue; - if (to < from) res.downgraded.push(m.id); + if (to < from) (!j.duplicate_of && j.reason?.trim() && summaryCandidate(m.raw) ? res.dismissed : res.downgraded).push(m.id); else if (j.duplicate_of) res.folded.push(m.id); else if (to > from) { res.promoted.push(m.id); if (!j.reason?.trim()) res.unexplained.push(m.id); } } @@ -286,8 +312,9 @@ export function recordJudgment(ledger: string, merged: MergedLine[], judged: Jud if (res.ok) { for (const id of res.added) appendEvent(ledger, { event: 'judgment', kind: 'added', id, to: byId.get(id)!.severity, reason: byId.get(id)!.reason }); for (const id of res.promoted) appendEvent(ledger, { event: 'judgment', kind: 'promoted', id, from: labels.get(id), to: byId.get(id)!.severity, reason: byId.get(id)!.reason }); + for (const id of res.dismissed) appendEvent(ledger, { event: 'judgment', kind: 'dismissed', id, from: labels.get(id), to: byId.get(id)!.severity, reason: byId.get(id)!.reason }); } - appendEvent(ledger, { event: 'judge', ok: res.ok, judged: path.resolve(judgedFile), judged_sha256: promptHash(fs.readFileSync(judgedFile, 'utf8')), merged: path.resolve(mergedFile), merged_ids: merged.map(m => m.id), dropped: res.dropped, downgraded: res.downgraded, unexplained: res.unexplained, invalid: res.invalid, added: res.added.length, promoted: res.promoted.length, folded: res.folded.length }); + appendEvent(ledger, { event: 'judge', ok: res.ok, judged: path.resolve(judgedFile), judged_sha256: promptHash(fs.readFileSync(judgedFile, 'utf8')), merged: path.resolve(mergedFile), merged_ids: merged.map(m => m.id), dropped: res.dropped, downgraded: res.downgraded, unexplained: res.unexplained, invalid: res.invalid, added: res.added.length, promoted: res.promoted.length, folded: res.folded.length, dismissed: res.dismissed.length }); return res; } @@ -307,7 +334,8 @@ const treeHolds = (render: LedgerEvent | undefined, reply: string | undefined) = const realPath = (f: string) => { try { return fs.realpathSync(f); } catch { return path.resolve(f); } }; /** - * The blocking findings a run's ledger holds (GST-951): every collected line whose label ranks CRITICAL, raised to its judged + * The blocking findings a run's ledger holds (GST-951): every collected line whose label ranks CRITICAL and whose reader did not state + * `Blocks: no` (GST-1031: the count keys on Blocks; lead judgment raising such a line above its label counts it), raised to its judged * severity when the newest judge accepted a judged set that is unchanged since; lead judgment's additions count and a folded * duplicate does not. Every reader counts the same way, whatever it is and whether or not Step 9.4 classified its findings. * Each carries its locus (a JSON finding's path:line, else the first path:line its text names, an extensionless bin/ path @@ -331,12 +359,16 @@ export function ledgerBlockers(ledger: string): LedgerBlocker[] { text.split('\n').filter(l => l.trim()).map(l => { try { return JSON.parse(l); } catch { return fail(`${what} has a line that is not JSON`); } }); const events = jsonLines(read(ledger, 'ledger'), 'the ledger') as LedgerEvent[]; const ranks = new Map(); + const unblocking = new Map(); + const raws = new Map(); const loci = new Map(); for (const o of events.filter(e => e.event === 'output' && Array.isArray(e.ids) && e.ids.length)) { const lines = jsonLines(read(o.merged, `merged file of ${String(o.reader)}`), String(o.merged)) as MergedLine[]; for (const id of o.ids as string[]) { const line = lines.find(l => l.id === id) ?? fail(`collected id ${id} is missing from ${String(o.merged)}`); ranks.set(id, rank(line.label) ?? 0); + if (statesNoBlocks(line.raw)) unblocking.set(id, rank(line.label) ?? 0); + raws.set(id, line.raw); loci.set(id, lineLocus(line.raw)); } } @@ -346,11 +378,12 @@ export function ledgerBlockers(ledger: string): LedgerBlocker[] { if (promptHash(text) !== verdict.judged_sha256) fail(`judged set ${String(verdict.judged)} changed since judge`); for (const j of jsonLines(text, String(verdict.judged)) as JudgedLine[]) { if (j.duplicate_of) { ranks.delete(j.id); continue; } - ranks.set(j.id, Math.max(ranks.get(j.id) ?? 0, rank(j.severity) ?? 0)); + const dismissed = !!j.reason?.trim() && summaryCandidate(raws.get(j.id) ?? ''); + ranks.set(j.id, dismissed ? rank(j.severity) ?? 0 : Math.max(ranks.get(j.id) ?? 0, rank(j.severity) ?? 0)); if (!loci.has(j.id)) loci.set(j.id, lineLocus(j.reason ?? '')); } } - return [...ranks].filter(([, r]) => r >= 4).map(([id]) => ({ id, locus: loci.get(id) ?? null })); + return [...ranks].filter(([id, r]) => r >= 4 && !(r <= (unblocking.get(id) ?? -1))).map(([id]) => ({ id, locus: loci.get(id) ?? null })); } /** @@ -480,7 +513,7 @@ export function verify(ledger: string): { rows: VerifyRow[]; clean: boolean; bri const forged = differs.filter(id => judgedIds.has(id)); if (forged.length) notes.push(`merged_line_differs=${JSON.stringify(forged)}`); const status = !v.ok ? 'REJECTED' : notes.length ? 'MISMATCH' : 'OK'; - rows.push({ kind: 'JUDGE', reader: '-', status, detail: `dropped=${JSON.stringify(v.dropped)} downgraded=${JSON.stringify(v.downgraded)} added=${v.added} promoted=${v.promoted} folded=${v.folded}${notes.length ? ' ' + notes.join(' ') : ''}` }); + rows.push({ kind: 'JUDGE', reader: '-', status, detail: `dropped=${JSON.stringify(v.dropped)} downgraded=${JSON.stringify(v.downgraded)} added=${v.added} promoted=${v.promoted} folded=${v.folded}${v.dismissed ? ` dismissed=${v.dismissed}` : ''}${notes.length ? ' ' + notes.join(' ') : ''}` }); } else if (events.some(e => e.event === 'output')) rows.push({ kind: 'JUDGE', reader: '-', status: 'MISSING', detail: 'outputs were collected but no judged set was checked' }); const clean = episodes.length > 0 && rows.every(r => ['MATCH', 'OK', 'VOIDED', 'UNAVAILABLE'].includes(r.status)); return { rows, clean, briefs: episodes.length, voided, unavailable: rows.filter(r => r.kind === 'BRIEF' && r.status === 'UNAVAILABLE').length }; diff --git a/lib/review-scope.ts b/lib/review-scope.ts index 620c3c11a..f40d49884 100644 --- a/lib/review-scope.ts +++ b/lib/review-scope.ts @@ -29,7 +29,7 @@ export const HUNK_CONTEXT_LINES = 3; export interface ScopeFinding { fingerprint?: string; path?: string; line?: number; severity?: string; category?: string; summary?: string; problem?: string; fix?: string; specialist?: string; advisory?: boolean; test_stub?: string; - /** The severity and Blocks the reviewer's own text stated, from its merged.jsonl line (GST-766); shown, never used to classify. */ + /** The severity and Blocks the reviewer's own text stated, from its merged.jsonl line (GST-766); `Blocks: no` keeps a CRITICAL below the floor (GST-1031). */ stated?: { severity?: string; blocks?: string }; /** The changed line that causes a defect reported elsewhere (a broken caller, a consumer of a removed export); the locus follows it. */ cause?: { path?: string; line?: number }; @@ -180,11 +180,13 @@ export function kindOf(finding: ScopeFinding): Kind { /** * The blocking floor: a CRITICAL defect (a test that would fail, a production - * break, a security or data-loss defect). Advisories, test gaps, wording and - * INFORMATIONAL items are below it and never trigger another pass. + * break, a security or data-loss defect) its reviewer did not mark `Blocks: no` + * (GST-1031). Advisories, test gaps, wording and INFORMATIONAL items are below + * it and never trigger another pass. */ +export const statesNoBlock = (f: Record) => String(f.stated?.blocks ?? '').toLowerCase() === 'no'; export function isBlocking(finding: ScopeFinding, kind = kindOf(finding)): boolean { - return kind === 'defect' && String(finding.severity ?? '').toUpperCase() === 'CRITICAL'; + return kind === 'defect' && String(finding.severity ?? '').toUpperCase() === 'CRITICAL' && !statesNoBlock(finding); } export interface ScopeInput { policy: ReviewScopePolicy; pass: number; diffHunks: HunkMap; rangeHunks: HunkMap | null; context?: number } @@ -355,8 +357,8 @@ function rowDispatches(row: Record): Array<{ role: string; bytes: n /** Row actions that record what happened to a finding. */ const DISPOSITIONS = ['fixed', 'auto-fixed', 'deferred', 'noted', 'skipped', 'kept', 'restored', 'open']; -/** A row finding that blocks: classified blocking, or an unclassified CRITICAL defect (logged before Step 9.4's classify). */ -const rowBlocks = (f: Record) => f.blocking === true || (f.blocking === undefined && f.advisory !== true && rank(f.severity) === 4); +/** A row finding that blocks: classified blocking, or an unclassified CRITICAL defect its reviewer did not mark Blocks: no (logged before Step 9.4's classify). */ +const rowBlocks = (f: Record) => f.blocking === true || (f.blocking === undefined && f.advisory !== true && rank(f.severity) === 4 && !statesNoBlock(f)); /** The reviewer behind a row's raised_by or a ledger id: every specialist is one; the lead's additions and unknowns name none. */ function raiserOf(raiser: unknown): string | null { const role = typeof raiser === 'string' ? raiser.split(/[/#]/)[0]!.trim() : ''; diff --git a/lib/ship-release.ts b/lib/ship-release.ts index 02f5218a7..48796e691 100644 --- a/lib/ship-release.ts +++ b/lib/ship-release.ts @@ -160,6 +160,20 @@ function commitRelease(cwd: string, release: string[], trailer: string | undefin return true; } +/** + * A harness pin edit that only records changed harness files as non-behavioral at the same version and patterns (GST-1031): release + * metadata, like a version stamp. A bump, a pattern change or an entry without its reason is behavior. + */ +const HARNESS_PIN = 'scripts/harness-version.json'; +function harnessRepin(cwd: string, from: string, to: string, p: string): boolean { + if (p !== HARNESS_PIN) return false; + const read = (tree: string): any => { const s = git(cwd, ['show', `${tree}:${p}`]); try { return s.status === 0 ? JSON.parse(s.stdout) : null; } catch { return null; } }; + const a = read(from), b = read(to); + if (!a?.files || !b?.files || typeof b.files !== 'object' || a.version !== b.version || JSON.stringify(a.patterns) !== JSON.stringify(b.patterns)) return false; + return Object.entries(b.files as Record).every(([f, e]) => JSON.stringify(a.files[f]) === JSON.stringify(e) + || (e?.since === b.version && typeof e?.nonBehavioral === 'string' && e.nonBehavioral.trim().length >= 10)); +} + /** Step 16 stage 2's route. With --reviewed-base, a path whose branch patch is the reviewed one counts as base (lib/ship-patch.ts). */ type Routed = Record<'behavior' | 'docs' | 'metadata' | 'tests' | 'base' | 'context' | 'accepted', string[]>; function route(cwd: string, base: string, reviewed: string, reviewedBase: string | undefined, release: string[], opts: { docsRechecked: boolean; contextReviewed?: string; loop?: ReviewLoopException }, r: Report): Routed | null { @@ -184,7 +198,7 @@ function route(cwd: string, base: string, reviewed: string, reviewedBase: string const by: Routed = { behavior: [], docs: [], metadata: [], tests: [], base: [], context: [], accepted: [] }; for (const p of [...changedSet].sort()) { const verdict = sides ? (touched.has(p) ? comparePath(cwd, sides, p) : 'same') : 'changed'; - by[verdict === 'same' ? 'base' : release.includes(p) ? 'metadata' : sides && isTestCode(p) ? 'tests' : classifyPath(p, cwd) === 'docs' ? 'docs' : verdict === 'context' ? 'context' : 'behavior'].push(p); + by[verdict === 'same' ? 'base' : release.includes(p) || harnessRepin(cwd, reviewed, now, p) ? 'metadata' : sides && isTestCode(p) ? 'tests' : classifyPath(p, cwd) === 'docs' ? 'docs' : verdict === 'context' ? 'context' : 'behavior'].push(p); } const gated = gateEditedPaths(cwd, reviewed, now, by.tests) ?? new Set(by.tests); by.behavior.push(...by.tests.filter(p => gated.has(p))); diff --git a/package.json b/package.json index 2fe60ead2..9864d54ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.93.37", + "version": "1.93.38", "description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.", "license": "MIT", "type": "module", diff --git a/test/fixtures/review-ledger/gst-1031-fix-check.txt b/test/fixtures/review-ledger/gst-1031-fix-check.txt new file mode 100644 index 000000000..359217b4d --- /dev/null +++ b/test/fixtures/review-ledger/gst-1031-fix-check.txt @@ -0,0 +1,6 @@ +REVIEWED_TREE: 4d6a982968de8e11d2665976fc91587730a4767d /home/user/.capy/work/gst986-wt +{"severity":"INFORMATIONAL","path":"docs/troubleshooting.md","line":3307,"summary":"The RECEIPT_INVALID entry still describes the old AND rule: it says write refuses when the read commit's product patch is not the receipt's AND a later change carries a targeted class. The fixed code at lib/ship-receipt-depth.ts:153 refuses on either one. So a user who hits the refusal after a docs-only or TODOS.md commit (the Step 14 and 14.5 commits) finds no matching cause in this entry. docs/review-policy.md and the changelog fragment were updated; this entry was not."} +{"severity":"INFORMATIONAL","path":"lib/ship-receipt-depth.ts","line":153,"summary":"The fix list calls this main's rule, but it isn't. On origin/main, parseReviewTargeted(value, productPatchId) takes no head and binds any record. So under this change, every money, gate, auth or secret ship whose Step 14 or 14.5 commits after the Step 11 read now stops at Step 19 with RECEIPT_INVALID. That is the same outcome pass 1's Red Team flagged. Step 19's prose (ship/sections/pr-body.md:247, 'fix that input file and rerun') doesn't say to rerun the targeted reader on HEAD; only the tool's own error message does. The guard fails closed, and the code deliberately defers the docs-only case to GST-1031, so this is not data loss. It is a known extra stop in unattended /ship runs."} +{"severity":"INFORMATIONAL","path":"lib/ship-receipt-depth.ts","line":153,"summary":"When the product patches are equal and only classesSince refuses (a test edit after the read that skips a case), the message prints the same patch id twice: 'whose product patch X is not this receipt's X'. This was already true before the fix and the fix kept it. The message misstates the cause; the decision itself is correct."} + +I found nothing at the blocking floor. The OR guard fails closed in the right places: it refuses when the product patch differs, when classesSince returns null (unreadable), and when a class shows up after the read. Its only production caller, bin/gstack-ship-receipt:227, passes the same arguments as before. The test change does replace the old docs-binds assertion with a refusal, but that matches the intended new rule; it doesn't weaken coverage. The new no-money-token regression test covers the CRITICAL fix. I reran the three focused files at this tree: 34 pass, 0 fail, 403 expect() calls. diff --git a/test/fixtures/review-ledger/gst-1031-native.txt b/test/fixtures/review-ledger/gst-1031-native.txt new file mode 100644 index 000000000..3e676510d --- /dev/null +++ b/test/fixtures/review-ledger/gst-1031-native.txt @@ -0,0 +1,34 @@ +I reviewed the range base..HEAD, one commit that changes four files. I read every non-test file in full. + +## Findings + +**1. The family check refuses two models in one call even when no task is judged (check.ts:165-169). FIXABLE.** +The family check runs whether or not the run uses a judge. Elsewhere the judge is used only when `judged` is true. + +Before this commit the call passed. Now every judge stops with E_POLICY: +- the default judge clashes with the second model; +- the other judges clash with the first model. + +So the two models can no longer run in one call, even though the judge would never be called. It fails closed with a clear message, and two calls work around it. +Fix: `else if (judged && sameFamily.length)`, plus a test with an unjudged set. +Severity: Medium. Blocks: no. + +**2. max_price now uses the long-prompt rates for every call, short prompts included (prices.ts:75, set at proxy.ts:513). FIXABLE, with part to INVESTIGATE.** +`routing` sets max_price from the price row alone, whatever the prompt length. + +Today the only endpoints are standard, fast and ultrafast. + +Two more problems: +- The commit assumes the router checks max_price against long-tier rates. +- The new doc comment gives the wrong reason. + +Fix: build max_price per request. +Severity: Low. Blocks: no. + +**3. The docs' third-family judge barely exists (docs/eval.md:125, policy.ts:125-129). INVESTIGATE.** +Only weak judges have price rows, so in practice the remedy is two calls. + +Also, call.ts still picks the default judge by provider, not by family. +Severity: Low. Blocks: no. + +Recommendation: Fix the unconditional family check at check.ts:169, because gating it on `judged` is a one-line change. diff --git a/test/prose-voice-floor.test.ts b/test/prose-voice-floor.test.ts index 0cbe7ad27..10796354e 100644 --- a/test/prose-voice-floor.test.ts +++ b/test/prose-voice-floor.test.ts @@ -50,12 +50,12 @@ describe('normalizer v2 as collected: Blocks: yes is CRITICAL, Blocks: no never // Value: protects=the rule round 5's G1 was scored under, on the path production runs (gstack-review-dispatch collect); // fails_when=Blocks: yes collects below CRITICAL or Blocks: no lowers a label; seam=parseFindings test.each([ - ['FIXABLE: race in a.ts:3\nSeverity: Medium\nBlocks: no', 'CRITICAL'], + ['FIXABLE: race in a.ts:3\nSeverity: Medium\nBlocks: no', 'Medium'], ['INVESTIGATE: odd lock in b.ts:9\nSeverity: Low\nBlocks: yes', 'CRITICAL'], ['INVESTIGATE: odd lock in b.ts:9\nBlocks: no', 'INVESTIGATE'], - ['FIXABLE: race in a.ts:3. Severity: Medium. Blocks: no', 'CRITICAL'], - ['1. FIXABLE: race in a.ts:3 — Severity: Low, Blocks: no', 'CRITICAL'], - ['- FIXABLE: race in a.ts:3\n- Severity: Medium\n- Blocks: no', 'CRITICAL'], + ['FIXABLE: race in a.ts:3. Severity: Medium. Blocks: no', 'Medium'], + ['1. FIXABLE: race in a.ts:3 — Severity: Low, Blocks: no', 'Low'], + ['- FIXABLE: race in a.ts:3\n- Severity: Medium\n- Blocks: no', 'Medium'], ] as const)('native %j -> %s', (output, want) => expect(parseFindings('adversarial-native', output).map(g => g.label)).toEqual([want])); test.each([ ['1. Drops the last row (q.ts:7). Severity: Critical. Blocks: no', 'Critical'], diff --git a/test/review-dispatch.test.ts b/test/review-dispatch.test.ts index e2e9662da..fa5e40f54 100644 --- a/test/review-dispatch.test.ts +++ b/test/review-dispatch.test.ts @@ -440,7 +440,10 @@ describe('gstack-review-dispatch sent, collect, judge and verify: nothing change ['CRITICAL: x.ts:4 drops rows (pass 1 had Severity: Low)', [['CRITICAL', 'CRITICAL: x.ts:4 drops rows (pass 1 had Severity: Low)']]], ])('fix-check shape %j', (output, want) => expect(parseFindings('outside-voice', output).map(f => [f.label, f.raw])).toEqual(want)); test('the native voice\'s FIXABLE collects as CRITICAL under its role with or without a dispatch name', () => { - for (const reader of ['adversarial-native', 'adversarial-native/adversarial']) expect(parseFindings(reader, 'FIXABLE: race in a.ts:3\nSeverity: Medium\nBlocks: no').map(f => f.label)).toEqual(['CRITICAL']); + for (const reader of ['adversarial-native', 'adversarial-native/adversarial']) { + expect(parseFindings(reader, 'FIXABLE: race in a.ts:3\nSeverity: Medium').map(f => f.label)).toEqual(['CRITICAL']); + expect(parseFindings(reader, 'FIXABLE: race in a.ts:3\nSeverity: Medium\nBlocks: no').map(f => f.label)).toEqual(['Medium']); + } expect(parseFindings('outside-voice', 'FIXABLE: race in a.ts:3\nSeverity: Medium').map(f => f.label)).toEqual(['Medium']); }); test('a non-prefix Blocks: yes under a labeled finding raises it to CRITICAL', () => { @@ -529,7 +532,7 @@ describe('gstack-review-dispatch sent, collect, judge and verify: nothing change test('unlabeled detail bullets and the Severity line after them stay on the open paragraph finding', () => { const native = fs.readFileSync(path.join(ROOT, 'test/fixtures/review-ledger/gsta-196-native.txt'), 'utf8'); expect(parseFindings('adversarial-native', native).map(f => [f.label, f.raw.slice(0, 12), f.raw.endsWith('| Severity: ' + (f.label === 'High' ? 'High' : 'Low') + '. Blocks: no.')])) - .toEqual([['High', '**1. A PR in', true], ['CRITICAL', '**2. A case ', true], ['CRITICAL', '**3. Local `', true], ['Low', '**4. No trai', true]]); + .toEqual([['High', '**1. A PR in', true], ['Low', '**2. A case ', true], ['Low', '**3. Local `', true], ['Low', '**4. No trai', true]]); expect(parseFindings('outside-voice', '1. FIXABLE: race in a.ts:3\n- Unlabeled sibling at b.ts:9\nSeverity: Medium').map(f => f.label)).toEqual(['FIXABLE', 'Medium']); expect(parseFindings('outside-voice', '**Retry storm in r.ts:2 (INVESTIGATE).**\n- detail\n- High: a second defect in s.ts:4\nSeverity: Medium').map(f => f.label)).toEqual(['INVESTIGATE', 'High']); expect(parseFindings('outside-voice', 'Low: cache TTL mismatch (cache.ts:4)\n\n2. Token never expires (auth.ts:9)\nSeverity: High\nBlocks: yes').map(f => [f.label, f.raw])) @@ -548,7 +551,7 @@ describe('gstack-review-dispatch sent, collect, judge and verify: nothing change const native = fs.readFileSync(path.join(ROOT, 'test/fixtures/review-ledger/gsta-196-native.txt'), 'utf8'); const r = collect(path.join(d, 'l.jsonl'), 'adversarial-native', native, path.join(d, 'm.jsonl')); expect(r.lines.map(l => [l.label, l.stated])).toEqual([ - ['High', { severity: 'High', blocks: 'no' }], ['CRITICAL', { severity: 'Low', blocks: 'no' }], ['CRITICAL', { severity: 'Low', blocks: 'no' }], ['Low', { severity: 'Low', blocks: 'no' }]]); + ['High', { severity: 'High', blocks: 'no' }], ['Low', { severity: 'Low', blocks: 'no' }], ['Low', { severity: 'Low', blocks: 'no' }], ['Low', { severity: 'Low', blocks: 'no' }]]); expect(fs.readFileSync(path.join(d, 'm.jsonl'), 'utf8').trim().split('\n').map(l => JSON.parse(l).stated)).toEqual(r.lines.map(l => l.stated)); const json = collect(path.join(d, 'l2.jsonl'), 'fix-check', '{"severity":"INFORMATIONAL","path":"a.ts","line":3,"summary":"Severity: High is the wrong word here"}\n', path.join(d, 'm2.jsonl')); expect(json.lines.map(l => [l.label, l.stated])).toEqual([['INFORMATIONAL', undefined]]); @@ -584,7 +587,8 @@ describe('gstack-review-dispatch sent, collect, judge and verify: nothing change for (const [line, label] of kept) expect([line, parseFindings('outside-voice', line).map(f => f.label)]).toEqual([line, [label]]); const native = fs.readFileSync(path.join(ROOT, 'test/fixtures/review-ledger/harn15-152-p1-adversarial-native.txt'), 'utf8'); expect(parseFindings('adversarial-native', native).map(f => f.label)).toEqual(['CRITICAL', 'INVESTIGATE', 'INVESTIGATE', 'CRITICAL', 'INVESTIGATE', 'INVESTIGATE', 'CRITICAL']); - expect(parseFindings('adversarial-native', '**1. Race in a.ts:3 (`FIXABLE`).**\nSeverity: Low. Blocks: no').map(f => f.label)).toEqual(['CRITICAL']); + expect(parseFindings('adversarial-native', '**1. Race in a.ts:3 (`FIXABLE`).**\nSeverity: Low. Blocks: no').map(f => f.label)).toEqual(['Low']); + expect(parseFindings('adversarial-native', '**1. Race in a.ts:3 (`FIXABLE`).**\nSeverity: Low.').map(f => f.label)).toEqual(['CRITICAL']); expect(parseFindings('red-team', '1. Race in a.ts:3 (FIXABLE).').map(f => f.label)).toEqual(['FIXABLE']); expect(parseFindings('adversarial-native', 'No rate limit is FIXABLE (login.ts:9)').map(f => f.label)).toEqual(['CRITICAL']); }); @@ -626,7 +630,7 @@ describe('gstack-review-dispatch sent, collect, judge and verify: nothing change test('item layouts collect as on main; the later-paragraph split and indented label headings are known deferred shapes', () => { const native = fs.readFileSync(path.join(ROOT, 'test/fixtures/review-ledger/harn15-ship2-p2-adversarial-native.txt'), 'utf8'); const found = parseFindings('adversarial-native', native); - expect(found.map(f => f.label)).toEqual(['CRITICAL', 'CRITICAL', 'CRITICAL', 'CRITICAL', 'CRITICAL', 'Low']); + expect(found.map(f => f.label)).toEqual(['Medium', 'Low', 'Low', 'Low', 'Low', 'Low']); expect(parseFindings('outside-voice', '1. **Race on the lock** (a.ts:3)\n - the writer holds no lock\n\n Fix: take it first. Severity: High. Blocks: no.').map(f => f.label)).toEqual(['High']); expect(parseFindings('outside-voice', '1. Lock race (a.ts:3)\n\n Fix: take it first. Blocks: yes\n2. Cache drift (c.ts:4)').map(f => f.label)).toEqual(['CRITICAL']); expect(parseFindings('red-team', '1. Unescaped query\n {"severity":"critical","summary":"Low-level race in q.ts"}').map(f => [f.label, f.raw])) diff --git a/test/review-fixable-class.test.ts b/test/review-fixable-class.test.ts index 010781330..7bc46dd8b 100644 --- a/test/review-fixable-class.test.ts +++ b/test/review-fixable-class.test.ts @@ -18,7 +18,7 @@ describe('native FIXABLE by review class (GST-987)', () => { // no_claim=which class a diff belongs to (lib/review-depth.ts decides) test('#141 native #4 and #6 collect at their own Severity on a code-class plan', () => { expect(parseFindings('adversarial-native', NATIVE, fixableRaises(CODE)).map(f => f.label)).toEqual(['Medium', 'Low']); - expect(parseFindings('adversarial-native', NATIVE).map(f => f.label)).toEqual(['CRITICAL', 'CRITICAL']); + expect(parseFindings('adversarial-native', NATIVE).map(f => f.label)).toEqual(['Medium', 'Low']); }); test('gate class, any risk reason, a depth error or an unreadable plan keeps normalizer v2', () => { for (const lines of [plan('gate', 'gate-class,runtime=9'), plan('code', 'risk:money,runtime=9'), plan('code', 'risk:data,runtime=9'), plan('code', 'error:DIFF,runtime=9'), plan('code', 'runtime=9,history:fixed-blocking'), plan('code', 'runtime=9,floor:full'), plan('code', ''), plan('unknown', 'runtime=9'), [CODE[0]!], [], undefined]) @@ -47,7 +47,7 @@ describe('native FIXABLE by review class (GST-987)', () => { ['### 1. Race in a.ts:3 — FIXABLE\n\nBody.\n\n**Severity:** Medium\n**Blocks:** no\n\n### 2. Drift in b.ts:9 — FIXABLE\n\nBody.\n\n**Severity:** Low\n**Blocks:** no'], ])('a numbered finding heading keeps its body paragraph and fields (#149) %#', (output) => { expect(parseFindings('adversarial-native', output, false).map(f => f.label)).toEqual(['Medium', 'Low']); - expect(parseFindings('adversarial-native', output, true).map(f => f.label)).toEqual(['CRITICAL', 'CRITICAL']); + expect(parseFindings('adversarial-native', output, true).map(f => f.label)).toEqual(['Medium', 'Low']); }); test('a labeled or located paragraph after a numbered heading stays its own finding (#149 joins only plain body text)', () => { for (const raises of [true, false]) { @@ -74,9 +74,9 @@ describe('native FIXABLE by review class (GST-987)', () => { }; expect(labels(['--manifest', manifest])).toEqual(['Medium', 'Low']); expect(fs.readFileSync(ledger, 'utf8')).toContain('"fixable_raises":false'); - expect(labels([])).toEqual(['CRITICAL', 'CRITICAL']); + expect(labels([])).toEqual(['Medium', 'Low']); expect(fs.readFileSync(ledger, 'utf8')).not.toContain('fixable_raises'); - expect(labels(['--manifest', foreign])).toEqual(['CRITICAL', 'CRITICAL']); + expect(labels(['--manifest', foreign])).toEqual(['Medium', 'Low']); fs.rmSync(dir, { recursive: true, force: true }); }); test('verify re-derives a code-class collect with the class it was collected under', () => { diff --git a/test/review-gst1031.test.ts b/test/review-gst1031.test.ts new file mode 100644 index 000000000..c8a4b76f0 --- /dev/null +++ b/test/review-gst1031.test.ts @@ -0,0 +1,145 @@ +import { describe, expect, test } from 'bun:test'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import { promptHash } from '../lib/review-brief'; +import { collect, judge, ledgerBlockers, parseFindings, readJsonl, recordJudgment, summaryCandidate, verify } from '../lib/review-ledger'; +import { isBlocking, summarizeReviewLoop } from '../lib/review-scope'; + +const ROOT = path.resolve(import.meta.dir, '..'); +const fixture = (name: string) => fs.readFileSync(path.join(ROOT, 'test/fixtures/review-ledger', name), 'utf8'); +const labels = (reader: string, output: string, raises: boolean) => parseFindings(reader, output, raises).map(f => f.label); +const HEAD = '**1. The family check refuses two models in one call (check.ts:165-169). FIXABLE.**'; + +describe('one record per native finding at its stated severity (GST-1031 case 1, ruling A)', () => { + // Value: protects=a native finding whose reader states Severity and Blocks: no collects once, at that severity, on every class, and a + // heading keeps its body (located or numbered bullets, a bold subheading, a located paragraph) until its fields arrive; + // fails_when=the heading collects CRITICAL beside a separate severity record, or the gate class raises a Blocks: no finding; + // why_new=GEVA-196 (gstack-evals #153) and GSTA-150 GST-1027 looped Steps 9-11 at about 12M tokens a hit; seam=parseFindings; + // no_claim=which class a diff belongs to (lib/review-depth.ts decides) + test.each([true, false])('the GEVA-196 shape collects Medium, Low, Low with raises=%p', (raises) => { + const found = parseFindings('adversarial-native', fixture('gst-1031-native.txt'), raises); + expect(found.map(f => f.label)).toEqual(['Medium', 'Low', 'Low']); + expect(found.map(f => f.raw.startsWith('**'))).toEqual([true, true, true]); + }); + test.each([ + ['located bullets', [HEAD, 'The check runs always.', '', 'Now every judge stops:', '- the default judge clashes in policy.ts:12;', '- the other judges clash in call.ts:40.', '', 'Fix: gate it on judged.', 'Severity: Medium. Blocks: no.']], + ['numbered bullets', [HEAD, 'The check runs always.', '', 'Now every judge stops:', '1. the default judge clashes;', '2. the other judges clash.', '', 'Severity: Medium. Blocks: no.']], + ['a bold subheading', [HEAD, 'The check runs always.', '', '**Why it matters**', 'So the two models cannot share a call.', 'Severity: Medium. Blocks: no.']], + ['a located paragraph', [HEAD, 'The check runs always.', '', 'The caller in call.ts:40 picks the judge by provider.', 'Severity: Medium. Blocks: no.']], + ])('a heading keeps its body with %s: one record on both classes', (_shape, lines) => { + for (const raises of [true, false]) expect(labels('adversarial-native', (lines as string[]).join('\n'), raises)).toEqual(['Medium']); + }); + test('negative controls: no Blocks: no, Blocks: yes, no Severity field, or a labeled body line keep the raise or their own record', () => { + for (const raises of [true, false]) { + expect(labels('adversarial-native', [HEAD, 'Body.', 'Severity: Medium.'].join('\n'), raises)).toEqual(['CRITICAL']); + expect(labels('adversarial-native', [HEAD, 'Body.', 'Severity: Medium. Blocks: yes.'].join('\n'), raises)).toEqual(['CRITICAL']); + expect(labels('adversarial-native', [HEAD, 'Body.', 'Blocks: no.'].join('\n'), raises)).toEqual(['CRITICAL']); + expect(labels('adversarial-native', [HEAD, '', '- High: the caller in call.ts:40 leaks the key.', '', 'Severity: Medium. Blocks: no.'].join('\n'), raises)).toEqual(['CRITICAL', 'High']); + } + expect(labels('adversarial-native', '## FIXABLE\n1. Leak in a.ts:3\n2. Race in b.ts:4. Blocks: no', true)).toEqual(['CRITICAL', 'CRITICAL']); + }); + test('collect records the stated severity beside the one record', () => { + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gst1031-')); + const c = collect(path.join(dir, 'l.jsonl'), 'adversarial-native', fixture('gst-1031-native.txt'), path.join(dir, 'm.jsonl')); + expect(c.lines.map(l => [l.label, l.stated])).toEqual([['Medium', { severity: 'Medium', blocks: 'no' }], ['Low', { severity: 'Low', blocks: 'no' }], ['Low', { severity: 'Low', blocks: 'no' }]]); + fs.rmSync(dir, { recursive: true, force: true }); + }); +}); + +describe('a closing summary is a candidate lead judgment may dismiss on record (GST-1031 case 5)', () => { + // Value: protects=a sentence that names a severity with no file:line and no exception clause collects as a summary_candidate, which + // judge lets lead judgment lower with a reason (recorded as dismissed) so it stops counting as a blocker, while it still collects at + // its label; fails_when=GSTA-212's "nothing is CRITICAL" or GST-986 r2's "covers the CRITICAL fix" can only be cleared by a + // hand-edited row, a candidate lowered without a reason passes judge, or GST-766's exception-clause line becomes a candidate; + // why_new=both stopped /ship with NEXT: stop; seam=collect, judge, ledgerBlockers; no_claim=that a dismissal is right (it is on record) + const dir = () => fs.mkdtempSync(path.join(os.tmpdir(), 'gst1031s-')); + test('the negated and the plain summary sentence are candidates; dismissed with a reason they leave the blocker count', () => { + for (const [reader, output, id] of [['fix-check', 'None of these would fail a test or let a real consumer through on input the fix was about, so nothing is CRITICAL.\n', 'fix-check#1'], ['fix-check', fixture('gst-1031-fix-check.txt'), 'fix-check#4']]) { + const d = dir(); + const ledger = path.join(d, 'l.jsonl'); + const merged = path.join(d, 'm.jsonl'); + fs.writeFileSync(path.join(d, 'out.txt'), output!); + const c = collect(ledger, reader!, output!, merged, path.join(d, 'out.txt')); + expect(c.lines.filter(l => l.summary_candidate).map(l => [l.id, l.label])).toEqual([[id, 'CRITICAL']]); + const write = (reason?: string) => { fs.writeFileSync(path.join(d, 'j.jsonl'), c.lines.map(l => JSON.stringify({ id: l.id, severity: 'INFORMATIONAL', ...(l.id === id && reason ? { reason } : {}) })).join('\n') + '\n'); return recordJudgment(ledger, c.lines, readJsonl(path.join(d, 'j.jsonl')), path.join(d, 'j.jsonl'), merged); }; + expect(write()).toMatchObject({ ok: false, downgraded: [id], dismissed: [] }); + expect(write('closing summary: it names no defect')).toMatchObject({ ok: true, downgraded: [], dismissed: [id] }); + expect(ledgerBlockers(ledger)).toEqual([]); + expect(verify(ledger).rows.find(r => r.kind === 'JUDGE')!.status).toBe('OK'); + fs.rmSync(d, { recursive: true, force: true }); + } + }); + test('coordinated denials are candidates', () => { + for (const line of ['No CRITICAL or HIGH findings remain.', 'Nothing CRITICAL or HIGH remains.', 'No CRITICAL/HIGH findings.', 'No CRITICAL, HIGH or MEDIUM issues.', 'Nothing at CRITICAL severity remains.', 'No CRITICAL — the fix is sound.']) + expect([line, summaryCandidate(line)]).toEqual([line, true]); + }); + test('negative controls: a locus, an exception clause, a lead label, a field or a JSON finding is no candidate and keeps its label', () => { + for (const line of ['No CRITICAL issues except the token leak in log.ts:3.', 'Nothing else is CRITICAL, but the retry loop never ends.', 'The token leak in log.ts:3 is CRITICAL.', + 'The leak in bin/gstack-log:3 is CRITICAL.', 'CRITICAL: the retry loop never ends.', 'The retry loop never ends. Severity: High', 'Not checked. Blocks: no. CRITICAL', '{"severity":"CRITICAL","summary":"x"}', + 'The retry loop in the upload handler never ends, which is CRITICAL.', 'Path traversal in the download route lets any user read arbitrary files; this is CRITICAL.', + 'The session token is written to the debug log on every request, a CRITICAL leak.', 'Nothing guards the write path the failure of which is CRITICAL', + 'There is no CRITICAL lock around the refund write, so two workers double-pay.', 'The patch closes the CRITICAL window only on Linux; on macOS the race remains.']) { + expect([line, summaryCandidate(line)]).toEqual([line, false]); + expect(parseFindings('fix-check', line).length).toBe(1); + } + const lowered = judge([{ id: 'r#1', reader: 'r', label: 'CRITICAL', raw: 'No CRITICAL issues except the token leak in log.ts:3.', output_sha256: 'x' }], [{ id: 'r#1', severity: 'INFORMATIONAL', reason: 'summary' }]); + expect(lowered).toMatchObject({ ok: false, downgraded: ['r#1'] }); + }); +}); + +describe('the blocker count keys on Blocks (GST-1031 case 3)', () => { + // Value: protects=a CRITICAL its reader marked Blocks: no is not counted as a blocker by the ledger count, the row count or Step + // 9.4's classify, while Blocks: yes, an unstated Blocks and a lead promotion still block; fails_when=REVIEW_LOOP reports a + // Blocks: no note as found or unrecorded, or a Blocks: yes CRITICAL stops blocking; why_new=ggstack#52: a lane hand-added + // fixed rows to get a receipt; seam=ledgerBlockers, summarizeReviewLoop, isBlocking; no_claim=what the reader meant + const OUT = '1. Drops rows in q.ts:7. Severity: Critical. Blocks: no.\n\n2. Leaks a token in log.ts:3. Severity: Critical. Blocks: yes.\n\n3. Races in a.ts:9. Severity: Critical.\n\n4. Slows down in b.ts:2. Severity: Medium. Blocks: no.\n'; + const run = (judged?: string) => { + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gst1031b-')); + const ledger = path.join(dir, 'l.jsonl'); + const merged = path.join(dir, 'm.jsonl'); + fs.writeFileSync(path.join(dir, 'out.txt'), OUT); + collect(ledger, 'outside-voice', OUT, merged, path.join(dir, 'out.txt')); + if (judged !== undefined) { + fs.writeFileSync(path.join(dir, 'j.jsonl'), judged); + fs.appendFileSync(ledger, JSON.stringify({ event: 'judge', ok: true, judged: path.join(dir, 'j.jsonl'), judged_sha256: promptHash(judged) }) + '\n'); + } + const ids = ledgerBlockers(ledger).map(b => b.id); + fs.rmSync(dir, { recursive: true, force: true }); + return ids; + }; + test('ledgerBlockers skips a Blocks: no CRITICAL and keeps Blocks: yes, unstated and a lead promotion', () => { + expect(run()).toEqual(['outside-voice#2', 'outside-voice#3']); + const promote = ['outside-voice#1', 'outside-voice#2', 'outside-voice#3'].map(id => JSON.stringify({ id, severity: 'CRITICAL' })).join('\n') + '\n' + JSON.stringify({ id: 'outside-voice#4', severity: 'CRITICAL', reason: 'it loses rows' }) + '\n'; + expect(run(promote)).toEqual(['outside-voice#2', 'outside-voice#3', 'outside-voice#4']); + }); + test('a verb "blocks no" is no Blocks field: the located CRITICAL still counts, on the ledger and in a native finding', () => { + for (const out of ['CRITICAL: The lock in queue.ts:40 blocks no other writer, so two passes lose findings.\n', '1. **CRITICAL** — cache.ts:12 evicts on read; it blocks no request with a stale token.\n', '- CRITICAL src/auth.ts:9 token check is skipped; it blocks no attacker.\n']) { + const d = fs.mkdtempSync(path.join(os.tmpdir(), 'gst1031v-')); + const c = collect(path.join(d, 'l.jsonl'), 'outside-voice', out, path.join(d, 'm.jsonl')); + expect([out, c.lines[0]!.stated?.blocks, ledgerBlockers(path.join(d, 'l.jsonl')).map(b => b.id)]).toEqual([out, undefined, ['outside-voice#1']]); + fs.rmSync(d, { recursive: true, force: true }); + } + for (const raises of [true, false]) expect(labels('adversarial-native', '**1. Race in a.ts:3. FIXABLE.**\nIt blocks no attacker.\nSeverity: Low.', raises)).toEqual(['CRITICAL']); + const q = fs.mkdtempSync(path.join(os.tmpdir(), 'gst1031y-')); + const y = collect(path.join(q, 'l.jsonl'), 'outside-voice', 'CRITICAL: auth.ts:9 skips authentication. The previous note said `Blocks: no`. Blocks yes.\n', path.join(q, 'm.jsonl')); + expect([y.lines[0]!.stated?.blocks, ledgerBlockers(path.join(q, 'l.jsonl')).map(b => b.id)]).toEqual(['yes', ['outside-voice#1']]); + fs.rmSync(q, { recursive: true, force: true }); + const d = fs.mkdtempSync(path.join(os.tmpdir(), 'gst1031j-')); + collect(path.join(d, 'l.jsonl'), 'specialist', JSON.stringify({ severity: 'CRITICAL', path: 'lib/auth.ts', line: 9, summary: 'the old guard, which a reader marked `Blocks: no`, is gone so any caller gets admin' }) + '\n', path.join(d, 'm.jsonl')); + expect(ledgerBlockers(path.join(d, 'l.jsonl')).map(b => b.id)).toEqual(['specialist#1']); + fs.rmSync(d, { recursive: true, force: true }); + }); + test('classify and the row count key on Blocks, and a raw holding both Blocks: yes and no blocks', () => { + expect(isBlocking({ severity: 'CRITICAL', stated: { severity: 'Critical', blocks: 'no' } })).toBe(false); + expect(isBlocking({ severity: 'CRITICAL', stated: { severity: 'Critical', blocks: 'yes' } })).toBe(true); + expect(isBlocking({ severity: 'CRITICAL' })).toBe(true); + const row = (stated?: object) => ({ skill: 'review', via: 'ship', timestamp: '2026-11-02T00:00:00Z', findings: [{ path: 'q.ts', line: 7, severity: 'CRITICAL', ...(stated ? { stated } : {}) }] }); + expect(summarizeReviewLoop([row({ blocks: 'no' })], '2026-11-01T00:00:00Z').blocking_found).toBe(0); + expect(summarizeReviewLoop([row()], '2026-11-01T00:00:00Z')).toMatchObject({ blocking_found: 1, unrecorded: 1 }); + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gst1031c-')); + const both = collect(path.join(dir, 'l.jsonl'), 'outside-voice', 'Leaks a token in log.ts:3. Severity: Critical. Blocks: yes. Retry is fine. Blocks: no.\n', path.join(dir, 'm.jsonl')); + expect(both.lines.map(l => l.stated?.blocks)).toEqual(['yes']); + fs.rmSync(dir, { recursive: true, force: true }); + }); +}); diff --git a/test/review-ledger-invariant.test.ts b/test/review-ledger-invariant.test.ts index 18b2f6744..13496e1c2 100644 --- a/test/review-ledger-invariant.test.ts +++ b/test/review-ledger-invariant.test.ts @@ -21,7 +21,8 @@ describe('parseFindings is never weaker than main (GST-976 invariant)', () => { // why_new=three GST-976 review rounds each found a shape the row tables missed; seam=parseFindings; no_claim=that main's label was // right (it is the floor), or coverage of stored private reader outputs (checked outside the repo). GST-987: the gate class (and every // risk class) keeps this rule; outside it the native voice's FIXABLE beside Blocks: no no longer counts as a raise, so such a fielded - // finding collects at its field unless a lead, a label heading or Blocks: yes raises it + // finding collects at its field unless a lead, a label heading or Blocks: yes raises it. GST-1031 ruling A: the gate and risk classes + // drop that raise too, so on every class FIXABLE raises only a finding that does not state Blocks: no test.each([['gate', true], ['code', false]] as const)('every pinned input, reader fixture and generated field shape (%s class)', (_cls, raises) => { const { entries, shapes } = JSON.parse(fs.readFileSync(path.join(ROOT, 'test/fixtures/review-ledger/main-labels.json'), 'utf8')); const { bodies, fields: tails, joins, readers, generated } = shapes; @@ -37,7 +38,7 @@ describe('parseFindings is never weaker than main (GST-976 invariant)', () => { findings++; const fields = [...f.raw.matchAll(FIELD)].map(m => (m[1] ?? m[2])!); const single = fields.length === 1 && fields[0]!.match(LABEL)!.length === 1 ? fields[0]!.match(LABEL)![0] : undefined; - const raised = /Blocks:?\**:?\s*\**\s*yes/i.test(f.raw) || (e.reader.startsWith('adversarial-native') && /FIXABLE/.test(f.raw) && (raises || !/Blocks:?\**:?\s*\**\s*no\b/i.test(f.raw))) || (raises ? LEAD : LEAD_NO_FIXABLE).test(f.raw) || HEADING.test(output); + const raised = /Blocks:?\**:?\s*\**\s*yes/i.test(f.raw) || (e.reader.startsWith('adversarial-native') && /FIXABLE/.test(f.raw) && !/Blocks:?\**:?\s*\**\s*no\b/i.test(f.raw)) || (raises ? LEAD : LEAD_NO_FIXABLE).test(f.raw) || HEADING.test(output); const ok = single === undefined ? (rank(f.label) ?? 0) >= (rank(e.main[i]) ?? 0) : (rank(f.label) ?? 0) >= (rank(single) ?? 0) && (raised || (rank(f.label) ?? 0) === (rank(single) ?? 0)); if (!ok) bad.push(`${e.reader} main=${e.main[i]} got=${f.label} field=${single ?? '-'} ${JSON.stringify(f.raw.slice(0, 100))}`); diff --git a/test/review-pass.test.ts b/test/review-pass.test.ts index 2e8ec1126..57a9512e5 100644 --- a/test/review-pass.test.ts +++ b/test/review-pass.test.ts @@ -706,6 +706,21 @@ describe('Capy pass program (fake host, real bins)', () => { expect(v).toMatch(/^OUTPUT fix-check MATCH /m); }, 240_000); + // Value: protects=decision 3.5's fix-check takes a review-fix-check start token even when the parent passes the Capy skill's + // logStart ["review"], so its row is never a pass and a review_loop_exception can follow it; fails_when=the fix-check pass logs a + // review start; why_new=ggstack#52 (GST-1031): a scoped fix-check logged as review counted as a second pass; seam=the pass program; + // no_claim=what the parent writes in the row + test('a fix-check pass given logStart ["review"] takes the review-fix-check start', async () => { + const { dir, env } = repo(); + const files = path.join(dir, '.state/fc'); + fs.mkdirSync(files, { recursive: true }); + const fc: Record = {}; + for (const [k, v] of [['fix_list', '1. src/a.ts: guard v80\n'], ['hunks', 'diff --git a/src/a.ts b/src/a.ts\n+export const v81 = 81;\n'], ['tests', 'bun test: 3 pass, 0 fail\n']]) { fc[k] = path.join(files, k + '.txt'); fs.writeFileSync(fc[k]!, v!); } + const res = await runPass(host(dir, env), { base: 'main', out: path.join(dir, '.state/run/fcr'), pass: 'x52fc', planFlags: ['--pass', '1', '--last', 'full', '--fixed-below'], fixCheck: fc, logStart: ['review'] }); + expect(res).toMatch(/REVIEW_LOG_START: review-fix-check token=\S+/); + expect(res).not.toMatch(/REVIEW_LOG_START: review token=/); + }, 240_000); + test('Step 11 records one start per row it logs, even when two rows share a skill (native and outside adversarial-review)', async () => { const { dir, env } = repo(); const out = path.join(dir, '.state/run/p1'); diff --git a/test/ship-release.test.ts b/test/ship-release.test.ts index c6011e974..8b7dc72b2 100644 --- a/test/ship-release.test.ts +++ b/test/ship-release.test.ts @@ -308,6 +308,29 @@ describe('gstack-ship-release push: branch names', () => { }); }); +describe('GST-1031: a non-behavioral harness re-pin after review is release metadata', () => { + // Value: protects=a scripts/harness-version.json edit after review that only records changed harness files as non-behavioral at the same + // version routes as metadata, so a clean round 2 is not sent back through 5-11.5, while a version bump, a pattern change or an entry + // without its reason stays behavior; fails_when=the re-pin stops finish, or a bump or bare re-pin routes as metadata; + // why_new=GSTA-150 GST-1027 (icm_01M6ERWWBZ3VWXZY07F2W5ZSFB); seam=route; no_claim=that the recorded reason is true + const pin = (version: number, entry: Record, patterns = ['test/helpers/x.ts']) => JSON.stringify({ version, patterns, files: { 'test/helpers/x.ts': entry } }) + '\n'; + const finish = (after: string) => { + const f = fx(); + f.write({ 'scripts/harness-version.json': pin(6, { blob: 'a'.repeat(40), since: 6 }) }); f.commit('pin'); + const reviewed = wtree(f); + const post = snapshot(f); + f.write({ 'scripts/harness-version.json': after }); f.commit('re-pin'); + return f.run(RELEASE, ['finish', '--base', 'main', '--reviewed-tree', reviewed, '--docs-post', post, '--lane', LANE]).stdout; + }; + test('a non-behavioral re-pin is metadata; a bump, a pattern change or an entry without its reason is behavior', () => { + const repin = finish(pin(6, { blob: 'b'.repeat(40), since: 6, nonBehavioral: 'comment-only edit: no verdict can change' })); + expect(lineOf(repin, 'ROUTE')).toMatch(/behavior=0 docs=0 metadata=1/); + expect(repin).not.toContain('STOP: behavior'); + for (const after of [pin(7, { blob: 'b'.repeat(40), since: 7 }), pin(6, { blob: 'b'.repeat(40), since: 6 }), pin(6, { blob: 'b'.repeat(40), since: 6, nonBehavioral: 'comment-only edit: no verdict can change' }, ['test/helpers/**'])]) + expect(finish(after)).toContain('STOP: behavior, tests or build inputs changed since review (scripts/harness-version.json)'); + }); +}); + describe('GSTA-167 part 4a: the post-review route stays path-only', () => { // Value: protects=F1/F2, a data file edited after review sends the ship back through review even when no code names it, // because the route never applies the data rule; fails_when=a JSON edit after review takes the docs-rechecked route; seam=classifyPath From d4bef0a6a314b21a85bd85f516a43ec48bc94999 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 19:05:47 -0800 Subject: [PATCH 2/6] v1.93.39.0 fix(ship): stop a hung outside voice and record it unavailable as the host subagent (GST-1104) (#3895) * fix(ship): stop a hung outside voice and record it unavailable as the host subagent (GST-1104) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review-pass): collect a stopped or failed outside voice's report before marking it unavailable (GST-1104) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review-pass): an ended outside voice with a non-review summary is unavailable, not a stuck pass (GST-1104) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review-pass): write an unavailable outside voice's failure text to its own file so verify keeps the earlier output (GST-1104) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review-pass): an ended outside voice with no findings is collected unavailable from its own reply, so verify keeps no NOT_REVIEWED row (GST-1104) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 9 ++++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- docs/unattended.md | 16 ++++-- lib/capy-review-pass.js | 51 ++++++++++++++++-- package.json | 2 +- test/review-pass.test.ts | 98 ++++++++++++++++++++++++++++++++-- 7 files changed, 164 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0740836fd..bbdc69e7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [1.93.39.0] - 2026-11-03 + +**/ship on Capy stops an outside voice that hangs and records it as missing, never as converged or as an unavailable Codex CLI (GST-1104).** TRUT-7's /ship run had two outside voices end with no result (gpt-6.1-sol stopped after 20 minutes; grok-4.7 used 16.9M tokens before it was stopped), and its Step 11 row read `outside_provider: codex`, `outside_status: unavailable`, `converged: true`. + +### Fixed +- **`lib/capy-review-pass.js`**: an outside voice still running with no output after `input.stuckMs` (20 minutes by default) is stopped. One that hangs, finishes empty, or stops or fails without leaving findings is collected as unavailable coverage (`COLLECT_UNAVAILABLE:`); one that stops or fails after writing findings is collected normally, so its findings are kept, and Step 11 goes on to judge the native voice instead of stopping the pass with nothing recorded. Other readers still stop the pass as before. +- **`lib/capy-review-pass.js`**: Step 11 returns an `OUTSIDE_RECORD:` line with `outside_provider: host-subagent`, the model that ran and its status, for the review-log rows to copy instead of the template's `codex`. When the voice was unavailable, the line tells the parent to write that voice its own row first (`status: unavailable`, `completed` and `converged` false), so the native row's convergence no longer stands in for it. +- **`docs/unattended.md`**: "The outside voice on Capy" describes the stop, the unavailable record and the new fields. + ## [1.93.38.0] - 2026-11-03 - **Review collector and blocker count follow what the reader said (GST-1031).** A native adversarial finding that states `Blocks: no` and one Severity now collects once, at that severity, on every review class; a numbered finding heading keeps its body (located or numbered bullets, a bold subheading, a located paragraph) so its Severity line no longer splits off as a second CRITICAL record. A closing summary such as "so nothing is CRITICAL" is marked `summary_candidate`, and lead judgment may lower it with a reason that `judge` records as `dismissed`. A CRITICAL whose reader writes the field `Blocks: no` no longer counts as a blocker in `REVIEW_LOOP`'s ledger count (classify does the same for a finding that carries `stated`; Step 9.4 does not copy it yet). Decision 3.5's fix-check pass takes a `review-fix-check` start token even when given `logStart: ["review"]`, so it is never counted as a pass. `gstack-ship-release finish` routes a `scripts/harness-version.json` edit that only records non-behavioral pins at the same version as release metadata. diff --git a/VERSION b/VERSION index 499e69b38..06dc54ecd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.93.38.0 +1.93.39.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index ad4f63936..5c25e2c05 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.93.38.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.93.39.0 — regenerate/re-copy after upgrading gstack Behavioral rules from gstack (https://github.com/garrytan/gstack), compressed for agent hosts without a full skill install. The full skills add workflows, diff --git a/docs/unattended.md b/docs/unattended.md index f16896597..08703d6b6 100644 --- a/docs/unattended.md +++ b/docs/unattended.md @@ -216,8 +216,9 @@ review-log row is the same row every Step 11 pass writes (the outside provider that reviewed, with the model recorded, for the cross-family subagent; `codex` for completed Codex CLI output, as `ship/sections/adversarial.md` prescribes), -`outside_provider` (the provider the host would have used, as the generated -prose names it), `outside_status` (`completed` for a finished outside pass; +`outside_provider` (on Capy, `host-subagent`, with `outside_model`, both copied +from the pass program's `OUTSIDE_RECORD:` line; elsewhere the provider the +generated prose names), `outside_status` (`completed` for a finished outside pass; `unavailable` when neither the CLI nor a subagent completed, the cause on the `gstack-outside-voice run:` stderr line and in `.meta.json` rather than in the row; `disabled` under @@ -237,7 +238,16 @@ when `input.models['outside-voice']` is empty and the lane model is rounds ran. Any other lane must name a model. An outside voice from the same provider as the lane model or the native voice stops the pass (`STOP:`) before either voice is created, including on a rerun, and each outside voice prints an -`OUTSIDE_VOICE:` line saying whether it is the certified configuration. +`OUTSIDE_VOICE:` line saying whether it is the certified configuration. An +outside voice still running with no output after `input.stuckMs` (20 minutes by +default) is stopped, and one that stops or fails without leaving findings, or +finishes empty, is collected as unavailable coverage (`COLLECT_UNAVAILABLE:`) +instead of stopping the pass, so Step 11 goes on to judge the native voice. A +stopped or failed outside voice whose reply holds findings is collected like any +finished one, so its findings are kept; one whose reply holds none is unavailable. That outside voice then gets its own +row (`source: "host-subagent"`, `status: "unavailable"`, `completed` and +`converged` false, written without `--finish` before the native row), so a +missing voice never reads as converged or as an unavailable Codex CLI. ### The carry across a base merge or a test-only fix diff --git a/lib/capy-review-pass.js b/lib/capy-review-pass.js index 033cce32d..8ad670887 100644 --- a/lib/capy-review-pass.js +++ b/lib/capy-review-pass.js @@ -4,7 +4,9 @@ // fix-check with its plan's voices included, whose `review` start becomes `review-fix-check`, never a pass: GST-1031) or Step 11's voices from the manifest `gstack-review-dispatch pass` writes: render, chunked brief transport, `sent`, // intent before create, create, poll, collect. It returns 200 s after the loader's first line // (input.startedAt) at most; the next call resumes from the manifest. A failed, stuck or ambiguous -// reader, a brief mismatch or a failing bin returns `STOP:` for the parent; nothing is dropped. +// reader, a brief mismatch or a failing bin returns `STOP:` for the parent; nothing is dropped. The outside +// voice is the exception (GST-1104): one that hangs past stuckMs is stopped, and one that hangs, ends empty, or +// stops or fails without findings is collected as unavailable coverage (one that left findings is collected); Step 11 returns OUTSIDE_RECORD: for its review-log rows. // Once Phase 2 has started /parts (the parent of input.out), each poll or finished pass also // returns the next phase's section parts that fit its 32 KB (`gstack-ship-parts next`, GSTA-167 C5); // after a return that never reached the parent, rerun with input.resendParts to get that batch again. @@ -124,6 +126,16 @@ const familyStop = (readers) => { return null; }; const safe = (s) => s.replace(/[^a-zA-Z0-9._-]/g, '_'); +const UNAVAILABLE = 'unavailable: '; +const recordUnavailable = async (m, r, why) => { + const file = m.out + '/out/' + safe(r.reader) + '.unavailable.txt'; + await tools.capy.write({ path: file, content: 'outside voice (' + modelOf(r).model_id + ') ' + why + '\n' }); + const c = await sh(bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf) + ' --unavailable ' + q(why)); + if (c.code !== 0) return stop('collect --unavailable ' + r.reader + ' exited ' + c.code + ': ' + c.out.slice(-500)); + lines.push(c.out.trim()); + await mark(r.reader, 'collected', { output: file, error: UNAVAILABLE + why }); + return null; +}; const active = input.stage === 'voices' ? ['voices'] : ['first', 'specialists', 'red-team']; const beforeKey = input.stage === 'voices' ? 'before_voices' : 'before'; @@ -186,20 +198,44 @@ try { for (const r of m.readers.filter((x) => active.includes(x.stage) && x.state === 'created')) { const t = byPath.get(r.path); if (!t) return stop(r.reader + "'s subagent " + r.path + ' is missing from the subagent list'); - if (t.status === 'failed' || t.status === 'stopped') { await mark(r.reader, 'failed', { error: t.status }); return stop(r.reader + ' (subagent ' + r.path + ') ' + t.status + '; its review is incomplete, so the pass cannot certify coverage'); } + const outside = r.role === 'outside-voice'; + const ended = t.status === 'failed' || t.status === 'stopped'; + if (ended && !outside) { await mark(r.reader, 'failed', { error: t.status }); return stop(r.reader + ' (subagent ' + r.path + ') ' + t.status + '; its review is incomplete, so the pass cannot certify coverage'); } const stuck = async () => r.state_at && (await now()) - Date.parse(r.state_at) > stuckMs; - const g = t.status === 'done' || t.status === 'idle' ? await tools.subagent.get({ path: r.path, transcript: 'none' }) : null; + const g = t.status === 'done' || t.status === 'idle' || ended ? await tools.subagent.get({ path: r.path, transcript: 'none' }) : null; + if (ended && !(g && g.summary)) { + const s = await recordUnavailable(m, r, t.status + ' with no result'); + if (s) return s; + continue; + } if (!g || !g.summary) { if (t.status === 'done') { const seen = (emptyDone[r.reader] ??= await now()); - if ((await now()) - seen >= emptyGraceMs) return stop(r.reader + ' (subagent ' + r.path + ') finished with no output'); + if ((await now()) - seen < emptyGraceMs) continue; + if (!outside) return stop(r.reader + ' (subagent ' + r.path + ') finished with no output'); + const s = await recordUnavailable(m, r, 'finished with no output'); + if (s) return s; continue; } - if (await stuck()) return stop(r.reader + ' (subagent ' + r.path + ') still ' + t.status + ' after ' + Math.round(stuckMs / 60000) + ' minutes with no output'); + if (!(await stuck())) continue; + const why = 'still ' + t.status + ' after ' + Math.round(stuckMs / 60000) + ' minutes with no output'; + if (!outside) return stop(r.reader + ' (subagent ' + r.path + ') ' + why); + await tools.subagent.stop({ paths: [r.path] }); + const s = await recordUnavailable(m, r, why + '; stopped'); + if (s) return s; continue; } const file = m.out + '/out/' + safe(r.reader) + '.txt'; await tools.capy.write({ path: file, content: g.summary }); + if (ended) { + const why = t.status + ' before finishing its review'; + const u = await sh(bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf) + ' --unavailable ' + q(why)); + if (u.code === 0) { + lines.push(u.out.trim()); + await mark(r.reader, 'collected', { output: file, error: UNAVAILABLE + why }); + continue; + } + } const c = await sh(r.prompt_file ? bin + ' mark --manifest ' + q(mf) + ' --reader ' + q(r.reader) + ' --state collected --output ' + q(file) : bin + ' collect --ledger ' + q(m.ledger) + roleArgs(r) + ' --output ' + q(file) + ' --merged ' + q(m.merged) + ' --manifest ' + q(mf)); if (c.code !== 0) return stop((r.prompt_file ? 'mark ' : 'collect ') + r.reader + ' exited ' + c.code + ': ' + c.out.slice(-500)); @@ -266,6 +302,11 @@ try { const o = await sh('cat ' + q(r.output)); outs.push('OUTPUT: ' + r.reader + ' file=' + r.output, o.out.trimEnd()); } + for (const r of done.filter((x) => x.role === 'outside-voice')) { + const lost = String(r.error || '').startsWith(UNAVAILABLE); + outs.push('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":' + JSON.stringify(modelOf(r).model_id) + ',"outside_status":"' + (lost ? 'unavailable' : 'completed') + '" (Step 11\'s review-log rows carry these fields, never the template\'s codex' + + (lost ? '; first write this voice its own adversarial-review row with "source":"host-subagent","status":"unavailable","completed":false,"converged":false and no --finish, then the native row' : '') + ')'); + } if (noteExit !== 0) return finish([...outs, 'STOP: gstack-ship-budget note exited ' + noteExit + ' (its lines above say why); judge nothing further until the budget allows it']); return await withParts([...outs, input.stage === 'voices' ? 'NEXT: judge the voices' : input.step === '14.5' ? 'NEXT: apply the docs audit (Step 14.5)' : 'NEXT: judge (Phase 4)']); } catch (e) { diff --git a/package.json b/package.json index 9864d54ed..dabdd8dc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.93.38", + "version": "1.93.39", "description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.", "license": "MIT", "type": "module", diff --git a/test/review-pass.test.ts b/test/review-pass.test.ts index 57a9512e5..3eadafe57 100644 --- a/test/review-pass.test.ts +++ b/test/review-pass.test.ts @@ -144,18 +144,20 @@ function treeLine(dir: string): string { return tree.status === 0 && top.status === 0 ? `REVIEWED_TREE: ${tree.stdout.trim()} ${top.stdout.trim()}\n` : ''; } const briefDir = (prompt: string) => /Workspace: the checkout under review is (.+?)\. Your shell and file tools/.exec(prompt)?.[1] ?? ''; -function host(dir: string, env: NodeJS.ProcessEnv, o: { output?: (title: string) => string; reportFrom?: (title: string) => string; fail?: (title: string) => boolean; reject?: (title: string) => boolean; createThrows?: (title: string) => 'before' | 'after' | undefined; pollsToFinish?: number; lateSummary?: boolean } = {}) { +function host(dir: string, env: NodeJS.ProcessEnv, o: { output?: (title: string) => string; reportFrom?: (title: string) => string; fail?: (title: string) => boolean; reject?: (title: string) => boolean; createThrows?: (title: string) => 'before' | 'after' | undefined; pollsToFinish?: number; lateSummary?: boolean; hang?: (title: string) => boolean; stopped?: (title: string) => boolean; keepSummary?: boolean; epoch?: number } = {}) { let clock = 0; const subs = new Map(); const creates: Sub[] = []; const starts: number[][] = []; + const stops: string[] = []; const reply = (s: Sub) => treeLine(o.reportFrom?.(s.title) ?? briefDir(s.prompt)) + (o.output?.(s.title) ?? cleanReply(s.title)); const advance = () => { for (const s of subs.values()) { if (s.late && !s.summary) { s.summary = reply(s); continue; } - if (s.status !== 'working') continue; + if (s.status !== 'working' || o.hang?.(s.title)) continue; if (++s.polls < (o.pollsToFinish ?? 1)) continue; - if (o.fail?.(s.title)) s.status = 'failed'; + if (o.stopped?.(s.title)) { s.status = 'stopped'; if (o.keepSummary) s.summary = reply(s); } + else if (o.fail?.(s.title)) { s.status = 'failed'; if (o.keepSummary) s.summary = reply(s); } else if (o.lateSummary && !s.late) { s.status = 'done'; s.late = true; } else { s.status = 'done'; s.summary = reply(s); } } @@ -185,10 +187,11 @@ function host(dir: string, env: NodeJS.ProcessEnv, o: { output?: (title: string) start: async ({ indices, model }: { indices: number[]; model?: unknown }) => { starts.push(indices); for (const i of indices) { const s = subs.get(String(i))!; s.status = 'working'; if (model) s.model = model; } return { started: indices.map(index => ({ index })), rejected: [] }; }, list: async () => { advance(); return { tasks: [...subs].map(([p, s]) => ({ path: p, title: s.title, status: s.status })), total: subs.size }; }, get: async ({ path: p }: { path: string }) => ({ path: p, status: subs.get(p)!.status, summary: subs.get(p)!.summary }), + stop: async ({ paths }: { paths: string[] }) => { stops.push(...paths); for (const p of paths) subs.get(p)!.status = 'stopped'; return { results: paths.map(p => ({ path: p, ok: true })) }; }, }, thread: { get: async () => ({ cost: { tokens: 1000 + clock, credits: 1 + clock / 1000 } }) }, }; - return { tools, subs, creates, starts, sleep: async (ms: number) => { clock += ms; }, now: async () => 1_000_000 + clock }; + return { tools, subs, creates, starts, stops, sleep: async (ms: number) => { clock += ms; }, now: async () => (o.epoch ?? 1_000_000) + clock }; } const PROGRAM = fs.readFileSync(path.join(ROOT, 'lib/capy-review-pass.js'), 'utf8'); @@ -362,7 +365,9 @@ describe('Capy pass program (fake host, real bins)', () => { expect(await runPass(h, { ...base, stage: 'voices', laneModel: undefined })).toContain("STOP: the outside voice needs input.models['outside-voice']"); expect(h.creates.some(c => c.title.startsWith('ship x7p1 ') && /adversarial|outside/.test(c.title))).toBe(false); const models = { 'outside-voice': { model_id: 'openai/gpt-6.1-sol' }, 'adversarial-native': { model_id: 'anthropic/claude-opus-5-5', reasoning_mode: 'high' } }; - expect(await runPass(h, { ...base, stage: 'voices', models })).toContain('NEXT: judge the voices'); + const voices = await runPass(h, { ...base, stage: 'voices', models }); + expect(voices).toContain('NEXT: judge the voices'); + expect(voices).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6.1-sol","outside_status":"completed"'); expect(h.creates.find(c => c.title === 'ship x7p1 outside-voice')!.model).toEqual(models['outside-voice']); expect(h.creates.find(c => c.title === 'ship x7p1 adversarial-native')!.model).toEqual(models['adversarial-native']); }, 240_000); @@ -489,6 +494,89 @@ describe('Capy pass program (fake host, real bins)', () => { for (const t of Object.keys(named.models)) if (t !== 'ship x17p1 outside-voice') expect(over.models[t]).toEqual(named.models[t]); }, 300_000); + // Value: protects=GST-1104 (TRUT-7, truther#1159): an outside voice that runs past the stuck limit, or ends stopped or failed with no result, is stopped and recorded as unavailable coverage under its own runner and model, and Step 11 goes on to judge the native voice; fails_when=the stuck subagent is left running (TRUT-7 p2 burned 16.9M tokens before anyone stopped it), the pass stops with nothing recorded, or the returned record names no host-subagent runner so the review-log row falls back to the template's codex; + // why_new=GST-1104; seam=lib/capy-review-pass.js reader poll; no_claim=which outside model Step 11 picks + test('an outside voice that hangs or stops with no result is stopped and recorded unavailable as the host subagent, and Step 11 goes on (GST-1104)', async () => { + for (const [pass, o] of [['x30p1', { hang: (t: string) => t.endsWith('outside-voice') }], ['x31p1', { stopped: (t: string) => t.endsWith('outside-voice') }], ['x32p1', { fail: (t: string) => t.endsWith('outside-voice') }]] as const) { + const { dir, env } = repo(); + const out = path.join(dir, '.state/run/p1'); + const h = host(dir, env, { ...o, epoch: Date.now() }); + const base = { base: 'main', out, pass, planFlags: ['--depth-floor', 'full'] }; + expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)'); + let res = ''; + for (let i = 0; i < 6; i++) { + res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 }); + if (!res.includes('NEXT: poll')) break; + } + expect(res).not.toContain('STOP:'); + expect(res).toContain('COLLECT_UNAVAILABLE: reader=outside-voice'); + expect(res).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6.1-sol","outside_status":"unavailable"'); + expect(res).toContain('first write this voice its own adversarial-review row with "source":"host-subagent","status":"unavailable","completed":false,"converged":false and no --finish, then the native row'); + expect(res).toContain('NEXT: judge the voices'); + if ('hang' in o) { + const token = /REVIEW_LOG_START: adversarial-review token=(\S+)/.exec(res)![1]!; + const record = /OUTSIDE_RECORD: (\S+)/.exec(res)![1]!; + const log = (row: string, a: string[] = []) => spawnSync(path.join(BIN, 'gstack-review-log'), [row, ...a], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 }); + expect(log('{"skill":"adversarial-review","status":"unavailable","source":"host-subagent",' + record + ',"phase":"adversarial","completed":false,"converged":false}').status).toBe(0); + expect(log('{"skill":"adversarial-review","status":"clean","source":"in-host",' + record + ',"phase":"adversarial","completed":true,"converged":true}', ['--finish', token]).status).toBe(0); + const rows = spawnSync(path.join(BIN, 'gstack-review-read'), [], { cwd: dir, env, encoding: 'utf8', timeout: 60_000 }).stdout.split('---CONFIG---')[0]!.trim().split('\n').map(l => JSON.parse(l)); + expect(rows.map(r => [r.source, r.outside_provider, r.outside_status, r.converged])).toEqual([['host-subagent', 'host-subagent', 'unavailable', false], ['in-host', 'host-subagent', 'unavailable', true]]); + expect(rows[1].review_freshness).toMatchObject({ status: 'CURRENT' }); + } + const ov = [...h.subs].find(([, s]) => s.title === 'ship ' + pass + ' outside-voice')!; + expect(ov[1].status).not.toBe('working'); + expect(h.stops).toEqual('hang' in o ? [ov[0]] : []); + const v = bin(dir, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]); + expect(v.stdout).toMatch(/^BRIEF outside-voice UNAVAILABLE/m); + expect(v.stdout).not.toContain('MISMATCH'); + expect(v.stdout).toContain('unavailable=1'); + } + }, 600_000); + + // Value: protects=GST-1104 review finding: an outside voice that wrote its report and then ended stopped or failed is collected from its summary, never replaced by unavailable coverage; fails_when=the pass records the voice unavailable without reading the summary, silently dropping its findings; + // why_new=GST-1104 /ship review (three readers); seam=lib/capy-review-pass.js reader poll; no_claim=what the voice found + test('an outside voice that ends stopped or failed with a report is collected, not marked unavailable (GST-1104)', async () => { + for (const [pass, o] of [['x33p1', { stopped: (t: string) => t.endsWith('outside-voice') }], ['x34p1', { fail: (t: string) => t.endsWith('outside-voice') }]] as const) { + const { dir, env } = repo(); + const out = path.join(dir, '.state/run/p1'); + const h = host(dir, env, { ...o, keepSummary: true, output: (t: string) => (t.endsWith('outside-voice') ? '1. **A guard fails open** - `src/a.ts:1` accepts any input. Severity: Medium. Blocks: no.\n\nRecommendation: fix the guard because it fails open' : cleanReply(t)), epoch: Date.now() }); + const base = { base: 'main', out, pass, planFlags: ['--depth-floor', 'full'] }; + expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)'); + let res = ''; + for (let i = 0; i < 6; i++) { + res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 }); + if (!res.includes('NEXT: poll')) break; + } + expect(res).not.toContain('STOP:'); + expect(res).not.toContain('COLLECT_UNAVAILABLE: reader=outside-voice'); + expect(res).toContain('OUTSIDE_RECORD: "outside_provider":"host-subagent","outside_model":"openai/gpt-6.1-sol","outside_status":"completed"'); + expect(res).toContain('NEXT: judge the voices'); + } + }, 600_000); + + // Value: protects=GST-1104 review finding: an outside voice that ends stopped or failed with a summary that is not a review is recorded unavailable and Step 11 goes on; fails_when=collect's COLLECT_NOT_REVIEWED stops the pass and every rerun stops the same way; + // why_new=GST-1104 /ship review round 2; seam=lib/capy-review-pass.js reader collect; no_claim=what the summary says + test('an outside voice that ends stopped with a non-review summary is recorded unavailable, not a stuck pass (GST-1104)', async () => { + const { dir, env } = repo(); + const out = path.join(dir, '.state/run/p1'); + const h = host(dir, env, { stopped: (t: string) => t.endsWith('outside-voice'), keepSummary: true, output: (t: string) => (t.endsWith('outside-voice') ? 'Stopped before I could read the diff.' : cleanReply(t)), epoch: Date.now() }); + const base = { base: 'main', out, pass: 'x35p1', planFlags: ['--depth-floor', 'full'] }; + expect(await runPass(h, base)).toContain('NEXT: judge (Phase 4)'); + let res = ''; + for (let i = 0; i < 6; i++) { + res = await runPass(h, { ...base, stage: 'voices', stuckMs: 60_000 }); + if (!res.includes('NEXT: poll')) break; + } + expect(res).not.toContain('STOP:'); + expect(res).toContain('COLLECT_UNAVAILABLE: reader=outside-voice'); + expect(res).toContain('"outside_status":"unavailable"'); + expect(res).toContain('NEXT: judge the voices'); + const v = bin(dir, env, ['verify', '--ledger', path.join(out, 'review-ledger.jsonl')]); + expect(v.stdout).toMatch(/^BRIEF outside-voice UNAVAILABLE/m); + expect(v.stdout).not.toContain('MISMATCH'); + expect(v.stdout).not.toContain('NOT_REVIEWED'); + }, 300_000); + test('an audit reader marked first settles before any specialist starts; its output is returned, never merged', async () => { const { dir, env } = repo(); const out = path.join(dir, '.state/run/p1'); From e4e9913398e3b11a445bb5706bd387b4be5d38c4 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 19:14:57 -0800 Subject: [PATCH 3/6] v1.93.40.0 fix(ship): Step 9.2.1 QA reports go to a git-excluded run dir, not the product tree (GST-969) (#3898) * fix(ship): Step 9.2.1 QA writes reports under a git-excluded run dir, not the product tree (GST-969) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: harden report-dir (linked .gstack, .gitignore negation, error cause) per Step 11 voices Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CHANGELOG fragment for GST-969 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: move the QA report-dir fallback into the shared exploratory section (review-army.md stays at its no-loss pin); classify qa-reports for gstack-clean Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 6 ++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- lib/qa-evidence.ts | 38 +++++++++- package.json | 2 +- qa/sections/exploratory.md | 2 +- scripts/resolvers/qa.ts | 2 +- test/gstack-clean-producers.test.ts | 1 + test/qa-report-dir.test.ts | 104 ++++++++++++++++++++++++++++ 9 files changed, 153 insertions(+), 6 deletions(-) create mode 100644 test/qa-report-dir.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index bbdc69e7b..88736099e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [1.93.40.0] - 2026-11-03 + +### Fixed + +- **/ship and /review exploratory QA no longer write reports into your project (GST-969).** /ship Step 9.2.1 and /review Step 4.7 used to put its QA reports, deadline file and captured evidence in `.gstack/qa-reports/` inside the repository under review. In a project that doesn't ignore `.gstack/`, those files showed up as untracked changes, so they could land in the PR and change the tree the review certified. The new `gstack-qa-evidence report-dir` command creates a fresh run directory under `.gstack/tmp/qa-reports/` and adds `/.gstack/tmp/` to the repository's git exclude file, and both QA steps now use it. It refuses a symlinked `.gstack`, a `.gitignore` rule that un-ignores `.gstack/tmp`, and a directory outside a git repository. /qa keeps its `.gstack/qa-reports` output directory. + ## [1.93.39.0] - 2026-11-03 **/ship on Capy stops an outside voice that hangs and records it as missing, never as converged or as an unavailable Codex CLI (GST-1104).** TRUT-7's /ship run had two outside voices end with no result (gpt-6.1-sol stopped after 20 minutes; grok-4.7 used 16.9M tokens before it was stopped), and its Step 11 row read `outside_provider: codex`, `outside_status: unavailable`, `converged: true`. diff --git a/VERSION b/VERSION index 06dc54ecd..5ebe98992 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.93.39.0 +1.93.40.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index 5c25e2c05..937952f0e 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.93.39.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.93.40.0 — regenerate/re-copy after upgrading gstack Behavioral rules from gstack (https://github.com/garrytan/gstack), compressed for agent hosts without a full skill install. The full skills add workflows, diff --git a/lib/qa-evidence.ts b/lib/qa-evidence.ts index 4fc9eead6..841cb2354 100644 --- a/lib/qa-evidence.ts +++ b/lib/qa-evidence.ts @@ -388,7 +388,37 @@ function materialize(root: string, source: string) { next: `Include every reportLinks entry in the Markdown report, and report the overall status as ${verdict.status}${verdict.open.length ? ` (open: ${verdict.open.join('; ')})` : ''}; this verdict is final. Next, write the Markdown report beside evidence.json.` }; } -const QA_EVIDENCE_USAGE = 'capture ROOT ID [--public] --deadline FILE|--timeout-ms MS [--after PREVIOUS_CAPTURE --hypothesis TEXT] -- COMMAND ARGS (--after publishes checkpoint ID linking PREVIOUS_CAPTURE to this probe; required after the first complete capture unless a checkpoint was published) | checkpoint ROOT ID CAPTURE OBSERVATION_COMMAND HYPOTHESIS NEXT_COMMAND | checkpoint ROOT ID INTENT_FILE | materialize ROOT ANNOTATIONS (annotations: {evidence: [{capture, command, contract, expected, classification: pass|superseded|product-defect|fail|setup-blocked|blocked|inconclusive}], limits: [..]}; revision, runtime, cwd and learning are filled in)'; +/** A fresh report root for caller QA (/review and /ship) under the repository's git-excluded .gstack/tmp, so probes never change the reviewed tree. */ +function reportDir(): Record { + const top = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8', timeout: 5000 }); + if (top.status !== 0 || !top.stdout.trim()) throw new QaEvidenceError('report-dir needs a git work tree'); + const repoRoot = fs.realpathSync(top.stdout.trim()); + const exclude = spawnSync('git', ['rev-parse', '--git-path', 'info/exclude'], { encoding: 'utf8', timeout: 5000 }); + if (exclude.status !== 0 || !exclude.stdout.trim()) throw new QaEvidenceError('report-dir cannot locate the git exclude file'); + const excludeFile = path.resolve(exclude.stdout.trim()); + fs.mkdirSync(path.dirname(excludeFile), { recursive: true }); + const excluded = fs.existsSync(excludeFile) ? fs.readFileSync(excludeFile, 'utf8') : ''; + if (!excluded.split(/\r?\n/).includes('/.gstack/tmp/')) fs.appendFileSync(excludeFile, `${excluded && !excluded.endsWith('\n') ? '\n' : ''}/.gstack/tmp/\n`); + const parent = path.join(repoRoot, '.gstack', 'tmp', 'qa-reports'); + for (const dir of [path.join(repoRoot, '.gstack'), path.dirname(parent), parent]) { + try { + if (fs.lstatSync(dir).isSymbolicLink()) throw new QaEvidenceError(`report-dir refuses the linked ${path.relative(repoRoot, dir)}`); + } catch (error: any) { + if (error?.code !== 'ENOENT') throw error; + fs.mkdirSync(dir, { mode: 0o700 }); + } + } + const ignored = spawnSync('git', ['check-ignore', '-q', path.join(parent, 'report.md')], { cwd: repoRoot, encoding: 'utf8', timeout: 5000 }); + if (ignored.status !== 0) throw new QaEvidenceError('report-dir: .gstack/tmp is not git-ignored here (a .gitignore rule overrides info/exclude)'); + const stamp = new Date().toISOString().replace(/[-:]/g, '').replace(/\.\d+Z$/, 'Z'); + for (let n = 1; ; n++) { + const dir = path.join(parent, `run-${stamp}${n > 1 ? `-${n}` : ''}`); + try { fs.mkdirSync(dir, { mode: 0o700 }); } catch (error: any) { if (error?.code === 'EEXIST') continue; throw error; } + return { action: 'report-dir', status: 'complete', reportDir: qaEvidenceRoot(dir), exitCode: 0 }; + } +} + +const QA_EVIDENCE_USAGE = 'report-dir (prints a fresh git-excluded report root for /review and /ship QA) | capture ROOT ID [--public] --deadline FILE|--timeout-ms MS [--after PREVIOUS_CAPTURE --hypothesis TEXT] -- COMMAND ARGS (--after publishes checkpoint ID linking PREVIOUS_CAPTURE to this probe; required after the first complete capture unless a checkpoint was published) | checkpoint ROOT ID CAPTURE OBSERVATION_COMMAND HYPOTHESIS NEXT_COMMAND | checkpoint ROOT ID INTENT_FILE | materialize ROOT ANNOTATIONS (annotations: {evidence: [{capture, command, contract, expected, classification: pass|superseded|product-defect|fail|setup-blocked|blocked|inconclusive}], limits: [..]}; revision, runtime, cwd and learning are filled in)'; export async function qaEvidenceMain(args: string[]): Promise { return withQaReceiptOutput(false, 'qa-evidence-receipt', value => value.event === 'observation' @@ -400,6 +430,12 @@ export async function qaEvidenceMain(args: string[]): Promise { emit('stdout', { action: 'help', status: 'complete', usage: QA_EVIDENCE_USAGE, exitCode: 0 }); return 0; } + if (action === 'report-dir' && args.length === 1) { + let created: Record; + try { created = reportDir(); } catch (error: any) { throw error instanceof QaEvidenceError ? error : new QaEvidenceError(`report-dir failed: ${error?.code ?? 'unknown error'}`); } + emit('stdout', created); + return 0; + } const root = qaEvidenceRoot(reportRoot); let receipt: Record; const publicOutput = action === 'capture' && rest[1] === '--public'; diff --git a/package.json b/package.json index dabdd8dc4..ba4291f7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.93.39", + "version": "1.93.40", "description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.", "license": "MIT", "type": "module", diff --git a/qa/sections/exploratory.md b/qa/sections/exploratory.md index 0c62850b0..1364afdb9 100644 --- a/qa/sections/exploratory.md +++ b/qa/sections/exploratory.md @@ -19,7 +19,7 @@ Missing or unreadable assets, prerequisites or permission block affected probes, ## 1. Charter and preflight -Reuse resolved REPORT_DIR; otherwise own a fresh `.gstack/qa-reports` subdirectory. +Reuse resolved REPORT_DIR; otherwise use the `reportDir` `EVIDENCE_TOOL report-dir` prints. Write a **charter** per behavior: contract, risk, entrypoint, isolation, exit condition, source, commands and inputs. Save charters as Markdown in the report. For /review and /ship, no plan/server is required. diff --git a/scripts/resolvers/qa.ts b/scripts/resolvers/qa.ts index 330b8b43f..76be4da89 100644 --- a/scripts/resolvers/qa.ts +++ b/scripts/resolvers/qa.ts @@ -66,7 +66,7 @@ full contents. If either required Read is missing, complete it now before Charte ## 1. Charter and preflight -Reuse resolved REPORT_DIR; otherwise own a fresh \`.gstack/qa-reports\` subdirectory. +${reportOnly ? 'Reuse resolved REPORT_DIR; otherwise own a fresh \`.gstack/qa-reports\` subdirectory.' : 'Reuse resolved REPORT_DIR; otherwise use the \`reportDir\` \`EVIDENCE_TOOL report-dir\` prints.'} Write a **charter** per behavior: contract, risk, entrypoint, isolation, exit condition, source, commands and inputs. Save charters as Markdown in the report. ${reportOnly ? '' : `For /review and /ship, no plan/server is required. diff --git a/test/gstack-clean-producers.test.ts b/test/gstack-clean-producers.test.ts index daad0df41..937eb19cb 100644 --- a/test/gstack-clean-producers.test.ts +++ b/test/gstack-clean-producers.test.ts @@ -42,6 +42,7 @@ const KEPT: Record = { 'review-*': '/ship review loop records', 'fix-check-*': '/ship fix-check inputs', 'tasks-*': 'gstack-tasks rows files (bin/gstack-tasks)', + 'qa-reports': 'caller QA report runs from gstack-qa-evidence report-dir (lib/qa-evidence.ts)', 'autoplan': 'autoplan phase artifacts (autoplan/SKILL.md.tmpl)', 'eval-bisect': '/investigate eval bisect cache', 'price-gate': 'gstack-eval-plan price receipts', diff --git a/test/qa-report-dir.test.ts b/test/qa-report-dir.test.ts new file mode 100644 index 000000000..97a121703 --- /dev/null +++ b/test/qa-report-dir.test.ts @@ -0,0 +1,104 @@ +import { afterAll, expect, test } from 'bun:test'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import { spawnSync } from 'node:child_process'; + +import { RESOLVERS } from '../scripts/resolvers'; +import { HOST_PATHS, type TemplateContext } from '../scripts/resolvers/types'; + +const BIN = path.resolve(import.meta.dir, '../bin'); +const ROOT = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'qa-report-dir-')); +afterAll(() => fs.rmSync(ROOT, { recursive: true, force: true })); + +const IDENTITY = { GIT_AUTHOR_NAME: 'fixture', GIT_AUTHOR_EMAIL: 'fixture@example.com', GIT_COMMITTER_NAME: 'fixture', GIT_COMMITTER_EMAIL: 'fixture@example.com' }; + +function product() { + const root = fs.mkdtempSync(path.join(ROOT, 'product-')); + const git = (...args: string[]) => { + const r = spawnSync('git', args, { cwd: root, encoding: 'utf8', timeout: 10_000, env: { ...process.env, ...IDENTITY } }); + expect(r.status, r.stderr).toBe(0); + return r.stdout; + }; + git('init', '-q'); + fs.writeFileSync(path.join(root, 'app.ts'), 'export const x = 1;\n'); + git('add', 'app.ts'); + git('commit', '-q', '-m', 'seed'); + const tool = (name: string, ...args: string[]) => { + const r = spawnSync(process.execPath, [path.join(BIN, name), ...args], { cwd: root, encoding: 'utf8', timeout: 15_000 }); + expect(r.error, r.error?.message).toBeUndefined(); + return r; + }; + const tree = () => git('status', '--porcelain', '--untracked-files=all', '--ignored=no') + git('ls-files', '--others', '--exclude-standard'); + return { root, tool, tree }; +} + +function reportDir(f: ReturnType): string { + const r = f.tool('gstack-qa-evidence', 'report-dir'); + expect(r.status, r.stderr).toBe(0); + return JSON.parse(r.stdout.trim().slice('QA_EVIDENCE '.length)).reportDir; +} + +test('the /ship QA report root leaves a product tree without a .gstack ignore rule unchanged', () => { + const f = product(); + expect(f.tree()).toBe(''); + const dir = reportDir(f); + expect(path.relative(f.root, dir).split(path.sep).slice(0, 3)).toEqual(['.gstack', 'tmp', 'qa-reports']); + const deadline = path.join(dir, 'deadline.json'); + expect(f.tool('gstack-qa-deadline', 'start', deadline, '300').status).toBe(0); + const capture = f.tool('gstack-qa-evidence', 'capture', dir, '001', '--public', '--deadline', deadline, '--', process.execPath, '-e', 'console.log(JSON.stringify({ ok: true }))'); + expect(capture.status, capture.stderr).toBe(0); + fs.writeFileSync(path.join(dir, 'report.md'), '## Exploratory QA\n'); + expect(f.tree()).toBe(''); +}); + +test('each report-dir call owns a fresh run so a second QA run never overwrites the first', () => { + const f = product(); + const first = reportDir(f); + const second = reportDir(f); + expect(second).not.toBe(first); + expect(fs.readdirSync(first)).toEqual([]); + expect(fs.readdirSync(second)).toEqual([]); +}); + +test('report-dir refuses a linked .gstack instead of creating directories through it', () => { + const f = product(); + const elsewhere = fs.mkdtempSync(path.join(ROOT, 'elsewhere-')); + fs.symlinkSync(elsewhere, path.join(f.root, '.gstack')); + const r = f.tool('gstack-qa-evidence', 'report-dir'); + expect(r.status).toBe(2); + expect(r.stderr).toContain('report-dir refuses the linked .gstack'); + expect(fs.readdirSync(elsewhere)).toEqual([]); +}); + +test('report-dir refuses when a product .gitignore un-ignores .gstack/tmp', () => { + const f = product(); + fs.writeFileSync(path.join(f.root, '.gitignore'), '!/.gstack/tmp/\n!/.gstack/tmp/**\n'); + const r = f.tool('gstack-qa-evidence', 'report-dir'); + expect(r.status).toBe(2); + expect(r.stderr).toContain('.gstack/tmp is not git-ignored here'); +}); + +test('report-dir names the filesystem cause when .gstack is not a directory', () => { + const f = product(); + fs.writeFileSync(path.join(f.root, '.gstack'), 'not a directory\n'); + const r = f.tool('gstack-qa-evidence', 'report-dir'); + expect(r.status).toBe(2); + expect(r.stderr).toContain('report-dir failed: ENOTDIR'); +}); + +test('report-dir refuses outside a git work tree instead of guessing a location', () => { + const outside = fs.mkdtempSync(path.join(ROOT, 'plain-')); + const r = spawnSync(process.execPath, [path.join(BIN, 'gstack-qa-evidence'), 'report-dir'], { cwd: outside, encoding: 'utf8', timeout: 15_000, env: { ...process.env, GIT_CEILING_DIRECTORIES: ROOT } }); + expect(r.status).toBe(2); + expect(r.stderr).toContain('report-dir needs a git work tree'); + expect(fs.readdirSync(outside)).toEqual([]); +}); + +test('caller QA without a resolved REPORT_DIR (/review, /ship) falls back to report-dir, not the product tree', () => { + const line = 'Reuse resolved REPORT_DIR; otherwise use the `reportDir` `EVIDENCE_TOOL report-dir` prints.'; + const ctx: TemplateContext = { host: 'claude', skillName: 'qa', tmplPath: '', paths: HOST_PATHS.claude }; + expect(RESOLVERS.QA_EXPLORATORY(ctx)).toContain(line); + expect(fs.readFileSync(path.resolve(import.meta.dir, '../qa/sections/exploratory.md'), 'utf8')).toContain(line); + expect(fs.readFileSync(path.resolve(import.meta.dir, '../qa/SKILL.md.tmpl'), 'utf8')).toContain('Use the directory as `REPORT_DIR`'); +}); From 106fd394466eeb0b43cf417d81ad4c842811f8c1 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 19:24:35 -0800 Subject: [PATCH 4/6] v1.93.41.0 Codex outside reviews report their token usage (#2948) (#3729) * outside-review-result: one Codex usage parser and an OUTSIDE_USAGE line (#2948) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: troubleshooting names the OUTSIDE_USAGE line (#2948) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: the generated Codex plan-review invocation prints OUTSIDE_USAGE (#2948) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 10 ++++++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- docs/troubleshooting.md | 4 ++- lib/outside-review-result.ts | 42 +++++++++++++++++++++++-- lib/outside-voice-runner.ts | 21 +++---------- package.json | 2 +- test/outside-review-result.test.ts | 32 ++++++++++++++++++- test/run-in-background-guidance.test.ts | 4 +-- 9 files changed, 93 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88736099e..eb22d4629 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [1.93.41.0] - 2026-11-03 + +**Codex outside reviews report their token usage (#2948).** Codex already emits token counts in its `--json` events, and gstack used to throw them away. When `lib/outside-review-result.ts` is given an events file, it now prints `OUTSIDE_USAGE: input=… cached_input=… output=… reasoning_output=…` (only the counters Codex reported), or `OUTSIDE_USAGE: unknown`, on every verdict. + +### Changed +- **Every Codex outside voice that runs `codex exec --json`** (/review, /ship, /autoplan, the plan reviews) now prints one more stdout line, `OUTSIDE_USAGE:`, after `VERDICT:` and `FINDINGS:`. +- **One usage parser** (`usageFromEvents`, now in `lib/outside-review-result.ts` and re-exported by `lib/outside-voice-runner.ts`). A cumulative `total_token_usage` snapshot wins; without one, the latest `turn.completed` usage does, because Codex reports the session's running total there. It adds cached, cache-write, reasoning and total counters when the events carry them. + +Thanks to @omicron-soft for the report. Storing usage in review-log rows, the native `codex review` path and a token column in /ship come in a follow-up. + ## [1.93.40.0] - 2026-11-03 ### Fixed diff --git a/VERSION b/VERSION index 5ebe98992..abacf7c40 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.93.40.0 +1.93.41.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index 937952f0e..3bab33017 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.93.40.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.93.41.0 — regenerate/re-copy after upgrading gstack Behavioral rules from gstack (https://github.com/garrytan/gstack), compressed for agent hosts without a full skill install. The full skills add workflows, diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 56add0826..5a9bf8fb5 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -146,7 +146,9 @@ record. Another successful fetch alone cannot certify corrupted history. Outside reviews send your diff, plan or question to a second AI provider. Their verdict comes from `lib/outside-review-result.ts`, which prints -`VERDICT: clean|findings|unverified|unavailable`. A `findings` verdict with a +`VERDICT: clean|findings|unverified|unavailable`. When given an events file, it +also prints `OUTSIDE_USAGE:` with the token counters Codex reported, or +`OUTSIDE_USAGE: unknown` when it reported none. A `findings` verdict with a P0 or P1 finding blocks exactly like a native P0/P1. `unverified` and `unavailable` are missing coverage: /ship and /review continue, show the gap in the readiness dashboard and the PR body, and never count it as a pass. diff --git a/lib/outside-review-result.ts b/lib/outside-review-result.ts index c09ffb9a5..397c94ba2 100644 --- a/lib/outside-review-result.ts +++ b/lib/outside-review-result.ts @@ -297,6 +297,43 @@ const LEGACY_REASONS: Partial> = { review_refused: 'review refused', }; +export interface TokenUsage { + input_tokens?: number; cached_input_tokens?: number; cache_write_input_tokens?: number; + output_tokens?: number; reasoning_output_tokens?: number; total_tokens?: number; usd: number | 'unknown'; +} +const USAGE_COUNTERS = ['input_tokens', 'cached_input_tokens', 'cache_write_input_tokens', 'output_tokens', 'reasoning_output_tokens', 'total_tokens'] as const; + +/** + * Token usage from `codex exec --json` events, read loosely. A cumulative + * `total_token_usage` snapshot (info, payload.info or msg.info) wins, latest first; + * without one, the latest `usage` object does: codex exec fills turn.completed.usage + * with the session's running total, so summing turns would overcount. Only the + * counters the events carry are reported. + */ +export function usageFromEvents(events: string): TokenUsage { + let cumulative: Record | undefined; + let latest: Record = {}; + for (const line of events.split('\n')) { + if (!line.trim()) continue; + let obj: any; + try { obj = JSON.parse(line); } catch { continue; } + const snapshot = obj?.info?.total_token_usage ?? obj?.payload?.info?.total_token_usage ?? obj?.msg?.info?.total_token_usage; + if (snapshot && typeof snapshot === 'object') { cumulative = snapshot; continue; } + if (!obj?.usage || typeof obj.usage !== 'object') continue; + latest = obj.usage; + } + const source = cumulative ?? latest; + const usage: TokenUsage = { usd: 'unknown' }; + for (const key of USAGE_COUNTERS) if (typeof source[key] === 'number') usage[key] = source[key] as number; + return usage; +} + +/** The OUTSIDE_USAGE line: counters the events carried, or `unknown` when they carried none. */ +export function formatUsageLine(usage: TokenUsage): string { + const parts = USAGE_COUNTERS.filter(key => usage[key] !== undefined).map(key => `${key.replace(/_tokens$/, '')}=${usage[key]}`); + return `OUTSIDE_USAGE: ${parts.length ? parts.join(' ') : 'unknown'}`; +} + /** Text-only compatibility shape for direct importers (claude-code/SKILL.md.tmpl) and the two-argument CLI. */ export function validateOutsideReview(text: string, gate: OutsideGate): { completed: boolean; reason?: string; score?: number; gate?: 'pass' | 'fail' } { const checked = classifyOutsideReview({ text, gate }); @@ -347,12 +384,13 @@ if (import.meta.main) { if (!result.completed) { console.error(`Outside review unavailable: ${result.reason}; missing coverage.`); process.exit(1); } process.exit(0); } - const checked = classifyOutsideReview({ text, gate: gate as OutsideGate, exit, - stderr: await readOptional(flags['--stderr']), events: await readOptional(flags['--events']) }); + const events = await readOptional(flags['--events']); + const checked = classifyOutsideReview({ text, gate: gate as OutsideGate, exit, stderr: await readOptional(flags['--stderr']), events }); const label = flags['--label'] ?? 'Outside review'; console.log(`VERDICT: ${checked.verdict}`); console.log(`FINDINGS: ${checked.findings.highest ?? (checked.verdict === 'findings' ? 'unspecified' : 'none')}`); if (checked.unparsed) console.log(`UNPARSED: ${checked.unparsed}`); + if (flags['--events'] !== undefined) console.log(formatUsageLine(usageFromEvents(events))); if (checked.reason) { console.log(`REASON: ${checked.reason}`); console.error(gateOutcomeLine(label, checked.reason, checked.detail)); diff --git a/lib/outside-voice-runner.ts b/lib/outside-voice-runner.ts index 1ac6d569d..728dd0ec7 100644 --- a/lib/outside-voice-runner.ts +++ b/lib/outside-voice-runner.ts @@ -18,7 +18,9 @@ import { createHash } from 'node:crypto'; import * as fs from 'node:fs'; import * as path from 'node:path'; -import { classifyOutsideReview, type OutsideGate, type OutsideReviewClassification } from './outside-review-result'; +import { classifyOutsideReview, usageFromEvents, type OutsideGate, type OutsideReviewClassification, type TokenUsage } from './outside-review-result'; + +export { usageFromEvents }; export type RunnerId = 'codex-cli' | 'api' | 'host-subagent'; export const RUNNER_IDS: readonly RunnerId[] = ['codex-cli', 'api', 'host-subagent']; @@ -43,7 +45,7 @@ export interface RunnerRequest { binDir?: string; } export type RunnerStatus = 'completed' | 'unverified' | 'unavailable' | 'failed' | 'timeout' | 'cancelled'; -export interface RunnerUsage { input_tokens?: number; output_tokens?: number; usd: number | 'unknown' } +export type RunnerUsage = TokenUsage; export interface RunnerResult { schema_version: 1; runner: RunnerId; status: RunnerStatus; model: string | null; family: ModelFamily; capabilities: RunnerCapabilities; input_sha256: string; output_sha256: string | null; output: string | null; @@ -104,21 +106,6 @@ function classify(text: string, gate: OutsideGate, extra: { stderr?: string; exi return { status, verdict }; } -/** Token usage from `codex exec --json` events, read loosely: any object carrying usage counters. */ -export function usageFromEvents(events: string): RunnerUsage { - let input: number | undefined; let output: number | undefined; - for (const line of events.split('\n')) { - if (!line.trim()) continue; - let obj: any; - try { obj = JSON.parse(line); } catch { continue; } - const usage = obj?.usage ?? obj?.info?.total_token_usage ?? obj?.payload?.info?.total_token_usage ?? obj?.msg?.info?.total_token_usage; - if (!usage || typeof usage !== 'object') continue; - if (typeof usage.input_tokens === 'number') input = usage.input_tokens; - if (typeof usage.output_tokens === 'number') output = usage.output_tokens; - } - return { ...(input !== undefined ? { input_tokens: input } : {}), ...(output !== undefined ? { output_tokens: output } : {}), usd: 'unknown' }; -} - // --------------------------------------------------------------------------- // codex-cli: today's path, as one process this module can cancel // --------------------------------------------------------------------------- diff --git a/package.json b/package.json index ba4291f7c..f27bcb93f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.93.40", + "version": "1.93.41", "description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.", "license": "MIT", "type": "module", diff --git a/test/outside-review-result.test.ts b/test/outside-review-result.test.ts index 572b90f30..e9550285b 100644 --- a/test/outside-review-result.test.ts +++ b/test/outside-review-result.test.ts @@ -8,7 +8,7 @@ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { spawnSync } from 'node:child_process'; -import { classifyOutsideReview, validateOutsideReview, type OutsideGate } from '../lib/outside-review-result'; +import { classifyOutsideReview, usageFromEvents, validateOutsideReview, type OutsideGate } from '../lib/outside-review-result'; import { gateOutcomeLine, type GateReason } from '../lib/gate-outcomes'; const ROOT = path.resolve(import.meta.dir, '..'); @@ -262,6 +262,36 @@ describe('B1: a review whose sandbox could not start is unavailable, not clean', }); }); +describe('Codex token usage from --json events (#2948)', () => { + const turn = (usage: Record) => JSON.stringify({ type: 'turn.completed', usage }); + + test('one turn: every counter the event carries, nothing invented', () => { + expect(usageFromEvents(turn({ input_tokens: 12016, cached_input_tokens: 0, cache_write_input_tokens: 12013, output_tokens: 5, reasoning_output_tokens: 0 }))) + .toEqual({ input_tokens: 12016, cached_input_tokens: 0, cache_write_input_tokens: 12013, output_tokens: 5, reasoning_output_tokens: 0, usd: 'unknown' }); + }); + + test('the latest turn wins (codex reports the running session total); malformed and unrelated lines are skipped', () => { + const events = [turn({ input_tokens: 100, output_tokens: 10 }), 'not json', '{"type":"item.completed","item":{"type":"agent_message"}}', turn({ input_tokens: 150, output_tokens: 15, reasoning_output_tokens: 2 })].join('\n'); + expect(usageFromEvents(events)).toEqual({ input_tokens: 150, output_tokens: 15, reasoning_output_tokens: 2, usd: 'unknown' }); + }); + + test('a cumulative total_token_usage snapshot wins over per-turn usage, latest first', () => { + const snap = (n: number) => JSON.stringify({ msg: { type: 'token_count', info: { total_token_usage: { input_tokens: n, output_tokens: n / 10, total_tokens: n * 1.1 } } } }); + expect(usageFromEvents([turn({ input_tokens: 7 }), snap(100), snap(300)].join('\n'))).toEqual({ input_tokens: 300, output_tokens: 30, total_tokens: 330, usd: 'unknown' }); + }); + + test('the CLI prints OUTSIDE_USAGE only when given --events, on every verdict', () => { + const events = path.join(TMP, 'usage-events.jsonl'); + fs.writeFileSync(events, turn({ input_tokens: 1200, cached_input_tokens: 200, output_tokens: 340 }) + '\n'); + const withEvents = cli(['--events', events, 'review', file('No issues found.')]); + expect(withEvents.stdout).toContain('OUTSIDE_USAGE: input=1200 cached_input=200 output=340\n'); + const empty = path.join(TMP, 'no-usage.jsonl'); + fs.writeFileSync(empty, '{"type":"thread.started"}\n'); + expect(cli(['--events', empty, 'review', file('')]).stdout).toContain('OUTSIDE_USAGE: unknown\n'); + expect(cli(['--verdict', 'review', file('No issues found.')]).stdout).not.toContain('OUTSIDE_USAGE'); + }); +}); + describe('a mid-run Codex usage limit is unavailable (quota_exhausted); a mid-run 429 is unavailable (rate_limited)', () => { const LINE = "ERROR: You've hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at Oct 10th, 2026 2:55 AM."; const RATE_429 = 'ERROR: {"type":"error","status":429,"error":{"type":"rate_limit_exceeded","message":"Rate limit reached"}}'; diff --git a/test/run-in-background-guidance.test.ts b/test/run-in-background-guidance.test.ts index 5851cb6ea..8475a2661 100644 --- a/test/run-in-background-guidance.test.ts +++ b/test/run-in-background-guidance.test.ts @@ -107,8 +107,8 @@ exec ${quote(Bun.which('cat')!)} "$@" const findings = (id: string) => `${id}: current findings\nNo issues found.\nRecommendation: fix ${id} because this is the current finding.\n`; // INV-1: the verdict-form validator prints its verdict before the completed status. - const unavailable = (id: string) => `${findings(id)}VERDICT: unavailable\nFINDINGS: none\nREASON: execution_failed\n`; - const completed = (id: string) => `${findings(id)}VERDICT: clean\nFINDINGS: none\nOUTSIDE_STATUS: completed provider=codex host=claude\n`; + const unavailable = (id: string) => `${findings(id)}VERDICT: unavailable\nFINDINGS: none\nOUTSIDE_USAGE: unknown\nREASON: execution_failed\n`; + const completed = (id: string) => `${findings(id)}VERDICT: clean\nFINDINGS: none\nOUTSIDE_USAGE: unknown\nOUTSIDE_STATUS: completed provider=codex host=claude\n`; test('fresh shells retain the current stderr and clean its exact temporary file', () => { const f = fixture(); From b42ad1e300fad1641ef1bc65c876701d235d921d Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 19:34:35 -0800 Subject: [PATCH 5/6] v1.93.42.0 fix(stamp): name branch lines by position; carry and finish accept a kept VERSION claim (GST-979, GST-980) (#3889) * fix(stamp): name branch lines by position; carry and finish accept a kept VERSION claim (GST-979, GST-980) BranchSide carries the positions of the branch-added lines and stampOnlyLine takes the removed line position, so a base line whose text duplicates a branch line keeps the old-version floor. At equal versions only the branch own lines may move. stampOnlyText and stampedFiles accept a kept claim for those lines, and the carry leaves a stamp file out of the product comparison when its only change since the reviewed head is a stamp on the branch own rows and the base did not touch it. Failing-first: all five new tests fail on main fc292e22f. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (GST-980 carry reads the stamp file line by line at the branch's positions, and keeps its mode) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(changelog): GST-979/980 entry counts the seven tests Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: the receipt carry follows a stamp on the branch's own rows (GST-980) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: keep docs/ship-policy.md at the reviewed text; its GST-980 sentence already states the carry rule Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Revert "docs: keep docs/ship-policy.md at the reviewed text; its GST-980 sentence already states the carry rule" This reverts commit f926ccb0c206ce9b1cf2387f3500558a20102510. --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 17 ++++ VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- bin/gstack-ship-receipt | 32 +++++-- docs/ship-policy.md | 3 +- docs/troubleshooting.md | 6 +- lib/restamp.ts | 15 ++-- lib/ship-bin-common.ts | 9 +- lib/ship-receipt.ts | 19 ++-- lib/stamp-only.ts | 27 +++--- lib/tree-receipt.ts | 2 +- package.json | 2 +- test/gstack-ship-receipt-docs.test.ts | 19 +++- test/restamp-mentions.test.ts | 102 ++++++++++++++++++++++ test/ship-rereview-triggers.test.ts | 18 ++++ test/tree-receipt-stamp-sensitive.test.ts | 16 ++++ 16 files changed, 250 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb22d4629..b27b94ae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [1.93.42.0] - 2026-11-03 + +**The stamp checks name the branch's lines by position, and the carry and finish accept a kept VERSION claim (GST-979, GST-980).** After GST-963, three gaps were left in the checks that accept a stamp commit, all found by the #3862 reviewers. A base line whose text duplicated a line the branch added got the branch's fork-version bound, so a hand edit of that base copy passed the tree receipt. When a train slot kept its claimed VERSION, a base line moved down to that version also read as a stamp. And the /ship receipt carry and finish refused the fork-version row move the restamp now makes: the carry kept the branch-added row in both product patch-ids (`RECEIPT_CARRY_PRODUCT_CHANGED`), and with a kept VERSION claim the carry and finish read every change as product or behavior. + +### Fixed +- **`lib/stamp-only.ts`:** `BranchSide` carries the positions of the branch's lines, and `stampOnlyLine` takes the removed line's position. Only a line at a branch-added position gets the fork-version bound. When the version does not move, only such a line may change. +- **`lib/restamp.ts`:** `parseUnifiedDiff` records each removed line's position on the old side, which the tree receipt, the train checks and finish's `stampedFiles` pass along. +- **`lib/ship-receipt.ts`, `lib/ship-bin-common.ts`:** `stampOnlyText` and `stampedFiles` accept a kept VERSION claim for the branch's own rows and nothing else. +- **`bin/gstack-ship-receipt` carry:** a stamp file the branch changed as product, whose only change since the reviewed head is a stamp on its own rows and which the base did not touch, is left out of the product comparison. The carry records `a stamp on the branch's own rows ()` as the reason. It reads that file line by line. Only lines at the branch's own positions may move, and the file must keep its reviewed mode, so a version edit on a base line of the same file or a mode change still refuses, as does a product edit anywhere else. + +### Tests +- `test/tree-receipt-stamp-sensitive.test.ts`: the bound holds only at the branch line's position, and a kept VERSION refuses a base line moved down. +- `test/restamp-mentions.test.ts`: a hand move of a base row whose text the branch duplicates reads `TREE: changed`, and the carry follows the fork-version row stamp but still refuses a product edit beside it, a hand version edit on a base line of the same file, and a mode change. +- `test/gstack-ship-receipt-docs.test.ts`, `test/ship-rereview-triggers.test.ts`: the carry classifier and finish accept the kept-claim row move and refuse a base row moved the same way. + +On main, five of the seven new tests fail. The other two, the carry's refusals of a base-line version edit and a mode change, pass on main, which refuses every such carry; they fail on the broader first version of this fix. + ## [1.93.41.0] - 2026-11-03 **Codex outside reviews report their token usage (#2948).** Codex already emits token counts in its `--json` events, and gstack used to throw them away. When `lib/outside-review-result.ts` is given an events file, it now prints `OUTSIDE_USAGE: input=… cached_input=… output=… reasoning_output=…` (only the counters Codex reported), or `OUTSIDE_USAGE: unknown`, on every verdict. diff --git a/VERSION b/VERSION index abacf7c40..e39764546 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.93.41.0 +1.93.42.0 diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.md index 3bab33017..693260e81 100644 --- a/agents-digest/gstack-AGENTS.md +++ b/agents-digest/gstack-AGENTS.md @@ -1,4 +1,4 @@ -# gstack digest v1.93.41.0 — regenerate/re-copy after upgrading gstack +# gstack digest v1.93.42.0 — regenerate/re-copy after upgrading gstack Behavioral rules from gstack (https://github.com/garrytan/gstack), compressed for agent hosts without a full skill install. The full skills add workflows, diff --git a/bin/gstack-ship-receipt b/bin/gstack-ship-receipt index 9e417faa9..5fda9dcb6 100755 --- a/bin/gstack-ship-receipt +++ b/bin/gstack-ship-receipt @@ -37,7 +37,7 @@ import * as path from 'node:path'; import { EXIT, exitTableHelp, type ShipReceipt } from '../lib/headless-artifacts'; import { resultLine, resultLineWithDocs } from '../lib/result-codes'; import { versionAtRef } from '../lib/restamp'; -import { branchSides, type BranchSide } from '../lib/stamp-only'; +import { branchSides, stampOnlyLine, type BranchSide } from '../lib/stamp-only'; import { runScriptSync } from '../lib/script-invocation'; import { readPregateFile, verifyPregate } from '../lib/pregate/index'; import { isUnavailable, loadPolicyFromBase, matchesAny, policyUnavailableLine, resolveBaseBranch, runningGstackVersion, stampFilesInTree, validatePolicy, type ShipPolicy } from '../lib/ship-policy'; @@ -516,7 +516,7 @@ function productRules(repoRoot: string, base: string, outputs: readonly string[] * change, such as a CHANGELOG fragment next to the base's changelog.d/README.md * (GST-343, #3606), into the product patch-id at one head only. */ -function productSpec(repoRoot: string, rules: ProductRules, from: string, to: string, branch?: { touched: ReadonlySet; sides: ReadonlyArray; own: (rel: string) => BranchSide | undefined }): { changed: Array<{ path: string; class: ReturnType }>; product: string[]; tests: string[] } | undefined { +function productSpec(repoRoot: string, rules: ProductRules, from: string, to: string, branch?: { touched: ReadonlySet; sides: ReadonlyArray; own: (rel: string) => BranchSide | undefined }): { changed: Array<{ path: string; class: ReturnType }>; product: string[]; tests: string[]; demoted: string[]; ownRows: string[] } | undefined { const changedRaw = git(['diff', '--name-only', from, to], repoRoot); if (changedRaw === undefined) return undefined; const blobAt = (ref: string, p: string): string | null => { const r = spawnSync('git', ['show', `${ref}:${p}`], { cwd: repoRoot, encoding: 'utf8', timeout: 30_000, maxBuffer: 16 * 1024 * 1024 }); return r.status === 0 ? r.stdout : null; }; @@ -534,7 +534,19 @@ function productSpec(repoRoot: string, rules: ProductRules, from: string, to: st const demoted = !branch ? changed.filter(c => c.class === 'product' && matchesAny(rules.metadata, c.path)).map(c => c.path) : [...branch.touched].filter(p => stamped(p) && (changed.some(c => c.path === p && c.class === 'product') || branch.sides.some(([a, b]) => blobAt(a, p) !== blobAt(b, p) && classify(p, a, b) === 'product'))); const metadataGlobs = rules.metadata.filter(g => !demoted.some(p => matchesAny([g], p))); - return { changed, product: ['.', ...excludeGlobs(CARRY_TEST_GLOBS), ...excludeGlobs(metadataGlobs)], tests: [...CARRY_TEST_GLOBS.map(g => `:(glob)${g}`), ...excludeGlobs(metadataGlobs)] }; + // A demoted path whose from-to change is, line for line, a stamp on the branch's own rows (named by their position in + // `from`), a regular file with the reviewed mode at both heads (GST-980): never the whole-text version swap. + const ownRows = demoted.filter(p => { + const side = branch?.own(p); + const mode = (ref: string) => /^(100644|100755) blob /.exec(git(['ls-tree', ref, '--', p], repoRoot) ?? '')?.[1]; + const before = blobAt(from, p), after = blobAt(to, p), oldVersion = version(from), newVersion = version(to); + if (!side || before === null || after === null || !oldVersion || !newVersion || !mode(from) || mode(from) !== mode(to)) return false; + const was = before.split('\n'); + const now = after.split('\n'); + const lines = was.map((_, i) => i).filter(i => was[i] !== now[i]); + return was.length === now.length && lines.length > 0 && lines.every(i => side.at.has(i + 1) && stampOnlyLine(was[i]!, now[i]!, oldVersion, newVersion, rules.templates, side, i + 1)); + }); + return { changed, product: ['.', ...excludeGlobs(CARRY_TEST_GLOBS), ...excludeGlobs(metadataGlobs)], tests: [...CARRY_TEST_GLOBS.map(g => `:(glob)${g}`), ...excludeGlobs(metadataGlobs)], demoted, ownRows }; } /** A commit's product patch-id against its merge base with the base ('' for no product diff), as write records it and a rewritten-history carry recomputes it. */ @@ -665,6 +677,7 @@ function cmdCarry(rest: string[], json: boolean): number { const current = retarget ? headPatch : productHead; const changedProduct: string[] = []; const contextPaths: string[] = []; + const stampOnly: string[] = []; if (retarget && reviewed !== current) changedProduct.push(`HEAD's product diff against ${base} is not the one reviewed against ${reviewedBase} (the parent has not fully landed on ${base}, or the branch changed since)`); else if (productFrom !== productHead && !retarget) { // planCarry names at most CARRY_NAMED_PATHS differing paths, so the walk stops there, and it reads only the paths the @@ -676,22 +689,27 @@ function cmdCarry(rest: string[], json: boolean): number { const moved = [touchedPaths(repoRoot, from, head), touchedPaths(repoRoot, fromBase, headBase)]; if (moved.some(l => !l)) return refused('RECEIPT_CARRY_REFUSED', `git could not list the paths the branch touched against ${base}; run /ship on ${head.slice(0, 12)}`); const [movedHead, movedBase] = moved as Set[]; + // A stamp file the branch changed as product (its own row) whose reviewed-to-current change is a stamp on its own lines + // and that the base did not touch holds no unreviewed change, so the comparison leaves its bytes out (GST-980). for (const p of [...touched].filter(p => movedHead.has(p) || movedBase.has(p)).sort()) { if (changedProduct.length >= CARRY_NAMED_PATHS) break; const cls = changed.find(c => c.path === p)?.class ?? classifyCarryPath(p, rules.extra); + if (cls === 'metadata' && spec.ownRows.includes(p) && !movedBase.has(p)) stampOnly.push(p); if (cls !== 'product') continue; const verdict = comparePath(repoRoot, sides, p); if (verdict === 'changed') changedProduct.push(p); else if (verdict === 'context') contextPaths.push(p); } - if (!changedProduct.length && !contextPaths.length) changedProduct.push('(a product path outside the branch\'s touched files; compare the two base diffs)'); + const left = [...contextPaths, ...stampOnly]; + if (!changedProduct.length && !left.length) changedProduct.push('(a product path outside the branch\'s touched files; compare the two base diffs)'); else if (!changedProduct.length) { - const rest = [...spec.product, ...contextPaths.map(p => `:(exclude,literal)${p}`)]; + const rest = [...spec.product, ...left.map(p => `:(exclude,literal)${p}`)]; const restFrom = patchId(repoRoot, fromBase, from, rest); const restHead = patchId(repoRoot, headBase, head, rest); - if (typeof restFrom !== 'string' || typeof restHead !== 'string' || restFrom !== restHead) changedProduct.push(`(a product path outside ${contextPaths.join(', ')}; compare the two base diffs without them)`); + if (typeof restFrom !== 'string' || typeof restHead !== 'string' || restFrom !== restHead) changedProduct.push(`(a product path outside ${left.join(', ')}; compare the two base diffs without them)`); } } + const stampedRows = changedProduct.length ? [] : stampOnly; let scopedReview: string | undefined; const packetBody = !changedProduct.length && contextPaths.length ? contextPacket(repoRoot, { reviewedBase: fromBase, reviewed: from, currentBase: headBase, current: head }, contextPaths) : null; if (packetBody?.over.length) changedProduct.push(...packetBody.over.map(p => `${p} (too large for the scoped review: over ${PACKET_SECTION_CAP} lines in a section)`)); @@ -721,7 +739,7 @@ function cmdCarry(rest: string[], json: boolean): number { // Evidence for the record, never the decision: a slow range-diff is reported unavailable rather than waited for. const rangeRaw = spawnSync('git', ['range-diff', '--no-color', `${fromBase}..${from}`, `${headBase}..${head}`], { cwd: repoRoot, encoding: 'utf8', timeout: 15_000, maxBuffer: 64 * 1024 * 1024 }); const rangeDiff = rangeRaw.status === 0 ? (rangeRaw.stdout.trim().split('\n').slice(0, 20).join('\n') || '(empty: identical ranges)') : `unavailable: ${(rangeRaw.stderr ?? '').trim().split('\n')[0] || (rangeRaw.signal ? `range-diff killed by ${rangeRaw.signal} after 15 s` : 'range-diff failed')}`; - plan = planCarry({ from, head, changed, productPatchId: { from: reviewed as string, head: current as string }, testPatchId: { from: testFrom, head: testHead }, changedProduct, mergeCommits: Number(mergeCommits) || 0, rangeDiff, ...(retarget ? { retargetedFrom: reviewedBase } : {}), ...(scopedReview ? { scopedReview } : {}) }); + plan = planCarry({ from, head, changed, productPatchId: { from: reviewed as string, head: current as string }, testPatchId: { from: testFrom, head: testHead }, changedProduct, mergeCommits: Number(mergeCommits) || 0, rangeDiff, ...(retarget ? { retargetedFrom: reviewedBase } : {}), ...(scopedReview ? { scopedReview } : {}), ...(stampedRows.length ? { stampedRows } : {}) }); } if (!plan.ok) return refused(plan.code, plan.message); // Eligibility is not publication: a receipt that recorded a pregate is rebound only with a pregate current for HEAD, diff --git a/docs/ship-policy.md b/docs/ship-policy.md index d76edb603..a6fcabd18 100644 --- a/docs/ship-policy.md +++ b/docs/ship-policy.md @@ -1503,6 +1503,7 @@ receipt when the base moves: | a rebase or force-push onto a tree the receipt covers, product diff against the new base unchanged | carries (`carry.ancestry: rewritten`) | | any other rebase or force-push | a fresh /ship (`RECEIPT_CARRY_TREE_MISMATCH`) | | a stacked PR whose parent landed (squash or merge), retargeted to the base with the base merged in, HEAD's product diff exactly the one reviewed against the parent branch | carries (reason `stack parent landed`) | +| a stamp on the branch's own rows in a stamp file the branch also changed as product: every changed line at a branch-added position, the file's mode unchanged, the base not touching it, the rest of the product diff unchanged | carries (reason `a stamp on the branch's own rows ()`) | **Stacked PRs (#3570).** A child PR's receipt is written against its parent branch, so its `base` names that branch and its `product_patch_id` is the @@ -1673,7 +1674,7 @@ Stages, each journaled in `.gstack/tmp/restamp-journal.json`: 1. **version**: `gstack-version-bump write --version ` in the staging worktree (VERSION, the manifest, npm lockfiles); skipped when `restamp_command` owns the version. The manifest gets the npm-valid three-part form, except when the policy lists it in `stamp_paths` or `stamp_files` and its copy at the base holds four parts (gbrain's convention): then it keeps the full version (`--manifest-form full`) and the stage detail says so. 2. **release_tool**: the policy command, under the contract below. 3. **changelog**: the PR's `[Unreleased]` or old-version section moves to the top under ``, above its predecessor's entry. A duplicate heading the PR introduces (`CHANGELOG_DUPLICATE_HEADING`: the headings are counted against the base's CHANGELOG at `origin/` and at the fork point, so a version the base already heads twice passes as long as the PR adds no further copy) and a top entry that is not `` (`CHANGELOG_TOP_MISMATCH`) are errors; the section being re-headed itself may exist only once. -4. **stamp_paths**: exact `(was X)`, `since: X` and `vX` rewrites, plus every `stamp_patterns` template, within `stamp_paths` and `stamp_files`. A quote around X in the first two forms is part of the form and is kept as written: `since: 'X'`, `since: "X"`, `(was 'X')` and `(was "X")` move like the bare ones (the shape of a quoted source row such as gbrain's `{ since: '0.60.468.0', … }`), an opened quote must close right after X (`since: '1.2.3-beta'` and `since: '1.2.3"` are not the form, in the writer and in the tree receipt alike), and `vX` already accepts a quote before the `v`. Which X moves is decided by provenance. The branch's own tentative stamp (its VERSION when it moved past base) and `--was `, when given, are each rewritten on every line of every stamp file. Beyond that, only lines the branch itself added are read, by their position in the file (`git diff --unified=0` from the fork point), so a base line with the same text, or a CRLF checkout whose diff is LF-normalized, is told apart: a stamp-form mention there of a version newer than the version at the branch's fork point is a tentative stamp and moves (this is what finds a quoted row after a lost slot and a merge of the base, since the base's release is newer than the fork point), and so does one of the fork-point version itself (a row the branch wrote at the version it forked from instead of a next version is its own stale stamp; a branch-added mention older than the fork point stays), and when the branch has no stamp of its own because its VERSION equals the base's and its fork point is the base itself (a branch rebased onto the base after it reached X, or one never stamped) a mention of the base version on a line it added is its stale stamp and moves too, while the same version on a line the base already carries is the base's release and stays. The stage detail names both counts per file (`VERSION equals base X, so X moved only on lines this branch added and stayed on the base's own lines (: N moved, M kept)`), so the stamp commit shows which lines moved and why. A line the base added since the fork point is the base's even when that diff shows it (a merge of the base on the branch, committed or still staged, brings every line the base added since the fork into the diff from the fork point, main's own release keys included): it is left out, the detail says `N line(s) the base added since the fork point are the base's, not this branch's, and stay (: N)`, and a base diff git cannot run refuses the stage (`POLICY_SOURCE_UNAVAILABLE`, `cannot diff .. for the stamp_paths stage`) rather than reading as an empty set that would move the base's lines again. The rule reads line ownership, not meaning: a branch-added line inside `stamp_paths` that means the base's own release in a stamp form (`Requires vX or later` written on a branch forked at X) moves with it, which the `--dry-run` diff and the per-file counts show before anything is written; write such a reference outside a stamp form, or keep that file out of `stamp_paths`. `--was X` is the opposite tool: it rewrites X everywhere, the base's own lines included, and re-heads the CHANGELOG section `## [X]`. Only the repo's own version width counts, so a 3-digit dependency pin in a 4-digit repo is never a candidate. The checks that accept a stamp commit read the same bound as the writer (`stampOnlyLine` with the branch's side in `lib/stamp-only.ts`): the tree receipt behind `stamp`, `verify` and the gate-ahead replay, the merge train's stamp and verify checks (each reading the slot's predecessor, the gated commit's first parent, as the base), and finish's route each take a moved version on a line the branch added at or above the fork-point version, and on any other line at or above the gated head's VERSION. A base line whose text duplicates a line the branch added gets the branch's bound too, because the checks match branch lines by text, not position (GST-979). The /ship receipt carry can still refuse the move (`RECEIPT_CARRY_PRODUCT_CHANGED`), and when the branch keeps its VERSION claim, carry and finish still route the move as behavior (GST-980). +4. **stamp_paths**: exact `(was X)`, `since: X` and `vX` rewrites, plus every `stamp_patterns` template, within `stamp_paths` and `stamp_files`. A quote around X in the first two forms is part of the form and is kept as written: `since: 'X'`, `since: "X"`, `(was 'X')` and `(was "X")` move like the bare ones (the shape of a quoted source row such as gbrain's `{ since: '0.60.468.0', … }`), an opened quote must close right after X (`since: '1.2.3-beta'` and `since: '1.2.3"` are not the form, in the writer and in the tree receipt alike), and `vX` already accepts a quote before the `v`. Which X moves is decided by provenance. The branch's own tentative stamp (its VERSION when it moved past base) and `--was `, when given, are each rewritten on every line of every stamp file. Beyond that, only lines the branch itself added are read, by their position in the file (`git diff --unified=0` from the fork point), so a base line with the same text, or a CRLF checkout whose diff is LF-normalized, is told apart: a stamp-form mention there of a version newer than the version at the branch's fork point is a tentative stamp and moves (this is what finds a quoted row after a lost slot and a merge of the base, since the base's release is newer than the fork point), and so does one of the fork-point version itself (a row the branch wrote at the version it forked from instead of a next version is its own stale stamp; a branch-added mention older than the fork point stays), and when the branch has no stamp of its own because its VERSION equals the base's and its fork point is the base itself (a branch rebased onto the base after it reached X, or one never stamped) a mention of the base version on a line it added is its stale stamp and moves too, while the same version on a line the base already carries is the base's release and stays. The stage detail names both counts per file (`VERSION equals base X, so X moved only on lines this branch added and stayed on the base's own lines (: N moved, M kept)`), so the stamp commit shows which lines moved and why. A line the base added since the fork point is the base's even when that diff shows it (a merge of the base on the branch, committed or still staged, brings every line the base added since the fork into the diff from the fork point, main's own release keys included): it is left out, the detail says `N line(s) the base added since the fork point are the base's, not this branch's, and stay (: N)`, and a base diff git cannot run refuses the stage (`POLICY_SOURCE_UNAVAILABLE`, `cannot diff .. for the stamp_paths stage`) rather than reading as an empty set that would move the base's lines again. The rule reads line ownership, not meaning: a branch-added line inside `stamp_paths` that means the base's own release in a stamp form (`Requires vX or later` written on a branch forked at X) moves with it, which the `--dry-run` diff and the per-file counts show before anything is written; write such a reference outside a stamp form, or keep that file out of `stamp_paths`. `--was X` is the opposite tool: it rewrites X everywhere, the base's own lines included, and re-heads the CHANGELOG section `## [X]`. Only the repo's own version width counts, so a 3-digit dependency pin in a 4-digit repo is never a candidate. The checks that accept a stamp commit read the same bound as the writer (`stampOnlyLine` with the branch's side in `lib/stamp-only.ts`): the tree receipt behind `stamp`, `verify` and the gate-ahead replay, the merge train's stamp and verify checks (each reading the slot's predecessor, the gated commit's first parent, as the base), the /ship receipt carry, and finish's route each take a moved version on a line the branch added at or above the fork-point version, and on any other line at or above the gated head's VERSION. A branch line is named by its position in the gated file, so a base line whose text duplicates a line the branch added keeps the gated head's bound (GST-979). When the stamp keeps the VERSION (a slot that keeps its claim), only the branch's own lines may move, so a base line moved by hand is refused. The carry follows a stamp on the branch's own rows in a stamp file the branch also changed as product when every changed line of that file sits at a branch-added position, the file keeps its mode, the base did not touch it and the rest of the product diff is unchanged (`a stamp on the branch's own rows` in the carry reason, GST-980). 5. **mirror**: tier 2; declared and validated, reported as not run. 6. **apply**: every changed file is written to the branch only after all stages validated, each against the fingerprinted preimage; a file edited meanwhile is `RESTAMP_CONFLICT` and the applied writes roll back (rollback refuses to overwrite a file whose bytes differ from the recorded postimage). diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 5a9bf8fb5..7ae72bf86 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -5989,8 +5989,10 @@ retargeted stacked PR the parent branch and the base. conflict-only base merge, a test-only change, release metadata, a registered output the pregate's regen check proved, a rebase onto a covered tree with the recorded product diff, a stacked PR's retarget once its parent fully -landed on the base, or base context next to unchanged hunks after a clean -scoped review ([`RECEIPT_CARRY_SCOPED_REVIEW`](#receipt-carry-scoped-review)), which the +landed on the base, a stamp on the branch's own rows in a stamp file it also +changed as product (every changed line at a branch-added position, the mode +unchanged, the base not touching the file), or base context next to unchanged +hunks after a clean scoped review ([`RECEIPT_CARRY_SCOPED_REVIEW`](#receipt-carry-scoped-review)), which the `carry` object in the carried receipt records with the product patch-id and the range-diff evidence ([unattended.md](unattended.md#the-terminal-line)). diff --git a/lib/restamp.ts b/lib/restamp.ts index 45dd82ff7..be2c6fc23 100644 --- a/lib/restamp.ts +++ b/lib/restamp.ts @@ -244,7 +244,7 @@ function allowedOutput(plan: Plan, root: string, rel: string): boolean { return matchesAny(p.stamp_paths, rel) || matchesAny(p.stamp_files, rel) || matchesAny(p.release_outputs, rel); } -interface Hunk { removed: string[]; added: string[]; at: number; addedAt: number[] } +interface Hunk { removed: string[]; added: string[]; at: number; addedAt: number[]; removedAt: number[] } export interface FileDiff { path: string; binary: boolean; hunks: Hunk[]; status: 'M' | 'A' | 'D' | 'R'; modeChanged?: boolean } /** @@ -252,13 +252,15 @@ export interface FileDiff { path: string; binary: boolean; hunks: Hunk[]; status * File headers come only before a file's first hunk: inside a hunk every `-`/`+` line is content, so a * body line that begins `--` or `++` (`---`/`+++` in the diff) is never dropped as a header. * `addedAt` holds each added line's 1-based position on the new side, counted through any context - * line the hunk carries (`diff.interHunkContext` can join hunks under `--unified=0`). + * line the hunk carries (`diff.interHunkContext` can join hunks under `--unified=0`), and `removedAt` each removed + * line's position on the old side, counted the same way. */ export function parseUnifiedDiff(text: string): FileDiff[] { const files: FileDiff[] = []; let cur: FileDiff | null = null; let hunk: Hunk | null = null; let cursor = 0; + let oldCursor = 0; for (const line of text.split('\n')) { if (line.startsWith('diff --git ')) { const m = /^diff --git a\/(.+?) b\/(.+)$/.exec(line); @@ -271,10 +273,13 @@ export function parseUnifiedDiff(text: string): FileDiff[] { else if (!hunk && (line.startsWith('old mode ') || line.startsWith('new mode '))) cur.modeChanged = true; else if (line.startsWith('rename to ')) cur.status = 'R'; else if (line.startsWith('Binary files')) cur.binary = true; - else if (line.startsWith('@@')) { hunk = { removed: [], added: [], at: Number(/^@@ -\d+(?:,\d+)? \+(\d+)/.exec(line)?.[1] ?? 0), addedAt: [] }; cursor = hunk.at; cur.hunks.push(hunk); } - else if (hunk && line.startsWith('-')) hunk.removed.push(line.slice(1)); + else if (line.startsWith('@@')) { + const m = /^@@ -(\d+)(?:,\d+)? \+(\d+)/.exec(line); + hunk = { removed: [], added: [], at: Number(m?.[2] ?? 0), addedAt: [], removedAt: [] }; cursor = hunk.at; oldCursor = Number(m?.[1] ?? 0); cur.hunks.push(hunk); + } + else if (hunk && line.startsWith('-')) { hunk.removed.push(line.slice(1)); hunk.removedAt.push(oldCursor); oldCursor += 1; } else if (hunk && line.startsWith('+')) { hunk.added.push(line.slice(1)); hunk.addedAt.push(cursor); cursor += 1; } - else if (hunk && line.startsWith(' ')) cursor += 1; + else if (hunk && line.startsWith(' ')) { cursor += 1; oldCursor += 1; } } return files; } diff --git a/lib/ship-bin-common.ts b/lib/ship-bin-common.ts index 6bdd582dc..d1b8115d3 100644 --- a/lib/ship-bin-common.ts +++ b/lib/ship-bin-common.ts @@ -111,7 +111,8 @@ export function releasePaths(policy: Record | null, cwd: string, re * A moved version is floored at `ref`'s VERSION, except on a line the branch added itself (gstack-restamp's own rule: * added since the merge base with origin/, and not added by the base since): after a lost slot and a merge of the * base its stale stamp is older than `ref`'s VERSION, so it must be at or newer than the fork point's version instead, - * the bound gstack-restamp's stamp_paths stage uses (GST-895; the fork version itself since GST-963). + * the bound gstack-restamp's stamp_paths stage uses (GST-895; the fork version itself since GST-963). A branch line is + * named by its position, and with a kept VERSION only such a line may move (GST-979, GST-980). */ export function stampedFiles(policy: Record | null, cwd: string, ref: string, base: string): string[] { const globs = Array.isArray(policy?.stamp_files) ? policy.stamp_files.filter((s: unknown): s is string => typeof s === 'string') : []; @@ -120,14 +121,14 @@ export function stampedFiles(policy: Record | null, cwd: string, re if (!('version' in before)) return []; let after = ''; try { after = extractVersion(fs.readFileSync(path.join(cwd, before.rel), 'utf8'), before.rel); } catch { return []; } - if (!after || after === before.version) return []; + if (!after) return []; const templates = Array.isArray(policy?.stamp_patterns) ? policy.stamp_patterns.filter((s: unknown): s is string => typeof s === 'string') : []; const diff = git(cwd, ['diff', '--unified=0', '--no-color', '--no-ext-diff', '--no-textconv', '--no-renames', ref]); if (diff.status !== 0) return []; const side = branchSides(cwd, `origin/${base}`, 'HEAD', before.version, ref); - const stamp = (rel: string, removed: string, added: string): boolean => stampOnlyLine(removed, added, before.version, after, templates, side(rel)); + const stamp = (rel: string, removed: string, added: string, at: number): boolean => stampOnlyLine(removed, added, before.version, after, templates, side(rel), at); return parseUnifiedDiff(diff.stdout).filter(f => f.status === 'M' && !f.binary && !f.modeChanged && matchesAny(globs, f.path) && f.hunks.length > 0 && - f.hunks.every(h => h.removed.length === h.added.length && h.removed.every((line, i) => stamp(f.path, line, h.added[i]!)))).map(f => f.path); + f.hunks.every(h => h.removed.length === h.added.length && h.removed.every((line, i) => stamp(f.path, line, h.added[i]!, h.removedAt[i]!)))).map(f => f.path); } /** Under `changelog_fragments`, the branch's own Step 13 entry `/.md` (docs/ship-policy.md#changelog-fragments); null without the key. */ diff --git a/lib/ship-receipt.ts b/lib/ship-receipt.ts index bb908c088..ff6af045e 100644 --- a/lib/ship-receipt.ts +++ b/lib/ship-receipt.ts @@ -178,6 +178,8 @@ export interface CarryPlanInput { retargetedFrom?: string; /** A clean scoped review of product paths whose only difference is base context next to unchanged hunks (lib/ship-patch.ts, GST-384): the carry reason it adds. */ scopedReview?: string; + /** Stamp files the branch changed as product whose only change since the reviewed head is a stamp on the branch's own rows, the base untouched, and without which the two product patches match (GST-980). */ + stampedRows?: string[]; } export interface CarryRecord { from: string; reason: string; product_patch_id: string; changed_paths: string[]; merge_commits: number; range_diff: string; covers: string[]; reruns: string[]; trees?: string[]; ancestry?: 'linear' | 'rewritten' } export type CarryPlan = { ok: true; carry: CarryRecord } | { ok: false; code: 'RECEIPT_CARRY_PRODUCT_CHANGED' | 'RECEIPT_CARRY_REFUSED' | 'RECEIPT_CARRY_TREE_MISMATCH'; message: string }; @@ -195,22 +197,23 @@ export interface CarryChange { before: string | null; after: string | null; oldV * old text once every new version in it is the old one, or when every changed * line is a stamp-form rewrite to the new version (`stampOnlyLine`: the old * version or a newer tentative `*_KEY_VERSION` the slot stamp moved, #3512, and - * on a line the branch added itself, `side`, the fork version or newer, GST-963): the rule + * on a line the branch added itself, `side`, the fork version or newer, GST-963; with a kept VERSION only such a line, + * GST-980): the rule * the tree receipt applies to the same `stamp_paths`, `stamp_files` and * `release_outputs` before the train accepts a stamp commit. No version - * change, or a file missing on either side, is not a stamp. + * change outside the branch's own lines, or a file missing on either side, is not a stamp. */ export function stampOnlyText(change: CarryChange): boolean { const { before, after, oldVersion, newVersion } = change; - if (before === null || after === null || !oldVersion || !newVersion || oldVersion === newVersion) return false; + if (before === null || after === null || !oldVersion || !newVersion || (oldVersion === newVersion && !change.side)) return false; // Digit-bounded: replacing 1.2.3 inside 11.2.3 or 1.2.34 would read a different version's stamp as this one's. const escaped = newVersion.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - if (after.replace(new RegExp(`(? i).filter(i => was[i] !== now[i]); - return changed.length > 0 && changed.every(i => stampOnlyLine(was[i]!, now[i]!, oldVersion, newVersion, change.templates ?? [], change.side)); + return changed.length > 0 && changed.every(i => stampOnlyLine(was[i]!, now[i]!, oldVersion, newVersion, change.templates ?? [], change.side, i + 1)); } /** @@ -241,16 +244,18 @@ export function classifyCarryPath(rel: string, extra: { metadata?: readonly stri * conflict-only base merge, a test-only fix or a release-metadata change * leaves behind. A product patch that differs is RECEIPT_CARRY_PRODUCT_CHANGED, * whatever else changed, unless every difference is base context next to unchanged hunks - * and a scoped review of those hunks came back clean (`scopedReview`). + * and a scoped review of those hunks came back clean (`scopedReview`), or a stamp on the + * branch's own rows in a stamp file the branch also changed as product (`stampedRows`, GST-980). */ export function planCarry(input: CarryPlanInput): CarryPlan { - if (input.productPatchId.from !== input.productPatchId.head && (input.changedProduct.length || !input.scopedReview)) { + if (input.productPatchId.from !== input.productPatchId.head && (input.changedProduct.length || (!input.scopedReview && !input.stampedRows?.length))) { const named = input.changedProduct.slice(0, CARRY_NAMED_PATHS); return { ok: false, code: 'RECEIPT_CARRY_PRODUCT_CHANGED', message: `product diff changed between ${input.from.slice(0, 12)} and ${input.head.slice(0, 12)}: ${named.join(', ') || 'patch-id differs'}${input.changedProduct.length > named.length ? ` (+${input.changedProduct.length - named.length} more)` : ''}` }; } const reasons: string[] = input.retargetedFrom ? [`stack parent ${input.retargetedFrom} landed`] : []; if (input.mergeCommits > 0) reasons.push(input.mergeCommits === 1 ? 'base merge' : `${input.mergeCommits} base merges`); if (input.scopedReview && input.productPatchId.from !== input.productPatchId.head) reasons.push(input.scopedReview); + if (input.stampedRows?.length && input.productPatchId.from !== input.productPatchId.head) reasons.push(`a stamp on the branch's own rows (${input.stampedRows.join(', ')})`); if (input.testPatchId.from !== input.testPatchId.head) reasons.push('test-only change'); if (input.changed.some(c => c.class === 'metadata')) reasons.push('release metadata'); if (input.changed.some(c => c.class === 'generated')) reasons.push('regenerated outputs'); diff --git a/lib/stamp-only.ts b/lib/stamp-only.ts index 3b0d2d1e7..bbb87dc66 100644 --- a/lib/stamp-only.ts +++ b/lib/stamp-only.ts @@ -20,18 +20,25 @@ import { cmpVersion, parseVersion, versionWidth } from './version-source'; * one of another width (`tentativeMentions`: a 3-digit dependency pin in a * 4-digit repo is never a candidate, so moving it is a hand edit). A line that * moves nothing, or changes anything beyond those mentions, is not one either. - * With `side`, a removed line the branch added itself is bounded by its fork - * point's version instead, the stage's bound for its own lines (GST-895, - * GST-963): finish's stampedFiles, the tree receipt and the receipt carry all - * pass the same side. + * With `side`, a removed line the branch added itself, named by its 1-based + * position `at` in the side's file (GST-979: a base line with the same text + * is not the branch's), is bounded by its fork point's version instead, the + * stage's bound for its own lines (GST-895, GST-963): finish's stampedFiles, + * the tree receipt and the receipt carry all pass the same side. When the + * version does not move (a slot that keeps its claimed VERSION), only such a + * branch line may change: the stage moves nothing else then. */ -export function stampOnlyLine(removed: string, added: string, oldV: string, newV: string, templates: readonly string[] = [], side?: BranchSide): boolean { +export function stampOnlyLine(removed: string, added: string, oldV: string, newV: string, templates: readonly string[] = [], side?: BranchSide, at?: number): boolean { if (removed === added) return false; - return stampOnlyWithin(removed, added, oldV, newV, templates) || (!!side?.added.has(removed) && stampOnlyWithin(removed, added, side.fork, newV, templates)); + if (oldV !== newV && stampOnlyWithin(removed, added, oldV, newV, templates)) return true; + return !!side && at !== undefined && side.at.has(at) && side.added.has(removed) && stampOnlyWithin(removed, added, side.fork, newV, templates); } -/** Lines the branch added to one file (since its merge base with the base, less the lines the base added since) and its fork point's version. */ -export interface BranchSide { fork: string; added: ReadonlySet } +/** + * Lines the branch added to one file (since its merge base with the base, less the lines the base added since): their + * text and their 1-based positions in the side's file, and its fork point's version. + */ +export interface BranchSide { fork: string; added: ReadonlySet; at: ReadonlySet } /** * Each file's BranchSide for `head` against `baseRef`, read lazily and cached: the lines come from merge-base..`to` @@ -48,8 +55,8 @@ export function branchSides(repoRoot: string, baseRef: string, head: string, fal let side: BranchSide | undefined; if (since) { try { - const added = branchAddedLines(repoRoot, since, [rel], to, branchAddedLines(repoRoot, since, [rel], baseRef)).get(rel)?.text; - if (added?.size) side = { fork: (fork ??= forkVersion(repoRoot, baseRef, fallback, head)), added }; + const own = branchAddedLines(repoRoot, since, [rel], to, branchAddedLines(repoRoot, since, [rel], baseRef)).get(rel); + if (own?.text.size) side = { fork: (fork ??= forkVersion(repoRoot, baseRef, fallback, head)), added: own.text, at: own.at }; } catch {} } sides.set(rel, side); diff --git a/lib/tree-receipt.ts b/lib/tree-receipt.ts index 7ba350205..f5d46b053 100644 --- a/lib/tree-receipt.ts +++ b/lib/tree-receipt.ts @@ -86,7 +86,7 @@ function stampOnlyHunks(hunks: FileDiff['hunks'], oldV: string, newV: string, te for (let i = 0; i < h.removed.length; i++) { const r = h.removed[i]!; const a = h.added[i]!; - if (!stampOnlyLine(r, a, oldV, newV, templates, side)) return { why: `${JSON.stringify(r.trim().slice(0, 60))} -> ${JSON.stringify(a.trim().slice(0, 60))}`, line: h.at + i }; + if (!stampOnlyLine(r, a, oldV, newV, templates, side, h.removedAt[i])) return { why: `${JSON.stringify(r.trim().slice(0, 60))} -> ${JSON.stringify(a.trim().slice(0, 60))}`, line: h.at + i }; } } return null; diff --git a/package.json b/package.json index f27bcb93f..2f2aab339 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "1.93.41", + "version": "1.93.42", "description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.", "license": "MIT", "type": "module", diff --git a/test/gstack-ship-receipt-docs.test.ts b/test/gstack-ship-receipt-docs.test.ts index 497d49c07..db89a68fb 100644 --- a/test/gstack-ship-receipt-docs.test.ts +++ b/test/gstack-ship-receipt-docs.test.ts @@ -225,12 +225,29 @@ describe('carry follow-ups: git floor, named refusal, branch-touched walk, digit const mine = "export const MINE_KEY_VERSION = '1.2.3.0';"; const before = `${mine}\nexport const BASE_KEY_VERSION = '1.2.3.0';\n`; const moved = (text: string) => ({ before, after: text, oldVersion: '1.2.4.0', newVersion: '1.2.5.0', templates }); - const side = { fork: '1.2.3.0', added: new Set([mine]) }; + const side = { fork: '1.2.3.0', added: new Set([mine]), at: new Set([1]) }; expect(stampOnlyText({ ...moved(before.replace(mine, mine.replace('1.2.3.0', '1.2.5.0'))), side })).toBe(true); expect(stampOnlyText(moved(before.replace(mine, mine.replace('1.2.3.0', '1.2.5.0'))))).toBe(false); expect(stampOnlyText({ ...moved(before.replace("BASE_KEY_VERSION = '1.2.3.0'", "BASE_KEY_VERSION = '1.2.5.0'")), side })).toBe(false); }); + // Value: protects=the carry reads the branch's own line by position and, with a kept VERSION claim, accepts only the + // branch's own row moved from the fork version (GST-979, GST-980); fails_when=stampOnlyText refuses every change at + // equal versions or takes a duplicated base line as the branch's; seam=lib/ship-receipt.ts stampOnlyText + test('stampOnlyText reads the branch line by position, and with a kept VERSION moves only the branch\'s own row (GST-979, GST-980)', () => { + const templates = ["_KEY_VERSION = '{version}'"]; + const key = (v: string) => `export const MINE_KEY_VERSION = '${v}';`; + const before = `${key('1.2.3.0')}\nexport const BASE_KEY_VERSION = '1.2.3.0';\n${key('1.2.3.0')}\n`; + const side = { fork: '1.2.3.0', added: new Set([key('1.2.3.0')]), at: new Set([3]) }; + const lines = (a: string, c: string) => `${a}\nexport const BASE_KEY_VERSION = '1.2.3.0';\n${c}\n`; + const change = (after: string, oldVersion: string, newVersion: string) => stampOnlyText({ before, after, oldVersion, newVersion, templates, side }); + expect(change(lines(key('1.2.3.0'), key('1.2.5.0')), '1.2.4.0', '1.2.5.0')).toBe(true); + expect(change(lines(key('1.2.5.0'), key('1.2.3.0')), '1.2.4.0', '1.2.5.0')).toBe(false); + expect(change(lines(key('1.2.3.0'), key('1.2.4.0')), '1.2.4.0', '1.2.4.0')).toBe(true); + expect(change(lines(key('1.2.4.0'), key('1.2.3.0')), '1.2.4.0', '1.2.4.0')).toBe(false); + expect(stampOnlyText({ before, after: lines(key('1.2.3.0'), key('1.2.4.0')), oldVersion: '1.2.4.0', newVersion: '1.2.4.0', templates })).toBe(false); + }); + test('planCarry names at most CARRY_NAMED_PATHS paths', () => { const many = Array.from({ length: CARRY_NAMED_PATHS + 3 }, (_, i) => `src/f${i}.ts`); const plan = planCarry({ from: 'a'.repeat(40), head: 'b'.repeat(40), changed: many.map(p => ({ path: p, class: 'product' as const })), productPatchId: { from: 'x', head: 'y' }, testPatchId: { from: '', head: '' }, changedProduct: many, mergeCommits: 0, rangeDiff: '' }); diff --git a/test/restamp-mentions.test.ts b/test/restamp-mentions.test.ts index 3913d7e92..68a546a9c 100644 --- a/test/restamp-mentions.test.ts +++ b/test/restamp-mentions.test.ts @@ -329,4 +329,106 @@ describe('a branch-added row left at the fork version after the base moved (GST- expect(receipt.out).toContain("id: 'base_row'"); expect(receipt.out).not.toContain("id: 'mine'"); }); + + // Value: protects=a base row whose text a branch row duplicates keeps the old-version floor in the tree receipt + // (GST-979, the #3862 outside voice); fails_when=the side matches by text, so a hand move of the base copy reads as + // same-modulo-stamps; seam=lib/stamp-only.ts branchSides positions + test('a base row whose text the branch duplicates still refuses a hand move; the branch copy\'s own move passes (GST-979)', () => { + const repo = makeFixtureRepo({ prefix: 'restamp-dup-row-', policy: receiptPolicy(true) }); repos.push(repo); + write(repo, NOTICE, notice([row('1.2.3.0', 'base_row')])); + repo.git('add', '-A'); repo.git('commit', '-qm', 'notice rows'); repo.git('push', '-q', 'origin', 'main'); + makePr(repo, 'pr-dup'); + expect(restamp(repo, ['--version', '1.2.4.0']).status).toBe(EXIT.ok); + repo.git('commit', '-qam', 'stamp 1.2.4.0'); + write(repo, NOTICE, notice([row('1.2.3.0', 'base_row'), '', '', row('1.2.3.0', 'base_row')])); + repo.git('commit', '-qam', 'dup: the same row text at the fork version'); + const gated = repo.git('rev-parse', 'HEAD'); + expect(restamp(repo, ['--version', '1.2.5.0']).status).toBe(EXIT.ok); + expect(readFile(repo, NOTICE)).toBe(notice([row('1.2.3.0', 'base_row'), '', '', row('1.2.5.0', 'base_row')])); + repo.git('commit', '-qam', 'stamp dup'); + const own = runBin(repo, 'gstack-tree-receipt', ['--gated', gated, '--base', 'main']); + expect(own.out, own.err).toContain('TREE: same-modulo-stamps'); + write(repo, NOTICE, notice([row('1.2.5.0', 'base_row'), '', '', row('1.2.5.0', 'base_row')])); + repo.git('commit', '-qam', 'move the base copy by hand'); + const hand = runBin(repo, 'gstack-tree-receipt', ['--gated', gated, '--base', 'main']); + expect(hand.out, hand.err).toContain('TREE: changed'); + }); + + // Value: protects=the receipt carry follows a stamp that moves the branch's own fork-version row, the move the writer + // makes since GST-963 (GST-980); fails_when=the carry keeps the branch-added row's bytes in both product patch-ids and + // refuses RECEIPT_CARRY_PRODUCT_CHANGED; seam=bin/gstack-ship-receipt carry walk + test('the carry follows a stamp that moves the branch\'s own fork-version row, and still refuses a product edit beside it (GST-980)', () => { + const repo = makeFixtureRepo({ prefix: 'restamp-carry-row-', policy: policy(true) }); repos.push(repo); + write(repo, NOTICE, notice([row('1.2.3.0', 'base_row')])); + fs.rmSync(path.join(repo.work, 'package-lock.json')); + repo.git('add', '-A'); repo.git('commit', '-qm', 'notice rows, no lockfile'); repo.git('push', '-q', 'origin', 'main'); + makePr(repo, 'pr-carry'); + expect(restamp(repo, ['--version', '1.2.4.0']).status).toBe(EXIT.ok); + repo.git('commit', '-qam', 'stamp 1.2.4.0'); + write(repo, NOTICE, notice([row('1.2.3.0', 'base_row'), '', row('1.2.3.0', 'mine')])); + repo.git('commit', '-qam', 'mine: claims 1.2.4.0 with a row at the fork version'); + const body = path.join(repo.root, 'body.md'); + fs.writeFileSync(body, '## Summary\n'); + const w = runBin(repo, 'gstack-ship-receipt', ['write', '--pr', '3', '--base', 'main', '--session-kind', 'x', '--body', body]); + expect(w.status, w.err).toBe(EXIT.ok); + expect(restamp(repo, ['--version', '1.2.5.0']).status).toBe(EXIT.ok); + expect(readFile(repo, NOTICE)).toBe(notice([row('1.2.3.0', 'base_row'), '', row('1.2.5.0', 'mine')])); + repo.git('commit', '-qam', 'stamp 1.2.5.0'); + const carried = runBin(repo, 'gstack-ship-receipt', ['carry', '--body', body, '--base', 'main']); + expect(carried.err).not.toContain('RECEIPT_CARRY_PRODUCT_CHANGED'); + expect(carried.out, carried.err).toContain('CARRY: carried'); + write(repo, 'src.ts', 'export const x = 1;\n'); + repo.git('add', '-A'); repo.git('commit', '-qm', 'a product change after the stamp'); + const changed = runBin(repo, 'gstack-ship-receipt', ['carry', '--body', body, '--base', 'main']); + expect(changed.status).toBe(EXIT.refused); + expect(changed.err).toContain('RECEIPT_CARRY_PRODUCT_CHANGED'); + }); + + /** The GST-980 carry state: a receipt written at the claim 1.2.4.0 with the branch's own row, then the stamp to 1.2.5.0, uncommitted. */ + function carryAfterStamp(prefix: string, baseRows: string[], mine: string, stamped: string[]): { repo: FixtureRepo; body: string } { + const repo = makeFixtureRepo({ prefix, policy: policy(true) }); repos.push(repo); + write(repo, NOTICE, notice(baseRows)); + fs.rmSync(path.join(repo.work, 'package-lock.json')); + repo.git('add', '-A'); repo.git('commit', '-qm', 'notice rows, no lockfile'); repo.git('push', '-q', 'origin', 'main'); + makePr(repo, 'pr-carry'); + expect(restamp(repo, ['--version', '1.2.4.0']).status).toBe(EXIT.ok); + repo.git('commit', '-qam', 'stamp 1.2.4.0'); + write(repo, NOTICE, notice([...baseRows, '', mine])); + repo.git('commit', '-qam', 'mine: a row of its own'); + const body = path.join(repo.root, 'body.md'); + fs.writeFileSync(body, '## Summary\n'); + const w = runBin(repo, 'gstack-ship-receipt', ['write', '--pr', '3', '--base', 'main', '--session-kind', 'x', '--body', body]); + expect(w.status, w.err).toBe(EXIT.ok); + expect(restamp(repo, ['--version', '1.2.5.0']).status).toBe(EXIT.ok); + expect(readFile(repo, NOTICE)).toBe(notice(stamped)); + return { repo, body }; + } + + // Value: protects=the carry leaves out only a stamp on the branch's own rows, never a version edit on a base line of + // the same file (GST-980 review); fails_when=the carry trusts the whole-text version swap, so a hand move of a base + // line's version mention rides along with the row stamp; seam=bin/gstack-ship-receipt productSpec ownRows + test('the carry refuses a hand version edit on a base line of a stamp file whose own row it follows (GST-980)', () => { + const min = "export const MIN = '1.2.4.0';"; + const { repo, body } = carryAfterStamp('restamp-carry-base-line-', [row('1.2.3.0', 'base_row'), min], row('1.2.4.0', 'mine'), + [row('1.2.3.0', 'base_row'), min, '', row('1.2.5.0', 'mine')]); + write(repo, NOTICE, notice([row('1.2.3.0', 'base_row'), min.replace('1.2.4.0', '1.2.5.0'), '', row('1.2.5.0', 'mine')])); + repo.git('commit', '-qam', 'stamp 1.2.5.0, and move the base pin by hand'); + const carried = runBin(repo, 'gstack-ship-receipt', ['carry', '--body', body, '--base', 'main']); + expect(carried.status, carried.out).toBe(EXIT.refused); + expect(carried.err).toContain('RECEIPT_CARRY_PRODUCT_CHANGED'); + }); + + // Value: protects=a mode change rides on no stamp: the carry leaves out a stamp file only when its mode is the + // reviewed one (GST-980 review); fails_when=the left-out stamp file drops its mode line from both patch-ids; + // seam=bin/gstack-ship-receipt productSpec ownRows + test('the carry refuses a mode change on a stamp file whose own row it follows (GST-980)', () => { + const { repo, body } = carryAfterStamp('restamp-carry-mode-', [row('1.2.3.0', 'base_row')], row('1.2.3.0', 'mine'), + [row('1.2.3.0', 'base_row'), '', row('1.2.5.0', 'mine')]); + fs.chmodSync(path.join(repo.work, NOTICE), 0o755); + repo.git('commit', '-qam', 'stamp 1.2.5.0, and make the file executable'); + expect(repo.git('ls-tree', 'HEAD', '--', NOTICE)).toStartWith('100755 '); + const carried = runBin(repo, 'gstack-ship-receipt', ['carry', '--body', body, '--base', 'main']); + expect(carried.status, carried.out).toBe(EXIT.refused); + expect(carried.err).toContain('RECEIPT_CARRY_PRODUCT_CHANGED'); + }); }); diff --git a/test/ship-rereview-triggers.test.ts b/test/ship-rereview-triggers.test.ts index 4e465c0a4..63bc87850 100644 --- a/test/ship-rereview-triggers.test.ts +++ b/test/ship-rereview-triggers.test.ts @@ -248,6 +248,24 @@ describe('a restamp after a lost slot (GST-895, GBRA-218, gbrain #8134)', () => const e = finish(edited.f, edited.reviewed, edited.post, ['--reviewed-base', edited.reviewedBase]); expect([e.status, lineOf(e.stdout, 'STOP')]).toEqual([3, behaviorStop]); }); + + // Value: protects=with a kept VERSION claim, the restamp's move of the branch's own fork-version row routes as metadata, + // and a base row moved the same way still stops (GST-980); fails_when=stampedFiles returns nothing at equal versions + // and finish routes the row as behavior; seam=lib/ship-bin-common.ts stampedFiles + test('a kept VERSION claim: the moved fork-version row is metadata; a moved base row stops (GST-980)', () => { + const kept = (rows: [string, string][]) => { + const f = fx({ '.gstack/ship-policy.json': policy, VERSION: '1.0.0.0\n', 'src/notice.ts': notice(['0.9.0.0', 'old'], ['1.0.0.0', 'base']) }, + { VERSION: '1.0.1.0\n', 'src/notice.ts': notice(['0.9.0.0', 'old'], ['1.0.0.0', 'base'], ['1.0.0.0', 'mine']) }); + const reviewed = wtree(f); + const post = snapshot(f); + f.write({ 'src/notice.ts': notice(...rows) }); f.commit('stamp, VERSION kept'); + return finish(f, reviewed, post, ['--reviewed-base', mergeBase(f)]); + }; + const own = kept([['0.9.0.0', 'old'], ['1.0.0.0', 'base'], ['1.0.1.0', 'mine']]); + expect(lineOf(own.stdout, 'ROUTE')).toEqual(expect.stringMatching(/ behavior=0 docs=0 metadata=1 tests=0 /)); + const base = kept([['0.9.0.0', 'old'], ['1.0.1.0', 'base'], ['1.0.0.0', 'mine']]); + expect([base.status, lineOf(base.stdout, 'STOP')]).toEqual([3, behaviorStop]); + }); }); describe('adjacent base edits (GST-384, #3631, founderstar#441)', () => { diff --git a/test/tree-receipt-stamp-sensitive.test.ts b/test/tree-receipt-stamp-sensitive.test.ts index 569cc83cd..e9c56e660 100644 --- a/test/tree-receipt-stamp-sensitive.test.ts +++ b/test/tree-receipt-stamp-sensitive.test.ts @@ -105,6 +105,22 @@ describe('tree receipt: stamps, stamp-sensitive gates and negative fixtures', () expect(width.out).toMatch(/^TREE: changed \(lib\/policy\.ts\)$/m); }); + // Value: protects=the fork-version bound reads the branch's own line by its position, so a base copy of the same text + // is still floored at the old version, and when the slot keeps its VERSION only the branch's own lines may move + // (GST-979); fails_when=stampOnlyLine matches the branch's lines by text alone or takes the old-version floor at equal + // versions; seam=lib/stamp-only.ts stampOnlyLine + test('the fork-version bound holds only at the branch line\'s own position, and a kept VERSION moves only the branch\'s own lines (GST-979)', () => { + const tpl = ["since: '{version}'"]; + const row = " { since: '1.2.3.0', id: 'x' },"; + const moved = row.replace('1.2.3.0', '1.2.5.0'); + const side = { fork: '1.2.3.0', added: new Set([row]), at: new Set([10]) }; + expect(stampOnlyLine(row, moved, '1.2.4.0', '1.2.5.0', tpl, side, 10)).toBe(true); + expect(stampOnlyLine(row, moved, '1.2.4.0', '1.2.5.0', tpl, side, 2)).toBe(false); + const mine = { fork: '1.2.3.0', added: new Set(["mine since: '1.2.3.0'"]), at: new Set([5]) }; + expect(stampOnlyLine("base since: '1.3.0.0'", "base since: '1.2.4.0'", '1.2.4.0', '1.2.4.0', tpl, mine, 1)).toBe(false); + expect(stampOnlyLine("mine since: '1.2.3.0'", "mine since: '1.2.4.0'", '1.2.4.0', '1.2.4.0', tpl, mine, 5)).toBe(true); + }); + test('negative fixture: a dependency pin equal to the old version is `changed`, not a stamp, even inside stamp_paths', () => { const repo = fixture(); const g = gated(repo); From 4ec1722ecbc02a22552e274d17b551c9f722c9fd Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 2 Nov 2026 20:02:41 -0800 Subject: [PATCH 6/6] v1.94.0.0 ship: CI is the one full test run (CI carry, tree cache, /ship beside CI) (#3901) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(ship): base merges, adjacent base edits, test-only and audit-requested fixes no longer force a second review loop (GST-407, GST-384, GST-391) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship driver: trim two phrases for headroom with #3662 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship driver: keep the Next steps heading phrase the handoff check reads; trim elsewhere Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: regenerate ship goldens Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes comparePath returns same only when every hunk sits where the base change puts it (patch-ids ignore positions) and treats a file-mode change as changed; the scoped-review packet says when a fence is truncated; --docs-result must be the posted audit's result; the --context-reviewed record goes beside the packet, outside the worktree. Negative controls for each. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pass-2 review fixes A test edit routes as tests= only when it adds lines with no gate tag; a removed or changed line or an unreadable test diff goes through the full loop. Diffs skip textconv. A hunkless patch (binary, empty, mode-only) is same when its patch-id matches. Without --reviewed-base test files route as before. finish's packet path and attempt's state directory have fallbacks. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 review fixes; a version-only stamp_files edit after review is release metadata (GBRA-251) gateEditedPaths reads removed lines only inside hunks; carry refuses when a path listing fails; docs freshness stops on a failed listing; attempt counts an unreadable state file. releasePaths includes stamp_files paths whose edit is a version swap under stamp_patterns. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: no test edit skips review; guard packet writes; exclusive attempt state A test-only edit with no gate tag gets the scoped fix-check of its test hunks instead of a lanes-only rerun. Packet write failures print a STOP or RECEIPT_CARRY_REFUSED. attempt's allowance uses an exclusive create. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: attempt prints gstack's install command; carry checks the product diff outside context paths The attempt STOP no longer echoes the audit child's fix text. A scoped-review carry now requires the product patch-id without the context paths to match at both heads. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: oversized packets take the full loop; exact --docs-requested match; name-only test globs only in test dirs A scoped-review packet section over 200 lines sends that path to the full loop instead of a truncated packet. The docs-result path match is exact. test_*.py, *Test.java and similar count as test code only under a test directory. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(unattended): carry's scoped-review refusal and what it keeps Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: carry's scoped-review route in ship-policy, review-policy and troubleshooting (docs-a-1) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(windows): curate ship-rereview-triggers out of the Windows lane like ship-release (run 41193336209) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review-log): record a notes-only /ship pass clean; name the cause and repair when a pass's tree moved (GST-430) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(receipt): carry and write handle PRs with thousands of files; tree receipt fails closed on a failed diff (GST-448) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship): preflight routes RECEIPT_CARRY_SCOPED_REVIEW to the scoped review; carry --dry-run writes no packet (GST-442) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs(ship): Step 1.4 and Step 16 route the scoped-review refusal and the --docs-requested fix; trims keep the cap (GST-442, GST-444) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: /ship review pass 1: notes-only floor, scoped carry order, named temp and diff refusals - A notes-only pass is recorded clean only when every finding is fixed, or noted or deferred below the blocking floor (never CRITICAL or blocking), by its logger-stamped action, and the findings account for the claimed issue and critical counts (GST-430). - The preflight scoped carry route commits and pushes the base-merge fix before writing the packet (GST-442). - patchId refuses by name on an unwritable TMPDIR; the tree receipt names why its diff failed (GST-448). - Step 16 stage 3 spells out --docs-requested with its --docs-result (GST-444). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: pin the Step 16 --docs-requested route with its --docs-result Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: a claimed clean review row with a logger-stamped open gate finding reads UNVERIFIED (red-team, pass 1) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 findings: gate rows from --findings are stamped, one open rule, stale patch-id dirs swept - deriveFromFindings stamps gate rows with the session kind before deriving status, so a findings file cannot dispose of a gate finding the unattended logger forces open (outside-voice#1). - reviewFreshness reads a claimed row's findings with isOpenByAction, the rule the notes-only rewrite uses; noted and deferred clear a finding only when it is marked blocking: false and is not CRITICAL. - patchId sweeps gstack-patch-id-* directories over an hour old that a killed carry left in TMPDIR. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 round 2: stamped-open gates win over status and disposition; resolved gate, skipped and below-floor actions stay CURRENT - isOpenFinding treats action 'open' (the logger's forced-open stamp) as open before a row's status or disposition. - reviewFreshness flags a claimed clean row only for an 'open' action or a CRITICAL or blocking deferral or note, so interactive kept and restored gates, skipped advisories and INFORMATIONAL deferrals read CURRENT as before. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: carry dry run offers the scoped route last; patch-id diff under the git dir; changelog matches the review-log floor Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: a claimed clean review row with any unresolved non-gate CRITICAL finding reads UNVERIFIED (pass 2 red-team) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: carry dry-run scoped route, patch-id directory, tree-receipt refusal (docs-d-1 audit) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship): Step 3 names merge conflicts in its STOP sentence again (ship-workflow-clarity pin) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(tree-receipt): keep the gated-to-current diff at the file helper timeout (60 s); pregate literals check Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(carry): large-diff fixture sets core.longpaths so Git for Windows can add its long receipt paths (windows-free-shard 1, run 41210080055) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review): a stale local base branch yields to its origin twin in gate-diff and diff-scope (GST-462) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship): Step 11 saves the targeted record and the receipt writes carry it; Step 9 clears it (GST-464) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: GST-464 and GST-462 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(review): pass 1: ahead and diverged labels, diff-scope needs shared history; preflight refreshes origin/ and stops on a diff far beyond the PR (GST-462, HARN-15) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pass-2 review fixes for base twin, prSized stop and targeted record Resolve the tracking twin by refs/remotes// and only for a bare branch name, keep a local base that is ahead or diverged, quote the prSized stop's base and name the fork case, and have every Step 9 entry create, exclude and clear .gstack/tmp/targeted.json. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: origin's tracking base wins whenever related; prSized lower bound The fix-check found that keeping a local base ahead of origin left unpushed base commits out of the gate scan while review-plan listed them. The tracking branch now wins whenever it shares history with HEAD, an explicit origin/main reads refs/remotes/origin/main, the preflight also stops when the diff lists fewer files than the PR, and the Step 9 exclude line survives a missing .git/info and an exclude file without a final newline. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: the tracking-ref claim holds while the tracking branch exists Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: repin the two ship section briefs under no-loss replay GST-464 GST-464 brief-identity check: every reviewer brief lib/review-brief.ts cuts from ship/sections/review-army.md and adversarial.md stays byte-identical to the bodies the L and GST-257 replays admitted; only lead instructions outside the cut spans changed. The check is a test CI runs. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship: keep Step 9's PASS_HEAD sentence whole; repin review-army under GST-464 The targeted-record line follows the PASS_HEAD/RANGE_BASE sentence instead of splitting it (test/review-fix-range.test.ts pins that sentence). The brief-body check still holds: every reviewer brief is byte-identical. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: restore bin/gstack-ship-receipt after the main merge The merge commit b10e2db wrote a truncated copy of the file. This is the three-way merge of both sides with the refused() union: main's codes plus RECEIPT_CARRY_SCOPED_REVIEW. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: narrow the consumer scan and give it one 300 s deadline (GST-544) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: keep the consumer scan deadline under the 180 s plan timeout (review fix) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: plain paths under --literal-pathspecs; whole-millisecond timeout override (review fix) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: whole-tree grep for non-UTF-8 names, no argument spread, name spawn errors (review fix) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: cap the consumer grep output at 256 MB across calls; per-scan deadline wording (review fix, cycle 4) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-collect: read a missing spawn status as null (Bun 1.4.2 returns undefined on ENOENT) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: review-collect whole-tree helper reads a null status as -1 (typecheck:test ratchet) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-bots: /review and /ship triage every configured review bot, not only Greptile (#3122) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (gh before 2.48 pages without --slurp; driver routes Step 10; tests for guards, review-bot fence, REMOTE_SLUG owner) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: drop the review-bot fence test that could not fail (the tool-fence WARN degrade is unreachable: placeholder spans are skipped first) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: Step 11 review fixes (record by comment id so a filename never reaches a shell; lookup failures are errors; tojson pages; longest bot prefix wins) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pass-2 review fixes (record refuses * paths, colliding ids and a missing fetch dir; parent requires id and dir; botOwning doc) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review: classify the PR type and always check repo conventions (#356) The checklist now opens with a PR-type line (application, CI/infra, scripts/tooling, docs-only or mixed). Application and mixed diffs run every category; other types always run five categories, including the new Repo Conventions & Platform Fit, and report the rest as not applicable in one line instead of skipping silently. No-loss replay: GSTA-224 H1 preregistered no-loss run (run id gsta224-h1-20261031, Opus 5.5, 81 calls, $9.53) against main's checklist with a no-gstack arm; every preregistered bar passed. The review/checklist.md pin in test/review-packets-removed.test.ts moves to a32963ef with replay 'GSTA-224 H1'. Refs GSTA-224 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review-bots: allowlist the record placeholders and match Step 10's id rule in tests The record fence uses , and , each with an enum or numeric grammar; becomes . review/greptile-triage.md also lists every REVIEW_BOTS skip reason. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: review-bot triage covers every configured bot (#3122) README, CONTRIBUTING, the contributor reference and standalone-binaries name gstack-review-bots and the review-bot fence; TODOS drops the #3122 item; the changelog fragment covers record-by-id and lookup errors. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: the PR-type test also pins the compose, Terraform and README/CHANGELOG phrases Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: follow the review-bot rename in the remote free tier's three reds The cross-skill consistency judge describes review-bot-history.md and its record helper; the tracker-guard exemption for the removed raw Greptile fetch in review/greptile-triage.md is dropped (the fetch now lives in gstack-review-bots, whose bodies still reach context only through gstack-issue-guard); the Step 10 PR-check test expects 'Review bots: not run'. HARNESS_VERSION stays 6: skill-fixture.ts and llm-judge.ts are recorded non-behavioral for every other case. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: keep the cross-skill judge's rubric to one renamed bullet Name review-bot-history.md beside the older greptile-history.md so the calibration corpus still matches, and keep the REMOTE_SLUG bullet. One live 3-sample panel at this tree: consistent 3/3, scores 4/4/4. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: H1 fragment passes prose lint Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: name the H1 fragment after its branch; TODOS drops #356 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: /review's PR type step in docs/skills.md (#356) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship-policy: review_exclude_paths key and loadPolicyAt (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * review: apply the base policy's review_exclude_paths and the reviewer diff ceiling (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * receipt: bind review_exclude in write, carry and the queue (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs, tests and changelog for review_exclude_paths (GST-508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (binary by bytes, links kept, untracked files out of the selection) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: keep binary files at code paths under review_exclude_paths Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: name the reasons that keep a binary file under review_exclude_paths Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: keep every review_exclude_paths candidate when the gate scan is unknown; docs example names its version Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: keep the NUL fixture clear of the sync-spawn tripwire Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: split the ceiling sentence Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: keep a live binary file whose bytes cannot be read; tests render outside voices from a clean checkout and read the ship fixture text Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test(review-exclude): explicit +x for the census script; skip the chmod-000 read case on Windows and root Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * refactor: move loadPolicyAt to lib/ship-policy-at.ts so lib/ship-policy.ts stays under the 800-line module cap Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: refuse a base that contains HEAD; skip a self-pointing origin/HEAD (GST-774) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * chore: regenerate gstack-doctor-components.sh for BASE_CONTAINS_HEAD Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: land resumes a merged merge-only PR instead of refusing BASE_CONTAINS_HEAD (GST-774 review) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: changelog fragment for GST-774 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: troubleshooting names diff-scope base_contains_head and the self-pointing no_base case (GST-774 docs audit) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: repin the reviewer briefs to GST-508's no-loss-tested bytes ship/sections/review-army.md, ship/sections/adversarial.md and lib/review-depth.ts now pin the bytes the GST-508 preregistered no-loss replay ran at ef2760f (handoffs/GSTA-202/noloss-results.md in the GStack Minder drive): Arm V 33/41 vs R 33/41, delta 4, exact sign flip, p_NI 0.0279 (pass). The merge of main 83ae96e leaves these three files byte-identical to ef2760f, and an Arm P unit (3593) renders byte-identical briefs at ef2760f and at the merge. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: GST-774 review round 1 — merged resume depth, aliased and detached PR checkouts, develop/trunk defaults Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship: Step 20 says a metrics row, keeping DRIVER.md at 12 KB after the main merge Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * test: ship-parts resend case leaves room for the first phase-3 part after the Step 9 targeted-record sentence Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: /ship delivers review/checklist.md in two parts so checklist v1 fits the 24576-byte part cap (#3670) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * changelog: drop the GST-407 and GST-430 fragments, already released on main (stacked history) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * wave review-53cfb5bfe011: lib/ship-policy.ts back to 800 lines (module-size ratchet after merging #3744 and #3795) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * wave review-53cfb5bfe011: /ship pass 1 fixes - lib/ship-receipt-depth.ts: a merged resume (land after a true merge) no longer recomputes the review_exclude digest over the emptied range, so it lands instead of RECEIPT_INVALID (failing-first land test with review_exclude_paths active). - bin/gstack-review-dispatch render: a standalone targeted render under an active review_exclude_paths refuses and points at the pass manifest voices stage, instead of writing a brief with no selection that leaves verify dirty (failing-first test). - test/default-base.test.ts: #3795 expectations follow main R51 depth (light for an 80-line code diff; runtime_lines=80 still proves the real base). - test/review-dispatch.test.ts: the GST-897 fingerprint test renders from the clean checkout, like its neighbor, because CI rebuilds the tracked lib/diagram-render/dist/diagram-render.html and the reviewer diff ceiling refused the ROOT render. * wave review-53cfb5bfe011: /ship pass 2 fixes - lib/review-exclude.ts: binaryContent reads each blob's first 8,000 bytes (git cat-file blob, 8 KB buffer) instead of one --batch read capped at 256 MB, so head mode (receipt, carry, queue) and the plan agree past 256 MB of blobs; an unreadable blob is kept, as in live mode. Failing-first test with two 270 MB blobs. - lib/review-bots.ts: a file-level bot review comment (subject_type file, no line position) is triaged instead of read as outdated. Failing-first test. - test/ship-queue-land.test.ts: the merged-resume exclusion test runs its gate scan under the fixture state root, not the real home (CI free-suite 6 home containment). * fix: merge follow-ups for main 3d99c22: origin/* stays qualified in diff-scope's twin step, retro skeleton back under its cap, combined no-loss pin GST-508+R51+GST-911 * fix(review): receipt write gate-scans whenever the base declares review_exclude_paths; collectLive never re-qualifies origin/ (#3852 /ship red-team#1, outside-voice#1) * test: the docs-only receipt digest test keeps its gate scan out of the real home (free-suite shard 5 FREE_SUBSHARD_REJECTED) * fix(merge fc292e22f): tentative REVIEW_EXCLUDE_KEY_VERSION, classify targeted.json, render main's new outside-voice test from a clean checkout - lib/ship-policy.ts: REVIEW_EXCLUDE_KEY_VERSION 1.93.0.0 -> 1.94.0.0, the next-minor tentative form stamp_paths moves (docs/ship-policy.md, #3512); 1.93.0.0 is a released heading that never names the key. - test/gstack-clean-producers.test.ts (new from main): KEPT gains targeted.json, the wave's --review-targeted input. - test/review-dispatch.test.ts: main's wrong-tree test rendered the outside voice from ROOT; a CI build that dirties ROOT pushes that diff past the wave's REVIEW_DIFF_MAX_BYTES ceiling, so render refused and verify saw no brief (exit 3). It now runs in cleanCheckout like the wave's other outside-voice tests. * test(merge 68410828f): GST-967's brief-body pin carries the wave's GST-508 placeholders The merged sectionTexts differ from main's by exactly the wave's GST-508 exclude-pathspec lines (merged minus main equals wave minus fc292e22f); the 1,440-case plan grid still hashes to main's MAIN_PLANS. Checks: GStack Minder drive handoffs/GSTA-202/merge-6841-checks.md. * ship: CI carries mapped lanes, --reuse tree cache, early push, finish/accept split (GSTA-258 A) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * ship: name the ship and pregate bins in prose so skill-bin-drift does not read a bin Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * size-ledger: re-record ship after the tests.md wording fix Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * pregate: a carried run clears the remote gate through remote_gate_runs, so a paid-only remainder is not a dead end Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * merge cleanup: drop wave fragments main already consumed and a duplicated KEPT entry Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix(ship): record-ci verifies the CI run itself; finish's deferred preflight keeps pregate.json /ship pass 1 findings red-team#1 and specialist-batched#1 (GSTA-258 piece A). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * feat(pregate): CI carry is gstack's default remote gate route; the VM is opt-in (plan choice F1) The uncleared remote_gate obligation names the CI route first when the base declares remote_gate_runs. docs/pregate.md says how gstack clears it, including the pull_request merge-ref tree mismatch. GSTA-258 piece A. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * fix: pre-landing review fixes (round 2) record-ci records the base policy that mapped the lane; the CI-first remote gate hint respects --no-ci-carry and reruns the whole pregate; changelog and docs say what the tool does. GSTA-258 piece A. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * docs: CI carry in CONTRIBUTING, recommended-harness and the pregate usage line (ship docs audit) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- .gstack/pregate.json | 3 + CHANGELOG.md | 9 + CONTRIBUTING.md | 3 +- VERSION | 2 +- agents-digest/gstack-AGENTS.md | 2 +- bin/gstack-ci-carry | 77 +++++++ bin/gstack-evidence | 166 ++++++++++++++- bin/gstack-pregate | 8 +- bin/gstack-ship-receipt | 8 +- docs/pregate.md | 119 ++++++++++- docs/recommended-harness.md | 4 +- lib/ci-carry.ts | 132 ++++++++++++ lib/headless-artifacts.ts | 3 + lib/pregate/checks/lanes.ts | 16 +- lib/pregate/config.ts | 16 +- lib/pregate/index.ts | 58 +++++- lib/pregate/types.ts | 2 + lib/ship-bin-common.ts | 55 ++++- lib/ship-preflight.ts | 13 +- lib/ship-receipt.ts | 3 +- lib/ship-release.ts | 96 ++++++++- package.json | 2 +- ship/DRIVER.md | 17 +- ship/DRIVER.md.tmpl | 17 +- ship/sections/tests.md | 16 ++ ship/sections/tests.md.tmpl | 16 ++ test/ci-carry.test.ts | 111 ++++++++++ test/evidence-reuse.test.ts | 141 +++++++++++++ test/helpers/fake-gh-runs.ts | 45 ++++ test/pregate-carry-gate.test.ts | 98 +++++++++ test/ship-ci-carry.test.ts | 194 ++++++++++++++++++ .../size-ledger/ship/gsta-258-a-ci-carry.json | 4 + 32 files changed, 1395 insertions(+), 61 deletions(-) create mode 100755 bin/gstack-ci-carry create mode 100644 lib/ci-carry.ts create mode 100644 test/ci-carry.test.ts create mode 100644 test/evidence-reuse.test.ts create mode 100644 test/helpers/fake-gh-runs.ts create mode 100644 test/pregate-carry-gate.test.ts create mode 100644 test/ship-ci-carry.test.ts create mode 100644 test/size-ledger/ship/gsta-258-a-ci-carry.json diff --git a/.gstack/pregate.json b/.gstack/pregate.json index 5d1caa4f3..1dded7b5f 100644 --- a/.gstack/pregate.json +++ b/.gstack/pregate.json @@ -27,6 +27,9 @@ "inventory": "bun --no-env-file --config=/dev/null run scripts/test-free-shards.ts --list | sed -n 's/^ //p'", "skipped": "bun --no-env-file --config=/dev/null -e 'import { isPaidTestFile } from \"./test/helpers/paid-test-set.ts\"; import * as fs from \"node:fs\"; for (const f of fs.readFileSync(process.env.PREGATE_FILES_FILE, \"utf8\").split(/\\r?\\n/)) if (f && isPaidTestFile(f)) console.log(f);'" }, + "ship_lanes_from": { + "bun run test": { "profiles": ["ci-reuse/free-tests"], "inventory": "bun --no-env-file --config=/dev/null run scripts/test-free-shards.ts --list | sed -n 's/^ //p'" } + }, "warn": [], "strays": { "allow": ["modules/loadouts.json", "modules/loadouts.schema.json"] } } diff --git a/CHANGELOG.md b/CHANGELOG.md index b27b94ae1..945e76db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [1.94.0.0] - 2026-11-03 + +- CI is now the one full test run. When a verified CI run already passed at the exact, clean tree, `gstack-pregate`'s tests stage and /ship's test lanes use it instead of running the suite again (GSTA-258, R65 item 1). The tests stage looks up the newest verified run at HEAD under the base branch's `run_profiles` by itself (`CI_CARRY: accepted …`; `--no-ci-carry` turns it off). A /ship lane carries only when the base branch's `.gstack/pregate.json` maps its exact command in the new `ship_lanes_from` key, and only when the run's `tree.json` covers the lane's inventory; gstack maps `bun run test` to its Free Tests run. A carried lane prints `LANE: