Skip to content

docs(design): design prefix-blob reclamation for byte-proven revisions - #3164

Merged
Sinity merged 3 commits into
masterfrom
feature/design/prefix-blob-reclamation
Jul 19, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/design/prefix-blob-reclamation

Conversation

@Sinity

@Sinity Sinity commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

Design-only lane for polylogue-vzn6: a reference-blob representation that
lets byte-proven strict-prefix superseded raw-payload blobs be reclaimed
without breaking any consumer that reads them by hash. No code/schema
changes are applied in this PR — implementation is deferred to follow-up
work.

Problem

raw_sessions stores every observed file snapshot as an independent full
blob. When a live-captured file only grows (Codex rollouts, Claude Code
transcripts), every capture before the last is a byte-proven strict prefix
of a later one — #3146's classify_historical_full_revision_streams already
proves this with zero heuristics — so the old bytes are redundant by
construction, but blob GC correctly refuses to collect them since
raw_sessions/blob_refs still point at them.

The bead (and #3146's own problem statement) cited 45.2GB of 97.4GB (46%)
as the reclaimable scale. That number assumes every non-newest member of a
same-identity growth cohort is a clean append chain, without actually running
the byte-proof. Running the real proof against the live archive shows this
assumption is mostly wrong: the verified, strict byte-proof reclaimable
total is 17.65GB (18.12% of the archive)
— most same-identity cohorts
(96%+ of those checked) are non-monotonic (edits, resegmentation,
coincidental identity reuse) and are correctly quarantined by the existing
classifier, not silently reclaimable.

Solution

docs/design/prefix-blob-reclamation.md covers:

  1. Evidence pack — three buckets measured read-only against the live
    archive (already-classified byte_proven chains: 10.48GB/992 rows; typed
    cohorts needing a fresh streamed proof: 7.17GB/318 rows from 50 of 3,432
    cohorts checked; untyped/legacy cohorts: 0.0006GB/11 rows from 4 of 3,240
    checked). Top cohorts and an origin distribution (86.4% codex-session,
    13.6% claude-code-session) are included. Reproduction scripts are
    preserved for audit.
  2. Reference-blob representation — a new additive blob_prefix_references
    table (own hash / byte_length / successor hash), not blob_refs (a
    different axis: referrer identity vs. content-reconstruction recipe).
    Chained rather than always-flattened-to-leaf resolution, justified by
    BlobStore's write-once immutability removing the TOCTOU class entirely.
  3. Read-path audit — found 15+ non-publisher BlobStore/get_blob_store()
    callers beyond the "publisher" surface the bead named (backup, validation,
    revision backfill, retention, artifact inspection, sampling/validation
    corpora, blob integrity, source parsing, live batch, repair, reconciler,
    ingest worker). Decision: push reference-resolution into the shared
    BlobStore base class (not just ArchiveBlobPublisher), so all 15+
    callers become reference-aware through one change. Flags blob_path()'s
    permanent-path contract as the single riskiest open item — some callers
    assume a stable, reusable CAS file, and a reference-backed hash can only
    offer a bounded ephemeral spill file.
  4. GC/lease interaction — reuses blob_gc.py's existing hardened deletion
    path via one added exclusion clause in _reference_surfaces, rather than
    a parallel deletion mechanism. Crash-window analysis at every step (write
    reference row → verify → mark collectible → existing GC collects →
    confirmation sweep), including the one new race the added clause could
    introduce (resolved by SQLite's existing WAL snapshot isolation).
  5. Consent gate — reuses the existing verified-backup-manifest tooling
    (daemon/backup.py) ahead of the first real physical reclamation pass;
    the schema addition itself is ordinary additive DDL needing no special
    gate.
  6. Verification plan — sampled and full byte-identity + read-path-parity
    modes.
  7. Forward-fix sibling — traced why acquisition-side append-delta storage
    only activates ~2.3% of the time: _append_plan's cursor continuity is
    anchored to ops.db (the disposable tier), so every ops.db reset forces
    every currently-growing file back onto a full capture. Sketches a fix
    (durable-tier cursor reconstruction fallback) and records the decision to
    file it as a follow-up rather than implement it in this design-only lane.
  8. Anti-goals — no heuristic similarity reclamation, no reclamation of a
    quarantined/ambiguous chain, retired-generation cleanup out of scope.

Verification

  • python -m devtools render all --check — clean (the new doc needed a
    devtools/docs_surface.py entry; added and regenerated docs/README.md).
  • python -m devtools verify --quick (format + lint + mypy + render-all-check)
    — passed via the pre-push hook, exit_code: 0.
  • Evidence-pack numbers were computed with three read-only probe scripts
    (evidence_pack.py, prove_mixed.py, prove_unknown.py, final_evidence.py)
    run against the live archive's source.db (mode=ro) and blob store,
    importing the project's own classify_historical_full_revision_streams
    rather than reimplementing the proof. No writes were made to the live
    archive.

Ref polylogue-vzn6

Sinity and others added 2 commits July 19, 2026 17:39
Problem: raw_sessions stores every observed file snapshot as an independent
full blob; when a live-captured file only grows (Codex rollouts, Claude Code
transcripts), every capture before the last is a byte-proven strict prefix
of a later one (#3146's classify_historical_full_revision_streams already
proves this), so the old bytes are redundant by construction but blob GC
correctly refuses to collect them since raw_sessions/blob_refs still point
at them.

What changed: added docs/design/prefix-blob-reclamation.md covering: (1) an
evidence pack measured read-only against the live archive that decomposes
the bead's "45.2GB (46%)" naive estimate into a verified 17.65GB (18.12%)
strict byte-proof reclaimable total across three buckets (already-classified,
freshly-proven-typed, freshly-proven-untyped), with top cohorts and an
origin distribution (86% codex-session); (2) a new additive
blob_prefix_references table (own hash, byte_length, successor hash) as the
reference-blob representation, chained rather than always-flattened-to-leaf
resolution, and why blob_refs is the wrong home for it; (3) a read-path audit
finding 15+ non-publisher BlobStore callers beyond the "publisher" surface
the bead named, and a decision to push reference-resolution into the shared
BlobStore base class rather than only ArchiveBlobPublisher; (4) reuse of
blob_gc.py's existing hardened deletion path via one added exclusion clause
in _reference_surfaces, with a crash-window analysis per step; (5) a
consent-gate design reusing the existing verified-backup-manifest tooling;
(6) a two-mode (sampled/full) byte-identity + read-path-parity verification
plan; (7) a grounded forward-fix sketch for the acquisition-side sibling
(append-delta capture only activates 2.3% of the time because its cursor
continuity is anchored to the disposable ops.db tier, not source.db).

Anti-goals stated: no heuristic similarity reclamation (byte-proof only, and
the evidence pack shows why heuristics would be wrong most of the time
here), no reclamation of a quarantined/ambiguous chain, retired-generation
cleanup is out of scope.

This is a design-only change (no code, no schema migration applied) per the
bead's ask; implementation is deferred to follow-up work.

Ref polylogue-vzn6

Co-Authored-By: Claude <[email protected]>
render docs-surface flagged the new doc as unindexed documentation; add its
entry to devtools/docs_surface.py's design tier and regenerate docs/README.md.

Ref polylogue-vzn6

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 19, 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: 51 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: 2c4e0fd4-1b81-4501-b46b-3be692eb6cbc

📥 Commits

Reviewing files that changed from the base of the PR and between 4d53070 and 22672c2.

📒 Files selected for processing (4)
  • devtools/docs_surface.py
  • docs/README.md
  • docs/design/README.md
  • docs/design/prefix-blob-reclamation.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/design/prefix-blob-reclamation

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 added a commit that referenced this pull request Jul 19, 2026
Append-notes on polylogue-vzn6 (evidence pack + design summary, PR #3164)
and the new follow-up bead polylogue-aex0 (append-ingest cursor continuity
root cause).

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity merged commit aa45aa5 into master Jul 19, 2026
3 checks passed
@Sinity
Sinity deleted the feature/design/prefix-blob-reclamation branch July 19, 2026 15:47
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