Skip to content

fix(storage): restore the sidecar blob owner and legacy carrier - #4381

Merged
Sinity merged 1 commit into
masterfrom
fix/p9txi-sidecar-blob-owner
Aug 28, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/p9txi-sidecar-blob-owner

Conversation

@Sinity

@Sinity Sinity commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Summary

#4339 removed the ledger entry that resolved blob_refs.ref_type='sidecar', but nothing removed the relation it describes. history_sidecars is still a live source-tier table and the blob_refs CHECK still admits sidecar, so the writer remains entitled to create rows that the readers could no longer resolve. This restores the owner and the legacy carrier, and couples the two declarations so they cannot drift apart again.

Problem

Ten storage tests were red on master. Both consequences are real, and they point in opposite directions:

  • validated_blob_ref_liveness_joins() no longer resolved sidecar, so any archive holding such a row returned BlobLiveness(state=BLOCKED, blockers=('unknown blob_refs ref_type(s): sidecar',)). That fails closed — no over-deletion — but GC stalls on data the writer was entitled to write.
  • referenced_blob_hashes omitted sidecar-owned hashes on a legacy archive carrying history_sidecars.blob_hash, making those blobs GC-eligible. That one is a data-loss risk on a real archive, and it matters directly to the reindex campaign.

Retiring the ref_type from the DDL CHECK instead would have stranded any archive already holding sidecar rows — the wrong direction while the table still exists.

Solution

  • storage/blob_liveness.py — restored BlobOwner("source", "history_sidecars", ref_type="sidecar", referent_column="sidecar_id")
  • storage/blob_integrity.py — history_sidecars back in _LEGACY_DIRECT_BLOB_CARRIERS, guarded by the existing _column_exists(conn, table, "blob_hash") check, so it is inert on the current schema (which uses content_hash) and protective on older ones
  • new test_blob_refs_check_vocabulary_and_liveness_join_map_agree — nothing previously coupled the blob_refs CHECK vocabulary to the liveness join map, and they live in different files. That gap is what allowed the drift.

No test was deleted or weakened; all nine failures were production defects.

The sessions_unenriched assertion was vacuous — _enrich_parsed_sessions returns False on both paths, so it could not fail. Its real subject, that a worker never consults the ambient source tree, was still worth protecting, so it now asserts via a call recorder that discover_sidecars is never invoked. That is strictly stronger than the previous monkeypatched raise.

Verification

devtools test over the three bead-named files plus the ingest-worker file: 84 passed, was 9 failed / 69 passed. Widened to every BLOB_OWNERS / blob_gc / archive_verification consumer — GC, excision, retention, migrations, maintenance, CLI, daemon — 265 passed, and 118 passed in a further run. devtools verify --quick: all 18 gates ok, zero out of sync.

Anti-vacuity, verified by mutation rather than asserted:

Mutation Red test
Delete the sidecar BlobOwner test_blob_refs_check_vocabulary_and_liveness_join_map_agree
Drop history_sidecars from _LEGACY_DIRECT_BLOB_CARRIERS test_source_capabilities_conserve_mixed_legacy_and_typed_references
Reintroduce on-demand discover_sidecars in the worker test_missing_snapshot_does_not_attempt_on_demand_enrichment

The first mutation is exactly #4339's edit, so the new guard would have caught the original regression.

Residual risk

devtools verify (selected/affected) did not run: it exits 2 with native_testmon_graph_unavailable because the lane worktree has no testmon graph. That is the documented refusal, not a failure of this change; the targeted runs above are the compensating evidence and prove their selected scope only.

The failure total measured here (9 failed / 69 passed) differs from the 10 / 93 recorded on the bead. Same failure signature and same root cause, measured at a different master point.

Filed polylogue-mmf7c separately: sessions_unenriched is dead production surface, not just a dead assertion — it feeds a batch summary counter that can never be nonzero, so it reads as positive evidence of no degradation. Left out of scope because removing it touches ingest_batch.

Closes polylogue-p9txi.

🤖 Generated with Claude Code

https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA

history_sidecars is still a live source-tier relation and blob_refs still
admits ref_type='sidecar', but the ledger map no longer resolved it: any
archive holding a sidecar ref made liveness projection return BLOCKED, and
referenced_blob_hashes omitted sidecar-owned hashes on a legacy archive
carrying history_sidecars.blob_hash, making those blobs GC-eligible.

A new proof couples the blob_refs CHECK vocabulary to the liveness join map
so the two cannot drift apart again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA
@coderabbitai

coderabbitai Bot commented Aug 28, 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f9a1cdd9-e167-49a1-8f5c-4db79fd9ffb7


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 a9eb500 into master Aug 28, 2026
3 checks passed
@Sinity
Sinity deleted the fix/p9txi-sidecar-blob-owner branch August 28, 2026 07:53
Sinity added a commit that referenced this pull request Aug 28, 2026
## Summary

#4339 removed the ledger entry that resolved
`blob_refs.ref_type='sidecar'`, but nothing removed the relation it
describes. `history_sidecars` is still a live source-tier table and the
`blob_refs` CHECK still admits `sidecar`, so the writer remains entitled
to create rows that the readers could no longer resolve. This restores
the owner and the legacy carrier, and couples the two declarations so
they cannot drift apart again.

## Problem

Ten storage tests were red on master. Both consequences are real, and
they point in opposite directions:

- `validated_blob_ref_liveness_joins()` no longer resolved `sidecar`, so
any archive holding such a row returned `BlobLiveness(state=BLOCKED,
blockers=('unknown blob_refs ref_type(s): sidecar',))`. That fails
closed — no over-deletion — but GC stalls on data the writer was
entitled to write.
- `referenced_blob_hashes` omitted sidecar-owned hashes on a legacy
archive carrying `history_sidecars.blob_hash`, making those blobs
GC-eligible. That one is a data-loss risk on a real archive, and it
matters directly to the reindex campaign.

Retiring the ref_type from the DDL CHECK instead would have stranded any
archive already holding sidecar rows — the wrong direction while the
table still exists.

## Solution

- `storage/blob_liveness.py` — restored `BlobOwner("source",
"history_sidecars", ref_type="sidecar", referent_column="sidecar_id")`
- `storage/blob_integrity.py` — `history_sidecars` back in
`_LEGACY_DIRECT_BLOB_CARRIERS`, guarded by the existing
`_column_exists(conn, table, "blob_hash")` check, so it is inert on the
current schema (which uses `content_hash`) and protective on older ones
- new `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` —
nothing previously coupled the `blob_refs` CHECK vocabulary to the
liveness join map, and they live in different files. That gap is what
allowed the drift.

No test was deleted or weakened; all nine failures were production
defects.

The `sessions_unenriched` assertion was vacuous —
`_enrich_parsed_sessions` returns `False` on both paths, so it could not
fail. Its real subject, that a worker never consults the ambient source
tree, was still worth protecting, so it now asserts via a call recorder
that `discover_sidecars` is never invoked. That is strictly stronger
than the previous monkeypatched raise.

## Verification

`devtools test` over the three bead-named files plus the ingest-worker
file: **84 passed**, was 9 failed / 69 passed. Widened to every
`BLOB_OWNERS` / `blob_gc` / `archive_verification` consumer — GC,
excision, retention, migrations, maintenance, CLI, daemon — **265
passed**, and **118 passed** in a further run. `devtools verify
--quick`: all 18 gates ok, zero `out of sync`.

Anti-vacuity, verified by mutation rather than asserted:

| Mutation | Red test |
|---|---|
| Delete the sidecar `BlobOwner` |
`test_blob_refs_check_vocabulary_and_liveness_join_map_agree` |
| Drop `history_sidecars` from `_LEGACY_DIRECT_BLOB_CARRIERS` |
`test_source_capabilities_conserve_mixed_legacy_and_typed_references` |
| Reintroduce on-demand `discover_sidecars` in the worker |
`test_missing_snapshot_does_not_attempt_on_demand_enrichment` |

The first mutation is exactly #4339's edit, so the new guard would have
caught the original regression.

## Residual risk

`devtools verify` (selected/affected) did not run: it exits 2 with
`native_testmon_graph_unavailable` because the lane worktree has no
testmon graph. That is the documented refusal, not a failure of this
change; the targeted runs above are the compensating evidence and prove
their selected scope only.

The failure total measured here (9 failed / 69 passed) differs from the
10 / 93 recorded on the bead. Same failure signature and same root
cause, measured at a different master point.

Filed polylogue-mmf7c separately: `sessions_unenriched` is dead
production surface, not just a dead assertion — it feeds a batch summary
counter that can never be nonzero, so it reads as positive evidence of
no degradation. Left out of scope because removing it touches
`ingest_batch`.

Closes polylogue-p9txi.

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

https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sinity added a commit that referenced this pull request Sep 1, 2026
## Summary

#4339 removed the ledger entry that resolved
`blob_refs.ref_type='sidecar'`, but nothing removed the relation it
describes. `history_sidecars` is still a live source-tier table and the
`blob_refs` CHECK still admits `sidecar`, so the writer remains entitled
to create rows that the readers could no longer resolve. This restores
the owner and the legacy carrier, and couples the two declarations so
they cannot drift apart again.

## Problem

Ten storage tests were red on master. Both consequences are real, and
they point in opposite directions:

- `validated_blob_ref_liveness_joins()` no longer resolved `sidecar`, so
any archive holding such a row returned `BlobLiveness(state=BLOCKED,
blockers=('unknown blob_refs ref_type(s): sidecar',))`. That fails
closed — no over-deletion — but GC stalls on data the writer was
entitled to write.
- `referenced_blob_hashes` omitted sidecar-owned hashes on a legacy
archive carrying `history_sidecars.blob_hash`, making those blobs
GC-eligible. That one is a data-loss risk on a real archive, and it
matters directly to the reindex campaign.

Retiring the ref_type from the DDL CHECK instead would have stranded any
archive already holding sidecar rows — the wrong direction while the
table still exists.

## Solution

- `storage/blob_liveness.py` — restored `BlobOwner("source",
"history_sidecars", ref_type="sidecar", referent_column="sidecar_id")`
- `storage/blob_integrity.py` — `history_sidecars` back in
`_LEGACY_DIRECT_BLOB_CARRIERS`, guarded by the existing
`_column_exists(conn, table, "blob_hash")` check, so it is inert on the
current schema (which uses `content_hash`) and protective on older ones
- new `test_blob_refs_check_vocabulary_and_liveness_join_map_agree` —
nothing previously coupled the `blob_refs` CHECK vocabulary to the
liveness join map, and they live in different files. That gap is what
allowed the drift.

No test was deleted or weakened; all nine failures were production
defects.

The `sessions_unenriched` assertion was vacuous —
`_enrich_parsed_sessions` returns `False` on both paths, so it could not
fail. Its real subject, that a worker never consults the ambient source
tree, was still worth protecting, so it now asserts via a call recorder
that `discover_sidecars` is never invoked. That is strictly stronger
than the previous monkeypatched raise.

## Verification

`devtools test` over the three bead-named files plus the ingest-worker
file: **84 passed**, was 9 failed / 69 passed. Widened to every
`BLOB_OWNERS` / `blob_gc` / `archive_verification` consumer — GC,
excision, retention, migrations, maintenance, CLI, daemon — **265
passed**, and **118 passed** in a further run. `devtools verify
--quick`: all 18 gates ok, zero `out of sync`.

Anti-vacuity, verified by mutation rather than asserted:

| Mutation | Red test |
|---|---|
| Delete the sidecar `BlobOwner` |
`test_blob_refs_check_vocabulary_and_liveness_join_map_agree` |
| Drop `history_sidecars` from `_LEGACY_DIRECT_BLOB_CARRIERS` |
`test_source_capabilities_conserve_mixed_legacy_and_typed_references` |
| Reintroduce on-demand `discover_sidecars` in the worker |
`test_missing_snapshot_does_not_attempt_on_demand_enrichment` |

The first mutation is exactly #4339's edit, so the new guard would have
caught the original regression.

## Residual risk

`devtools verify` (selected/affected) did not run: it exits 2 with
`native_testmon_graph_unavailable` because the lane worktree has no
testmon graph. That is the documented refusal, not a failure of this
change; the targeted runs above are the compensating evidence and prove
their selected scope only.

The failure total measured here (9 failed / 69 passed) differs from the
10 / 93 recorded on the bead. Same failure signature and same root
cause, measured at a different master point.

Filed polylogue-mmf7c separately: `sessions_unenriched` is dead
production surface, not just a dead assertion — it feeds a batch summary
counter that can never be nonzero, so it reads as positive evidence of
no degradation. Left out of scope because removing it touches
`ingest_batch`.

Closes polylogue-p9txi.

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

https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA

Co-authored-by: Claude Opus 5 (1M context) <[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