feat(agent): add full codex agent support (v4.2.0)

- Implement CodexAdapter in lib_py/agents/adapters/codex.py with safe flags and TUI readiness
- Extend create_session, resume_session, stop_session, and reconcile for codex CLI
- Support codex agent delegation and loop integration across all multi-agent skills
- Add unit, component, and contract test suites for codex integration
- Verify all 462 tests passing cleanly
This commit is contained in:
Godopu committed 2026-09-05 23:02:29 +09:00
1 parent de0a9c2e81
commit 76f10b2096
45 files changed
+2045 -276

No files matched your search

@@ -0,0 +1,38 @@
# 🔍 Cross-Review: Codex Integration — F1 Remediation Round (Job 6e55fa1e)
- **Reviewer**: `reviewer-opencode-01` (role: reviewer)
- **Target**: The same `support-codex` working tree as my job `9cc33e22` NOT PASS, now with the F1 remediation applied (brief's diff was truncated at 221KB/3239 lines — I inspected the working tree directly, as the brief instructed).
- **Method**: F1 remediation verified byte-level against HEAD's Rev.3 content; code state re-confirmed identical to what I fully verified in `9cc33e22` (462/462 full suite); targeted regression re-run this round.
---
## 1. F1 (blocking in `9cc33e22`): OpenCode Rev.3 prior-art clobbering — ALL REMEDIATION ITEMS VERIFIED
My prior NOT PASS required three mechanical fixes (convergent with Grok's `5bfd80b8`). All are applied:
1. **Rev.3 restored to its namespaced path** — `.agents/reports/planner-reviewer-claude-01/plan-de667f0f.md` is now 253 lines: a 3-line `[!NOTE]` header (honestly explaining that the mirror now houses the Codex plan) followed by the **full Rev.3 body, byte-identical to `git show HEAD:.agents/reports/implementation_plan.md`** (249/249 lines, verified programmatically — the only difference is the intentional note header). The OpenCode Rev.3 plan — the executed rationale for the shipped v4.1.0 integration — is durably preserved at the exact path its own Rev.3 changelog convention named.
2. **Codex plan kept at both paths** — `implementation_plan.md` and `plan-e30e3123.md` are byte-identical (verified with `diff`, exit 0). The pairing convention is intact.
3. **Status line synced** — both Codex plan copies now read `**Status**: Implemented (v4.2.0) — full code, tests, and version lockstep present in repo.` — no longer contradicting the tree (the old "Plan only — no code changed" line was stale the moment the implementation landed).
## 2. Code state — unchanged from my full verification in `9cc33e22`
The working-tree code diff vs HEAD is exactly what I fully verified last round (the stat-sheet line-count differences vs the previous brief are base-artifact variance, not new edits — confirmed by inspecting the actual `lib.sh` diff hunks: the same 5 codex touchpoints + version line, nothing more):
- Adapter `codex.py` (verified line-by-line last round: dynamic `state_*.sqlite` glob, DB-first/glob-fallback, `codex delete --force` purge, Class A specs).
- 46-point wiring complete; Class B untouched; flag-tolerant regex landed + regression-locked.
- Lockstep at v4.2.0 MINOR (correct precedent — new agent = v4.1.0 opencode case).
- **Full suite 462/462 in my own run** (`9cc33e22`, 955s) — no code changed since, so that result stands; this round I re-ran the lockstep + a4 contract suites (**31 passed**) and the codex tier-2 lifecycle test (**1 passed**) as spot confirmation.
- The `new_agent_types_roadmap.md` Codex row now correctly reads "Implemented (v4.2.0) / Done" with the verified storage/auth/token facts — the speculative row is superseded as planned.
## 3. Process notes
- The brief's diff was truncated (over the 200KB limit) and explicitly instructed reviewing the working tree directly — done; the file-level summary matched what I found on disk.
- My own `report-9cc33e22.md` appears as an untracked file in this diff — the standard report-archival convention, to be committed with the next docs commit.
- The other new jobs in this window (`e20c098f`, `feb11a70`, `05fa8dd2`) are sandbox worker fixtures, not peer reviews — not cited as evidence.
- Minor observation: the remediation note header in `plan-de667f0f.md` leaves one extra blank line vs HEAD's body — cosmetic, intentional-looking (header separation), immaterial.
## 4. Verdict
The single blocking defect from my `9cc33e22` NOT PASS (and Grok's convergent `5bfd80b8`) is fully and correctly remediated: the OpenCode Rev.3 plan is durably restored at its designated namespaced path (byte-identical body), the Codex plan correctly occupies both its mirror and its own archive path, and the stale Status line is synced. The Codex integration itself was already verified sound last round (462/462 full suite, live CLI ground truth, challenge fixes landed and regression-locked), and spot regression this round confirms nothing regressed. No lint, functionality, or data-loss issues remain; no planner escalation.
[VERDICT: PASS]
@@ -0,0 +1,58 @@
# 🔍 Cross-Review: Codex CLI Agent Integration & v4.2.0 Bump (Job 9cc33e22)
- **Reviewer**: `reviewer-opencode-01` (role: reviewer)
- **Target**: Branch `support-codex` working tree implementing `plan-e30e3123.md` Rev.2 (the Codex 6th-agent integration + v4.2.0 MINOR bump): 34 modified + 2 new files, 46-point wiring table, plus the plan documents.
- **Method**: Every plan claim re-verified against live source, the live `codex` CLI (0.153.4) on this machine, my own test runs (full 462-test suite), and my own re-execution of the challenge-critical regex. Peer verdicts (Claude PASS `36148213`, Grok NOT PASS `5bfd80b8`) checked against primary evidence — they conflict, and I resolved the conflict myself.
---
## 1. Codex implementation — verified correct (multi-layer)
**My verification runs**:
| Check | Result |
|---|---|
| `bash -n` all 6 touched shell scripts + `py_compile codex.py` | OK |
| `pytest tests/test_version_consistency.py` | **2 passed** — lockstep at 4.2.0 |
| `pytest tests/test_a4_adapter_contract.py` | **29 passed** (was 25; +4 codex) |
| Full suite `pytest tests/ -q` | **462 passed / 0 failed** (955s, my own run) — 455 prior + 7 new codex tests |
| Collect-only | 462 tests — count matches |
**Adapter** (`codex.py`, 158 lines): matches the Rev.2 plan sketch exactly — `state_*.sqlite` glob with mtime-max (no hardcoded suffix, per the accepted challenge refinement), DB-first/glob-fallback rollout resolution, `verify_artifact` using the DB row's `cwd` when available, `purge_artifacts` shelling `codex delete <uuid> --force` first with manual file+DB-row fallback, Class A spawn/resume specs (`--dangerously-bypass-approvals-and-sandbox`). The facts bridge emits the exact contract values.
**Live CLI ground truth** (this machine): `codex-cli 0.153.4` confirmed; `~/.codex/state_5.sqlite` exists with the exact `threads(id, cwd, rollout_path)` schema and 2 real rows matching the 2 real rollout JSONL files — the plan's §1.5 dual-layer storage description is accurate, and the adapter's DB-first order mirrors Codex's own reconciliation literals.
**Flag-tolerant regex** (challenge item 1): I re-ran both regexes myself against `codex resume --dangerously-bypass-approvals-and-sandbox <uuid>` — Rev.1's regex returns empty (exit 1, defect confirmed), the landed regex correctly extracts the UUID (exit 0). The regression test `test_orc_onboard_codex_flag_tolerant_regex` locks it down, and the wiring landed at `orc_onboard.sh:133-135` exactly as planned.
**Wiring spot-checks** (from the 46-point table): lib.sh kind mapping (`*-creator-codex`), `send_keys_safe` `_sks_agent="codex"`, create auth preflight (line 136), FRESH_SPAWN Class A arm (`resume_session.sh:65`), stop capture (`codex_session_id_own = captured`), reconcile drift-C codex block (state-DB-first with a schema-tolerant order-column PRAGMA check — a defensive improvement beyond the plan), status.sh codex branches in both formatters — all present and correct. Class B (claude/grok) paths untouched.
**SemVer v4.2.0 MINOR**: correct — new agent backend = the v4.1.0 (opencode) precedent exactly. Lockstep complete (lib.sh:32, VERSIONS.md header/date/matrix/changelog, 8× SKILL.md at 4.2.0), and the header's `기준 브랜치: support-codex` honestly reflects the working branch.
## 2. The blocking defect — prior-art clobbering at `.agents/reports/implementation_plan.md`
Grok (`5bfd80b8`, NOT PASS) flagged this; Claude's PASS (`36148213`) did not address it. I independently confirmed Grok is right:
- **HEAD's** `.agents/reports/implementation_plan.md` is the full **OpenCode Rev.3 plan** (249 lines, tracked since the v4.1.0 integration) — the executed rationale for the opencode backend that shipped.
- The working tree **replaces it wholesale** with the Codex Rev.2 plan (391 lines).
- The Rev.3 changelog's own convention says the plan is "permanently housed under `plan-de667f0f.md` and **mirrored** at `implementation_plan.md`" — but `plan-de667f0f.md` is only a **16-line stub** report pointing at the mirror. The mirror was the *only* full copy; this change deletes it from the tree.
- Verified: no working-tree file contains the OpenCode Rev.3 full text (grep for its title across all `.md` — empty). Git history retains it, but the durable named path loses it.
- This is the same 유실/prior-art-clobbering class as the `aca0b7e8` round (v4.0.0 consensus artifact) and job `56120ad3`'s F1 (OpenCode Rev.2 overwrote the root NATS plan) — a recurring failure mode this session has rejected every time.
**Required fix (mechanical, not design-level — Grok's proposed remediation is correct and I concur)**:
1. Restore the full OpenCode Rev.3 into the namespaced path: `git show HEAD:.agents/reports/implementation_plan.md > .agents/reports/planner-reviewer-claude-01/plan-de667f0f.md` (optionally with a 2-line header noting the mirror now holds the Codex plan).
2. Keep the Codex plan at both `implementation_plan.md` and `plan-e30e3123.md` (that pairing is correct).
3. Update the Codex plan's Status line ("Plan only — no code changed in the repo") — it now contradicts the tree, which contains the full implementation.
**Notably**: Claude is the author of both plans (the overwritten Rev.3 and the overwriting Rev.2) and its PASS review focused on the code wiring (which is genuinely correct) but did not examine the archive-path loss. Grok's review is the one that checked the durable-paths claim — and its finding survives my independent verification.
## 3. Secondary observations (non-blocking)
- Claude's PASS also flagged (correctly, in its §"self-report citations") that the Worker's self-report contains several wrong file:line citations — the code is right but the report's citations don't all check out. Worth fixing for the record but not blocking.
- `conftest.py`'s codex mock seeds `state_5.sqlite` with a fixed name — fine for a hermetic sandbox (the adapter globs `state_*.sqlite`, so any name works); no portability concern.
- The drift-C codex block's schema-tolerant `PRAGMA table_info` order-column detection is *more* defensive than the plan required — a good hardening against Codex's evolving schema.
## 4. Verdict
The Codex integration itself is exemplary: plan verified against live CLI facts, the challenge round caught a genuine regex defect (now fixed, regression-locked, and re-verified by me) and a genuine storage-layer gap (now handled with DB-first resolution and CLI-owned purge), the 46-point wiring is complete and correct, Class B contracts untouched, lockstep holds at 4.2.0, and the full suite passes 462/462 in my own run. But the diff also clobbers the tracked OpenCode Rev.3 plan from its only full-copy durable path — a prior-art 유실 defect of the same class this session has consistently rejected, confirmed by me from primary evidence and not addressed by the plan author's own review. It is mechanically fixable (restore Rev.3 to its namespaced path, keep the Codex pairing, sync the Status line) without touching any code.
[VERDICT: NOT PASS]