From e671a531f4ede3d63b3143c96903466c960aca58 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 18 Nov 2026 03:54:16 +0800 Subject: [PATCH] Unattended /autoplan runs its configured second-model review in the foreground, and run ids no longer collide (GST-3015) (#4459) Unattended `/autoplan --full` now runs the second-model review when `codex_reviews: enabled` is set, runs it in the foreground with a 9-minute limit, and records a timeout with the standard failure line instead of ending the session. Two runs started in the same second also get different run ids now. Why: in a planning test, Opus 5.5 skipped the second reviewer in 2 of 3 runs over consent the config had already given, and ended the third session while the review ran in the background. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- autoplan/DRIVER.md | 2 +- autoplan/DRIVER.md.tmpl | 2 +- autoplan/sections/unattended.md | 7 +-- autoplan/sections/unattended.md.tmpl | 7 +-- ...attended-autoplan-runs-its-second-voice.md | 2 + docs/troubleshooting.md | 3 +- lib/approval-record.ts | 2 +- lib/autoplan-run.ts | 5 +- scripts/resolvers/autoplan-driver.ts | 8 +++ scripts/resolvers/index.ts | 3 +- test/approval-classes.test.ts | 4 +- test/autoplan-run-id.test.ts | 39 +++++++++++++++ test/autoplan-unattended-voice.test.ts | 50 +++++++++++++++++++ test/outside-consent.test.ts | 11 ++++ 14 files changed, 130 insertions(+), 15 deletions(-) create mode 100644 changelog.d/unattended-autoplan-runs-its-second-voice.md create mode 100644 test/autoplan-run-id.test.ts create mode 100644 test/autoplan-unattended-voice.test.ts diff --git a/autoplan/DRIVER.md b/autoplan/DRIVER.md index a117116ed..91d970bc2 100644 --- a/autoplan/DRIVER.md +++ b/autoplan/DRIVER.md @@ -26,7 +26,7 @@ line yourself; gstack never writes the plan. **Kinds (R65), first `next` only.** 1. `next` prints one `ATTEMPT: phase=

voice=native|outside prompt= result=` per voice. Dispatch the native prompt to a subagent on your model and the outside prompt to - a subagent on another model family (or `gstack-outside-voice run`). Each writes `result=`. The first `next` also prints `REVIEW_ESTIMATE:` (most attempts and reservations the review can take). + a subagent on another model family (or `gstack-outside-voice run`). Each writes `result=`. The first `next` also prints `REVIEW_ESTIMATE:` (most attempts and reservations the review can take). **Outside voice, unattended.** A stored `codex_reviews: enabled` is the owner's standing consent to send each phase's review input to the outside model (`next` prints `OUTSIDE_CONSENT: given by codex_reviews=enabled`), so run the outside attempt: the preamble's unattended consent rule does not cover it, and you never close it `--unavailable` over consent or data leaving the machine. The runner itself enforces `disabled` or an unreadable config (`OUTSIDE: not_run reason=consent_missing`, no outside attempt); an unset `codex_reviews` keeps its existing handling. Run the voice in the foreground, inside this turn: `gstack-outside-voice run ... --timeout-ms 540000` with the tool's own timeout above it (Claude Code Bash `timeout: 600000`), or a subagent you await. Never `run_in_background`, never a monitor, never end the turn to wait for it: an unattended session ends with its turn. When the voice fails, `submit --voice outside --unavailable ""` with the matching line and carry on in the same turn, the native voice still counting: **Auth failure:** If stderr contains "auth", "login", "unauthorized", or "API key": "Codex authentication failed. Run `codex login` to authenticate." **Timeout:** "Codex timed out after 9 minutes and was terminated; this pass produced NO findings." A timed-out pass is MISSING COVERAGE, not a clean bill — say so explicitly rather than continuing as if Codex had reviewed. **Empty response:** "Codex returned no response. Stderr: ." 2. Submit each voice exactly once (`BOUND:`). Both voices in closes the phase (`PHASE_CLOSED:`). 3. Repeat `next` until `status=gate_pending` (`GATE: gate_rev=`); render it with `gstack-gate render

/gate.json --all` and relay every page with the two cost lines printed under `GATE:`: `GATE_SPEND:` (spent, worst case, cap, headroom, attempts; host-subagent attempts are priced unknown and counted at their reservation, so quote their real figure from the host's cost view) and `GATE_REC_COST:` (the phases `rec` can reopen and the estimate for them, an upper bound; `gate_cost` in `--json`). You never approve the gate for the owner. Offer `rec` (every recommendation, plan changes included) as the default. diff --git a/autoplan/DRIVER.md.tmpl b/autoplan/DRIVER.md.tmpl index b4b64d887..c9f84eb4a 100644 --- a/autoplan/DRIVER.md.tmpl +++ b/autoplan/DRIVER.md.tmpl @@ -23,7 +23,7 @@ line yourself; gstack never writes the plan. **Kinds (R65), first `next` only.** 1. `next` prints one `ATTEMPT: phase=

voice=native|outside prompt= result=` per voice. Dispatch the native prompt to a subagent on your model and the outside prompt to - a subagent on another model family (or `gstack-outside-voice run`). Each writes `result=`. The first `next` also prints `REVIEW_ESTIMATE:` (most attempts and reservations the review can take). + a subagent on another model family (or `gstack-outside-voice run`). Each writes `result=`. The first `next` also prints `REVIEW_ESTIMATE:` (most attempts and reservations the review can take). {{AUTOPLAN_UNATTENDED_VOICE}} 2. Submit each voice exactly once (`BOUND:`). Both voices in closes the phase (`PHASE_CLOSED:`). 3. Repeat `next` until `status=gate_pending` (`GATE: gate_rev=`); render it with `gstack-gate render

/gate.json --all` and relay every page with the two cost lines printed under `GATE:`: `GATE_SPEND:` (spent, worst case, cap, headroom, attempts; host-subagent attempts are priced unknown and counted at their reservation, so quote their real figure from the host's cost view) and `GATE_REC_COST:` (the phases `rec` can reopen and the estimate for them, an upper bound; `gate_cost` in `--json`). You never approve the gate for the owner. Offer `rec` (every recommendation, plan changes included) as the default. diff --git a/autoplan/sections/unattended.md b/autoplan/sections/unattended.md index 06e5a4101..a3d181f6b 100644 --- a/autoplan/sections/unattended.md +++ b/autoplan/sections/unattended.md @@ -3,9 +3,10 @@ ## Unattended profile `SESSION_KIND: unattended`: a parent drives the run through -`~/.claude/skills/gstack/bin/gstack-autoplan` (`next`/`submit`/`answer --gate-rev`/ -`export`; docs/unattended.md) and reads artifacts, never prose. Phases close -themselves, Eng runs last, the outside voice (none when lean) runs through `gstack-outside-voice`, +`~/.claude/skills/gstack/bin/gstack-autoplan` (DRIVER.md; +docs/unattended.md) and reads artifacts, never prose. Phases close +themselves, Eng runs last, the outside voice (none when lean) runs per DRIVER.md +(enabled `codex_reviews` is consent; foreground only), and the run stops at `status=gate_pending`: never approve. `gstack-artifact validate /run.json` is the completion check. End with `GSTACK_RESULT: skill=autoplan status= run=`. diff --git a/autoplan/sections/unattended.md.tmpl b/autoplan/sections/unattended.md.tmpl index f41f0b09a..e5a2cd6f8 100644 --- a/autoplan/sections/unattended.md.tmpl +++ b/autoplan/sections/unattended.md.tmpl @@ -1,9 +1,10 @@ ## Unattended profile `SESSION_KIND: unattended`: a parent drives the run through -`~/.claude/skills/gstack/bin/gstack-autoplan` (`next`/`submit`/`answer --gate-rev`/ -`export`; docs/unattended.md) and reads artifacts, never prose. Phases close -themselves, Eng runs last, the outside voice (none when lean) runs through `gstack-outside-voice`, +`~/.claude/skills/gstack/bin/gstack-autoplan` (DRIVER.md; +docs/unattended.md) and reads artifacts, never prose. Phases close +themselves, Eng runs last, the outside voice (none when lean) runs per DRIVER.md +(enabled `codex_reviews` is consent; foreground only), and the run stops at `status=gate_pending`: never approve. `gstack-artifact validate /run.json` is the completion check. End with `GSTACK_RESULT: skill=autoplan status= run=`. diff --git a/changelog.d/unattended-autoplan-runs-its-second-voice.md b/changelog.d/unattended-autoplan-runs-its-second-voice.md new file mode 100644 index 000000000..23c75fae4 --- /dev/null +++ b/changelog.d/unattended-autoplan-runs-its-second-voice.md @@ -0,0 +1,2 @@ +- **Unattended /autoplan now runs the second-model review you turned on, and waits for it instead of ending the session.** With `codex_reviews: enabled` in the config, Opus 5.5 still skipped the second reviewer in 2 of 3 unattended `--full` runs, saying the owner had not agreed to send the plan off the machine; in the third it started the review in the background and ended its turn, which ends a headless session. `gstack-autoplan next` now prints `OUTSIDE_CONSENT: given by codex_reviews=enabled` beside the outside attempt, and autoplan/DRIVER.md says that an explicit `enabled` is the owner's standing consent, that the review runs in the foreground with a 9-minute limit, and that a timeout or failure is recorded with the standard failure line while the run carries on. `disabled` is still enforced by the runner, and an unset `codex_reviews` is handled as before. +- **Two /autoplan runs started in the same second no longer share a run id.** Run ids were the run directory's name plus a time stamp to the second, so two runs whose directories were both named `autoplan` got the same id and the same checkpoint folder. Each id now carries six random letters before the stamp. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 1357386a7..48451b019 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -2118,7 +2118,8 @@ Nothing was written, locally or to the Drive mirror. `import --autoplan` skips a `pii.phone.e164` or `pii.cc` finding that starts inside the autoplan run id's 14-digit stamp, or the thread-code digits right before it, where import places the id (the ask's `autoplan run ` and the source's `autoplan:@`), when -the id has the minted shape `-<14 digits>` (GST-2047); a phone number in +the id has the minted shape `-<14 digits>` (GST-2047; since GST-3015 the +name ends in six random letters); a phone number in the rest of the directory name, the same id anywhere else, and every other finding in the row still refuse. diff --git a/lib/approval-record.ts b/lib/approval-record.ts index 4e3f0d6c3..f28373a39 100644 --- a/lib/approval-record.ts +++ b/lib/approval-record.ts @@ -153,7 +153,7 @@ function validDate(d: string): boolean { export interface NewRow { ask: string; words: string; by: string; scope: string; pending?: string; outcome?: string; date?: string; source?: string } -/** An autoplan run id as gstack-autoplan mints it: the run directory's name, a hyphen, then a 14-digit time stamp. */ +/** An autoplan run id as gstack-autoplan mints it: the run directory's name, a hyphen, six random letters (since GST-3015), a hyphen, then a 14-digit time stamp. */ const MINTED_RUN_ID = /^[A-Za-z0-9._-]{1,64}-\d{14}$/; /** The part of a minted run id the exemption covers: the 14-digit stamp and, when the name ends in a thread code, its digits. */ const RUN_ID_STAMP = /(?:(? String.fromCharCode(97 + b % 26)).join('')}-${new Date().toISOString().replace(/[-:T.Z]/g, '').slice(0, 14)}`; // codex_reviews gates the outside voice here, before any dispatch: a refusal is a terminal not_run outcome per phase. const consent = (o.outsideEnabled ?? true) && !lean ? outsideConsent({ userInvoked: false }) : undefined; const consentMissing = consent && !consent.allowed ? consent.lines[0] : undefined; @@ -283,6 +283,7 @@ export function nextStep(o: NextOptions): NextResult { state.status = 'awaiting_result'; writeState(state); for (const a of result.attempts) lines.push(`ATTEMPT: ${a.attempt} phase=${phase} voice=${a.voice} prompt=${a.prompt} result=${a.result} model_family=${a.model_family}${a.new ? '' : ' (open)'}`); + if (result.attempts.some(a => a.voice === 'outside') && readStoredCodexReviews().value === 'enabled') lines.push("OUTSIDE_CONSENT: given by codex_reviews=enabled (the owner's standing consent to send this review input to the outside model: run the outside attempt in the foreground, ask nothing, and never close it --unavailable over consent)"); lines.push(renderSpend(summarize(readLedger(path.join(state.out, FILES.spend)))), roundsLine(state)); return result; } diff --git a/scripts/resolvers/autoplan-driver.ts b/scripts/resolvers/autoplan-driver.ts index 5b8153e7d..e24cb6dcb 100644 --- a/scripts/resolvers/autoplan-driver.ts +++ b/scripts/resolvers/autoplan-driver.ts @@ -13,6 +13,7 @@ import { PHASES, RESULT_FORMAT } from '../../lib/autoplan-prompts'; import { SCOPE_FLAG_TOKENS } from '../../lib/autoplan-scope'; import { RESULT_CODES } from '../../lib/result-codes'; import { DEFAULT_HOST_ESTIMATE_USD, DEFAULT_MAX_ROUNDS } from '../../lib/autoplan-budget'; +import { outsideVoiceFailurePolicy } from './outside-voice'; import type { ResolverFn } from './types'; /** One entry per command line the loop runs, as the field-wave plan specifies them. */ @@ -75,3 +76,10 @@ export const generateAutoplanDriverCodes: ResolverFn = () => DRIVER_CODES.map(co const row = (RESULT_CODES as Record)[code]; return `- \`${code}\`: ${row?.fix ?? PENDING_FIX[code]}`; }).join('\n'); + +/** GST-3015: the outside voice in an unattended run, one line so it sits inside the loop's dispatch step. An explicit codex_reviews: enabled is consent; the voice runs in the foreground with a bounded timeout. */ +export const generateAutoplanUnattendedVoice: ResolverFn = ctx => [ + "**Outside voice, unattended.** A stored `codex_reviews: enabled` is the owner's standing consent to send each phase's review input to the outside model (`next` prints `OUTSIDE_CONSENT: given by codex_reviews=enabled`), so run the outside attempt: the preamble's unattended consent rule does not cover it, and you never close it `--unavailable` over consent or data leaving the machine. The runner itself enforces `disabled` or an unreadable config (`OUTSIDE: not_run reason=consent_missing`, no outside attempt); an unset `codex_reviews` keeps its existing handling.", + "Run the voice in the foreground, inside this turn: `gstack-outside-voice run ... --timeout-ms 540000` with the tool's own timeout above it (Claude Code Bash `timeout: 600000`), or a subagent you await. Never `run_in_background`, never a monitor, never end the turn to wait for it: an unattended session ends with its turn. When the voice fails, `submit --voice outside --unavailable \"\"` with the matching line and carry on in the same turn, the native voice still counting:", + ...outsideVoiceFailurePolicy(ctx, { timeoutMinutes: 9, onTimeout: 'missing-coverage', stderrOnEmpty: true, fallback: 'none', escape: 0 }).split('\n').map(l => l.replace(/^- /, '')), +].join(' '); diff --git a/scripts/resolvers/index.ts b/scripts/resolvers/index.ts index 2fd070d74..e68656396 100644 --- a/scripts/resolvers/index.ts +++ b/scripts/resolvers/index.ts @@ -53,7 +53,7 @@ import { generateImplementerDispatchRules } from './dispatch-rules'; import { generatePlanRealityRows } from './plan-reality'; import { generateSidewaysSweep, generateFlakeFixNumber } from './sideways'; import { generateCoordinatorContract } from './coordinator-contract'; -import { generateAutoplanDriverCodes, generateAutoplanDriverCommands, generateAutoplanDriverFiles, generateAutoplanDriverGate, generateAutoplanDriverPhases, generateAutoplanDriverResultFormat } from './autoplan-driver'; +import { generateAutoplanDriverCodes, generateAutoplanDriverCommands, generateAutoplanDriverFiles, generateAutoplanDriverGate, generateAutoplanDriverPhases, generateAutoplanDriverResultFormat, generateAutoplanUnattendedVoice } from './autoplan-driver'; import { generateShipDriverStops } from './ship-driver'; import { generateQAScope, generateQAExploratory, generateQAFunctional, generateQAResource, generateQAReview, generateQAReviewPreflight, generateQAMethodReads } from './qa'; import { generateVoiceTriggerRouting } from './voice-triggers'; @@ -193,6 +193,7 @@ export const RESOLVERS: Record = { AUTOPLAN_DRIVER_GATE: generateAutoplanDriverGate, AUTOPLAN_DRIVER_FILES: generateAutoplanDriverFiles, AUTOPLAN_DRIVER_CODES: generateAutoplanDriverCodes, + AUTOPLAN_UNATTENDED_VOICE: generateAutoplanUnattendedVoice, SHIP_DRIVER_STOPS: generateShipDriverStops, SECTION, SECTION_INDEX, diff --git a/test/approval-classes.test.ts b/test/approval-classes.test.ts index 0b9b5e262..e86b957a4 100644 --- a/test/approval-classes.test.ts +++ b/test/approval-classes.test.ts @@ -237,11 +237,11 @@ describe('gstack-ship-receipt write enforces declared classes (APPROVAL_CITATION const other = run('docs-plan', 'Rewrite the quickstart in docs/quickstart.md with a shorter first step. Tests cover the links.', true); const ok = write(repo, `Approved by Garry 2026-10-16 via ${good.sha}\n`, ['--approval-run', other.out, '--approval-run', good.out]); expect(ok.status, ok.err).toBe(EXIT.ok); - expect(JSON.parse(ok.out).approval.classes[0]).toMatchObject({ class: 'data-repair', citation: 'verified', binding: 'paths', via: good.sha, evidence: expect.stringMatching(/^plan run-\d+ gate_rev=1 p1=b answered_by=human$/) }); + expect(JSON.parse(ok.out).approval.classes[0]).toMatchObject({ class: 'data-repair', citation: 'verified', binding: 'paths', via: good.sha, evidence: expect.stringMatching(/^plan run-[a-z]{6}-\d{14} gate_rev=1 p1=b answered_by=human$/) }); const notApproved = write(repo, `Approved by Garry 2026-10-16 via ${pending.sha}\n`, ['--approval-run', pending.out]); expect(notApproved.err).toMatch(/holds this plan but its gate is not APPROVED \(status gate_pending, p1 unanswered\).*\(APPROVAL_CITATION_MISSING\)$/m); const unrelated = write(repo, `Approved by Garry 2026-10-16 via ${other.sha}\n`, ['--approval-run', other.out]); - expect(unrelated.err).toMatch(/plan run-\d+ gate_rev=1 p1=b answered_by=human names neither/); + expect(unrelated.err).toMatch(/plan run-[a-z]{6}-\d{14} gate_rev=1 p1=b answered_by=human names neither/); const noRun = write(repo, `Approved by Garry 2026-10-16 via ${good.sha}\n`); expect(noRun.err).toMatch(/plan sha [0-9a-f]{8}: pass the autoplan run with --approval-run .*must attest "for data-repair@[0-9a-f]{12}"/); fs.appendFileSync(path.join(good.out, 'plan.md'), '\nsrc/commands/repair/later.ts\n'); diff --git a/test/autoplan-run-id.test.ts b/test/autoplan-run-id.test.ts new file mode 100644 index 000000000..af7b6b18a --- /dev/null +++ b/test/autoplan-run-id.test.ts @@ -0,0 +1,39 @@ +/** + * Run ids from gstack-autoplan (GST-3015, from GBRA-108): two runs started in the + * same second whose run directories share a name ("autoplan") minted the same id, + * autoplan-20261117010353, and so shared one checkpoint collection. Each run id now + * carries a random part between the directory name and the 14-digit stamp, which + * stays last so the approval importer's stamp exemption still reads it. + */ +import { afterAll, afterEach, expect, setSystemTime, test } from 'bun:test'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import { buildRow } from '../lib/approval-record'; +import { initRun } from '../lib/autoplan-run'; +import { ROOT, SMALL_PLAN } from './helpers/autoplan-run-fixture'; + +const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'autoplan-run-id-')); +afterAll(() => fs.rmSync(TMP, { recursive: true, force: true })); +afterEach(() => setSystemTime()); + +test('two runs started in the same second in same-named directories get different run ids', () => { + const plan = path.join(TMP, 'plan.md'); + fs.writeFileSync(plan, SMALL_PLAN); + setSystemTime(new Date('2026-11-17T01:03:53.250Z')); + const first = initRun({ plan, out: path.join(TMP, 'a', 'autoplan'), cwd: ROOT, full: true, sessionKind: 'unattended', outsideEnabled: false }); + const second = initRun({ plan, out: path.join(TMP, 'b', 'autoplan'), cwd: ROOT, full: true, sessionKind: 'unattended', outsideEnabled: false }); + expect(first.run).not.toBe(second.run); + for (const run of [first.run, second.run]) { + expect(run).toMatch(/^autoplan-[a-z]{6}-20261117010353$/); + const ask = `autoplan run ${run}`; + const row = buildRow({ ask, words: 'do it', by: 'agent:test', scope: 'this plan', source: `autoplan:${run}@gate_rev=1` }, 'main', new Date(), { id: run, at: { ask: ask.indexOf(run), source: 'autoplan:'.length } }); + expect('code' in row ? row.code : 'ok').toBe('ok'); + } +}); + +test('an explicit run id is kept as given', () => { + const plan = path.join(TMP, 'plan.md'); + fs.writeFileSync(plan, SMALL_PLAN); + expect(initRun({ plan, out: path.join(TMP, 'c', 'autoplan'), cwd: ROOT, full: true, sessionKind: 'unattended', outsideEnabled: false, runId: 'autoplan-fixed-20261117010353' }).run).toBe('autoplan-fixed-20261117010353'); +}); diff --git a/test/autoplan-unattended-voice.test.ts b/test/autoplan-unattended-voice.test.ts new file mode 100644 index 000000000..24761ba25 --- /dev/null +++ b/test/autoplan-unattended-voice.test.ts @@ -0,0 +1,50 @@ +/** + * GST-3015: in the GST-2944 smoke (gstack c5250ded), unattended /autoplan --full on Opus + * closed the outside voice --unavailable "needs the owner's consent" in 2 of 3 sessions + * although the config said codex_reviews: enabled, and in the third it ran the voice with + * run_in_background and ended its turn, which ends a headless session. The text an + * unattended driver reads (autoplan/DRIVER.md and the unattended profile) must say that an + * explicit enabled is the owner's standing consent, that the voice runs in the foreground + * under a bounded timeout, and that a failure binds outsideVoiceFailurePolicy()'s line. + */ +import { describe, expect, test } from 'bun:test'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import { outsideVoiceFailurePolicy } from '../scripts/resolvers/outside-voice'; +import { generateAutoplanUnattendedVoice } from '../scripts/resolvers/autoplan-driver'; +import type { TemplateContext } from '../scripts/resolvers/types'; + +const ROOT = path.resolve(import.meta.dir, '..'); +const read = (rel: string) => fs.readFileSync(path.join(ROOT, rel), 'utf8'); +const flat = (s: string) => s.replace(/\s+/g, ' '); +const ctx = { host: 'claude', skillName: 'autoplan' } as unknown as TemplateContext; +const policy = outsideVoiceFailurePolicy(ctx, { timeoutMinutes: 9, onTimeout: 'missing-coverage', stderrOnEmpty: true, fallback: 'none', escape: 0 }); + +describe('autoplan/DRIVER.md, step 1 of the loop', () => { + const text = flat(read('autoplan/DRIVER.md')); + test('an explicit codex_reviews: enabled is the owner\'s standing consent; disabled stays with the runner and unset is unchanged', () => { + expect(text).toContain("A stored `codex_reviews: enabled` is the owner's standing consent to send each phase's review input to the outside model"); + expect(text).toContain('`OUTSIDE_CONSENT: given by codex_reviews=enabled`'); + expect(text).toContain("the preamble's unattended consent rule does not cover it, and you never close it `--unavailable` over consent or data leaving the machine"); + expect(text).toContain('`OUTSIDE: not_run reason=consent_missing`'); + expect(text).toContain('an unset `codex_reviews` keeps its existing handling'); + }); + test('the voice runs in the foreground in this turn with a bounded timeout, never in the background', () => { + expect(text).toContain('Run the voice in the foreground, inside this turn: `gstack-outside-voice run ... --timeout-ms 540000`'); + expect(text).toContain('Claude Code Bash `timeout: 600000`'); + expect(text).toContain('Never `run_in_background`, never a monitor, never end the turn to wait for it'); + }); + test('a failed or timed-out voice binds the documented outside-voice failure line and the run carries on', () => { + expect(text).toContain('`submit --voice outside --unavailable ""` with the matching line and carry on in the same turn'); + for (const line of policy.split('\n')) expect(text).toContain(flat(line.replace(/^- /, ''))); + expect(policy).toContain('timed out after 9 minutes and was terminated; this pass produced NO findings.'); + }); +}); + +test('the unattended profile points at that step and states the two rules', () => { + expect(flat(read('autoplan/sections/unattended.md'))).toContain('the outside voice (none when lean) runs per DRIVER.md (enabled `codex_reviews` is consent; foreground only)'); +}); + +test('the resolver renders the same block the generated files carry', () => { + expect(flat(read('autoplan/DRIVER.md'))).toContain(flat(generateAutoplanUnattendedVoice(ctx))); +}); diff --git a/test/outside-consent.test.ts b/test/outside-consent.test.ts index 104323609..239a57fc3 100644 --- a/test/outside-consent.test.ts +++ b/test/outside-consent.test.ts @@ -218,4 +218,15 @@ describe('API sends: gstack-outside-voice and the unattended runner', () => { const sent = await outsideVoice(f, path.join(out, 'ceo-outside-prompt.md'), path.join(f.dir, 'ceo-outside.md')); expect([sent.status, requests - before], sent.stderr).toEqual([0, 1]); }); + + test('unattended runner (GST-3015): an explicit codex_reviews: enabled is printed as the owner\'s standing consent beside the outside attempt; unset is not', () => { + const enabled = initRun(fixture('enabled')).r; + expect(enabled.status, enabled.stderr).toBe(0); + expect(enabled.stdout).toContain('voice=outside'); + expect(enabled.stdout).toMatch(/^OUTSIDE_CONSENT: given by codex_reviews=enabled \(the owner's standing consent .*\)$/m); + const unset = initRun(fixture('unset')).r; + expect(unset.status, unset.stderr).toBe(0); + expect(unset.stdout).toContain('voice=outside'); + expect(unset.stdout).not.toContain('OUTSIDE_CONSENT:'); + }); });