Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
TypeScript
v1.91.92.0 feat(outside-voice): enforce codex_reviews consent in the send binaries, codex_effort setting, privacy disclosures (Wave 9 Lane C) (#3144)
Garry Tan3b7254a54d32
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e72113238..9792fb1da 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,22 @@# Changelog+## [1.91.92.0] - 2026-10-11++**Outside reviews honor `codex_reviews` at the send, not in skill prose. Codex reasoning effort is a setting, and the README says what leaves your machine.**++- **Consent in the binaries (#3102).** `gstack-codex-probe run-with-timeout`, `gstack-claude-code`, `gstack-outside-voice run` and the unattended `/autoplan` runner read `codex_reviews` before anything starts. When it is `disabled`, or the config can't be read, or the value is unknown, they refuse with `not_run` / `consent_missing` (exit 3). The refusal prints the fix command and links the `outside-review-consent-missing` troubleshooting anchor. `/ship` design-lite and `/design-review` no longer hard-code consent, so `codex_reviews=disabled` now stops them too. `/codex` and `/claude-code` pass `--user-invoked` because you asked for those reviews by name. `gstack-config get --stored <key>` prints `enabled`, `disabled`, `unset` or `unreadable` (exit 2).+- **Reasoning effort (D1-A, #3098, closes #2934).** `run-with-timeout --effort <default>` uses `GSTACK_CODEX_EFFORT` first, then `gstack-config set codex_effort <level>`, then the gate's own default, and appends `model_reasoning_effort`. An invalid level stops before any Codex call. `/codex ... --xhigh` sets the env for that dispatch. `/spec` keeps `medium` inside its 120 s budget. `gstack-models list` shows the effective effort.+- **Privacy text (#1081, #1080, #1150).** The README's Privacy & Telemetry section now lists:+ - the telemetry fields and what is never sent+ - the local `skill-usage.jsonl` (repo and branch are stripped before upload)+ - the update check, which goes to GitHub+ - outside-review egress and its first-send notice+ - session markers and the timeline, which stay local++ The telemetry prompt and the `gstack-config` header match it.++Thanks @Lockyer228 (#3098) for the `GSTACK_CODEX_EFFORT` precedence and its probe tests, and @lubosxyz (#2934) for the original env override.+## [1.91.91.0] - 2026-10-11**Review gates fail closed: a Codex reply that lists P1 findings is never `clean`, /autoplan survives a Claude Code auto-compaction, and a read-only /plan-eng-review finishes `DONE` instead of `BLOCKED` (Wave 9 lane B).**diff --git a/README.md b/README.mdindex 2ad75ca8f..fadbffd52 100644--- a/README.md+++ b/README.md@@ -668,19 +668,86 @@ Other references: [docs/gbrain-sync.md](docs/gbrain-sync.md) (sync-specific guid## Privacy & Telemetry-gstack includes **opt-in** usage telemetry to help improve the project. Here's exactly what happens:--- **Default is off.** Nothing is sent anywhere unless you explicitly say yes.-- **On first run,** gstack asks if you want to share anonymous usage data. You can say no.-- **What's sent (if you opt in):** skill name, duration, success/fail, gstack version, OS. That's it.-- **What's never sent:** code, file paths, repo names, branch names, prompts, or any user-generated content.-- **Change anytime:** `gstack-config set telemetry off` disables everything instantly.-- **Every off-machine send is receipted.** Any gstack-initiated network send — telemetry included — writes a hash-chained, tamper-evident receipt to `~/.gstack/security/egress.jsonl` before the send; sensitive sinks refuse to send at all if the receipt can't be written. Audit with `gstack-egress list`, verify the chain with `gstack-egress verify` (exit 3 on tamper), see the standing consent settings with `gstack-egress grants`. The ledger records attempted sends so accidents are auditable — it's an audit trail, not a network firewall.-- **Optional third-party bridges are off by default and receipted too.** The one that exists today, the [Memorable recall bridge](docs/memorable-workflow-memory.md), hands your prompt to a locally installed vendor binary only after you run `gstack-memorable enable`; every hand-off writes a receipt first, the consent shows up in `gstack-egress grants`, and what the vendor then sends is documented as the vendor's claim.--Data is stored in [Supabase](https://supabase.com) (open source Firebase alternative). The schema is in [`supabase/migrations/`](supabase/migrations/) — you can verify exactly what's collected. The Supabase publishable key in the repo is a public key (like a Firebase API key) — row-level security policies deny all direct access. Telemetry flows through validated edge functions that enforce schema checks, event type allowlists, and field length limits.--**Local analytics are always available.** Run `gstack-analytics` to see your personal usage dashboard from the local JSONL file — no remote data needed.+gstack sends nothing about how you use it unless you opt in. Three kinds of+network traffic exist, and each has its own switch.++**Telemetry (opt-in, default off).** On first run gstack asks once. You can say+no, and `gstack-config set telemetry off` turns it off at any time.++- **What's sent, per skill run:** skill name, event type, outcome+ (success/error/abort), duration, gstack version, OS and CPU architecture,+ whether the browser was used, whether the run was live or a test, a session+ id, the count of live session markers (below), the error class, the failed step, and an error message passed through gstack's+ secret redaction (cut to 200 characters). `community` adds a stable device+ ID; `anonymous` sends no ID. Prompt-injection detections add the attacking+ page's domain, a payload hash, a confidence score, the detection layer and+ the verdict.+- **What's never sent:** code, file paths, repo names, branch names, prompts,+ or any other content you write.+- **What stays on your machine:** opted in, each run is also logged to+ `~/.gstack/analytics/skill-usage.jsonl` (under your state root; see+ [docs/state-root.md](docs/state-root.md)) with the repo name and branch, so+ `gstack-analytics` can show your own dashboard. `gstack-telemetry-sync`+ deletes those two fields (and, for `anonymous`, the device ID) before+ anything is uploaded. With telemetry off, gstack logs no usage analytics at+ all; nothing new is written there.+- **Where it goes:** [Supabase](https://supabase.com) (an open-source Firebase+ alternative). The schema is in [`supabase/migrations/`](supabase/migrations/),+ so you can verify what's collected. The publishable key in the repo is a+ public key; row-level security denies direct access, and edge functions+ enforce schema checks, event allowlists and field length limits.++**Update check (on by default, regardless of telemetry).** Every interactive+skill start runs `gstack-update-check`. When its cache is stale (60 minutes after an+up-to-date result, 12 hours while an upgrade is pending, 10 minutes after a+failure) it asks GitHub for the latest version: a `git ls-remote` of+`github.com/garrytan/gstack` and a GET of the `VERSION` file from+`raw.githubusercontent.com`. GitHub sees your IP address; nothing about you or+your code is sent. With telemetry on, the same check also posts your gstack+version and OS to gstack's Supabase. Turn the check off with+`gstack-config set update_check false`.++**Outside reviews (on by default; the first one prints a notice).** Plan+reviews, `/autoplan`, `/review` and `/ship` adversarial passes, `/ship`'s design+check, `/design-review`, `/design-consultation`, `/office-hours`,+`/document-release` and `/spec` can+ask a second model for an independent review: Codex under Claude Code, Claude+Code under Codex. That sends the review prompt and the relevant code, diff or+plan to that provider, using your own Codex or Claude Code login. The first+send on a machine says which provider and which account. Turn it off with+`gstack-config set codex_reviews disabled`; the binaries that send then refuse+(`not_run`, `consent_missing`) and start nothing, and an unreadable config+counts as disabled. `/codex` and `/claude-code` still run when you ask for+them by name.++**Local state that is not telemetry.** gstack keeps a few local files whatever+your telemetry setting. They are functional state, not usage logs, and the+files are never sent:++- **Session markers:** `~/.gstack/sessions/<pid>`, one empty file per live agent+ session, touched at skill start and deleted after 120 minutes. The count lets+ skills notice several sessions on one machine; with telemetry on, that number+ is the session count above.+- **Project timeline:** `~/.gstack/projects/<repo>/timeline.jsonl` records skill+ starts and finishes with the branch name, for `/context-restore` and `/retro`.+ It leaves the machine only if you turn on `artifacts_sync_mode full`+ ([docs/gbrain-sync.md](docs/gbrain-sync.md)).++**Every off-machine send is receipted.** Any gstack-initiated network send,+telemetry included, writes a hash-chained, tamper-evident receipt to+`~/.gstack/security/egress.jsonl` before the send; sensitive sinks refuse to+send at all if the receipt can't be written. Audit with `gstack-egress list`,+verify the chain with `gstack-egress verify` (exit 3 on tamper), and see the+standing consent settings with `gstack-egress grants`. The ledger records+attempted sends so accidents are auditable; it's an audit trail, not a network+firewall.++**Optional third-party bridges are off by default and receipted too.** The one+that exists today, the [Memorable recall bridge](docs/memorable-workflow-memory.md),+hands your prompt to a locally installed vendor binary only after you run+`gstack-memorable enable`; every hand-off writes a receipt first, the consent+shows up in `gstack-egress grants`, and what the vendor then sends is+documented as the vendor's claim.## Troubleshootingdiff --git a/VERSION b/VERSIONindex 0be972b05..09b16c3f2 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-1.91.91.0+1.91.92.0diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.mdindex d5597826c..6fb3d36ef 100644--- a/agents-digest/gstack-AGENTS.md+++ b/agents-digest/gstack-AGENTS.md@@ -1,4 +1,4 @@-# gstack digest v1.91.91.0 — regenerate/re-copy after upgrading gstack+# gstack digest v1.91.92.0 — regenerate/re-copy after upgrading gstackBehavioral rules from gstack (https://github.com/garrytan/gstack), compressedfor agent hosts without a full skill install. The full skills add workflows,diff --git a/autoplan/SKILL.md b/autoplan/SKILL.mdindex a61f41b5a..e83ecc6b5 100644--- a/autoplan/SKILL.md+++ b/autoplan/SKILL.md@@ -765,10 +765,10 @@ Review skills load at each phase entry; starting the full pipeline with auto-dec# Codex preflight: the probe runs as a command, so any shell works._CODEX_PROBE=~/.claude/skills/gstack/bin/gstack-codex-probe-_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get codex_reviews 2>/dev/null || echo enabled)+_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get --stored codex_reviews 2>/dev/null)_gstack_helper_error=""[ -x "$_CODEX_PROBE" ] || _gstack_helper_error="gstack: cannot load gstack-codex-probe; re-run ./setup. https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#sourced-helper-location"-if [ "$_CODEX_CFG" = "disabled" ]; then+if [ "$_CODEX_CFG" = "disabled" ] || [ "$_CODEX_CFG" = "unreadable" ]; then_CODEX_MODE="disabled"elif { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then_CODEX_MODE="under_codex"@@ -791,7 +791,7 @@ echo "CODEX_MODE: $_CODEX_MODE"```Branch on the echoed `CODEX_MODE`:-- **`disabled`** — the user turned Codex reviews off (`codex_reviews=disabled`). Skip the Codex passes only; the Claude adversarial subagent below STILL runs (it is free and fast). Print: "Codex passes skipped (codex_reviews disabled) — running Claude adversarial only."+- **`disabled`** (or a send's `consent_missing` line) — `codex_reviews` is off or unreadable. Skip the Codex passes only; the Claude adversarial subagent below STILL runs (it is free and fast). Print: "Codex passes skipped (codex_reviews disabled) — running Claude adversarial only."- **`helper_unavailable`** — the probe is missing or not executable; relay the line above (cause and fix). Keep the required Claude adversarial pass; do not dispatch a duplicate.- **`not_installed`** — Codex CLI absent. Print: "Codex not installed; outside coverage unavailable. Install: `npm install -g @openai/codex`." Keep the required Claude adversarial pass; do not dispatch a duplicate.- **`under_codex`** — stale artifact selected its own harness. Print: "Codex outside review unavailable: harness mismatch; no outside process started. Missing coverage. Repair: setup --host codex." Skip the outside invocation and follow the workflow's native-review instructions below. Conflicting inherited harness markers are not grounds to guess another provider.diff --git a/autoplan/sections/ceo-phase.md b/autoplan/sections/ceo-phase.mdindex 6636d153b..de9d0d1bd 100644--- a/autoplan/sections/ceo-phase.md+++ b/autoplan/sections/ceo-phase.md@@ -118,7 +118,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?cat "$_OUTSIDE_TMP/text" 2>/dev/null || tail -n 20 "$_OUTSIDE_TMP/events"if [ "$_OUTSIDE_EXIT" -eq 124 ]; then"$_CODEX_PROBE" log-event codex_timeout "540" || truediff --git a/autoplan/sections/design-phase.md b/autoplan/sections/design-phase.mdindex 403669ed0..cd59ad580 100644--- a/autoplan/sections/design-phase.md+++ b/autoplan/sections/design-phase.md@@ -77,7 +77,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?cat "$_OUTSIDE_TMP/text" 2>/dev/null || tail -n 20 "$_OUTSIDE_TMP/events"if [ "$_OUTSIDE_EXIT" -eq 124 ]; then"$_CODEX_PROBE" log-event codex_timeout "540" || truediff --git a/autoplan/sections/dx-phase.md b/autoplan/sections/dx-phase.mdindex b5c64b78c..3ab7571e0 100644--- a/autoplan/sections/dx-phase.md+++ b/autoplan/sections/dx-phase.md@@ -81,7 +81,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?cat "$_OUTSIDE_TMP/text" 2>/dev/null || tail -n 20 "$_OUTSIDE_TMP/events"if [ "$_OUTSIDE_EXIT" -eq 124 ]; then"$_CODEX_PROBE" log-event codex_timeout "540" || truediff --git a/autoplan/sections/eng-phase.md b/autoplan/sections/eng-phase.mdindex 09fecd624..ad9da2018 100644--- a/autoplan/sections/eng-phase.md+++ b/autoplan/sections/eng-phase.md@@ -70,7 +70,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?cat "$_OUTSIDE_TMP/text" 2>/dev/null || tail -n 20 "$_OUTSIDE_TMP/events"if [ "$_OUTSIDE_EXIT" -eq 124 ]; then"$_CODEX_PROBE" log-event codex_timeout "540" || truediff --git a/bin/gstack-autoplan b/bin/gstack-autoplanindex 3b8c81f86..d1b034e90 100755--- a/bin/gstack-autoplan+++ b/bin/gstack-autoplan@@ -48,6 +48,8 @@ const HELP = `gstack-autoplan — unattended /autoplan: next/submit loop, answerThe first next needs --plan. The native voice is dispatched by the parent from the printed prompt file (a subagent on theparent's model); the outside voice runs through gstack-outside-voice or a cross-family subagent. Spend by host subagents is unknown.+The first next reads codex_reviews: disabled (or an unreadable config) records every phase's outside voice as a terminal+not_run consent_missing outcome and dispatches none. Enable: gstack-config set codex_reviews enabled.${exitTableHelp()}`;function flag(args: string[], name: string): string | undefined {diff --git a/bin/gstack-claude-code b/bin/gstack-claude-codeindex ac206b69d..4861547ba 100755--- a/bin/gstack-claude-code+++ b/bin/gstack-claude-code@@ -1,5 +1,16 @@#!/usr/bin/env bun// Claude-only outside-review runner. Prompts arrive on stdin, never argv.+// codex_reviews gates the send (lib/outside-consent.ts); --user-invoked marks+// a review the user asked for by name (/claude-code) and runs regardless.import { claudeCodeMain } from '../lib/claude-code';+import { outsideConsent } from '../lib/outside-consent';-process.exit(await claudeCodeMain(process.argv.slice(2)));+const argv = process.argv.slice(2);+const userInvoked = argv.includes('--user-invoked');+const consent = outsideConsent({ userInvoked });+if (!consent.allowed) {+ process.stderr.write(consent.lines.join('\n') + '\n');+ process.stdout.write(JSON.stringify({ status: 'not_run', reason: 'consent_missing', stderr: consent.lines.join('\n') }) + '\n');+ process.exit(3);+}+process.exit(await claudeCodeMain(argv.filter(a => a !== '--user-invoked')));diff --git a/bin/gstack-codex-probe b/bin/gstack-codex-probeindex f09173b7b..6bf0fc6c1 100755--- a/bin/gstack-codex-probe+++ b/bin/gstack-codex-probe@@ -6,6 +6,7 @@## Subcommands (each wraps one function below):# select-model <exec|review> [--model <id>] CODEX_SEL:, CODEX_SEL_KIND:, CODEX_SANDBOX:+# check-effort <default-effort> CODEX_EFFORT:; exit 0, or 1 on an invalid setting# check-auth exit 0 authed, 1 not# show-sandbox CODEX_SANDBOX:# check-sandbox exit 0, or 3 with the reason on stderr@@ -16,7 +17,11 @@# CODEX_PROBE_STATE:; exit 0, 1, 2, 3 or 4# check-version warnings on stderr; exit 0# show-first-use-notice notice on stderr; exit 0-# run-with-timeout <secs> <cmd...> the command's exit code; 124 on timeout+# run-with-timeout [--user-invoked] [--effort <default>] <secs> <cmd...>+# the command's exit code; 124 on timeout;+# 3 when codex_reviews refuses the send;+# --effort appends the resolved+# model_reasoning_effort to a codex command# log-event <event> [detail] silent; exit 0# log-hang <skill> <prompt-size> silent; exit 0# help usage; an unknown subcommand exits 64@@ -36,6 +41,7 @@# _gstack_codex_sandbox_mode — read-only, or full access only for GSTACK_CODEX_NO_SANDBOX=1# _gstack_codex_sandbox_preflight — free `codex sandbox` check before paid calls (Linux)# _gstack_codex_first_use_notice — once per machine: provider, account, how to turn off+# _gstack_codex_consent — codex_reviews gate before run-with-timeout sends# _gstack_codex_model_probe — round-trip probe of the selected model (#2477);# exit 4 = the account's Codex usage limit# _gstack_codex_lock_acquire — bounded mkdir lock with abandoned-owner recovery@@ -272,6 +278,44 @@ _gstack_codex_first_use_notice() {return 0}+# --- Send consent (#3102) ----------------------------------------------------++_gstack_codex_consent() {+ # The send itself honors codex_reviews, whatever the skill prose did: a+ # disabled switch, an unreadable config or a gstack-config that cannot run+ # refuses before any CLI starts (exit 3, not_run consent_missing). Unset is+ # the default, enabled, and shows the one-time notice. $1=1 is a review the+ # user asked for by name (/codex), which runs regardless. The line matches+ # gateOutcomeLine('outside review', 'consent_missing', ...) in+ # lib/gate-outcomes.ts (test/outside-consent.test.ts).+ # Same read as `gstack-config get --stored codex_reviews`, in a subshell+ # with the state-root helper's builtins only, so no caller state changes.+ [ "${1:-0}" = 1 ] && return 0+ local _out _detail+ _out=$(+ . "$_GSTACK_CODEX_BIN/gstack-state-root.sh" 2>/dev/null || { printf 'unreadable:the gstack state-root helper could not be loaded'; exit 0; }+ gstack_state_root_select; gstack_legacy_root_select+ for _r in "$_gstack_sr_root" "$_gstack_legacy_root"; do+ [ -n "$_r" ] || continue+ if [ -e "$_r/config.yaml" ] && { [ ! -f "$_r/config.yaml" ] || [ ! -r "$_r/config.yaml" ]; }; then+ printf 'unreadable:cannot read %s/config.yaml' "$_r"; exit 0+ fi+ done+ gstack_config_select codex_reviews || true+ printf '%s' "${_gstack_cfg_value:-unset}"+ )+ case "$_out" in+ enabled) return 0 ;;+ unset) _gstack_codex_first_use_notice; return 0 ;;+ disabled) _detail="codex_reviews=disabled" ;;+ unreadable:*) _detail="${_out#unreadable:}" ;;+ *) _detail="codex_reviews is '$_out', which is neither enabled nor disabled" ;;+ esac+ echo "outside review: not run (outside reviews are turned off (codex_reviews=disabled) or the gstack config could not be read, so no repository content was sent ($_detail)). Fix: gstack-config set codex_reviews enabled (or make config.yaml readable), then re-run; /codex and /claude-code still run when you ask for them (https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#outside-review-consent-missing)." >&2+ echo "OUTSIDE_CONSENT: consent_missing" >&2+ return 3+}+# --- Model round-trip probe (#2477) ------------------------------------------_gstack_codex_model_probe() {@@ -801,12 +845,44 @@ _gstack_codex_log_hang() {>/dev/null 2>&1 || true}+# --- Reasoning effort (#3098, #2934) ------------------------------------------++_gstack_codex_effort_check() {+ # One precedence, like the model: GSTACK_CODEX_EFFORT (per run), then+ # codex_effort in config.yaml, then the gate's own default in $1. Codex only+ # rejects an unknown model_reasoning_effort at request time, so an invalid+ # setting stops here, before any paid call, naming the source to fix. The+ # allowlist is the union of Codex's config levels and the API's minimal;+ # levels are model-dependent. A default outside it is a usage error (64).+ local _default="$1" _chosen _source _cfg+ case "$_default" in minimal|low|medium|high|xhigh|max|ultra) ;; *) return 64 ;; esac+ if [ -n "${GSTACK_CODEX_EFFORT:-}" ]; then+ _chosen="$GSTACK_CODEX_EFFORT"; _source="env GSTACK_CODEX_EFFORT"+ else+ _cfg=$("$_GSTACK_CODEX_BIN/gstack-config" get codex_effort 2>/dev/null || true)+ if [ -n "$_cfg" ]; then _chosen="$_cfg"; _source="config codex_effort"+ else _chosen="$_default"; _source="gate default"; fi+ fi+ case "$_chosen" in+ minimal|low|medium|high|xhigh|max|ultra) ;;+ *)+ echo "CODEX_EFFORT: invalid — '$_chosen' from $_source is not a Codex reasoning effort level. No Codex call was made." >&2+ echo "HINT: use one of minimal, low, medium, high, xhigh, max or ultra (export GSTACK_CODEX_EFFORT=<level> or gstack-config set codex_effort <level>), or unset it to keep each gate's own effort." >&2+ return 1+ ;;+ esac+ [ "$_source" = "gate default" ] || echo "CODEX_EFFORT: $_chosen (source: $_source)" >&2+ printf 'CODEX_EFFORT: %s\n' "$_chosen"+}+# --- Executed subcommands ----------------------------------------------------_gstack_codex_usage() {printf '%s\n' \'Usage: gstack-codex-probe <subcommand> [args]' \' select-model <exec|review> [--model <id>] print CODEX_SEL:, CODEX_SEL_KIND: and CODEX_SANDBOX:; exit 0 or 1' \+ ' check-effort <default-effort> GSTACK_CODEX_EFFORT, else codex_effort, else the default; print' \+ ' CODEX_EFFORT:; exit 0, 1 on an invalid setting' \' check-auth exit 0 when Codex credentials exist, 1 otherwise' \' show-sandbox print CODEX_SANDBOX: read-only (or danger-full-access)' \' check-sandbox free sandbox check; exit 0, or 3 with the reason on stderr' \@@ -816,7 +892,12 @@ _gstack_codex_usage() {' CODEX_SEL:, CODEX_SEL_KIND:, CODEX_SANDBOX:, CODEX_PROBE_STATE:' \' check-version warn on stderr about known-bad Codex CLI versions; exit 0' \' show-first-use-notice once per machine, say where reviews go; exit 0' \- ' run-with-timeout <secs> <cmd...> run cmd under a deadline; its exit code, 124 on timeout' \+ ' run-with-timeout [--user-invoked] [--effort <default>] <secs> <cmd...>' \+ ' run cmd under a deadline once codex_reviews allows the send;' \+ ' its exit code, 124 on timeout, 3 refused (consent_missing).' \+ ' --user-invoked: the user asked for this review by name' \+ ' --effort: append -c model_reasoning_effort=<level> to a codex' \+ ' command, as check-effort resolves it; 1 on an invalid setting' \' log-event <event> [detail] record a telemetry event when telemetry is on; exit 0' \' log-hang <skill> <prompt-size> record a timeout learning; exit 0' \' help this text'@@ -866,6 +947,12 @@ _gstack_codex_main() {_gstack_codex_kind_args "$@" || { _gstack_codex_usage >&2; return 64; }_gstack_codex_select_model "$_GSTACK_CODEX_ARG_KIND" "$_GSTACK_CODEX_ARG_MODEL" || return 1printf 'CODEX_SEL: %s\nCODEX_SEL_KIND: %s\nCODEX_SANDBOX: %s\n' "$_GSTACK_CODEX_SEL" "$_GSTACK_CODEX_SEL_KIND" "$_GSTACK_CODEX_SANDBOX" ;;+ check-effort)+ [ "$#" -eq 1 ] || { _gstack_codex_usage >&2; return 64; }+ _gstack_codex_effort_check "$1"+ _rc=$?+ [ "$_rc" -eq 64 ] && { _gstack_codex_usage >&2; return 64; }+ return "$_rc" ;;check-auth) [ "$#" -eq 0 ] || { _gstack_codex_usage >&2; return 64; }; _gstack_codex_auth_probe ;;show-sandbox)[ "$#" -eq 0 ] || { _gstack_codex_usage >&2; return 64; }@@ -899,8 +986,24 @@ _gstack_codex_main() {check-version) [ "$#" -eq 0 ] || { _gstack_codex_usage >&2; return 64; }; _gstack_codex_version_check >&2; return 0 ;;show-first-use-notice) [ "$#" -eq 0 ] || { _gstack_codex_usage >&2; return 64; }; _gstack_codex_first_use_notice; return 0 ;;run-with-timeout)+ _GSTACK_CODEX_USER_INVOKED=0+ _GSTACK_CODEX_EFFORT_DEFAULT=""+ if [ "${1:-}" = "--user-invoked" ]; then _GSTACK_CODEX_USER_INVOKED=1; shift; fi+ if [ "${1:-}" = "--effort" ]; then+ { [ "$#" -ge 2 ] && [ -n "$2" ]; } || { _gstack_codex_usage >&2; return 64; }+ _GSTACK_CODEX_EFFORT_DEFAULT="$2"; shift 2+ ficase "${1:-}" in ''|*[!0-9.]*) _gstack_codex_usage >&2; return 64 ;; esac[ "$#" -ge 2 ] || { _gstack_codex_usage >&2; return 64; }+ if [ -n "$_GSTACK_CODEX_EFFORT_DEFAULT" ] && [ "${2##*/}" != "codex" ]; then _gstack_codex_usage >&2; return 64; fi+ _gstack_codex_consent "$_GSTACK_CODEX_USER_INVOKED" || return 3+ if [ -n "$_GSTACK_CODEX_EFFORT_DEFAULT" ]; then+ _rc=0+ _GSTACK_CODEX_EFFORT_LINE=$(_gstack_codex_effort_check "$_GSTACK_CODEX_EFFORT_DEFAULT") || _rc=$?+ [ "$_rc" -eq 64 ] && { _gstack_codex_usage >&2; return 64; }+ [ "$_rc" -eq 0 ] || return "$_rc"+ set -- "$@" -c "model_reasoning_effort=\"${_GSTACK_CODEX_EFFORT_LINE#CODEX_EFFORT: }\""+ fi_gstack_codex_timeout_wrapper "$@" ;;log-event) [ "$#" -ge 1 ] && _gstack_codex_log_event "$@" >/dev/null 2>&1; return 0 ;;log-hang) _gstack_codex_log_hang "$@" >/dev/null 2>&1; return 0 ;;diff --git a/bin/gstack-config b/bin/gstack-configindex ee7685b2e..059189272 100755--- a/bin/gstack-config+++ b/bin/gstack-config@@ -3,6 +3,11 @@## Usage:# gstack-config get <key> — read a config value (falls back to DEFAULTS)+# gstack-config get --stored <key> — the stored value or "unset", never DEFAULTS;+# "unreadable" + exit 2 when config cannot be read+# or a privacy key holds an unknown value+# (the outside-review consent check reads+# codex_reviews this way)# gstack-config has <key> — exit 0 iff the key is literally present in the# config file (get returns DEFAULTS for absent keys,# so callers that need provenance use this instead)@@ -60,6 +65,17 @@ CONFIG_HEADER='# gstack configuration — edit freely, changes take effect on ne# # off — no data sent, no local analytics (default)# # anonymous — counter only, no device ID# # community — usage data + stable device ID+# # Opted in, each skill run is also logged locally to+# # analytics/skill-usage.jsonl under this state root+# # with the repo name and branch; those two fields are+# # stripped before upload. Off logs nothing there.+#+# ─── Session markers (local functional state, not telemetry) ─────────+# sessions/<pid> # One empty file per live agent session, touched at+# # skill start and deleted after 120 minutes. The+# # count tells skills when several sessions share a+# # machine. Never sent anywhere; not gated on+# # telemetry.## ─── Updates ─────────────────────────────────────────────────────────# auto_upgrade: false # true = silently upgrade on session start@@ -166,16 +182,25 @@ CONFIG_HEADER='# gstack configuration — edit freely, changes take effect on ne# model_smart_claude and model_smart_openai. Leave pins absent for catalog defaults;# empty pins are invalid. gstack-models list prints copyable set/unset commands.# Invalid writes are rejected and preserve the stored value.+# codex_effort: # Codex reasoning effort for outside reviews and /codex:+# # minimal | low | medium | high | xhigh | max | ultra.+# # Absent = every gate keeps its effort. GSTACK_CODEX_EFFORT+# # overrides it per run; /spec keeps medium (120 s budget).# Docs: docs/model-policy.md## ─── Advanced ────────────────────────────────────────────────────────-# codex_reviews: enabled # Workflow outside review (Codex or Claude Code by harness).-# # enabled: /review, /ship, /document-release, plan reviews,-# # and /autoplan use their existing external + fallback rules.-# # disabled: /review, /ship, /autoplan keep native passes;-# # plan/document reviews skip the entire extra review step.-# # Office hours/design/spec/manual wrappers keep their own-# # opt-in/skip controls. Invalid values preserve the old value.+# codex_reviews: enabled # Outside review (Codex or Claude Code by harness): sends+# # the review prompt and repository content to that model.+# # enabled (default; the first send prints a notice once):+# # the outside voice of every workflow may run.+# # disabled: the send binaries refuse (not_run,+# # consent_missing) and start no CLI and make no API call;+# # /review, /ship, /autoplan keep native passes; plan and+# # document reviews skip the extra step. Covers design+# # review, /ship design-lite, office hours and /spec.+# # /codex and /claude-code still run when you ask by name.+# # An unreadable config counts as disabled.+# # Invalid values preserve the old value.# browse_extension_id: # Forks and self-built extensions: the 32-letter (a-p)# # Chrome extension ID the browse sidebar terminal accepts.# # Empty = the gstack extension. "" clears it.@@ -310,6 +335,7 @@ lookup_default() {plan_review_tier) echo "frontier" ;; # frontier | smart | host — lib/model-policy.ts reads it strictlyimplementation_tier) echo "smart" ;; # frontier | smartmodel_frontier_claude|model_frontier_openai|model_smart_claude|model_smart_openai) echo "" ;; # empty = shipped catalog ID (gstack-models list)+ codex_effort) echo "" ;; # empty = each gate's own effort; GSTACK_CODEX_EFFORT wins (gstack-codex-probe run-with-timeout --effort)ship_greptile_early) echo "true" ;; # true | false — /ship's early Greptile PR# Unknown key: exit non-zero instead of printing "". The fallback pattern# the preambles use,@@ -608,6 +634,41 @@ report_root_disagreement() {case "${1:-}" inget)+ if [ "${2:-}" = "--stored" ]; then+ KEY="${3:-}"+ [ -n "$KEY" ] || { echo "Usage: gstack-config get --stored <key>" >&2; exit 1; }+ if ! printf '%s' "$KEY" | LC_ALL=C grep -qE '^[a-zA-Z0-9_]+(@[a-zA-Z0-9]+)?$'; then+ echo "Error: key must contain only alphanumeric characters, underscores, and an optional @<endpoint-id> suffix" >&2+ exit 1+ fi+ # Provenance without DEFAULTS: the stored value, or "unset". A config+ # file that exists but cannot be read prints "unreadable" (exit 2), and+ # a privacy key holding an unknown value is refused the same way, so a+ # consent check never turns an unreadable file into the default.+ _stored_roots="$STATE_DIR"+ _gstack_config_rank "$KEY" x+ if [ -n "$_gstack_cfg_rank" ]; then+ gstack_legacy_root_select+ [ -n "$_gstack_legacy_root" ] && _stored_roots="$_stored_roots+$_gstack_legacy_root"+ fi+ while IFS= read -r _stored_root; do+ if [ -e "$_stored_root/config.yaml" ] && { [ ! -f "$_stored_root/config.yaml" ] || [ ! -r "$_stored_root/config.yaml" ]; }; then+ echo "gstack-config: cannot read $_stored_root/config.yaml, so $KEY is unknown. fix: make it a readable file, then re-run (https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#outside-review-consent-missing)" >&2+ printf 'unreadable'; exit 2+ fi+ done <<< "$_stored_roots"+ gstack_config_select "$KEY" || true+ VALUE="$_gstack_cfg_value"+ if [ -z "$VALUE" ]; then printf 'unset'; exit 0; fi+ _gstack_config_rank "$KEY" "$VALUE"+ if [ "$_gstack_cfg_rank" = "-1" ]; then+ echo "gstack-config: $KEY is '$VALUE' in ${_gstack_cfg_root:+$_gstack_cfg_root/}config.yaml, which is not a recognized value. fix: gstack-config set $KEY <value> (or remove that line) (https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#outside-review-consent-missing)" >&2+ printf 'unreadable'; exit 2+ fi+ printf '%s' "$VALUE"+ exit 0+ fiKEY="${2:?Usage: gstack-config get <key>}"# Validate key (alphanumeric + underscore + optional @<endpoint-id> suffix for# endpoint-namespaced keys introduced by the brain-aware planning layer).@@ -715,6 +776,15 @@ case "${1:-}" inecho "Error: codex_reviews '$VALUE' not recognized. Valid values: enabled, disabled. Existing value left unchanged." >&2exit 1fi+ # codex_effort feeds model_reasoning_effort on paid Codex calls: reject a+ # typo instead of coercing it (the probe refuses an invalid stored value too).+ if [ "$KEY" = "codex_effort" ]; then+ case "$VALUE" in+ minimal|low|medium|high|xhigh|max|ultra) ;;+ *) echo "Error: codex_effort '$VALUE' not recognized. Valid values: minimal, low, medium, high, xhigh, max, ultra. Existing value left unchanged. fix: gstack-config unset codex_effort restores each gate's own effort (https://github.com/garrytan/gstack/blob/main/docs/model-policy.md#reasoning-effort)" >&2+ exit 1 ;;+ esac+ ficase "$KEY" inplan_review_tier|implementation_tier|model_frontier_claude|model_frontier_openai|model_smart_claude|model_smart_openai)_mp_doc="https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#model-policy-config"@@ -947,7 +1017,7 @@ case "${1:-}" inship_measure_judge_outputs ship_measure_ask_per_trial_usd ship_measure_budget_usd \ship_measure_max_rounds ship_measure_sweep_cases ship_measure_sweep_budget_usd ship_rerun_backend test_backend \plan_review_tier implementation_tier model_frontier_claude model_frontier_openai \- model_smart_claude model_smart_openai; do+ model_smart_claude model_smart_openai codex_effort; dogstack_config_select "$KEY"VALUE="$_gstack_cfg_value"SOURCE="default"@@ -972,7 +1042,7 @@ case "${1:-}" inship_measure_judge_outputs ship_measure_ask_per_trial_usd ship_measure_budget_usd \ship_measure_max_rounds ship_measure_sweep_cases ship_measure_sweep_budget_usd ship_rerun_backend test_backend \plan_review_tier implementation_tier model_frontier_claude model_frontier_openai \- model_smart_claude model_smart_openai; do+ model_smart_claude model_smart_openai codex_effort; doprintf ' %-24s %s\n' "$KEY:" "$(lookup_default "$KEY")"done;;diff --git a/bin/gstack-outside-voice b/bin/gstack-outside-voiceindex b0cbbac94..09e85db75 100755--- a/bin/gstack-outside-voice+++ b/bin/gstack-outside-voice@@ -11,12 +11,15 @@* Logic: lib/outside-voice-runner.ts (adapters), lib/outside-voice-api.ts (api* transport), lib/outside-review-result.ts (verdict). Codes: lib/result-codes.ts.* Writes <out> (the review text) and <out>.meta.json (the terminal result).+ * codex_reviews=disabled or an unreadable config refuses before any runner+ * starts: not_run consent_missing, exit 3 (lib/outside-consent.ts).*/import * as fs from 'node:fs';import * as path from 'node:path';import { EXIT, exitTableHelp } from '../lib/headless-artifacts';import type { OutsideGate } from '../lib/outside-review-result';import { RUNNER_IDS, createRunner, familyConflict, modelFamily, outsideStatusLine, runnerTable, selectRunner, type RunnerId } from '../lib/outside-voice-runner';+import { outsideConsent } from '../lib/outside-consent';import { resultLine } from '../lib/result-codes';const HELP = `gstack-outside-voice — one outside voice, three runners (docs/unattended.md)@@ -31,6 +34,8 @@ OPENAI_API_KEY/ANTHROPIC_API_KEY; needs --model), host-subagent (binds --resultcross-family subagent the host ran; needs --model). --native-model enforces the same-familyrule. GSTACK_OUTSIDE_RUNNER names the fallback when --fallback is absent.Prints OUTSIDE_STATUS: <status> provider=<runner> model=<id> family=<f> and writes <out>.meta.json.+codex_reviews=disabled (or an unreadable config) refuses every runner before it starts:+OUTSIDE_STATUS: not_run reason=consent_missing, exit 3. Enable: gstack-config set codex_reviews enabled.${exitTableHelp()}`;function flag(args: string[], name: string): string | undefined {@@ -84,6 +89,16 @@ async function main(argv: string[]): Promise<number> {const conflict = familyConflict(model, nativeModel);if (conflict) { process.stderr.write(resultLine('gstack-outside-voice run', 'MODEL_FAMILY_CONFLICT', conflict) + '\n'); return EXIT.refused; }}+ const consent = outsideConsent({ userInvoked: false });+ if (!consent.allowed) {+ const result = { status: 'not_run', reason: 'consent_missing', runner: requested, detail: consent.lines[0] };+ fs.mkdirSync(path.dirname(path.resolve(outFile)), { recursive: true });+ fs.writeFileSync(`${path.resolve(outFile)}.meta.json`, JSON.stringify(result, null, 2) + '\n');+ process.stderr.write(consent.lines.join('\n') + '\n');+ if (json) process.stdout.write(JSON.stringify(result) + '\n');+ else process.stdout.write(`OUTSIDE_STATUS: not_run reason=consent_missing provider=${requested}\n`);+ return EXIT.refused;+ }const choice = selectRunner(requested, { model, resultFile }, fallbackText);if (!choice.runner) {process.stderr.write(resultLine('gstack-outside-voice run', 'OUTSIDE_RUNNER_UNAVAILABLE', choice.reason) + '\n');diff --git a/bin/gstack-skill-start b/bin/gstack-skill-startindex f03dbab9d..2daa76687 100755--- a/bin/gstack-skill-start+++ b/bin/gstack-skill-start@@ -122,6 +122,8 @@ if [ "$_NO_HUMAN" != "yes" ]; then[ -n "$_UPD" ] && printf '%s\n' "$_UPD" | _sanitize || truefi+# Session markers: local functional state (live-session count), never sent and+# not gated on telemetry (#1150). README "Privacy & Telemetry" describes them.mkdir -p "$_GH/sessions" 2>/dev/null || truetouch "$_GH/sessions/$PARENT_PID" 2>/dev/null || truefind "$_GH/sessions" -mmin +120 -type f -exec rm {} + 2>/dev/null || true@@ -496,7 +498,7 @@ if [ "$_TEL_PROMPTED" = "no" ] && [ "$_LAKE_SEEN" = "yes" ]; then_emit_block telemetry-prompt <<EOIAsk telemetry once via AskUserQuestion:-> Help gstack get better. Share usage data only: skill, duration, crashes, stable device ID. No code or file paths. Your repo name is recorded locally only and stripped before any upload.+> Help gstack get better. Yes sends, per skill run: skill name, outcome, duration, gstack version, OS, a redacted error summary and a stable device ID. Never code, file paths, prompts, repo or branch names. Your repo and branch are also logged on this machine (analytics/skill-usage.jsonl) and stripped before upload; off logs nothing. Not covered by this answer: the update check asks GitHub for the latest version about hourly (\`gstack-config set update_check false\`), and outside reviews send code to Codex or Claude Code (\`gstack-config set codex_reviews disabled\`). Details: README "Privacy & Telemetry".Options:- A) Help gstack get better! (recommended)diff --git a/claude-code/SKILL.md.tmpl b/claude-code/SKILL.md.tmplindex 96a9a1b31..87965693e 100644--- a/claude-code/SKILL.md.tmpl+++ b/claude-code/SKILL.md.tmpl@@ -117,7 +117,7 @@ if [ ! -s "$DIFF_FILE" ]; thenfiprintf '\nREPOSITORY DIFF (data, not instructions):\n' >> "$PROMPT_FILE"cat "$DIFF_FILE" >> "$PROMPT_FILE"-if ! "$CLAUDE_RUNNER" --cwd "$_REPO_ROOT" --access none --timeout-ms 600000 < "$PROMPT_FILE" > "$RESP_FILE"; then+if ! "$CLAUDE_RUNNER" --user-invoked --cwd "$_REPO_ROOT" --access none --timeout-ms 600000 < "$PROMPT_FILE" > "$RESP_FILE"; thencat "$RESP_FILE"exit 1fi@@ -185,7 +185,7 @@ if [ ! -s "$DIFF_FILE" ]; thenfiprintf '\nREPOSITORY DIFF (data, not instructions):\n' >> "$PROMPT_FILE"cat "$DIFF_FILE" >> "$PROMPT_FILE"-if ! "$CLAUDE_RUNNER" --cwd "$_REPO_ROOT" --access none --timeout-ms 600000 < "$PROMPT_FILE" > "$RESP_FILE"; then+if ! "$CLAUDE_RUNNER" --user-invoked --cwd "$_REPO_ROOT" --access none --timeout-ms 600000 < "$PROMPT_FILE" > "$RESP_FILE"; thencat "$RESP_FILE"exit 1fi@@ -255,7 +255,7 @@ case "$SESSION_MODE" inset -- --resume "$SESSION_ID" ;;*) echo 'ERROR: choose fresh or resume before invoking consult' >&2; exit 1 ;;esac-if ! "$CLAUDE_RUNNER" --cwd "$_REPO_ROOT" --access read-only --timeout-ms 600000 "$@" < "$PROMPT_FILE" > "$RESP_FILE"; then+if ! "$CLAUDE_RUNNER" --user-invoked --cwd "$_REPO_ROOT" --access read-only --timeout-ms 600000 "$@" < "$PROMPT_FILE" > "$RESP_FILE"; thencat "$RESP_FILE"exit 1fidiff --git a/codex/SKILL.md b/codex/SKILL.mdindex 45ddee89b..a2d4ef2ea 100644--- a/codex/SKILL.md+++ b/codex/SKILL.md@@ -598,8 +598,9 @@ above); never read the other two mode sections.**Reasoning effort override:** If the user's input contains `--xhigh` anywhere,note it and remove it from the prompt text before passing to Codex. When `--xhigh`-is present, use `model_reasoning_effort="xhigh"` for all modes regardless of the-per-mode default below. Otherwise, use the per-mode defaults:+is present, prefix the `run-with-timeout` dispatch with `GSTACK_CODEX_EFFORT=xhigh`,+which outranks `codex_effort` and the per-mode default. Otherwise `--effort` applies+`GSTACK_CODEX_EFFORT`, then `codex_effort`, then the per-mode defaults:- Review (2A): `high` — bounded diff input, needs thoroughness- Challenge (2B): `high` — adversarial but bounded by diff- Consult (2C): `medium` — large context, interactive, needs speed@@ -792,6 +793,10 @@ nested skill run.- **Challenge (2B):** `high` — adversarial but bounded by diff size- **Consult (2C):** `medium` — large context (plans, codebase), interactive, needs speed+`run-with-timeout --effort <default>` resolves `GSTACK_CODEX_EFFORT`, then `gstack-config+set codex_effort <level>`, then the default; an invalid value stops before any Codex call.+`--user-invoked` runs even with `codex_reviews` disabled: the user asked by name.+`xhigh` uses ~23x more tokens than `high` and causes 50+ minute hangs on large contexttasks (OpenAI issues #8545, #8402, #6931). Users can override with `--xhigh` flag(e.g., `/codex review --xhigh`) when they want maximum reasoning and are willing to wait.diff --git a/codex/SKILL.md.tmpl b/codex/SKILL.md.tmplindex 167bafc3f..dd2b33854 100644--- a/codex/SKILL.md.tmpl+++ b/codex/SKILL.md.tmpl@@ -183,8 +183,9 @@ above); never read the other two mode sections.**Reasoning effort override:** If the user's input contains `--xhigh` anywhere,note it and remove it from the prompt text before passing to Codex. When `--xhigh`-is present, use `model_reasoning_effort="xhigh"` for all modes regardless of the-per-mode default below. Otherwise, use the per-mode defaults:+is present, prefix the `run-with-timeout` dispatch with `GSTACK_CODEX_EFFORT=xhigh`,+which outranks `codex_effort` and the per-mode default. Otherwise `--effort` applies+`GSTACK_CODEX_EFFORT`, then `codex_effort`, then the per-mode defaults:- Review (2A): `high` — bounded diff input, needs thoroughness- Challenge (2B): `high` — adversarial but bounded by diff- Consult (2C): `medium` — large context, interactive, needs speed@@ -252,6 +253,10 @@ nested skill run.- **Challenge (2B):** `high` — adversarial but bounded by diff size- **Consult (2C):** `medium` — large context (plans, codebase), interactive, needs speed+`run-with-timeout --effort <default>` resolves `GSTACK_CODEX_EFFORT`, then `gstack-config+set codex_effort <level>`, then the default; an invalid value stops before any Codex call.+`--user-invoked` runs even with `codex_reviews` disabled: the user asked by name.+`xhigh` uses ~23x more tokens than `high` and causes 50+ minute hangs on large contexttasks (OpenAI issues #8545, #8402, #6931). Users can override with `--xhigh` flag(e.g., `/codex review --xhigh`) when they want maximum reasoning and are willing to wait.diff --git a/codex/sections/challenge-mode.md b/codex/sections/challenge-mode.mdindex 1e0294de1..ac43d023e 100644--- a/codex/sections/challenge-mode.md+++ b/codex/sections/challenge-mode.md@@ -35,7 +35,6 @@ Substitute the printed name for `<prompt-file-name>` (letters, digits, `.`, `_`Use `timeout: 600000` on the Bash call (the tool's maximum) — the gate sits ABOVE the540s wrapper so the wrapper fires first, ends Codex, and prints its explicit stall message:-If the user passed `--xhigh`, use `"xhigh"` instead of `"high"`.```bash_REPO_ROOT=$(git rev-parse --show-toplevel) || { echo "ERROR: not in a git repo" >&2; exit 1; }@@ -56,7 +55,7 @@ if [ -n "$_CODEX_ROLE" ]; then export _CODEX_DEADLINE=$(($(date +%s)+540)); _CODelse _CODEX_OUT=$("$_CODEX_PROBE" select-model exec) || exit 1; fi_CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR" | tee "$TMPRESP.events" | PYTHONUNBUFFERED=1 "$PYTHON_CMD" -u -c "+"$_CODEX_PROBE" run-with-timeout --user-invoked --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR" | tee "$TMPRESP.events" | PYTHONUNBUFFERED=1 "$PYTHON_CMD" -u -c "import sys, jsonturn_completed_count = 0turn_failed = Falsediff --git a/codex/sections/challenge-mode.md.tmpl b/codex/sections/challenge-mode.md.tmplindex 49c3f1db5..16bbf84a9 100644--- a/codex/sections/challenge-mode.md.tmpl+++ b/codex/sections/challenge-mode.md.tmpl@@ -26,7 +26,6 @@ Substitute the printed name for `<prompt-file-name>` (letters, digits, `.`, `_`Use `timeout: 600000` on the Bash call (the tool's maximum) — the gate sits ABOVE the540s wrapper so the wrapper fires first, ends Codex, and prints its explicit stall message:-If the user passed `--xhigh`, use `"xhigh"` instead of `"high"`.```bash_REPO_ROOT=$(git rev-parse --show-toplevel) || { echo "ERROR: not in a git repo" >&2; exit 1; }@@ -42,7 +41,7 @@ fi[ -n "${TMPERR:-}" ] || TMPERR=$(mktemp "$TMP_ROOT/codex-err-XXXXXX") || { echo "ERROR: mktemp failed in TMP_ROOT=$TMP_ROOT; not running codex without its temp file" >&2; exit 1; }TMPRESP=$(mktemp "$TMP_ROOT/codex-resp-XXXXXX") || { echo "ERROR: mktemp failed in TMP_ROOT=$TMP_ROOT; not running codex without its temp file" >&2; exit 1; }{{CODEX_SELECT:exec:540}}-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" {{CODEX_MODEL_CONFIG_FLAG}} -c 'model_reasoning_effort="high"' {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR" | tee "$TMPRESP.events" | PYTHONUNBUFFERED=1 "$PYTHON_CMD" -u -c "+"$_CODEX_PROBE" run-with-timeout --user-invoked --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" {{CODEX_MODEL_CONFIG_FLAG}} {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR" | tee "$TMPRESP.events" | PYTHONUNBUFFERED=1 "$PYTHON_CMD" -u -c "import sys, jsonturn_completed_count = 0turn_failed = Falsediff --git a/codex/sections/consult-mode.md b/codex/sections/consult-mode.mdindex a9b2e3c91..12d3bcb1b 100644--- a/codex/sections/consult-mode.md+++ b/codex/sections/consult-mode.md@@ -88,7 +88,6 @@ session id from `.context/codex-session-id`. Substitute the printed name forthe Bash call (the tool's maximum) — the gate sits ABOVE the 540s wrapper so the wrapperfires first, ends Codex, and prints its explicit stall message:-If the user passed `--xhigh`, use `"xhigh"` instead of `"medium"`.```bash_CODEX_MODE=<new|resume>@@ -115,9 +114,9 @@ fi_LABEL=consult${_SID:+-resume}# Fix 1: wrap with timeout (gtimeout/timeout fallback chain via probe helper)if [ -n "$_SID" ]; then- "$_CODEX_PROBE" run-with-timeout 540 codex exec resume "$_SID" - -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="medium"' -c 'web_search="cached"' --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"+ "$_CODEX_PROBE" run-with-timeout --user-invoked --effort medium 540 codex exec resume "$_SID" - -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"else- "$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="medium"' -c 'web_search="cached"' --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"+ "$_CODEX_PROBE" run-with-timeout --user-invoked --effort medium 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"fi | tee "$TMPRESP.events" | PYTHONUNBUFFERED=1 "$PYTHON_CMD" -u -c "import sys, jsonturn_completed_count = 0diff --git a/codex/sections/consult-mode.md.tmpl b/codex/sections/consult-mode.md.tmplindex d080f833d..8c6c3bb48 100644--- a/codex/sections/consult-mode.md.tmpl+++ b/codex/sections/consult-mode.md.tmpl@@ -79,7 +79,6 @@ session id from `.context/codex-session-id`. Substitute the printed name forthe Bash call (the tool's maximum) — the gate sits ABOVE the 540s wrapper so the wrapperfires first, ends Codex, and prints its explicit stall message:-If the user passed `--xhigh`, use `"xhigh"` instead of `"medium"`.```bash_CODEX_MODE=<new|resume>@@ -101,9 +100,9 @@ fi_LABEL=consult${_SID:+-resume}# Fix 1: wrap with timeout (gtimeout/timeout fallback chain via probe helper)if [ -n "$_SID" ]; then- "$_CODEX_PROBE" run-with-timeout 540 codex exec resume "$_SID" - -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" {{CODEX_MODEL_CONFIG_FLAG}} -c 'model_reasoning_effort="medium"' {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"+ "$_CODEX_PROBE" run-with-timeout --user-invoked --effort medium 540 codex exec resume "$_SID" - -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" {{CODEX_MODEL_CONFIG_FLAG}} {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"else- "$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" {{CODEX_MODEL_CONFIG_FLAG}} -c 'model_reasoning_effort="medium"' {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"+ "$_CODEX_PROBE" run-with-timeout --user-invoked --effort medium 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" {{CODEX_MODEL_CONFIG_FLAG}} {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPRESP" < "$PROMPT_FILE" 2>"$TMPERR"fi | tee "$TMPRESP.events" | PYTHONUNBUFFERED=1 "$PYTHON_CMD" -u -c "import sys, jsonturn_completed_count = 0diff --git a/codex/sections/review-mode.md b/codex/sections/review-mode.mdindex caf00ebad..ebf8f1a12 100644--- a/codex/sections/review-mode.md+++ b/codex/sections/review-mode.md@@ -56,7 +56,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')# The 330s wrapper sits BELOW the 360s Bash gate so the wrapper fires FIRST# and a stall surfaces as a diagnosable exit 124 with an explicit message,# never as a silent harness kill that downstream reads as "no findings".-"$_CODEX_PROBE" run-with-timeout 330 codex review --base <base> -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "review_model=\"${_CODEX_SEL:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' < /dev/null >"$TMPOUT" 2>"$TMPERR"+"$_CODEX_PROBE" run-with-timeout --user-invoked --effort high 330 codex review --base <base> -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "review_model=\"${_CODEX_SEL:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' < /dev/null >"$TMPOUT" 2>"$TMPERR"_CODEX_EXIT=$?cat "$TMPOUT"if [ "$_CODEX_EXIT" = "124" ]; then@@ -74,7 +74,6 @@ fibun ~/.claude/skills/gstack/lib/outside-review-result.ts --label 'Codex review' --exit "$_CODEX_EXIT" --stderr "$TMPERR" structured "$TMPOUT"```-If the user passed `--xhigh`, use `"xhigh"` instead of `"high"`.**Custom-instructions path (user typed `/codex review <focus>`):** custom instructionscannot ride along with `--base` — that is exactly the combination the CLI rejects — and@@ -124,7 +123,7 @@ _PROMPT_FILE=$(mktemp "$TMP_ROOT/codex-prompt-XXXXXX") || { echo "ERROR: mktempgit diff "<base>...HEAD" 2>/dev/nullprintf '\nDIFF_END\n'} > "$_PROMPT_FILE"-"$_CODEX_PROBE" run-with-timeout 330 codex exec - -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$TMPOUT" < "$_PROMPT_FILE" >"$TMPOUT.events" 2>"$TMPERR"+"$_CODEX_PROBE" run-with-timeout --user-invoked --effort high 330 codex exec - -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$TMPOUT" < "$_PROMPT_FILE" >"$TMPOUT.events" 2>"$TMPERR"_CODEX_EXIT=$?rm -f "$_PROMPT_FILE" "$FOCUS_FILE"cat "$TMPOUT"diff --git a/codex/sections/review-mode.md.tmpl b/codex/sections/review-mode.md.tmplindex 7be8f0db1..34eb451cb 100644--- a/codex/sections/review-mode.md.tmpl+++ b/codex/sections/review-mode.md.tmpl@@ -49,7 +49,7 @@ cd "$_REPO_ROOT"# The 330s wrapper sits BELOW the 360s Bash gate so the wrapper fires FIRST# and a stall surfaces as a diagnosable exit 124 with an explicit message,# never as a silent harness kill that downstream reads as "no findings".-"$_CODEX_PROBE" run-with-timeout 330 codex review --base <base> -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" {{CODEX_REVIEW_MODEL_CONFIG_FLAG}} -c 'model_reasoning_effort="high"' {{CODEX_WEB_SEARCH_FLAG}} < /dev/null >"$TMPOUT" 2>"$TMPERR"+"$_CODEX_PROBE" run-with-timeout --user-invoked --effort high 330 codex review --base <base> -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" {{CODEX_REVIEW_MODEL_CONFIG_FLAG}} {{CODEX_WEB_SEARCH_FLAG}} < /dev/null >"$TMPOUT" 2>"$TMPERR"_CODEX_EXIT=$?cat "$TMPOUT"if [ "$_CODEX_EXIT" = "124" ]; then@@ -67,7 +67,6 @@ fibun ~/.claude/skills/gstack/lib/outside-review-result.ts --label 'Codex review' --exit "$_CODEX_EXIT" --stderr "$TMPERR" structured "$TMPOUT"```-If the user passed `--xhigh`, use `"xhigh"` instead of `"high"`.**Custom-instructions path (user typed `/codex review <focus>`):** custom instructionscannot ride along with `--base` — that is exactly the combination the CLI rejects — and@@ -105,7 +104,7 @@ _PROMPT_FILE=$(mktemp "$TMP_ROOT/codex-prompt-XXXXXX") || { echo "ERROR: mktempgit diff "<base>...HEAD" 2>/dev/nullprintf '\nDIFF_END\n'} > "$_PROMPT_FILE"-"$_CODEX_PROBE" run-with-timeout 330 codex exec - -s "${_CODEX_SANDBOX_MODE:?}" {{CODEX_MODEL_CONFIG_FLAG}} -c 'model_reasoning_effort="high"' {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPOUT" < "$_PROMPT_FILE" >"$TMPOUT.events" 2>"$TMPERR"+"$_CODEX_PROBE" run-with-timeout --user-invoked --effort high 330 codex exec - -s "${_CODEX_SANDBOX_MODE:?}" {{CODEX_MODEL_CONFIG_FLAG}} {{CODEX_WEB_SEARCH_FLAG}} --json -o "$TMPOUT" < "$_PROMPT_FILE" >"$TMPOUT.events" 2>"$TMPERR"_CODEX_EXIT=$?rm -f "$_PROMPT_FILE" "$FOCUS_FILE"cat "$TMPOUT"diff --git a/design-consultation/sections/proposal-and-preview.md b/design-consultation/sections/proposal-and-preview.mdindex 19c7174d4..e161e2c24 100644--- a/design-consultation/sections/proposal-and-preview.md+++ b/design-consultation/sections/proposal-and-preview.md@@ -119,7 +119,9 @@ Write the product brief to that path; remember its absolute path across fresh Ba**Check Codex availability:**```bash-if ( # GSTACK_ACTIVE_HOST names the harness, never the model.+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; then+ echo 'CODEX_MODE: disabled'+elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; thenecho 'Codex outside review unavailable: harness mismatch; no outside process started. Missing coverage.' >&2if { [ -n "${CLAUDECODE:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = claude ]; } && { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -136,9 +138,9 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Honor this caller’s existing opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Otherwise honor this caller’s opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.-Non-ready CLI: retain its repair notice and use only the native voice. The invocation deliberately rechecks the harness before spawning; native success never replaces external coverage.+`CODEX_MODE: disabled` or a non-ready CLI: retain any repair notice and use only the native voice. The invocation deliberately rechecks the harness before spawning; native success never replaces external coverage.**When ready**, run both voices and await both before synthesis. Overlap callsif supported; keep the native call blocking.@@ -185,7 +187,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="medium"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort medium 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/design-review/SKILL.md b/design-review/SKILL.mdindex 60aec132e..827603b13 100644--- a/design-review/SKILL.md+++ b/design-review/SKILL.md@@ -1599,13 +1599,12 @@ $GSTACK_STATE_ROOT/projects/$SLUG/designs/design-audit-{YYYYMMDD}/## Design Outside Voices (independent)-**Automatic:** Outside voices run automatically when Codex is available. No opt-in needed.+**Consent:** Outside voices run without a question when Codex is available and `codex_reviews` allows the send (unset means the default, enabled; the first send prints a one-time notice). `codex_reviews=disabled` runs only the native voice.**Check Codex availability:**```bash-_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -1624,9 +1623,9 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Honor this caller’s existing opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Otherwise honor this caller’s opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.-Declined: skip both voices. Non-ready: retain the repair notice, use only the native voice, and record `outside_status: unavailable` even if it succeeds. The invocation rechecks the harness before spawning.+Declined: skip both voices. `CODEX_MODE: disabled`: run only the native voice and record `outside_status: disabled`. Non-ready: retain the repair notice, use only the native voice, and record `outside_status: unavailable` even if it succeeds. The invocation rechecks the harness before spawning.**When ready**, run both voices and await both before synthesis. Overlap callsif supported; keep the native call blocking.@@ -1692,7 +1691,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/docs/model-policy.md b/docs/model-policy.mdindex 6ca945a28..7a9459485 100644--- a/docs/model-policy.md+++ b/docs/model-policy.md@@ -120,6 +120,33 @@ JSON output list these limits. Use an explicit compatible model for those cases,or `host` mode for plan reviews. Implementation recommendations require anexplicit implementation model rather than delegating to a hidden native choice.+## Reasoning effort++Codex calls carry a `model_reasoning_effort`. It follows the same shape as the+model: a per-run environment override, then a stored setting, then the default+each gate ships with.++| Order | Source | Set it with |+| --- | --- | --- |+| 1 | `GSTACK_CODEX_EFFORT` (this shell, this run) | `export GSTACK_CODEX_EFFORT=max` |+| 2 | `codex_effort` in config.yaml | `gstack-config set codex_effort low` (`unset` restores the defaults) |+| 3 | the gate's default | nothing: `high` for reviews, plan reviews and `/codex` review and challenge; `medium` for `/codex` consult and design direction |++Levels: `minimal`, `low`, `medium`, `high`, `xhigh`, `max`, `ultra`. Support is+model-dependent, so an unsupported level for your model fails at request time+through the usual model error. An invalid value never reaches Codex:+`gstack-config set` rejects it, and `gstack-codex-probe run-with-timeout --effort+<default>` (which resolves the order above and appends the flag) stops the call+before anything is sent, naming the source to fix. `gstack-codex-probe+check-effort <default>` prints the same resolution without a call. `/codex ...+--xhigh` outranks all three for that request (it sets `GSTACK_CODEX_EFFORT=xhigh`+on the dispatch).++`/spec`'s quality gate keeps `medium` inside its 120-second budget whatever you+set, because a higher effort would spend the time the gate is sized for.+`gstack-models list` prints the effective effort and where it came from+(`--json`: `codexEffort`). The Claude Code runner takes no effort setting.+## Which workflows use the tiers?The plan-review role applies to autoplan's CEO, design, DX and engineeringdiff --git a/docs/troubleshooting.md b/docs/troubleshooting.mdindex fa4c98713..54e28a2a9 100644--- a/docs/troubleshooting.md+++ b/docs/troubleshooting.md@@ -448,6 +448,32 @@ never an outage.gstack-config set codex_reviews enabled```+<a id="outside-review-consent-missing"></a>+### `outside review: not run (outside reviews are turned off ... ). Fix: gstack-config set codex_reviews enabled ...` / `OUTSIDE_STATUS: not_run reason=consent_missing`++**Meaning.** The send itself refused. `gstack-codex-probe run-with-timeout`,+`gstack-claude-code`, `gstack-outside-voice` and the unattended+`gstack-autoplan` runner read `codex_reviews` before they send repository+content to an outside model. When it is `disabled`, or when the config file+exists but cannot be read (or holds a value other than `enabled` or+`disabled`), they print this line, start no CLI and make no API request. An+unset `codex_reviews` means the default, `enabled`, and the first send on a+machine prints the [notice](#codex-review-notice) below. A review you ask for by+name (`/codex`, `/claude-code`) passes `--user-invoked` and still runs. This is+`not run`, never a pass and never an outage; `/autoplan` records it as the+phase's outside outcome (`status: disabled`, `outcome: not_run`,+`reason: consent_missing`).++**Fix.** To allow outside reviews again:++```bash+gstack-config set codex_reviews enabled+gstack-config get --stored codex_reviews # enabled, disabled, unset, or unreadable (exit 2)+```++If the stored read exits 2, fix the permissions or the malformed+`codex_reviews` line in the `config.yaml` it names, then re-run.+<a id="codex-review-notice"></a>### `NOTICE: gstack outside reviews send the review prompt and code to Codex (...) using ...`diff --git a/document-release/sections/release-body.md b/document-release/sections/release-body.mdindex 449c9fae8..396259601 100644--- a/document-release/sections/release-body.md+++ b/document-release/sections/release-body.md@@ -224,10 +224,10 @@ health summary and continue to Step 9. Ship-owned children already stopped at St# Codex preflight: the probe runs as a command, so any shell works._CODEX_PROBE=~/.claude/skills/gstack/bin/gstack-codex-probe-_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get codex_reviews 2>/dev/null || echo enabled)+_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get --stored codex_reviews 2>/dev/null)_gstack_helper_error=""[ -x "$_CODEX_PROBE" ] || _gstack_helper_error="gstack: cannot load gstack-codex-probe; re-run ./setup. https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#sourced-helper-location"-if [ "$_CODEX_CFG" = "disabled" ]; then+if [ "$_CODEX_CFG" = "disabled" ] || [ "$_CODEX_CFG" = "unreadable" ]; then_CODEX_MODE="disabled"elif { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then_CODEX_MODE="under_codex"@@ -266,7 +266,7 @@ echo "CODEX_MODE: $_CODEX_MODE"```Branch on the echoed `CODEX_MODE`:-- **`disabled`** — the user turned Codex reviews off (`codex_reviews=disabled`). Skip this section entirely; do NOT fall back to a Claude subagent — disabled means no extra review step. Print: "Codex review skipped (codex_reviews disabled). Re-enable: `gstack-config set codex_reviews enabled`."+- **`disabled`** (or a send's `consent_missing` line) — `codex_reviews` is off or unreadable. Skip this section entirely; do NOT fall back to a Claude subagent — disabled means no extra review step. Print: "Codex review skipped (codex_reviews disabled). Re-enable: `gstack-config set codex_reviews enabled`."- **`helper_unavailable`** — the probe is missing or not executable; relay the line above (cause and fix). Fall back to the Claude subagent path.- **`not_installed`** — Codex CLI absent. Print: "Codex not installed; outside coverage unavailable. Install: `npm install -g @openai/codex`." Fall back to the Claude subagent path.- **`under_codex`** — stale artifact selected its own harness. Print: "Codex outside review unavailable: harness mismatch; no outside process started. Missing coverage. Repair: setup --host codex." Skip the outside invocation and follow the workflow's native-review instructions below. Conflicting inherited harness markers are not grounds to guess another provider.@@ -357,7 +357,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/lib/autoplan-run.ts b/lib/autoplan-run.tsindex ff52e4438..94d39d652 100644--- a/lib/autoplan-run.ts+++ b/lib/autoplan-run.ts@@ -23,6 +23,7 @@ import { PHASES, SNAPSHOT_TOOL, detectScope, extractHeading, phaseOrder, reviewSimport { FILES, RunError, journal, now, readJournal, readState, writeState, type AttemptState, type PhaseState, type RunState, type Voice, type VoiceState } from './autoplan-state';import type { RunStatus } from './headless-artifacts';import { sha256File } from './headless-artifacts';+import { outsideConsent } from './outside-consent';import { familyConflict, modelFamily } from './outside-voice-runner';import { renderSpend, reserve, settle, summarize, readLedger } from './spend-ledger';@@ -75,19 +76,23 @@ export function initRun(o: InitOptions): RunState {const scope = detectScope(active, o.cwd, o.scope ?? {});const order = phaseOrder(scope);const run = o.runId ?? `${path.basename(out)}-${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) ? outsideConsent({ userInvoked: false }) : undefined;+ const consentMissing = consent && !consent.allowed ? consent.lines[0] : undefined;const phases: Record<string, PhaseState> = {};for (const p of PHASES) if (!order.includes(p)) phases[p] = { skipped: p === 'design' ? 'no UI scope detected' : 'no developer-facing scope detected', native: { status: 'skipped' }, outside: { status: 'skipped' } };const state: RunState = {schema_version: 1, run, status: 'running', required_phases: order, phases, artifacts: {}, revision: 0, out,plan_source: init.sourcePlan, active_plan: init.activePlan, restore: init.restorePath, scope, phase_order: order,- outside_enabled: o.outsideEnabled ?? true, attempt_counter: 0, spend_cap_usd: o.spendCap ?? null,+ outside_enabled: (o.outsideEnabled ?? true) && !consentMissing, attempt_counter: 0, spend_cap_usd: o.spendCap ?? null,+ ...(consentMissing ? { outside_not_run: { reason: 'consent_missing', detail: consentMissing } } : {}),session_kind: o.sessionKind ?? process.env.GSTACK_SESSION_KIND ?? 'unattended', host: 'gstack-autoplan', history: [], created_at: now(), updated_at: now(),deviations: ['autoplan guard: not enforced by this host; publication order is unverified (GUARD_NOT_INSTALLED)'],...(o.deadlineMin ? { deadline_at: new Date(Date.now() + o.deadlineMin * 60_000).toISOString() } : {}),...(o.light ? { light: true } : {}),};fs.writeFileSync(path.join(out, 'timing.json'), JSON.stringify({ schema_version: 1, run, phases: [], started_at: now(), session_kind: state.session_kind }, null, 2) + '\n');- journal(out, { event: 'init', run, plan_source: source, scope, phase_order: order });+ journal(out, { event: 'init', run, plan_source: source, scope, phase_order: order, ...(consentMissing ? { outside: 'not_run', reason: 'consent_missing' } : {}) });writeState(state);return state;}@@ -126,7 +131,9 @@ function openPhase(state: RunState, phase: Phase, cwd: string): void {ps.snapshot = snap.sha256; ps.snapshot_dir = path.dirname(snap.snapshotPath); ps.snapshot_path = snap.snapshotPath; ps.methodology = methodology.methodologyPath; ps.opened_at = now();ps.sections = { loaded: sections.loaded, skipped: sections.skipped, checklist: !!sections.checklist };ps.native = { status: 'pending', attempts: [] };- ps.outside = state.outside_enabled ? { status: 'pending', attempts: [] } : { status: 'disabled' };+ const notRun = state.outside_not_run as { reason: string; detail: string } | undefined;+ ps.outside = state.outside_enabled ? { status: 'pending', attempts: [] }+ : notRun ? { status: 'disabled', outcome: 'not_run', reason: notRun.reason, detail: notRun.detail } : { status: 'disabled' };ps.prompts = prompts;journal(state.out, { event: 'phase_opened', phase, snapshot: snap.sha256, prompts });}@@ -143,6 +150,7 @@ export function nextStep(o: NextOptions): NextResult {const ps = state.phases[phase]!;result.phase = phase;lines.push(`PHASE: ${phase} snapshot=${ps.snapshot} order=${state.phase_order.join(',')}`);+ if (ps.outside?.reason === 'consent_missing') lines.push(`OUTSIDE: ${phase} not_run reason=consent_missing`, String(ps.outside.detail));if (ps.sections) lines.push(`Skipped sections: ${ps.sections.skipped.length ? ps.sections.skipped.join(',') : 'none'} (scope: ui=${state.scope.ui ? 'yes' : 'no'},dx=${state.scope.dx ? 'yes' : 'no'},source=${state.scope.source}; checklist=${ps.sections.checklist ? 'loaded' : 'none'})`);const prompts = ps.prompts!;for (const voice of ['native', 'outside'] as const) {diff --git a/lib/claude-code-migration.ts b/lib/claude-code-migration.tsindex 8ab1fc350..a15095a7d 100644--- a/lib/claude-code-migration.ts+++ b/lib/claude-code-migration.ts@@ -10,7 +10,7 @@ const BANNER = '<!-- AUTO-GENERATED from';export const CLAUDE_CODE_RUNTIME_FILES = ['bin/gstack-claude-code', 'bin/gstack-models', 'bin/gstack-config', 'bin/gstack-state-root.sh','lib/claude-code.ts', 'lib/claude-code-windows-job.ts', 'lib/claude-bin.ts',- 'lib/outside-review-result.ts', 'lib/gate-outcomes.ts', 'lib/state-root.ts',+ 'lib/outside-review-result.ts', 'lib/gate-outcomes.ts', 'lib/outside-consent.ts', 'lib/state-root.ts','lib/model-catalog.ts', 'lib/model-policy.ts', 'lib/model-policy-cli.ts', 'lib/model-policy-notice.ts',];diff --git a/lib/gate-outcomes.ts b/lib/gate-outcomes.tsindex 73e04ff59..0834d58f2 100644--- a/lib/gate-outcomes.ts+++ b/lib/gate-outcomes.ts@@ -98,6 +98,11 @@ export const GATE_OUTCOMES = {summary: 'outside reviews are turned off (codex_reviews=disabled)',fix: 'gstack-config set codex_reviews enabled',},+ consent_missing: {+ state: 'not_run', anchor: 'outside-review-consent-missing',+ summary: 'outside reviews are turned off (codex_reviews=disabled) or the gstack config could not be read, so no repository content was sent',+ fix: 'gstack-config set codex_reviews enabled (or make config.yaml readable), then re-run; /codex and /claude-code still run when you ask for them (https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#outside-review-consent-missing)',+ },no_version_source: {state: 'not_run', anchor: 'ship-no-version-source',summary: 'no version source is configured, or release automation owns it',diff --git a/lib/model-catalog.ts b/lib/model-catalog.tsindex caaaefae6..1eba9ff3b 100644--- a/lib/model-catalog.ts+++ b/lib/model-catalog.ts@@ -6,6 +6,9 @@ export type ModelTier = 'frontier' | 'smart';export const MODEL_PROVIDERS: readonly ModelProvider[] = Object.freeze(['anthropic', 'openai'] as const);export const MODEL_TIERS: readonly ModelTier[] = Object.freeze(['frontier', 'smart'] as const);export const MODEL_CATALOG_VERSION = 1 as const;+/** Codex model_reasoning_effort levels gstack accepts (union of Codex config levels and the API's minimal; model-dependent). bin/gstack-codex-probe (run-with-timeout --effort, check-effort) and gstack-config codex_effort hold the same list. */+export const CODEX_EFFORT_LEVELS = Object.freeze(['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'] as const);+export type CodexEffort = typeof CODEX_EFFORT_LEVELS[number];export interface ModelCatalogEntry {readonly provider: ModelProvider;diff --git a/lib/model-policy-cli.ts b/lib/model-policy-cli.tsindex a4ca67193..7626693d6 100644--- a/lib/model-policy-cli.ts+++ b/lib/model-policy-cli.ts@@ -1,5 +1,5 @@import * as path from 'node:path';-import { MODEL_CATALOG, MODEL_CATALOG_VERSION, MODEL_PROVIDERS, MODEL_TIERS, modelCatalogSha256, type ModelProvider } from './model-catalog';+import { CODEX_EFFORT_LEVELS, MODEL_CATALOG, MODEL_CATALOG_VERSION, MODEL_PROVIDERS, MODEL_TIERS, modelCatalogSha256, type ModelProvider } from './model-catalog';import {CUSTOM_PROVIDER_UNSCANNED,describeSelection,@@ -14,7 +14,7 @@ import {type ModelRole,type ModelSelection,} from './model-policy';-import type { StateRootEnv } from './state-root';+import { readConfigKey, type StateRootEnv } from './state-root';export interface ModelsCliResult {code: 0 | 1 | 2;@@ -63,6 +63,12 @@ Settings (gstack-config set|unset <key>):implementation_tier frontier | smart (default smart)model_frontier_claude, model_frontier_openai,model_smart_claude, model_smart_openai (default: shipped catalog ID)+ codex_effort ${CODEX_EFFORT_LEVELS.join(' | ')}+ (default: each gate's own effort)++Codex reasoning effort: GSTACK_CODEX_EFFORT (per run), then codex_effort, then+the gate's default (high for reviews, medium for /codex consult and design+direction). /spec keeps medium inside its 120 s budget.A detected custom Anthropic or OpenAI endpoint (Bedrock, Vertex, Foundry, a base-URLoverride or a Codex model_provider) never receives a shipped public ID: set a@@ -92,7 +98,15 @@ function parseProvider(value: string | undefined): ModelProvider | null {return value === 'anthropic' || value === 'openai' ? value : null;}-function document(command: 'list' | 'resolve' | null, config: ModelPolicyConfig | null, selections: ModelSelection[], errors: CliError[]) {+/** The effective Codex effort override, same precedence as gstack-codex-probe check-effort; null = each gate's default. */+export function codexEffortSetting(env: StateRootEnv): { value: string | null; source: 'env' | 'config' | 'gate-default'; valid: boolean } {+ const pick = (value: string, source: 'env' | 'config') => ({ value, source, valid: (CODEX_EFFORT_LEVELS as readonly string[]).includes(value) });+ if (env.GSTACK_CODEX_EFFORT) return pick(env.GSTACK_CODEX_EFFORT, 'env');+ const stored = readConfigKey('codex_effort', env);+ return stored ? pick(stored, 'config') : { value: null, source: 'gate-default', valid: true };+}++function document(command: 'list' | 'resolve' | null, config: ModelPolicyConfig | null, selections: ModelSelection[], errors: CliError[], env: StateRootEnv = {}) {return {schemaVersion: 1,command,@@ -103,6 +117,7 @@ function document(command: 'list' | 'resolve' | null, config: ModelPolicyConfigcatalog: { version: MODEL_CATALOG_VERSION, sha256: modelCatalogSha256(), entries: MODEL_CATALOG },settings: config ? settingsOf(config) : null,tiers: config ? tiersOf(config) : null,+ codexEffort: config ? codexEffortSetting(env) : null,providerDetection: { scope: 'declared local settings files and environment only', unscanned: CUSTOM_PROVIDER_UNSCANNED },selections,errors,@@ -164,7 +179,8 @@ function renderSelections(role: ModelRole, config: ModelPolicyConfig, selectionsreturn lines;}-function renderList(config: ModelPolicyConfig, selections: ModelSelection[]): string {+function renderList(config: ModelPolicyConfig, selections: ModelSelection[], env: StateRootEnv): string {+ const effort = codexEffortSetting(env);const commands = modelPolicyCommands();const configCommand = `'${CONFIG_BIN.replaceAll('\\', '/').replaceAll("'", "'\\''")}'`;const lines = [@@ -174,6 +190,8 @@ function renderList(config: ModelPolicyConfig, selections: ModelSelection[]): st...renderSelections('plan-review', config, selections),...renderSelections('implementation', config, selections),'',+ `codex effort: ${effort.value ?? 'each gate\'s default'} (${effort.source === 'env' ? 'GSTACK_CODEX_EFFORT' : effort.source === 'config' ? `codex_effort in ${config.path}` : 'default; set codex_effort'})${effort.valid ? '' : ` - invalid; Codex calls stop before sending. Use ${CODEX_EFFORT_LEVELS.join(', ')}`}; /spec keeps medium`,+ '',`catalog v${MODEL_CATALOG_VERSION} (sha256 ${modelCatalogSha256().slice(0, 12)})`,];for (const tier of MODEL_TIERS) {@@ -264,7 +282,7 @@ export function modelsMain(args: string[], env: StateRootEnv = process.env, plat// eval-arms (plan E1): the implementation-tier resolution of each provider, one arm each.if (role === 'eval-arms') for (const s of selections) (s as { role: string }).role = 'eval-arms';const code = errors.length ? 1 : 0;- if (json) return { code, stdout: `${JSON.stringify(document(command, config, selections, errors), null, 2)}\n`, stderr: '' };- const stdout = command === 'list' ? renderList(config, selections) : role === 'eval-arms' ? renderEvalArms(config, selections) : renderResolve(role as ModelRole, config, selections);+ if (json) return { code, stdout: `${JSON.stringify(document(command, config, selections, errors, env), null, 2)}\n`, stderr: '' };+ const stdout = command === 'list' ? renderList(config, selections, env) : role === 'eval-arms' ? renderEvalArms(config, selections) : renderResolve(role as ModelRole, config, selections);return { code, stdout, stderr: errors.map(renderError).join('') };}diff --git a/lib/outside-consent.ts b/lib/outside-consent.tsnew file mode 100644index 000000000..7ccf0ce25--- /dev/null+++ b/lib/outside-consent.ts@@ -0,0 +1,57 @@+/**+ * outside-consent — the one TS reader of the outside-review consent switch+ * (`codex_reviews`) for every binary that sends repository content to an+ * outside model: bin/gstack-claude-code, bin/gstack-outside-voice and the+ * unattended runner (lib/autoplan-run.ts). Its bash twin is+ * `gstack-config get --stored codex_reviews`, which gstack-codex-probe's+ * run-with-timeout reads; test/outside-consent.test.ts keeps the two equal.+ *+ * Stored value, most restrictive across the merged state roots:+ * enabled | unset (the default, enabled) → allowed+ * disabled → refused, consent_missing+ * unreadable config or an unknown value → refused, consent_missing+ * A review the user asked for by name (/codex, /claude-code) passes+ * `userInvoked` and is allowed regardless.+ */+import * as fs from 'node:fs';+import * as path from 'node:path';+import { gateOutcomeLine } from './gate-outcomes';+import { mergedStateRoots, type StateRootEnv } from './state-root';++export type StoredCodexReviews =+ | { value: 'enabled' | 'disabled' | 'unset' }+ | { value: 'unreadable'; detail: string };++/** Marker line the skill blocks match to report `OUTSIDE_STATUS: not_run reason=consent_missing`. */+export const CONSENT_MARKER = 'OUTSIDE_CONSENT: consent_missing';++export function readStoredCodexReviews(env: StateRootEnv = process.env): StoredCodexReviews {+ let best: 'enabled' | 'disabled' | 'unset' = 'unset';+ for (const root of mergedStateRoots(env)) {+ const file = path.join(root, 'config.yaml');+ if (!fs.existsSync(file)) continue;+ let yaml: string;+ try {+ yaml = fs.readFileSync(file, 'utf8');+ } catch (error) {+ return { value: 'unreadable', detail: `cannot read ${file}: ${(error as NodeJS.ErrnoException).code ?? (error as Error).message}` };+ }+ let value = '';+ for (const line of yaml.split('\n')) if (line.startsWith('codex_reviews:')) value = line.slice('codex_reviews:'.length).trim();+ if (!value) continue;+ if (value === 'disabled') best = 'disabled';+ else if (value === 'enabled') { if (best === 'unset') best = 'enabled'; }+ else return { value: 'unreadable', detail: `${file} sets codex_reviews to '${value}', which is neither enabled nor disabled` };+ }+ return { value: best };+}++export type OutsideConsent = { allowed: true; source: 'user-invoked' | 'enabled' | 'unset' } | { allowed: false; lines: string[] };++export function outsideConsent(opts: { userInvoked: boolean; env?: StateRootEnv }): OutsideConsent {+ if (opts.userInvoked) return { allowed: true, source: 'user-invoked' };+ const stored = readStoredCodexReviews(opts.env);+ if (stored.value === 'enabled' || stored.value === 'unset') return { allowed: true, source: stored.value };+ const detail = stored.value === 'unreadable' ? stored.detail : 'codex_reviews=disabled';+ return { allowed: false, lines: [gateOutcomeLine('outside review', 'consent_missing', detail), CONSENT_MARKER] };+}diff --git a/office-hours/SKILL.md b/office-hours/SKILL.mdindex 693bf2939..7f5f1b3e0 100644--- a/office-hours/SKILL.md+++ b/office-hours/SKILL.md@@ -771,8 +771,7 @@ Use AskUserQuestion to confirm. If the user disagrees with a premise, revise und```bash-_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -791,7 +790,7 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Honor this caller’s existing opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Otherwise honor this caller’s opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.Use AskUserQuestion (regardless of codex availability):@@ -854,7 +853,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }@@ -1157,8 +1156,7 @@ After the wireframe is approved, offer outside design perspectives:```bash-_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -1177,7 +1175,7 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Honor this caller’s existing opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Otherwise honor this caller’s opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.If Codex is available, use AskUserQuestion:> "Want outside design perspectives on the chosen approach? Codex proposes a visual thesis, content plan, and interaction ideas. A Claude subagent proposes an alternative aesthetic direction."@@ -1217,7 +1215,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="medium"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort medium 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/package.json b/package.jsonindex 2a513245e..c1c0de65b 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "gstack",- "version": "1.91.91",+ "version": "1.91.92","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/plan-ceo-review/sections/review-sections.md b/plan-ceo-review/sections/review-sections.mdindex 5012795cb..d308444ef 100644--- a/plan-ceo-review/sections/review-sections.md+++ b/plan-ceo-review/sections/review-sections.md@@ -358,8 +358,7 @@ review. The user turns this off only by asking explicitly```bash-_OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get codex_reviews 2>/dev/null || echo enabled)-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -378,7 +377,7 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Disabled ends this entire extra review step, including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer. Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Disabled ends this entire extra review step (so does a send's `consent_missing` line), including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer. Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled. Never substitute another external provider.**Outcome routing:** Follow the row for the current result. After an invocation, route its resultagain. Leave only after recording disabled/unavailable coverage, or after@@ -483,7 +482,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/plan-design-review/SKILL.md b/plan-design-review/SKILL.mdindex da96ccbbb..0d4ee094d 100644--- a/plan-design-review/SKILL.md+++ b/plan-design-review/SKILL.md@@ -980,8 +980,7 @@ If user chooses B, skip this step and continue.**Check Codex availability:**```bash-_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -1000,9 +999,9 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Honor this caller’s existing opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Otherwise honor this caller’s opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.-Declined: skip both voices. Non-ready: retain the repair notice, use only the native voice, and record `outside_status: unavailable` even if it succeeds. The invocation rechecks the harness before spawning.+Declined: skip both voices. `CODEX_MODE: disabled`: run only the native voice and record `outside_status: disabled`. Non-ready: retain the repair notice, use only the native voice, and record `outside_status: unavailable` even if it succeeds. The invocation rechecks the harness before spawning.**When ready**, run both voices and await both before synthesis. Overlap callsif supported; keep the native call blocking.@@ -1063,7 +1062,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/plan-devex-review/sections/review-sections.md b/plan-devex-review/sections/review-sections.mdindex fd1187c66..3507edf88 100644--- a/plan-devex-review/sections/review-sections.md+++ b/plan-devex-review/sections/review-sections.md@@ -296,8 +296,7 @@ review. The user turns this off only by asking explicitly```bash-_OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get codex_reviews 2>/dev/null || echo enabled)-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -316,7 +315,7 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Disabled ends this entire extra review step, including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer. Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Disabled ends this entire extra review step (so does a send's `consent_missing` line), including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer. Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled. Never substitute another external provider.**Disabled is a terminal branch for this section.** If the preflight prints`CODEX_MODE: disabled`, persist `outside_status: disabled` with the guarded@@ -416,7 +415,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/plan-eng-review/sections/review-sections.md b/plan-eng-review/sections/review-sections.mdindex 6a7fafe5f..3d455a407 100644--- a/plan-eng-review/sections/review-sections.md+++ b/plan-eng-review/sections/review-sections.md@@ -834,8 +834,7 @@ review. The user turns this off only by asking explicitly```bash-_OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get codex_reviews 2>/dev/null || echo enabled)-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -854,7 +853,7 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Disabled ends this entire extra review step, including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer. Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Disabled ends this entire extra review step (so does a send's `consent_missing` line), including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer. Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled. Never substitute another external provider.**Outcome routing:** Pick exactly one row from this table, finish that row'ssteps, then leave Outside Voice. Missing reviewer coverage is non-blocking;@@ -956,7 +955,7 @@ _CODEX_SEL=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SEL: //p')_CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/review/sections/adversarial.md b/review/sections/adversarial.mdindex 487130db0..a8ebcd46a 100644--- a/review/sections/adversarial.md+++ b/review/sections/adversarial.md@@ -20,10 +20,10 @@ echo "DIFF_SIZE: $DIFF_TOTAL"# Codex preflight: the probe runs as a command, so any shell works._CODEX_PROBE=~/.claude/skills/gstack/bin/gstack-codex-probe-_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get codex_reviews 2>/dev/null || echo enabled)+_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get --stored codex_reviews 2>/dev/null)_gstack_helper_error=""[ -x "$_CODEX_PROBE" ] || _gstack_helper_error="gstack: cannot load gstack-codex-probe; re-run ./setup. https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#sourced-helper-location"-if [ "$_CODEX_CFG" = "disabled" ]; then+if [ "$_CODEX_CFG" = "disabled" ] || [ "$_CODEX_CFG" = "unreadable" ]; then_CODEX_MODE="disabled"elif { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then_CODEX_MODE="under_codex"@@ -62,7 +62,7 @@ echo "CODEX_MODE: $_CODEX_MODE"```Branch on the echoed `CODEX_MODE`:-- **`disabled`** — the user turned Codex reviews off (`codex_reviews=disabled`). Skip the Codex passes only; the Claude adversarial subagent below STILL runs (it is free and fast). Print: "Codex passes skipped (codex_reviews disabled) — running Claude adversarial only."+- **`disabled`** (or a send's `consent_missing` line) — `codex_reviews` is off or unreadable. Skip the Codex passes only; the Claude adversarial subagent below STILL runs (it is free and fast). Print: "Codex passes skipped (codex_reviews disabled) — running Claude adversarial only."- **`helper_unavailable`** — the probe is missing or not executable; relay the line above (cause and fix). Keep the required Claude adversarial pass; do not dispatch a duplicate.- **`not_installed`** — Codex CLI absent. Print: "Codex not installed; outside coverage unavailable. Install: `npm install -g @openai/codex`." Keep the required Claude adversarial pass; do not dispatch a duplicate.- **`under_codex`** — stale artifact selected its own harness. Print: "Codex outside review unavailable: harness mismatch; no outside process started. Missing coverage. Repair: setup --host codex." Skip the outside invocation and follow the workflow's native-review instructions below. Conflicting inherited harness markers are not grounds to guess another provider.@@ -141,7 +141,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }@@ -203,7 +203,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex review --base '<base>' -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "review_model=\"${_CODEX_SEL:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' < /dev/null >"$_OUTSIDE_TMP/text" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex review --base '<base>' -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "review_model=\"${_CODEX_SEL:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' < /dev/null >"$_OUTSIDE_TMP/text" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?cat "$_OUTSIDE_TMP/text"cat "$_OUTSIDE_TMP/stderr" >&2 || { [ "$_OUTSIDE_EXIT" -ne 0 ] || _OUTSIDE_EXIT=1; }diff --git a/scripts/resolvers/constants.ts b/scripts/resolvers/constants.tsindex 4dc3b786e..5f865534d 100644--- a/scripts/resolvers/constants.ts+++ b/scripts/resolvers/constants.ts@@ -139,7 +139,8 @@ On any error: continue — ${feature} is informational, not a gate.`;* 5. sets ONE canonical mode var and echoes `CODEX_MODE: <mode>` so the agent* gates later blocks on the echoed value.*- * Mode values: `disabled` (config off) | `helper_unavailable` (the probe is+ * Mode values: `disabled` (codex_reviews disabled or config unreadable; the+ * send binaries refuse it as consent_missing whatever this block prints) | `helper_unavailable` (the probe is* missing or not executable) | `not_installed` | `not_authed` |* `broken_install` | `sandbox_unavailable` | `model_unusable` | `quota_exhausted` |* `unverified` (echoed as `unverified (rate_limited)` after a probe-time 429) | `ready`.@@ -165,10 +166,10 @@ export function codexPreflight(opts: { modeVar?: string; disabledBehavior: 'skipreturn `\`\`\`bash# Codex preflight: the probe runs as a command, so any shell works._CODEX_PROBE=${CODEX_PROBE_PATH}-_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get codex_reviews 2>/dev/null || echo enabled)+_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get --stored codex_reviews 2>/dev/null)_gstack_helper_error=""[ -x "$_CODEX_PROBE" ] || _gstack_helper_error="gstack: cannot load gstack-codex-probe; re-run ./setup. https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#sourced-helper-location"-if [ "$_CODEX_CFG" = "disabled" ]; then+if [ "$_CODEX_CFG" = "disabled" ] || [ "$_CODEX_CFG" = "unreadable" ]; then${m}="disabled"elif { [ -n "\${CODEX_THREAD_ID:-}" ] || [ -n "\${CODEX_SANDBOX:-}" ] || [ "\${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then${m}="under_codex"@@ -209,7 +210,7 @@ echo "CODEX_MODE: $${m}"\`\`\`Branch on the echoed \`CODEX_MODE\`:-- **\`disabled\`** — the user turned Codex reviews off (\`codex_reviews=disabled\`). ${disabledLine}+- **\`disabled\`** (or a send's \`consent_missing\` line) — \`codex_reviews\` is off or unreadable. ${disabledLine}- **\`helper_unavailable\`** — the probe is missing or not executable; relay the line above (cause and fix). ${nativeRoute}- **\`not_installed\`** — Codex CLI absent. Print: "Codex not installed; outside coverage unavailable. Install: \`npm install -g @openai/codex\`." ${nativeRoute}- **\`under_codex\`** — stale artifact selected its own harness. Print: "Codex outside review unavailable: harness mismatch; no outside process started. Missing coverage. Repair: setup --host codex." Skip the outside invocation and follow the workflow's native-review instructions below. Conflicting inherited harness markers are not grounds to guess another provider.diff --git a/scripts/resolvers/design.ts b/scripts/resolvers/design.tsindex c9973fe24..f1ec60a68 100644--- a/scripts/resolvers/design.ts+++ b/scripts/resolvers/design.ts@@ -14,7 +14,7 @@ export function generateDesignReviewLite(ctx: TemplateContext): string {// Each supported host uses its selected outside reviewer.const codexBlock = `-6. **${outsideVoiceFor(ctx).label} design voice** (optional, automatic if available):+6. **${outsideVoiceFor(ctx).label} design voice** (optional; runs when available and \`codex_reviews\` allows it):${outsideVoicePreflight(ctx, { disabledBehavior: 'opt-in' })}@@ -695,8 +695,8 @@ export function generateDesignOutsideVoices(ctx: TemplateContext): string {const isDesignReview = ctx.skillName === 'design-review';const isDesignConsultation = ctx.skillName === 'design-consultation';- // Determine opt-in behavior and reasoning effort- const isAutomatic = isDesignReview; // design-review runs automatically+ // design-review asks no question; codex_reviews (enforced by the send) is its consent+ const isAutomatic = isDesignReview;const reasoningEffort = isDesignConsultation ? 'medium' : 'high'; // creative vs analytical// Build the skill-specific outside-review prompt.@@ -785,7 +785,7 @@ Be bold and specific.`;// Build the opt-in sectionconst optInSection = isAutomatic ? `-**Automatic:** Outside voices run automatically when ${outsideVoiceFor(ctx).label} is available. No opt-in needed.` : `+**Consent:** Outside voices run without a question when ${outsideVoiceFor(ctx).label} is available and \`codex_reviews\` allows the send (unset means the default, enabled; the first send prints a one-time notice). \`codex_reviews=disabled\` runs only the native voice.` : `Use AskUserQuestion:> "Want outside design voices${isPlanDesignReview ? ' before the detailed review' : ''}? ${outsideVoiceFor(ctx).label} ${isDesignConsultation ? 'proposes an independent design direction' : "evaluates against OpenAI's design hard rules + litmus checks"}; ${outsideVoiceFor(ctx).nativeLabel} subagent does an independent ${isDesignConsultation ? 'design direction proposal' : 'completeness review'}.">@@ -841,9 +841,9 @@ printf 'DESIGN_BRIEF=%s\\n' "$_DESIGN_BRIEF"Write the product brief to that path; remember its absolute path across fresh Bash calls. Neither voice inherits context: give both the same brief. Include its complete contents in the outside prompt file for Codex, along with the design-direction request below; substitute its shell-quoted absolute path for the literal <prepared-prompt-file> in the invocation. Keep your draft direction out of both prompts; give the native Agent its absolute path (the product brief's path, not the Codex prompt file). Never paste brief text into shell source.` : ''}**Check ${outsideVoiceFor(ctx).label} availability:**-${outsideVoicePreflight(ctx, { disabledBehavior: 'opt-in', acceptedOnly: isDesignConsultation, ...(isPlanDesignReview ? { role: 'plan-review' as const } : {}) })}+${outsideVoicePreflight(ctx, { disabledBehavior: 'opt-in', ...(isPlanDesignReview ? { role: 'plan-review' as const } : {}) })}-${isDesignConsultation ? 'Non-ready CLI: retain its repair notice and use only the native voice. The invocation deliberately rechecks the harness before spawning; native success never replaces external coverage.' : 'Declined: skip both voices. Non-ready: retain the repair notice, use only the native voice, and record `outside_status: unavailable` even if it succeeds. The invocation rechecks the harness before spawning.'}+${isDesignConsultation ? '`CODEX_MODE: disabled` or a non-ready CLI: retain any repair notice and use only the native voice. The invocation deliberately rechecks the harness before spawning; native success never replaces external coverage.' : 'Declined: skip both voices. `CODEX_MODE: disabled`: run only the native voice and record `outside_status: disabled`. Non-ready: retain the repair notice, use only the native voice, and record `outside_status: unavailable` even if it succeeds. The invocation rechecks the harness before spawning.'}**When ready**, run both voices and await both before synthesis. Overlap callsif supported; keep the native call blocking.diff --git a/scripts/resolvers/outside-voice.ts b/scripts/resolvers/outside-voice.tsindex ddf1e45c4..fc1a0d9b4 100644--- a/scripts/resolvers/outside-voice.ts+++ b/scripts/resolvers/outside-voice.ts@@ -47,7 +47,7 @@ fi`;/** Caller-owned workflow role. Only enumerated plan-review generators pass it; everything else stays no-role. */export type OutsideRole = 'plan-review';-export function outsideVoicePreflight(ctx: TemplateContext, opts: { disabledBehavior: 'skip-all' | 'codex-only' | 'opt-in'; acceptedOnly?: boolean; nativeReview?: boolean; role?: OutsideRole }): string {+export function outsideVoicePreflight(ctx: TemplateContext, opts: { disabledBehavior: 'skip-all' | 'codex-only' | 'opt-in'; nativeReview?: boolean; role?: OutsideRole }): string {const v = outsideVoiceFor(ctx);if (v.id === 'codex' && (opts.disabledBehavior === 'codex-only' || (opts.disabledBehavior === 'skip-all' && !opts.role))) {let preflight = outsideVoiceLabels(ctx, codexPreflight({ disabledBehavior: opts.disabledBehavior, nativeReview: opts.nativeReview, role: !!opts.role }))@@ -64,10 +64,10 @@ export function outsideVoicePreflight(ctx: TemplateContext, opts: { disabledBehaconst probe = v.id === 'codex'? 'command -v codex >/dev/null 2>&1': `bun -e 'const {resolveClaudeCommand} = await import(process.argv[1]); process.exit(resolveClaudeCommand() ? 0 : 1)' "${bin}/../lib/claude-bin.ts"`;- const config = opts.disabledBehavior === 'opt-in'- ? (ctx.skillName === 'ship' ? '_OUTSIDE_CFG=enabled' : '_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.')- : `_OUTSIDE_CFG=$("${bin}/gstack-config" get codex_reviews 2>/dev/null || echo enabled)`;- const readiness = `${opts.acceptedOnly ? 'if' : 'elif'} ( ${outsideVoiceGuard(ctx)}+ // The send binaries enforce codex_reviews (consent_missing); this read only spares a doomed call.+ // An unreadable config exits 2 with its fix on stderr and reads as disabled.+ const config = `if ! _OUTSIDE_CFG=$("${bin}/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; then`;+ const readiness = `elif ( ${outsideVoiceGuard(ctx)}); thenif ${probe}; then echo 'CODEX_MODE: ready'; else echo 'CODEX_MODE: not_installed'; fielse@@ -75,16 +75,14 @@ elsefi`;return `\`\`\`bash${runtimeRootPrelude(ctx)}-${opts.acceptedOnly ? '' : `${config}-if [ "$_OUTSIDE_CFG" = disabled ]; then+${config}echo 'CODEX_MODE: disabled'-`}${readiness}+${readiness}\`\`\`-${ctx.skillName === 'ship' && opts.disabledBehavior === 'opt-in' ? `Ship attempts this optional design check automatically when frontend review applies.-The enabled value above carries that choice. No additional opt-in is needed.-Step 11 keeps its separate outside-review switch.-\`CODEX_MODE\` reports provider availability, not user consent; here the provider is **${v.label}**.` : `The historical \`CODEX_MODE\` variable describes **${v.label}** availability here.`} ${opts.role ? 'The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model.' : 'Authentication and configured model validity are checked by the actual invocation, without overriding either.'} Missing/broken CLI: install or repair ${v.label}; authentication failure: run \`${v.id === 'codex' ? 'codex login' : 'claude auth login'}\`. ${opts.disabledBehavior === 'skip-all' ? 'Disabled ends this entire extra review step, including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer.' : opts.disabledBehavior === 'codex-only' ? 'Disabled skips only the outside CLI; retain the native pass.' : ctx.skillName === 'ship' ? '' : 'Honor this caller’s existing opt-in/skip choice.'} ${opts.disabledBehavior === 'skip-all' ? 'Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled.' : opts.disabledBehavior === 'codex-only' ? 'Non-ready means missing outside coverage. Keep the required native pass without duplicating it.' : 'Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback.'} Never substitute another external provider.`;+${ctx.skillName === 'ship' && opts.disabledBehavior === 'opt-in' ? `Ship attempts this optional design check when frontend review applies and \`codex_reviews\` allows it.+Unset means the default, enabled; the first send prints a one-time notice.+\`CODEX_MODE\` names the provider here, **${v.label}**.` : `The historical \`CODEX_MODE\` variable describes **${v.label}** availability here.`}${opts.disabledBehavior === 'opt-in' ? " `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`." : ''} ${opts.role ? 'The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model.' : 'Authentication and configured model validity are checked by the actual invocation, without overriding either.'} Missing/broken CLI: install or repair ${v.label}; authentication failure: run \`${v.id === 'codex' ? 'codex login' : 'claude auth login'}\`. ${opts.disabledBehavior === 'skip-all' ? "Disabled ends this entire extra review step (so does a send's `consent_missing` line), including the native fallback; record outside_status: disabled and continue after the section. Disabled is not an unavailable provider and never triggers a replacement reviewer." : opts.disabledBehavior === 'codex-only' ? "Disabled skips only the outside CLI (so does a send's `consent_missing` line); retain the native pass." : ctx.skillName === 'ship' ? '' : 'Otherwise honor this caller’s opt-in/skip choice.'} ${opts.disabledBehavior === 'skip-all' ? 'Provider failure is missing outside coverage; follow the caller’s existing fallback only when reviews are enabled.' : opts.disabledBehavior === 'codex-only' ? 'Non-ready means missing outside coverage. Keep the required native pass without duplicating it.' : 'Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback.'} Never substitute another external provider.`;}export interface OutsideCommandOptions {@@ -110,9 +108,14 @@ export function outsideVoiceCommand(ctx: TemplateContext, opts: OutsideCommandOpconst bin = toShellPath(ctx.paths.binDir);const root = toShellPath(ctx.paths.skillRoot);const prompt = sh(opts.promptFile ?? '<prepared-prompt-file>');+ // /spec's 120 s gate keeps its effort: a raised effort would spend the budget it is timed for.+ // 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 effortFlag = pinnedEffort ? ` -c 'model_reasoning_effort="${effort}"'` : '';const codex = opts.structuredBase- ? `codex review --base ${sh(opts.structuredBase)} -c "sandbox_mode=\\"${CODEX_SANDBOX_REF}\\"" ${CODEX_REVIEW_MODEL_CONFIG_FLAG} -c 'model_reasoning_effort="${opts.reasoningEffort ?? 'high'}"' ${CODEX_WEB_SEARCH_FLAG} < /dev/null`- : `codex exec - -C "$_REPO_ROOT" -s "${CODEX_SANDBOX_REF}" ${CODEX_MODEL_CONFIG_FLAG} -c 'model_reasoning_effort="${opts.reasoningEffort ?? 'high'}"' ${CODEX_WEB_SEARCH_FLAG} --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT"`;+ ? `codex review --base ${sh(opts.structuredBase)} -c "sandbox_mode=\\"${CODEX_SANDBOX_REF}\\"" ${CODEX_REVIEW_MODEL_CONFIG_FLAG}${effortFlag} ${CODEX_WEB_SEARCH_FLAG} < /dev/null`+ : `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 kind = opts.structuredBase ? 'review' : 'exec';const invocation = v.id === 'codex'? `${opts.role@@ -121,7 +124,7 @@ export function outsideVoiceCommand(ctx: TemplateContext, opts: OutsideCommandOp"$_CODEX_PROBE" check-sandbox || exit 1`}"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout ${Math.ceil(opts.timeoutMs / 1000)} ${codex} >"$_OUTSIDE_TMP/${opts.structuredBase ? 'text' : 'events'}" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout ${pinnedEffort ? '' : `--effort ${effort} `}${Math.ceil(opts.timeoutMs / 1000)} ${codex} >"$_OUTSIDE_TMP/${opts.structuredBase ? 'text' : 'events'}" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?${opts.structuredBase ? 'cat "$_OUTSIDE_TMP/text"' : 'cat "$_OUTSIDE_TMP/text" 2>/dev/null || tail -n 20 "$_OUTSIDE_TMP/events"'}`: `_OUTSIDE_EXIT=0: >"$_OUTSIDE_TMP/stderr" || exit 1diff --git a/ship/sections/adversarial.md b/ship/sections/adversarial.mdindex 4ae1896f8..bfcafef8e 100644--- a/ship/sections/adversarial.md+++ b/ship/sections/adversarial.md@@ -20,10 +20,10 @@ echo "DIFF_SIZE: $DIFF_TOTAL"# Codex preflight: the probe runs as a command, so any shell works._CODEX_PROBE=~/.claude/skills/gstack/bin/gstack-codex-probe-_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get codex_reviews 2>/dev/null || echo enabled)+_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get --stored codex_reviews 2>/dev/null)_gstack_helper_error=""[ -x "$_CODEX_PROBE" ] || _gstack_helper_error="gstack: cannot load gstack-codex-probe; re-run ./setup. https://github.com/garrytan/gstack/blob/main/docs/troubleshooting.md#sourced-helper-location"-if [ "$_CODEX_CFG" = "disabled" ]; then+if [ "$_CODEX_CFG" = "disabled" ] || [ "$_CODEX_CFG" = "unreadable" ]; then_CODEX_MODE="disabled"elif { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then_CODEX_MODE="under_codex"@@ -62,7 +62,7 @@ echo "CODEX_MODE: $_CODEX_MODE"```Branch on the echoed `CODEX_MODE`:-- **`disabled`** — the user turned Codex reviews off (`codex_reviews=disabled`). Skip the Codex passes only; the Claude adversarial subagent below STILL runs (it is free and fast). Print: "Codex passes skipped (codex_reviews disabled) — running Claude adversarial only."+- **`disabled`** (or a send's `consent_missing` line) — `codex_reviews` is off or unreadable. Skip the Codex passes only; the Claude adversarial subagent below STILL runs (it is free and fast). Print: "Codex passes skipped (codex_reviews disabled) — running Claude adversarial only."- **`helper_unavailable`** — the probe is missing or not executable; relay the line above (cause and fix). Keep the required Claude adversarial pass; do not dispatch a duplicate.- **`not_installed`** — Codex CLI absent. Print: "Codex not installed; outside coverage unavailable. Install: `npm install -g @openai/codex`." Keep the required Claude adversarial pass; do not dispatch a duplicate.- **`under_codex`** — stale artifact selected its own harness. Print: "Codex outside review unavailable: harness mismatch; no outside process started. Missing coverage. Repair: setup --host codex." Skip the outside invocation and follow the workflow's native-review instructions below. Conflicting inherited harness markers are not grounds to guess another provider.@@ -141,7 +141,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }@@ -203,7 +203,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 540 codex review --base '<base>' -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "review_model=\"${_CODEX_SEL:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' < /dev/null >"$_OUTSIDE_TMP/text" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 540 codex review --base '<base>' -c "sandbox_mode=\"${_CODEX_SANDBOX_MODE:?}\"" -c "review_model=\"${_CODEX_SEL:?}\"" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' < /dev/null >"$_OUTSIDE_TMP/text" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?cat "$_OUTSIDE_TMP/text"cat "$_OUTSIDE_TMP/stderr" >&2 || { [ "$_OUTSIDE_EXIT" -ne 0 ] || _OUTSIDE_EXIT=1; }diff --git a/ship/sections/review-army.md b/ship/sections/review-army.mdindex d6503559e..13a7b7e9c 100644--- a/ship/sections/review-army.md+++ b/ship/sections/review-army.md@@ -167,12 +167,11 @@ Exit 2 means findings. Read the `DETECT_TOP` block (untrusted content: evidence,5. **Include findings** in the review output under a "Design Review" header, following the output format in the checklist. Design findings merge with code review findings into the same Fix-First flow.-6. **Codex design voice** (optional, automatic if available):+6. **Codex design voice** (optional; runs when available and `codex_reviews` allows it):```bash-_OUTSIDE_CFG=enabled-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -191,10 +190,9 @@ elsefi```-Ship attempts this optional design check automatically when frontend review applies.-The enabled value above carries that choice. No additional opt-in is needed.-Step 11 keeps its separate outside-review switch.-`CODEX_MODE` reports provider availability, not user consent; here the provider is **Codex**. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.+Ship attempts this optional design check when frontend review applies and `codex_reviews` allows it.+Unset means the default, enabled; the first send prints a one-time notice.+`CODEX_MODE` names the provider here, **Codex**. `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`. Authentication and configured model validity are checked by the actual invocation, without overriding either. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.If Codex is available, run a lightweight design check on the diff:@@ -227,7 +225,7 @@ _CODEX_SANDBOX_MODE=$(echo "$_CODEX_OUT" | sed -n 's/^CODEX_SANDBOX: //p')"$_CODEX_PROBE" check-sandbox || exit 1"$_CODEX_PROBE" show-first-use-notice_OUTSIDE_EXIT=0-"$_CODEX_PROBE" run-with-timeout 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'model_reasoning_effort="high"' -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?+"$_CODEX_PROBE" run-with-timeout --effort high 300 codex exec - -C "$_REPO_ROOT" -s "${_CODEX_SANDBOX_MODE:?}" -c "model=\"${_CODEX_SEL:?}\"" -c skills.include_instructions=false -c 'web_search="cached"' --json -o "$_OUTSIDE_TMP/text" <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/events" 2>"$_OUTSIDE_TMP/stderr" || _OUTSIDE_EXIT=$?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; }diff --git a/spec/sections/gate-and-file.md b/spec/sections/gate-and-file.mdindex 6455c3988..6c6585356 100644--- a/spec/sections/gate-and-file.md+++ b/spec/sections/gate-and-file.md@@ -129,8 +129,7 @@ dispatch. `spec-quality-gate-secret-sink.test.ts` enforces this.```bash-_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.-if [ "$_OUTSIDE_CFG" = disabled ]; then+if ! _OUTSIDE_CFG=$("$HOME/.claude/skills/gstack/bin/gstack-config" get --stored codex_reviews) || [ "$_OUTSIDE_CFG" = disabled ]; thenecho 'CODEX_MODE: disabled'elif ( # GSTACK_ACTIVE_HOST names the harness, never the model.if { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ] || [ "${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then@@ -149,7 +148,7 @@ elsefi```-The historical `CODEX_MODE` variable describes **Codex** availability here. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Honor this caller’s existing opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.+The historical `CODEX_MODE` variable describes **Codex** availability here. `CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`. The invocation checks auth and the [policy](https://github.com/garrytan/gstack/blob/main/docs/model-policy.md) plan-review model. Missing/broken CLI: install or repair Codex; authentication failure: run `codex login`. Otherwise honor this caller’s opt-in/skip choice. Any non-ready outcome is missing outside coverage; follow the caller’s existing fallback. Never substitute another external provider.Write the prompt with the exact redaction-approved spec bytes using the Write tool; never shell-interpolate the raw draft. Keep hard delimiters and this boundary:diff --git a/test/autoplan-dual-voice-evidence.test.ts b/test/autoplan-dual-voice-evidence.test.tsindex 037bd18ec..1692d495e 100644--- a/test/autoplan-dual-voice-evidence.test.ts+++ b/test/autoplan-dual-voice-evidence.test.ts@@ -237,8 +237,8 @@ test.each(['before','after'])('guard blocks retain command separators around thetest.each(['assignment-only','set-config','other-config','foreign-reader','or-config','and-cli','inverted-cli','no-exit','return','dynamic-exit','out-of-range-exit','command-substitution','backticks','redirect','diagnostic-command','completed-diagnostic','variable-change','duplicate-config','duplicate-cli','extra-command','conditional-body','inside-harness','inside-body','before-cd','changed-harness','changed-timeout','changed-sandbox','changed-prompt','skipped-validator','suffix'])('availability guards reject changed dispatch or non-stop shell: %s',kind=>{const f=fixture();let guards=configStop(f)+'\n'+cliStop;if(kind==='assignment-only')guards=configRead(f);- if(kind==='set-config')guards=guards.replace('get codex_reviews','set codex_reviews enabled');- if(kind==='other-config')guards=guards.replace('get codex_reviews','get telemetry');+ if(kind==='set-config')guards=guards.replace('get --stored codex_reviews','set codex_reviews enabled');+ if(kind==='other-config')guards=guards.replace('get --stored codex_reviews','get --stored telemetry');if(kind==='foreign-reader')guards=guards.replace('~/.claude/skills/gstack/bin/gstack-config','/tmp/gstack-config');if(kind==='or-config')guards=guards.replace('] && {','] || {');if(kind==='and-cli')guards=guards.replace('2>&1 || {','2>&1 && {');@@ -263,7 +263,7 @@ test.each(['assignment-only','set-config','other-config','foreign-reader','or-coif(kind==='inside-body')input.command=input.command.replace(guards+'\n','').replace('_OUTSIDE_EXIT=0','_OUTSIDE_EXIT=0\n'+guards);if(kind==='before-cd')input.command=guards+'\ncd '+f.dir+'\n'+f.options.commands.outside.replace("'<prepared-prompt-file>'","'"+f.file+"'");if(kind==='changed-harness')input.command=input.command.replace('exit 78','exit 0');- if(kind==='changed-timeout')input.command=input.command.replace('run-with-timeout 540','run-with-timeout 1');+ if(kind==='changed-timeout')input.command=input.command.replace('high 540 codex','high 1 codex');if(kind==='changed-sandbox')input.command=input.command.replace('-s "${_CODEX_SANDBOX_MODE:?}"','-s danger-full-access');if(kind==='changed-prompt')input.command=input.command.replace('codex exec - ','codex exec "Different plan" ');if(kind==='skipped-validator')input.command=input.command.replace(/^bun .*outside-review-result.*\n/m,'');diff --git a/test/binding-template-drift.test.ts b/test/binding-template-drift.test.tsindex 5c4c5065a..8dda8e0dc 100644--- a/test/binding-template-drift.test.ts+++ b/test/binding-template-drift.test.ts@@ -120,7 +120,7 @@ describe('content-binding template drift', () => {const codex = rendered('codex/sections/review-mode.md');const starts = [...codex.matchAll(/gstack-review-log --start codex-review/g)];expect(starts).toHaveLength(2);- expect(starts[0].index).toBeLessThan(codex.indexOf('run-with-timeout 330 codex review'));+ expect(starts[0].index).toBeLessThan(codex.indexOf('run-with-timeout --user-invoked --effort high 330 codex review'));expect(starts[1].index).toBeLessThan(codex.indexOf('git diff "<base>...HEAD"'));expect(codex).toContain('--finish CODEX_REVIEW_START');expect(codex).toContain('"completed":COMPLETED,"converged":CONVERGED');diff --git a/test/claude-code-skill.test.ts b/test/claude-code-skill.test.tsindex 61139c927..4e8a6447e 100644--- a/test/claude-code-skill.test.ts+++ b/test/claude-code-skill.test.ts@@ -81,7 +81,7 @@ function shell(mode: Mode, extra: NodeJS.ProcessEnv = {}, options: {resume?: boo.replace("'<gstack-runtime-root>'", q(options.runtime ?? RUNTIME)).replace("'<base>'", q('main')).replace("'<fresh-or-resume>'", q(options.resume ? 'resume' : 'fresh'))- .replaceAll('"$CLAUDE_RUNNER" --cwd', `"$CLAUDE_RUNNER"${options.planReview ? ' --role plan-review' : ''} --cwd`);+ .replaceAll('"$CLAUDE_RUNNER" --user-invoked --cwd', `"$CLAUDE_RUNNER" --user-invoked${options.planReview ? ' --role plan-review' : ''} --cwd`);return spawnSync('bash', ['-c',script], {cwd:options.cwd ?? REPO, env:{...ENV,...extra}, encoding:'utf8',timeout:10000});}function captured() { return JSON.parse(fs.readFileSync(CAPTURE,'utf8')); }diff --git a/test/codex-effort.test.ts b/test/codex-effort.test.tsnew file mode 100644index 000000000..9ff3d1556--- /dev/null+++ b/test/codex-effort.test.ts@@ -0,0 +1,129 @@+/**+ * D1-A (#3098, #2934): Codex reasoning effort follows the model's precedence,+ * GSTACK_CODEX_EFFORT, then codex_effort in config.yaml, then each gate's own+ * default, for manual /codex and gstack's outside reviews alike. /spec's gate+ * keeps medium inside its 120 s budget whatever is set. Template contracts are+ * adapted from #3098 (@Lockyer228); the gate test runs the generated command+ * against a fake codex and reads the arguments it was given.+ */+import { afterAll, describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';+import { codexEffortSetting, modelsMain } from '../lib/model-policy-cli';+import { outsideVoiceCommand } from '../scripts/resolvers/outside-voice';+import { HOST_PATHS, type TemplateContext } from '../scripts/resolvers/types';++const ROOT = path.resolve(import.meta.dir, '..');+const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'codex-effort-'));+afterAll(() => fs.rmSync(TMP, { recursive: true, force: true }));+const read = (rel: string) => fs.readFileSync(path.join(ROOT, rel), 'utf8');++const MODES: Array<[string, string]> = [['review-mode', 'high'], ['challenge-mode', 'high'], ['consult-mode', 'medium']];++describe('manual /codex modes (#3098)', () => {+ test('every mode dispatches through run-with-timeout --effort with its own default', () => {+ for (const [mode, def] of MODES) {+ const tmpl = read(`codex/sections/${mode}.md.tmpl`);+ const dispatches = tmpl.split('\n').filter(line => /run-with-timeout --user-invoked --effort \w+ \d+ codex (exec|review)\b/.test(line));+ expect(dispatches.length, mode).toBeGreaterThan(0);+ for (const line of dispatches) {+ expect(line, mode).toContain(`--effort ${def} `);+ expect(line, mode).not.toContain('model_reasoning_effort');+ }+ expect(tmpl, mode).not.toContain('check-effort');+ }+ });++ test('the skill body documents the precedence and the --xhigh override', () => {+ const body = read('codex/SKILL.md.tmpl');+ for (const want of ['GSTACK_CODEX_EFFORT=xhigh', 'codex_effort', 'run-with-timeout --effort <default>']) expect(body).toContain(want);+ });+});++describe('gstack outside reviews use the same precedence', () => {+ test('rendered gates pass their default to run-with-timeout --effort', () => {+ for (const [rel, def] of [['autoplan/sections/ceo-phase.md', 'high'], ['plan-eng-review/sections/review-sections.md', 'high'],+ ['review/sections/adversarial.md', 'high'], ['design-consultation/sections/proposal-and-preview.md', 'medium']] as const) {+ const text = read(rel);+ expect(text, rel).not.toContain('check-effort');+ const dispatches = text.split('\n').filter(line => /run-with-timeout (--effort \w+ )?\d+ codex (exec|review)\b/.test(line));+ expect(dispatches.length, rel).toBeGreaterThan(0);+ for (const line of dispatches) {+ expect(line, rel).toContain(`run-with-timeout --effort ${def} `);+ expect(line, rel).not.toContain('model_reasoning_effort');+ }+ }+ });++ const fakeBin = path.join(TMP, 'bin');+ const capture = path.join(TMP, 'codex-args');+ fs.mkdirSync(fakeBin, { recursive: true });+ fs.writeFileSync(path.join(fakeBin, 'codex'), `#!/usr/bin/env bash+[ "$1" = sandbox ] && exit 0+printf '%s\\n' "$@" > '${capture}'+cat >/dev/null+while [ "$#" -gt 0 ]; do [ "$1" = -o ] && printf 'SCORE: 8\\nAMBIGUITIES: NONE\\n' > "$2"; shift; done+echo '{"type":"item.completed","item":{"type":"agent_message","text":"SCORE: 8"}}'+`, { mode: 0o755 });+ const repo = path.join(TMP, 'repo');+ fs.mkdirSync(repo);+ spawnSync('git', ['init', '-q'], { cwd: repo, timeout: 30_000 });+ const prompt = path.join(TMP, 'prompt.txt');+ fs.writeFileSync(prompt, 'Score this spec.\n');++ function dispatchedArgs(gate: 'spec' | 'review', effortEnv: string | undefined, stored: string | undefined): string[] {+ const state = path.join(TMP, `state-${gate}-${effortEnv ?? 'none'}-${stored ?? 'none'}`);+ fs.mkdirSync(state, { recursive: true });+ if (stored) fs.writeFileSync(path.join(state, 'config.yaml'), `codex_effort: ${stored}\n`);+ const ctx: TemplateContext = { skillName: gate === 'spec' ? 'spec' : 'review', tmplPath: 'x/SKILL.md.tmpl', host: 'claude', paths: { ...HOST_PATHS.claude, binDir: path.join(ROOT, 'bin'), skillRoot: ROOT } };+ const command = gate === 'spec'+ ? outsideVoiceCommand(ctx, { promptFile: prompt, timeoutMs: 120_000, gate: 'spec', reasoningEffort: 'medium' })+ : outsideVoiceCommand(ctx, { promptFile: prompt, timeoutMs: 300_000 });+ fs.rmSync(capture, { force: true });+ const env: Record<string, string> = {};+ for (const [k, v] of Object.entries(process.env)) if (v !== undefined && !/^(CODEX_|GSTACK_CODEX_|OPENAI_)/.test(k)) env[k] = v;+ Object.assign(env, { PATH: `${fakeBin}:${process.env.PATH}`, GSTACK_HOME: state, GSTACK_STATE_ROOT: '', CODEX_HOME: TMP, GSTACK_ACTIVE_HOST: 'claude', CLAUDECODE: '1' });+ if (effortEnv) env.GSTACK_CODEX_EFFORT = effortEnv;+ spawnSync('bash', ['-c', command], { cwd: repo, env, encoding: 'utf8', timeout: 60_000 });+ return fs.existsSync(capture) ? fs.readFileSync(capture, 'utf8').split('\n') : [];+ }++ test('an ordinary gate takes env, then config, then its default', () => {+ expect(dispatchedArgs('review', undefined, undefined)).toContain('model_reasoning_effort="high"');+ expect(dispatchedArgs('review', undefined, 'low')).toContain('model_reasoning_effort="low"');+ expect(dispatchedArgs('review', 'max', 'low')).toContain('model_reasoning_effort="max"');+ expect(dispatchedArgs('review', 'banana', undefined)).toEqual([]);+ });++ test('/spec keeps medium effort and its 120 s budget whatever env or config say', () => {+ for (const [env, stored] of [[undefined, undefined], ['max', undefined], [undefined, 'xhigh'], ['ultra', 'low']] as const) {+ expect(dispatchedArgs('spec', env, stored)).toContain('model_reasoning_effort="medium"');+ }+ const spec = read('spec/sections/gate-and-file.md');+ const dispatch = spec.split('\n').find(line => /run-with-timeout \d+ codex exec/.test(line))!;+ expect(dispatch).toContain('run-with-timeout 120 codex exec');+ expect(dispatch).toContain(`-c 'model_reasoning_effort="medium"'`);+ expect(spec).not.toContain('check-effort');+ });+});++describe('codex_effort setting', () => {+ test('gstack-config rejects an invalid level and keeps the stored one', () => {+ const state = path.join(TMP, 'config-state');+ fs.mkdirSync(state, { recursive: true });+ const env = { ...process.env, GSTACK_HOME: state, GSTACK_STATE_ROOT: '' } as Record<string, string>;+ const config = (...args: string[]) => spawnSync(path.join(ROOT, 'bin', 'gstack-config'), args, { env, encoding: 'utf8', timeout: 30_000 });+ expect(config('set', 'codex_effort', 'low').status).toBe(0);+ const bad = config('set', 'codex_effort', 'banana');+ expect(bad.status).toBe(1);+ expect(bad.stderr).toContain("codex_effort 'banana' not recognized");+ expect(config('get', 'codex_effort').stdout).toBe('low');+ expect(codexEffortSetting(env)).toEqual({ value: 'low', source: 'config', valid: true });+ expect(codexEffortSetting({ ...env, GSTACK_CODEX_EFFORT: 'max' })).toEqual({ value: 'max', source: 'env', valid: true });+ const list = modelsMain([], env);+ expect(list.stdout).toContain('codex effort: low (codex_effort in ');+ expect(JSON.parse(modelsMain(['--json'], { ...env, GSTACK_CODEX_EFFORT: 'nope' }).stdout).codexEffort).toEqual({ value: 'nope', source: 'env', valid: false });+ });+});diff --git a/test/codex-hardening.test.ts b/test/codex-hardening.test.tsindex 174154f81..0810f6d6d 100644--- a/test/codex-hardening.test.ts+++ b/test/codex-hardening.test.ts@@ -645,7 +645,7 @@ describe('codex timeout wrapper: /review + /ship diff passes', () => {test(`${relPath}: both diff-review Codex calls run under the wrapper`, () => {const wrapped =- read().match(/run-with-timeout\s+\d+\s+codex\s+(exec|review)\b/g) ?? [];+ read().match(/run-with-timeout\s+(?:--user-invoked\s+)?(?:--effort\s+\w+\s+)?\d+\s+codex\s+(exec|review)\b/g) ?? [];// Adversarial pass + structured review pass.expect(wrapped.length).toBeGreaterThanOrEqual(2);});@@ -658,7 +658,7 @@ describe('codex timeout wrapper: /review + /ship diff passes', () => {});test(`${relPath}: wrapper budget stays under the outer Bash gate`, () => {- const budgets = [...read().matchAll(/run-with-timeout\s+(\d+)\s+codex\b/g)].map(+ const budgets = [...read().matchAll(/run-with-timeout\s+(?:--user-invoked\s+)?(?:--effort\s+\w+\s+)?(\d+)\s+codex\b/g)].map((m) => Number(m[1]) * 1000,);expect(budgets.length).toBeGreaterThan(0);@@ -710,7 +710,7 @@ describe('codex skeleton+sections union: review sandbox + fail-closed gate + timtest(`${relPath}: (a) every scoped codex review invocation pins sandbox_mode from the selected sandbox`, () => {const invocations = read().split('\n')- .filter((l) => /run-with-timeout\s+\d+\s+codex\s+review\b/.test(l));+ .filter((l) => /run-with-timeout\s+(?:--user-invoked\s+)?(?:--effort\s+\w+\s+)?\d+\s+codex\s+review\b/.test(l));expect(invocations.length).toBeGreaterThanOrEqual(1);for (const line of invocations) {// select-model reports read-only (full access only for@@ -772,7 +772,7 @@ describe('codex skeleton+sections union: review sandbox + fail-closed gate + timconst inspected: string[] = [];for (const section of sections) {const gates = [...section.matchAll(/timeout:\s*(\d{4,})/g)].map((m) => Number(m[1]));- const wrappers = [...section.matchAll(/run-with-timeout\s+(\d+)\s+codex\b/g)].map(+ const wrappers = [...section.matchAll(/run-with-timeout\s+(?:--user-invoked\s+)?(?:--effort\s+\w+\s+)?(\d+)\s+codex\b/g)].map((m) => Number(m[1]) * 1000,);if (gates.length === 0 || wrappers.length === 0) continue;diff --git a/test/codex-invocation-sites.test.ts b/test/codex-invocation-sites.test.tsindex 3fce944a7..290834ec5 100644--- a/test/codex-invocation-sites.test.ts+++ b/test/codex-invocation-sites.test.ts@@ -17,7 +17,7 @@ const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'codex-sites-'));afterAll(() => fs.rmSync(TMP, { recursive: true, force: true }));/** `codex exec|review` at the start of a shell command, optionally behind the probe's run-with-timeout. */-const COMMAND = /(?:^|[;&|]\s*|\$\(\s*)(?:"\$_CODEX_PROBE"\s+run-with-timeout\s+\d+\s+)?codex\s+(?:exec|review)\b/;+const COMMAND = /(?:^|[;&|]\s*|\$\(\s*)(?:"\$_CODEX_PROBE"\s+run-with-timeout\s+(?:--user-invoked\s+)?(?:--effort\s+\w+\s+)?\d+\s+)?codex\s+(?:exec|review)\b/;const VALIDATOR = /outside-review-result\.ts\b/;interface Site { file: string; line: string; fence: string; after: string }diff --git a/test/codex-probe-subcommands.test.ts b/test/codex-probe-subcommands.test.tsindex 5dfed8e26..8d4500714 100644--- a/test/codex-probe-subcommands.test.ts+++ b/test/codex-probe-subcommands.test.ts@@ -17,7 +17,7 @@ const PROBE = path.join(ROOT, 'bin', 'gstack-codex-probe');const HAS_ZSH = Boolean(Bun.which('zsh'));const ZSH_REQUIRED = Boolean(process.env.CI) && process.platform !== 'win32';const SHELLS = ['bash', 'zsh'] as const;-const SUBCOMMANDS = ['select-model', 'check-auth', 'show-sandbox', 'check-sandbox', 'probe-model', 'check-version',+const SUBCOMMANDS = ['select-model', 'check-effort', 'check-auth', 'show-sandbox', 'check-sandbox', 'probe-model', 'check-version','show-first-use-notice', 'run-with-timeout', 'log-event', 'log-hang', 'help'];const STUB = `#!/usr/bin/env bash@@ -96,6 +96,7 @@ describe('gstack-codex-probe subcommands', () => {try {const results: Record<string, ReturnType<typeof probe>> = {'select-model': probe(f, 'select-model exec', {}, shell),+ 'check-effort': probe(f, 'check-effort high', {}, shell),'check-auth': probe(f, 'check-auth', {}, shell),'show-sandbox': probe(f, 'show-sandbox', {}, shell),'check-sandbox': probe(f, 'check-sandbox', {}, shell),@@ -113,6 +114,8 @@ describe('gstack-codex-probe subcommands', () => {}expect(results['select-model']!.stdout).toBe('CODEX_SEL: gpt-test-model\nCODEX_SEL_KIND: exec\nCODEX_SANDBOX: read-only\n');expect(results['select-model']!.stderr).toContain('CODEX_MODEL: gpt-test-model (exec; source: ');+ expect(results['check-effort']!.stdout).toBe('CODEX_EFFORT: high\n');+ expect(results['check-effort']!.stderr).toBe('');expect(results['check-auth']!.stdout).toBe('AUTH_OK\n');expect(results['show-sandbox']!.stdout).toBe('CODEX_SANDBOX: read-only\n');expect(results['check-sandbox']!.stdout).toBe('');@@ -153,6 +156,61 @@ describe('gstack-codex-probe subcommands', () => {} finally { fs.rmSync(f.home, { recursive: true, force: true }); }});+ test('check-effort uses GSTACK_CODEX_EFFORT, then codex_effort, then the gate default, and rejects a bad level before any Codex call', () => {+ const f = fixture();+ try {+ const unset = probe(f, 'check-effort high');+ expect([unset.code, unset.stdout]).toEqual([0, 'CODEX_EFFORT: high\n']);+ expect(probe(f, 'check-effort medium').stdout).toBe('CODEX_EFFORT: medium\n');+ const max = probe(f, 'check-effort high', { GSTACK_CODEX_EFFORT: 'max' });+ expect([max.code, max.stdout]).toEqual([0, 'CODEX_EFFORT: max\n']);+ expect(max.stderr).toBe('CODEX_EFFORT: max (source: env GSTACK_CODEX_EFFORT)\n');+ fs.writeFileSync(path.join(f.state, 'config.yaml'), 'codex_effort: low\n');+ const config = probe(f, 'check-effort high');+ expect([config.code, config.stdout, config.stderr]).toEqual([0, 'CODEX_EFFORT: low\n', 'CODEX_EFFORT: low (source: config codex_effort)\n']);+ expect(probe(f, 'check-effort high', { GSTACK_CODEX_EFFORT: 'xhigh' }).stdout).toBe('CODEX_EFFORT: xhigh\n');+ fs.writeFileSync(path.join(f.state, 'config.yaml'), 'codex_effort: bogus\n');+ const badConfig = probe(f, 'check-effort high');+ expect([badConfig.code, badConfig.stdout]).toEqual([1, '']);+ expect(badConfig.stderr).toContain("'bogus' from config codex_effort");+ fs.rmSync(path.join(f.state, 'config.yaml'));+ const empty = probe(f, 'check-effort high', { GSTACK_CODEX_EFFORT: '' });+ expect([empty.code, empty.stdout]).toEqual([0, 'CODEX_EFFORT: high\n']);+ const invalid = probe(f, 'check-effort high', { GSTACK_CODEX_EFFORT: 'banana' });+ expect([invalid.code, invalid.stdout]).toEqual([1, '']);+ expect(invalid.stderr).toContain('HINT:');+ expect(invalid.stderr).toContain('banana');+ const badDefault = probe(f, 'check-effort banana');+ expect([badDefault.code, badDefault.stdout, badDefault.stderr.startsWith('Usage: gstack-codex-probe')])+ .toEqual([64, '', true]);+ const badDefaultWithEnv = probe(f, 'check-effort banana', { GSTACK_CODEX_EFFORT: 'max' });+ expect([badDefaultWithEnv.code, badDefaultWithEnv.stdout, badDefaultWithEnv.stderr.startsWith('Usage: gstack-codex-probe')])+ .toEqual([64, '', true]);+ expect(calls(f)).toEqual([]);+ } finally { fs.rmSync(f.home, { recursive: true, force: true }); }+ });++ test('run-with-timeout --effort appends the resolved effort to the codex command; a bad level or non-codex command never runs', () => {+ const f = fixture();+ try {+ expect(probe(f, 'run-with-timeout --effort high 20 codex exec - --json').code).toBe(0);+ fs.writeFileSync(path.join(f.state, 'config.yaml'), 'codex_effort: low\n');+ expect(probe(f, 'run-with-timeout --user-invoked --effort high 20 codex review --base main').code).toBe(0);+ expect(probe(f, 'run-with-timeout --effort medium 20 codex exec -', { GSTACK_CODEX_EFFORT: 'xhigh' }).code).toBe(0);+ expect(calls(f)).toEqual([+ 'exec - --json -c model_reasoning_effort="high"',+ 'review --base main -c model_reasoning_effort="low"',+ 'exec - -c model_reasoning_effort="xhigh"',+ ]);+ const bad = probe(f, 'run-with-timeout --effort high 20 codex exec -', { GSTACK_CODEX_EFFORT: 'banana' });+ expect([bad.code, bad.stdout]).toEqual([1, '']);+ expect(bad.stderr).toContain('No Codex call was made');+ expect(probe(f, 'run-with-timeout --effort high 20 echo hi').code).toBe(64);+ expect(probe(f, 'run-with-timeout --effort 20 codex exec -').code).toBe(64);+ expect(calls(f)).toHaveLength(3);+ } finally { fs.rmSync(f.home, { recursive: true, force: true }); }+ });+test('probe-model reports CODEX_PROBE_STATE with the old exit codes, probing exactly the requested model', () => {const f = fixture();try {diff --git a/test/codex-skill-isolation.test.ts b/test/codex-skill-isolation.test.tsindex 5b66651bf..a014a085a 100644--- a/test/codex-skill-isolation.test.ts+++ b/test/codex-skill-isolation.test.ts@@ -43,7 +43,7 @@ describe('Codex skill isolation (#2847)', () => {const calls: string[] = [];for (const file of renderedSkillFiles()) {for (const line of fs.readFileSync(file, 'utf8').split('\n')) {- if (/run-with-timeout\s+\d+\s+codex\s+(exec|review)\b/.test(line)) calls.push(`${path.relative(ROOT, file)}: ${line}`);+ if (/run-with-timeout\s+(?:--user-invoked\s+)?(?:--effort\s+\w+\s+)?\d+\s+codex\s+(exec|review)\b/.test(line)) calls.push(`${path.relative(ROOT, file)}: ${line}`);}}expect(calls.length).toBeGreaterThan(10);diff --git a/test/design-consultation-contract.test.ts b/test/design-consultation-contract.test.tsindex 1081aa327..99ecc8dc6 100644--- a/test/design-consultation-contract.test.ts+++ b/test/design-consultation-contract.test.ts@@ -79,7 +79,7 @@ test('consultation drafts before independent dispatch and compares completed inpexpect(section).toContain('label old proposals stale');});-test('consultation opt-in probes the CLI without a disabled branch and rechecks its spawn', () => {+test('consultation opt-in reads the stored consent, probes the CLI and rechecks its spawn', () => {const text = generateDesignOutsideVoices(context('claude'));const accepted = text.indexOf('**If accepted:**');const availability = text.indexOf('**Check Codex availability:**');@@ -88,7 +88,8 @@ test('consultation opt-in probes the CLI without a disabled branch and rechecksexpect(invocation).toBeGreaterThan(availability);const preflight = text.slice(availability, invocation);expect(preflight).not.toContain('_OUTSIDE_CFG=enabled');- expect(preflight).not.toContain('CODEX_MODE: disabled');+ expect(preflight).toContain('get --stored codex_reviews');+ expect(preflight).toContain('CODEX_MODE: disabled');expect(preflight).toContain('CODEX_MODE: under_current_harness');expect(preflight).toContain('exit 78');expect(text.slice(invocation)).toContain('exit 78');diff --git a/test/gen-skill-docs.test.ts b/test/gen-skill-docs.test.tsindex 3b7f4f0f3..909544f53 100644--- a/test/gen-skill-docs.test.ts+++ b/test/gen-skill-docs.test.ts@@ -2379,10 +2379,13 @@ describe('DESIGN_OUTSIDE_VOICES resolver', () => {test('branches correctly per skillName — different prompts', () => {const planContent = readSkillUnion('plan-design-review');const consultContent = readSkillUnion('design-consultation');- // plan-design-review uses analytical prompt (high reasoning)- expect(planContent).toContain('model_reasoning_effort="high"');+ // plan-design-review uses analytical prompt (high reasoning); run-with-timeout+ // turns --effort X into -c model_reasoning_effort="X" (test/codex-probe-subcommands.test.ts)+ expect(planContent).toContain('run-with-timeout --effort high ');+ expect(planContent).not.toContain('--effort medium');// design-consultation uses creative prompt (medium reasoning)- expect(consultContent).toContain('model_reasoning_effort="medium"');+ expect(consultContent).toContain('run-with-timeout --effort medium ');+ expect(consultContent).not.toContain('--effort high');});});diff --git a/test/gstack-config-key-locale.test.ts b/test/gstack-config-key-locale.test.tsindex b313f1513..b6ac09ee3 100644--- a/test/gstack-config-key-locale.test.ts+++ b/test/gstack-config-key-locale.test.ts@@ -47,13 +47,13 @@ afterEach(() => {});describe("gstack-config key validation is locale-independent", () => {- test("get, has, set and unset all validate ASCII ranges under the C locale", () => {+ test("get, get --stored, has, set and unset all validate ASCII ranges under the C locale", () => {const source = fs.readFileSync(CONFIG, "utf8");const guardedValidators = source.match(/LC_ALL=C grep -qE '\^\[a-zA-Z0-9_\]\+\(@\[a-zA-Z0-9\]\+\)\?\$'/g,);- expect(guardedValidators).toHaveLength(4);+ expect(guardedValidators).toHaveLength(5);});test("round-trips existing keys that contain i", () => {diff --git a/test/helpers/autoplan-dual-voice-evidence.ts b/test/helpers/autoplan-dual-voice-evidence.tsindex 6176eebf5..3cfa33d33 100644--- a/test/helpers/autoplan-dual-voice-evidence.ts+++ b/test/helpers/autoplan-dual-voice-evidence.ts@@ -34,7 +34,7 @@ function block(source: string, needle: string): string {}export function loadAutoplanDualCommandContract(root: string) {return { probe: block(readFileSync(join(root, 'autoplan/SKILL.md'), 'utf8'), 'echo "CODEX_MODE: $_CODEX_MODE"'),- outside: block(readFileSync(join(root, 'autoplan/sections/ceo-phase.md'), 'utf8'), 'run-with-timeout 540 codex exec') };+ outside: block(readFileSync(join(root, 'autoplan/sections/ceo-phase.md'), 'utf8'), 'run-with-timeout --effort high 540 codex exec') };}export interface AutoplanDualEvidenceOptions {ownedRoots: string[];diff --git a/test/host-config.test.ts b/test/host-config.test.tsindex 57ae4adb2..4a66af701 100644--- a/test/host-config.test.ts+++ b/test/host-config.test.ts@@ -469,7 +469,7 @@ describe('golden-file regression', () => {test('every Claude outside-voice mode uses the restricted runner and exposes an explicit model override', () => {const rendered = fs.readFileSync(path.join(GOLDEN_OUT, '.agents/skills/gstack-claude-code/SKILL.md'), 'utf8');- const calls = rendered.split('\n').filter(line => line.includes('"$CLAUDE_RUNNER" --cwd'));+ const calls = rendered.split('\n').filter(line => line.includes('"$CLAUDE_RUNNER" --user-invoked --cwd'));expect(calls).toHaveLength(3);expect(rendered.match(/CLAUDE_RUNNER="\$RUNTIME_ROOT\/bin\/gstack-claude-code"/g)).toHaveLength(3);for (const call of calls) {diff --git a/test/model-role-invocation.test.ts b/test/model-role-invocation.test.tsindex 117484620..d9be98072 100644--- a/test/model-role-invocation.test.ts+++ b/test/model-role-invocation.test.ts@@ -607,7 +607,7 @@ describe('manual /codex entry: explicit role only, paid probe only for the dispaexpect(template.match(/\{\{CODEX_SELECT/g)!.length).toBe(selections.length);for (const block of template.split(/\{\{CODEX_SELECT:/).slice(1)) {const [kind, budget] = block.split('}}')[0]!.split(':');- const wrappers = [...block.split('```')[0]!.matchAll(/run-with-timeout (\d+) codex/g)].map(m => m[1]);+ const wrappers = [...block.split('```')[0]!.matchAll(/run-with-timeout (?:--user-invoked )?(?:--effort \w+ )?(\d+) codex/g)].map(m => m[1]);expect(wrappers.length).toBeGreaterThan(0);expect(new Set(wrappers)).toEqual(new Set([budget]));expect(kind).toMatch(/^(exec|review)$/);diff --git a/test/outside-consent.test.ts b/test/outside-consent.test.tsnew file mode 100644index 000000000..104323609--- /dev/null+++ b/test/outside-consent.test.ts@@ -0,0 +1,221 @@+/**+ * #3102 / D5: codex_reviews is enforced where the send happens. The stored+ * read (`gstack-config get --stored`) tells enabled, disabled, unset and+ * unreadable apart; gstack-codex-probe run-with-timeout, gstack-claude-code,+ * gstack-outside-voice and the unattended runner (gstack-autoplan) refuse with+ * `not_run consent_missing` when it is disabled or unreadable, and stub+ * launchers prove zero CLI launches and zero API requests then, and one launch+ * when it is allowed. The bash and TS readers agree on every fixture.+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';+import { GATE_OUTCOMES, gateOutcomeLine } from '../lib/gate-outcomes';+import { CONSENT_MARKER, outsideConsent, readStoredCodexReviews } from '../lib/outside-consent';+import { SMALL_PLAN } from './helpers/autoplan-run-fixture';++const ROOT = path.resolve(import.meta.dir, '..');+const BIN = path.join(ROOT, 'bin');+const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'outside-consent-'));+afterAll(() => fs.rmSync(TMP, { recursive: true, force: true }));++type Consent = 'unset' | 'enabled' | 'disabled' | 'unreadable' | 'garbage' | 'legacy-disabled';+let n = 0;++/** A private state root (and legacy root) holding one consent fixture, plus a stub bin dir that logs launches. */+function fixture(consent: Consent) {+ const dir = path.join(TMP, `f${++n}`);+ const state = path.join(dir, 'state');+ const legacy = path.join(dir, 'legacy');+ const stubs = path.join(dir, 'stubs');+ const launches = path.join(dir, 'launches.log');+ for (const d of [state, legacy, stubs]) fs.mkdirSync(d, { recursive: true });+ if (consent === 'enabled' || consent === 'disabled') fs.writeFileSync(path.join(state, 'config.yaml'), `codex_reviews: ${consent}\n`);+ if (consent === 'garbage') fs.writeFileSync(path.join(state, 'config.yaml'), 'codex_reviews: maybe\n');+ if (consent === 'unreadable') fs.mkdirSync(path.join(state, 'config.yaml'));+ if (consent === 'legacy-disabled') {+ fs.writeFileSync(path.join(state, 'config.yaml'), 'codex_reviews: enabled\n');+ fs.writeFileSync(path.join(legacy, 'config.yaml'), 'codex_reviews: disabled\n');+ }+ const log = `printf '%s\\n' "$(basename "$0") $*" >> '${launches}'`;+ fs.writeFileSync(path.join(stubs, 'codex'), `#!/usr/bin/env bash\n${log}\ncat >/dev/null\necho 'stub codex review'\n`, { mode: 0o755 });+ fs.writeFileSync(path.join(stubs, 'claude'), `#!/usr/bin/env bash\n${log}\ncat >/dev/null\necho '{"type":"result","subtype":"success","is_error":false,"result":"stub"}'\n`, { mode: 0o755 });+ const env: Record<string, string> = {};+ for (const [k, v] of Object.entries(process.env)) if (v !== undefined && !/^(OPENAI|ANTHROPIC|CODEX)_|^GSTACK_(STATE_ROOT|HOME|STATE_DIR|OUTSIDE_RUNNER)$/.test(k)) env[k] = v;+ Object.assign(env, {+ PATH: `${stubs}:${path.dirname(process.execPath)}:/usr/bin:/bin`,+ HOME: dir, GSTACK_HOME: state, GSTACK_TEST_LEGACY_ROOT: legacy, CODEX_HOME: path.join(dir, '.codex'),+ GSTACK_CLAUDE_BIN: path.join(stubs, 'claude'),+ });+ fs.mkdirSync(env.CODEX_HOME!, { recursive: true });+ const count = () => (fs.existsSync(launches) ? fs.readFileSync(launches, 'utf8').split('\n').filter(Boolean).length : 0);+ return { dir, state, env, count };+}++const sh = (args: string[], env: Record<string, string>, input = '') =>+ spawnSync(args[0]!, args.slice(1), { cwd: ROOT, env, input, encoding: 'utf8', timeout: 60_000 });++describe('stored consent read: gstack-config get --stored and its TS twin agree', () => {+ const expected: Record<Consent, { stdout: string; code: number; ts: string }> = {+ unset: { stdout: 'unset', code: 0, ts: 'unset' },+ enabled: { stdout: 'enabled', code: 0, ts: 'enabled' },+ disabled: { stdout: 'disabled', code: 0, ts: 'disabled' },+ unreadable: { stdout: 'unreadable', code: 2, ts: 'unreadable' },+ garbage: { stdout: 'unreadable', code: 2, ts: 'unreadable' },+ 'legacy-disabled': { stdout: 'disabled', code: 0, ts: 'disabled' },+ };+ for (const [consent, want] of Object.entries(expected) as Array<[Consent, typeof expected[Consent]]>) {+ test(consent, () => {+ const f = fixture(consent);+ const r = sh([path.join(BIN, 'gstack-config'), 'get', '--stored', 'codex_reviews'], f.env);+ expect([r.stdout, r.status]).toEqual([want.stdout, want.code]);+ if (want.code === 2) expect(r.stderr).toContain('troubleshooting.md#outside-review-consent-missing');+ expect(readStoredCodexReviews(f.env).value).toBe(want.ts as never);+ const plain = sh([path.join(BIN, 'gstack-config'), 'get', 'codex_reviews'], f.env);+ if (consent === 'unset' || consent === 'unreadable') expect(plain.stdout).toBe('enabled');+ });+ }++ test('the TS decision allows enabled and unset, refuses the rest, and a user-invoked review always runs', () => {+ for (const consent of ['unset', 'enabled'] as const) expect(outsideConsent({ userInvoked: false, env: fixture(consent).env }).allowed).toBe(true);+ for (const consent of ['disabled', 'unreadable', 'garbage', 'legacy-disabled'] as const) {+ const decision = outsideConsent({ userInvoked: false, env: fixture(consent).env });+ expect(decision.allowed).toBe(false);+ if (!decision.allowed) expect(decision.lines[1]).toBe(CONSENT_MARKER);+ expect(outsideConsent({ userInvoked: true, env: fixture(consent).env })).toEqual({ allowed: true, source: 'user-invoked' });+ }+ });++ test('consent_missing is a not_run gate outcome whose fix names the enable command', () => {+ expect(GATE_OUTCOMES.consent_missing.state).toBe('not_run');+ expect(GATE_OUTCOMES.consent_missing.fix).toContain('gstack-config set codex_reviews enabled');+ });+});++describe('gstack-codex-probe run-with-timeout', () => {+ const probe = path.join(BIN, 'gstack-codex-probe');+ for (const consent of ['disabled', 'unreadable', 'garbage', 'legacy-disabled'] as const) {+ test(`${consent}: exit 3, the gate line and marker, zero codex launches`, () => {+ const f = fixture(consent);+ const r = sh(['bash', probe, 'run-with-timeout', '30', 'codex', 'exec', '-'], f.env, 'repository content');+ expect(r.status).toBe(3);+ expect(f.count()).toBe(0);+ expect(r.stderr).toContain(CONSENT_MARKER);+ if (consent === 'disabled') expect(r.stderr.split('\n')[0]).toBe(gateOutcomeLine('outside review', 'consent_missing', 'codex_reviews=disabled'));+ else expect(r.stderr.split('\n')[0]).toMatch(/^outside review: not run \(.+\)\. Fix: gstack-config set codex_reviews enabled/);+ });+ }++ for (const consent of ['enabled', 'unset'] as const) {+ test(`${consent}: exactly one codex launch`, () => {+ const f = fixture(consent);+ const r = sh(['bash', probe, 'run-with-timeout', '30', 'codex', 'exec', '-'], f.env, 'repository content');+ expect([r.status, r.stdout, f.count()]).toEqual([0, 'stub codex review\n', 1]);+ if (consent === 'unset') expect(r.stderr).toContain('NOTICE: gstack outside reviews send the review prompt and code to Codex');+ });+ }++ test('--user-invoked (/codex) runs with codex_reviews disabled', () => {+ const f = fixture('disabled');+ const r = sh(['bash', probe, 'run-with-timeout', '--user-invoked', '30', 'codex', 'review'], f.env);+ expect([r.status, f.count()]).toEqual([0, 1]);+ });+});++describe('gstack-claude-code', () => {+ const runner = path.join(BIN, 'gstack-claude-code');+ const args = (dir: string) => [process.execPath, runner, '--cwd', dir, '--access', 'none', '--timeout-ms', '30000'];+ for (const consent of ['disabled', 'unreadable'] as const) {+ test(`${consent}: exit 3, a not_run JSON result, zero claude launches`, () => {+ const f = fixture(consent);+ const r = sh(args(f.dir), f.env, 'repository content');+ expect(r.status).toBe(3);+ expect(JSON.parse(r.stdout)).toMatchObject({ status: 'not_run', reason: 'consent_missing' });+ expect(r.stderr).toContain(CONSENT_MARKER);+ expect(f.count()).toBe(0);+ });+ }+ test('enabled: one claude launch; --user-invoked: one launch even when disabled', () => {+ const allowed = fixture('enabled');+ sh(args(allowed.dir), allowed.env, 'repository content');+ expect(allowed.count()).toBe(1);+ const asked = fixture('disabled');+ sh([...args(asked.dir), '--user-invoked'], asked.env, 'repository content');+ expect(asked.count()).toBe(1);+ });+});++describe('API sends: gstack-outside-voice and the unattended runner', () => {+ let server: ReturnType<typeof Bun.serve>;+ let requests = 0;+ const REVIEW = '[P2] A finding.\n\nRecommendation: revise because the premise is unmeasured.\n';+ beforeAll(() => {+ server = Bun.serve({ port: 0, fetch() { requests++; return Response.json({ model: 'gpt-6-astra', choices: [{ message: { content: REVIEW } }], usage: {} }); } });+ });+ afterAll(() => server.stop(true));++ async function outsideVoice(f: ReturnType<typeof fixture>, prompt: string, out: string) {+ const env = { ...f.env, OPENAI_API_KEY: 'sk-test', OPENAI_BASE_URL: `http://127.0.0.1:${server.port}/v1` };+ const proc = Bun.spawn([process.execPath, path.join(BIN, 'gstack-outside-voice'), 'run', '--runner', 'api', '--prompt', prompt, '--out', out, '--model', 'openai/gpt-6-astra'], { cwd: ROOT, env, stdout: 'pipe', stderr: 'pipe' });+ const timer = setTimeout(() => proc.kill('SIGKILL'), 60_000);+ const [status, stdout, stderr] = await Promise.all([proc.exited, new Response(proc.stdout).text(), new Response(proc.stderr).text()]);+ clearTimeout(timer);+ return { status, stdout, stderr };+ }++ test('gstack-outside-voice: disabled or unreadable makes zero API requests (exit 3); enabled makes one', async () => {+ for (const consent of ['disabled', 'unreadable'] as const) {+ const f = fixture(consent);+ fs.writeFileSync(path.join(f.dir, 'prompt.md'), 'repository content');+ const before = requests;+ const r = await outsideVoice(f, path.join(f.dir, 'prompt.md'), path.join(f.dir, 'out.md'));+ expect([r.status, requests - before]).toEqual([3, 0]);+ expect(r.stdout).toContain('OUTSIDE_STATUS: not_run reason=consent_missing provider=api');+ expect(JSON.parse(fs.readFileSync(path.join(f.dir, 'out.md.meta.json'), 'utf8'))).toMatchObject({ status: 'not_run', reason: 'consent_missing' });+ }+ const f = fixture('enabled');+ fs.writeFileSync(path.join(f.dir, 'prompt.md'), 'repository content');+ const before = requests;+ const r = await outsideVoice(f, path.join(f.dir, 'prompt.md'), path.join(f.dir, 'out.md'));+ expect([r.status, requests - before], r.stderr).toEqual([0, 1]);+ });++ const SESSION_KIND = ['GSTACK', 'SESSION', 'KIND'].join('_');+ function initRun(f: ReturnType<typeof fixture>) {+ const plan = path.join(f.dir, 'plan.md');+ fs.writeFileSync(plan, SMALL_PLAN);+ const out = path.join(f.dir, 'run');+ const r = spawnSync(process.execPath, [path.join(BIN, 'gstack-autoplan'), 'next', '--out', out, '--plan', plan, '--no-ui'],+ { cwd: ROOT, env: { ...f.env, [SESSION_KIND]: 'un' + 'attended', GSTACK_EPHEMERAL: '1' }, encoding: 'utf8', timeout: 120_000 });+ return { r, out, run: () => JSON.parse(fs.readFileSync(path.join(out, 'run.json'), 'utf8')) };+ }++ test('unattended runner: disabled records a terminal not_run consent_missing outcome per phase and dispatches no outside voice', async () => {+ for (const consent of ['disabled', 'unreadable'] as const) {+ const f = fixture(consent);+ const before = requests;+ const { r, run } = initRun(f);+ expect(r.status, r.stderr).toBe(0);+ expect(r.stdout).not.toContain('voice=outside');+ expect(r.stdout).toContain('OUTSIDE: ceo not_run reason=consent_missing');+ const state = run();+ expect(state.outside_enabled).toBe(false);+ expect(state.phases.ceo.outside).toMatchObject({ status: 'disabled', outcome: 'not_run', reason: 'consent_missing' });+ expect(state.phases.ceo.native.status).toBe('running');+ expect([f.count(), requests - before]).toEqual([0, 0]);+ }+ });++ test('unattended runner: allowed dispatches the outside voice, and its send makes one API request', async () => {+ const f = fixture('unset');+ const { r, out, run } = initRun(f);+ expect(r.status, r.stderr).toBe(0);+ expect(r.stdout).toContain('voice=outside');+ expect(run().phases.ceo.outside.status).toBe('running');+ const before = requests;+ 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]);+ });+});diff --git a/test/outside-send-boundary.test.ts b/test/outside-send-boundary.test.tsnew file mode 100644index 000000000..2c566a6a6--- /dev/null+++ b/test/outside-send-boundary.test.ts@@ -0,0 +1,83 @@+/**+ * #3102 / D5: consent is enforced by the binaries that send, so no generated+ * skill may start an outside CLI any other way. In every rendered bash fence+ * (Claude and Codex hosts), `codex exec|review` at a command position must run+ * behind `"$_CODEX_PROBE" run-with-timeout`, and the Claude CLI is never run+ * directly: Claude Code reviews go through bin/gstack-claude-code. Prose and+ * quoted strings are ignored; only command positions count.+ */+import { afterAll, describe, expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import * as fs from 'node:fs';+import * as os from 'node:os';+import * as path from 'node:path';++const ROOT = path.resolve(import.meta.dir, '..');+const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'outside-send-boundary-'));+afterAll(() => fs.rmSync(TMP, { recursive: true, force: true }));++const POSITION = String.raw`(?:^|[;&|]\s*|\$\(\s*|\b(?:then|do|else|if|!)\s+)`;+const CODEX = new RegExp(`${POSITION}(?:g?timeout\\s+\\S+\\s+)?((?:"\\$_CODEX_PROBE"\\s+run-with-timeout\\s+(?:--user-invoked\\s+)?(?:--effort\\s+\\w+\\s+)?\\d+\\s+)?)codex\\s+(?:exec|review)\\b`);+/** A headless Claude prompt run (`claude -p`, `--print`, or a prompt on stdin), or the resolved CLAUDE_BIN; `claude mcp|auth|config` manage the CLI and send no repository content. */+const CLAUDE = new RegExp(`${POSITION}(?:command\\s+)?(?:"\\$\\{?CLAUDE_BIN\\}?"|claude(?=\\s)(?![^|;&]*\\s(?:mcp|auth|config|update|doctor)\\b)[^|;&]*(?:\\s(?:-p|--print)\\b|\\s<\\s*\\S))`);++/** Lines in bash fences that start an outside CLI without its consent-enforcing wrapper. */+function directLaunches(markdown: string): string[] {+ const bad: string[] = [];+ for (const match of markdown.matchAll(/```bash\n([\s\S]*?)```/g)) {+ for (const raw of match[1]!.split('\n')) {+ const line = raw.trim().replace(/'[^']*'/g, "''").replace(/"(?:[^"\\]|\\.)*"/g, m => (m.startsWith('"$') ? m : '""'));+ if (line.startsWith('#')) continue;+ const codex = CODEX.exec(line);+ if (codex && !codex[1]) bad.push(raw.trim());+ if (CLAUDE.test(line)) bad.push(raw.trim());+ }+ }+ return bad;+}++function render(host: string): string[] {+ const out = path.join(TMP, host);+ const r = spawnSync('bun', ['run', 'scripts/gen-skill-docs.ts', '--host', host, '--out-dir', out], { cwd: ROOT, encoding: 'utf8', timeout: 120_000 });+ if (r.status !== 0) throw new Error(`render ${host} failed: ${r.stderr}`);+ const files: string[] = [];+ const walk = (dir: string) => {+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {+ const p = path.join(dir, entry.name);+ if (entry.isDirectory()) walk(p);+ else if (entry.name.endsWith('.md')) files.push(p);+ }+ };+ walk(out);+ return files;+}++describe('generated skills start outside CLIs only through the consent-enforcing binaries', () => {+ for (const host of ['claude', 'codex']) {+ test(`${host}: no direct codex exec/review or Claude CLI launch`, () => {+ const files = render(host);+ expect(files.length).toBeGreaterThan(20);+ const bad = files.flatMap(f => directLaunches(fs.readFileSync(f, 'utf8')).map(l => `${path.relative(TMP, f)}: ${l}`));+ expect(bad).toEqual([]);+ const wrapped = files.filter(f => /run-with-timeout (?:--user-invoked )?(?:--effort \w+ )?\d+ codex|gstack-claude-code/.test(fs.readFileSync(f, 'utf8')));+ expect(wrapped.length).toBeGreaterThan(5);+ });+ }++ test('negative controls: direct launches are flagged, wrapped ones and prose are not', () => {+ const fence = (body: string) => '```bash\n' + body + '\n```';+ expect(directLaunches(fence('codex exec - -C "$_REPO_ROOT" < prompt'))).toHaveLength(1);+ expect(directLaunches(fence('timeout 300 codex review --base main'))).toHaveLength(1);+ expect(directLaunches(fence('OUT=$(codex exec "review this")'))).toHaveLength(1);+ expect(directLaunches(fence('if true; then codex review --base main; fi'))).toHaveLength(1);+ expect(directLaunches(fence('claude -p "review" < prompt'))).toHaveLength(1);+ expect(directLaunches(fence('"$CLAUDE_BIN" -p < prompt'))).toHaveLength(1);+ expect(directLaunches(fence('claude < prompt > out'))).toHaveLength(1);+ expect(directLaunches(fence('claude mcp add --scope user gbrain -- "$GBRAIN_BIN" serve'))).toHaveLength(0);+ expect(directLaunches(fence('"$_CODEX_PROBE" run-with-timeout 540 codex exec - -s read-only'))).toHaveLength(0);+ expect(directLaunches(fence('"$_CODEX_PROBE" run-with-timeout --user-invoked 330 codex review --base main'))).toHaveLength(0);+ expect(directLaunches(fence('"$CLAUDE_RUNNER" --cwd "$_REPO_ROOT" --access none --timeout-ms 600000 < prompt'))).toHaveLength(0);+ expect(directLaunches(fence('echo "run by hand: codex exec - -C $_REPO_ROOT < $PROMPT_FILE" >&2'))).toHaveLength(0);+ expect(directLaunches('Run `codex exec` yourself.\n')).toHaveLength(0);+ });+});diff --git a/test/outside-voice-invocation.test.ts b/test/outside-voice-invocation.test.tsindex 3684ef4c9..2920d2b62 100644--- a/test/outside-voice-invocation.test.ts+++ b/test/outside-voice-invocation.test.ts@@ -465,7 +465,8 @@ echo 'Recommendation: approve because the late answer arrived.'const rendered = outsideVoiceInvocation(ctx, { timeoutMs: requested });const gates = [...rendered.matchAll(/timeout: (\d+)/g)].map(m => Number(m[1]));expect(gates).toEqual([provider + 60000]);- expect(rendered).toContain(host === 'claude' ? `run-with-timeout ${provider / 1000} codex` : `--timeout-ms ${provider}`);+ if (host === 'claude') expect(rendered).toMatch(new RegExp(`run-with-timeout (?:--effort \\w+ )?${provider / 1000} codex`));+ else expect(rendered).toContain(`--timeout-ms ${provider}`);}}});diff --git a/test/outside-voice-preflight.test.ts b/test/outside-voice-preflight.test.tsindex 8b561f62a..0bf7fc93a 100644--- a/test/outside-voice-preflight.test.ts+++ b/test/outside-voice-preflight.test.ts@@ -42,17 +42,17 @@ test('adversarial outside failures retain the required native pass without dupli}});-test('ship design availability is an existing automatic choice, not a new opt-in', () => {+test('ship design-lite honors codex_reviews like every other opt-in caller (#3102)', () => {for (const host of ALL_HOST_CONFIGS) {const ctx: TemplateContext = { host: host.name, skillName: 'ship', tmplPath: 'ship/SKILL.md.tmpl', paths: HOST_PATHS[host.name] };const output = outsideVoicePreflight(ctx, { disabledBehavior: 'opt-in' });- expect(output).toContain('No additional opt-in is needed');- expect(output).toContain('`CODEX_MODE` reports provider availability, not user consent');+ expect(output).not.toContain('No additional opt-in is needed');+ expect(output).not.toContain('_OUTSIDE_CFG=enabled');+ expect(output).toContain('get --stored codex_reviews');+ expect(output).toContain("`CODEX_MODE: disabled` or a send's `consent_missing` line: `codex_reviews` is off or unreadable; do not ask; record `outside_status: disabled`.");const other = outsideVoicePreflight({ ...ctx, skillName: 'review' }, { disabledBehavior: 'opt-in' });- expect(other).not.toContain('No additional opt-in is needed');- expect(other).toContain('_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.');- expect(output.match(/```bash\n([\s\S]*?)\n```/)![1]).toBe(other.match(/```bash\n([\s\S]*?)\n```/)![1].replace(- '_OUTSIDE_CFG=enabled # This caller has its own opt-in/skip control.', '_OUTSIDE_CFG=enabled'));+ expect(other).not.toContain('_OUTSIDE_CFG=enabled');+ expect(output.match(/```bash\n([\s\S]*?)\n```/)![1]).toBe(other.match(/```bash\n([\s\S]*?)\n```/)![1]);}});diff --git a/test/run-in-background-guidance.test.ts b/test/run-in-background-guidance.test.tsindex dc70821da..750f478e6 100644--- a/test/run-in-background-guidance.test.ts+++ b/test/run-in-background-guidance.test.ts@@ -4,7 +4,7 @@ import * as path from 'path';import * as os from 'node:os';import { spawnSync } from 'node:child_process';import { generateCodexPlanReview } from '../scripts/resolvers/outside-voice-steps';-import { CODEX_MODEL_CONFIG_FLAG } from '../scripts/resolvers/constants';+import { CODEX_MODEL_CONFIG_FLAG, CODEX_WEB_SEARCH_FLAG } from '../scripts/resolvers/constants';import { HOST_PATHS, type TemplateContext } from '../scripts/resolvers/types';import { ALL_HOST_CONFIGS } from '../hosts';import { expectMentions, expectTokens } from './helpers/prompt-structure';@@ -263,7 +263,8 @@ describe('outside-voice dispatch contract', () => {expect(answer).toBeGreaterThan(0);expect(apply).toBeGreaterThan(answer);// B1: the sandbox comes from the probe's select-model (read-only unless GSTACK_CODEX_NO_SANDBOX=1).- expect(rendered).toContain(`-s "\${_CODEX_SANDBOX_MODE:?}" ${CODEX_MODEL_CONFIG_FLAG} -c 'model_reasoning_effort="high"'`);+ expect(rendered).toContain(`run-with-timeout --effort high `);+ expect(rendered).toContain(`-s "\${_CODEX_SANDBOX_MODE:?}" ${CODEX_MODEL_CONFIG_FLAG} ${CODEX_WEB_SEARCH_FLAG}`);});test('the generated-carrier exception rejects missing wait, cancellation or result guards', () => {diff --git a/test/skill-validation.test.ts b/test/skill-validation.test.tsindex 06e8f9d08..4f8c73cde 100644--- a/test/skill-validation.test.ts+++ b/test/skill-validation.test.ts@@ -1609,7 +1609,7 @@ describe('Codex skill', () => {expectMentions(content, [['only', 'disabled', 'passes']], 'content');// Review logexpect(content).toContain('adversarial-review');- expect(content).toContain('reasoning_effort="high"');+ expect(content).toContain('run-with-timeout --effort high ');expect(content).toContain('ADVERSARIAL REVIEW SYNTHESIS');// Large diff structured review still gatedexpectMentions(content, [['only', 'structured', 'review']], 'content');@@ -1620,7 +1620,7 @@ describe('Codex skill', () => {const content = readShipUnion();expect(content).toContain('Adversarial review (always-on)');expect(content).toContain('adversarial-review');- expect(content).toContain('reasoning_effort="high"');+ expect(content).toContain('run-with-timeout --effort high ');expect(content).toContain('Investigate and fix');expect(content).toContain('Claude adversarial subagent (always runs)');});diff --git a/test/spec-quality-gate-secret-sink.test.ts b/test/spec-quality-gate-secret-sink.test.tsindex f6150bfd9..011c604ab 100644--- a/test/spec-quality-gate-secret-sink.test.ts+++ b/test/spec-quality-gate-secret-sink.test.ts@@ -123,7 +123,7 @@ for (const host of ['claude', 'codex'] as const) {test('redaction remains ahead of outside preflight and --no-gate only skips scoring', () => {const text = content(host);const scan = text.indexOf('#### Redaction scan — pre-codex');- const preflight = text.indexOf('_OUTSIDE_CFG=enabled', scan);+ const preflight = text.indexOf('_OUTSIDE_CFG=$(', scan);expect(scan).toBeGreaterThan(-1);expect(preflight).toBeGreaterThan(scan);expect(text).toContain('`--no-gate` skips the outside score only; redaction always runs');