Prevent OAuth browser waits during Codex MCP activation #316

Merged
nimmo merged 2 commits from fix/noninteractive-codex-mcp into main 2026-10-12 07:54:15 +01:00
Owner

Lyra's unattended update timed out after five minutes when codex mcp add cloudflare --url ... started an interactive OAuth login inside Home Manager activation. Vega and Lyra are headless. The retry succeeded because the endpoint had already been written, but the original switch still reported failure.

HTTP MCP activation now writes configuration directly through the existing TOML-preserving helper, without discovery or login. Generic entries whose URL and bearer environment variable match are left entirely untouched, preserving user headers and OAuth settings. Transport mismatches repair stale settings; Redview's custom-header path still reconciles its declarative headers. Authentication is an explicit operator step; README documents an SSH-forwarded callback for headless Codex login.

Refs #315 and #312. Milestone: Cloudflare Agent Tooling. Keep #315 open until deployment evidence is complete.

Validation:

  • Full nix flake check passed after the review fix, including four host evaluations and formatting.
  • Seven helper tests passed, covering offline registration, matching user headers with/without bearer authentication, stale-auth repair, OAuth preservation, invalid-config safety and no-op repeats.
  • Revised Lyra Home Manager activation package built.
  • Exact generated HTTP function passed a disposable Lyra fresh registration and no-op repeat with user-added headers; config contents and mtime unchanged. Home Manager/Paseo remained active. A duplicate-table error in the first canary fixture was corrected before the successful rerun; details are in the discussion.
  • Lyra's Codex CLI recognizes the URL-only/empty-header schema as streamable_http without a discriminator, discovery, or persisted changes.
  • Pre-publication rebase was a no-op. Existing upstream stdenv deprecation warnings were reviewed.

Live test activation is now confirmed: the user completed Lyra's test deploy on 2026-10-12. Read-only checks confirm running configurationRevision 52c0440590 and Home Manager generation bnry5g4k46snlpzx3kvjpkv5hb9gw1j3. Home Manager activation completed 07:36:22–07:36:24 BST with Result=success and ExecMainStatus=0; codexMcpConfig advanced without a browser wait. Home Manager and Paseo are active. A follow-up invocation of the deployed Cloudflare registration function against the real user config preserved both content and mtime; Codex confirmed a valid streamable_http endpoint. This follow-up exercised the registration hook, not a second complete system activation. CI passed for the exact tested head.

The affected-host test canary is satisfied. Remaining before closing #315: persistent deployment evidence and the required full deployment no-op follow-up. No merge has been performed; test deployment should not be represented as persistent switch deployment.

Lyra's unattended update timed out after five minutes when `codex mcp add cloudflare --url ...` started an interactive OAuth login inside Home Manager activation. Vega and Lyra are headless. The retry succeeded because the endpoint had already been written, but the original switch still reported failure. HTTP MCP activation now writes configuration directly through the existing TOML-preserving helper, without discovery or login. Generic entries whose URL and bearer environment variable match are left entirely untouched, preserving user headers and OAuth settings. Transport mismatches repair stale settings; Redview's custom-header path still reconciles its declarative headers. Authentication is an explicit operator step; README documents an SSH-forwarded callback for headless Codex login. Refs #315 and #312. Milestone: Cloudflare Agent Tooling. Keep #315 open until deployment evidence is complete. Validation: - Full nix flake check passed after the review fix, including four host evaluations and formatting. - Seven helper tests passed, covering offline registration, matching user headers with/without bearer authentication, stale-auth repair, OAuth preservation, invalid-config safety and no-op repeats. - Revised Lyra Home Manager activation package built. - Exact generated HTTP function passed a disposable Lyra fresh registration and no-op repeat with user-added headers; config contents and mtime unchanged. Home Manager/Paseo remained active. A duplicate-table error in the first canary fixture was corrected before the successful rerun; details are in the discussion. - Lyra's Codex CLI recognizes the URL-only/empty-header schema as streamable_http without a discriminator, discovery, or persisted changes. - Pre-publication rebase was a no-op. Existing upstream stdenv deprecation warnings were reviewed. Live test activation is now confirmed: the user completed Lyra's test deploy on 2026-10-12. Read-only checks confirm running configurationRevision 52c04405903c1506b023a36b9cecb1797c2bd7f5 and Home Manager generation bnry5g4k46snlpzx3kvjpkv5hb9gw1j3. Home Manager activation completed 07:36:22–07:36:24 BST with Result=success and ExecMainStatus=0; codexMcpConfig advanced without a browser wait. Home Manager and Paseo are active. A follow-up invocation of the deployed Cloudflare registration function against the real user config preserved both content and mtime; Codex confirmed a valid streamable_http endpoint. This follow-up exercised the registration hook, not a second complete system activation. CI passed for the exact tested head. The affected-host test canary is satisfied. Remaining before closing #315: persistent deployment evidence and the required full deployment no-op follow-up. No merge has been performed; test deployment should not be represented as persistent switch deployment.
fix: register Codex HTTP MCP servers without OAuth during activation
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 2m18s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 7m37s
9844b568aa
clankbot left a comment

Automated code review

Reviewed commit: 9844b568aa582a1c77f30a3999bc32cb792aa59b

Verdict: Requires further work

Resolve the blocking or important findings and investigate failed deterministic checks before merging.

Overall assessment

The supplied diff replaces the codex mcp get/codex mcp add round-trip in ensure_http_mcp (modules/profiles/ai-agents.nix:92-100) with a direct call to scripts/ensure-codex-http-mcp.py, adds an optional bearer_token_env_var parameter to that helper, and extends scripts/test-codex-http-mcp.py with two regression tests. Caller signatures were checked: modules/mcp/default.nix:253 emits ensure_http_mcp <name> <url> [tokenEnvVar], matching the unchanged three-argument shell signature, and the pre-existing custom snippet at modules/mcp/redview.nix:47 still passes four arguments, which the defaulted fifth parameter accepts. ${python}/bin/python with pkgs.python3.withPackages (ps: [ ps.tomlkit ]) and the relative path ../../scripts/ensure-codex-http-mcp.py mirror the existing redview pattern, and flake.nix:231-237 already copies both scripts into the redview-mcp check, so the new tests are wired into nix flake check. No evaluation-breaking or secret-leaking defect was identified in the changed code; the open items are the deployment evidence AGENTS.md requires for a multi-host/auto-update change and a behavioural narrowing in which the helper now rewrites header keys unconditionally instead of only on mismatch.

Blocking findings

None.

Important findings

  • Multi-host auto-update change has no recorded NixOS generation or no-op follow-up in the supplied evidence (modules/profiles/ai-agents.nix:99; high confidence)
    The rewritten activation helper at modules/profiles/ai-agents.nix:92-100 is emitted for every enabled HTTP server via modules/mcp/default.nix:253 (ensure_http_mcp), and the README diff itself states the change targets 'unattended updates on headless Vega and Lyra'. AGENTS.md:43 states: 'For multi-host or auto-update changes, record one genuine deployment and a no-op follow-up before closing the issue.' The only executable evidence supplied with the change is the Python regression tests in scripts/test-codex-http-mcp.py, which run the helper against a temp config.toml and never exercise a NixOS activation, the auto-update path, or the generated shell snippet.
    Impact: The failure mode being prevented (an unattended auto-update activation timeout) lives in the activation path that the supplied evidence does not exercise, so a regression in the rewritten shell snippet - a python invocation failure, a wrong store path, or an aborted activation - would first surface at the next unattended update on Vega/Lyra rather than in nix flake check. The repository rule for this class of change is not yet satisfied by anything in the supplied material.
    Suggested fix: Before closing the issue, produce the evidence AGENTS.md:43 requires: create an auto-update hold, run just test on one affected headless host (plus just test-remote if the controller path is in scope), release the hold, then record one genuine switch deployment and a no-op follow-up activation showing ~/.codex/config.toml is left byte-identical and untouched (mtime unchanged) by the rewritten helper.

Suggestions

  • Generic HTTP path now rewrites header keys on every activation instead of only on mismatch (scripts/ensure-codex-http-mcp.py:22; medium confidence)
    The removed code in the modules/profiles/ai-agents.nix diff re-registered a server only when codex mcp get reported a mismatching url or bearer_token_env_var, so an already-matching entry was left completely untouched. The replacement always invokes the helper, which unconditionally pops bearer_token_env_var and http_headers (scripts/ensure-codex-http-mcp.py:19-20) and assigns server["env_http_headers"] = env_headers (line 22), while modules/profiles/ai-agents.nix:100 passes the literal '{}' for every server emitted by codexEnsureSnippet. The new test at scripts/test-codex-http-mcp.py asserts bearer_token_env_var is dropped for cloudflare when the argument is empty.
    Impact: Any http_headers or bearer_token_env_var a user had set inside [mcp_servers.<name>] for a generic HTTP server is now deleted on every activation, where previously it survived while url and bearer variable still matched. The README only claims that 'user preferences and OAuth settings' are preserved, so this header/auth loss is not covered by the stated contract; no supplied evidence shows anyone currently sets such keys on those servers, so the practical impact may be nil.
    Suggested fix: If declarative ownership of these keys is intended, no code change is needed; make it explicit by adding a regression test to scripts/test-codex-http-mcp.py that pins the intended outcome for pre-existing http_headers/bearer_token_env_var on a server registered through the generic path. If user-set headers should survive, skip the assignment/pop when env_headers and bearer_token_env_var are empty for the generic path (redview.nix:47 passes non-empty headers and must keep rewriting them).

Tests and validation

  • No configured deterministic checks.

Questions

  • Does codex mcp login cloudflare write anything into the [mcp_servers.cloudflare] table itself (e.g. bearer_token_env_var, http_headers) rather than only a separate sub-table such as [mcp_servers.cloudflare.oauth]? scripts/ensure-codex-http-mcp.py:19-20 pops those keys on every activation, so any live auth material stored under them would be dropped by the next unattended update.
  • The removed guard asserted .transport.type == "streamable_http" on the entry Codex had registered. Can a live host confirm that codex mcp get <name> --json reports streamable_http for an entry written by the new helper, which emits only url, env_http_headers and optionally bearer_token_env_var with no transport discriminator?

Review limitations

  • No Nix, Python, git or host tooling was used in this review; nix flake check, the regression tests, and any canary or deployment result are taken from the supplied diff and repository text as untrusted evidence, not verified.
  • The pull-request body was not supplied to this review, so statements about which validation steps were or were not performed come only from the supplied diff and AGENTS.md, not from the PR text.
  • The Codex CLI configuration schema and mcp get/mcp login/mcp add behaviour are not present in the repository material, so claims about which keys Codex writes into [mcp_servers.<name>] are phrased as questions rather than findings.
  • Only the four changed files and their direct callers (modules/mcp/default.nix, modules/mcp/redview.nix, modules/mcp/*.nix, flake.nix:227-237) were inspected; unchanged code outside those call paths was not analysed, and no defects were inferred in unchanged code.
  • Live host state on Vega and Lyra (current ~/.codex/config.toml, active auto-update holds, running generations) is not supplied, so the practical effect of the header-rewriting behaviour on the deployed fleet could not be confirmed.

Diff coverage

  • README.md: reviewed — included in a context-limited batch
  • modules/profiles/ai-agents.nix: reviewed — included in a context-limited batch
  • scripts/ensure-codex-http-mcp.py: reviewed — included in a context-limited batch
  • scripts/test-codex-http-mcp.py: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 1
  • Previous automated review: none found
  • Findings: 2
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `9844b568aa582a1c77f30a3999bc32cb792aa59b` ## Verdict: Requires further work Resolve the blocking or important findings and investigate failed deterministic checks before merging. ### Overall assessment The supplied diff replaces the `codex mcp get`/`codex mcp add` round-trip in `ensure_http_mcp` (modules/profiles/ai-agents.nix:92-100) with a direct call to `scripts/ensure-codex-http-mcp.py`, adds an optional `bearer_token_env_var` parameter to that helper, and extends `scripts/test-codex-http-mcp.py` with two regression tests. Caller signatures were checked: `modules/mcp/default.nix:253` emits `ensure_http_mcp <name> <url> [tokenEnvVar]`, matching the unchanged three-argument shell signature, and the pre-existing custom snippet at `modules/mcp/redview.nix:47` still passes four arguments, which the defaulted fifth parameter accepts. `${python}/bin/python` with `pkgs.python3.withPackages (ps: [ ps.tomlkit ])` and the relative path `../../scripts/ensure-codex-http-mcp.py` mirror the existing redview pattern, and `flake.nix:231-237` already copies both scripts into the `redview-mcp` check, so the new tests are wired into `nix flake check`. No evaluation-breaking or secret-leaking defect was identified in the changed code; the open items are the deployment evidence AGENTS.md requires for a multi-host/auto-update change and a behavioural narrowing in which the helper now rewrites header keys unconditionally instead of only on mismatch. ### Blocking findings None. ### Important findings - **Multi-host auto-update change has no recorded NixOS generation or no-op follow-up in the supplied evidence** (modules/profiles/ai-agents.nix:99; high confidence) The rewritten activation helper at modules/profiles/ai-agents.nix:92-100 is emitted for every enabled HTTP server via modules/mcp/default.nix:253 (`ensure_http_mcp`), and the README diff itself states the change targets 'unattended updates on headless Vega and Lyra'. AGENTS.md:43 states: 'For multi-host or auto-update changes, record one genuine deployment and a no-op follow-up before closing the issue.' The only executable evidence supplied with the change is the Python regression tests in scripts/test-codex-http-mcp.py, which run the helper against a temp config.toml and never exercise a NixOS activation, the auto-update path, or the generated shell snippet. Impact: The failure mode being prevented (an unattended auto-update activation timeout) lives in the activation path that the supplied evidence does not exercise, so a regression in the rewritten shell snippet - a python invocation failure, a wrong store path, or an aborted activation - would first surface at the next unattended update on Vega/Lyra rather than in `nix flake check`. The repository rule for this class of change is not yet satisfied by anything in the supplied material. Suggested fix: Before closing the issue, produce the evidence AGENTS.md:43 requires: create an auto-update hold, run `just test` on one affected headless host (plus `just test-remote` if the controller path is in scope), release the hold, then record one genuine `switch` deployment and a no-op follow-up activation showing `~/.codex/config.toml` is left byte-identical and untouched (mtime unchanged) by the rewritten helper. ### Suggestions - **Generic HTTP path now rewrites header keys on every activation instead of only on mismatch** (scripts/ensure-codex-http-mcp.py:22; medium confidence) The removed code in the modules/profiles/ai-agents.nix diff re-registered a server only when `codex mcp get` reported a mismatching url or `bearer_token_env_var`, so an already-matching entry was left completely untouched. The replacement always invokes the helper, which unconditionally pops `bearer_token_env_var` and `http_headers` (scripts/ensure-codex-http-mcp.py:19-20) and assigns `server["env_http_headers"] = env_headers` (line 22), while modules/profiles/ai-agents.nix:100 passes the literal `'{}'` for every server emitted by `codexEnsureSnippet`. The new test at scripts/test-codex-http-mcp.py asserts `bearer_token_env_var` is dropped for cloudflare when the argument is empty. Impact: Any `http_headers` or `bearer_token_env_var` a user had set inside `[mcp_servers.<name>]` for a generic HTTP server is now deleted on every activation, where previously it survived while url and bearer variable still matched. The README only claims that 'user preferences and OAuth settings' are preserved, so this header/auth loss is not covered by the stated contract; no supplied evidence shows anyone currently sets such keys on those servers, so the practical impact may be nil. Suggested fix: If declarative ownership of these keys is intended, no code change is needed; make it explicit by adding a regression test to scripts/test-codex-http-mcp.py that pins the intended outcome for pre-existing `http_headers`/`bearer_token_env_var` on a server registered through the generic path. If user-set headers should survive, skip the assignment/pop when `env_headers` and `bearer_token_env_var` are empty for the generic path (redview.nix:47 passes non-empty headers and must keep rewriting them). ### Tests and validation - No configured deterministic checks. ### Questions - Does `codex mcp login cloudflare` write anything into the `[mcp_servers.cloudflare]` table itself (e.g. `bearer_token_env_var`, `http_headers`) rather than only a separate sub-table such as `[mcp_servers.cloudflare.oauth]`? scripts/ensure-codex-http-mcp.py:19-20 pops those keys on every activation, so any live auth material stored under them would be dropped by the next unattended update. - The removed guard asserted `.transport.type == "streamable_http"` on the entry Codex had registered. Can a live host confirm that `codex mcp get <name> --json` reports `streamable_http` for an entry written by the new helper, which emits only `url`, `env_http_headers` and optionally `bearer_token_env_var` with no transport discriminator? ### Review limitations - No Nix, Python, git or host tooling was used in this review; `nix flake check`, the regression tests, and any canary or deployment result are taken from the supplied diff and repository text as untrusted evidence, not verified. - The pull-request body was not supplied to this review, so statements about which validation steps were or were not performed come only from the supplied diff and AGENTS.md, not from the PR text. - The Codex CLI configuration schema and `mcp get`/`mcp login`/`mcp add` behaviour are not present in the repository material, so claims about which keys Codex writes into `[mcp_servers.<name>]` are phrased as questions rather than findings. - Only the four changed files and their direct callers (modules/mcp/default.nix, modules/mcp/redview.nix, modules/mcp/*.nix, flake.nix:227-237) were inspected; unchanged code outside those call paths was not analysed, and no defects were inferred in unchanged code. - Live host state on Vega and Lyra (current `~/.codex/config.toml`, active auto-update holds, running generations) is not supplied, so the practical effect of the header-rewriting behaviour on the deployed fleet could not be confirmed. ### Diff coverage - `README.md`: **reviewed** — included in a context-limited batch - `modules/profiles/ai-agents.nix`: **reviewed** — included in a context-limited batch - `scripts/ensure-codex-http-mcp.py`: **reviewed** — included in a context-limited batch - `scripts/test-codex-http-mcp.py`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md - Commits considered: 1 - Previous automated review: none found - Findings: 2 </details>
Author
Owner

Reviewed the feedback on 9844b56.

The header-preservation suggestion is valid and is fixed in the next push. Generic HTTP registration now has an explicit preservation mode matching the old guard: if the entry is HTTP and its URL and bearer environment variable already match, the entire entry and file remain untouched. User literal/environment headers and OAuth settings survive. Transport mismatches still repair stale fields, as before. Redview's custom-header path retains declarative reconciliation. Two new regressions cover matching headers (with and without bearer authentication) and mismatched stale authentication; the URL-only CLI test now exercises preservation mode.

Validation: all seven helper tests and full nix flake check passed; the revised Lyra activation package built. Lyra's Codex CLI also confirmed .transport.type == "streamable_http" for the helper's URL/empty-header schema, without any transport discriminator, browser, network discovery, or persisted config change. The exact generated HTTP function passed a fresh disposable Lyra registration and a no-op repeat with user-added headers: contents and mtime unchanged; Home Manager/Paseo remained active. Preserving a matching entry also avoids depending on where an OAuth client might keep its table settings.

The deployment finding is a valid operational acceptance gate, already explicitly pending in this MR and #315. The earlier review did not receive the MR body: it therefore omitted the existing exact-generated-function canary, which exercises the shell invocation/store paths but is still not a genuine system deployment. No generation deployment is claimed. Keep #315 open and require an affected-host deployment plus no-op follow-up before closure, and an appropriate canary before merge. This feedback loop authorizes review fixes and pushes; it does not authorize a live deployment or merge.

Posting this explanation before pushing the preservation fix to trigger another review.

Reviewed the feedback on 9844b56. The header-preservation suggestion is valid and is fixed in the next push. Generic HTTP registration now has an explicit preservation mode matching the old guard: if the entry is HTTP and its URL and bearer environment variable already match, the entire entry and file remain untouched. User literal/environment headers and OAuth settings survive. Transport mismatches still repair stale fields, as before. Redview's custom-header path retains declarative reconciliation. Two new regressions cover matching headers (with and without bearer authentication) and mismatched stale authentication; the URL-only CLI test now exercises preservation mode. Validation: all seven helper tests and full nix flake check passed; the revised Lyra activation package built. Lyra's Codex CLI also confirmed `.transport.type == "streamable_http"` for the helper's URL/empty-header schema, without any transport discriminator, browser, network discovery, or persisted config change. The exact generated HTTP function passed a fresh disposable Lyra registration and a no-op repeat with user-added headers: contents and mtime unchanged; Home Manager/Paseo remained active. Preserving a matching entry also avoids depending on where an OAuth client might keep its table settings. The deployment finding is a valid operational acceptance gate, already explicitly pending in this MR and #315. The earlier review did not receive the MR body: it therefore omitted the existing exact-generated-function canary, which exercises the shell invocation/store paths but is still not a genuine system deployment. No generation deployment is claimed. Keep #315 open and require an affected-host deployment plus no-op follow-up before closure, and an appropriate canary before merge. This feedback loop authorizes review fixes and pushes; it does not authorize a live deployment or merge. Posting this explanation before pushing the preservation fix to trigger another review.
Author
Owner

Canary correction: I posted the revised-canary result before checking its first run's exit status. That first run failed because my disposable fixture declared an empty header table twice, not because activation failed. I corrected the fixture to set its user headers through TOMLKit and reran the exact generated function successfully on Lyra. Header preservation, unchanged content/mtime, and active Home Manager/Paseo are now confirmed. Repository checks and the seven regression tests passed independently. Fix commit: 52c0440.

Canary correction: I posted the revised-canary result before checking its first run's exit status. That first run failed because my disposable fixture declared an empty header table twice, not because activation failed. I corrected the fixture to set its user headers through TOMLKit and reran the exact generated function successfully on Lyra. Header preservation, unchanged content/mtime, and active Home Manager/Paseo are now confirmed. Repository checks and the seven regression tests passed independently. Fix commit: 52c0440.
fix: preserve matching HTTP MCP headers during activation
All checks were successful
Build and Push Attic Cache / test (pull_request) Successful in 1m26s
Build and Push Attic Cache / build (pull_request) Has been skipped
Build and Push Attic Cache / pin-lifecycle (pull_request) Has been skipped
Build and Push Attic Cache / remediate (pull_request) Has been skipped
Build and Push Attic Cache / notify-remediation (pull_request) Has been skipped
Build and Push Attic Cache / record-remediation-notify-failure (pull_request) Has been skipped
AI pull-request review / review (pull_request) Successful in 4m23s
52c0440590
clankbot left a comment

Automated code review

Reviewed commit: 52c04405903c1506b023a36b9cecb1797c2bd7f5

Verdict: Requires further work

Resolve the blocking or important findings and investigate failed deterministic checks before merging.

Overall assessment

The change replaces the codex mcp get/remove/add guard in ensure_http_mcp (modules/profiles/ai-agents.nix:92-101) with the existing TOML-preserving helper scripts/ensure-codex-http-mcp.py, adding an optional bearer_token_env_var positional and a --preserve-matching-headers guard, and documents the headless-OAuth workaround in README. I traced both call sites: the unchanged generic caller at modules/mcp/default.nix:253 passes name/url/optional token, which matches the new shell function and the new argparse CLI (the optional positional keeps that 3-argument form working), and Redview's own snippet at modules/mcp/redview.nix:46 keeps its 4-argument, non-preserving, header-reconciling path. Only Redview declares Codex-side headers (grep headers modules/mcp matches redview.nix plus the agy/opencode/hermes blocks in default.nix), so no declarative headers are dropped by the new path; cloudflare.nix declares no tokenEnvVar, so it takes the URL-only path. The new tests in scripts/test-codex-http-mcp.py exercise both the library API and the CLI form used by the activation (including the --preserve-matching-headers flag and the no-op mtime check), and they run under nix flake check via checks.x86_64-linux.redview-mcp (flake.nix:234-236). The same TOML shape the new path writes (url + env_http_headers, no transport discriminator) is already produced by the pre-existing Redview snippet, so the new registration form is not novel. I found no defect demonstrable in the changed code; the remaining gap is that the changed code is a home.activation DAG entry whose end-to-end activation path is not evidenced in the supplied material, which AGENTS.md explicitly requires for deployment-affecting changes.

Blocking findings

None.

Important findings

  • Activation-script change has no end-to-end activation evidence in the supplied material (modules/profiles/ai-agents.nix:99; medium confidence)
    The changed code is inside home.activation.codexMcpConfig = hmLib.hm.dag.entryAfter [ "writeBoundary" ], i.e. it only runs during Home Manager activation on hosts enabling the shared AI-client profile (README.md:151 lists Codex on Electra, Lena, Vega, Lyra). AGENTS.md:43 states 'Before merging a deployment-affecting change: Confirm local validation, required MR checks, and a canary appropriate to the risk', AGENTS.md:45 states 'Use just test rather than raw nixos-rebuild test', and README.md:306 describes the hold/test/deploy/no-op-follow-up sequence. The supplied material contains only the diff and the helper's unit tests (flake.nix:234-236 runs test-codex-http-mcp.py in a fixture directory); nothing supplied shows an activation of an affected host generation.
    Impact: The failure mode this change targets (an interactive browser wait inside unattended activation on a headless host) lives in the activation script, which the supplied evidence never exercises; a regression there would keep breaking unattended auto-updates even though nix flake check and the helper tests pass.
    Suggested fix: Per AGENTS.md: create an auto-update hold, run just test on one affected headless host (Vega or Lyra), and record that activation completes without an interactive wait and that the HTTP entries appear in ~/.codex/config.toml; then record the no-op follow-up required by AGENTS.md:43 before the issue is closed, and release the hold only after validation.

Suggestions

None.

Tests and validation

  • No configured deterministic checks.

Questions

  • Is preserving enabled = false across a URL/transport repair intended for the generic path? The removed code did codex mcp remove "$name" then codex mcp add, which reset the entry, whereas the new repair branch pops only command, args, env, env_vars, cwd, bearer_token_env_var, http_headers and keeps enabled (scripts/test-codex-http-mcp.py asserts self.assertFalse(server["enabled"]) after a URL change).
  • For a generic entry whose URL or bearer variable changed, the repair path replaces any user-authored env_http_headers with {} while the matching path preserves them; is that asymmetry acceptable, or should user env-backed headers be merged rather than replaced?
  • Was the README's new headless recipe (codex -c mcp_oauth_callback_port=4321 mcp login cloudflare with ssh -L 4321:127.0.0.1:4321 <host>) actually exercised on a headless host, as AGENTS.md:43 requires for documented user-facing commands, and is port 4321 free of conflicts on Vega/Lyra?
  • The stdio path ensure_mcp still shells out to codex mcp get/add during activation; is that known to be prompt-free, given only the HTTP path was changed?

Review limitations

  • No Nix tooling was available: I could not run nix flake check, the helper's unit tests, or any just test/activation, so the PR's validation claims were not independently verified.
  • Codex CLI's config.toml schema is not defined anywhere in this repository, so I cannot verify from supplied evidence that an entry written as url + env_http_headers = {} with no transport discriminator is accepted, nor that the pop list in ensure_server covers every stdio key Codex may write (e.g. a type or environment key).
  • No live host state was inspected: I cannot confirm the current contents of ~/.codex/config.toml on Vega or Lyra, nor what the previously timed-out switch left behind.
  • The PR description, its canary records, and issue #315's state were not supplied; the validation-evidence finding is based only on AGENTS.md/README rules plus the absence of activation evidence in the supplied material.
  • I did not evaluate the runtime behaviour of checks.x86_64-linux.redview-mcp beyond its source, which is unchanged by this diff.

Diff coverage

  • README.md: reviewed — included in a context-limited batch
  • modules/profiles/ai-agents.nix: reviewed — included in a context-limited batch
  • scripts/ensure-codex-http-mcp.py: reviewed — included in a context-limited batch
  • scripts/test-codex-http-mcp.py: reviewed — included in a context-limited batch
Review metadata
  • Reviewer: forgejo-ai-review v1
  • Model: strata/strata
  • Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md
  • Commits considered: 2
  • Previous automated review: none found
  • Findings: 1
<!-- forgejo-ai-review:v1 --> ## Automated code review Reviewed commit: `52c04405903c1506b023a36b9cecb1797c2bd7f5` ## Verdict: Requires further work Resolve the blocking or important findings and investigate failed deterministic checks before merging. ### Overall assessment The change replaces the `codex mcp get`/`remove`/`add` guard in `ensure_http_mcp` (modules/profiles/ai-agents.nix:92-101) with the existing TOML-preserving helper `scripts/ensure-codex-http-mcp.py`, adding an optional `bearer_token_env_var` positional and a `--preserve-matching-headers` guard, and documents the headless-OAuth workaround in README. I traced both call sites: the unchanged generic caller at modules/mcp/default.nix:253 passes name/url/optional token, which matches the new shell function and the new argparse CLI (the optional positional keeps that 3-argument form working), and Redview's own snippet at modules/mcp/redview.nix:46 keeps its 4-argument, non-preserving, header-reconciling path. Only Redview declares Codex-side headers (`grep headers modules/mcp` matches redview.nix plus the agy/opencode/hermes blocks in default.nix), so no declarative headers are dropped by the new path; cloudflare.nix declares no `tokenEnvVar`, so it takes the URL-only path. The new tests in scripts/test-codex-http-mcp.py exercise both the library API and the CLI form used by the activation (including the `--preserve-matching-headers` flag and the no-op mtime check), and they run under `nix flake check` via `checks.x86_64-linux.redview-mcp` (flake.nix:234-236). The same TOML shape the new path writes (`url` + `env_http_headers`, no transport discriminator) is already produced by the pre-existing Redview snippet, so the new registration form is not novel. I found no defect demonstrable in the changed code; the remaining gap is that the changed code is a `home.activation` DAG entry whose end-to-end activation path is not evidenced in the supplied material, which AGENTS.md explicitly requires for deployment-affecting changes. ### Blocking findings None. ### Important findings - **Activation-script change has no end-to-end activation evidence in the supplied material** (modules/profiles/ai-agents.nix:99; medium confidence) The changed code is inside `home.activation.codexMcpConfig = hmLib.hm.dag.entryAfter [ "writeBoundary" ]`, i.e. it only runs during Home Manager activation on hosts enabling the shared AI-client profile (README.md:151 lists Codex on Electra, Lena, Vega, Lyra). AGENTS.md:43 states 'Before merging a deployment-affecting change: Confirm local validation, required MR checks, and a canary appropriate to the risk', AGENTS.md:45 states 'Use `just test` rather than raw `nixos-rebuild test`', and README.md:306 describes the hold/test/deploy/no-op-follow-up sequence. The supplied material contains only the diff and the helper's unit tests (flake.nix:234-236 runs `test-codex-http-mcp.py` in a fixture directory); nothing supplied shows an activation of an affected host generation. Impact: The failure mode this change targets (an interactive browser wait inside unattended activation on a headless host) lives in the activation script, which the supplied evidence never exercises; a regression there would keep breaking unattended auto-updates even though `nix flake check` and the helper tests pass. Suggested fix: Per AGENTS.md: create an auto-update hold, run `just test` on one affected headless host (Vega or Lyra), and record that activation completes without an interactive wait and that the HTTP entries appear in `~/.codex/config.toml`; then record the no-op follow-up required by AGENTS.md:43 before the issue is closed, and release the hold only after validation. ### Suggestions None. ### Tests and validation - No configured deterministic checks. ### Questions - Is preserving `enabled = false` across a URL/transport repair intended for the generic path? The removed code did `codex mcp remove "$name"` then `codex mcp add`, which reset the entry, whereas the new repair branch pops only `command`, `args`, `env`, `env_vars`, `cwd`, `bearer_token_env_var`, `http_headers` and keeps `enabled` (scripts/test-codex-http-mcp.py asserts `self.assertFalse(server["enabled"])` after a URL change). - For a generic entry whose URL or bearer variable changed, the repair path replaces any user-authored `env_http_headers` with `{}` while the matching path preserves them; is that asymmetry acceptable, or should user env-backed headers be merged rather than replaced? - Was the README's new headless recipe (`codex -c mcp_oauth_callback_port=4321 mcp login cloudflare` with `ssh -L 4321:127.0.0.1:4321 <host>`) actually exercised on a headless host, as AGENTS.md:43 requires for documented user-facing commands, and is port 4321 free of conflicts on Vega/Lyra? - The stdio path `ensure_mcp` still shells out to `codex mcp get`/`add` during activation; is that known to be prompt-free, given only the HTTP path was changed? ### Review limitations - No Nix tooling was available: I could not run `nix flake check`, the helper's unit tests, or any `just test`/activation, so the PR's validation claims were not independently verified. - Codex CLI's `config.toml` schema is not defined anywhere in this repository, so I cannot verify from supplied evidence that an entry written as `url` + `env_http_headers = {}` with no transport discriminator is accepted, nor that the pop list in `ensure_server` covers every stdio key Codex may write (e.g. a `type` or `environment` key). - No live host state was inspected: I cannot confirm the current contents of `~/.codex/config.toml` on Vega or Lyra, nor what the previously timed-out switch left behind. - The PR description, its canary records, and issue #315's state were not supplied; the validation-evidence finding is based only on AGENTS.md/README rules plus the absence of activation evidence in the supplied material. - I did not evaluate the runtime behaviour of `checks.x86_64-linux.redview-mcp` beyond its source, which is unchanged by this diff. ### Diff coverage - `README.md`: **reviewed** — included in a context-limited batch - `modules/profiles/ai-agents.nix`: **reviewed** — included in a context-limited batch - `scripts/ensure-codex-http-mcp.py`: **reviewed** — included in a context-limited batch - `scripts/test-codex-http-mcp.py`: **reviewed** — included in a context-limited batch <details><summary>Review metadata</summary> - Reviewer: forgejo-ai-review v1 - Model: strata/strata - Guidance loaded: .forgejo/ai-review.md, .forgejo/ai-review.yml, AGENTS.md, docs/auto-update-remediation.md, docs/nova-remote-builder.md, README.md - Commits considered: 2 - Previous automated review: none found - Findings: 1 </details>
Author
Owner

Reviewed the second report on final head 52c0440. It identifies no demonstrable code defect and no further suggestions; CI and the review job both passed. The one important finding is the same outstanding end-to-end activation evidence already recorded in the MR/#315. I am not treating the isolated generated-function canary as a NixOS generation deployment, and will not close #315 or claim that operational gate is satisfied.

Answers to the questions:

  • Preserving enabled = false across repair is intentional: an operator's disablement is a user preference, not a stale transport field. The explicit regression pins this behavior. Repair updates the declared transport rather than re-enabling a server the operator disabled.
  • Matching transport leaves all user headers untouched. A URL/bearer change deliberately repairs stale header/auth fields rather than carrying credentials over to a different endpoint. Redview still owns and reconciles its custom headers. This distinction is documented and tested; merging old auth into a changed endpoint is not intended.
  • The full interactive Cloudflare OAuth/SSH-forwarding recipe has not been completed on a headless host, and is not claimed as verified. A read-only check now confirms Lyra accepts the fixed-port CLI configuration and has no current TCP listener on 4321. Port availability is transient and must be checked on both tunnel endpoints when logging in. Actual login and full generation activation remain acceptance work.
  • The stdio registration path is unchanged. The observed timeout was specifically HTTP Cloudflare OAuth discovery, confirmed in the service journal. Existing stdio registration already runs in unattended activations without the observed browser wait; no universal guarantee about future upstream behavior is claimed.

No additional code change is warranted by these questions, so there is no empty push to retrigger review. Monitoring remains active within the latest push's 30-minute window; genuine activation evidence remains explicitly pending.

Reviewed the second report on final head 52c0440. It identifies no demonstrable code defect and no further suggestions; CI and the review job both passed. The one important finding is the same outstanding end-to-end activation evidence already recorded in the MR/#315. I am not treating the isolated generated-function canary as a NixOS generation deployment, and will not close #315 or claim that operational gate is satisfied. Answers to the questions: - Preserving `enabled = false` across repair is intentional: an operator's disablement is a user preference, not a stale transport field. The explicit regression pins this behavior. Repair updates the declared transport rather than re-enabling a server the operator disabled. - Matching transport leaves all user headers untouched. A URL/bearer change deliberately repairs stale header/auth fields rather than carrying credentials over to a different endpoint. Redview still owns and reconciles its custom headers. This distinction is documented and tested; merging old auth into a changed endpoint is not intended. - The full interactive Cloudflare OAuth/SSH-forwarding recipe has not been completed on a headless host, and is not claimed as verified. A read-only check now confirms Lyra accepts the fixed-port CLI configuration and has no current TCP listener on 4321. Port availability is transient and must be checked on both tunnel endpoints when logging in. Actual login and full generation activation remain acceptance work. - The stdio registration path is unchanged. The observed timeout was specifically HTTP Cloudflare OAuth discovery, confirmed in the service journal. Existing stdio registration already runs in unattended activations without the observed browser wait; no universal guarantee about future upstream behavior is claimed. No additional code change is warranted by these questions, so there is no empty push to retrigger review. Monitoring remains active within the latest push's 30-minute window; genuine activation evidence remains explicitly pending.
Author
Owner

The outstanding test-activation evidence from review 61 is now available. The user completed Lyra's test deployment; live verification confirms configurationRevision 52c0440590 (the reviewed/current MR head) and the exact revised Home Manager generation. Activation ran 07:36:22–07:36:24 BST with Result=success, ExecMainStatus=0; codexMcpConfig proceeded to installPackages without an OAuth/browser wait. Home Manager and Paseo are active.

I also repeated the deployed Cloudflare registration function against Lyra's real ~/.codex/config.toml: content and mtime remained unchanged, and Codex reported the expected streamable_http endpoint. This is a hook no-op check, not a second full system activation. CI is successful on the same SHA.

This resolves the pre-merge affected-host canary gap. The MR body is updated. Keep #315 open for persistent deployment and full no-op follow-up evidence; no merge or persistent switch is claimed here.

The outstanding test-activation evidence from review 61 is now available. The user completed Lyra's test deployment; live verification confirms configurationRevision 52c04405903c1506b023a36b9cecb1797c2bd7f5 (the reviewed/current MR head) and the exact revised Home Manager generation. Activation ran 07:36:22–07:36:24 BST with Result=success, ExecMainStatus=0; codexMcpConfig proceeded to installPackages without an OAuth/browser wait. Home Manager and Paseo are active. I also repeated the deployed Cloudflare registration function against Lyra's real ~/.codex/config.toml: content and mtime remained unchanged, and Codex reported the expected streamable_http endpoint. This is a hook no-op check, not a second full system activation. CI is successful on the same SHA. This resolves the pre-merge affected-host canary gap. The MR body is updated. Keep #315 open for persistent deployment and full no-op follow-up evidence; no merge or persistent switch is claimed here.
nimmo merged commit 2d1f6f90ba into main 2026-10-12 07:54:15 +01:00
nimmo deleted branch fix/noninteractive-codex-mcp 2026-10-12 07:54:20 +01:00
Sign in to join this conversation.
No reviewers
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/nixos-config!316
No description provided.