-
Notifications
You must be signed in to change notification settings - Fork 1
fix(daemon): recover typed CAS frontier failures #3918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,10 @@ | |
|
|
||
| from polylogue.config import load_polylogue_config | ||
| from polylogue.core.enums import Provider | ||
| from polylogue.core.raw_failure_evidence import ( | ||
| RAW_FAILURE_DEFERRED_SUPPORT_STATUS, | ||
| RAW_FAILURE_REPLAY_AUTHORITY_EVIDENCE_KINDS, | ||
| ) | ||
| from polylogue.daemon.convergence import ConvergenceStage, StageExecuteReturn, StageExecutionResult | ||
| from polylogue.daemon.convergence_standing_queries import make_standing_query_stage | ||
| from polylogue.logging import get_logger | ||
|
|
@@ -884,6 +888,7 @@ def _raw_parse_recovery_pending_count(db_path: Path, path: Path, *, archive_root | |
| return 0 | ||
| index_db = ArchiveLocation.resolve(durable_root).active_index_path | ||
| normalized_root = str(path).rstrip("/") | ||
| replay_authority_placeholders = ", ".join("?" for _ in RAW_FAILURE_REPLAY_AUTHORITY_EVIDENCE_KINDS) | ||
| try: | ||
| conn = sqlite3.connect(f"file:{source_db}?mode=ro", uri=True, timeout=5.0) | ||
| except sqlite3.Error: | ||
|
|
@@ -918,16 +923,36 @@ def _raw_parse_recovery_pending_count(db_path: Path, path: Path, *, archive_root | |
| FROM raw_sessions AS r | ||
| {materialized_join} | ||
| WHERE (r.source_path = ? OR r.source_path LIKE ?) | ||
| AND r.parsed_at_ms IS NULL | ||
| AND COALESCE(r.validation_status, '') != 'failed' | ||
| AND ( | ||
| r.parse_error IS NULL | ||
| 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:%' | ||
| ( | ||
| r.parsed_at_ms IS NULL | ||
| AND ( | ||
| r.parse_error IS NULL | ||
| 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 ( | ||
| SELECT 1 | ||
| FROM raw_artifacts AS failure_evidence | ||
| WHERE failure_evidence.raw_id IS r.raw_id | ||
| AND failure_evidence.origin IS r.origin | ||
| AND failure_evidence.source_path IS r.source_path | ||
| AND failure_evidence.source_index IS r.source_index | ||
| AND failure_evidence.artifact_kind IN ({replay_authority_placeholders}) | ||
| AND failure_evidence.support_status = ? | ||
|
Comment on lines
+944
to
+945
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an exact CAS carrier belongs to a raw whose AGENTS.md reference: AGENTS.md:L168-L177 Useful? React with 👍 / 👎. |
||
| ) | ||
| ) | ||
| {materialized_where} | ||
| """, | ||
| (normalized_root, f"{normalized_root}/%"), | ||
| ( | ||
| normalized_root, | ||
| f"{normalized_root}/%", | ||
| *sorted(RAW_FAILURE_REPLAY_AUTHORITY_EVIDENCE_KINDS), | ||
| RAW_FAILURE_DEFERRED_SUPPORT_STATUS, | ||
| ), | ||
| ).fetchone() | ||
| return int(row[0] or 0) if row is not None else 0 | ||
| except sqlite3.Error: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When replaying a previously successful raw after its derived index row is lost, a
RawCASFrontierErrorleaves the oldparsed_at_msintact because_raw_parse_failure_statedoes not update that field. Althoughrepair.pydeliberately admits these already-parsed, unmaterialized rows, this new typed-evidence branch remains inside the outerr.parsed_at_ms IS NULLcondition, 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 👍 / 👎.