From af9c2353997cb0e55789407007aef9e729e04d62 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 28 Nov 2026 20:30:01 -0500 Subject: [PATCH] Codex second-model reviews in /gstack-ship now count, and the shipping record carries them (GST-4148) (#4889) When /gstack-ship's second-model review runs on Codex, the review record now names the Codex model and its family, so it counts as a second-model review instead of being recorded as unavailable. Why: shipping records should say which second model reviewed a change; Codex reviews were silently dropped from that record, and live records never carried it. Nothing to do: if Codex can't run, that is still recorded and never blocks shipping. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=state-machines Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p2/outside-voice#2 reader=outside-voice Review-Finding: p2/outside-voice#4 reader=outside-voice Review-Finding: p3/outside-voice#1 reader=outside-voice --- bin/gstack-review-dispatch | 17 +++-- .../garrytan-codex-outside-status-family.md | 1 + docs/review-policy.md | 6 +- docs/ship-policy.md | 10 ++- docs/troubleshooting.md | 30 ++++++++ lib/outside-voice-record.ts | 9 ++- lib/review-ledger.ts | 4 +- scripts/resolvers/outside-voice-steps.ts | 4 +- scripts/resolvers/outside-voice.ts | 10 ++- ship/DRIVER.md | 4 +- ship/DRIVER.md.tmpl | 4 +- ship/sections/adversarial.md | 12 +-- ship/sections/adversarial.md.tmpl | 2 +- ship/sections/pr-body.md | 4 +- ship/sections/pr-body.md.tmpl | 4 +- ship/sections/review-army.md | 2 +- ship/sections/review-army.md.tmpl | 2 +- .../files/ship/sections/adversarial.md.json | 2 +- .../files/ship/sections/review-army.md.json | 2 +- .../review-pins/replays/GST-4148.json | 1 + test/gstack-clean-producers.test.ts | 1 + test/outside-voice-family.test.ts | 73 +++++++++++++++++-- test/review-pass-step11.test.ts | 24 ++++++ .../garrytan-codex-outside-status-family.json | 4 + 24 files changed, 189 insertions(+), 43 deletions(-) create mode 100644 changelog.d/garrytan-codex-outside-status-family.md create mode 100644 test/fixtures/review-pins/replays/GST-4148.json create mode 100644 test/size-ledger/ship/garrytan-codex-outside-status-family.json diff --git a/bin/gstack-review-dispatch b/bin/gstack-review-dispatch index 551b61005..33ad78e59 100755 --- a/bin/gstack-review-dispatch +++ b/bin/gstack-review-dispatch @@ -7,7 +7,7 @@ * gstack-review-dispatch sent --ledger --role [--name ] --sent the prompt actually passed; mismatch fails * gstack-review-dispatch collect --ledger --role [--name ] --output --merged * gstack-review-dispatch judge --ledger --merged --judged no drop, no downgrade - * gstack-review-dispatch verify --ledger [--targeted-out ] replay every hash and the judgment + * gstack-review-dispatch verify --ledger [--targeted-out ] [--outside-voice-out ] replay every hash and the judgment * gstack-review-dispatch pass --base --out --pass [-- plan flags] the pass's staged manifest * gstack-review-dispatch show|stage|chunk|mark|retry --manifest ... one manifest step * gstack-review-dispatch program [--ledger ] the checked-in Capy pass program @@ -79,9 +79,9 @@ const HELP = `gstack-review-dispatch — verbatim reviewer briefs and loss-free duplicate folds into one at least as severe); added and promoted findings need a reason. JUDGMENT: ok …, or JUDGMENT_REJECTED: dropped=… downgraded=… (exit 1). An empty merged.jsonl needs no judged file: judge writes an empty one and prints JUDGMENT: ok nothing to judge; a merge with findings and no judged file is refused (exit 2) - verify --ledger [--targeted-out ] + verify --ledger [--targeted-out ] [--outside-voice-out ] on a clean ledger prints OUTSIDE_VOICE_RECORD: {"status","provider","model","family"[,"native_family"][,"reason"]} for the last - collected outside voice (gstack-ship-receipt write --outside-voice takes it; completed only for a recognized family beside a + collected outside voice, and --outside-voice-out writes it as JSON (a ledger with no outside voice leaves the file alone; one with an outside voice removes it first and writes it only when clean; gstack-ship-receipt write --outside-voice takes it; completed only for a recognized family beside a different recognized native family, else unavailable with the reason); a dirty ledger prints OUTSIDE_VOICE_RECORD_WITHHELD instead. A same-family outside read is OUTSIDE SAME_FAMILY, dirty BRIEF, OUTPUT and JUDGE rows from the ledger alone, then VERIFY: clean (exit 0), VERIFY: dirty (exit 1) or @@ -683,7 +683,7 @@ function main(): number { const outside = mayBeUnavailable(reader) ? outsideProvenance({ model: flag('--outside-model'), provider: flag('--outside-provider'), nativeModel: flag('--native-model'), output }) : undefined; const same = outside && unavailable === undefined ? sameFamily(outside) : undefined; if (same) { - process.stdout.write(`COLLECT_SAME_FAMILY: reader=${reader} model=${outside!.model} family=${outside!.family} native=${outside!.native_model} (${same}: a same-family fallback is one voice, never outside coverage; nothing was merged. Rerun the outside voice on another family. When no other family can read it, record the missing second-model read by collecting a file that holds only the reason, not this reply (--unavailable refuses output that holds findings), with --unavailable '')\n`); + process.stdout.write(`COLLECT_SAME_FAMILY: reader=${reader} model=${outside!.model} family=${outside!.family} native=${outside!.native_model} (${same}: a same-family fallback is one voice, never outside coverage; nothing was merged. Rerun the outside voice on another family. When no other family can read it, record the missing second-model read by collecting a file that holds only the reason, not this reply (--unavailable refuses output that holds findings), with --unavailable ''; docs/troubleshooting.md#collect-same-family)\n`); return EXIT.fail; } const asked = readLedger(ledger).filter(e => e.event === 'rendered' && e.reader === reader).at(-1)?.verdict === 1; @@ -734,6 +734,8 @@ function main(): number { return r.ok ? EXIT.ok : EXIT.fail; } if (cmd === 'verify') { + const outs = ['--targeted-out', '--outside-voice-out'].filter(f => flag(f)).map(f => path.resolve(flag(f)!)); + if (outs.includes(path.resolve(ledger)) || new Set(outs).size < outs.length) { process.stderr.write('gstack-review-dispatch verify: --targeted-out and --outside-voice-out must name two files other than --ledger\n'); return EXIT.usage; } if (flag('--targeted-out')) fs.rmSync(flag('--targeted-out')!, { force: true }); const v = verify(ledger); for (const r of v.rows) process.stdout.write(`${r.kind} ${r.reader} ${r.status} ${r.detail}\n`); @@ -751,8 +753,11 @@ function main(): number { if (sel && 'mixed' in sel) process.stdout.write(`REVIEW_EXCLUDE_RECORD: mixed digests=${sel.mixed.join(',')} (readers read different review_exclude_paths selections; rerun the review so every reader reads HEAD's)\n`); for (const r of slices) process.stdout.write(`${r.kind} ${r.reader} ${r.status} ${r.detail}\n`); const clean = v.clean && !(sel && 'mixed' in sel) && slices.every(r => r.status === 'MATCH'); - const voice = outsideVoiceRecord(ledger); - if (voice) process.stdout.write(clean ? `OUTSIDE_VOICE_RECORD: ${JSON.stringify(voice)}\n` : 'OUTSIDE_VOICE_RECORD_WITHHELD: VERIFY is dirty, so the outside voice\'s record does not bind; fix the rows above and verify again\n'); + const recorded = outsideVoiceRecord(ledger); + const voice = recorded?.reason ? { ...recorded, reason: recorded.reason.replace(/(^|[\s(])(?:~|\/)[^\s,;)]*/g, '$1') } : recorded; + if (voice) process.stdout.write(clean ? `OUTSIDE_VOICE_RECORD: ${JSON.stringify(voice)}\n` : 'OUTSIDE_VOICE_RECORD_WITHHELD: VERIFY is dirty, so the outside voice\'s record does not bind; fix the rows above and verify again (docs/troubleshooting.md#outside-voice-record-withheld)\n'); + if (voice && flag('--outside-voice-out')) fs.rmSync(flag('--outside-voice-out')!, { force: true }); + if (voice && clean && flag('--outside-voice-out')) fs.writeFileSync(flag('--outside-voice-out')!, JSON.stringify(voice) + '\n'); if (v.verdicts.asked) process.stdout.write(`VERIFY_VERDICT: agree=${v.verdicts.agree} asked=${v.verdicts.asked} (informational: a disagreeing count already counts its blockers; docs/review-policy.md#verdict-line)\n`); process.stdout.write(`VERIFY: ${clean ? 'clean' : 'dirty'} briefs=${v.briefs} outputs=${v.rows.filter(r => r.kind === 'OUTPUT').length} voided=${v.voided}${v.unavailable ? ` unavailable=${v.unavailable}` : ''}\n`); return clean ? EXIT.ok : EXIT.fail; diff --git a/changelog.d/garrytan-codex-outside-status-family.md b/changelog.d/garrytan-codex-outside-status-family.md new file mode 100644 index 000000000..91e81f7ad --- /dev/null +++ b/changelog.d/garrytan-codex-outside-status-family.md @@ -0,0 +1 @@ +**When /gstack-ship's second-model review runs on Codex, it now counts as a second-model review.** The Codex review's closing status line names the Codex model and its family, so the review record proves the reviewer came from a different model family than the one that wrote the code, instead of recording the Codex review as unavailable. /gstack-ship also saves that record once the review checks out and passes it to the shipping record by itself, so every shipping record says which second model reviewed the change. If Codex can't run, that is still recorded and still never blocks shipping (GST-4148). diff --git a/docs/review-policy.md b/docs/review-policy.md index da3355a91..158b8796c 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -1233,8 +1233,10 @@ ones, and the arm lost blockers. `bin/gstack-review-dispatch` closes both ends: missing coverage leaves the review incomplete. Collect also records who read the outside voice (GST-4140): the model and provider from `--outside-model` and `--outside-provider`, or else from the reply's closing `OUTSIDE_STATUS:` line, the lane's model from `--native-model`, and each family from its model id. A read in the native model's family is `COLLECT_SAME_FAMILY` - (exit 1, nothing merged), and a ledger that holds one anyway prints an `OUTSIDE SAME_FAMILY` row and is dirty. On a - clean ledger verify prints `OUTSIDE_VOICE_RECORD:` for `gstack-ship-receipt write --outside-voice` + (exit 1, nothing merged), and a ledger that holds one anyway prints an `OUTSIDE SAME_FAMILY` row and is dirty. A reply + whose closing line says `OUTSIDE_STATUS: unverified` still merges its findings but is recorded `unavailable`. On a + clean ledger verify prints `OUTSIDE_VOICE_RECORD:` (and `--outside-voice-out ` saves it as JSON) for + `gstack-ship-receipt write --outside-voice` ([ship-policy.md](ship-policy.md#the-ship-receipt)), and `OUTSIDE_VOICE_RECORD_WITHHELD:` instead on a dirty one. A mismatched send re-sent byte-exact before anything was collected is void and counted (`voided=N` on the verdict line); one that produced an output stays `MISMATCH`. Then output hashes diff --git a/docs/ship-policy.md b/docs/ship-policy.md index cad039c11..486abda11 100644 --- a/docs/ship-policy.md +++ b/docs/ship-policy.md @@ -1376,9 +1376,13 @@ reports an outside read it cannot prove cross-family (no model from the record only when `VERIFY` is clean (`OUTSIDE_VOICE_RECORD_WITHHELD:` otherwise). `--outside-voice` also takes pretty-printed JSON or `verify`'s whole output. The field is -optional, so receipts written before it stay valid, and `/gstack-ship`'s Step 19 -write does not pass `--outside-voice` yet: a receipt carries it only when the run -passes the flag (GST-4140). +optional, so receipts written before it stay valid. `/gstack-ship` runs +`verify --outside-voice-out .gstack/tmp/outside-voice.json`, which saves the record +only when `VERIFY` is clean, and Step 19's write passes `--outside-voice` with that +file whenever it exists (GST-4140). Codex's closing `OUTSIDE_STATUS:` line in +Step 11 names `model=` and `family=`, so a Codex read collected without +`--outside-model` still proves its family. A closing `OUTSIDE_STATUS: unverified` +records the read as `unavailable`, though its findings still merge. **`design`.** On a rendered-UI diff (`gstack-diff-scope` reports `SCOPE_FRONTEND=true` for the committed range, which counts CSS, views, diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 7d26dc6c9..7338c2cfa 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -4312,6 +4312,36 @@ find out why readers keep fetching (a brief or a checklist that sends them to another repository, or a sealed path the policy does not list yet) and start a fresh pass under a new `--pass` and `--out`. A third attempt is never automatic. + +### `COLLECT_SAME_FAMILY` + +**Meaning.** `gstack-review-dispatch collect` refused the second-model review +because its model is the same family as the lane's own model (a Claude reader +checking a Claude lane, for example). The model comes from `--outside-model` or +the reply's closing `OUTSIDE_STATUS: ... model=` line, the lane's from +`--native-model`, and each family from its model id. Nothing was merged: a +same-family read is one voice, never second-model coverage (GST-4140). + +**Fix.** Rerun the review on a model from another family (Codex or an OpenAI or +Google subagent beside a Claude lane). When no other family can run, write a +file that holds only the reason, not the reply, and collect it with +`--unavailable ''`. Missing second-model coverage is recorded as +unavailable and never blocks shipping. + + +### `OUTSIDE_VOICE_RECORD_WITHHELD` + +**Meaning.** `gstack-review-dispatch verify` found a dirty ledger (a row above +the verdict line is not `MATCH`, or `VERIFY: dirty`), so it did not print +`OUTSIDE_VOICE_RECORD:`, and `--outside-voice-out` removed any saved file. A record from a +ledger that does not verify would not prove who read the diff. + +**Fix.** Fix the rows `verify` printed (resend a mismatched brief, collect a +missing reply, rerun judge), then run `verify` again. Once it prints +`VERIFY: clean`, it prints the record, and `/gstack-ship` Step 19 passes the +saved file to `gstack-ship-receipt write --outside-voice`. Never write the +record by hand. + ### `EXECUTION_UNKNOWN` diff --git a/lib/outside-voice-record.ts b/lib/outside-voice-record.ts index 2d86ae3ec..096ff1b5a 100644 --- a/lib/outside-voice-record.ts +++ b/lib/outside-voice-record.ts @@ -15,8 +15,11 @@ export const UNPROVEN_NATIVE = 'the outside read recorded no recognizable native export const OUTSIDE_VOICE_STATUSES = ['completed', 'unavailable', 'skipped'] as const; export type OutsideVoiceStatus = typeof OUTSIDE_VOICE_STATUSES[number]; export interface OutsideVoiceRecord { status: OutsideVoiceStatus; provider: string; model: string; family: ModelFamily | string; native_family?: ModelFamily | string; reason?: string } -/** Who read: recorded on a collected outside voice's output event. */ -export interface OutsideProvenance { provider: string; model: string; family: ModelFamily | string; native_model?: string; native_family?: ModelFamily | string } +/** Who read: recorded on a collected outside voice's output event; `reported` is a closing OUTSIDE_STATUS other than completed (unverified). */ +export interface OutsideProvenance { provider: string; model: string; family: ModelFamily | string; native_model?: string; native_family?: ModelFamily | string; reported?: string } + +/** The reason verify records a read whose own closing line said it is not a completed review (GST-4148): findings still merge, coverage is missing. */ +export const unverifiedRead = (status: string) => `the outside voice's closing line reported OUTSIDE_STATUS: ${status}, so its read is missing coverage, never a completed review`; /** * A model id's family: lib/outside-voice-runner.ts's rules on the whole id, then on its last path segment (a router prefix such as @@ -51,7 +54,7 @@ export function outsideProvenance(o: { model?: string; provider?: string; native const model = o.model ?? status?.model ?? 'unknown'; const family = familyOf(model); const native = o.nativeModel ? familyOf(o.nativeModel) : undefined; - return { provider: o.provider ?? status?.provider ?? 'unknown', model, family, ...(o.nativeModel ? { native_model: o.nativeModel, native_family: native } : {}) }; + return { provider: o.provider ?? status?.provider ?? 'unknown', model, family, ...(o.nativeModel ? { native_model: o.nativeModel, native_family: native } : {}), ...(status && status.status !== 'completed' ? { reported: status.status } : {}) }; } /** Why a read with this provenance is not outside coverage: the same family as the lane's native model. undefined when it may count. */ diff --git a/lib/review-ledger.ts b/lib/review-ledger.ts index 08dacd9a4..2295e26a7 100644 --- a/lib/review-ledger.ts +++ b/lib/review-ledger.ts @@ -19,7 +19,7 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; import { checkReviewedTree, isReviewedTreeLine, promptHash, type TreeCheck } from './review-brief'; import { parseVerdict, withoutVerdictLines } from './review-verdict'; -import { UNPROVEN_FAMILY, unprovenCoverage, type OutsideProvenance, type OutsideVoiceRecord } from './outside-voice-record'; +import { UNPROVEN_FAMILY, unprovenCoverage, unverifiedRead, type OutsideProvenance, type OutsideVoiceRecord } from './outside-voice-record'; export interface LedgerEvent { event: 'rendered' | 'sent' | 'output' | 'judgment' | 'judge' | 'program' | 'quarantined' | 'fetch-sweep'; [k: string]: unknown } export const readerKey = (role: string, name?: string, slice?: { index: number; total: number }) => `${name ? `${role}/${name}` : role}${slice ? `#${slice.index}/${slice.total}` : ''}`; @@ -472,7 +472,7 @@ export function outsideVoiceRecord(ledger: string): OutsideVoiceRecord | undefin if (!o) return undefined; const p = provenance(o); const family = p?.family ?? 'unknown'; - const reason = unavailableOutput(o) ? String(o.unavailable) : p ? unprovenCoverage(p) : UNPROVEN_FAMILY; + const reason = unavailableOutput(o) ? String(o.unavailable) : p?.reported ? unverifiedRead(p.reported) : p ? unprovenCoverage(p) : UNPROVEN_FAMILY; return { status: reason ? 'unavailable' : 'completed', provider: p?.provider ?? 'unknown', model: p?.model ?? 'unknown', family, ...(p?.native_family ? { native_family: p.native_family } : {}), ...(reason ? { reason } : {}) }; } diff --git a/scripts/resolvers/outside-voice-steps.ts b/scripts/resolvers/outside-voice-steps.ts index 147879cf9..46214d8e1 100644 --- a/scripts/resolvers/outside-voice-steps.ts +++ b/scripts/resolvers/outside-voice-steps.ts @@ -153,7 +153,7 @@ Outside prompt (supply repository context from the parent): "${CODEX_BOUNDARY}Review the changes on this branch against the base branch. Use the supplied branch diff. If it was not supplied and you have repository tools, run DIFF_BASE=$(git merge-base origin/ HEAD) && git diff "$DIFF_BASE". Your job is to find ways this code will fail in production. Think like an attacker and a chaos engineer. Find edge cases, race conditions, security holes, resource leaks, failure modes, and silent data corruption paths. Be adversarial. Be thorough. No compliments — just the problems. A finding blocks only if it ${BLOCKING_FLOOR}; end each finding with \`Severity: Critical|High|Medium|Low\` and \`Blocks: yes|no\`. Then write ONE line in the canonical format \`Recommendation: because \`. Generic reasons like 'because it's safer' do not qualify; the reason must point to a specific finding or no-fix rationale. ${OUTSIDE_VERDICT_REQUEST}" -${!isShip && outsideVoiceFor(ctx).id === 'codex' ? outsideVoiceHelperInvocation(ctx, { pass: 'adversarial', gate: 'review' }) : outsideVoiceInvocation(ctx, { timeoutMs: 540000, nativeAlreadyRequired: isShip ? 'dispatched' : true, diffCommand: 'DIFF_BASE=$(git merge-base origin/ HEAD) && git diff "$DIFF_BASE"' })} +${!isShip && outsideVoiceFor(ctx).id === 'codex' ? outsideVoiceHelperInvocation(ctx, { pass: 'adversarial', gate: 'review' }) : outsideVoiceInvocation(ctx, { timeoutMs: 540000, nativeAlreadyRequired: isShip ? 'dispatched' : true, provenance: isShip, diffCommand: 'DIFF_BASE=$(git merge-base origin/ HEAD) && git diff "$DIFF_BASE"' })} Present the full output verbatim. A Critical, High or \`Blocks: yes\` finding is CRITICAL; \`Blocks: no\` never lowers one, and only a named policy ground drops it. ${isShip ? 'An unavailable outside challenge does not block shipping by itself; supported findings still enter Step 11, and the structured P0/P1 and non-convergence gates still apply.' : 'This outside challenge is informational; supported findings still enter Step 5 Fix-First, whose approval and convergence gates apply.'} @@ -172,7 +172,7 @@ function adversarialStructuredReview(ctx: TemplateContext, isShip: boolean): str ${isShip ? 'On \`DISPATCH: outside-voice\`, if' : 'If'} \`CODEX_MODE\` is \`ready\` or \`unverified\` and either \`DIFF_TOTAL >= 200\` or the user requested the override above: -${!isShip && outsideVoiceFor(ctx).id === 'codex' ? outsideVoiceHelperInvocation(ctx, { pass: 'structured', gate: 'structured', appendDiffBase: '' }) : outsideVoiceInvocation(ctx, { timeoutMs: 540000, nativeAlreadyRequired: isShip ? 'dispatched' : true, gate: 'structured', diffCommand: 'DIFF_BASE=$(git merge-base HEAD) && git diff "$DIFF_BASE"' })} +${!isShip && outsideVoiceFor(ctx).id === 'codex' ? outsideVoiceHelperInvocation(ctx, { pass: 'structured', gate: 'structured', appendDiffBase: '' }) : outsideVoiceInvocation(ctx, { timeoutMs: 540000, nativeAlreadyRequired: isShip ? 'dispatched' : true, provenance: isShip, gate: 'structured', diffCommand: 'DIFF_BASE=$(git merge-base HEAD) && git diff "$DIFF_BASE"' })} ${outsideVoiceFor(ctx).id === 'codex' ? '' : 'The Claude Code backend receives the parent-captured base diff, including committed and working-tree changes, because review mode cannot execute git.\n\n'}Present output under \`${outsideVoiceFor(ctx).label.toUpperCase()} SAYS (code review):\` inside a \`tool-output\` fence. Only a completed response ending with its \`VERDICT:\` line establishes the gate. P0/P1 findings (\`[P0]\`/\`[P1]\` or native \`P0:\`/\`P1:\` labels; \`VERDICT: findings\`) → GATE: FAIL. Completed without P0/P1 → GATE: PASS. Refusal, failure, missing markers or \`OUTSIDE_STATUS: unverified\` → GATE: MISSING COVERAGE; no fix question. diff --git a/scripts/resolvers/outside-voice.ts b/scripts/resolvers/outside-voice.ts index d08861e02..93eda9d81 100644 --- a/scripts/resolvers/outside-voice.ts +++ b/scripts/resolvers/outside-voice.ts @@ -99,6 +99,8 @@ export interface OutsideCommandOptions { nativeAlreadyRequired?: boolean | 'dispatched'; /** Resolve the plan-review policy once in the invocation shell and bind it through probe and dispatch. */ role?: OutsideRole; + /** /gstack-ship's dispatched voices: Codex's closing OUTSIDE_STATUS line names model= and family=, which collect needs to prove a second family (GST-4140). */ + provenance?: boolean; } /** One self-contained shell body. No shell functions/variables survive between blocks. */ @@ -111,6 +113,8 @@ export function outsideVoiceCommand(ctx: TemplateContext, opts: OutsideCommandOp // Every other gate lets run-with-timeout resolve GSTACK_CODEX_EFFORT, then codex_effort, then this default. const effort = opts.reasoningEffort ?? 'high'; const pinnedEffort = opts.gate === 'spec'; + const provenance = v.id === 'codex' && opts.provenance; + const status = (s: string) => provenance ? `"OUTSIDE_STATUS: ${s} provider=${v.id} host=${ctx.host} $_OUTSIDE_ID"` : `'OUTSIDE_STATUS: ${s} provider=${v.id} host=${ctx.host}'`; const effortFlag = pinnedEffort ? ` -c 'model_reasoning_effort="${effort}"'` : ''; const codex = `codex exec - -C "$_REPO_ROOT" -s "${CODEX_SANDBOX_REF}" ${CODEX_MODEL_CONFIG_FLAG}${effortFlag} ${CODEX_WEB_SEARCH_FLAG} --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT"`; const invocation = v.id === 'codex' @@ -144,12 +148,12 @@ fi` : ''} cat "$_OUTSIDE_TMP/stderr" >&2 || { [ "$_OUTSIDE_EXIT" -ne 0 ] || _OUTSIDE_EXIT=1; } _OUTSIDE_RC=0 bun --no-env-file --config=/dev/null "${root}/lib/outside-review-result.ts" --label '${v.label} outside review' --exit "$_OUTSIDE_EXIT" --stderr "$_OUTSIDE_TMP/stderr" ${v.id === 'codex' ? '--events "$_OUTSIDE_TMP/events" ' : ''}${opts.purpose === 'design-direction' ? 'proposal' : opts.gate ?? 'review'} "$_OUTSIDE_TMP/text" || _OUTSIDE_RC=$? -${v.id === 'claude-code' ? '[ "$_OUTSIDE_RC" -eq 1 ] || cat "$_OUTSIDE_TMP/text" || exit 1\n' : ''}case "$_OUTSIDE_RC" in +${v.id === 'claude-code' ? '[ "$_OUTSIDE_RC" -eq 1 ] || cat "$_OUTSIDE_TMP/text" || exit 1\n' : ''}${provenance ? `_OUTSIDE_ID="model=$_CODEX_SEL family=$("${bin}/gstack-outside-voice" family "$_CODEX_SEL" 2>/dev/null || echo unknown)"\n` : ''}case "$_OUTSIDE_RC" in 0|3) ;; - 4) echo 'OUTSIDE_STATUS: unverified provider=${v.id} host=${ctx.host}'; exit 4 ;; + 4) echo ${status('unverified')}; exit 4 ;; *) [ "$_OUTSIDE_EXIT" -ne 0 ] && exit "$_OUTSIDE_EXIT"; exit 1 ;; esac -echo 'OUTSIDE_STATUS: completed provider=${v.id} host=${ctx.host}'`; +echo ${status('completed')}`; } /** The reviewer's required last line: lib/outside-review-result.ts reads a review clean only from it. */ diff --git a/ship/DRIVER.md b/ship/DRIVER.md index 746df27be..a72ad571a 100644 --- a/ship/DRIVER.md +++ b/ship/DRIVER.md @@ -116,8 +116,8 @@ repo gates run with CI. Unattended, push defers the pre-push offer; else its STO ## 8. Publish: Steps 18, 19, 19-C, 20, 21, 22 - Step 18: the open-PR lookup; a plain `v ` title (`gstack-plain-title check`). `UNATTENDED_SHIP:` with no open PR at HEAD takes Step 18-H. -- Step 19 body: plain opening sentences, then sections `sections/pr-body.md` lists, led under `CAPY_PR: on` (Step 19-C) by What changed, Why and Blast radius; Agent notes last (receipt, `gstack-approvals render --plan`, `REVIEW_LOOP:`). `gstack-prose-lint --sections 'Why,Summary,Blast radius' --gate`; `gstack-issue-links`; `gstack-review-scope summary --since "$REVIEW_SINCE" --run && gstack-ship-receipt write --pr --run --base --gate @ --pregate --issues @ --review-loop @ --docs @ --budget-record [--review-exclude ] [--review-targeted @] --body `; `gstack-post pr-body` and `pr-title` (new PR: host PR tool; draft while a gate finding is `open`). `SHIP_RECEIPT:` opens your report. -- Steps 20 and 21 are skipped (no catch recorded, L; /retro gets no row). +- Step 19 body: plain opening sentences, then `sections/pr-body.md`'s sections, led under `CAPY_PR: on` (Step 19-C) by What changed, Why and Blast radius; Agent notes last (receipt, `gstack-approvals render --plan`, `REVIEW_LOOP:`). `gstack-prose-lint --sections 'Why,Summary,Blast radius' --gate`; `gstack-issue-links`; `gstack-review-scope summary --since "$REVIEW_SINCE" --run && gstack-ship-receipt write --pr --run --base --gate @ --pregate --issues @ --review-loop @ --docs @ --budget-record [--review-exclude ] [--outside-voice @] [--review-targeted @] --body `; `gstack-post pr-body` and `pr-title` (new PR: host PR tool; draft while a gate finding is `open`). `SHIP_RECEIPT:` opens your report. +- Steps 20-21 are skipped (no catch recorded, L; no /retro row). - Step 22: `gstack-ship-budget close --reading R --credits C` (report `BUDGET_FINAL:`, `BUDGET_TIMELINE:`, any `METER:` line), then `gstack-ship-receipt result --pr `: `GSTACK_RESULT: skill=ship status=complete head= run=`. Under a merge queue, `gstack-ship-queue ready --pr [--screen|--no-screen]` at the pushed head; paste its output. ## Where each STOP sends you (paths under `/ship/`) diff --git a/ship/DRIVER.md.tmpl b/ship/DRIVER.md.tmpl index 69d3b4b5a..fbfccb0e3 100644 --- a/ship/DRIVER.md.tmpl +++ b/ship/DRIVER.md.tmpl @@ -114,8 +114,8 @@ repo gates run with CI. Unattended, push defers the pre-push offer; else its STO ## 8. Publish: Steps 18, 19, 19-C, 20, 21, 22 - Step 18: the open-PR lookup; a plain `v ` title (`gstack-plain-title check`). `UNATTENDED_SHIP:` with no open PR at HEAD takes Step 18-H. -- Step 19 body: plain opening sentences, then sections `sections/pr-body.md` lists, led under `CAPY_PR: on` (Step 19-C) by What changed, Why and Blast radius; Agent notes last (receipt, `gstack-approvals render --plan`, `REVIEW_LOOP:`). `gstack-prose-lint --sections 'Why,Summary,Blast radius' --gate`; `gstack-issue-links`; `gstack-review-scope summary --since "$REVIEW_SINCE" --run && gstack-ship-receipt write --pr --run --base --gate @ --pregate --issues @ --review-loop @ --docs @ --budget-record [--review-exclude ] [--review-targeted @] --body `; `gstack-post pr-body` and `pr-title` (new PR: host PR tool; draft while a gate finding is `open`). `SHIP_RECEIPT:` opens your report. -- Steps 20 and 21 are skipped (no catch recorded, L; /retro gets no row). +- Step 19 body: plain opening sentences, then `sections/pr-body.md`'s sections, led under `CAPY_PR: on` (Step 19-C) by What changed, Why and Blast radius; Agent notes last (receipt, `gstack-approvals render --plan`, `REVIEW_LOOP:`). `gstack-prose-lint --sections 'Why,Summary,Blast radius' --gate`; `gstack-issue-links`; `gstack-review-scope summary --since "$REVIEW_SINCE" --run && gstack-ship-receipt write --pr --run --base --gate @ --pregate --issues @ --review-loop @ --docs @ --budget-record [--review-exclude ] [--outside-voice @] [--review-targeted @] --body `; `gstack-post pr-body` and `pr-title` (new PR: host PR tool; draft while a gate finding is `open`). `SHIP_RECEIPT:` opens your report. +- Steps 20-21 are skipped (no catch recorded, L; no /retro row). - Step 22: `gstack-ship-budget close --reading R --credits C` (report `BUDGET_FINAL:`, `BUDGET_TIMELINE:`, any `METER:` line), then `gstack-ship-receipt result --pr `: `GSTACK_RESULT: skill=ship status=complete head= run=`. Under a merge queue, `gstack-ship-queue ready --pr [--screen|--no-screen]` at the pushed head; paste its output. ## Where each STOP sends you (paths under `/ship/`) diff --git a/ship/sections/adversarial.md b/ship/sections/adversarial.md index 6880a18a9..33b736490 100644 --- a/ship/sections/adversarial.md +++ b/ship/sections/adversarial.md @@ -6,7 +6,7 @@ above 0 the plan lists it beside the batched specialist), print `ADVERSARIAL: skipped (review plan)`; with neither line, take decision 3 of Finish the adversarial phase. The native pass takes its line's `checklists=` and `classes=` as render flags and runs on its `model=` (`lane`: yours). On `DISPATCH: targeted`, also run the targeted reader -(`gstack-review-dispatch render --role targeted --classes --base --diff-base `, the merge base on every pass, never RANGE_BASE) like the voices; `verify --targeted-out .gstack/tmp/targeted.json` feeds the receipt's `--review-targeted`. Under a token cap, +(`gstack-review-dispatch render --role targeted --classes --base --diff-base `, the merge base on every pass, never RANGE_BASE) like the voices; `verify --targeted-out .gstack/tmp/targeted.json` feeds the receipt's `--review-targeted`. Collect the outside voice with `--native-model `, and add `--outside-voice-out .gstack/tmp/outside-voice.json` to every `verify`, for the receipt's `--outside-voice`. Under a token cap, reserve the planned voices as one batch (`gstack-ship-budget check --next dispatch:`) and add `--reservation ` to the `--start adversarial-review` call below. After `NEXT: voices` (gate class: Step 11 before any stop), Finish the adversarial phase takes neither @@ -157,12 +157,13 @@ cat "$_OUTSIDE_TMP/text" 2>/dev/null || tail -n 20 "$_OUTSIDE_TMP/events" cat "$_OUTSIDE_TMP/stderr" >&2 || { [ "$_OUTSIDE_EXIT" -ne 0 ] || _OUTSIDE_EXIT=1; } _OUTSIDE_RC=0 bun --no-env-file --config=/dev/null "$HOME/.claude/skills/gstack/lib/outside-review-result.ts" --label 'Codex outside review' --exit "$_OUTSIDE_EXIT" --stderr "$_OUTSIDE_TMP/stderr" --events "$_OUTSIDE_TMP/events" review "$_OUTSIDE_TMP/text" || _OUTSIDE_RC=$? +_OUTSIDE_ID="model=$_CODEX_SEL family=$("$HOME/.claude/skills/gstack/bin/gstack-outside-voice" family "$_CODEX_SEL" 2>/dev/null || echo unknown)" case "$_OUTSIDE_RC" in 0|3) ;; - 4) echo 'OUTSIDE_STATUS: unverified provider=codex host=claude'; exit 4 ;; + 4) echo "OUTSIDE_STATUS: unverified provider=codex host=claude $_OUTSIDE_ID"; exit 4 ;; *) [ "$_OUTSIDE_EXIT" -ne 0 ] && exit "$_OUTSIDE_EXIT"; exit 1 ;; esac -echo 'OUTSIDE_STATUS: completed provider=codex host=claude' +echo "OUTSIDE_STATUS: completed provider=codex host=claude $_OUTSIDE_ID" ``` Use Bash `timeout: 600000`; show the full response in a `tool-output` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing score/severity/completion markers, timeout or CLI failure means `outside_status: unavailable`. P0/P1 findings block like native ones; `OUTSIDE_STATUS: unverified` is missing coverage. A dispatched native pass runs once either way; outside output cannot complete it. After either outcome, delete only your private prompt; scratch cleanup is automatic. @@ -217,12 +218,13 @@ cat "$_OUTSIDE_TMP/text" 2>/dev/null || tail -n 20 "$_OUTSIDE_TMP/events" cat "$_OUTSIDE_TMP/stderr" >&2 || { [ "$_OUTSIDE_EXIT" -ne 0 ] || _OUTSIDE_EXIT=1; } _OUTSIDE_RC=0 bun --no-env-file --config=/dev/null "$HOME/.claude/skills/gstack/lib/outside-review-result.ts" --label 'Codex outside review' --exit "$_OUTSIDE_EXIT" --stderr "$_OUTSIDE_TMP/stderr" --events "$_OUTSIDE_TMP/events" structured "$_OUTSIDE_TMP/text" || _OUTSIDE_RC=$? +_OUTSIDE_ID="model=$_CODEX_SEL family=$("$HOME/.claude/skills/gstack/bin/gstack-outside-voice" family "$_CODEX_SEL" 2>/dev/null || echo unknown)" case "$_OUTSIDE_RC" in 0|3) ;; - 4) echo 'OUTSIDE_STATUS: unverified provider=codex host=claude'; exit 4 ;; + 4) echo "OUTSIDE_STATUS: unverified provider=codex host=claude $_OUTSIDE_ID"; exit 4 ;; *) [ "$_OUTSIDE_EXIT" -ne 0 ] && exit "$_OUTSIDE_EXIT"; exit 1 ;; esac -echo 'OUTSIDE_STATUS: completed provider=codex host=claude' +echo "OUTSIDE_STATUS: completed provider=codex host=claude $_OUTSIDE_ID" ``` Use Bash `timeout: 600000`; show the full response in a `tool-output` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing score/severity/completion markers, timeout or CLI failure means `outside_status: unavailable`. P0/P1 findings block like native ones; `OUTSIDE_STATUS: unverified` is missing coverage. A dispatched native pass runs once either way; outside output cannot complete it. After either outcome, delete only your private prompt; scratch cleanup is automatic. diff --git a/ship/sections/adversarial.md.tmpl b/ship/sections/adversarial.md.tmpl index 2f3b841b8..4407fb76c 100644 --- a/ship/sections/adversarial.md.tmpl +++ b/ship/sections/adversarial.md.tmpl @@ -4,7 +4,7 @@ above 0 the plan lists it beside the batched specialist), print `ADVERSARIAL: skipped (review plan)`; with neither line, take decision 3 of Finish the adversarial phase. The native pass takes its line's `checklists=` and `classes=` as render flags and runs on its `model=` (`lane`: yours). On `DISPATCH: targeted`, also run the targeted reader -(`gstack-review-dispatch render --role targeted --classes --base --diff-base `, the merge base on every pass, never RANGE_BASE) like the voices; `verify --targeted-out .gstack/tmp/targeted.json` feeds the receipt's `--review-targeted`. Under a token cap, +(`gstack-review-dispatch render --role targeted --classes --base --diff-base `, the merge base on every pass, never RANGE_BASE) like the voices; `verify --targeted-out .gstack/tmp/targeted.json` feeds the receipt's `--review-targeted`. Collect the outside voice with `--native-model `, and add `--outside-voice-out .gstack/tmp/outside-voice.json` to every `verify`, for the receipt's `--outside-voice`. Under a token cap, reserve the planned voices as one batch (`gstack-ship-budget check --next dispatch:`) and add `--reservation ` to the `--start adversarial-review` call below. After `NEXT: voices` (gate class: Step 11 before any stop), Finish the adversarial phase takes neither diff --git a/ship/sections/pr-body.md b/ship/sections/pr-body.md index 19225423b..2a2b8de26 100644 --- a/ship/sections/pr-body.md +++ b/ship/sections/pr-body.md @@ -252,9 +252,11 @@ per-lane counts (`{"":{"pass":N,"fail":N,"skip":N}}`) to rm .gstack/tmp/review-loop.json 2>/dev/null || true NS=$(~/.claude/skills/gstack/bin/gstack-no-stop list | sed -n 's/^NO_STOP_FILE: //p'); [ -s "$NS" ] || NS= ~/.claude/skills/gstack/bin/gstack-review-scope summary --since "$REVIEW_SINCE" --no-ledger --out .gstack/tmp/review-loop.json && -~/.claude/skills/gstack/bin/gstack-ship-receipt write --pr --run --base --gate @.gstack/tmp/ship-gate.json --pregate .gstack/tmp/pregate.json --issues @.gstack/tmp/issues.json --review-loop @.gstack/tmp/review-loop.json --docs @.gstack/tmp/docs-audit.json $([ -s .gstack/tmp/targeted.json ] && echo --review-targeted @.gstack/tmp/targeted.json) ${NS:+--no-stop "@$NS"} --body "$PR_BODY_FILE" +~/.claude/skills/gstack/bin/gstack-ship-receipt write --pr --run --base --gate @.gstack/tmp/ship-gate.json --pregate .gstack/tmp/pregate.json --issues @.gstack/tmp/issues.json --review-loop @.gstack/tmp/review-loop.json --docs @.gstack/tmp/docs-audit.json $([ -s .gstack/tmp/targeted.json ] && echo --review-targeted @.gstack/tmp/targeted.json) $([ -s .gstack/tmp/outside-voice.json ] && echo --outside-voice @.gstack/tmp/outside-voice.json) ${NS:+--no-stop "@$NS"} --body "$PR_BODY_FILE" ``` +`--outside-voice` binds the record a clean `verify --outside-voice-out` saved (docs/troubleshooting.md#outside-voice-record-withheld). + If write refuses `review_targeted` for a docs claim added after the read, rerun Step 9's plan with `--range-base --targeted-ran `; on `NEXT: targeted`, run that one reader (`pass`, its voices stage, `verify --targeted-out .gstack/tmp/targeted.json`) and write again. diff --git a/ship/sections/pr-body.md.tmpl b/ship/sections/pr-body.md.tmpl index af5b2e1b2..90200643f 100644 --- a/ship/sections/pr-body.md.tmpl +++ b/ship/sections/pr-body.md.tmpl @@ -235,9 +235,11 @@ per-lane counts (`{"":{"pass":N,"fail":N,"skip":N}}`) to rm .gstack/tmp/review-loop.json 2>/dev/null || true NS=$(~/.claude/skills/gstack/bin/gstack-no-stop list | sed -n 's/^NO_STOP_FILE: //p'); [ -s "$NS" ] || NS= ~/.claude/skills/gstack/bin/gstack-review-scope summary --since "$REVIEW_SINCE" --no-ledger --out .gstack/tmp/review-loop.json && -~/.claude/skills/gstack/bin/gstack-ship-receipt write --pr --run --base --gate @.gstack/tmp/ship-gate.json --pregate .gstack/tmp/pregate.json --issues @.gstack/tmp/issues.json --review-loop @.gstack/tmp/review-loop.json --docs @.gstack/tmp/docs-audit.json $([ -s .gstack/tmp/targeted.json ] && echo --review-targeted @.gstack/tmp/targeted.json) ${NS:+--no-stop "@$NS"} --body "$PR_BODY_FILE" +~/.claude/skills/gstack/bin/gstack-ship-receipt write --pr --run --base --gate @.gstack/tmp/ship-gate.json --pregate .gstack/tmp/pregate.json --issues @.gstack/tmp/issues.json --review-loop @.gstack/tmp/review-loop.json --docs @.gstack/tmp/docs-audit.json $([ -s .gstack/tmp/targeted.json ] && echo --review-targeted @.gstack/tmp/targeted.json) $([ -s .gstack/tmp/outside-voice.json ] && echo --outside-voice @.gstack/tmp/outside-voice.json) ${NS:+--no-stop "@$NS"} --body "$PR_BODY_FILE" ``` +`--outside-voice` binds the record a clean `verify --outside-voice-out` saved (docs/troubleshooting.md#outside-voice-record-withheld). + If write refuses `review_targeted` for a docs claim added after the read, rerun Step 9's plan with `--range-base --targeted-ran `; on `NEXT: targeted`, run that one reader (`pass`, its voices stage, `verify --targeted-out .gstack/tmp/targeted.json`) and write again. diff --git a/ship/sections/review-army.md b/ship/sections/review-army.md index 33237394b..43fac7ae4 100644 --- a/ship/sections/review-army.md +++ b/ship/sections/review-army.md @@ -6,7 +6,7 @@ Set CYCLES to 0 on first entry only, with PASS set to 1, `REVIEW_SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ)` saved and the `ship: review_scope` policy line (Step 3) kept. Every entry saves `PASS_HEAD=$(git rev-parse HEAD)`; from pass 2 on, `RANGE_BASE` is the previous pass's PASS_HEAD. Every entry also runs -`mkdir -p .gstack/tmp && { rm .gstack/tmp/targeted.json 2>/dev/null || true; } && _EX=$(git rev-parse --git-path info/exclude) && mkdir -p "$(dirname "$_EX")" && { grep -qxF '/.gstack/tmp/' "$_EX" 2>/dev/null || printf '\n/.gstack/tmp/\n' >> "$_EX"; }` +`mkdir -p .gstack/tmp && { rm .gstack/tmp/targeted.json 2>/dev/null || true; rm .gstack/tmp/outside-voice.json 2>/dev/null || true; } && _EX=$(git rev-parse --git-path info/exclude) && mkdir -p "$(dirname "$_EX")" && { grep -qxF '/.gstack/tmp/' "$_EX" 2>/dev/null || printf '\n/.gstack/tmp/\n' >> "$_EX"; }` (a pass without the targeted reader leaves no record, and the record never reads as an uncommitted edit). Keep existing approvals; changed finding scope needs a new decision. Order: checklist/design, specialists (9.1), Red Team (9.2), QA (9.2.1), dedup (9.3), scope, fixes and logging (9.4). diff --git a/ship/sections/review-army.md.tmpl b/ship/sections/review-army.md.tmpl index d1170143a..153c5eb7c 100644 --- a/ship/sections/review-army.md.tmpl +++ b/ship/sections/review-army.md.tmpl @@ -4,7 +4,7 @@ Set CYCLES to 0 on first entry only, with PASS set to 1, `REVIEW_SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ)` saved and the `ship: review_scope` policy line (Step 3) kept. Every entry saves `PASS_HEAD=$(git rev-parse HEAD)`; from pass 2 on, `RANGE_BASE` is the previous pass's PASS_HEAD. Every entry also runs -`mkdir -p .gstack/tmp && { rm .gstack/tmp/targeted.json 2>/dev/null || true; } && _EX=$(git rev-parse --git-path info/exclude) && mkdir -p "$(dirname "$_EX")" && { grep -qxF '/.gstack/tmp/' "$_EX" 2>/dev/null || printf '\n/.gstack/tmp/\n' >> "$_EX"; }` +`mkdir -p .gstack/tmp && { rm .gstack/tmp/targeted.json 2>/dev/null || true; rm .gstack/tmp/outside-voice.json 2>/dev/null || true; } && _EX=$(git rev-parse --git-path info/exclude) && mkdir -p "$(dirname "$_EX")" && { grep -qxF '/.gstack/tmp/' "$_EX" 2>/dev/null || printf '\n/.gstack/tmp/\n' >> "$_EX"; }` (a pass without the targeted reader leaves no record, and the record never reads as an uncommitted edit). Keep existing approvals; changed finding scope needs a new decision. Order: checklist/design, specialists (9.1), Red Team (9.2), QA (9.2.1), dedup (9.3), scope, fixes and logging (9.4). diff --git a/test/fixtures/review-pins/files/ship/sections/adversarial.md.json b/test/fixtures/review-pins/files/ship/sections/adversarial.md.json index c6bae4625..94ef4bc4d 100644 --- a/test/fixtures/review-pins/files/ship/sections/adversarial.md.json +++ b/test/fixtures/review-pins/files/ship/sections/adversarial.md.json @@ -1 +1 @@ -{"sha":"63f0b646cbc3f3ea6dae42ee1072242f63105f9e579d52ac38f22a7ad5370c8c","replay":"GST-3562-part-2"} +{"sha":"0af3965410c0849e74cbff3f743137a2137bf0de2dbcc29f38661f27c4e53ab1","replay":"GST-4148"} diff --git a/test/fixtures/review-pins/files/ship/sections/review-army.md.json b/test/fixtures/review-pins/files/ship/sections/review-army.md.json index a5c0b7da0..a6129a93b 100644 --- a/test/fixtures/review-pins/files/ship/sections/review-army.md.json +++ b/test/fixtures/review-pins/files/ship/sections/review-army.md.json @@ -1 +1 @@ -{"sha":"da1d5170a1a63732382837483b68d997aa15eabb249c3dcbef834c38b78e5736","replay":"GST-3562-part-4"} +{"sha":"30f7246d67528699b730f727a38424bd6adb51037b17c818040be43d7ea1ae6f","replay":"GST-4148"} diff --git a/test/fixtures/review-pins/replays/GST-4148.json b/test/fixtures/review-pins/replays/GST-4148.json new file mode 100644 index 000000000..74286aeee --- /dev/null +++ b/test/fixtures/review-pins/replays/GST-4148.json @@ -0,0 +1 @@ +{"replay":"GST-4148","justification":"GST-4148 deterministic no-loss replay, no paid run (CREW rule 13: workflow prose that leaves every reviewer brief byte-identical). ship/sections/adversarial.md: the Codex block's closing OUTSIDE_STATUS line in Step 11 now names model= and family= (from the selected Codex model), and the intro tells every verify to add --outside-voice-out for the receipt's --outside-voice. ship/sections/review-army.md: the run-start cleanup also removes .gstack/tmp/outside-voice.json. No reviewer prompt, Codex prompt, effort, depth rule or dispatch changes: every reviewer brief cut from these sections renders byte-identical to its pinned body (brief-bodies pins unchanged, test/review-packets-removed.test.ts)."} diff --git a/test/gstack-clean-producers.test.ts b/test/gstack-clean-producers.test.ts index 1d13fd5bd..2891994a1 100644 --- a/test/gstack-clean-producers.test.ts +++ b/test/gstack-clean-producers.test.ts @@ -38,6 +38,7 @@ const KEPT: Record = { 'issues.json': '/ship issue links', 'docs-audit.json': '/ship documentation audit record', 'targeted.json': '/ship Step 11 targeted reader record (gstack-review-dispatch verify --targeted-out)', + 'outside-voice.json': '/ship second-model review record for the receipt (gstack-review-dispatch verify --outside-voice-out)', 'tree-receipt.json': 'gstack-tree-receipt output', 'base-red.json': '/ship base-red record', 'review-*': '/ship review loop records', diff --git a/test/outside-voice-family.test.ts b/test/outside-voice-family.test.ts index c40bf1fb4..7b0efa9f4 100644 --- a/test/outside-voice-family.test.ts +++ b/test/outside-voice-family.test.ts @@ -11,7 +11,7 @@ import * as path from 'node:path'; import { spawnSync } from 'node:child_process'; import { runScriptSync } from '../lib/script-invocation'; import { appendEvent, outsideVoiceRecord, readLedger, verify } from '../lib/review-ledger'; -import { familyOf, outsideProvenance, outsideVoiceProblem, parseOutsideStatus, sameFamily, UNPROVEN_FAMILY, UNPROVEN_NATIVE } from '../lib/outside-voice-record'; +import { familyOf, outsideProvenance, outsideVoiceProblem, parseOutsideStatus, sameFamily, UNPROVEN_FAMILY, UNPROVEN_NATIVE, unverifiedRead } from '../lib/outside-voice-record'; import { validateReceipt } from '../lib/ship-receipt'; const ROOT = path.resolve(import.meta.dir, '..'); @@ -40,7 +40,7 @@ const gitIn = (cwd: string, args: string[]) => spawnSync('git', ['-C', cwd, ...a * A clean ledger holding only the outside voice: its brief rendered in a clean checkout of HEAD and sent verbatim, a reply that * names that checkout's REVIEWED_TREE, then judge. verify prints OUTSIDE_VOICE_RECORD only on a ledger like this. */ -function cleanVoice(extra: string[], reply = REPLY) { +function cleanVoice(extra: string[], reply = REPLY, tree?: string) { if (!worktree) { worktree = path.join(fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'outside-family-wt-'))), 'wt'); const add = spawnSync('git', ['-C', ROOT, 'worktree', 'add', '--detach', worktree, 'HEAD'], { encoding: 'utf8', timeout: 120_000 }); @@ -51,13 +51,16 @@ function cleanVoice(extra: string[], reply = REPLY) { const inTree = (args: string[]) => runScriptSync(DISPATCH, args, { cwd: worktree, encoding: 'utf8', timeout: 60_000 }); const file = /file=(\S+)/.exec(inTree(['render', '--role', 'outside-voice', '--out', out, '--diff-base', gitIn(worktree, ['rev-parse', 'HEAD'])]).stdout)?.[1] ?? ''; expect(dispatch(['sent', '--ledger', ledger, '--role', 'outside-voice', '--sent', file]).status).toBe(0); - fs.writeFileSync(output, `REVIEWED_TREE: ${gitIn(worktree, ['rev-parse', 'HEAD^{tree}'])} ${worktree}\n` + reply); + fs.writeFileSync(output, `REVIEWED_TREE: ${tree ?? `${gitIn(worktree, ['rev-parse', 'HEAD^{tree}'])} ${worktree}`}\n` + reply); const c = inTree(['collect', '--ledger', ledger, '--role', 'outside-voice', '--output', output, '--merged', merged, ...extra]); - expect([c.status, c.stdout + c.stderr]).toEqual([0, expect.stringContaining('COLLECT: reader=outside-voice')]); + expect([c.status, c.stdout + c.stderr]).toEqual([0, expect.stringContaining(tree ? 'COLLECT_UNAVAILABLE: reader=outside-voice' : 'COLLECT: reader=outside-voice')]); expect(dispatch(['judge', '--ledger', ledger, '--merged', merged, '--judged', path.join(out, 'judged.jsonl')]).status).toBe(0); - const v = dispatch(['verify', '--ledger', ledger]); + const saved = path.join(out, 'outside-voice.json'); + const v = dispatch(['verify', '--ledger', ledger, '--outside-voice-out', saved]); expect([v.status, v.stdout]).toEqual([0, expect.stringContaining('VERIFY: clean')]); - return v.stdout.split('\n').find(l => l.startsWith('OUTSIDE_VOICE_RECORD:')); + const line = v.stdout.split('\n').find(l => l.startsWith('OUTSIDE_VOICE_RECORD:')); + expect(fs.existsSync(saved) ? `OUTSIDE_VOICE_RECORD: ${fs.readFileSync(saved, 'utf8').trim()}` : undefined).toBe(line); + return line; } describe('the outside voice record (lib/outside-voice-record.ts)', () => { @@ -195,6 +198,19 @@ describe('gstack-ship-receipt write: outside_voice (GST-4140)', () => { const w = write(line); expect([w.status, JSON.parse(w.stdout || '{}').outside_voice?.status]).toEqual([0, 'unavailable']); }, 120_000); + // Value: protects=Step 19's automatic --outside-voice never stops a receipt write; fails_when=a wrong-tree reply's unavailable reason carries + // the checkout's home path into the saved record, and write refuses the receipt as private (p3 outside-voice#1 on #4889); seam=collect, verify and write + test('a wrong-tree outside reply saves an unavailable record without checkout paths, and write accepts it', () => { + const t = setup(); + const line = cleanVoice(['--native-model', 'anthropic/claude-opus-5-5'], REPLY, `${'b'.repeat(40)} ${path.join(t, 'elsewhere')}`)!; + const record = JSON.parse(line.slice('OUTSIDE_VOICE_RECORD:'.length)); + expect([record.status, record.reason]).toEqual(['unavailable', expect.stringMatching(/^reviewed another tree: reported b{40} , expected [0-9a-f]{40} $/)]); + const leaked = path.join(t, 'leaked.json'); + fs.writeFileSync(leaked, JSON.stringify({ ...record, reason: 'reviewed another tree: reported x /home/fixture-user/elsewhere' })); + expect(write('@' + leaked).status).toBe(1); + const w = write(line); + expect([w.status, JSON.parse(w.stdout || '{}').outside_voice?.reason], w.stderr).toEqual([0, record.reason]); + }, 120_000); test('a receipt without outside_voice stays valid; validateReceipt rejects a same-family completed record', () => { const base = { schema_version: 1, head: 'a'.repeat(40), base: 'main' }; expect(validateReceipt(base)).toEqual([]); @@ -203,3 +219,48 @@ describe('gstack-ship-receipt write: outside_voice (GST-4140)', () => { expect(outsideVoiceProblem({ status: 'done', provider: 'x', model: 'y', family: 'z' })).toContain('status must be one of'); }); }); + +describe('/gstack-ship Step 11: the Codex block\'s closing OUTSIDE_STATUS line (GST-4148)', () => { + const rendered = fs.readFileSync(path.join(ROOT, 'ship/sections/adversarial.md'), 'utf8').split('\n'); + const id = rendered.filter(l => l.startsWith('_OUTSIDE_ID=')); + const echo = (s: string) => rendered.filter(l => l.includes(`echo "OUTSIDE_STATUS: ${s} provider=codex`)); + const statusLine = (model: string, s: 'completed' | 'unverified') => { + const script = [id[0]!.split('"$HOME/.claude/skills/gstack/bin/').join(`"${path.join(ROOT, 'bin')}/`), echo(s)[0]!.replace(/^.*?(echo "[^"]*").*$/, '$1')].join('\n'); + const r = spawnSync('bash', ['-c', script], { env: { ...process.env, _CODEX_SEL: model }, encoding: 'utf8', timeout: 60_000 }); + expect(r.status, r.stderr).toBe(0); + return r.stdout.trim(); + }; + // Value: protects=a Codex CLI read in /gstack-ship counts as second-model coverage once collect has the lane's model; fails_when=the + // rendered Codex block's OUTSIDE_STATUS line names no model, so collect records a cross-family Codex read as unavailable, or a + // non-OpenAI Codex model is labelled openai; seam=the rendered ship section, collect and verify end to end + test('both Codex passes print model= and family=, and collect records a Codex read as a completed cross-family review', () => { + expect([id.length, echo('completed').length, echo('unverified').length]).toEqual([2, 2, 2]); + expect(rendered.join('\n')).toContain('Collect the outside voice with `--native-model `'); + expect(statusLine('gpt-6.2-astra', 'completed')).toBe('OUTSIDE_STATUS: completed provider=codex host=claude model=gpt-6.2-astra family=openai'); + expect(parseOutsideStatus(statusLine('gpt-6.2-astra', 'unverified'))).toEqual({ status: 'unverified', provider: 'codex', model: 'gpt-6.2-astra' }); + const unverified = cleanVoice(['--native-model', 'anthropic/claude-opus-5-5'], REPLY + statusLine('gpt-6.2-astra', 'unverified') + '\n')!; + expect(JSON.parse(unverified.slice('OUTSIDE_VOICE_RECORD:'.length))).toEqual({ status: 'unavailable', provider: 'codex', model: 'gpt-6.2-astra', family: 'openai', native_family: 'anthropic', reason: unverifiedRead('unverified') }); + expect(statusLine('claude-opus-5-5', 'completed')).toEndWith('model=claude-opus-5-5 family=anthropic'); + const line = cleanVoice(['--native-model', 'anthropic/claude-opus-5-5'], REPLY + statusLine('gpt-6.2-astra', 'completed') + '\n')!; + expect(JSON.parse(line.slice('OUTSIDE_VOICE_RECORD:'.length))).toEqual({ status: 'completed', provider: 'codex', model: 'gpt-6.2-astra', family: 'openai', native_family: 'anthropic' }); + const same = pass().outside(['--native-model', 'anthropic/claude-opus-5-5'], REPLY + statusLine('claude-opus-5-5', 'completed') + '\n'); + expect([same.status, same.stdout]).toEqual([1, expect.stringContaining('COLLECT_SAME_FAMILY: reader=outside-voice model=claude-opus-5-5 family=anthropic')]); + }, 120_000); + // Value: protects=Step 19 never binds a stale or unverified record, and a later verify of a ledger with no outside voice (Step 19's + // targeted-only rerun) keeps the earlier record; fails_when=verify --outside-voice-out keeps an older file beside a dirty ledger, writes + // one there, or deletes the record on a ledger with no outside voice (the clean write is checked in cleanVoice); seam=the bin + test('verify --outside-voice-out removes a stale file beside a dirty ledger and leaves it alone on a ledger with no outside voice', () => { + const p = pass(); + const alias = dispatch(['verify', '--ledger', p.ledger, '--outside-voice-out', p.ledger]); + expect([alias.status, alias.stderr, fs.statSync(p.ledger).size > 0]).toEqual([2, expect.stringContaining('must name two files other than --ledger'), true]); + const kept = path.join(p.out, 'kept.json'); + fs.writeFileSync(kept, '{"earlier":true}\n'); + dispatch(['verify', '--ledger', p.ledger, '--outside-voice-out', kept]); + expect(fs.readFileSync(kept, 'utf8')).toBe('{"earlier":true}\n'); + expect(p.outside(['--outside-model', 'openai/gpt-6.2-sol', '--outside-provider', 'host-subagent', '--native-model', 'anthropic/claude-opus-5-5']).status).toBe(0); + const file = path.join(p.out, 'outside-voice.json'); + fs.writeFileSync(file, '{"stale":true}\n'); + const v = dispatch(['verify', '--ledger', p.ledger, '--outside-voice-out', file]); + expect([v.status, v.stdout, fs.existsSync(file)]).toEqual([1, expect.stringContaining('docs/troubleshooting.md#outside-voice-record-withheld'), false]); + }, 60_000); +}); diff --git a/test/review-pass-step11.test.ts b/test/review-pass-step11.test.ts index 4c1dc40cc..eb28f8b9f 100644 --- a/test/review-pass-step11.test.ts +++ b/test/review-pass-step11.test.ts @@ -199,4 +199,28 @@ describe('Capy pass program (fake host, real bins)', () => { expect(over.shas).toEqual(named.shas); 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=the Capy pass hands collect who read the outside voice, so its record proves a second family; fails_when=lib/capy-review-pass.js + // collects the outside voice without --outside-model, --outside-provider or --native-model, and verify records a cross-family read as + // unavailable (read-only review note on #4886); seam=lib/capy-review-pass.js voiceArgs; no_claim=the Codex CLI route + test('Step 11 collects the outside voice with its model, provider and the lane model, and verify records a completed cross-family read', async () => { + const { dir, env } = repo(); + const out = path.join(dir, '.state/run/p1'); + const h = host(dir, env); + const commands: string[] = []; + const bash = h.tools.capy.bash; + h.tools.capy.bash = async (a: { command: string }) => { commands.push(a.command); return bash(a); }; + const base = { base: 'main', out, pass: 'x20s11', planFlags: ['--depth-floor', 'full'] }; + expect(await runPass(h, { ...base, stage: 'voices', models: { 'outside-voice': { model_id: 'openai/gpt-6.2-sol' } } })).toContain('NEXT: judge the voices'); + const collect = commands.filter(c => / collect /.test(c) && /--role 'outside-voice'|--role outside-voice/.test(c)); + expect(collect.length).toBe(1); + expect(collect[0]).toContain(" --outside-model 'openai/gpt-6.2-sol' --outside-provider host-subagent --native-model 'anthropic/claude-opus-5-5'"); + const m = JSON.parse(fs.readFileSync(path.join(out, 'pass-manifest.json'), 'utf8')) as Manifest; + const ledger = fs.readFileSync(m.ledger, 'utf8').trim().split('\n').map(l => JSON.parse(l)); + expect(ledger.filter(e => e.event === 'output' && e.reader === 'outside-voice').map(e => e.outside)) + .toEqual([{ provider: 'host-subagent', model: 'openai/gpt-6.2-sol', family: 'openai', native_model: 'anthropic/claude-opus-5-5', native_family: 'anthropic' }]); + expect(bin(dir, env, ['judge', '--ledger', m.ledger, '--merged', m.merged, '--judged', path.join(out, 'judged.jsonl')]).status).toBe(0); + const v = bin(dir, env, ['verify', '--ledger', m.ledger]); + expect([v.status, v.stdout]).toEqual([0, expect.stringContaining('OUTSIDE_VOICE_RECORD: {"status":"completed","provider":"host-subagent","model":"openai/gpt-6.2-sol","family":"openai","native_family":"anthropic"}')]); + }, 240_000); }); diff --git a/test/size-ledger/ship/garrytan-codex-outside-status-family.json b/test/size-ledger/ship/garrytan-codex-outside-status-family.json new file mode 100644 index 000000000..660a207cc --- /dev/null +++ b/test/size-ledger/ship/garrytan-codex-outside-status-family.json @@ -0,0 +1,4 @@ +{ + "bytes": 814, + "why": "GST-4148: Step 11's Codex status line names the model and family, the outside voice is collected with the lane model, verify saves the second-model record, and Step 19 passes it to the receipt" +}