Skip to content

feat(storage): add byte-duplicate supersession classifier + actuator - #3624

Merged
Sinity merged 1 commit into
masterfrom
feature/raw-authority/byte-dup-supersession
Aug 3, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/raw-authority/byte-dup-supersession

Conversation

@Sinity

@Sinity Sinity commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a read-only classifier plus a dry-run-by-default actuator that resolves quarantined, logical-key-less raws that are byte-identical to content the archive already indexed under a different raw_id.

Problem

Of 7,200 unindexed logical-source heads in the live archive, 4,305 (17.6 of 22.9 GiB, 77% of the bytes) sit at revision_authority='quarantined' with logical_source_key IS NULL -- invisible to every existing reconciliation path (classify_raw_revision_cohort, the membership pipeline, the append-chain backfill all key off logical_source_key). These rows turn out to be byte-identical re-acquisitions/re-syncs of content the archive already indexed under a different raw_id, not missing content -- they inflate every "archive is X% unconverged" measurement while carrying nothing the archive doesn't already have.

Solution

polylogue/storage/raw_byte_duplicate_supersession.py is a strictly read-only classifier: for each quarantined, logical-key-less raw, it checks whether the raw's blob_hash matches some OTHER raw_sessions row that already has a materialized session in index.db. index.db is opened read-only; nothing here writes to it or touches the indexed twin's own row.

polylogue/maintenance/raw_byte_duplicate_supersession_apply.py is the "act" half, following the identical dry-run-by-default / verified-backup-required / immutable-receipt pattern already established by raw_live_source_reconciliation_apply, raw_membership_writeback_apply, and raw_append_chain_backfill_apply. It promotes matched rows to revision_authority='byte_proven' -- reusing the existing closed vocabulary rather than inventing a new disposition -- and deliberately leaves revision_authority_evidence NULL (widening its closed CHECK constraint requires a full raw_sessions table rebuild, per migration 021's own precedent for why that's expensive) in favor of a dedicated raw_byte_duplicate_supersession_receipts table (migration 022, source schema v21->v22) that records which indexed raw_id/session_id each duplicate matches, so the evidence is durable and inspectable, not silent.

Wired as devtools workspace raw-byte-duplicate-supersession-apply.

The genuinely novel remainder (~2,895 rows / ~5.3 GiB, no indexed byte-identical twin) is left untouched -- that population is polylogue-lkrc/polylogue-hjpx's reconciler scope, explicitly out of scope here.

Verification

  • devtools test tests/unit/storage/test_raw_byte_duplicate_supersession.py tests/unit/maintenance/test_raw_byte_duplicate_supersession_apply.py -- 6 passed. Fixture proves a genuine byte-duplicate pair (one indexed, one quarantined-no-lsk raw with matching blob_hash) resolves, a genuine non-duplicate quarantined-no-lsk raw does not, dry-run makes zero mutations to source.db or index.db, and apply refuses without a verified backup manifest.
  • devtools test tests/unit/storage/test_durable_migrations.py -- 43 passed (updated hardcoded v21 schema-chain assertions to v22).
  • devtools test -k raw_authority -- 108 passed, 6 failed; confirmed via git stash (reverting this change) that the same 6 failures (test_raw_authority_scale_proof.py x5, test_raw_authority_daemon_health_proof.py x1) reproduce identically without this change -- pre-existing/unrelated.
  • devtools verify --quick -- exit 0 (format, lint, mypy --strict, render all --check, layering, schema-versioning and raw-authority-frontier-executability lab policies all pass).

Not run against the live archive as part of this PR -- the dry-run sanity check against /realm/db/polylogue (and any subsequent --apply) is a separate, explicitly operator-supervised step, tracked in the referenced bead.

Ref polylogue-6753s

@coderabbitai

coderabbitai Bot commented Aug 3, 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: 17 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 Plus

Run ID: a3782d99-8958-4f65-9812-b19c07f0112c

📥 Commits

Reviewing files that changed from the base of the PR and between ee9e938 and 9a7e580.

📒 Files selected for processing (10)
  • devtools/command_catalog.py
  • devtools/raw_byte_duplicate_supersession_apply.py
  • docs/devtools.md
  • docs/plans/topology-target.yaml
  • polylogue/maintenance/raw_byte_duplicate_supersession_apply.py
  • polylogue/storage/raw_byte_duplicate_supersession.py
  • polylogue/storage/sqlite/archive_tiers/source.py
  • polylogue/storage/sqlite/migrations/source/023_raw_byte_duplicate_supersession_receipts.sql
  • tests/unit/maintenance/test_raw_byte_duplicate_supersession_apply.py
  • tests/unit/storage/test_raw_byte_duplicate_supersession.py

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.

Problem: of 7,200 unindexed logical-source heads in the live archive,
4,305 (17.6 of 22.9 GiB, 77% of the bytes) sit at
revision_authority='quarantined' with logical_source_key IS NULL --
invisible to every existing reconciliation path (classify_raw_revision_cohort,
the membership pipeline, the append-chain backfill all key off
logical_source_key). These rows turn out to be byte-identical
re-acquisitions/re-syncs of content the archive already indexed under a
different raw_id, not missing content.

What changed: polylogue/storage/raw_byte_duplicate_supersession.py is a
read-only classifier that, for each quarantined/logical-key-less raw, checks
whether its blob_hash matches some OTHER raw_sessions row that already has a
materialized session in index.db. index.db is opened strictly read-only;
nothing here writes to it or touches the indexed twin's own row.
polylogue/maintenance/raw_byte_duplicate_supersession_apply.py is the "act"
half, following the identical dry-run-by-default / verified-backup-required
/ immutable-receipt pattern established by raw_live_source_reconciliation_apply,
raw_membership_writeback_apply, and raw_append_chain_backfill_apply.
Promotes matched rows to revision_authority='byte_proven' -- reusing the
closed vocabulary rather than inventing a new one -- and leaves
revision_authority_evidence NULL (widening its closed CHECK requires a full
raw_sessions table rebuild, per migration 021's own precedent) in favor of a
dedicated raw_byte_duplicate_supersession_receipts table (migration 022,
source schema v21->v22) recording which indexed raw_id/session_id each
duplicate matches. Wired as `devtools workspace
raw-byte-duplicate-supersession-apply`.

The genuinely novel remainder (no indexed byte-identical twin) is left
untouched -- that population belongs to polylogue-lkrc/polylogue-hjpx's
reconciler, explicitly out of scope here.

Verification:
- devtools test tests/unit/storage/test_raw_byte_duplicate_supersession.py
  tests/unit/maintenance/test_raw_byte_duplicate_supersession_apply.py --
  6 passed. Fixture proves a genuine byte-duplicate pair (one indexed, one
  quarantined-no-lsk with matching blob_hash) resolves, a genuine
  non-duplicate quarantined-no-lsk raw does not, dry-run makes zero
  mutations to source.db or index.db, and apply refuses without a verified
  backup manifest.
- devtools test tests/unit/storage/test_durable_migrations.py -- 43 passed
  (updated hardcoded v21 schema-chain assertions to v22).
- devtools test -k raw_authority -- 108 passed, 6 failed; confirmed via
  git stash (reverting this change) that the same 6 failures
  (test_raw_authority_scale_proof.py x5, test_raw_authority_daemon_health_proof.py
  x1) reproduce identically without this change -- pre-existing/unrelated.
- devtools verify --quick -- exit 0 (format, lint, mypy --strict, render
  all --check, layering, schema-versioning and raw-authority-frontier-
  executability lab policies all pass).

Not run against the live archive this session -- the required dry-run
sanity check against /realm/db/polylogue before any --apply is a separate,
explicitly operator-supervised step.

Ref polylogue-6753s

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/raw-authority/byte-dup-supersession branch from 3cfa026 to 9a7e580 Compare August 3, 2026 10:22
@Sinity
Sinity merged commit 3bc420c into master Aug 3, 2026
1 of 3 checks passed
@Sinity
Sinity deleted the feature/raw-authority/byte-dup-supersession branch August 3, 2026 10:22
Sinity added a commit that referenced this pull request Aug 3, 2026
6753s (byte-dup supersession, PR #3624), c831 (message_type restamp,
PR #3629, live backfill verified 0 remaining), qhk8z (duplicate-chain
baseline tie-break, PR #3616), ct3r2 + t6iga (merge-gate enforcement,
PR #3607, duplicate beads for the same fix).

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