Repository navigation
Description
Epic: #497 Blocked by: #1058 Tier: mechanical Doc: docs/investigations/codex-driver-probe-2026-09.md §AC-2, §AC-4, "What changes in #497" Graph node: 2 of 3
Summary
Everything a downstream project needs on disk for the Codex driver to find sequant's skills and run sequant's guard hooks. No new hook scripts — the probe showed Codex's PreToolUse stdin payload is a superset of Claude Code's (tool_name: "Bash", tool_input.command, cwd, session_id), so the existing .claude/hooks/*.sh are wired behind a Codex config wrapper.
Design constraints (from the probe)
- Skills: a relative in-repo symlink
.agents/skills -> ../.claude/skills. All 19 skills are discovered under bare names this way; an absolute symlink into another checkout gets namespaced<repo-dir>:<name>and breaks$<phase>invocation (doc §AC-2). - Hooks:
.codex/config.tomlwith[[hooks.PreToolUse]]/[[hooks.PostToolUse]]entries whosecommandpoints at the existing scripts. Project-layer hooks only load when the project is trusted ([projects."<abs path>"] trust_level = "trusted"in the user config) — init must say so, since an untrusted repo's hooks are skipped with zero output. - Sync: the symlink must survive
sequant update/sync(copy-mode currently leaves foreign symlinks alone but must not delete or dereference this one).
Acceptance criteria
- AC-1: symlink — Verify:
sequant init --agent codexin a temp git repo creates.agents/skillsas a symlink whose target reads exactly../.claude/skills(readlink .agents/skills); re-running is idempotent (no error, no change). - AC-2: hooks wrapper from one template — Verify: init writes
.codex/config.tomlcontainingPreToolUseandPostToolUsecommand hooks pointing at.claude/hooks/pre-tool.sh/post-tool.sh;grep -rl 'hooks.PreToolUse' src templates | wc -l→ the template lives in exactly one place;.claude/hooks/*.shunchanged (git diff --stat -- .claude/hooks templates/hooksempty). - AC-3: payload compatibility (gate test) — Verify:
npx vitest run -t "497 AC-3": feeding the recorded Codex PreToolUse payload from the doc §AC-4 (withtool_input.commandswapped togit push --force) topre-tool.shexits 2; withecho okexits 0. Mutation-verified per the repo rule. - AC-4: doctor — Verify:
npx vitest run src/commands/doctor.test.ts -t "codex": withrun.agent: "codex"doctor checks the binary, theCODEX_MIN_VERSIONfloor, and auth (CODEX_API_KEYset orcodex login statusreports logged in), failing with an install/login hint otherwise. - AC-5: trust notice — Verify: init's completion output and the README section both state the
trust_level = "trusted"requirement with the exact TOML;-t "497 AC-5"asserts the string in init output. - AC-6: sync preserves the symlink — Verify:
-t "497 AC-6": aftersequant update(copy and symlink modes) in the temp repo,readlink .agents/skillsstill reads../.claude/skillsand.agents/skills/qa/SKILL.mdresolves. - AC-7: README — Verify: the multi-agent section gains a Codex subsection covering install,
CODEX_API_KEYvscodex login, the symlink, trust, and why the driver passes--dangerously-bypass-hook-trust(sequant generates the hooks it vets); content check, not file-existence. - AC-8:
--agent codexend-to-end dry run — Verify: in the temp repo after init,node dist/bin/cli.js run 1 --agent codex --dry-runresolves the driver and prints the$spec 1prompt.
Non-goals
Codex MCP config ([mcp_servers] pointing at sequant serve) and .codex/agents subagent definitions — wait for the gate. Windows symlink semantics — note as a limitation, do not solve.
Related
#497 (epic) · #1058 (driver core) · #990/#991 (sync clobbering, foreign symlinks) · #1057 (probe doc)
Activity
admarble commentedon Sep 15, 2026
Context for the phase agents (graph-run, 2026-09-15)
Repo state since this issue was written — #1058 merged as bf35818 (PR #1062):
CODEX_MIN_VERSION("0.154.0") and the version-floor check already live insrc/lib/workflow/drivers/codex.ts— import them for AC-4, do not redefine. The driver already passes--dangerously-bypass-hook-trust(AC-7 README explains why; see the header comment incodex.ts).src/commands/init.ts(writeOpencodeCommands/writeOpencodeAgents, one template undertemplates/opencode/) andsrc/commands/doctor.ts(OPENCODE_MIN_VERSIONimport, opencode checks). Codex should follow the same shape: one template undertemplates/codex/, a writer in init, a doctor block keyed onrun.agent: "codex".bin/cli.ts--agent <name>help text oninitlists(claude-code, aider, opencode)— addcodexthere too.docs/investigations/codex-driver-probe-2026-09.md§AC-4 as a fixture; swap onlytool_input.command.Hard constraints (from the probe — do not re-derive)
.agents/skills -> ../.claude/skills. An absolute target into another checkout namespaces skills as<repo-dir>:<name>.[projects."<abs path>"] trust_level = "trusted"); untrusted = silently skipped. That's why AC-5 exists..claude/hooks/*.shandtemplates/hooks/*.shmust be unchanged (AC-2)..env; nothing in this issue should need a liveCODEX_API_KEY— keep tests hermetic.Execution rules (MCP 30-min phase wall)
chore(#1059): wip checkpointroughly every 10 minutes of exec work.timeout, after a WIP commit. Norun_in_background/Monitor.497 AC-3test fails, restore) and put theMutation-verified: AC-3 — …record plus the<!-- SEQUANT_MUTATION: … -->anchor in the PR body.npm run buildin the worktree beforenode dist/bin/cli.js.node_modulesand the Node version (≥22.13) before trusting the failures.admarble commentedon Sep 15, 2026
/spec Plan — #1059
Complexity: Standard (8 ACs)
AC Checklist + Verification
.agents/skillsrelative symlink to../.claude/skills, idempotent re-run..codex/config.tomlhooks wrapper from one template;.claude/hooks/*.shunchanged.pre-tool.sh— force-push blocked, benign command passes.CODEX_MIN_VERSION(imported, not redefined), and auth.trust_level = "trusted"TOML.sequant updatepreserves the symlink in both symlink and--no-symlinksmodes.--dangerously-bypass-hook-trustrationale.run 1 --agent codex --dry-runresolves the (already-registered)CodexDriverand prints the spec prompt.Implementation Plan
init.ts):writeCodexProvisioning()— relative symlink +.codex/config.toml, mirroringwriteOpencodeCommands/writeOpencodeAgents. Addtemplates/codex/→nullintemplateDestination()(templates.ts) so sync/diff doesn't flag it as drift.doctor.ts): codex block mirroring the opencode block — binary,CODEX_MIN_VERSIONfloor, auth (env orcodex login status), never logging the key value.README.md): Codex subsection in Prerequisites, alongside Aider/opencode.Key Decisions
.claude/hooks/*.shscripts are reused as-is; Codex's PreToolUse payload is already a superset (per the feat: add OpenAI Codex CLI agent driver #497 probe)..agents/skillssymlink is unconditional — no copy-fallback (a copy would break Codex's skill discovery, not just degrade it); Windows is an explicit non-goal.Verify:command text, not independent deliverables. Keeping this as one issue; quality loop stays enabled given real AC count (8).Open Questions
.agents/skills(exists but not the expected symlink) — recommend warn-and-skip with--forceoverride, matching existingcopyTemplatesprecedent.--no-symlinksshould affect.agents/skills— recommend no; it's unconditional given no valid copy-fallback semantics exist for it.Phases: testgen → exec → qa
Quality Loop: enabled
admarble commentedon Sep 15, 2026
Resume note (graph-run) — the first exec hit the MCP 30-minute phase wall
The worktree was reaped, but the wip-checkpoint discipline worked: three commits survive on
feature/1059-feat-497-sequant-init-agent-codex-agents-skills-sy(dd93559c,f4dc4e77,20ee1ff1) — 710 insertions across init, doctor, the codex config template, README and tests. Start from that branch; do not redo the implementation.Coverage already on the branch: AC-1/AC-2/AC-6 (
src/commands/init.codex.integration.test.ts), AC-3 (__tests__/pre-tool-hook.integration.test.ts), AC-4 (src/commands/doctor.test.ts), AC-5 (src/commands/init.test.ts), AC-7 (README), AC-8 (src/commands/cli.integration.test.ts).What is left:
npm run buildin the worktree, then run the suite once, foreground, undertimeout— after a wip commit.git status --short | wc -lmust be 0 first): break the codex payload handling, confirm exactly the497 AC-3tests fail, restore, and put theMutation-verified: AC-3 — …record plus the<!-- SEQUANT_MUTATION: … -->anchor in the PR body.Keep committing
chore(#1059): wip checkpointevery ~10 minutes — this phase died at the wall once already.fix(#1059): never unlink a real .agents/skills directory under --force
docs(#1059): record codex init provisioning in the changelog
admarble commentedon Sep 15, 2026
QA round 2 — AC_NOT_MET (posted by graph-run; the QA phase itself posted nothing to this issue in either round)
PR #1066. Round 1 blocked on the mutation records; those are fixed and re-verified (AC-1/AC-3/AC-5 markers now classify
validthrough the repo's ownclassifyMutationMarker, with the AC-3 mutation re-done against the codex payload fixture instead of the shared hook). Round 2 blocks on one substantive finding.F1 (blocking) — AC-8: the codex path never emits
$specAC-8 reads "prints the
$spec 1prompt". The codex run emits the Claude-shaped prose prompt (Run the /spec 1 workflow.) fromphase-registry.ts's defaultpromptTemplate; nothing insrc/orbin/ever emits$spec.driverOverridesexists but registersaideronly.This is not notation drift. The founding doc says so in two places — line 13 ("Does explicit
$skillwork in headlesscodex exec? Yes → symlink.agents/skills → ../.claude/skills;resolvesSkills = true") and §"What changes in #497" P0 line 296 ("Prompt is$<phase> <issue>— the skill name, not a rewritten prompt"). If codex is sent/spec 1as prose, the.agents/skillssymlink this issue exists to create is never exercised.The AC-8 test at
src/commands/cli.integration.test.ts:378asserts"/spec 1"and adds a--verboseflag the AC's command does not carry — written to the implementation's output rather than the AC's text, which turned a product question into a green checkbox.Note the same doc line rules out the obvious fix shape: "Drop
CODEX_PHASE_PROMPTS/driverOverrides.codex" — so copying the aiderdriverOverridespattern across all eight phases contradicts the design the probe settled on. The prompt should come from the driver, not from per-phase overrides. This is a design call, so it is parked here for a human decision rather than patched.F4 (documented) — doctor runs zero codex checks after the documented setup path
initnever persistsrun.agent, so aftersequant init --agent codextherun.agentkey is unset anddoctoremits neither thecodex CLInor thecodex authcheck. The README this PR adds states "sequant doctorchecks for either" — true only if the user hand-edits.sequant/settings.json. Pre-existing pattern shared with--agent opencode, so not a regression, but this PR's README makes it newly user-visible.Also documented, not fixed
grep -rl 'hooks.PreToolUse' src templates | wc -l) now returns 3, not 1 — the extra hits are a JSDoc comment describing the check and the test asserting it. The substantive requirement (one real TOML template) holds and the test filters to/templates/first.-t "497 AC-6") runs feat(#497): CodexDriver core — subprocess codex exec --json, SDK-typed parser, three-level outcome evaluator #1058's tests, not this issue's, which are named1059 AC-6. The AC's own command proves nothing about symlink preservation; the correct command isnpx vitest run src/commands/init.codex.integration.test.ts.templates/codex/null-routing has no directtemplateDestinationtest.getCodexVersion/isCodexAuthenticatedcallexecSyncwith no timeout (mirrors the pre-existinggetOpencodeVersion).Verified green
Full suite re-run in the worktree after the fixes: 317 files, 6424 passed, 0 failed, 1 expected fail, 3 skipped. Lint, build and tsc clean.
fix(#1059): send codex the $<skill> invocation and persist run.agent …
fix(#1059): keep the skill-prompt lookup settings-aware and non-throwing
admarble commentedon Sep 16, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/1 met
Gaps:
createSymlink's return value is discarded —src/commands/init.ts.createSymlink(src/lib/fs.ts:101) returnsfalseonEPERM/EACCESinstead of throwing, signalling "caller should fall back to copy".writeCodexSkillsSymlinkcallsawait createSymlink(...)and unconditionallyreturn "created". Its sibling consumercopyTemplates(src/lib/templates.ts:546) does check the boolean (const symlinkCreated = await createSymlink(...)). On Windows without privileges, init would print✔ Symlinked .agents/skills -> ../.claude/skillswith no symlink on disk, and codex skill discovery would silently fail. This is the same "claims work it had not done" defect the PR already fixed for the idempotent-re-run path; the EPERM branch is the missed sibling. The status union has no failure variant to express it.writeCodexSkillsSymlink's JSDoc. Checking the boolean and warning is not "solving Windows symlink semantics" — it is declining to report success that did not happen.createDefaultSettings(agent)(the F4 fix) has no automated test.init.test.tsmockscreateDefaultSettings, so nothing asserts thatinitCommandforwardsoptions.agent, and no test coversgenerateSettingsJsonc's new conditional"agent"line. This behavior is load-bearing for the README's claim that doctor checks codex auth. I confirmed it manually (generated settings carried"agent": "codex", and a realdoctorrun consequently emitted both codex checks), so it works — but it is unpinned against regression.src/lib/workflow/phase-executor.ts:1269. The newtryBuildSkillPromptJSDoc was inserted betweenresolveDriverName's existing JSDoc and the new function, soresolveDriverNamenow has no doc comment andtryBuildSkillPromptcarries two stacked blocks, the first describing a different function. Cosmetic, mechanical to fix.Suggestions:
"symlink-unsupported"status toCodexSkillsSymlinkStatus, returned whencreateSymlinkyieldsfalse, and warn with a pointer to the Windows limitation. That satisfies the Non-goal's "note as a limitation" without solving it.createDefaultSettings("codex")writes"agent": "codex", and one assertinginitCommand({agent:"codex"})forwards it (un-mock or spy on the argument).chore(#1059): merge main (#1065) into the codex init branch
fix(#1059): report a refused .agents/skills symlink instead of claimi…
admarble commentedon Sep 16, 2026
QA round 3 — AC_MET_BUT_NOT_A_PLUS (posted by graph-run; the QA phase again posted nothing to this issue)
All eight ACs met. Four quality gaps, all fixed in
f6da00f6, plus one process problem worth recording.Fixed
createSymlink's return value was discarded. It answers EPERM/EACCES (Windows without privileges) withfalserather than throwing — the case its sibling consumercopyTemplateshandles with a copy fallback.writeCodexSkillsSymlinkreturned"created"regardless, so init would print✔ Symlinked .agents/skills -> ../.claude/skillswith no symlink on disk, and codex skill discovery would fail silently. Now a distinct"unsupported"status with a warning naming the cause. No copy fallback here: a copied skill tree goes stale the moment.claude/skillschanges. Mutation-verified.init.test.tsmockscreateDefaultSettings). Now tested: init forwards--agent, andgenerateSettingsJsoncemitsrun.agentonly when set.resolveDriverName's JSDoc had been left attached to the wrong function by the round-2 commit.Process: the QA phase rebased a pushed branch
The run log records
✔ Branch rebased onto origin/main. Main had advanced to #1065, and the rebase rewrote seven already-pushed commits — landing them would have required a force-push, which this repo's hooks block and its convention forbids. Undone: reset to the pushed branch, thengit merge origin/main(35dc1109). Content is identical either way. A QA phase rewriting pushed history is a bug worth filing against sequant.Related: the QA phase has now finished three times on this issue and posted its review to the issue in none of them. The verdict reaches the run log and
.sequant/state.json, but a reader of the issue sees nothing. Worth filing alongside the rebase.Verified by hand, end to end
In a scratch repo, against the built CLI from the worktree:
readlink .agents/skills→../.claude/skills; re-run reportsalready in place(no false "Symlinked" claim)..codex/config.tomlcarries both hook tables pointing at the unmodified guard scripts.init --agent codex,doctoremits both thecodex CLIandcodex authchecks (it emitted neither before the F4 fix).[projects."<path>"] trust_level = "trusted"TOML.sequant update, the symlink still reads../.claude/skillsand.agents/skills/qa/SKILL.mdresolves.run 1 --agent codex --dry-run→Driver: codex/Would execute: $spec 1(and$exec 1for the next phase) — the AC's command verbatim, no--verbose.Full suite: 318 files, 6432 passed, 0 failed, 1 expected fail, 3 skipped. Five mutation records (AC-1, AC-1b, AC-3, AC-5, AC-8) all classify
validthrough the repo's ownclassifyMutationMarker.PR #1066 is ready for a merge decision. Gate #1060 stays parked for a human.
feat(#497): sequant init --agent codex — .agents/skills symlink, .cod…
admarble commentedon Sep 16, 2026
Correction to my round-2 and round-3 notes
I wrote twice above that the QA phase posted nothing to this issue. That was wrong for round 3: it posted a full
## QA Verdict: AC_MET_BUT_NOT_A_PLUScomment at 01:58:42Z, ten minutes before my summary claiming it hadn't. I had checked the thread before that round finished and never re-checked.The accurate behavior, now filed as #1070:
postQaVerdictCommentis gated onresult.success && result.verdict(batch-executor.ts:1758).AC_NOT_METmakes the phase a failure, so rounds 1 and 2 posted nothing, while round 3's passing verdict posted normally. Failing reviews are suppressed; passing ones are not.