Repository navigation
fix(daemon): reduce catch-up replay amplification - #1459
Conversation
Append-only replay now writes only changed message, block, action, and provider-event rows instead of upserting every row from a full replayed session. This avoids turning tiny tails into full-session writes and prevents unchanged content-hash rows from being mutated by replay artifacts. Codex provider events now store compact provenance metadata for compactions, turn context, and response items rather than duplicating raw command output/history payloads already preserved in the raw blob and normalized message/action rows. The ingest logs also include changed/skipped row counts, serialized result size, max write duration, and RSS observations so the next live catch-up run can attribute remaining cost without another blind restart. Ref #1447
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 8 minutes and 29 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 (5)
✨ 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: Prevent hot JSONL session files from falling back to full ingest when the watcher observes a partial trailing line, and requeue failed live/catch-up paths for the normal retry loop. Problem: Live deployment of #1459 proved #1447 was not complete: a Codex file triggered `slow_write ... changed_messages=10309 ... elapsed_s=81.76`, drove IO PSI full avg10 to roughly 55%, and left the daemon in D-state. Append planning treated a grown tail without a complete newline as non-appendable, sending an actively written JSONL file into full ingest. Solution: Add an explicit deferred-append sentinel for incomplete JSONL tails; keep deferred paths out of full ingest and report them as retryable failed paths; requeue failed catch-up/live-drain paths into the existing pending watcher loop; return `LiveBatchMetrics` from `LiveWatcher._ingest_files` so callers can act on retryable failures. Verification: `pytest tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_batch_support.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_watcher_locking.py tests/unit/sources/test_live_hot_session_convergence.py -q` -> 83 passed; focused ruff and mypy on touched files passed; `devtools verify-file-budgets` -> clean; `devtools verify --quick` -> exit_code 0, total_duration_s 37.8. Ref #1447
Summary
Reduce daemon catch-up amplification for large Codex sessions by making append-only replay write only changed rows, compacting Codex provider-event payloads, and expanding ingest logs with row/result/RSS attribution fields.
Problem
Live #1447 deployment evidence showed
polyloguedreaching the 6G memory high mark and severe host IO PSI while processing a single 232MB Codex session. Inspection found a concrete append-only bug: the writer computed changed messages but still upserted every replayed message/block/action/provider-event tuple from the full parsed session. Codex provider events also duplicated raw command output and compaction history already retained in the raw blob and normalized message/action rows.Solution
Ref #1447. This does not close #1447: live catch-up still needs to prove whether first-time huge-session ingest requires chunked materialization beyond these amplification fixes.
Verification
pytest tests/unit/pipeline/test_ingest_append_replay.py tests/unit/pipeline/test_ingest_batch.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_codex_event_stream_contract.py -q→90 passed in 0.32sruff check polylogue/sources/parsers/codex.py polylogue/pipeline/services/ingest_batch/_core.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_codex_event_stream_contract.py tests/unit/pipeline/test_ingest_batch.py tests/unit/pipeline/test_ingest_append_replay.py→All checks passed!mypy polylogue/sources/parsers/codex.py polylogue/pipeline/services/ingest_batch/_core.py tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_codex_event_stream_contract.py tests/unit/pipeline/test_ingest_batch.py tests/unit/pipeline/test_ingest_append_replay.py→Success: no issues found in 6 source filesdevtools verify-file-budgets→file-size budgets: cleandevtools verify --quick→ exit 0,total_duration_s: 37.33devtools verify --quick→ exit 0,total_duration_s: 34.68