Skip to content

fix(daemon): repair raw failure lifecycle replay - #3746

Merged
Sinity merged 9 commits into
masterfrom
feature/fix/raw-failure-convergence-rebase
Aug 4, 2026
Merged

fix(daemon): repair raw failure lifecycle replay#3746
Sinity merged 9 commits into
masterfrom
feature/fix/raw-failure-convergence-rebase

Conversation

@Sinity

@Sinity Sinity commented Aug 4, 2026

Copy link
Copy Markdown
Owner

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

  • Reproduced the five failures before repair.
  • 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

    • Added clear raw-failure classifications for deferred, terminal, and unexplained outcomes.
    • Status views now show categorized failure counts, lifecycle details, and readable failure reports.
    • Deferred failures are identified as retryable, while terminal failures are retained and reported.
    • Improved handling of incomplete or unsupported source captures, including raw artifact preservation.
    • Added archive search and typed durable settings routes.
  • Documentation

    • Added audit records and registry entries documenting raw-failure preflight findings and safeguards.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a9a15192-697a-4e7b-8b6a-04997fd81d32

📥 Commits

Reviewing files that changed from the base of the PR and between 62bdd1c and 843ca77.

📒 Files selected for processing (18)
  • devtools/docs_surface.py
  • docs/README.md
  • docs/audits/2026-08-04-raw-failure-preflight.md
  • docs/audits/README.md
  • docs/plans/layering.yaml
  • polylogue/cli/commands/status.py
  • polylogue/core/raw_failure_evidence.py
  • polylogue/daemon/health.py
  • polylogue/daemon/status.py
  • polylogue/daemon/status_snapshot.py
  • polylogue/sources/live/batch.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • polylogue/storage/sqlite/archive_tiers/revision_governance.py
  • polylogue/storage/sqlite/archive_tiers/source_write.py
  • tests/unit/cli/test_status.py
  • tests/unit/daemon/test_health_check_paths.py
  • tests/unit/daemon/test_raw_failure_sample.py
  • tests/unit/sources/test_live_batch_support.py
📝 Walkthrough

Walkthrough

The 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.

Changes

Raw-failure lifecycle

Layer / File(s) Summary
Evidence taxonomy and archive persistence
polylogue/core/raw_failure_evidence.py, polylogue/storage/sqlite/archive_tiers/..., docs/plans/layering.yaml
Defines raw-failure evidence kinds and persists classified evidence through archive governance and raw-artifact upserts.
Live capture classification and cursor replay
polylogue/sources/live/batch.py, tests/unit/sources/test_live_batch_support.py
Classifies growing prefixes as deferred and incomplete or unsupported captures as terminal while retaining raw data and preventing terminal append replay.
Lifecycle-aware status and health reporting
polylogue/daemon/status.py, polylogue/daemon/health.py, polylogue/daemon/status_snapshot.py, polylogue/cli/commands/status.py, tests/unit/daemon/*, tests/unit/cli/test_status.py
Exposes deferred, terminal, and unexplained counts and samples in daemon and direct status paths. Health checks apply separate handling to each category. Archive route assertions and regression tests cover the new behavior.
Audit record and documentation registry
docs/audits/2026-08-04-raw-failure-preflight.md, docs/audits/README.md, docs/README.md, devtools/docs_surface.py
Adds the raw-failure preflight audit and registers it in the documentation indexes.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 49.02% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: repairing raw-failure lifecycle replay in the daemon.
Description check ✅ Passed The description includes complete Summary, Problem, Solution, and Verification sections and explains the primary behavior changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/raw-failure-convergence-rebase

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 399b059 and 62bdd1c.

📒 Files selected for processing (18)
  • devtools/docs_surface.py
  • docs/README.md
  • docs/audits/2026-08-04-raw-failure-preflight.md
  • docs/audits/README.md
  • docs/plans/layering.yaml
  • polylogue/cli/commands/status.py
  • polylogue/core/raw_failure_evidence.py
  • polylogue/daemon/health.py
  • polylogue/daemon/status.py
  • polylogue/daemon/status_snapshot.py
  • polylogue/sources/live/batch.py
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • polylogue/storage/sqlite/archive_tiers/revision_governance.py
  • polylogue/storage/sqlite/archive_tiers/source_write.py
  • tests/unit/cli/test_status.py
  • tests/unit/daemon/test_health_check_paths.py
  • tests/unit/daemon/test_raw_failure_sample.py
  • tests/unit/sources/test_live_batch_support.py

Comment thread polylogue/cli/commands/status.py Outdated
Comment thread polylogue/daemon/health.py Outdated
Comment thread polylogue/daemon/status.py Outdated
Comment thread polylogue/sources/live/batch.py Outdated
Sinity and others added 7 commits August 4, 2026 09:52
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>
@Sinity
Sinity force-pushed the feature/fix/raw-failure-convergence-rebase branch from 62bdd1c to 9351568 Compare August 4, 2026 07:54
Sinity and others added 2 commits August 4, 2026 10:08
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant