Repository navigation
feat(#497): CodexDriver core — subprocess codex exec --json, SDK-typed parser, three-level outcome evaluator - #1062
Merged
admarble merged 4 commits intoSep 15, 2026
Conversation
added 4 commits
September 15, 2026 01:18
…d parser, three-level outcome evaluator Entire-Checkpoint: cd1d5c7b7037
…-codexdriver-core-subprocess-codex-exec-js # Conflicts: # CHANGELOG.md
…-codexdriver-core-subprocess-codex-exec-js # Conflicts: # CHANGELOG.md
… smoke test run in a git repo - toModelUsage summed output_tokens + reasoning_output_tokens, but reasoning is a breakdown of output_tokens (every probe run: output - reasoning equals the visible text). outputTokens now takes output_tokens as-is; the AC-1 assertion drops from 6506 to 3306. - The AC-7 live test spawned in a bare mkdtemp dir, which codex exec refuses (Not inside a trusted directory), so it could never pass. It now git-inits the temp dir (the driver only ever sees worktrees, so it deliberately does not pass --skip-git-repo-check), and re-parses the captured raw stream in place of the former synthetic-line real-stream test. Verified green against codex 0.154.0 with a real key. Claude-Session: https://claude.ai/code/session_01LKP1FKm7sK7PEegt7vWhaJ
10 tasks
admarble
added a commit
that referenced
this pull request
Sep 15, 2026
…off the 5s unit test budget (#1063) Follow-up to the #1062 review, where three unrelated test failures rotated through full-suite runs on main: - doctor.test.ts: two scenario assertions depended on the live npm registry via checkVersionThorough(), so they failed on the day 2.15.1 was published while the branch still said 2.15.0. The module is now partially mocked (importOriginal + a pinned up-to-date result), the same class of fix as #1056's snapshot pin. - tui/load.test.ts: the first loadTui() paid the cold Ink/React import (~5 s under load) inside a test with the unit project's 5 s testTimeout. The import is now warmed in beforeAll (60 s hookTimeout); loadTui() sets/restores NODE_ENV on every call, so the restore behaviour each test guards is unchanged. - version-preflight.docs.test.ts: the one async test did an await import() of the manifest/version-check graph inside its 5 s budget. Hoisted to a static import (precedent: version-preflight.test.ts), paid at collection time. No tolerance was widened; the unit project keeps its 5 s default. Claude-Session: https://claude.ai/code/session_01LKP1FKm7sK7PEegt7vWhaJ Entire-Checkpoint: bd730d3b45a1 Co-authored-by: t <[email protected]>
This was referenced Sep 15, 2026
admarble
added a commit
that referenced
this pull request
Sep 16, 2026
…nexecuted declared evidence (#1065) Section 6h (Declared-Evidence Execution) now reads the PR body's Test plan / Verification section: an unchecked '- [ ]' item naming a backtick-quoted command is handled like a declared-evidence AC that was not run — execute it if the environment can, otherwise list it as Executed? No and emit a 6j test_gap with pause_for_human naming what the human must supply. Motivating case: PR #1062's one unchecked box ('CODEX_LIVE=1 npx vitest run ...codex.live...', annotated 'not run here; reports SKIPPED') hid a test that could not pass in any environment (non-git temp cwd the CLI refuses). QA marked the AC MET from the box's own wording; the owner's second look with a real binary found it. Mirrored to templates/skills and skills/ via check-skill-sync --fix; skill-gates, skill-calls, skill-sync, constitution-dod lints clean. Claude-Session: https://claude.ai/code/session_01LKP1FKm7sK7PEegt7vWhaJ Entire-Checkpoint: a36c796c63ec Co-authored-by: t <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CodexDriver(src/lib/workflow/drivers/codex.ts): spawnscodex exec --json -C <cwd> -s workspace-write --dangerously-bypass-hook-trust [-m <model>] <prompt>as a subprocess and parses its JSONL stream, followingOpencodeDriver'sbuildXArgs/XStreamParser/evaluateXRunsplit.CodexSettingsonRunSettings.codex(+ zod schema, validator,KNOWN_KEYS, settings-reference docs),codexSettingsonExecutionConfig,buildExecutionConfig, theDRIVERSregistry, and all threegetDrivercall sites inphase-executor.ts.@openai/codex-sdkas a devDependency used for types only —import typeat every site, and nothing referencing it survives intodist/.Deliberately not the SDK's
Codex/Threadclasses:--dangerously-bypass-hook-trustis CLI-only,Thread._execis private (nostderrTail/exitCode), and the SDK pins the binary version exactly.AC verification
codex.test.ts -t "497 AC-1"— 15 passed. Assertsagent_message.text→output,thread.started.thread_id→resumeHandle.token, all fiveusagecounters →modelUsage, and that the threeitem.completed/erroritems do not setsuccess: false-t "497 AC-2"— 8 passed. Exact argv,stdio: ["ignore","pipe","pipe"],detached: true, unmodifiedconfig.env, abort → SIGTERM on-pid, both RingBuffer tails,exitCode-t "497 AC-3"— 7 passed; all four mutations verified belowresume-semantics.test.ts -t "codex"— 7 passed.canResumefalse across cwd and across driver; resume args areexec resume <token> --json …with no-Cdrivers/index.test.ts -t "497"— 3 passed;node dist/bin/cli.js run 1 --agent codex --dry-runprintsDriver: codexthree times with no spawn-t "497 AC-6"— 2 passed. Hook-trust banner and model-metadata notice reachconfig.onStderr; run still succeedscodex.live.integration.test.ts— gate test passes, 2 live tests reported skipped (never passed). Mirrorsopencode.live.integration.test.ts'sskipReason()/it.skipIfshape, as the AC's own assumption requiresgrep -r "codex-sdk" dist/ | wc -l→ 0 afternpm run build; devDependencies-only asserted in-suiteexecution-config-parity.test.ts— 16 passed, incl. a newcodex-configured scenario and an explicitcodexSettingsequality assertion across both producers-t "497 AC-10"— 7 passed.CODEX_MIN_VERSION = "0.154.0"exported;isAvailable()parsescodex --version;getCodexVersionError()names the floorreasoning_output_tokensexplicitly mappedoutputTokens(3306 + 3200) with a comment stating the choice —toModelUsageincodex.ts.agents/skillscaveat documentedresolvesSkillsdoc commentMutation verification (AC-3)
Each mutation was applied to
codex.tsfrom a verified-clean tree (git status --short | wc -l= 0), run againstcodex.test.ts, then reverted withgit checkout.Mutation-verified: AC-3 — deleted the
turn.failedfatal branch fromevaluateCodexRun;codex.test.ts > 497 AC-3(a) turn.failed is fatal even on a clean exitfailed (1 failed / 35 passed); restored.Mutation-verified: AC-3 — deleted the top-level error-event fatal branch from
evaluateCodexRun;codex.test.ts > 497 AC-3(b) a top-level error event is fatalfailed (1 failed / 35 passed); restored.Mutation-verified: AC-3 — deleted the
noTerminalTurnbranch, leaving only the generic non-zero-exit path;codex.test.ts > 497 AC-3(c) exit != 0 with no turn.completed fails with a distinct codefailed (1 failed / 35 passed); restored.Mutation-verified: AC-3 — reclassified non-fatal
erroritems as fatal stream errors in the parser;codex.test.ts > 497 AC-3(d) an added item.completed/error alone is still a successfailed (7 failed / 29 passed — the fixture contains three such items, so every test depending on it failing-closed also went red); restored.Design notes worth a reviewer's attention
Four deliberate divergences from
OpencodeDriver, each documented incodex.ts's header:--dangerously-bypass-hook-trustis the enablement mechanism.config.envforwarded unmodified. NoXDG_CONFIG_HOMEredirect; inventing one would breakcodex login's stored credentials.turn.completedis not fatal. opencode treats the analogous case as failure (spike(opencode): doesopencode run --command <phase>load the sequant skill? (#862 P0 precondition, resolves OQ-8/OQ-9) #992); AC-3 scopes the codex equivalent to exit≠0, and failing the exit-0 case would reject runs no evidence says are broken.isAvailable()enforces the version floor, which opencode/aider leave todoctor. AC-10 asks for it explicitly. Nothing on the execution path callsisAvailable()today, so it is inert until a caller opts in.Two more:
modelUsagekey. codex reportsusageper turn and never names the model, so the map is keyed bysettings.model, falling back to"codex-default"when unpinned rather than silently merging into another backend's totals.tsccopies comments intodist/verbatim, so the package name appears only in the (erased)import typeand inpackage.json— never in prose. Spelling it out in a comment turns the AC's grep permanently red and stops it meaning "no runtime import survived".codex.tssays so explicitly, to stop a future edit from reintroducing it.Incidental fix
run.codexwas rejected by the settings key allowlist (⚠ Unknown key 'run.codex' in settings.json (ignored)on every run), which would have made the AC-5 interface a dead setting. Registered inKNOWN_KEYSand documented in the settings reference alongsiderun.aider/run.opencode.Known gaps
.agents/skillssymlink is not created by this PR.resolvesSkills = true, so the feat(run): pre-flight the skills install — missing .claude/skills/ should fail fast, not flail for 30 minutes as a spec retry #813/fix(run): skills preflight validates the main checkout, not the worktrees agents run in (#813 follow-up) #933 skills preflight will look for that tree in each phase's worktree and fail closed untilsequant init --agent codexlands (node 2, an explicit non-goal here). The preflight fails loudly, not silently — this is a scaffolding gap, not a bug in the driver.$<phase> <issue>; the defaultpromptTemplatestill says/<phase>. Template changes are outside this node's "pure TypeScript, no init/template changes" scope, so nodriverOverrides.codexwas added./qaactually produces a usable verdict through codex is node 3, the human gate.Test plan
npm run build— cleannpm run lint— clean (0 errors, 0 warnings)e1b867c4in the same worktree with these changes absent —relay-hook.integration.test.ts,prompt-wait.test.ts, andbatch-executor.test.ts > withActivityHook(the last assertswithActivityHookreturns its input unchanged, but it now installsonActivity/onAutoWaitregardless;batch-executor.tsis untouched by this PR)CODEX_LIVE=1 npx vitest run src/lib/workflow/drivers/codex.live.integration.test.ts— 2 passed against codex 0.154.0 with a realCODEX_API_KEY(post-QA; see below)Post-QA fixes (
9eb18cc8, after mergingorigin/mainat v2.15.1)Second-look review with the real binary and key found two defects the phase agents could not have seen without them, plus the §6i gap QA reported:
toModelUsagesummedoutput_tokens + reasoning_output_tokens, but Codex'sreasoning_output_tokensis a breakdown ofoutput_tokens(Responses-API shape). Every probe run shows it —output − reasoningequals the visible text (fixture: 3306 − 3200 = 106 tokens for 165 chars; a barePONGreply reports 6/0).outputTokensnow takesoutput_tokensas-is; the AC-1 assertion drops from 6506 to 3306. The original AC-11 comment's "3200 of 6506" was citing a number produced by the bug.mkdtempdir andcodex execrefuses a non-git cwd (Not inside a trusted directory and --skip-git-repo-check was not specified, exit 1, zero events). The test nowgit inits the temp dir — the driver deliberately does not pass--skip-git-repo-check, since sequant only ever hands it a worktree. The former "parses a real stream" test fed a synthetic line; it is replaced by re-parsing the captured raw stream of the live run and asserting it agrees with the driver's result.test_not_in_diff.failedTestlacked the file prefix the gate keys on; all four now readcodex.test.ts > 497 AC-3(x) …and classifyvalid.Also verified on the merged branch:
npm run lintclean,npm run buildclean,grep -r codex-sdk dist/→ 0,run 1 --agent codex --dry-run→Driver: codex×3. Full suite: 6398 passed; the 2 remaining failures (version-preflight.docs,tui/load) are ~5 s load-timeouts that pass 2/2 when run targeted, and the earlierdoctorpair was the v2.15.0→2.15.1 version-drift artifact, gone after the merge.Closes #1058
🤖 Generated with Claude Code