Repository navigation
fix(sources): fix cross-material isolation guard + dedup census parse by blob_hash - #3234
Conversation
…own ambiguous cohort
Problem
Ref polylogue-52l2. classify_raw_revision_cohort classifies a byte-prefix
chain from whichever raw_sessions rows currently carry
revision_kind='full' for a logical_source_key -- not against the complete
sibling population for that identity. Retiring an ambiguous sibling to
membership governance (replace_raw_membership_census(...,
retire_full_revision_governance=True), what the backfill/live-watcher
callers do once a cohort is decided ambiguous) nulls that raw's
raw_sessions.logical_source_key, so it disappears from the query. A THIRD
raw for the same identity, discovered afterward (e.g. a re-acquired
browser-capture snapshot), is then evaluated completely alone:
classify_historical_full_revision_streams unconditionally accepts a
one-member stream as a byte-proven baseline (no sibling to prove a byte
prefix against), so the isolated raw permanently becomes the accepted
session content -- an outcome that depends on incremental discovery
order, not on which content is actually correct.
Reproduced directly against ArchiveStore (test_revision_replay.py),
mirroring the live incremental watcher's own call sequence
(sources/live/batch.py: bind_raw_revision then
classify_raw_revision_cohort, no census-phase re-derivation in between).
The equivalent two-call scenario through backfill_historical_revision_evidence
does NOT reproduce: its census phase unconditionally re-parses every
still-unindexed raw and its connected-component selection expansion
reunites retired siblings by shared membership evidence before
classification runs -- protections the live incremental path lacks.
Solution
- New ArchiveStore.raw_membership_retired_full_revision_siblings(): finds
raw_session_memberships rows for a logical_source_key whose
raw_membership_census.detail matches the (now shared)
HISTORICAL_NON_PREFIX_GOVERNANCE_DETAIL marker written at retirement --
survives the raw_sessions.logical_source_key NULL-out.
- classify_raw_revision_cohort refuses the byte-chain path entirely (empty
full_rows) whenever this identity has retired sibling evidence, so the
caller's existing "no accepted chain" fallback
(convertible_full_revision_raw_ids) folds the newly-discovered raw into
membership governance instead, where the real prefix-based classifier
weighs every known sibling together, rather than silently establishing
a wrong permanent head.
- Unified the two retire_full_revision_governance call sites'
previously-divergent detail strings ("historical non-prefix full
revision governance" in revision_backfill.py, "cross-route full
revision governance" in live/batch.py) onto the one shared constant so
the guard recognizes retirement from either path.
Deferred (not in scope for this fix): once an identity's retired siblings
are recognized, nothing in the LIVE incremental watcher path (unlike
offline backfill) currently re-unites them with the new raw for a real
membership decision -- it fails closed instead (logs "no unique
byte-revision candidate accepted ... surfacing as failed"), correctly
never establishing wrong content, but requiring a later offline
backfill/repair pass to resolve the identity. Also out of scope: PR #3204
already tracks a known, separate limitation (a content-ahead capture
still yielding to a byte-kind chain head) as polylogue-nfl5.
Verification
devtools test tests/unit/storage/test_revision_replay.py
tests/unit/sources/test_revision_backfill.py tests/unit/storage/test_raw_retention.py
-> 178 passed (60 + 59 + 59). New regression
test_isolated_later_raw_does_not_override_known_ambiguous_cohort fails on
unmodified master (asserts accepted_raw_ids == () but gets the isolated
raw's id) and passes after this change. mypy --strict clean on the four
touched modules.
Ref polylogue-52l2
Co-Authored-By: Claude <[email protected]>
Problem Ref polylogue-869u. Live evidence (2026-07-19, source.db): the newest-revision-per-logical_source_key population is 87,177 rows / 52.1 GiB, but only 85,066 DISTINCT blob_hash values / 43.4 GiB -- the same bytes (e.g. one 442MB codex computer-use rollout) recur under up to 8 different logical_source_keys / source paths, from re-acquisition or re-export. The existing dedup (#3151, _parse_retained_raws) only collapses rows sharing BOTH blob_hash AND source_path, so this whole cross-path duplicate population -- 8.7GB / 17% of newest-only bytes -- still paid a full parse per row. Solution _parse_retained_raws' grouping key now drops source_path for a new _PATH_INDEPENDENT_PARSE_PROVIDERS allowlist (ChatGPT, Claude web/Code, Codex, Gemini/Gemini CLI, Grok, Drive): those parsers derive session identity purely from payload bytes, so identical bytes decode identically regardless of acquired path. Providers whose parse DOES depend on source_path keep the original (blob_hash, source_path) key unchanged: Beads derives workspace-scoped native ids from source_path (sources/parsers/beads.py:_repository_root), Antigravity's brain-metadata mode and Hermes' ATOF/ATIF/verification-evidence modes derive profile_root from source_path (sources/dispatch.py). Provider.UNKNOWN stays path-scoped too, out of caution. Updated the existing test_parse_retained_raws_dedupes_identical_blob_and_path (renamed test_..._across_paths_for_safe_providers) to assert the new cross-path Codex dedup; added test_parse_retained_raws_preserves_path_scoped_dedup_for_path_dependent_providers to prove Beads rows at different paths still parse separately (the safety property this change must not regress). Verification (dedup receipt) Synthetic corpus: 40 distinct ~300KB Codex payloads, each duplicated across 5 different source paths (200 raw rows total, mirroring the live re-acquisition-stampede shape) -- measured via tests/infra/revision_backfill_benchmark.py-style corpus construction, counting real _parse_retained_raw invocations: before (blob_hash+source_path key): 200 parse calls, 0.516s wall clock after (blob_hash key, safe providers): 40 parse calls, 0.104s wall clock 160 avoided parse calls (80% reduction) on this corpus; proportional to duplicate ratio on the live archive's 17% figure. devtools test tests/unit/sources/test_revision_backfill.py -> 40 passed. devtools test tests/unit/storage/test_revision_replay.py tests/unit/storage/test_raw_retention.py tests/property/test_sql_injection_boundary.py -> 120 passed. mypy --strict clean. Ref polylogue-869u Co-Authored-By: Claude <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughThe PR centralizes a full-revision governance detail marker, applies it during live and backfill census updates, prevents classification from incomplete retired sibling state, and changes retained-raw parsing deduplication according to provider path dependence. ChangesFull revision governance
Retained-raw parsing deduplication
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ArchiveStore
participant SQLite
participant CohortClassifier
ArchiveStore->>SQLite: Query retired full-revision siblings
SQLite-->>ArchiveStore: Return retired raw IDs
ArchiveStore->>CohortClassifier: Clear full rows when retired siblings exist
CohortClassifier-->>ArchiveStore: Use no-accepted-chain fallback
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
Coordinator stand-in review (CodeRabbit still pending): read the full 415-line diff.
Merge is HELD until the v42 walk hits terminal — this PR changes |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
polylogue/archive/revision_authority.py (1)
242-252: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExport
HISTORICAL_NON_PREFIX_GOVERNANCE_DETAILin__all__.Since
HISTORICAL_NON_PREFIX_GOVERNANCE_DETAILis a public constant explicitly imported and used across multiple layers (e.g.,live/batch.py,revision_backfill.py,archive.py), consider adding it to the__all__declaration for completeness and consistency.♻️ Proposed refactor
__all__ = [ + "HISTORICAL_NON_PREFIX_GOVERNANCE_DETAIL", "HistoricalRawRevision", "HistoricalRawRevisionStream", "HistoricalRevisionDecision",🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@polylogue/archive/revision_authority.py` around lines 242 - 252, Add the public constant HISTORICAL_NON_PREFIX_GOVERNANCE_DETAIL to the __all__ list in revision_authority.py, alongside the other exported revision symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@polylogue/archive/revision_authority.py`:
- Around line 242-252: Add the public constant
HISTORICAL_NON_PREFIX_GOVERNANCE_DETAIL to the __all__ list in
revision_authority.py, alongside the other exported revision symbols.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 599ea61d-8233-4af1-b9a1-ec079910d0f0
📒 Files selected for processing (6)
polylogue/archive/revision_authority.pypolylogue/sources/live/batch.pypolylogue/sources/revision_backfill.pypolylogue/storage/sqlite/archive_tiers/archive.pytests/unit/sources/test_revision_backfill.pytests/unit/storage/test_revision_replay.py
|
CodeRabbit triage: 1 finding (trivial) — |
…f+miwv residuals v42 generation gen-1784486727919-da69ed72 promoted after 36-pass resumable walk; verification checklist green (0 dup variants, FTS delta 0, 0 dangling branch points, cost rollups populated). PRs #3234 #3235 merged post-terminal. 623q updated with terminal receipt + whale spill evidence. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QUsH3Rhq6oAZpYPWcsZqnZ
## Summary Implements both named residuals from polylogue-52l2 (fixed in PR #3234, merged b3429fa), tracked as polylogue-hm2f: 1. Widen the 52l2 guard query to recognize the legacy pre-#3234 durable detail-string literal, not only the current shared constant. 2. Give the live incremental watcher a route to reunify a newly discovered raw with siblings already retired to membership governance, instead of failing closed forever. ## Problem ### 1. Legacy detail-string coverage `raw_membership_retired_full_revision_siblings` (the #3234 guard's lookup) matches `raw_membership_census.detail` against `HISTORICAL_NON_PREFIX_GOVERNANCE_DETAIL` only. Durable rows written by `sources/live/batch.py` *before* #3234 used a different literal, `"cross-route full revision governance"`, at that call site. Those durable `source.db` rows were never rewritten (durable-tier changes need an explicit additive migration, not a silent detail-string rewrite), so identities retired under the legacy literal are invisible to the guard -- they retain the original discovery-order bug. ### 2. Live-path fails closed with no reunification route #3234's guard correctly stops an isolated later-discovered raw from being silently accepted over known-ambiguous siblings, but it fails CLOSED: `classify_raw_revision_cohort` returns an empty cohort and the live watcher (`sources/live/batch.py`) just logs a warning and marks the file failed, permanently. Only the offline `backfill_historical_revision_evidence` path has the census/retirement bookkeeping to move a full-only cohort into membership governance where the real content-prefix classifier (`classify_membership_revisions`) can arbitrate it. A real, resolvable identity would otherwise sit unresolved forever without a manual offline backfill run. ## Solution ### Legacy detail-string coverage `polylogue/archive/revision_authority.py`: added `RETIRED_FULL_REVISION_GOVERNANCE_DETAILS`, a frozen tuple naming every detail literal that means "retired from full-revision byte governance" -- the current shared constant plus the legacy literal, documented read-only (never write). `ArchiveStore.raw_membership_retired_full_revision_siblings` (`polylogue/storage/sqlite/archive_tiers/archive.py`) now matches `c.detail IN (...)` against the whole tuple, using the repo's trusted `where_clause` f-string-fragment pattern with fully parameterized values (no user data interpolated). ### Live-path reunification `polylogue/sources/live/batch.py`: when `classify_raw_revision_cohort` returns an empty cohort in the single-session non-membership branch, query `raw_membership_retired_full_revision_siblings` before giving up. If it names known retired siblings, fold the new raw into membership governance via the existing `_apply_membership_sessions` helper (the same one already used for the browser-capture and pre-existing- membership branches), extended with a new `extra_member_raw_ids` parameter -- `archive.raw_membership_raw_ids()` alone cannot see retired siblings, since retirement leaves their membership row at the default `revision_authority='quarantined'`; only the durable detail marker still names them. The real classifier then weighs the new raw against every known sibling instead of evaluating it alone. A genuine three-way conflict is still correctly quarantined as ambiguous -- this recovers a real resolution when one exists, it never fabricates one. If no retired siblings exist (first-encounter divergence), behavior is unchanged (fail closed). This is full within-tick reunification, not retire+defer: the live path re-derives the sibling set from the same durable marker the 52l2 guard itself reads, so no additional `convergence_debt` plumbing was needed for correctness. ## Verification - `devtools test tests/unit/storage/test_revision_replay.py tests/unit/sources/test_revision_backfill.py` -> 61 passed, 1 pre-existing unrelated failure (`test_backfill_resumes_after_replay_batch_crash_discards_whole_batch_cleanly`, `messages_fts_identity` UNIQUE constraint) -- reproduces identically on unmodified master (confirmed via `git stash`/rerun). - `devtools test tests/unit/sources/test_live_batch_support.py` -> 126 passed, 5 pre-existing unrelated failures (same `messages_fts_identity` cause, from #3235's rowid-reuse ledger under xdist) -- also reproduces identically on unmodified master. - `devtools test tests/property/test_sql_injection_boundary.py` -> 40 passed (archive.py touched a SQL WHERE clause). - `mypy --strict polylogue/archive/revision_authority.py polylogue/storage/sqlite/archive_tiers/archive.py polylogue/sources/live/batch.py` -> clean. - `devtools verify --quick` -> exit 0 (ran twice: pre-commit and pre-push hooks). - Anti-vacuity, both new tests: reverted the corresponding production file only (`git stash`) and reran -- each test fails with the exact pre-fix symptom (missing legacy-literal match; the original "no unique byte-revision candidate accepted ... surfacing as failed" warning with no `raw_session_memberships` row for the third raw), then passes again after restoring the fix. ## AC matrix - Legacy detail-string coverage (durable pre-#3234 rows recognized by the guard): **satisfied** -- `test_isolated_later_raw_does_not_override_cohort_retired_under_legacy_detail_string`. - Live-path cross-tick reunification (a later raw joins known retired siblings under real content-prefix arbitration instead of failing closed forever): **satisfied** -- `test_live_third_raw_reunifies_with_backfill_retired_siblings`, full within-tick reunification (not retire+defer); chosen because the live path can cheaply re-derive the sibling set from the same durable marker the guard already reads, so no separate convergence-debt plumbing was required for correctness. Ref polylogue-hm2f Co-Authored-By: Claude <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved live ingestion handling when no revisions are initially accepted. - Reunifies newly discovered records with existing membership-governed revision cohorts instead of silently dropping them. - Preserves compatibility with both current and legacy governance markers. - Prevents isolated later revisions from incorrectly overriding established cohorts. - **Tests** - Added regression coverage for live ingestion reunification and legacy governance behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <[email protected]>
) ## Summary Fixes 2 test failures reported on current master (`test_bundle_replay_respects_unconvertible_single_session_head[bundle_texts2-False-False]` and `[bundle_texts3-False-True]` in `tests/unit/sources/test_live_batch_support.py`). Root cause is **not** related to `messages_fts_identity`/polylogue-miwv's earlier work (PR #3239) — diagnosis below. ## Problem The working hypothesis (from another lane) was that PR #3239's `messages_fts_identity` `INSERT OR REPLACE` fix removed an `IntegrityError` abort that had been accidentally masking this test failure. That hypothesis is **disproven**: the exact same failure reproduces identically on commit `b3429fae6` (#3234), the commit immediately *before* `messages_fts_identity` (#3235) was even introduced. Bisecting by direct commit checkout (not `git stash`) traced the real regression to PR #3211 ("tree-byte decoded layer + in-cohort head-retire drift fix", 2026-07-20, ~10.5h before #3235). That PR removed a byte-governance refusal from `ArchiveStore.apply_raw_membership_classification` on the premise that its branch is only reachable after a real membership-governance conversion — but `_apply_membership_sessions` (`sources/live/batch.py`) unconditionally injects the *current* accepted head into the comparison cohort even when it was never converted (exactly PR #2718's original scenario: a byte-governed head compared against membership-discovered content for the first time). With the guard gone, a later-discovered bundle raw whose content happened to strictly extend the byte-governed head's content silently replaced the head via membership governance — confirmed with a standalone diagnostic script: `message_count` moved 2→3, `accepted_raw_id` changed, even though the head still had a live, unresolved `QUARANTINED` append raw blocking ordinary byte-chain conversion. The fail-closed contract was genuinely violated, not merely a reporting-list discrepancy. #3211 shipped this bundled into an unrelated perf PR without running `test_live_batch_support.py` in its own verification. ## Solution Restored a byte-governance refusal in `apply_raw_membership_classification`, narrower than #2718's original blanket `logical_source_key IS NOT NULL` check so #3211's own interrupted-pass-drift resumption keeps working: refuse only when (a) replay is about to *change* which raw is accepted, and (b) a live `raw_sessions` row elsewhere in this logical identity still chains a `predecessor_source_revision` off the existing head's own `source_revision` and isn't already part of the classified cohort — genuine unresolved byte-append evidence, not merely "was this raw ever membership-converted". ## Verification - Bisected via direct commit checkout: reproduced on `b3429fae6` (pre-#3235); traced the introducing diff to `996a3d6d3` (#3211) via `git log -S` on the removed guard string. - `devtools test tests/unit/sources/test_live_batch_support.py -k test_bundle_replay_respects_unconvertible_single_session_head` → 4 passed (all parametrizations, including the `succeeds=True` case) - `devtools test tests/unit/sources/test_live_batch_support.py tests/unit/storage/test_revision_replay.py tests/unit/sources/test_revision_backfill.py` → 136 passed - `devtools test tests/unit/storage/test_raw_retention.py` → 59 passed - `mypy --strict polylogue/storage/sqlite/archive_tiers/archive.py tests/unit/sources/test_live_batch_support.py` → Success, no issues - `devtools verify --quick` → exit 0 (also regenerated `docs/topology-status.md`, already out of sync on unmodified `origin/master` before this branch — unrelated pre-existing drift, picked up incidentally) - Anti-vacuity: reverted just the new guard body to a no-op and reran the 4-case test → 2 of 4 failed with the exact original symptom; restored and reran → 4 passed ## AC matrix | AC | Status | | --- | --- | | Diagnose true mechanism (bisect between the 3 merged changes) | Satisfied — root cause is #3211, not messages_fts_identity/miwv | | Determine whether content actually lands or reporting-only | Satisfied — content genuinely landed before this fix | | Fix production path to preserve explicit refusal | Satisfied | | `head_after == head_before` + `message_count` stays `(2,)` for `succeeds=False` | Satisfied (already asserted by the pre-existing test, now passing) | Ref polylogue-miwv Co-authored-by: Claude <[email protected]>
…polylogue-sze30) `raw_membership_census.detail` is load-bearing prose. When `replace_raw_membership_census(..., retire_full_revision_governance=True)` retires a raw, it nulls the raw's `logical_source_key` and quarantines it, so the surviving census marker is the only evidence that reaches the polylogue-52l2 guard: `raw_membership_retired_full_revision_siblings` (revision_governance.py:1229-1241) and `_raw_revision_source_path_has_divergent_evidence` (:1263-1291) both find the retired sibling by `detail IN (...)` alone. The writer accepted any string. A marker outside `RETIRED_FULL_REVISION_GOVERNANCE_DETAILS` did not fail: it made the retirement invisible, and a later-arriving sibling for the same identity was then accepted as an unconditional singleton byte-proven baseline. That is AC2's "unknown source values silently become success", reached through the ordinary write route. The write boundary now refuses it, so the reader's vocabulary (archive/revision_authority.py:199-202) is the single owner that producers must satisfy. A census leaving no membership row keeps free explanatory prose -- it has no logical identity to be ambiguous about, which is what the two empty-census retirement call sites (codex_state_evidence.py:310, revision_backfill.py:1379) rely on. The check sits after the `ActiveByteRevisionChainError` check and before any mutation. Not done, and off this bead's gate: migrating the marker to a typed code column. The fresh archive never writes the retired sentences, and the legacy pre-#3234 literal stays read-only for durable rows. Anti-vacuity: the test's second half rewrites an accepted retirement's detail to the unrecognized marker and shows the isolated third raw IS then promoted alone, so the refusal protects an outcome rather than a spelling. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
…polylogue-sze30) `raw_membership_census.detail` is load-bearing prose. When `replace_raw_membership_census(..., retire_full_revision_governance=True)` retires a raw, it nulls the raw's `logical_source_key` and quarantines it, so the surviving census marker is the only evidence that reaches the polylogue-52l2 guard: `raw_membership_retired_full_revision_siblings` (revision_governance.py:1229-1241) and `_raw_revision_source_path_has_divergent_evidence` (:1263-1291) both find the retired sibling by `detail IN (...)` alone. The writer accepted any string. A marker outside `RETIRED_FULL_REVISION_GOVERNANCE_DETAILS` did not fail: it made the retirement invisible, and a later-arriving sibling for the same identity was then accepted as an unconditional singleton byte-proven baseline. That is AC2's "unknown source values silently become success", reached through the ordinary write route. The write boundary now refuses it, so the reader's vocabulary (archive/revision_authority.py:199-202) is the single owner that producers must satisfy. A census leaving no membership row keeps free explanatory prose -- it has no logical identity to be ambiguous about, which is what the two empty-census retirement call sites (codex_state_evidence.py:310, revision_backfill.py:1379) rely on. The check sits after the `ActiveByteRevisionChainError` check and before any mutation. Not done, and off this bead's gate: migrating the marker to a typed code column. The fresh archive never writes the retired sentences, and the legacy pre-#3234 literal stays read-only for durable rows. Anti-vacuity: the test's second half rewrites an accepted retirement's detail to the unrecognized marker and shows the isolated third raw IS then promoted alone, so the refusal protects an outcome rather than a spelling. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
… fact (#5424) ## Summary One real fix, plus four schema-shape beads reconciled against head — of which **one AC is proven unperformable by executing it**, one is already satisfied, and one is deliberately deferred by its own ruling. ## Fixed `polylogue/archive/revision_authority.py` now splits the full-revision-governance detail markers into `WRITABLE_…` (1 member) and `LEGACY_…` (the pre-#3234 spelling), with `RETIRED_…` as their union. `revision_governance.py:2196` narrows the **write** boundary from the read set to the writable set. Before this, the declaration's own comment said the legacy spelling was "read-only, never write" and **nothing enforced it**. A writer could mint it, after which no query could distinguish a durable pre-#3234 row from a new one — which is precisely what makes the compatibility branch unretireable after the rebuild. Anti-vacuity executed: reverting the guard to the read vocabulary gives `Failed: DID NOT RAISE ValueError` at `test_revision_replay.py:1675`. The opposite direction is pinned too — the writable marker must still apply, so a blanket refusal cannot pass. ## `cuxz.11` — already satisfied, plus a real gap nobody had named The dispatch said "nothing is done". **Three of its four claims were wrong**, and the lane refuted each at base `9ef655cb8`: - **AC1 was already satisfied** — `write.py:6519 if policy_values != last_agent_policy:` emits a row only on genuine change, landed in #5309, with a comment naming this bead. - **`PRIMARY KEY(session_id, position)` is not the forbidden grain** — `position` is the offset where a retained *interval starts*, so the PK constrains interval starts, not per-message rows. - **The "100%-NULL index" is partial** — `WHERE source_message_id IS NOT NULL` at `index.py:1002` and again at `runtime_indexes.py:18`. A NULL column costs zero index entries. The 100%-NULL census is historical, exactly as the 2026-09-07 note cautioned. What *was* missing is the **append path**: `_last_agent_policy_values` now reads the highest-position stored row so an appended chunk compares against stored state. No test covered it, and live sessions are appended to many times. Mutation (`return None`): `Left contains one more item: (1, 'on-request', 'read-only', 'restricted')`. AC4 (row count against the 402,869 baseline) is **READY-AT-BUILD** — a live-archive measurement, nothing in code blocks it. ## `3szyi` AC2 — proven unperformable, by executing it The AC asks for durable CHECK constraints generated from Python enum owners. A `PolylogueStrEnum` carrying `audit.destructive_class`'s six members was injected into `archive_tiers/source.py` and the real gate run: ``` Enum-derived membership CHECKs found in durable tiers: 1 audit: destructive_class matches _TempDestructiveClass GATE_EXIT=1 ``` Reverted → exit 0. **Doing what the AC mandates makes `devtools verify` red.** `gate durable-enum-checks` refuses exactly this construct, because it pins an enum's evolution into a tier that only moves by numbered migration. 42 of the 54 hand-written lists are on durable tiers. The correct durable remedy is **delete-and-validate-at-the-write-boundary** (`require_vocabulary`), not generate. Exactly one durable list has an enum owner today (`source.outcome_code`), and it is an explicit grandfathered pre-policy waiver. Census measured with the gate's own classifier so it matches enforced policy: **54** typed value lists (source 26, audit 13, ops 7, user 3, specs 3, index 2 — the index pair are partial-INDEX predicates, not CHECKs). The bead's own raw grep of 76 counts f-string-rendered lists too. The 12 non-durable lists have **zero** exact Python owners and are narrow storage-local vocabularies — their correct disposition is AC4 (STORAGE_LOCAL with a stated reason), a small real change nobody has made. ## `a7xr.27` — deferred by its own ruling, and three records disagree on the counts The sequencing note exists: label `timing:post-reindex`, with a 2026-08-24 ruling that this is "worthwhile substrate completion but is not required to reconstruct the archive correctly." Nothing in this wave needed a tier's spec adoption, so **nothing was landed**. Re-measured at head, and **the bead, its own scoping note, and the dispatch each carry a different wrong count**: | tier | CREATE TABLE | spec-rendered | |---|---|---| | index | 36 | 35 | | embeddings | 5 | **5 — fully adopted** | | source | 32 | 0 | | ops | 17 | 0 | | user | 17 | 0 | | audit | 14 | 0 | | bootstrap | **0** | 0 | So 80 hand-written across five tiers — not 89 (bead), not ~86 (dispatch), not 84 (its scoping). Embeddings is **not** "6/5 un-adopted"; the sixth match was a comment saying it is adopted. `bootstrap.py` has zero CREATE TABLE. Also corrected: the scoping's claim that #5290 emptied the migration directories is **false** — `migrations/source/002` and `migrations/user/002` both exist with `.train.json` sidecars. Only `migrations/audit/` is bare, so the audit tier's route is declared-but-unexercised. ## Verification | command | exit | |---|---| | `devtools verify --quick` at base | 0, 25/25 | | `devtools verify --quick` at rebased head | **0, 25/25** (`durable-enum-checks`, `schema-manifest`, `schema-closure` all ok) | | `devtools render all --check` | 0, `out of sync` = **0** | | `test_revision_replay.py` + `test_archive_write.py` | 0 | | downstream consumers (169 tests) | 1 non-passing — **inherited** | Inherited red proven at base in a detached checkout: `test_owned_nonempty_generation_refuses_cold_build_deferral`, identical nodeid, 1 of 109. ## Schema closure — reconvergence required Both changed files are **IN**. `DerivedTier.index`: `96aca24d…` → **`d947bd97…`**; `ops` unchanged. **No DDL changed** — this is the AST-closure case CLAUDE.md describes. `gate schema-closure` green, membership unchanged, `INDEX_SCHEMA_VERSION` untouched at 107. **Must land before a fresh rebuild starts, never during one.** ## Residuals - **Latent gate gap:** `verify_durable_enum_checks.py` only walks `PolylogueStrEnum` subclasses, so a durable CHECK generated from a `typing.Literal` would evade it while carrying the same durability cost. Latent, not live — the durable tiers have zero generator call sites today. The embeddings conversion this bead already landed used `Literal` owners. - **`sze30` full removal** needs `migrations/source/003` adding a typed `detail_code` plus a backfill, and re-pointing four producers, three outside this scope. The read/write split landed here is what makes the eventual drop *provable*: once the rebuilt archive contains no row carrying the legacy spelling, `LEGACY_…` can go. - `audit.required_confirmation`/`confirmation_strength` and `audit.principal_surface`/`surface` are byte-identical member sets — real collapse candidates, both durable. 🤖 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]>
…t in integration (#5477) ## Summary Second single-wave batch: **13 `gpt-5.6-luna` workers, 34 beads**, integrated into one branch and verified once. Five lanes produced commits; eight were read-only adjudication lanes that produce evidence rather than code. Zero merge conflicts across eight parallel write worktrees, for the second wave running. ## What landed | commit | bead | |---|---| | `test(daemon): prove bounded attachment pagination` | `q54dt` — AC1–AC5 | | `fix(daemon): expose writer hold evidence` | `bp12n.5` — AC4 partial, AC5 | | `fix(storage): key retirement governance by typed authority` | `sze30` — AC2 | | `fix(polylogue-wzgpf): persist structural ZIP member identity` | `wzgpf` — AC2/AC4/AC7 | | `test(polylogue-1xc.14.1): reuse pilot resources per worker` | `1xc.14.1` | | `fix(storage): keep the legacy governance marker unwritable` | coordinator fix, below | ## The regression integration caught `sze30`'s typed-authority change deleted this branch: ```python if detail in LEGACY_FULL_REVISION_GOVERNANCE_DETAILS: raise ValueError("legacy marker is read-compatibility only and may never be written") ``` reasoning that authority is the protocol value and detail is display text. The first half is right. But with the guard gone the legacy spelling is refused only *as a side effect* of the quarantined-authority check — so a producer passing `RawRevisionAuthority.QUARANTINED` explicitly would mint the retired spelling afresh, and no query could then distinguish a pre-#3234 row from a new one. That is precisely the compat-branch trap `sze30` exists to close, reintroduced by the commit meant to close it. It surfaced because `test_legacy_governance_marker_is_never_writable` went red — a test written under this same bead, whose docstring says "both directions are pinned, so a blanket refusal cannot pass this test." The guard is restored unconditionally and ahead of the authority check. Typing the authority frees the *wording* of a recognized marker; it does not revive the retired one. Both tests now pass together, so the two requirements were never actually in conflict. ## Verification — once, over the integrated result ``` devtools verify --quick -> PASSED exit=0 devtools test <6 touched test files> -> 151 passed, exit 0 ``` ## Adjudication results (no code, but they move the closure) Eight read-only lanes. Closed this wave on proven evidence: `eug7l`, `xvwpi`, `62j1f`, `b55z1`, `kc8eq`. Key premise corrections: - **`pnxl6`** — claimed 4 ops tables to diet; there are **24 live / 20 declared**, and `secret_scan_status`, `whole_archive_convergence_pledge`, `context_injection_ledger` are restart-required state, not telemetry. - **`a7xr.27`** — the 89-table census is stale; current count is **84**. - **`cuxz.11`** — measured read-only with no build: **402,879 rows / 3,034 sessions / 3,056 distinct facts**, `source_message_id` 100% NULL. - **`z9gh.7.2` AC7** — not merely unmet but **+1126 LOC against its reduction target**. - **`bp12n.4`** — cold CLI **3211–4125 ms** against a 500/800 ms budget. - **`8r4zq`** — refuted again with mechanism; its titled fix would introduce the defect AC1 forbids. - **`lisa2`** — genuinely build-gated: the conservation check is owner-routed and refuses with `SchemaSkewError: expected 4, found 30`, so no read-only route reaches it. `8xvlf` is proven satisfied but left open — it is assigned to the operator. ## Residual Master carries **11 failing tests** unrelated to this branch (`test_embed_status_fast.py` ×10, `test_daemon_client_import_does_not_load_storage`). Confirmed present at `5f9210b6d^`, so they predate wave 1. They accumulated unseen because the `pytest` and `pytest-heavy` pueue groups had been paused since a `verify_all` failure on 2026-09-22 — no pytest ran on master for over a day, while `verify --quick` stayed green because it is static-only. Groups resumed; failures tracked separately. 🤖 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]>
Summary
Two fixes in the revision-authority census area, sharing the raw-materialization footprint:
blob_hashacrosssource_pathfor providers whose parse identity is byte-content-only, avoiding redundant full parses of byte-identical duplicate blobs.Problem
polylogue-52l2
classify_raw_revision_cohortclassifies a byte-prefix chain from whicheverraw_sessionsrows currently carryrevision_kind='full'for alogical_source_key— not against the complete sibling population for that identity. Retiring an ambiguous sibling to membership governance (replace_raw_membership_census(..., retire_full_revision_governance=True), what the backfill/live-watcher callers do once a cohort is decided ambiguous) nulls that raw'sraw_sessions.logical_source_key, so it disappears from the query. A THIRD raw for the same identity, discovered afterward (e.g. a re-acquired browser-capture snapshot), is then evaluated completely alone:classify_historical_full_revision_streamsunconditionally accepts a one-member stream as a byte-proven baseline (no sibling to prove a byte prefix against), so the isolated raw permanently becomes the accepted session content — an outcome that depends on incremental discovery order, not on which content is actually correct.Reproduced directly against
ArchiveStore(tests/unit/storage/test_revision_replay.py), mirroring the live incremental watcher's own call sequence (sources/live/batch.py:bind_raw_revisionthenclassify_raw_revision_cohort, no census-phase re-derivation in between). The equivalent two-call scenario throughbackfill_historical_revision_evidencedoes NOT reproduce: its census phase unconditionally re-parses every still-unindexed raw and its connected-component selection expansion reunites retired siblings by shared membership evidence before classification runs — protections the live incremental path lacks. This class of bug is closely related to (but distinct from) the head-collision fixes in #3204/#3205/#3211 that landed in the last 48h; those addressed head-handoff precedence and cohort absorption for an already-established head, not this isolated-singleton acceptance path.polylogue-869u
Live evidence (2026-07-19,
source.db): the newest-revision-per-logical_source_keypopulation is 87,177 rows / 52.1 GiB, but only 85,066 DISTINCTblob_hashvalues / 43.4 GiB — the same bytes (e.g. one 442MB codex computer-use rollout) recur under up to 8 differentlogical_source_keys / source paths, from re-acquisition or re-export. The existing dedup (#3151,_parse_retained_raws) only collapses rows sharing BOTHblob_hashANDsource_path, so this whole cross-path duplicate population — 8.7GB / 17% of newest-only bytes — still paid a full parse per row.Solution
polylogue-52l2 (
polylogue/storage/sqlite/archive_tiers/archive.py,polylogue/sources/revision_backfill.py,polylogue/sources/live/batch.py,polylogue/archive/revision_authority.py)ArchiveStore.raw_membership_retired_full_revision_siblings(): findsraw_session_membershipsrows for alogical_source_keywhoseraw_membership_census.detailmatches the (now shared)HISTORICAL_NON_PREFIX_GOVERNANCE_DETAILmarker written at retirement — survives theraw_sessions.logical_source_keyNULL-out.classify_raw_revision_cohortrefuses the byte-chain path entirely whenever this identity has retired sibling evidence, so the caller's existing "no accepted chain" fallback (convertible_full_revision_raw_ids) folds the newly-discovered raw into membership governance instead, where the real prefix-based classifier weighs every known sibling together, rather than silently establishing a wrong permanent head.retire_full_revision_governancecall sites' previously-divergent detail strings onto one shared constant so the guard recognizes retirement from either path.polylogue-869u (
polylogue/sources/revision_backfill.py)_parse_retained_raws' grouping key now dropssource_pathfor a new_PATH_INDEPENDENT_PARSE_PROVIDERSallowlist (ChatGPT, Claude web/Code, Codex, Gemini/Gemini CLI, Grok, Drive) — those parsers derive session identity purely from payload bytes. Providers whose parse DOES depend onsource_pathkeep the original(blob_hash, source_path)key: Beads derives workspace-scoped native ids fromsource_path, Antigravity's brain-metadata mode and Hermes' ATOF/ATIF/verification-evidence modes deriveprofile_rootfromsource_path.Provider.UNKNOWNstays path-scoped out of caution.Verification
devtools test tests/unit/storage/test_revision_replay.py tests/unit/sources/test_revision_backfill.py tests/unit/storage/test_raw_retention.py tests/property/test_sql_injection_boundary.py→ 160 passed.test_isolated_later_raw_does_not_override_known_ambiguous_cohortfails on unmodified master (assertsaccepted_raw_ids == ()but gets the isolated raw's id) and passes after the 52l2 fix.mypy --strictclean on all four touched modules.devtools verify --quick→ exit 0._parse_retained_rawinvocation counts:blob_hash+source_pathkey): 200 parse calls, 0.516s wall clockblob_hashkey, safe providers): 40 parse calls, 0.104s wall clockNote: the task brief also asked to run
tests/unit/storage/test_no_string_interpolated_sql.pyexplicitly after anyarchive.pyedit. That file does not exist in this repo (grepped for "interpolated" and "hardcoded.*line" repo-wide, no match) — rantests/property/test_sql_injection_boundary.pyas the closest existing analog instead (40 passed).AC matrix
polylogue-52l2
classify_raw_revision_cohort, proven by a failing-then-passing regression test.convertible_full_revision_raw_ids.source_outage_interval_events/capture_gap_events(bead's "related, separately-confirmed finding"): not addressed — out of this PR's footprint (_write_parsed_precedence_resultin the excludedarchive_tiers/write.py); still needs its own investigation pass as the bead notes.polylogue-869u
_PATH_INDEPENDENT_PARSE_PROVIDERSallowlist; path-dependent providers (Beads/Antigravity/Hermes/Unknown) intentionally keep path-scoped dedup.test_parse_retained_raws_preserves_path_scoped_dedup_for_path_dependent_providers.Ref polylogue-52l2, polylogue-869u
Co-Authored-By: Claude [email protected]
Summary by CodeRabbit