Skip to content

refactor(daemon): route stop and ownership through Control - #30

Closed
jlongster wants to merge 1 commit into
handler-spawnfrom
daemon-control
Closed

jlongster wants to merge 1 commit into
handler-spawnfrom
daemon-control

Conversation

@jlongster

Copy link
Copy Markdown
Collaborator

Summary

  • Part 3 of the stack for Idle daemon wakes the CPU ~100 times/s (10 ms sleep in the accept loop) #25, stacked on fix(daemon): survive thread spawn failures #29. Please merge fix(daemon): block subscriptions instead of polling #28 and fix(daemon): survive thread spawn failures #29 first.
  • Behaviour-preserving refactor: the 10 ms accept loop is unchanged. This PR prepares the loop to become readiness-driven in the next PR.
  • New daemon::Control holds a private stop flag and the ownership mutex, and is now the only way to stop the daemon or mutate ownership.
    • request_stop takes the ownership lock, so the next PR can wake the accept loop under that same lock.
  • run is split into bind → Control → serve. Ownership is still created after bind, as before.
  • Handler completion is tracked with a done flag set by a drop guard in the handler thread (the reap check still also accepts is_finished()). The next PR adds a wake there.
  • Ownership::with_timeouts lets tests use short starting/handoff deadlines.
  • New in-process unix tests in src/daemon/server.rs, using a TestDaemon fixture that runs serve on a temp socket:
    • shutdown_request_stops_immediately
    • owner_shutdown_stops_immediately
    • owner_disconnect_without_handoff_stops_immediately
    • starting_deadline_fires_on_time
    • waiting_deadline_fires_on_time
    • handoff_claim_transfers_without_spurious_stop

Validation

  • cargo fmt --check and cargo clippy --locked --all-targets --all-features -- -D warnings pass (toolchain 1.90.0).
  • The macOS CI test selection passes: cargo test --locked --lib --test service --test runtime --test ownership --test rows --test ghostty-effects (lib 47, ghostty-effects 5, ownership 8, rows 1, runtime 8 + 1 ignored, service 9).
  • Cross clippy with -D warnings passes for x86_64-pc-windows-msvc and x86_64-unknown-linux-gnu (--all-targets --all-features, ghostty-vt link libs stubbed). Windows and Linux tests rely on CI.

@jlongster

Copy link
Copy Markdown
Collaborator Author

This moved to the monorepo as anomalyco/opencode#59700 (merged).

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