Repository navigation
fix(daemon): keep status probes bounded - #851
Conversation
Problem: during production daemon convergence, polylogued status could exceed 30 seconds even though the daemon was healthy and the live attempt state was available in SQLite. Status was doing archive-size/deep-readiness work that does not belong on the critical status path.\n\nWhat changed: keep blob size as an unmeasured zero on the local status path, replace deep readiness/API probes with bounded read-only SQLite checks, and reuse the typed status probe results when rendering JSON instead of repeating them. Tests pin the single-probe behavior and lightweight readiness/freshness SQL.\n\nVerification: ruff format --check polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.py; ruff check polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.py; mypy --strict polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.py; pytest tests/unit/daemon/test_daemon_status.py -q; .venv/bin/polylogued status --format json against the live busy daemon returned in 1.7s; devtools verify.
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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.
Pull request overview
This PR keeps polylogued status responsive during large/locking daemon convergence by ensuring status probes are bounded and by reusing the already-computed DaemonStatus results when rendering JSON output.
Changes:
- Make blob store size reporting constant-time by returning an unmeasured
0(avoids recursive filesystem walks). - Replace “deep” readiness/insight status work with lightweight read-only SQLite probes (table presence + small counts).
- Update
daemon_status_payload()to reuseDaemonStatusfields instead of recomputing status sub-probes, and add unit tests covering the new bounded behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
polylogue/daemon/status.py |
Replaces expensive status probes with bounded SQLite/table checks; JSON payload now reuses the typed DaemonStatus results. |
tests/unit/daemon/test_daemon_status.py |
Adds tests asserting bounded probe behavior and that JSON payload rendering doesn’t duplicate probe work. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
## Summary Follow-up to the daemon-first #845 work after deploying #847/#850/#851 on the workstation. The live daemon exposed two deployment-scale problems: status payloads became huge with thousands of retryable live cursor failures, and full-ingest attempts could look stale while the worker was actually busy inside storage replacement. The same live run also exposed an unindexed SQLite foreign-key path that made conversation replacement scan millions of provider events. ## Problem During the Sinnix switch, `polylogued status --format json` returned quickly after #851 but emitted thousands of file paths. The active attempt was marked stale in `full_blob_copy`, while `py-spy` showed the daemon was actually in `_process_ingest_batch_sync -> replace_conversation_runtime_state_sync`. The live archive has ~4.0M `provider_events` rows, and `provider_events.source_message_id` referenced `messages(message_id)` without an index, so deleting messages during replacement caused repeated child-table scans and ~91GB of read I/O before I stopped the old service. ## Solution - Bound live cursor file samples in daemon status while preserving exact failed/excluded/retry counts. - Heartbeat full-ingest file scanning, blob materialization, and worker-write handoff with current path and payload-read counters. - Add schema v9 with indexes on `provider_events(source_message_id)` and `attachment_refs(message_id)` so message deletion during replacement has supporting FK indexes; v8 archives upgrade in place. - Split live-batch helper code and the new focused tests out of oversized modules, then refresh topology projections. ## Verification - `ruff check polylogue/sources/live/batch.py polylogue/sources/live/batch_support.py polylogue/storage/sqlite/schema_bootstrap.py tests/unit/sources/test_live_batch_support.py tests/unit/storage/test_schema_upgrades.py tests/unit/sources/test_live_watcher.py tests/unit/storage/test_backend.py` -> all checks passed. - `mypy polylogue/sources/live/batch.py polylogue/sources/live/batch_support.py polylogue/storage/sqlite/schema_bootstrap.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_batch_support.py tests/unit/storage/test_backend.py tests/unit/storage/test_schema_upgrades.py` -> success, no issues. - `pytest tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_batch_support.py tests/unit/daemon/test_daemon_status.py tests/unit/storage/test_backend.py tests/unit/storage/test_schema_upgrades.py tests/unit/devtools/test_verify_file_budgets.py -q` -> 110 passed. - `devtools verify-file-budgets` -> clean. - `devtools render-all --check` -> OK. - `devtools verify` -> all checks passed. - pre-push quick verification -> all checks passed. Ref #845
## Summary Keeps `polylogued status` responsive while the daemon is converging a large archive. ## Problem During the Sinnix deployment of #847/#850, the daemon was healthy and had live attempt state in SQLite, but `polylogued status --format json` exceeded a 30s timeout while convergence was starting. The status path was doing work that scales with archive size or takes deep archive locks: recursive blob-size walking, deep readiness imports, async insight status, and duplicate status probes. ## Solution Make the local daemon status path bounded: blob size is reported as unmeasured `0`, FTS readiness and insight freshness use small read-only SQLite probes, and JSON rendering reuses the typed `DaemonStatus` probe results instead of recomputing them. The live busy-daemon probe that timed out before returned in 1.7s with this branch. Ref #845 ## Verification - `ruff format --check polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.py` - `ruff check polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.py` - `mypy --strict polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.py` - `pytest tests/unit/daemon/test_daemon_status.py -q` → `8 passed in 10.84s` - `.venv/bin/polylogued status --format json` against the live busy daemon → returned in `1.731s` - `devtools verify` → `verify: all checks passed` - pre-push `devtools verify --quick` → `verify: all checks passed`
## Summary Follow-up to the daemon-first #845 work after deploying #847/#850/#851 on the workstation. The live daemon exposed two deployment-scale problems: status payloads became huge with thousands of retryable live cursor failures, and full-ingest attempts could look stale while the worker was actually busy inside storage replacement. The same live run also exposed an unindexed SQLite foreign-key path that made conversation replacement scan millions of provider events. ## Problem During the Sinnix switch, `polylogued status --format json` returned quickly after #851 but emitted thousands of file paths. The active attempt was marked stale in `full_blob_copy`, while `py-spy` showed the daemon was actually in `_process_ingest_batch_sync -> replace_conversation_runtime_state_sync`. The live archive has ~4.0M `provider_events` rows, and `provider_events.source_message_id` referenced `messages(message_id)` without an index, so deleting messages during replacement caused repeated child-table scans and ~91GB of read I/O before I stopped the old service. ## Solution - Bound live cursor file samples in daemon status while preserving exact failed/excluded/retry counts. - Heartbeat full-ingest file scanning, blob materialization, and worker-write handoff with current path and payload-read counters. - Add schema v9 with indexes on `provider_events(source_message_id)` and `attachment_refs(message_id)` so message deletion during replacement has supporting FK indexes; v8 archives upgrade in place. - Split live-batch helper code and the new focused tests out of oversized modules, then refresh topology projections. ## Verification - `ruff check polylogue/sources/live/batch.py polylogue/sources/live/batch_support.py polylogue/storage/sqlite/schema_bootstrap.py tests/unit/sources/test_live_batch_support.py tests/unit/storage/test_schema_upgrades.py tests/unit/sources/test_live_watcher.py tests/unit/storage/test_backend.py` -> all checks passed. - `mypy polylogue/sources/live/batch.py polylogue/sources/live/batch_support.py polylogue/storage/sqlite/schema_bootstrap.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_batch_support.py tests/unit/storage/test_backend.py tests/unit/storage/test_schema_upgrades.py` -> success, no issues. - `pytest tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_batch_support.py tests/unit/daemon/test_daemon_status.py tests/unit/storage/test_backend.py tests/unit/storage/test_schema_upgrades.py tests/unit/devtools/test_verify_file_budgets.py -q` -> 110 passed. - `devtools verify-file-budgets` -> clean. - `devtools render-all --check` -> OK. - `devtools verify` -> all checks passed. - pre-push quick verification -> all checks passed. Ref #845
Summary
Keeps
polylogued statusresponsive while the daemon is converging a large archive.Problem
During the Sinnix deployment of #847/#850, the daemon was healthy and had live attempt state in SQLite, but
polylogued status --format jsonexceeded a 30s timeout while convergence was starting. The status path was doing work that scales with archive size or takes deep archive locks: recursive blob-size walking, deep readiness imports, async insight status, and duplicate status probes.Solution
Make the local daemon status path bounded: blob size is reported as unmeasured
0, FTS readiness and insight freshness use small read-only SQLite probes, and JSON rendering reuses the typedDaemonStatusprobe results instead of recomputing them. The live busy-daemon probe that timed out before returned in 1.7s with this branch.Ref #845
Verification
ruff format --check polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.pyruff check polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.pymypy --strict polylogue/daemon/status.py tests/unit/daemon/test_daemon_status.pypytest tests/unit/daemon/test_daemon_status.py -q→8 passed in 10.84s.venv/bin/polylogued status --format jsonagainst the live busy daemon → returned in1.731sdevtools verify→verify: all checks passeddevtools verify --quick→verify: all checks passed