fix(daemon): repair raw failure lifecycle replay - #3746
Conversation
|
Warning Review limit reached
Next review available in: 35 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (18)
📝 WalkthroughWalkthroughThe change adds typed raw-failure evidence, durable artifact upserts, lifecycle-aware ingestion and cursor handling, and deferred/terminal/unexplained status reporting. It also adds health-check coverage, status tests, route assertions, and a preflight audit record. ChangesRaw-failure lifecycle
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant SourceFile
participant LiveBatch
participant ArchiveStore
participant StatusCommand
SourceFile->>LiveBatch: provide JSONL capture
LiveBatch->>ArchiveStore: record raw capture and evidence
StatusCommand->>ArchiveStore: read raw-failure evidence
ArchiveStore-->>StatusCommand: return lifecycle counts and samples
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@polylogue/cli/commands/status.py`:
- Around line 2273-2281: Update the raw_total calculation in the direct status
flow to include raw_failure_status["raw_maintenance_failures"] alongside parse
and validation failures, while preserving the existing reporting behavior for
raw failures.
In `@polylogue/daemon/health.py`:
- Around line 706-708: Update the severity/message branch in the health
reporting logic for deferred work so that when deferred retries and terminal
rejections coexist while total_failures is zero, the warning includes both
deferred and terminal counts. Add a regression test covering the mixed
deferred-and-terminal case and verify the resulting warning preserves the
pending-work context.
In `@polylogue/daemon/status.py`:
- Around line 1030-1058: The failed-session lifecycle scan currently
materializes every row with fetchall(); update the query handling around
_raw_failure_lifecycle to iterate the database cursor directly while retaining
only the first 50 sample rows. Preserve complete lifecycle counts for deferred,
terminal, and unexplained failures without loading the full failure backlog into
memory.
In `@polylogue/sources/live/batch.py`:
- Around line 168-187: Update _hot_capture_prefix_is_proven to accept the
already-computed blob_hash instead of requiring payload, and compare the live
prefix fingerprint directly against that hash while retaining the growth and
error checks. Update the call in _ingest_full_records_archive to pass blob_hash,
so streamed captures with payload=None can still be classified as deferred hot
JSONL captures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2b517bd5-e8c9-44c4-8138-c6c54b0d3de9
📒 Files selected for processing (18)
devtools/docs_surface.pydocs/README.mddocs/audits/2026-08-04-raw-failure-preflight.mddocs/audits/README.mddocs/plans/layering.yamlpolylogue/cli/commands/status.pypolylogue/core/raw_failure_evidence.pypolylogue/daemon/health.pypolylogue/daemon/status.pypolylogue/daemon/status_snapshot.pypolylogue/sources/live/batch.pypolylogue/storage/sqlite/archive_tiers/archive.pypolylogue/storage/sqlite/archive_tiers/revision_governance.pypolylogue/storage/sqlite/archive_tiers/source_write.pytests/unit/cli/test_status.pytests/unit/daemon/test_health_check_paths.pytests/unit/daemon/test_raw_failure_sample.pytests/unit/sources/test_live_batch_support.py
Problem Stopped daemon convergence presented retained hot captures, terminal input rejections, and unexplained parser failures as one retryable failure bucket. What changed Record closed source-tier evidence for deferred hot JSONL captures and terminal corrupt or unsupported payloads. Surface the lifecycle in daemon and direct CLI status, with a read-only preflight census and production-route tests. Compatibility Existing raw rows remain unexplained until a reviewed post-deploy route records new typed evidence. No archive data, cursor, or blob was mutated. Co-Authored-By: Codex <noreply@openai.com>
Problem: A terminal incomplete JSONL capture was retained as successful raw evidence, but its cursor enabled append-only parsing after the source completed. The append lacked the session prefix and deferred indefinitely. What changed: detect cursor prefixes backed by terminal raw-failure evidence and route later growth through full replay. The regression verifies durable terminal classification, successful raw retention, and eventual materialization of the completed source. Co-Authored-By: Codex <noreply@openai.com>
Problem: Health collectors that predate lifecycle classification omit unexplained_failures. Treating that absent field as zero hid their observed parse and validation failures. What changed: distinguish a missing lifecycle field from an explicit zero and derive the former from parse plus validation counts. Co-Authored-By: Codex <noreply@openai.com>
Problem: The hardcoded health scheduling contract predated two liveness checks now present in the verification registry. What changed: include excluded cursor vocabulary and stalled append cursor freshness in the explicit expected set. Co-Authored-By: Codex <noreply@openai.com>
Problem: The static status catalog fell behind the public async Polylogue facade, leaving similarity search and durable settings methods unclassified. What changed: route the four methods through their actual embeddings or user-tier paths and assert those classifications. Co-Authored-By: Codex <noreply@openai.com>
Typed raw failures retain incomplete source evidence without a materialized session. Route a later growth observation through full replay and resolve durable evidence from the configured archive root. Co-Authored-By: Codex <noreply@openai.com>
An active index generation can live outside the archive root. Resolve raw-failure evidence from the durable root source tier and cover pointer-selected status reads. Co-Authored-By: Codex <noreply@openai.com>
62bdd1c to
9351568
Compare
Verify streamed JSONL blobs against their captured hash, stream raw failure accounting, and retain every raw-failure state in direct operator summaries. Co-Authored-By: Codex <noreply@openai.com>
Problem: raw-failure cursors compared their durable source-row identity to a blob digest, hot prefix proof accepted in-place rewrites, and stopped status followed the active index generation for durable evidence.\n\nWhat changed: bind failure cursors and replay queries through source raw IDs, use stable pre/post file observations for hot captures, aggregate lifecycle totals in SQLite with a bounded sample query, and read direct status evidence from the configured archive root.\n\nRef #3746.\n\nCo-Authored-By: Codex <noreply@openai.com>
Summary
Repairs raw-failure lifecycle handling after the current-master replay exposed five failing routes.
Problem
Terminal malformed JSONL evidence was treated inconsistently with later completed input, legacy collectors could hide raw failures from health, and public route and liveness catalogs had drifted.
Solution
Replays a terminally retained raw once its source file grows, preserves legacy raw-failure signals, refreshes the actual facade and verification registries, and makes the affected tests assert real storage and daemon behavior.
Verification
devtools test tests/unit/cli/test_status.py tests/unit/sources/test_live_batch_support.py tests/unit/daemon/test_health_check_paths.py tests/unit/daemon/test_raw_failure_sample.py: 212 passed.devtools verify --quick: 23 checks passed.Ref polylogue-dyica.
Summary by CodeRabbit
New Features
Documentation