Repository navigation
fix(daemon): bound blob cleanup and append planning - #1428
Conversation
Problem: polylogue status used a 5s daemon timeout and treated any timeout as daemon absence. On the live workstation archive, the daemon status payload can take around 20s after a rebuild, so the CLI incorrectly reported no daemon while /api/status eventually returned a healthy payload.\n\nWhat changed: keep the fast bare-command probe at 1s, but raise the explicit status command timeout to 30s so operator-requested status can wait for the full archive health payload.\n\nVerification: python import check for _FULL_TIMEOUT_S == 30.0; pytest tests/unit/cli/test_json_envelope_contract.py::TestStatusJsonContract -q. Broad tests/unit/cli remains red from unrelated existing help snapshot/plain-output/cursor failures on this branch.
Document why the bare command keeps a 1s daemon probe while explicit status waits up to 30s for large archive health payloads.\n\nVerification: python import check for status timeout constants; pytest tests/unit/cli/test_json_envelope_contract.py::TestStatusJsonContract -q.
Problem: the live archive had 20,242 unreferenced blob files consuming 419,141,710,487 bytes, but the advertised orphaned_blobs maintenance target was not wired into the resumable executor and dry-runs only accounted the bounded sample. Live append planning also read every byte from a stale cursor offset to EOF and retained all append payloads before ingestion, which could balloon daemon RSS on large JSONL sessions.\n\nWhat changed: wire archive cleanup targets into maintenance replay, make orphaned blob dry-runs account the full orphan set, use read-only connections for planning/cleanup reads, add a direct exact orphaned_blobs planning path, make shallow archive cleanup preview explicitly truncated, and cap append plans at 16 MiB so large tails use the existing streaming full-ingest path.\n\nVerification: pytest tests/unit/storage/test_repair_blobs.py tests/unit/maintenance/test_idempotency.py tests/unit/maintenance/test_preview.py tests/unit/sources/test_live_watcher.py -q --tb=short; pytest tests/unit/sources/test_live_batch_support.py -q --tb=short; python -m mypy polylogue/maintenance polylogue/storage/repair.py polylogue/sources/live tests/unit/storage/test_repair_blobs.py tests/unit/sources/test_live_watcher.py tests/unit/maintenance/test_preview.py tests/unit/maintenance/test_idempotency.py; devtools verify --quick.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements deterministic orphan blob repair across the maintenance system, enforces payload limits for live session ingestion, and refines CLI database path handling. The changes integrate orphaned blob cleanup into planning and preview flows with shallow/full staleness modes, extend replay dispatch for multiple repair targets, and add comprehensive test coverage. ChangesOrphaned blobs maintenance support
Live ingestion append plan payload limit
CLI and configuration refinements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd1d856716
ℹ️ 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".
|
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. |
|
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
Fixes two production blockers discovered on the live archive: orphaned blob cleanup was advertised but not executable through the resumable maintenance path, and live append planning could retain large JSONL tails in daemon memory before ingestion.
Problem
The live blob store is 422.10 GiB while
raw_conversationsreferences only 31.44 GiB. A filesystem/DB comparison found 20,242 orphan blob files totaling 419,141,710,487 bytes, with no pending blob leases. The normalpolylogue maintenance run --target orphaned_blobs --dry-runpath failed as an unsupported replay target, and the older dry-run accounting only measured the bounded orphan sample.Separately,
LiveBatchProcessor._append_planread from cursor offset to EOF and retained every append payload before processing. A stale cursor on a large Claude/Codex JSONL session could allocate hundreds of MiB to GiB per file and multiply across a batch, matching the daemon RSS ballooning reports.The branch also includes the preceding status-timeout fix/docs so
polylogue statusremains usable on large archives.Solution
polylogue.maintenance.replay, includingorphaned_blobs.maintenance plan --target orphaned_blobspath that reports the real reclaim count/bytes without broad status scans.maintenance gc-historyto readconfig.db_path(polylogue.db) instead of the stalearchive.dbpath.Verification
pytest tests/unit/storage/test_repair_blobs.py tests/unit/maintenance/test_idempotency.py tests/unit/maintenance/test_preview.py tests/unit/sources/test_live_watcher.py -q --tb=shortpytest tests/unit/sources/test_live_batch_support.py -q --tb=shortpython -m mypy polylogue/maintenance polylogue/storage/repair.py polylogue/sources/live tests/unit/storage/test_repair_blobs.py tests/unit/sources/test_live_watcher.py tests/unit/maintenance/test_preview.py tests/unit/maintenance/test_idempotency.pydevtools verify --quick→ exit_code 0, total_duration_s 36.96 locally; pre-push rerun exit_code 0, total_duration_s 34.78.polylogue maintenance run --target orphaned_blobs --dry-run --output-format jsonreported 20,242 orphan blobs and 419,141,710,487 bytes.polylogue maintenance plan --target orphaned_blobs --output-format jsoncompleted in ~2.6s with the same count.polylogue maintenance preview --scope archive_cleanup --shallow --output-format jsoncompleted in ~3.0s and reports truncated rows.Operational note
This PR does not delete the live orphan blobs. Reclaiming the 419,141,710,487 bytes requires an explicit destructive maintenance run after review/deploy:
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation