Skip to content

refactor(server): split server.rs into concern modules - #136

Merged
Stephen Belanger (Qard) merged 1 commit into
mainfrom
refactor/split-server
Oct 6, 2026
Merged

Stephen Belanger (Qard) merged 1 commit into
mainfrom
refactor/split-server

Conversation

@Qard

@Qard Stephen Belanger (Qard) commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Based on main now that #135 has merged.

server.rs held about 2,700 lines: the Daemon struct and every subsystem that operates on it. The struct, ServeOptions, the auth traits, run and the serve entry points stay in server/mod.rs (344 lines). Each subsystem moves to its own module with its own impl Daemon block:

Module Responsibility
auth.rs resolving a route to a backend lease, refreshing it before flushes, auth.diagnose
sessions.rs DeliveryKey, session actors, journal writers, per-session locks, retirement
ingress.rs the capture queue, its worker, overflow recovery, the pending-session reconciler
correlation_store.rs automatic parent correlation and its persisted state and parent snapshots
recovery.rs startup replay of journals the previous daemon didn't finish
rpc.rs the listener, request handling, status
maintenance.rs retention GC, idle-session reaping, the idle watchdog, shutdown drain
managed_run.rs tracking which sessions a managed child produced and flushing them
claude_transcripts.rs Claude Code's transcript poller, which now lives outside the generic daemon code

Behaviour

None. The code moves verbatim:

  • Items that are now called across files become pub(super).
  • Struct fields read across files become pub(super).
  • Otherwise only rustfmt re-wrapped some longer signatures.

I checked this mechanically: with pub(super) stripped, the line multisets of the old and new files differ only by those re-wrapped signatures, the new module docs, and the use super::* / impl Daemon { lines.

Submodules share the parent's imports through use super::*, and mod.rs glob-imports each submodule. This keeps the PR a pure move. Tightening those imports can come later, once later PRs have moved the per-agent special cases out of the daemon.

The lock-ordering comments stay attached to the code they describe.

Testing

  • cargo clippy --all-features --all-targets -D warnings is clean.
  • cargo test --all-features --no-fail-fast: everything passes except trace_runtime::tests::doctor_reports_a_daemon_that_{cannot_authenticate_the_route,resolves_other_credentials}, which fail the same way on main in my local environment.

Conflicts

#132 and #130 both edit server.rs. Whichever lands second needs a rebase. Hunks in those PRs map onto the table above.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T12:29:11.556149Z eec2bf7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Base automatically changed from refactor/split-lib to main October 6, 2026 14:01
server.rs was about 2,700 lines of daemon state plus every subsystem
that operates on it. The Daemon struct, options, startup and the serve
entry points stay in server/mod.rs. Each subsystem moves to its own
module, contributing its own `impl Daemon` block:

- auth: route auth resolution, refresh before flush, diagnosis
- sessions: delivery keys, session actors, journal writers, locks
- ingress: the capture queue, its worker and overflow recovery
- correlation_store: automatic parent correlation and its persisted state
- recovery: startup replay of unfinished journals
- rpc: listener, request handling, status
- maintenance: GC, idle retirement, the idle watchdog, shutdown drain
- managed_run: managed-run session tracking and flushing
- claude_transcripts: Claude Code's transcript poller, now isolated from
  the generic daemon code

Code moves verbatim apart from `pub(super)` visibility. Submodules share
the parent's imports through `use super::*`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Qard
Stephen Belanger (Qard) merged commit eed70d2 into main Oct 6, 2026
20 checks passed
@Qard
Stephen Belanger (Qard) deleted the refactor/split-server branch October 6, 2026 14:42
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