Repository navigation
perf(maintenance): target stale session insight repairs - #1471
Conversation
Live daemon work showed repeated large session insight workloads are the main remaining risk after source reads, FTS scans, and append stats recounts were narrowed. The repair surface already has candidate discovery for stale session profiles; use it before falling back to a whole-archive session insight rebuild.\n\nWhen the caller does not provide explicit conversation ids and row debt exists, rebuild the stale profile candidates first. Refresh status afterward and only run the broad rebuild if the targeted pass did not restore readiness, preserving correctness while making the common stale-profile repair bounded.\n\nFocused verification:\n- pytest -q tests/unit/storage/test_repair.py tests/integration/test_health.py::TestMaintenanceSelection::test_session_insight_repair_cleans_duplicate_fts_rows -> 11 passed\n- mypy polylogue/storage/repair.py tests/unit/storage/test_repair.py -> success\n\nRef #1447
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 55 minutes and 13 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 (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 |
Summary Skip post-write message/action FTS repair when live FTS triggers were already present for the write. Problem After #1470 and #1471 were deployed, live validation still showed `polylogued` reading about `2.34 GB` over 10 seconds with IO full avg10 around `20%`, while logs showed hot insight rebuilds were deferred and append writes were small. The remaining broad path was `commit_archive_write_effects`: it always called `repair_message_fts_index_sync` and `repair_action_fts_index_sync` for changed conversations. On normal live writes the FTS triggers already maintain those rows, so the repair did a redundant delete/reinsert of the whole conversation FTS surface after every append. Solution - Record whether message/action FTS triggers were present before write side effects run. - Always call `ensure_fts_triggers_sync` to restore missing triggers. - If triggers were already live, trust them and skip the redundant repair. - If triggers were missing or suspended, keep the existing targeted repair path after trigger restoration. - Add tests for both paths. This keeps the hard FTS freshness contract: live-triggered writes stay fresh immediately, and missing/suspended triggers still force repair. Ref #1447 Verification - `pytest -q tests/unit/archive/test_write_gateway.py tests/unit/pipeline/test_ingest_append_replay.py` -> `9 passed in 0.20s` - `mypy polylogue/archive/write_effects.py tests/unit/archive/test_write_gateway.py` -> `Success: no issues found in 2 source files` - `devtools verify --quick` -> `exit_code 0`, `total_duration_s 39.71` - pre-push `devtools verify --quick` -> `exit_code 0`, `total_duration_s 34.62`
Summary
Use stale session-profile candidate IDs for session-insight repair before escalating to a whole-archive session insight rebuild.
Problem
Live daemon catch-up work has repeatedly shown that full session insight rebuilds are one of the largest remaining IO/RAM risks. The status layer already exposes stale profile candidates, but
repair_session_insightsignored that bounded set and calledrebuild_session_insights_sync(..., conversation_ids=None)whenever no explicit IDs were supplied.Solution
session_profile_repair_candidate_ids_syncinto the repair path.Ref #1447
Verification
pytest -q tests/unit/storage/test_repair.py tests/integration/test_health.py::TestMaintenanceSelection::test_session_insight_repair_cleans_duplicate_fts_rows->11 passed in 0.18smypy polylogue/storage/repair.py tests/unit/storage/test_repair.py->Success: no issues found in 2 source filesdevtools verify --quick->exit_code 0,total_duration_s 37.23