Skip to content

fix(daemon): recover typed CAS frontier failures - #3918

Merged
Sinity merged 2 commits into
masterfrom
feature/reindex/raw-failure-finalization
Aug 10, 2026
Merged

fix(daemon): recover typed CAS frontier failures#3918
Sinity merged 2 commits into
masterfrom
feature/reindex/raw-failure-finalization

Conversation

@Sinity

@Sinity Sinity commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

Route typed CAS-frontier failures into stopped-daemon raw recovery only when the existing repair selector authorizes replay. The probe recognizes canonical and historical CAS carriers by exact raw-artifact coordinate, admits previously parsed but unmaterialized raws, and delegates materialization to the existing repair engine.

Problem

raw_materialization already selected deferred_cas_frontier and deferred_codex_cas_frontier as retry authority. The daemon's path-scoped raw_parse_recovery probe initially recognized only untyped error strings. Its first typed-carrier version then diverged from the executor in two ways: validation-failed raws stayed pending forever, while previously parsed but unmaterialized CAS raws were skipped.

Solution

polylogue/daemon/convergence_stages.py imports the established core replay-authority vocabulary and requires the same raw ID, origin, source path, source index, partial-decode support status, failed-validation exclusion, and materialization guard before returning pending work. It keeps legacy raw retries unparsed-only while allowing typed CAS authority for previously parsed raws. tests/unit/daemon/test_raw_parse_recovery.py creates real file-backed temporary archive tiers, writes authority and parse transitions through ArchiveStore, and exercises raw_parse_recovery through the production repair engine until the session materializes.

Bead Whole-Bead disposition Evidence Remaining scope
polylogue-dyica Partial 08c363b0d; stopped-daemon route regressions; quick gate Current live census, deployment, backup-gated dry-run/apply, immutable receipt, and reprocessing remain under polylogue-reindex-source-remediation.
polylogue-dyica.1 Satisfied implementation slice Canonical, historical, validation-failed, and previously-parsed carrier route tests; pre-fix reproductions; quick gate Its required live successor exists through parent polylogue-dyica and remains open as polylogue-reindex-source-remediation; no live apply is claimed here.

Verification

devtools test tests/unit/daemon/test_raw_parse_recovery.py -k 'validation_failed_cas_frontier_failure or previously_parsed_cas_frontier_failure' failed before this correction with two inverse stage.check(path) assertions. devtools test tests/unit/daemon/test_raw_parse_recovery.py then reported 19 passed. devtools verify --quick completed all 24 checks with exit 0. The suite uses real temporary source.db and index.db files, not an in-memory substitute. Reverting either eligibility condition restores its corresponding production-route failure, so the regressions constrain the probe rather than a test-local replica.

Adversarial review notes

The late Codex review found two actionable probe/executor eligibility mismatches. This update adds red file-backed regressions for both: validation-failed rows are not pending, and previously parsed, unmaterialized CAS rows drain through the repair engine.

What this PR does not do

No production archive, daemon, migration, deployment, reprocess, dry-run apply, or receipt was mutated. The 2026-08-04 preflight observed 112 raw failures, including 111 parse failures and one maintenance failure. This PR does not remeasure that live population. Its current size and any reduction remain unknown until the open successor runs a fresh backup-gated census and reviewed apply.

Problem: stopped-daemon raw recovery ignored canonical and historical CAS frontier evidence even though the production repair selector accepted both as replay authority.

What changed: correlate the daemon probe with the exact raw-artifact coordinate and existing typed replay-authority vocabulary. Add a temporary-SQLite route test that persists the failure through ArchiveStore and drains it through the daemon recovery stage and repair engine.

Ref polylogue-dyica and polylogue-dyica.1.

Co-authored-by: Codex <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Raw parse recovery now treats deferred raw-authority failure evidence as pending work. Parametrized tests cover canonical and historical CAS-frontier failures and verify that recovery materializes the affected raw row.

Changes

Raw parse recovery

Layer / File(s) Summary
Detect and validate deferred evidence
polylogue/daemon/convergence_stages.py, tests/unit/daemon/test_raw_parse_recovery.py
The pending-count query recognizes deferred raw-authority evidence. Tests verify detection, retry, and session materialization for canonical and historical CAS-frontier failures.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly identifies the daemon recovery fix for typed CAS frontier failures.
Description check ✅ Passed The description covers the required summary, problem, solution, verification, bead dispositions, scope, and follow-up details.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/reindex/raw-failure-finalization

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e194d2613

ℹ️ 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".

Comment on lines +939 to +940
AND failure_evidence.artifact_kind IN ({replay_authority_placeholders})
AND failure_evidence.support_status = ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude validation-failed raws from CAS recovery

When an exact CAS carrier belongs to a raw whose validation_status is failed, this new EXISTS marks the path pending even though the executor explicitly rejects such rows in storage/repair.py:3952-3955. Consequently, execute performs no repair, recomputes the same positive count, and returns False, so this stage's false_means_pending behavior preserves and repeatedly retries convergence debt indefinitely. Mirror the executor's validation-status predicate in this probe so only raws actually authorized for replay are selected.

AGENTS.md reference: AGENTS.md:L168-L177

Useful? React with 👍 / 👎.

OR r.parse_error = 'OperationalError: database is locked'
OR r.parse_error LIKE 'decode:%No such file or directory:%'
OR r.parse_error LIKE 'membership_replay_conflict:%'
OR EXISTS (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include previously parsed raws with CAS authority

When replaying a previously successful raw after its derived index row is lost, a RawCASFrontierError leaves the old parsed_at_ms intact because _raw_parse_failure_state does not update that field. Although repair.py deliberately admits these already-parsed, unmaterialized rows, this new typed-evidence branch remains inside the outer r.parsed_at_ms IS NULL condition, so the stopped-daemon probe reports no pending work and never invokes the repair engine. Move the CAS-authority case outside that parsed-at restriction, while retaining the materialization checks.

Useful? React with 👍 / 👎.

Problem:
The stopped-daemon pending probe could retain validation-failed CAS rows
and skip previously parsed, unmaterialized CAS rows, unlike the repair
selector it triggers.

What changed:
Mirror failed-validation eligibility and separate unparsed legacy retries
from typed CAS retry authority. File-backed regressions cover both routes.

Ref polylogue-dyica.

Co-Authored-By: Codex <noreply@openai.com>
@Sinity

Sinity commented Aug 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 08c363b0de

ℹ️ 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".

@Sinity
Sinity merged commit ccb73aa into master Aug 10, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the feature/reindex/raw-failure-finalization branch August 10, 2026 14:28
Sinity added a commit that referenced this pull request Aug 10, 2026
## Summary

Record the verified closure of source-index ground-truth and testmon
seed-contract work.

## Problem

The implementation PRs are merged, but the authoritative Beads export
still reported their residuals as open.

## Solution

Close the four satisfied verification residuals with exact merged-PR and
verification evidence. Parent raw-failure/live remediation remains open.
The separate audit-toolchain Bead remains open because its full
dependency roster is not yet present.

## Verification

- PR #3919 merged at `a9744ae1b`; focused red-twin and quick gate
passed.
- PR #3918 merged at `ccb73aa3e`; focused raw-recovery tests and quick
gate passed.
- PR #3920 merged at `8a388e420`; 162 focused harness tests and quick
gate passed.
- Fresh seed receipt is typed `resource-timeout` and explicitly not
release-authorizing.
- `polylogue-29hwx` was deliberately reopened after review found its
audit dependency roster incomplete; it is not assigned to this closure
PR.

<!-- polylogue-pr-scope:v1
{
  "assigned_beads": [
    "polylogue-r4jiu",
    "polylogue-dyica.1",
    "polylogue-817er",
    "polylogue-d96ta"
  ],
"beads_digest":
"2baf0ca8a36d7ddce540f7d34a708f01692a48bb8af1791fca8f5d48e55ff424",
  "dispositions": [

{"bead_id":"polylogue-r4jiu","disposition":"satisfied","evidence":[{"kind":"commit","ref":"a9744ae1b
merged PR #3919"},{"kind":"test","ref":"source-index coverage red twin
and focused registry test passed"},{"kind":"command","ref":"devtools
verify --quick: exit 0"}],"successors":[]},

{"bead_id":"polylogue-dyica.1","disposition":"satisfied","evidence":[{"kind":"commit","ref":"ccb73aa3e
merged PR #3918 typed CAS recovery
implementation"},{"kind":"test","ref":"raw parse recovery focused suite
and quick gate passed"}],"successors":[]},

{"bead_id":"polylogue-817er","disposition":"satisfied","evidence":[{"kind":"commit","ref":"8a388e420
merged PR #3920"},{"kind":"test","ref":"162 focused testmon harness
tests passed"},{"kind":"command","ref":"devtools verify --quick: exit
0"}],"successors":[]},

{"bead_id":"polylogue-d96ta","disposition":"satisfied","evidence":[{"kind":"receipt","ref":"typed
fresh-seed resource-timeout receipt bound to exact
tree/dependencies/harness/node
universe"},{"kind":"command","ref":"POLYLOGUE_VERIFY_PYTEST_TIMEOUT_S=600
devtools verify --seed-testmon: exit 124;
release_baseline_allowed=false"}],"successors":[]}
  ],
"beads_digest":
"2baf0ca8a36d7ddce540f7d34a708f01692a48bb8af1791fca8f5d48e55ff424",
  "head_sha": "8867a00896777c2bf183d6e5f0e9dc11dcc7f561",
"scope_digest":
"655aa4b15af02a0b57c9f0427062fd946c2ac2183ee2035d34bb9a76c60189a5",
  "version": 1
}
-->
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