Skip to content

wip: two-tier daemon coordination — reload-auth before restart (stacked on #164) - #172

Closed
Loongphy wants to merge 1 commit into
stack/pr-164-headfrom
wip/pr-164-two-tier
Closed

Loongphy wants to merge 1 commit into
stack/pr-164-headfrom
wip/pr-164-two-tier

Conversation

@Loongphy

Copy link
Copy Markdown
Owner

WIP / draft — stacked on #164 (base is #164's head branch; this diff contains only the maintainer-side fix implementing the requested two-tier coordination). Will be retargeted to main after #164 merges.

What

Implements the two-tier --restart-daemon coordination requested in the #159-style review on #164:

  • ensure() probes the daemon, then attempts codex app-server daemon reload-auth (codex daemons) with a dedicated 10s budget before falling back to the full restart (upstream daemons without reload support)
  • reload outcomes: .reloaded (credentials applied in place, no restart, no session interruption) and .deferred (daemon busy with a running turn — exit 0, rerun switch --restart-daemon later); reload unavailability, failure, or timeout falls through to the existing restart path
  • diagnostics for both new outcomes; Enter keeps its switch-account meaning; the toggle stays on c... (key contract unchanged: --restart-daemon remains the flag, Enter remains the switch action)

Why this shape

  • Upstream daemons have no reload support: the reload attempt exits non-zero there and the restart fallback engages — so this PR stays correct for upstream codex.
  • Codex daemons accept the reload in place: no killed sessions, no reconnection, for the most common case (switch account, keep working).
  • The daemon-busy case (SkippedBusy) defers instead of restarting — restarting would kill the very turn that made the daemon busy.

Implementation

  • workflows/codex_daemon.zig: ensure() two-tier orchestrator, tryReload() (classify: success → .reloaded, skipped the auth reload → .deferred, anything else → fallback), reload budget 10s vs the 120s restart budget
  • workflows/switch.zig: restart() → ensure(); exit-1 contract unchanged (only unknown / restart_failed / timed_out fail)
  • cli/output.zig: diagnostics for .reloaded / .deferred
  • docs + fake lifecycle script + client/integration tests updated (version → reload-auth → restart sequences, reload-supported/unsupported/busy scenarios)

Validation

  • zig build -Doptimize=ReleaseFast clean; full zig build test exit 0
  • New scenarios covered: reload supported (no restart invoked), reload unsupported (fallback restart), reload busy (deferred, exit 0)

Two-tier --restart-daemon coordination, per the maintainer review:

- ensure() probes the daemon, then attempts 'app-server daemon
  reload-auth' (codex daemons) with a 10s budget before falling back to
  the full restart (upstream daemons without reload support)
- reload outcomes: .reloaded (credentials applied in place, no restart)
  and .deferred (daemon busy with a running turn — deferred, exit 0,
  rerun later); reload unavailability or failure falls through to the
  existing restart path
- diagnostics for both new outcomes; docs updated
- fake lifecycle script gains reload-auth variants; client + integration
  expectations updated for the version → reload-auth → restart sequence
[skip ci]
@Loongphy

Copy link
Copy Markdown
Owner Author

Superseded: the two-tier implementation is now pushed directly to this PR's branch (afded66) — see the commits above. Closing this stacked draft to avoid duplication.

@Loongphy Loongphy closed this Oct 22, 2026
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.

1 participant