Repository navigation
fix(daemon): make periodic status refresh resume slow embedding readiness - #3377
Conversation
…ness Problem ------- Live measurement against the real archive found embedding_readiness_info taking ~5s while its declared deadline is 2.0s. The daemon's periodic status-snapshot refresh (_periodic_status_snapshot_refresh, every 10s for the process lifetime) called daemon_status_payload -> build_daemon_status, which built a brand-new ephemeral StatusComponentRegistry on every tick. A component slower than its own deadline_s therefore timed out and was discarded on every single tick, forever -- it could never converge on a real value -- and each tick leaked one orphaned collector thread (the timed-out attempt cannot be cancelled and keeps running past the deadline). This is the same resumability gap PR #3131 fixed for coordination's archive_evidence stage, on the daemon status side. Solution -------- - Extracted build_daemon_status's inline StatusComponentSpec list into _daemon_status_component_specs(), shared by the existing ephemeral per-call path and a new persistent factory. - periodic_status_component_registry() lazily builds ONE process-wide StatusComponentRegistry (module singleton) with the same fixed parameters refresh_status_snapshot always passes (include_raw_replay_backlog=False, include_exact_raw_materialization_readiness=False, fast-tier health), and a real source fingerprint (_daemon_status_fingerprint: index db + ops db + their -wal mtimes) so a changed archive/ops source forces a refresh even inside the 10s ttl_s window (polylogue-20d.17 AC #5 -- previously none of these ~14 components had a fingerprint at all). - build_daemon_status/daemon_status_payload gained an optional `registry` parameter, threaded through by refresh_status_snapshot's periodic call. Direct one-shot CLI/API status calls keep the default None -- unchanged fresh-per-call ephemeral registry, correct for their pure-recompute contract (all ~63 pre-existing parameterized tests pass unmodified). Investigated and found NOT to need this treatment (false alarm, same methodology as polylogue-dhjz): coordination/envelope.py's beads and handoff stages, and daemon/status.py's archive_debt/ assertion_candidate_queue ephemeral registries. Beads probes are already bounded via real subprocess-timeout cancellation (not the unbounded blocking-SQL problem archive_evidence had); handoff is a cheap glob + LIMIT-bounded query; archive_debt/assertion_candidate_queue are only ever reached from one-shot `polylogue check`/`polylogued status` CLI invocations (verified by grepping every call site), so there is no cross-call state for a persistent registry to preserve. Detail in the polylogue-20d.17 bead notes. Verification ------------ - New anti-vacuity test test_periodic_status_component_registry_resumes_slow_embedding_readiness_across_ticks: proves the collector is invoked exactly once across three ticks (timed_out -> refreshing -> fresh) despite exceeding its deadline -- fails on the pre-fix ephemeral-registry code (verified by reverting the registry-reuse check and confirming the test fails with a duplicated attempt), and fails when refresh_status_snapshot stops threading the registry through (verified the same way). - New test test_periodic_status_component_registry_fingerprint_forces_refresh proves a changed index db forces a refresh inside the ttl_s window. - Live dogfood (read-only) against the real archive at /realm/db/polylogue: embedding_readiness_info measured ~5.06s standalone; against the fixed registry, tick 0 times out at the 2.0s deadline, ticks 1-2 (0.2s apart) observe "refreshing" without re-invoking the collector, and once the background attempt finishes (~8s total), a later poll returns "fresh" with the real embedding_coverage_percent=44.1 -- artifact at .local/coordination/20d17-embedding-resumability-dogfood.json. - devtools test tests/unit/daemon/test_daemon_status.py -- 63 passed. - mypy --strict polylogue/daemon/status.py polylogue/daemon/status_snapshot.py tests/unit/daemon/test_daemon_status.py -- clean. - devtools verify --quick -- exit 0. - Confirmed tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade fails identically on baseline master (unrelated, pre-existing). Ref polylogue-20d.17 Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45c17adb22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Extends polylogue-20d.17's budgeted-component-snapshot protocol (PR #3107/#3116/#3131) with the resumable-detail-query pattern for the daemon's own periodic status refresh, following live measurement that found a real, unfixed instance of the exact resumability gap PR #3131 fixed for coordination's
archive_evidencestage.Problem
Live measurement against the real archive at
/realm/db/polyloguefoundembedding_readiness_infotaking ~5.06s while its declareddeadline_sinbuild_daemon_status's component list is 2.0s. The daemon's periodic status-snapshot refresh (_periodic_status_snapshot_refresh, every 10s for the process lifetime —daemon/cli.py) callsdaemon_status_payload->build_daemon_status, which built a brand-new ephemeralStatusComponentRegistryon every tick. A component slower than its own deadline therefore timed out and was discarded on every single tick, forever — it could never converge on a real value — and each tick leaked one orphaned collector thread (a timed-out attempt cannot be cancelled and keeps running past the deadline on its own background thread). This is the same resumability gap PR #3131 fixed for coordination'sarchive_evidencestage, now found and fixed on the daemon status side.None of
build_daemon_status's ~14 components had afingerprinteither, so even a persistent registry would have hidden a changed archive/ops source behind the 10sttl_swindow (polylogue-20d.17 AC #5).Solution
build_daemon_status's inlineStatusComponentSpeclist into_daemon_status_component_specs(), shared by the existing ephemeral per-call path and a new persistent factory.periodic_status_component_registry()lazily builds ONE process-wideStatusComponentRegistry(module singleton) with the same fixed parametersrefresh_status_snapshotalways passes (include_raw_replay_backlog=False,include_exact_raw_materialization_readiness=False, fast-tier health only), plus a real source fingerprint (_daemon_status_fingerprint: index db + ops db + their-walmtimes) so a changed archive/ops source forces a refresh even inside the ttl window.build_daemon_status/daemon_status_payloadgained an optionalregistryparameter, threaded through byrefresh_status_snapshot's periodic call. Direct one-shot CLI/API status calls keep the defaultNone— unchanged fresh-per-call ephemeral registry, correct for their pure-recompute contract (all pre-existing parameterized tests pass unmodified).Investigated and found NOT to need this treatment (false alarm, same methodology as
polylogue-dhjz): coordination/envelope.py'sbeadsandhandoffstages, and daemon/status.py'sarchive_debt/assertion_candidate_queueephemeral registries.archive_evidencehad, which is why it needed a background-thread registry in the first place).handoffis a cheap filesystem glob + LIMIT-bounded SQLite query.archive_debt/assertion_candidate_queueare only ever reached from one-shotpolylogue check/polylogued statusCLI invocations (verified by grepping every call site) — no cross-call state exists for a persistent registry to preserve.Full detail recorded on the polylogue-20d.17 bead notes.
Verification
test_periodic_status_component_registry_resumes_slow_embedding_readiness_across_ticks: proves the collector is invoked exactly once across three ticks (timed_out->refreshing->fresh) despite exceeding its deadline. Confirmed it fails on the pre-fix ephemeral-registry behavior (reverted the registry-reuse check, reran, saw a duplicated attempt) and fails whenrefresh_status_snapshotstops threading the registry through (reverted that wiring, reran, saw the same failure).test_periodic_status_component_registry_fingerprint_forces_refreshproves a changed index db forces a fresh recollection inside thettl_swindow./realm/db/polylogue:embedding_readiness_infomeasured ~5.06s standalone; against the fixed registry, tick 0 times out at the 2.0s deadline, ticks 1-2 (0.2s apart) observerefreshingwithout re-invoking the collector, and once the background attempt finishes (~8s total), a later poll returnsfreshwith the realembedding_coverage_percent=44.1. Artifact:.local/coordination/20d17-embedding-resumability-dogfood.json(untracked,.local/per repo convention).devtools test tests/unit/daemon/test_daemon_status.py— 63 passed.mypy --strict polylogue/daemon/status.py polylogue/daemon/status_snapshot.py tests/unit/daemon/test_daemon_status.py— clean.devtools verify --quick— exit 0 (ran twice: once pre-push, once via the pre-push hook).tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facadefails identically on baselinemaster(unrelated, pre-existing — not introduced by this change).Ref polylogue-20d.17