Repository navigation
fix(daemon): block offline maintenance during convergence - #1465
Conversation
Problem: live deployment showed a foreground doctor repair racing the daemon's catch-up convergence and forcing session insight rebuilds into SQLite lock failures. That made the daemon appear stuck on a valid large Codex session even after the broad startup maintenance scans were removed.\n\nWhat changed: add a shared live-daemon guard for offline maintenance, return target-level repair failures from doctor/repair when polylogued is running, and surface the same blocker through maintenance replay envelopes. Dry-run previews remain allowed. The topology projection is refreshed for the new guard module.\n\nVerification:\n- pytest tests/unit/storage/test_repair.py tests/unit/maintenance/test_idempotency.py tests/unit/sources/test_live_batch_convergence.py tests/unit/daemon/test_ingest_worker_handoff.py -q\n- ruff check polylogue/maintenance/offline_guard.py polylogue/storage/repair.py polylogue/maintenance/replay.py tests/unit/storage/test_repair.py tests/unit/maintenance/test_idempotency.py\n- mypy polylogue/maintenance/offline_guard.py polylogue/storage/repair.py polylogue/maintenance/replay.py tests/unit/storage/test_repair.py tests/unit/maintenance/test_idempotency.py\n- devtools verify --quick\n\nRef #1447
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 25 minutes and 5 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, 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 trial, open-source, and free plans. In all cases, review capacity refills continuously over time. 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 (7)
✨ 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: c28e27077c
ℹ️ 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".
## Summary Stops schema-blocked daemon startup from launching any DB-opening background work. The daemon can still expose degraded browser/API surfaces, but a critical schema preflight now blocks the watcher, periodic archive tasks, and the post-ingest converger. ## Problem After deploying #1465, the live service correctly refused live ingest because the archive metadata reported schema v12 against runtime v8, but it still started the convergence engine and periodic loops. On the real archive, `read_bytes` rose by about 1.17 GB in 5 seconds even though the watcher was blocked. That defeats the schema preflight's purpose and can keep the host under IO pressure. ## Solution - Keep `run_daemon_services` from creating WAL, heartbeat, convergence-debt, health, DB optimize, or status-snapshot tasks when `watcher_blocked` is true. - Keep the post-ingest `DaemonConverger` unconstructed under the same schema-blocked state. - Add a regression test proving the schema-blocked browser/API path closes cleanly without starting DB background work. Ref #1447 ## Verification - `pytest -q tests/unit/daemon/test_daemon_cli.py -q` -> `18 passed` - `ruff check polylogue/daemon/cli.py tests/unit/daemon/test_daemon_cli.py` -> `All checks passed!` - `mypy polylogue/daemon/cli.py tests/unit/daemon/test_daemon_cli.py` -> `Success: no issues found in 2 source files` - `devtools verify --quick` -> `exit_code: 0`, `total_duration_s: 35.03` - pre-push `devtools verify --quick` -> `exit_code: 0`, `total_duration_s: 33.62`
|
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
Blocks offline maintenance repair/cleanup paths while a live
polyloguedpidfile points at an actual daemon process, and surfaces that refusal through bothdoctor --repairandpolylogue maintenance runenvelopes. Dry-run previews remain allowed.Problem
During the #1447 live deployment pass after #1464, a foreground
polylogue doctor --repair --target session_insightsprocess appeared whilepolyloguedwas catching up a large Codex session. The repair process held the SQLite lock and daemon insight convergence failed withOperationalError: database is locked, leaving the latest live ingest attempt stuck inrunning/convergenceuntil shutdown. That is not valid daemon convergence behavior; offline repair must not race the live daemon-owned writer.Solution
polylogue.maintenance.offline_guardto verify adaemon.pidbelongs to a livepolyloguedprocess.storage.repair.run_selected_maintenancereturn target-level failures instead of starting offline repair/cleanup when the daemon is live.OfflineMaintenanceBlockedfailure samples under the same condition.This preserves daemon scope: the daemon still owns live convergence and should drain valid inputs; out-of-band offline repair now requires stopping the daemon first.
Verification
pytest tests/unit/storage/test_repair.py tests/unit/maintenance/test_idempotency.py tests/unit/sources/test_live_batch_convergence.py tests/unit/daemon/test_ingest_worker_handoff.py -q→22 passed in 2.91sruff check polylogue/maintenance/offline_guard.py polylogue/storage/repair.py polylogue/maintenance/replay.py tests/unit/storage/test_repair.py tests/unit/maintenance/test_idempotency.py→All checks passed!mypy polylogue/maintenance/offline_guard.py polylogue/storage/repair.py polylogue/maintenance/replay.py tests/unit/storage/test_repair.py tests/unit/maintenance/test_idempotency.py→Success: no issues found in 5 source filesdevtools verify-file-budgets→file-size budgets: cleandevtools verify-topology→realized=829 declared=829 blocking=Falsedevtools render-all --check→ passeddevtools verify --quick→exit_code: 0,total_duration_s: 36.4devtools verify --quick→exit_code: 0,total_duration_s: 34.44Ref #1447