Skip to content

feat(review): codex branch for one-shot PR review#490

Open
dcellison wants to merge 1 commit into
mainfrom
feat/codex-pr-review-agent
Open

feat(review): codex branch for one-shot PR review#490
dcellison wants to merge 1 commit into
mainfrom
feat/codex-pr-review-agent

Conversation

@dcellison
Copy link
Copy Markdown
Owner

Summary

Phase 4 of #480. Adds the codex branch to run_review so GitHub webhook-driven PR reviews route through codex on a codex-active install, parallel to the codex triage branch that shipped in #483.

  • run_review codex branch: codex exec --json --model <model>; sudo -H -u <user> wrap when claude_user is set so codex reads ~<user>/.codex/auth.json; start_new_session in cross-user mode so timeout kills sweep both sudo and the codex grandchild; CODEX_BIN env honored for installs where codex lives in a per-os_user home not on the service user's PATH.
  • Model resolution goes through get_model_for(ModelRole.PR_REVIEW, "codex", override=os.environ.get("PR_REVIEW_MODEL_CODEX", "")). Registry row was added in feat(config): per-role model registry for multi-backend agent calls #481; codex-row validity is enforced at load_config time by the check shipped in fix(install): codex wizard hardening (#486) #489.
  • New kai.codex_exec module hosts the schema-defensive NDJSON parser (extract_codex_text plus private _recover_agent_message_text). Both triage.py and review.py import from there, so the review path does not reach into the triage module for a generic codex helper.
  • No new config plumbing: the webhook handler already threads per-user agent_backend / provider into review_pr and run_review.

Test plan

  • make test (3145 passed, 1 skipped)
  • make check (ruff check + ruff format)
  • TestRunReviewCodex (11 new tests) mirrors TestRunTriageCodex coverage: argv shape, CODEX_BIN override, registry-vs-env model resolution, no-sudo and sudo-wrap paths, no --max-budget-usd, NDJSON text extraction, non-zero exit raises, timeout-killpg, stdin carries prompt.
  • TestExtractCodexText (11 tests) moved from test_triage.py to test_codex_exec.py.
  • End-to-end smoke: open a real PR on a codex-active install and verify the review comment posts. Deferred to post-merge so the smoke runs against the merged code path the operator will actually use.

Phase 4 of the codex backend epic. Adds the codex branch to run_review
so GitHub webhook-driven PR reviews run through codex on a codex-active
install:

- run_review codex branch invokes `codex exec --json --model <model>`
  with the model from get_model_for(ModelRole.PR_REVIEW, "codex",
  override=os.environ.get("PR_REVIEW_MODEL_CODEX", "")). sudo -H -u wrap
  when claude_user is set so codex reads ~<user>/.codex/auth.json
  instead of the service user's home. start_new_session in cross-user
  mode so a timeout kill collects both sudo and the codex grandchild.
  CODEX_BIN env override honored so installs where codex lives in a
  per-os_user home (not on the service user's PATH) still resolve the
  absolute binary.
- New kai.codex_exec module hosts the schema-defensive NDJSON parser
  (extract_codex_text + private _recover_agent_message_text). Both
  triage.py and review.py import from there so review.py does not
  reach into triage.py for a generic codex helper. Codex re-review
  of #489 made canonical helpers an explicit aesthetic preference.
- Codex re-review of #489 also caught that get_effective_provider
  needed the codex->openai rule; that fix landed in #489. No new
  config plumbing needed here; the webhook handler already threads
  per-user agent_backend / provider into review_pr and run_review.
- Tests: TestRunReviewCodex (11 tests) mirrors TestRunTriageCodex
  argv/sudo/timeout/extraction coverage; TestExtractCodexText moved
  from test_triage.py to test_codex_exec.py (location follows
  implementation).
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.

2 participants