Repository navigation
Resolve live shared-daemon model reroutes - #15
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves Codexometer’s live telemetry accuracy by opportunistically consuming shared app-server daemon signals (without reading conversation content) to (a) disambiguate Monitor attention states and (b) correctly attribute API-equivalent pricing to server-rerouted models when an exact correlation can be proven, while preserving the existing requested-model and writer-lock fallbacks when the daemon is absent/disconnected/unsupported. It also bumps the maintained version to v0.7.3 and documents the recommended CLI/daemon setup and privacy boundaries.
Changes:
- Add a persistent Unix app-server daemon connection with per-thread subscription, plus model-reroute + token-usage correlation to resolve rerouted models for pricing when positively matched.
- Extend the rollout reader to track turn IDs and support one-refresh “pending” model resolution with a safe requested-model fallback.
- Update docs and versioning/tests for the v0.7.3 release and the recommended daemon-backed CLI setup.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Reworks daemon guidance into a recommended setup section; documents resolved-model costing, privacy boundaries, and fallback behavior; bumps version references. |
| main_test.go | Updates CLI --version output expectation to v0.7.3. |
| internal/version/version.go | Bumps maintained source-build fallback version to 0.7.3. |
| internal/version/version_test.go | Updates version test expectations to 0.7.3. |
| internal/codex/live_usage.go | Adds turn-id tracking plus pending/resolved model reroute reconciliation that adjusts API-equivalent pricing when matched to daemon observations. |
| internal/codex/live_usage_test.go | Adds tests covering delayed reroute correction, fail-closed behavior on unpriceable usage, and requested-model finalization when no reroute arrives. |
| internal/codex/daemon_status.go | Expands the status provider contract to return runtime statuses plus resolved-model observations and subscription set. |
| internal/codex/daemon_status_unix.go | Implements a persistent websocket client with subscriptions, reroute/usage event correlation, and snapshotting for the rollout reader. |
| internal/codex/daemon_status_unix_test.go | Extends tests to cover loaded-thread-only subscription, reroute observation capture, and missing-socket fallback. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Why this change
Codexometer's rollout-only telemetry records the model a turn requested, but not transient server-side model reroutes. It also cannot always distinguish a session waiting for user input or approval from one still running a long local tool. That leaves two of its most useful readouts unnecessarily approximate: API-equivalent costing can be attributed to the wrong model, and Monitor may have to show the cautious
CHECK SESSIONfallback.A shared Codex app-server already exposes the missing live, per-thread signals. This PR consumes those signals opportunistically, correlates them with the durable rollout without reading conversation content, and preserves the existing behavior whenever the optimized setup is unavailable.
Summary
model/reroutedandthread/tokenUsage/updatedwith rollout calls by thread, turn, cumulative checkpoint, and full response usageAccounting safeguards
Subscribed calls wait at most one refresh for a matching reroute observation. A proven match uses the resolved model; no match falls back to the requested model. This avoids provisional repricing contaminating quota-learning samples.
Unknown models, new token fields, and unpriceable resolved usage continue to fail closed. The client ignores server requests and conversation content, asks
thread/resumeto exclude turns, and never loads unrelated historical threads.Validation
go vet ./...go test -race -cover ./...Race-enabled coverage: