Repository navigation
fix(daemon): trust ready FTS triggers on live appends - #1469
Conversation
Problem: after #1468, hot insight deferral worked but live polylogued still read 879,820,800 bytes over a 10s append sample while source_payload_read_bytes stayed in the KB range. The remaining broad read came from exact per-conversation FTS docsize scans over huge active Codex sessions. What changed: daemon FTS convergence now skips exact missing-row scans only when a surface has durable ready freshness state and all live sync triggers are present. Missing tables, stale/unknown freshness, or missing triggers still take the exact scan and repair path. Session-insight FTS repair also gains a targeted rebuild path so duplicate insight FTS rows do not force a full insight rebuild. 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; devtools verify-topology; devtools render-all --check; devtools verify --quick. Ref #1447
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 13 minutes and 11 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 (9)
✨ 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 Update daemon append writes so conversation stats are maintained from changed tail-message deltas instead of recounting every message in the conversation after each append. Problem After #1469 was deployed, live catch-up still produced severe physical reads even though source payload reads were tiny, FTS freshness rows were ready, and hot insight rebuilds were being deferred. The remaining broad read was the append write path: `_append_conversation` always called `_upsert_stats_from_messages`, which scans the full `messages` set for the active conversation after every tiny append. Live evidence from the deployed daemon: - catch-up scanned `11886` files and needed `309` files / `508.6 MB`; - FTS freshness rows were `ready` for the live surfaces; - `/proc/$pid/io` over 10s still showed `1,440,432,128` read bytes; - recent attempts recorded tiny `source_payload_read_bytes` while `input_bytes` repeated huge source-file sizes. Solution - Add `polylogue/pipeline/services/ingest_batch/_append_stats.py` for append-only stats helpers. - Reuse existing message signatures to compare content hashes and carry old stat counters. - Apply deltas only for changed tail messages during append writes. - Fall back to the full recount only when the `conversation_stats` row is missing, including unchanged append replays that need stats repair. - Keep non-append writes on the existing full stats path. Ref #1447 Verification - `pytest -q tests/unit/pipeline/test_ingest_append_replay.py tests/unit/pipeline/test_ingest_batch.py` -> `29 passed in 0.24s` - `mypy polylogue/pipeline/services/ingest_batch/_core.py polylogue/pipeline/services/ingest_batch/_append_stats.py tests/unit/pipeline/test_ingest_append_replay.py` -> `Success: no issues found in 3 source files` - `devtools verify --quick` -> `exit_code 0`, `total_duration_s 38.25` - pre-push `devtools verify --quick` -> `exit_code 0`, `total_duration_s 36.11`
polylogue-gibn1, decisive: instrumented the sole consumer of summary.fts_repair_session_ids (_commit_sync_ingest_side_effects) and it never printed across five sessions and sixty messages in the failing convergence-evidence test. The repair is nested inside `if transaction_started`, so a route with an externally managed transaction skips FTS repair along with every other post-write side effect. Eliminated: repair_message_fts (defaults True everywhere, no daemon override), the repair queue itself (content_changed appends unconditionally), the invariant reader, and the triggers. Three independent places each assume another will populate the index: replay defers the reinsert, ingest-side repair never runs, and the path-scoped convergence check is a hardcoded `return False`. Read the #1498 cascade retro as CLAUDE.md requires; its closed list names the adjacent history (#1462, #1469, #1472, #1500, #1502), several of which narrowed FTS repair to avoid redundant work. Those PR bodies are the place to start. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HWcPJJJvuF25CqVwTFgSQC
Summary
Daemon FTS convergence now trusts an FTS surface only when durable freshness state is
readyand 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
polyloguedstill read879,820,800physical bytes over a 10s append sample whilesource_payload_read_bytesstayed in the KB range. The remaining broad read path was_fts_repair_needs_for_conversations, which exact-scannedmessages/action_eventsagainst FTS docsize tables for each changed huge conversation even when FTS was already marked ready and triggers were present.Solution
polylogue/daemon/convergence_stages.pyskips exact per-conversation FTS docsize scans formessages_ftsandaction_events_ftsonly when the FTS table, docsize table, all expected sync triggers, andfts_freshness_state=readyagree.polylogue/storage/fts/fts_lifecycle.pyexposesrebuild_session_insight_fts_syncfor targeted session insight FTS rebuilds.polylogue/storage/repair.pyuses 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.57sdevtools verify-topology->realized=830 declared=830 blocking=Falsedevtools render-all --check-> passdevtools verify --quick->exit_code 0,total_duration_s 34.84devtools verify --quick->exit_code 0,total_duration_s 34.52Changelog
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.