Skip to content

fix: Attachment byte backfill is coupled to one acquisition route, so p… - #4908

Merged
Sinity merged 2 commits into
masterfrom
batch/polylogue-20260912-093158-edf8db49/integration
Sep 12, 2026
Merged

Sinity merged 2 commits into
masterfrom
batch/polylogue-20260912-093158-edf8db49/integration

Conversation

@Sinity

@Sinity Sinity commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Batch polylogue-20260912-093158-edf8db49 on base f12c55d0720f.

polylogue-ck5v Attachment byte backfill is coupled to one acquisition route, so payloads from any other route are never backfilled

@coderabbitai

coderabbitai Bot commented Sep 12, 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: Advanced

Run ID: 6b9d044d-bf55-440b-879a-aa8415975f99


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 commented Sep 12, 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-12T09:52:36.262891Z b8e7db8 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.

@Sinity
Sinity merged commit ffd0ce6 into master Sep 12, 2026
3 checks passed
@Sinity
Sinity deleted the batch/polylogue-20260912-093158-edf8db49/integration branch September 12, 2026 09:55
Sinity added a commit that referenced this pull request Sep 22, 2026
… unchecked claims (#5378)

## Summary

Two coverage reads over `source_attachments` disagreed.
`corpus-attachment-fidelity` already partitioned the `acquired` bucket
correctly; `scan_attachment_coverage` and the `attachment-coverage` gate
collapsed it into a boolean and certified rows they had not checked.
This partitions the second read the same way and stops one write route
from re-asserting acquisition on trust.

## Problem (evidence)

Measured at `158d1363e` on a synthetic `index.db` with three
`acquisition_status='acquired'` rows — one with bytes in the store, one
naming a hash the store does not hold, one with `blob_hash` NULL:

- `scan_attachment_coverage` returned `{acquired_count: 3,
acquired_reachable_count: 3, acquired_missing_blob_count: 1}` — **no
term at all** for the NULL-hash row, because of `if blob_hash is None:
continue`.
- On a lone hashless acquired row the `attachment-coverage` gate printed
`OutcomeStatus.OK` with the summary `all 1 acquired attachment(s) have
bytes and a live attachment reference` — a false sentence about an
archive where it had checked nothing.
- `_surviving_blob_ref` gated the re-bind on `blob_store.exists()` ("a
file sits at that path") and then wrote `acquisition_status='acquired'`.
A published blob corrupted in place produced `{recorded_hash: 664656fb…,
actual_hash_of_file: 4ca8451f…, byte_count_claimed: 32, actual_size: 31,
downloads_attempted: []}` — acquisition re-asserted with no provider
request and no signal.

The bead's other cited defect (`DriveNotFoundError` recorded as
`acquired`) does **not** reproduce at head; it terminates `unavailable`
and has since #4873/#4908. That citation is stale.

## Solution

- `AttachmentCoverageReport` partitions `acquired` into
`acquired_with_bytes_count` (corroborated),
`acquired_missing_blob_count` (contradicted) and
`acquired_unverifiable_count` (nothing to check), published side by side
in `to_dict()`. Following #5367's
`raw_materialization_unmeasured_reason`, an unmeasured claim gets its
own term rather than folding into the nearest boolean.
- `ok` is false for either non-corroborated term, so an unmeasured claim
blocks exactly as a false one does — without the report ever asserting
bytes are absent.
- The survivor probe uses `blob_store.verify()`, not `exists()`. A
contradicted survivor is not evidence: it falls through to the provider,
and emits `operations.attachment_convergence.survivor_contradicted` at
WARNING/`outcome=degraded` so a decayed published blob is not silently
erased by a re-download.

## Verification

```
devtools verify --quick                    exit 0   25 gates ok (schema-closure, atlas, layering, test-collection)
devtools render all --check                exit 0   8 "sync OK", 0 "out of sync" (grep -c on captured log)
devtools test <8 attachment selections>    exit 0   198 passed in 75.25s
```
Receipt
`.cache/verify/runs/20260922T003420Z-focused-test-183221-b5c5388c/run.json`.

Inherited-red baseline at `158d1363e` in this worktree: `177 passed`,
exit 0 — no inherited reds in the touched scope.

Anti-vacuity conditions were **executed**, not asserted. Restoring `if
blob_hash is None: continue` → 3 failed, including `assert
<OutcomeStatus.OK> is <OutcomeStatus.ERROR>` with summary `all 1
acquired attachme…`. Reverting `debt_count` to `missing + unreachable` →
1 failed, whose evidence dict reads `'unverifiable_count': 1` beside
that same summary — the exact claim/measurement split. Reverting
`verify()` to `exists()` → `assert [] == ['drive-file-1']`, the
corrupted survivor re-binding with no provider request.

## Schema identity

Does not move. `derived_schema_identity` at `158d1363e` equals that at
this head for both derived tiers (index `d5e285b3…`, ops `86866235…`).
All six changed files report `out`; `storage/blob_liveness.py` is the
one IN-closure file in the area and was deliberately not touched. No
DDL, no vocabulary member — `acquisition_status` keeps its existing
three-value durable CHECK. Safe to land at any point relative to the
build boundary.

## Residuals

- **Criterion 5 of polylogue-o0uw5 is not discharged by this branch.**
Which route removed the 1242 blobs is still unnamed; the evidence is
`gc_generations` in `source.db` and the daemon event log, neither read
here. The bead's own design marks it not dispatchable to a code worker.
- Live census (read-only, reflink copy, deleted after): 1933 `acquired`
rows, 1446 distinct acquired hashes, 204 with bytes, **1242
contradicted** — the bead's 1240/1446 still reproduces. **0** acquired
rows with NULL `blob_hash`, so the unverifiable term guards a latent
shape the live archive does not currently contain.
- Oversize attachments and explicit 404s both terminate `unavailable`,
but for an oversize file the provider still has the bytes — the same
overstated claim in the opposite direction. Out of scope; wants its own
bead.
- `demo/constructs.py:104` claims stored bytes but its SQL never
consults the store.
- `daemon/webui_data.py` collapses six attachment states into
`missing-blob`.

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

https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Attachment coverage now flags acquired attachments without verifiable
blob identity as blocking issues.
* Coverage reports distinguish attachments with bytes, missing blobs,
and unverifiable blobs, including counts and sample details.
* Corrupted retained blobs are rejected and re-fetched when possible,
preventing invalid attachments from being rebound as acquired.
* When recovery fails, affected attachments are correctly marked
unavailable without retaining invalid blob data.

* **Tests**
* Added coverage for unverifiable attachments, corrupted blobs, and
recovery failures.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

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