Skip to content

fix(storage): name the differing fields when a raw revision rebind refuses - #3114

Merged
Sinity merged 1 commit into
masterfrom
fix/daemon/adoption-refusal-diagnostics
Jul 18, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/daemon/adoption-refusal-diagnostics

Conversation

@Sinity

@Sinity Sinity commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Instrumentation for the polylogue-emx2 investigation: the mass adoption refusals during the 2026-07-18 index restore are opaque — reconstructing the proposed envelope from the ingest code and comparing against the stored row yields equal tuples after the fact, so whatever field actually differs at runtime cannot be recovered from the one-line error. This makes the refusal self-explaining.

Problem

bind_source_raw_revision raises raw revision is already authoritative or missing: <raw_id> for both the missing-row case and the conflicting-values case, without saying which values conflict. Live during the restore: 21–50 of 50 files per catch-up chunk refuse re-adoption with this error while the stored rows (kind='full', authority='quarantined', source_revision=raw_id, generation 0) match a faithful reconstruction of the proposed envelope exactly — the actual runtime difference is invisible.

Solution

  • Missing row → raw revision bind found no raw row: <raw_id>.
  • Value conflict → raw revision is already authoritative and differs for <raw_id>: <field>: stored=… proposed=… for every differing field.

No semantic change: the accept/refuse decision logic is untouched.

Verification

devtools test tests/unit/storage/test_raw_revision_authority.py — 21 passed; the rebind-refusal tests now pin the specific field diffs (acquisition_generation: stored=0 proposed=99, source_revision: stored='revision-1' proposed='different') and the missing-row message. mypy clean; quick gate green on push.

Ref polylogue-emx2

🤖 Generated with Claude Code

https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ

…fuses

Problem: the mass adoption refusals during the 2026-07-18 index restore
("raw revision is already authoritative or missing") are opaque — the
stored row and a reconstruction of the proposed envelope compare equal
after the fact, so the actual differing field cannot be determined from
the error or later inspection (polylogue-emx2 evidence trail). The
one-line message also conflated missing-row with conflicting-values.

What changed: the missing-row case raises its own message, and the
conflict case names each differing field with stored vs proposed values,
so the next live refusal is self-explaining.

Ref polylogue-emx2

Co-Authored-By: Claude <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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

Run ID: 3ba7abbc-8741-401a-a5a9-51f63215b86c

📥 Commits

Reviewing files that changed from the base of the PR and between c2d3f94 and 844a8d4.

📒 Files selected for processing (2)
  • polylogue/storage/sqlite/archive_tiers/source_write.py
  • tests/unit/storage/test_raw_revision_authority.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/daemon/adoption-refusal-diagnostics

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.

@Sinity
Sinity merged commit b9f8be7 into master Jul 18, 2026
3 checks passed
@Sinity
Sinity deleted the fix/daemon/adoption-refusal-diagnostics branch July 18, 2026 17:09
Sinity added a commit that referenced this pull request Jul 18, 2026
…ailure (#3129)

## Summary

Watcher catch-up over already-acquired files was silently marking the
overwhelming majority of them as "failed" — with no exception raised and
no log line written — because the aggregation layer conflated
"membership decision not yet made" (a legitimate async hand-off to the
raw-materialization conveyor) with "genuine failure". This directly
fixes the emx2 restore-class gap: a rebuilt-index-over-intact-source
scenario can now self-heal without retry-churning the entire population.

## Problem

Live evidence from the mid-restore archive (2026-07-18 evening): every
watcher catch-up chunk was reporting `succeeded=0 failed=35-50/50`, but
only 2 of ~400+ "failed" files in that window had a matching exception
logged (`RuntimeError: raw revision CAS rejected an older accepted
frontier`). Direct read-only inspection of `source.db` found the real
cause:

- `raw_membership_census` had 25,324 rows with `status='complete'`.
- Of those, **24,626 (97.2%)** had at least one
`raw_session_memberships` row with `decision IS NULL` or `'ambiguous'` —
i.e. the raw-authority protocol's own async classification correctly
hadn't decided the winner yet (arbitration deferred to the
raw-materialization conveyor, by design).
- `_ingest_full_paths_sync` (`polylogue/sources/live/batch.py`) computed
the failed set as *every raw not present in `archive_write.raw_ids`* —
which only gets populated when `raw_authority_complete` is `True`. A raw
with a pending decision has no exception, no log, but also never lands
in `raw_ids` — so it was silently added to `failed`, triggering
`mark_failed` on its cursor (retry churn) forever with zero net
progress.

This is `polylogue-emx2` ("Watcher catch-up trusts ingest cursors that
the index cannot corroborate"), evidenced through a different live
mechanism than the bead's originally-hypothesized ValueError diagnostic
(which never fired on the current, post-#3114 deployed daemon — 0 log
hits either format).

## Solution

- `_ArchiveFullWriteResult` gains `deferred_raw_ids: dict[str, str]`,
populated at both no-exception non-completion points in
`_ingest_full_records_archive`:
- `raw_authority_complete=False` after `_apply_membership_sessions`
(census complete, decision pending/ambiguous).
- `classify_raw_revision_cohort` returning no accepted candidates in the
non-membership-governed single-session path.
- `_ingest_full_paths_sync`'s aggregation now excludes
`deferred_raw_ids` from the failed set and folds them into the succeeded
raw-id remap, so the cursor for that path is recorded as a normal
succeeded full-ingest — the bytes ARE durably acquired, only the
membership *decision* is outstanding, which is the conveyor's job, not
the watcher's.
- Genuine exceptions (the CAS `RuntimeError`, `ValueError`s, `"no longer
parses uniquely"` guards) are unaffected — still caught by the existing
`except Exception` block, still call `mark_raw_parse_failed`, still fail
loudly.

## Verification

- New regression test
`test_live_full_ingest_over_ambiguous_membership_defers_instead_of_failing`
(`tests/unit/sources/test_live_watcher.py`): ingests two genuinely
conflicting browser-capture snapshots of one session
(`classify_membership_revisions` correctly returns `ambiguous`, not
`accepted`) and proves the second observation lands as
succeeded/idempotent with `failure_count == 0` on the cursor, including
a third identical re-observation.
- Anti-vacuity: confirmed this test **fails** against the pre-fix code
(`failed_file_count=1`, zero exceptions/log lines in captured output)
before restoring the fix.
- `devtools test tests/unit/sources/test_live_watcher.py` — 88 passed.
- `devtools verify --quick` — exit 0 (format, lint, mypy --strict,
render all --check,
topology/layering/manifest/doc-commands/clock-hygiene/timeout/degrade-loudly
gates).
- Not run: the heavy `test` suite (skipped per-PR by CI policy, runs
post-merge).

Ref polylogue-emx2

Co-authored-by: Claude <[email protected]>
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