Skip to content

Codex now holds /review to its checklist before a session can end (GST-3173) - #4522

Merged
capy-ai[bot] merged 4 commits into
mainfrom
codex-review-contract-hook
Nov 19, 2026
Merged

capy-ai[bot] merged 4 commits into
mainfrom
codex-review-contract-hook

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

On Codex, gstack's /review can no longer end a session with a required step skipped: the end-of-session check reads Codex's own session log and sends the agent back to finish, as it already does on Claude Code.
Why: Codex users got routing and the destructive-command check in #4512, but not the /review checklist, so a review could stop after the diff read with no second-model pass.
To use it: run ./setup again and trust the new hook in Codex (/hooks); turn it off with GSTACK_SKILL_CONTRACTS=off.

What changed
  • Reads Codex session logs. New lib/codex-rollout.ts turns a Codex rollout file into the same events the checklist checker uses for Claude Code transcripts: skill loads (from the skill input or a shell read of skills/gstack-*/SKILL.md), shell commands, and subagent starts. A subagent start counts only when Codex reports an agent id, so a failed spawn is not a second-model pass.
  • Same checklist, one item fewer. On Codex the checklist comes from gstack's own review/SKILL.md. The "selected specialists dispatched" item is skipped there, because Codex has no specialist dispatch. The block message uses Codex wording in a Codex-only branch; Claude Code's message is unchanged and pinned by a test.
  • Stop hook on Codex. hosts/codex/hooks/codex-skill-contract-stop-hook wraps the existing hook. ./setup registers it in ~/.codex/hooks.json with PR 1's registration code, at a 10-second timeout, inert until you trust it. A Codex subagent's own session is never checked. gstack-skill-contract check accepts a Codex rollout too.
  • Docs. docs/skill-routing-and-contracts.md explains contracts on Codex; a changelog fragment is in changelog.d/.
Tests
  • New test/skill-contract-codex.test.ts (24 tests) over six trimmed real Codex 0.170 session logs, including negative controls (failed spawn, ls of a skill path, a subagent's log).
  • test/codex-hooks-setup.test.ts and test/codex-hooks-real-codex.test.ts now expect the Stop group.
  • Live run with real Codex 0.170 through the new hook: blocked on the missing second-model pass, then passed after the agent ran it.
Agent notes

Plan: GST-3173 (parent GST-3162), approved plan items A1, B1, C1, D1, E2, F1. Rebased onto main 944b41e with the controller's grant. Decision trail: reports/GSTA-641-decisions.tsv in the controller drive. /ship receipt follows at the final head.

Open notes (ruled to ship as disclosed notes by the controller, 2026-11-19):

  • A shell line where an earlier command fails before the cat still counts as a skill read, so the hook can block once.
  • Shell lines are split on ; without respecting quotes, so sed -n '1,200p;201q' …/SKILL.md is not seen as a read and the review goes unchecked (fails open).
  • A user turn holding only an image does not end the run, so a re-read in that turn is credited to the earlier review.
  • cat A/SKILL.md || cat B/SKILL.md with the first read failing loads nothing.
  • The SKILL.md path match in read-error lines has no end anchor, so an ls …/SKILL.md.bak error drops a good read.
  • PowerShell's "Cannot find path" is not recognised as a read error (Windows only).
  • Pasted <skill> markup at the start of a user message counts as an injected load.
  • A Codex agent is never treated as still running, so a stop during the adversarial pass blocks instead of deferring.
  • Exit codes are parsed only from exec_command output.
  • Windows setup copies hosts/codex/hooks but not hosts/claude/hooks, so Codex hooks fail open there (shared with the two hooks already on main).

Approvals

Approved: yes (record r-f015602d9cee). The full approval record stays private.
Plan: approved (record r-5204ffdb2560)
Plan check: approved (record r-5204ffdb2560)

Ruled note: hosts/codex/hooks/codex-skill-contract-stop-hook.ts:9:platform at 23490ef ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T12:05:46.316Z: Windows setup copies hosts/codex/hooks but not hosts/claude/hooks, so the shim fails open there; shared with PR 1's shims, fixed in the Codex hooks follow-up (approval a-4d0df93306f8)
Ruled note: lib/codex-rollout.ts:145:correctness at 23490ef ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T12:39:13.937Z: A repeat read of the same skill restarted the run; fixed in 4049329 under the grant, fix-check blocking=0 (approval a-e5bc25bd80a6)
Ruled note: lib/codex-rollout.ts:145:fail-open at 23490ef ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T12:39:14.422Z: The whole-call exit code decided whether a read counted; fixed in 4049329 under the grant, fix-check blocking=0 (approval a-f5bed483b6ef)

{
  "schema_version": 1,
  "pr": 4522,
  "head": "4049329d016720c8dac777cb3a1c5f4af77cffb3",
  "version": "1.101.0.0",
  "base": "main",
  "calls": 29,
  "session_kind": "unattended",
  "run": "ship-20261119T113057-4715a8",
  "head_tree": "d402c00f6fb6684782e6bceea0845d314ba4052e",
  "product_patch_id": "760787c5c33352dbdbc6561a90261491c015dca9",
  "gstack_version": "1.101.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 316,
    "rules": "1afa38a4be3b5eef",
    "base": "f82b6f76f3a148365d369566c76d53947406373c",
    "registry": "f82b6f76f3a148365d369566c76d53947406373c",
    "gate_scan": {
      "tagged": 0,
      "head": "4049329d016720c8dac777cb3a1c5f4af77cffb3"
    },
    "reasons": [
      "runtime=316"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @d402c00f6fb6 (8 checks, current for 4049329d0167)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44520248557/attempts/3",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44520248557/attempts/3",
    "windows-setup-e2e.yml/windows-setup: https://github.com/garrytan/gstack/actions/runs/44518677727/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44518677671/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=d402c00f6fb6 tests=38189 skipped=104 runs=44520248557/3 profiles=ci-reuse/free-tests heads=4049329d0167 verified=2026-11-19T12:33:12.803Z"
  ],
  "review_loop": {
    "passes": 1,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 7,
    "fixed": 2,
    "scope": "frozen",
    "fix_checks": 2,
    "rounds": 3,
    "est_input_tokens": 58834,
    "ledgers_read": 5,
    "dispatches": {
      "specialist-batched": 1
    }
  },
  "ruled_notes": [
    {
      "finding": "hosts/codex/hooks/codex-skill-contract-stop-hook.ts:9:platform",
      "head": "23490ef5bbeaf0640c207f56ab3c104ab883b3c3",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "Windows setup copies hosts/codex/hooks but not hosts/claude/hooks, so the shim fails open there; shared with PR 1's shims, fixed in the Codex hooks follow-up",
      "at": "2026-11-19T12:05:46.316Z",
      "approval": "a-4d0df93306f8"
    },
    {
      "finding": "lib/codex-rollout.ts:145:correctness",
      "head": "23490ef5bbeaf0640c207f56ab3c104ab883b3c3",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "A repeat read of the same skill restarted the run; fixed in 4049329 under the grant, fix-check blocking=0",
      "at": "2026-11-19T12:39:13.937Z",
      "approval": "a-e5bc25bd80a6"
    },
    {
      "finding": "lib/codex-rollout.ts:145:fail-open",
      "head": "23490ef5bbeaf0640c207f56ab3c104ab883b3c3",
      "by": "Captain GStack Minder (GSTA-36)",
      "reason": "The whole-call exit code decided whether a read counted; fixed in 4049329 under the grant, fix-check blocking=0",
      "at": "2026-11-19T12:39:14.422Z",
      "approval": "a-f5bed483b6ef"
    }
  ],
  "gate_dispositions": []
}
{"head":"23490ef5bbeaf0640c207f56ab3c104ab883b3c3","run":"ship2","status":"started","review_loop":{"passes":1,"blocking_found":3,"deferred":0,"noted":4,"fixed":2,"scope":"frozen","fix_checks":1,"rounds":2,"est_input_tokens":58834,"dispatches":{"specialist-batched":1}}}

Open in Capy

…tract checker and Stop hook

The skill-contract checker now reads a Codex rollout as well as a Claude Code
transcript, chosen by the file's content. A load is Codex injecting or the model
reading a gstack-* SKILL.md, a dispatch is a spawn_agent call that started an
agent, and /review's specialists item is skipped on Codex. Fixtures are real
Codex 0.170 rollouts. Claude Code's behaviour is unchanged.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 3 commits November 19, 2026 11:26
…nreadable call arguments no longer count

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ck's own /review checklist

Review-Finding: p1/specialist-batched#1 reader=testing
Review-Finding: p1/specialist-batched#2 reader=testing
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ts the review, and a later failing command no longer hides the read

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit b0f865c into main Nov 19, 2026
124 of 132 checks passed
garrytan added a commit that referenced this pull request Nov 19, 2026
…(GST-3196)

The scan flagged #4522's $gstack-review example. Codex lists the skill as
review, and codex exec '$review ...' injects it as a <skill> message
(codex-cli 0.170 stub probe); only a folder-name mention is plain text.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@garrytan garrytan mentioned this pull request Nov 19, 2026
capy-ai Bot added a commit that referenced this pull request Nov 19, 2026
- `gstack-artifact validate` no longer passes a run.json that gstack-autoplan never wrote. (#4494)
- /ship's changed-number check no longer stops on tests that only share a word with the change (#4478). (#4496)
- On Capy, /ship no longer edits or comments on pull requests as you. (#4518)
- The destructive-command check stops asking about scratch deletes and catches the real damage it used to miss. (#4513)
- The destructive-command check reads commands more carefully, closing gaps found after the last release. (#4525)
- The Codex readiness check and the second-model review now pick the same model for a custom Codex provider (GST-3089). (#4491)
- gstack's Codex hooks work when your Codex folder's path has a `(`, `&` or other shell character in it. (#4528)
- Uninstalling gstack keeps your own Codex hooks trusted. (#4528)
- Codex hook setup matches Codex more closely. (#4528)
- On Windows, setup copies the Claude Code hook code that gstack's Codex hooks import (#4528)
- /review's checklist on Codex reads shell commands more carefully. (#4528)
- On Codex, gstack now suggests the right skill for a prompt and stops destructive commands before they run. (#4512)
- On Codex, /review is now held once when it tries to finish without its adversarial pass or its report, as it already is on Claude Code. (#4522)
- On Codex, gstack's skill suggestion now names the skill the way Codex lists it. (#4523)
- On Codex, gstack's suggested prompts and docs now name skills the way Codex lists them. (#4524)
- /review on Codex with gpt-6.1-sol is no longer held back for a second-model pass it already ran. (#4526)
- On Codex, office-hours, plan-design-review and gstack-upgrade work again when you name them. (#4510)
- gstack knows when Codex is running unattended. (#4510)
- Codex reviewers start with a clean context. (#4510)
- Docs no longer say Codex has no hook support. (#4510)
- A command whose output was cut off no longer counts as a finished read. (#4492)
- A folder marked as published data can no longer hide source code or agent files from /ship's review. (#4516)
- Correction to the on-by-default helper hooks entry: the hook still routes only to /review, /qa and /verify, so skills you've installed yourself aren't suggested yet. With gstack's skills it routes 14 of 60 real bug reports (was 17), and long prompts are no longer skipped. (#4505)
- /sync-gbrain's read check now works when the first page in your code source is over 64 KB. (#4497)
- Free-suite CI no longer fails before any test runs when Ubuntu's package mirror is slow. (#4530)
- Syncing a second repo no longer makes the first one ask for /sync-gbrain again. (#4532)
- gstack's helper hooks are now on by default in Claude Code, OpenClaw and Hermes, and the prompt-routing hook fires on real bug reports. (#4503)
- `gstack-pregate clear --receipt` accepts a remote gate run from before a merged release when the release only regenerated a declared release output. (#4483)
- The second-model review now keeps the reviewer's own result, and reports a used-up budget as a budget stop. (#4515)
- When the reviewer wrote its review to the result file it was asked for, Codex then replaced that file with its short closing message ("Done, I wrote the review"), so the review was thrown away and reported as missing its markers. (#4515)
- When the provider refuses the call with HTTP 402 Payment Required (usually a metering proxy that hit its allowance, or an account out of credits or quota), gstack used to record only "exit 1". (#4515)
- The pre-commit /verify check now fails a check that times out, and its checks share one time budget (GST-3201). (#4527)
- /ship's review collector no longer reads a reviewer's own scope list or list of passed checks as findings (GST-3201). (#4527)
- Merge-queue stack tests fail when git cannot list a PR's added test files (GST-3201). (#4527)
- /ship can now review results PRs that publish raw session data. (#4511)
- /ship's review pass works when the checkout you ship isn't the project's default checkout. (#4507)
- A second review round no longer reports done when nothing was reviewed. (#4520)
- The prompt-routing hook now suggests skills you install yourself, and no longer sends ordinary bug reports to /qa (GST-3123). (#4506)
- gstack's script runner and merge-queue checks now also refuse cut-off output. (#4502)
- A failed second-model review reports the cause that actually stopped it, and the runner never deletes its own prompt. (#4519)
- `gstack-ship-queue ready` now fills in the trial merges and the second-model trail read instead of printing lines to fill. (#4529)
- Five small ship-tool fixes. (#4529)
- A ruling the owner gives while a `/ship` run is open can be relayed. (#4529)
- /ship no longer kills a working test run as stalled when the test command starts its workers in their own session. (#4533)
- /ship no longer stops a review because the state-machine reader started its reply the way its instructions say. (#4504)
- When Claude Code runs /verify right before a commit, it now gets a quick check instead of the full fix loop (GST-3150). (#4508)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant