Skip to content

fix(daemon): raw materialization refuses only the broken source paths - #4700

Merged
Sinity merged 1 commit into
masterfrom
lane/raw-materialization-gate
Sep 5, 2026
Merged

Sinity merged 1 commit into
masterfrom
lane/raw-materialization-gate

Conversation

@Sinity

@Sinity Sinity commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Raw materialization now refuses only the source paths whose authority the frontier proof names as broken and converges every other raw; each refusal is recorded as retryable raw_parse_recovery convergence debt for that path. The daemon trickle drain, the whale pass, and the raw_parse_recovery stage all use the per-path attribution; the reindex preflight keeps the global gate.

Problem

Rehearsal-4 (/realm/tmp/work/rehearsal-4) logged 906 raw materialization source-selection gate blocked: 2 active index raw seed(s) have a broken predecessor chain ...; 8 cursor/head authority row(s) could not be compared; ... refusals from _drain_raw_materialization_once; every drain since 14:05Z refused the whole backlog (raw_total 1263 vs raw_materialized 624). Read-only diagnosis of the archive before it was wiped:

  • The 2 broken seeds: two gemini-cli sessions (56cb9ec1, 44d35feb) each present in two files with one session id. The index holds a byte head (selected_baseline, "newest unique byte-proven full baseline") whose raw the source tier now records as revision_authority = quarantined; the sibling raws are quarantined full rows with no receipt. Tracked in polylogue-6vacn (evidence appended).
  • The 8 incomparable rows: 2 codex SQLite files (logs_2.sqlite, thread_history_1.sqlite) whose unsupported-candidate exclusion was revived by the live database's changing mtime and then refused by the per-path watcher gate before it could be re-excluded (a loop this PR closes: gaps are admitted); 3 Claude JSONL files with only summary/file-history-snapshot records, refused with a typed parse error whose terminal failure carrier was overwritten by a coordinator_session_stream classification (polylogue-lqo6a); 2 gemini sibling files from the pairs above; 1 tool-results/ sidecar whose cursor advanced to EOF with no source-tier evidence (polylogue-6xqhp).

Only the gemini pairs are violations; the other six are authority gaps that processing resolves and that refusal keeps alive.

Solution

  • RawFrontierBlockedPaths separates source_paths (violation-named, refused) from gap_source_paths (admitted); raw_frontier_source_selection_refusal exposes the attribution.
  • repair_raw_materialization and both candidate selections take excluded_source_paths.
  • _drain_raw_materialization_once / whale pass: unattributed refusal still raises; attributed paths are excluded and recorded as debt; a whale seed on a refused path is a typed refusal rather than an empty clean pass.
  • raw_parse_recovery stage: only the path's own refusal defers it.
  • Live watcher: a gap-only state refuses nothing.

Verification

  • devtools test tests/unit/storage/test_raw_retention.py tests/unit/daemon/test_raw_parse_recovery.py tests/unit/storage/test_repair.py tests/unit/daemon/test_daemon_cli.py -k "blocked_source_paths or drain_raw_materialization or whale_writer_route or raw_parse_recovery_stage or refused_source_paths or deferred_cursor" — queued on the host pytest slot as pueue task 1666 (polylogue:test:2168831); this line is updated with the result when it completes.
  • devtools verify --quick (format, lint, mypy, generated surfaces, layering, patterns, doc-commands, schema-manifest, oracle-integrity, testmon-selection, consumer-reachability, timestamp-doctrine, schema-privacy): all gates ok after provisioning the worktree venv (uv sync --extra dev --group audit --frozen; a .claude/worktrees checkout has none by default, polylogue-8dfcy). devtools render all --check: no out of sync. python -m devtools.verify_atlas: 149 stale findings, all pre-existing — docs/atlas/daemon.md and 00-core.md cite daemon/cli.py / convergence_stages.py at verification commit 24be873, which 14 earlier commits already changed; not re-verified here.

Residuals

  • The running rehearsal daemon must restart to pick this up; the drain code is imported at daemon start.
  • Refusals are recorded per source path (the unit the proof attributes), not per raw id.
  • The gemini head/authority disagreement, the overwritten failure carrier, and the sidecar cursor are acquisition defects left to their beads.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid

The frontier proof now attributes its refusal to exact source paths:
violation-named paths (cursor ahead of accepted material, broken head
chain) are excluded from the materialization pass and recorded as
retryable raw_parse_recovery debt; authority gaps are admitted because
materializing the path is what resolves them; a refusal no path explains
still blocks the whole pass. The trickle drain, the whale pass, and the
raw_parse_recovery stage share the attribution; a whale seed on a refused
path is a typed refusal instead of an empty clean pass.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-05T19:26:39.808808Z 0ce6d0f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 94d27d19-cee4-4dd7-b345-81440848971d


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: 0ce6d0f1a7

ℹ️ 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 thread polylogue/storage/repair.py Resolved
Comment thread polylogue/daemon/cli.py Resolved
Comment thread polylogue/storage/repair.py Resolved
Comment thread polylogue/daemon/cli.py Resolved
Comment thread polylogue/storage/repair.py Resolved
@Sinity

Sinity commented Sep 5, 2026

Copy link
Copy Markdown
Owner Author

Verification: focused run on the branch head via the host pytest slot (pueue task 2168831) — 17 passed, 0 failed. Quick gate green on the same tree.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid

@Sinity
Sinity merged commit 7a08e68 into master Sep 5, 2026
3 checks passed
@Sinity
Sinity deleted the lane/raw-materialization-gate branch September 5, 2026 20:32
Sinity added a commit that referenced this pull request Sep 5, 2026
…o refuse (#4704)

## Summary

Four admission defects that each left the raw-frontier source-selection
gate
with a row it could neither compare nor settle, so a fresh daemon
refused its
whole catch-up backlog.

## Problem

Fresh-root rehearsals stopped ingesting with `live watcher
source-selection
gate blocked: N cursor/head authority row(s) could not be compared`.
Four
distinct causes:

- **polylogue-6vacn** — Gemini CLI writes one session as several
complete
  checkpoint files that share a `sessionId` and no byte prefix
(`session-2026-04-02T10-09-56cb9ec1.json` and `…T10-12-…` carry the same
id
with different bytes). A byte-revision cohort over that logical key can
only
fail to order them, so admission logged `no unique byte-revision
candidate
  accepted` and dropped through, leaving both raws `quarantined` with no
  receipt of any kind for the gate to read.
- **polylogue-6q16u** — a quarantine was lifted the moment the watcher
noticed
a path deserved re-deciding, before anything was admitted. The row then
sat
`excluded = 0` carrying its old byte offset until the next acquisition
pass,
and the raw-frontier cursor map reads exactly that shape as committed
ingest
authority with no accepted head. A live database whose stat changes on
every
  poll re-entered that window on every poll.
- **polylogue-lqo6a** — both `raw_artifacts` upserts replace
`artifact_kind`
  unconditionally on `artifact_id` conflict, so an ordinary path
classification landing on a terminal failure carrier's id takes the row
back. `_terminal_artifact_paths` then reads the path as neither terminal
nor
  headed, forever.
- **polylogue-6xqhp** — a cursor advanced to EOF for a path with no
  `raw_sessions`, `blob_refs`, `history_sidecars`, `raw_artifacts` or
`source_items` row: bytes consumed, nothing retained, and no route able
to
  re-read them.

## Solution

- `Origin.GEMINI_CLI_SESSION` declares `frontier_kind =
"whole-snapshot"`, a
new value on the existing source-level continuation law meaning
successive
observations are competing complete snapshots rather than continuations.
Admission routes such an origin through the same typed membership
authority
browser captures already use, which yields one accepted head and a typed
  decision for the rest.
- An unorderable byte cohort with no retired siblings now records
`DEFERRED_CAS_FRONTIER` failure evidence and defers, instead of dropping
  through and leaving an untyped quarantined raw.
- `_needs_work_from_state_uncorroborated` reports the fresh attempt
without
clearing `excluded`. The quarantine is lifted by the cursor write of an
ingest that actually retained something, so a path that fails again
stays
quarantined and a never-admitted path never presents a stale byte offset
as
  committed authority.
- Both `raw_artifacts` upserts carry a shared guard
(`terminal_carrier_overwrite_predicate`) refusing an ordinary
classification
that would replace a terminal failure carrier; only failure-evidence
writes
  may change a carrier's kind.
- `_record_full_cursor` refuses to advance when the source tier holds no
row
for the path, recording retryable `raw_parse_recovery` debt instead. The
  raw-id lookup it guards on was already being performed.

Deliberately not done: no gate exemption is widened, and the per-path
drain
refusal owned by #4700 is untouched.

## Verification

Fresh daemon on a scratch root over a frozen read-only copy of only the
gemini-cli and codex-state sources plus the three Claude JSONL files
named in
polylogue-lqo6a (789 MB, `/realm/tmp/work/lane-raw-admission`),
production
route `polylogued run`:

```
refused by cursor authority: 0
no unique byte-revision candidate: 0
broken_heads: 0
gemini-cli-session:56cb9ec1-ece5-4705-ac40-a3e1b1569c25 -> 1 head
both raws of the colliding pair: raw_membership_census status = complete
refusing to advance cursor past bytes that left no source evidence: 0
```

Before this branch the same pair produced two untyped quarantined raws,
a
broken head, and repeated whole-backlog refusals.

`devtools verify --quick` — all 13 gates ok; `render all --check`
reports
nothing out of sync.

Residuals: one `source_raws_without_accepted_head` gap remains for the
second
file of the pair. That is a gap, not a violation — the path is typed and
materializing it is what resolves it — and #4700 is what stops gaps from
blocking. `state_5.sqlite` was still awaiting
`finalize_codex_state_snapshots`
when the rehearsal's time budget ended; that finalizer is unchanged
here.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@Sinity

Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Codex review threads on this PR whose cited code is gone (checked against master at 23f91a5):

Resolving these threads.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):

  • P2 polylogue/daemon/cli.py:1541: Stale: whale_pass_candidate and _maybe_run_raw_materialization_whale_pass no longer exist; raw materialization now converges through the canonical raw observation owner (polylogue/daemon/raw_observation_owner.py:72). (checked at 0914f89)

Resolving every thread listed; confirmed defects are fixed under the named bead.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing out open Codex review threads on this PR (evidence checked against master at 5d56c3a):

Resolving every thread listed; confirmed defects are fixed under the named bead.

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