Repository navigation
fix(daemon): defer hot insight rebuilds - #1468
Conversation
Problem: live deploy after the failed-file backoff fix still showed severe physical reads on tiny appends to very large active Codex session files. The source payload reads were only a few KB, so the remaining pressure came from derived session insight rebuilds rehydrating whole conversations on every append. What changed: keep archive ingest and targeted FTS repair immediate, but defer session insight rebuild for source files at least 64 MiB that were modified within the last 60 seconds. The deferral records convergence debt instead of claiming success, retries on a fixed 60 second quiet-window cadence, and shortens the periodic debt drain to 60 seconds. Verification: pytest -q tests/unit/daemon/test_convergence_stages.py tests/unit/daemon/test_daemon_convergence.py tests/unit/daemon/test_daemon_cli.py tests/unit/sources/test_live_catchup_planning.py; pytest -q tests/unit/sources/test_live_watcher.py; devtools verify --quick. Ref #1447
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 33 minutes and 59 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 (6)
✨ 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: ed8bb77f53
ℹ️ 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 Daemon FTS convergence now trusts an FTS surface only when durable freshness state is `ready` and the expected live sync triggers are present, avoiding whole-conversation docsize scans on every append to huge active sessions. This also adds targeted session-insight FTS repair so duplicate/stale insight FTS rows can be fixed without rebuilding all session insights. ## Problem After #1468 was deployed, hot insight deferral worked, but live `polylogued` still read `879,820,800` physical bytes over a 10s append sample while `source_payload_read_bytes` stayed in the KB range. The remaining broad read path was `_fts_repair_needs_for_conversations`, which exact-scanned `messages`/`action_events` against FTS docsize tables for each changed huge conversation even when FTS was already marked ready and triggers were present. ## Solution - `polylogue/daemon/convergence_stages.py` skips exact per-conversation FTS docsize scans for `messages_fts` and `action_events_fts` only when the FTS table, docsize table, all expected sync triggers, and `fts_freshness_state=ready` agree. - Missing tables, stale/unknown freshness, missing freshness state, or missing triggers still use the existing exact scan/repair path. - `polylogue/storage/fts/fts_lifecycle.py` exposes `rebuild_session_insight_fts_sync` for targeted session insight FTS rebuilds. - `polylogue/storage/repair.py` uses the new repair assessment helper to clean FTS-only insight debt without forcing a full session insight rebuild. Closes #1447 ## Verification - `pytest -q tests/unit/daemon/test_convergence_stages.py tests/unit/storage/test_fts_trigger_lifecycle.py tests/integration/test_health.py::TestMaintenanceSelection::test_session_insight_repair_cleans_duplicate_fts_rows` -> `26 passed in 0.57s` - `devtools verify-topology` -> `realized=830 declared=830 blocking=False` - `devtools render-all --check` -> pass - `devtools verify --quick` -> `exit_code 0`, `total_duration_s 34.84` - pre-push `devtools verify --quick` -> `exit_code 0`, `total_duration_s 34.52` ## Changelog Skip: internal daemon convergence and repair behavior only. ## Risks and Follow-ups The live daemon is intentionally still stopped until this lands, updates the Sinnix flake input, and is deployed. The next validation step is another live `/proc/$pid/io`, cgroup memory, cursor/debt, and ingest-attempt sample against the real archive.
|
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
Defers expensive session-insight rebuilds for very large source files while they are still actively appending, without reducing daemon convergence scope. Archive writes and targeted FTS repair still run immediately; insight convergence becomes durable debt until the source is quiet.
Problem
After #1467 was deployed, the failed-file hot requeue loop stopped, but live monitoring still showed severe physical reads on tiny appends to huge active Codex sessions.
source_payload_read_byteswas only a few KB per attempt while/proc/$pid/ioshowed roughly 2.36 GB of reads over 10s, pointing at derived session insight rebuilds rehydrating whole conversations on every append.Solution
Ref #1447
Verification
pytest -q tests/unit/daemon/test_convergence_stages.py tests/unit/daemon/test_daemon_convergence.py tests/unit/daemon/test_daemon_cli.py tests/unit/sources/test_live_catchup_planning.py-> 45 passedpytest -q tests/unit/sources/test_live_watcher.py-> 60 passeddevtools verify --quick-> exit_code 0, total_duration_s 34.58devtools verify --quick-> exit_code 0, total_duration_s 34.61