Repository navigation
fix: Give the rebuild denominator an operator route and rebind attachments per attachment - #5304
Conversation
…rebuild (polylogue-ck5v) Attachment convergence wrote every durable `blob_refs` row for a fetched attachment under one raw-wide coordinate: `source_url or "attachment-convergence"`, and `source_url` is `None` for every Drive-hosted document (sources/parsers/drive_support_attachments.py:114,145 never set it). A raw carrying two live-fetched attachments therefore produced two refs the survival probe could not tell apart. After a derived-tier rebuild both index rows came back `unfetched`, `_surviving_blob_ref` refused as ambiguous, both rows fell through to the provider, and a deleted Drive file marked them terminally `unavailable` while the retained bytes sat unreferenced in the blob store. The acquisition coordinate is now per attachment: `source_url` when the row has one, otherwise the provider file id. The probe and the written ref use the same name, so the ambiguity refusal is reserved for genuinely indistinguishable evidence. `devtools schema closure polylogue/operations/attachment_convergence.py` reports `out`: no derived-schema identity movement, no reconvergence consequence. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
…e-co2iz) `source_manifest_continuity` already builds, seals, loads and preflights the private wanted-source receipt, and `preflight_rebuild` already refuses a missing, tampered, incomplete or policy-revised one. Nothing in production called any of it: `require_rebuild_preflight` had test callers only, so no operator could produce the receipt the final build is supposed to be authorized against, and a rebuild that started without one would simply walk whatever the source roots held at the time. `polylogue ops maintenance wanted-sources` is that route. `--freeze` enumerates the configured declarations once under the campaign policy and atomically publishes the receipt into the archive's private maintenance state; the default direction is read-only and authorizes from the frozen receipt alone, printing the receipt digest, policy identity, declaration and frontier digests and the denominator totals. The output is digest- and count-shaped: source ids, roles and root states, never a path. `devtools schema closure` reports `out` for both production files. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
…lylogue-co2iz) The plain-text branch read its digests and counts back out of the JSON payload dict, so mypy saw `object` where an int format spec and an iteration were required. The command now carries typed locals and a `_RootRow` tuple, and the payload is derived from them rather than the other way round. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Warning Review limit reachedNext included review available in 44 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b485b0a8d
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…e conflicts polylogue-8v4rm AC1 and AC2. AC1 -- ownership. `source_attachments` declares acquired material with a verified `blob_hash` (its DDL CHECK requires hash, bytes and payload identity for `disposition = 'acquired'`, and the writer re-hashes the payload), but `BLOB_OWNERS` did not recognise the table. The only liveness surface for those bytes was `index.attachments`, so a rebuildable tier decided whether durable bytes survived -- the same root polylogue-o0uw5 measured as 1240 of 1446 acquired attachment hashes with no payload left. Direction check: `_direct_surfaces` APPENDS to the surface list, so adding an owner can only move a hash from `unreferenced` to `live`. No path can make a currently reachable hash collectable. The new owner pins exactly the hashes a `source_attachments` row claims were retained -- an acquired original, or a `duplicate`/`partial` row that genuinely carries stored bytes -- so it does not blanket-pin and does not hide a genuine orphan. `source_attachments` is in the current fresh-floor source DDL, so it stays a REQUIRED owner in `_schema_blockers` rather than joining `_OPTIONAL_OWNER_TABLES`, which exists for owners a later additive migration introduced. AC2 -- replay semantics. `record_source_attachments` used `ON CONFLICT(source_generation_id, reference_id) DO NOTHING`, so two different terminal facts for one reference silently kept whichever arrived first, with no record that the archive had been told two incompatible things. Recording now compares the ten declared columns: * identical replay is a no-op (the stored `updated_at_ms` does not move); * `pending` -> terminal is the one allowed progress transition and updates every declared column, inside the caller's batch transaction; * anything else raises the typed `SourceAttachmentConflictError`, naming the reference, the field, and both values. The stored row is unchanged. Row reads select positionally and zip against the declared field tuple: this module does not own the caller's `row_factory`. Not addressed here, reported as unresolved: AC3's explicit representation of unresolved attachment attribution, and AC4's retirement of the remaining per-table liveness interpretations. #5304's finding that ingest keys attachment refs by the RAW SESSION coordinate while convergence keys them by the ATTACHMENT coordinate is untouched by this change -- it adds a direct `blob_hash` owner, not a `blob_refs` ledger entry, so neither vocabulary moves. Verification: devtools test tests/unit/storage/test_blob_gc_durable_intent.py tests/unit/storage/test_blob_gc.py tests/unit/storage/test_blob_liveness.py tests/unit/storage/test_blob_gc_ref_type_liveness.py tests/unit/storage/test_blob_gc_generation_gate.py tests/unit/storage/test_blob_gc_raw_authority_verdict_invariant.py tests/unit/storage/test_source_attachments.py -> 84 of 85 passed, receipt .cache/verify/runs/20260920T213448Z-focused-test-2089150-536344e1/run.json. The single failure, test_blob_gc_durable_intent.py::test_v33_source_migrates_additively_to_exact_gc_member_intent, is INHERITED: it fails identically on a detached checkout of origin/master 005b688 with none of this branch applied (receipt .cache/verify/runs/20260920T213728Z-focused-test-2093977-caf71c1c/run.json, "source migration target 35 is newer than this runtime expects (1)"). It drives a retired source migration chain. Not fixed here. Anti-vacuity, stated on each new test: dropping the `source_attachments` entry from `BLOB_OWNERS` makes the owner test red; restoring `ON CONFLICT ... DO NOTHING` makes the conflict test red; raising on every difference makes the pending-to-terminal test red; raising unconditionally on a second recording makes the idempotent-replay test red. Closure: polylogue/storage/blob_liveness.py and polylogue/storage/sqlite/archive_tiers/source_attachments.py are both IN the derived schema identity closure, so this moves the identity and must land before a rebuild starts. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
) ## Summary `polylogue-co2iz` AC3 requires the final rebuild preflight to accept only a complete, valid receipt and **never silently fresh-walk ambient source roots**. The check existed; the build driver never called it. ## Problem (evidence at `158d1363e`) `require_rebuild_preflight` (`maintenance/source_manifest_continuity.py:664`, real entry `preflight_rebuild` at `:641`) has owned this since #5304. Its complete production caller set was **one CLI command** — `cli/commands/maintenance/_wanted_sources.py:103,138`. `ColdBuildGeneration.begin` — the actual final-build driver — called only `require_candidate_capacity` (`sources/live/cold_build.py:120`). So a cold build could start with **no frozen denominator at all**, and the rebuild's conservation proof would have nothing fixed to reconcile against. ## Solution Authorization runs before allocation and before the capacity walk, because its refusal means *"this build must not happen"* rather than *"not here, not now"*. Like the capacity preflight, it is **not** conditioned on operator intent — the docstring at `cold_build.py:97-102` already settles that: the build engages automatically whenever the active generation is empty, which is exactly the unattended whole-archive case that must not run unauthorized. It *is* conditioned on a denominator existing at all, which is a different question. `build_wanted_source_receipt` itself refuses an empty denominator, so requiring a receipt where no source is declared would make every live-capture-only archive permanently unbuildable. That bootstrap path emits `daemon.cold_build.wanted_sources_undeclared` and is pinned by a test — declared, not silent. Once a receipt *is* published it validates unconditionally even if the roots were later undeclared: a frozen denominator the current configuration no longer matches is a **typed refusal**, never a downgrade. `wanted_source_receipt_is_published` exists to separate "there is no receipt" from "the receipt is tampered", which `load_wanted_source_receipt` reports through one exception type. No branch falls back to walking source roots fresh. ## Verification Exit codes read directly, not through a filter. ``` devtools test tests/unit/sources/test_cold_build_generation.py \ tests/unit/maintenance/test_source_manifest_continuity.py -> PASSED exit=0 receipt .cache/verify/runs/20260922T010507Z-focused-test-224388-d3e0f78c/run.json devtools verify --quick -> exit 0, all 25 gates ok (test-collection 100.0s) devtools gate schema-closure -> ok, 557 members, 0 added, 0 removed ``` Four tests: refuse-unfrozen, refuse-tampered, authorize-valid, and the undeclared bootstrap path — the last pinning the opposite direction so "refuse everything" fails. ## Schema identity `cold_build.py` and `source_manifest_continuity.py` are both closure **IN**, so the derived index identity moves `d5e285b3… → 7cb86235…`; ops is unchanged at `86866235…`. Closure *membership* is unchanged (557 both sides), so no baseline update is required. **This must land before a fresh rebuild starts, never during one.** ## Residual The live host currently declares no source roots (`resolve_runtime_config().source_paths.explicit == ()`), so on that archive this guard takes the declared bootstrap path. Declaring the roots and freezing the receipt against the fresh root is an operator action, and `co2iz` stays open for it — this PR closes AC3's code half only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at f88b4a6):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
Source-custody lane. Two real defects fixed; four beads found already satisfied at head with no change manufactured.
co2iz — the frozen rebuild denominator had no operator route
preflight_rebuild/require_rebuild_preflightexisted but had no production caller at all — grep over the checkout returned its own definition and two test callers. No operator could produce or consume the wanted-source receipt outside tests, so "ingests the intended retained material" had no verifiable denominator.Adds
polylogue ops maintenance wanted-sources, which authorizes from the frozen receipt and emitsreceipt_sha256,policy_identity,declaration_sha256,frontier_sha256and item/byte counts. There is no fallback path that walks the roots — it accepts only a complete, valid receipt.Output is digest/count shaped and never a path; the receipt lives under
<archive_root>/.maintenance-state/wanted-sources/with a0o700state dir.ck5v — attachments of one raw were indistinguishable after a rebuild
New defect, found red-first. Convergence wrote every attachment's
blob_refunder one raw-wide coordinate,source_url or "attachment-convergence"— andsource_urlisNonefor every Drive document. A raw with two live-fetched attachments produced two indistinguishable refs; after a derived-tier rebuild_surviving_blob_refrefused as ambiguous, both rows fell through to the provider, and a deleted Drive file marked them terminallyunavailablewhile the retained bytes sat unreferenced in the blob store.Red at head, verbatim:
AssertionError: assert ['drive-file-...drive-file-a'] == [](receipt
20260920T194301Z-focused-test-1810967-23fd3bd4)Fixed with a per-attachment acquisition coordinate. The test asserts durable index rows and
blob_refscounts, not helper calls; reverting the coordinate restores the red.Found already satisfied — no change manufactured
candidate_capacity.py:757-763called fromindex_generation.py:779beforecreate) and predicted-vs-actual peak recording both implemented at head.(raw_id, capture_mode)with an explicit no-op forNone, so content-hash dedup collapses bytes without collapsing acquisition evidence.attachment_unreferencedproducer defect is already fixed atwrite.py:1631-1646.Verification
Thirteen focused runs, all receipts recorded.
devtools verify --quickexit 0 on the rebased head.devtools render all --checkexit 0,out of synccount 0.devtools schema closure: every production file touched isout— no identity movement, so landing order is unconstrained by closure.One red was reported honestly as contention, not inheritance: a 10k-event throughput assertion measured 1747 events/s against a 2000 floor under a contended pool, then passed alone on the same head. The lane declined to claim inheritance without building an
origin/masterworktree to prove it.Residuals that need owners
blob_refskeyed by the raw session coordinate; convergence looks up by the attachment coordinate. Correct today, but it means widening theupload_origin='drive'filter alone would be a no-op — it selects rows the survival probe cannot match. A future non-Drive backfill owner must fix the key, not the filter.precomputed_blobbranch marks a ChatGPT.datassetacquiredwithout appending anArchiveSourceBlobRef, unlike theinline_bytesbranch beside it. Nothing is unreachable (the index owner keeps it GC-visible), but the durable source ledger has no attachment ref for that acquisition. Worth a ruling before the build.IndexGenerationStore.create_transactionstill has no production caller — the final-build driver does not exist yet. When it lands it should callrequire_rebuild_preflightbesiderequire_candidate_capacity.co2izAC6 names two test selectors that do not exist at head; the AC text is stale.🤖 Generated with Claude Code
https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq