Repository navigation
fix(daemon): defer incomplete live appends - #1460
Conversation
Problem: deployed live catch-up still allowed a hot Codex JSONL file to fall back to full ingest when the watcher observed a partial trailing line. That replay rewrote thousands of rows, drove severe IO PSI, and stranded transient catch-up failures until restart. What changed: append planning now distinguishes incomplete append tails from true non-appendable files, reports them as retryable failed paths, and keeps them out of full ingest. Catch-up and live pending drains now requeue failed paths so transient locks or incomplete writer flushes are retried by the normal watcher loop. Verification: ruff check polylogue/sources/live/batch.py polylogue/sources/live/watcher.py tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py; mypy polylogue/sources/live/batch.py polylogue/sources/live/watcher.py tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py; pytest tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py::test_append_plan_defers_when_tail_has_no_complete_line tests/unit/sources/test_live_watcher.py::test_incomplete_append_is_requeued_not_full_ingested tests/unit/sources/test_live_watcher.py::test_append_plan_reads_only_completed_tail tests/unit/sources/test_live_watcher_locking.py -q. Ref #1447
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughImplements a deferred-append and retry mechanism to handle incomplete file appends during batch ingestion. Files with incomplete content (no trailing newline) are marked for later retry instead of being treated as full-ingest candidates, enabling automatic re-processing when more data arrives. ChangesDeferred append and retry mechanism for incomplete file ingestion
Sequence Diagram(s)sequenceDiagram
participant Watcher
participant _ingest_files
participant BatchProcessor
participant _requeue_failed_paths
participant pending_set
Watcher->>_ingest_files: call with file batch
_ingest_files->>BatchProcessor: ingest_files()
BatchProcessor-->>_ingest_files: metrics with failed_paths
_ingest_files-->>Watcher: return metrics
Watcher->>_requeue_failed_paths: pass metrics
_requeue_failed_paths->>pending_set: re-add failed_paths
_requeue_failed_paths-->>Watcher: done
Watcher->>Watcher: _ensure_pending_scheduled()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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
Prevents hot JSONL session files from falling back to full ingest when the watcher observes a partial trailing line, and requeues failed live/catch-up paths for the normal retry loop.
Problem
Live deployment of #1459 proved #1447 is still open: catch-up reached watching, but a Codex file then triggered
slow_write ... changed_messages=10309 ... elapsed_s=81.76, drove IO PSI full avg10 to ~55%, and left the daemon in D-state. The append planner was treating a grown tail with no complete newline as "not appendable", which sent an actively-written JSONL file into full ingest instead of waiting for the writer to finish the line.Solution
LiveBatchMetricsfromLiveWatcher._ingest_filesso callers can act on retryable failures.Ref #1447
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 passedruff check polylogue/sources/live/batch.py polylogue/sources/live/batch_support.py polylogue/sources/live/watcher.py tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_batch_support.py tests/unit/sources/test_live_hot_session_convergence.py→ passedmypy polylogue/sources/live/batch.py polylogue/sources/live/batch_support.py polylogue/sources/live/watcher.py tests/unit/sources/test_live_catchup_planning.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_live_batch_support.py tests/unit/sources/test_live_hot_session_convergence.py→ passeddevtools verify-file-budgets→ cleandevtools verify --quick→ exit_code 0, total_duration_s 37.8Summary by CodeRabbit
Bug Fixes
Refactor
Tests