Repository navigation
fix: Retire the trigram index, bound unbounded probes, and give acquired attachments a source owner - #5308
Conversation
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Warning Review limit reachedNext included review available in 26 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 (43)
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: cdf793d1b2
ℹ️ 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".
…tive ok polylogue-xvwpi composition clause. `combine_outcomes` filtered parts with `and entry.reason`, so an `error`/`degraded` part whose reason was None or blank contributed no gap and a composite of one unnamed error plus one ok part composed to `ok`. It also kept only a nested composite's first gap (`entry.reason`) and discarded the rest of its `detail["gaps"]`, so a two-level envelope named fewer gaps than it held. `decide_outcome` dropped blank gap reasons the same way. An unnamed gap is still a gap: it is now labelled by the declared `UNNAMED_GAP` constant, and re-combining a composite carries every subordinate gap forward. Verification: devtools test tests/unit/surfaces/test_terminal_outcomes.py -> PASSED exit=0, receipt .cache/verify/runs/20260920T193913Z-focused-test-1798046-905de4b7/run.json. Anti-vacuity proven by mutation: restoring the `entry.reason` filter makes test_unnamed_error_part_cannot_compose_into_ok, test_unnamed_degraded_part_cannot_compose_into_empty and test_nesting_a_composite_keeps_every_subordinate_gap red (receipt .cache/verify/runs/20260920T194007Z-focused-test-1800825-f7488186/run.json, FAILED exit=1). polylogue/surfaces/outcome.py is IN the derived schema identity closure (devtools schema 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
… string
polylogue-3sic0, bounded slice named by the 2026-09-19 comment on the bead.
`sessions.session_id` is `origin || ':' || native_id` and `native_id` comes
from provider JSON with no character restriction, so a comma-bearing
conversation id shattered into fragments where the cost-rollup and
usage-timeline aggregates emitted `GROUP_CONCAT(DISTINCT x)` (archive.py
four sites) and the reader split on `","` (three sites). The observable
outcome was an inflated distinct-session count.
SQLite refuses `group_concat(DISTINCT x, <sep>)` ("DISTINCT aggregates must
have exactly one argument", re-verified on this build, 3.51.2), so the
aggregates now emit `json_group_array(DISTINCT ...)` and one
`_decode_session_id_set` helper decodes the typed array. No separator a
native id could contain is involved.
Verification: devtools test tests/unit/storage/test_usage_timeline.py
tests/unit/storage/test_cost_queries.py
tests/unit/storage/test_usage_projection.py
tests/unit/storage/test_origin_usage_report.py
tests/unit/storage/test_comma_bearing_session_ids.py -> PASSED exit=0,
receipt .cache/verify/runs/20260920T195201Z-focused-test-1836158-0a492e15/run.json.
Anti-vacuity proven by mutation: restoring GROUP_CONCAT plus the comma split
makes all five new tests red (receipt
.cache/verify/runs/20260920T195051Z-focused-test-1831054-7569abee/run.json,
FAILED exit=1), including
test_distinct_sessions_are_still_counted_separately, which guards against
over-collapsing genuinely distinct sessions.
polylogue/storage/sqlite/archive_tiers/archive.py is IN the derived schema
identity closure (devtools schema closure), so this moves the identity and
must land before a rebuild starts.
Residuals explicitly left open on polylogue-3sic0: tool pairing by
(session_id, tool_id), debt-read cancellation, capacity-gate filesystem,
embeddings same-version bootstrap, /proc descriptor aliases and the
diagnostic schema read.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
… their own working set polylogue-dhkuu Findings A and C. Finding B is already landed (origin_specs.py `_bounded_jsonl_records` plus its size ceiling) and is not touched here. Finding A -- watcher stale-tail probe, non-terminating. `_defer_incomplete_ jsonl_append` did one `handle.read(bytes_to_probe)` where `bytes_to_probe` is the entire outstanding tail on the escalated path. `MemoryError` is not an `OSError`, so the handler never fired; and even the `OSError` branch returned True WITHOUT calling `record_deferred_append_cursor`, so the cursor kept its old observation and the identical probe was re-attempted on every catch-up pass forever. The scan now reads `_INCOMPLETE_APPEND_PROBE_CHUNK_BYTES` (1 MiB) chunks and stops at the first newline, and an unreadable tail falls through to the deferral record instead of returning bare. Finding C -- content-identity re-read. Acquisition did `payload_content_identity(stored_handle.read())` on the stored blob right after the bounded streaming publication had deliberately avoided holding it. `bounded_payload_content_identity` reuses the streaming SHA-256 above a declared `STRUCTURAL_IDENTITY_MAX_BYTES` ceiling and returns the reason, so the substitution is recorded (warning log plus `RawSessionData.content_identity_skipped_reason`) rather than silent -- a skipped structural identity is not equivalent to a computed one. The ceiling is far above any member in the measured corpus, so no ordinary member's identity changes. Verification: devtools test tests/unit/sources/test_live_watcher.py tests/unit/sources/test_unbounded_probe_ceilings.py tests/unit/sources/test_decoders.py tests/unit/sources/test_export_member_addressing.py tests/unit/sources/test_source_laws.py --deselect tests/unit/sources/test_live_watcher.py::test_ingest_files_emits_observable_batch_metrics -> PASSED exit=0, receipt .cache/verify/runs/20260920T200705Z-focused-test-1879589-21b83963/run.json. The deselected test is INHERITED red: it fails identically on a pristine tree with every change here reverted (receipt .cache/verify/runs/20260920T200607Z-focused-test-1875982-5dd3dc92/run.json). Its `stage_timings_s` expectation predates the `watcher.live_ingest.raw_ compaction` stage. Not fixed here; reported as unresolved. Closure: watcher.py, content_identity.py, decoder_zip.py, source_acquisition_components.py and parsers/base_models.py are all 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
…achinery polylogue-nv356. Index schema v101. The bead's premise, re-verified at this head and now ANSWERED: the open question recorded at archive_tiers/index.py:365-369 -- "whether blocks_command_trigram still has a live consumer is now open" -- resolves to NO. Its one consumer, devtools/affordance_usage.py's `_cli_action_rows`, was deleted on 2026-08-25 (polylogue-9m6ry) with no product-surface replacement. A repo-wide grep at this head finds the name only in its own DDL and triggers, its rebuild/repair helpers in storage/fts, one verification gap check, and comments. The surviving polylogue/analysis/affordance_usage.py never referenced it. No query consumer exists, so polylogue-xul7's same question closes against this evidence rather than commissioning its own investigation. Removed: the CREATE VIRTUAL TABLE and its three triggers plus the shared bulk-guard WHEN fragment (index.py); the `blocks.tool_detail_text` VIRTUAL generated column, which existed only to feed the trigram index (archive_tiers_specs.py); TRIGRAM_REBUILD_DELETE_ALL_SQL and the three trigram SQL builders (fts/sql.py); rebuild_command_trigram_index_sync and the deferred-full-replace trigram catch-up (fts/fts_lifecycle.py); the five writer call sites (archive_tiers/write.py); the readiness repopulate call, `_trigram_trigger_is_guarded` and its pre-guard-archive fallback branch in delete_sessions (archive_tiers/archive.py); the cold-replay rebuild call (sources/revision_backfill.py); the fts-parity gap check (maintenance/archive_verification.py); the same-version trigger variants (schema_manifest.py); and the predecessor-shaped tests. `delete_sessions` now sets the `fts-bulk-session-write` guard unconditionally. It was conditional only to accommodate an archive whose trigram trigger predated the guard; with the trigram surface gone and the fresh schema floor refusing an old lineage outright, that branch had nothing left to accommodate. Classification: index-only derived DDL. Derived tiers carry no version chain -- schema_identity.py stamps one hash over the tier's DDL plus the lowering, materializer and replay fingerprints -- so there is no delta class to declare and an existing index tier meets the new identity as a typed SchemaSkew whose recovery is reconvergence through the production daemon. Verification: devtools test tests/unit/storage/test_bulk_build_lifecycle.py tests/unit/storage/test_bulk_delete_guarded.py tests/unit/storage/test_bulk_fts_prefix_reextract.py tests/unit/storage/test_fts_repair_sql.py tests/unit/storage/test_schema_policy_contracts.py tests/unit/storage/test_column_spec_reordering.py tests/unit/storage/test_blocks_command_trigram_retired.py tests/unit/maintenance/test_archive_verification.py tests/unit/storage/test_raw_convergence.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_unbounded_probe_ceilings.py --deselect tests/unit/maintenance/test_archive_verification.py::test_stale_schema_version_trips_tier_schema_check -> PASSED exit=0, receipt .cache/verify/runs/20260920T203657Z-focused-test-1954098-cfcbaa43/run.json. The deselected test is INHERITED red: it fails identically on a detached checkout of origin/master 9d0fdac with none of this branch applied (receipt .cache/verify/runs/20260920T202314Z-focused-test-1929215-113dd5ca/run.json). It expects user.db PRAGMA user_version=1 to be stale, which the retired durable chains made current. Not fixed here; reported as unresolved. Anti-vacuity, stated on each new test in tests/unit/storage/test_blocks_command_trigram_retired.py: restoring the CREATE VIRTUAL TABLE makes the fresh-tier test red; re-adding `tool_detail_text` makes the projection test red; re-exporting any rebuild helper makes the machinery test red; suppressing the identity comparison on open makes the SchemaSkew test red. Closure: index.py, archive.py, write.py, archive_tiers_specs.py, fts/sql.py, fts/fts_lifecycle.py, index_generation.py, schema_manifest.py and revision_backfill.py are all IN the derived schema identity closure (archive_verification.py and fts_automerge.py are out). 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
Gate follow-up for polylogue-dhkuu Finding C and polylogue-nv356. `devtools gate patterns` counted the two `logger.warning(...)` calls added with the content-identity ceiling as new `legacy-prose-logging` matches; the ratchet is enforcing, so a new match is a violation, not a baseline entry. Both now go through `polylogue.logging.emit` with the reason, the member and the declared ceiling as fields, which is also the form a consumer can filter on. Also fixes the two `devtools gate mypy` errors the trigram removal left in the tests it edited: `_finished_output_snapshot`'s return annotation still declared the dropped third element, and the probe test's `Path.open` stub carried an ignore comment that no longer applied. Verification: devtools verify --quick -> exit 0, 22 gates ok (format, lint, mypy, generated-surfaces, layering, patterns, api-parity, declaration-bindings, doc-commands, schema-manifest, oracle-integrity, testmon-selection, consumer-reachability, test-packages, timestamp-doctrine, durable-enum-checks, schema-privacy, schema-provider-identity, atlas, schema-closure, test-collection, population-coverage). devtools render all --check -> exit 0, no "out of sync" line. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
The recorder replaced `Path.open` process-wide, so the pytest progress plugin's own file writes went through it too and the run died with an INTERNALERROR instead of reporting. It now delegates every path but the fixture's to the real `Path.open`, and reads the fixture bytes before patching (`Path.read_bytes` itself calls `Path.open`). Verification: devtools test tests/unit/sources/test_unbounded_probe_ceilings.py tests/unit/storage/test_bulk_build_lifecycle.py tests/unit/sources/test_decoders.py tests/unit/sources/test_export_member_addressing.py -> PASSED exit=0, receipt .cache/verify/runs/20260920T212139Z-focused-test-2066740-84b856a6/run.json. devtools verify --quick -> exit 0, 22 gates ok. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
polylogue-vlel3, disposition B, with the finding recorded. Premise re-verified at this head: `with_self_describing_identity` appeared in exactly 7 lines -- its declaration, docs and branches in tests/infra/source_composer.py, and tests/infra/test_source_composer.py's comparison of two composed metadata dicts, which never ingests. Disposition A was attempted first and is not reachable as the bead describes. `compose_append_revision_chain` emits post-parse `Session` objects and never populates `raw_payloads`, so the flag's only effect was adding a `source_identity` key to `Session.metadata`. The raw admission route never sees that key, and a repo-wide grep finds no production consumer of a session-metadata `source_identity` anywhere. The axis the flag claimed to model -- a wire format that repeats a conversation id in every record versus one whose identity is filename/positional only -- is a property of wire bytes, and this composer produces none. Its two branches therefore could not diverge at admission even in principle, which is the finding the bead asked for; disposition B follows. The opaque-identity case keeps its real coverage in tests/unit/sources/test_revision_backfill.py::test_thread_parse_recovers_append_native_id_matching_sequential, which drives appends carrying no session_meta through the production route. A composer that emits wire bytes for that axis remains open work; it is not this flag. Verification: devtools test tests/infra/test_source_composer.py -> PASSED exit=0, receipt .cache/verify/runs/20260920T212832Z-focused-test-2078019-b766a707/run.json. Nothing in scope is in the derived schema identity closure (test infrastructure only), so this does not gate the rebuild boundary. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
…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
mypy reads the literal as dict[str, str | bytes | int | None] and dict is invariant, so passing it to _apply_replay was rejected. Gate follow-up to polylogue-8v4rm; no behaviour change. Verification: devtools verify --quick -> exit 0, 22 gates ok. devtools render all --check -> exit 0, no "out of sync" line. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
cdf793d to
b791b83
Compare
…pproving moved evidence (#5311) ## Summary Two beads. `polylogue-q54dt`'s grammar extension is delivered and `/api/paste-browser` is repointed onto the declared route; `polylogue-irtix` sub-item D refuses approving a candidate whose evidence moved under a reused assertion id. `/api/attachments` is **not** converted, for a reason that is not a grammar gap. Three production files are IN the derived schema closure — **this must land before any rebuild starts.** ## q54dt — the declared route now expresses message grain `query_units` accepted `has_paste` but lowered it to `sessions.paste_count > 0`, while the handler read message-grain `msg.has_paste` because session aggregates lag direct message writes. The predicate is now declared, and `_do_paste_browser` calls `poly.query_units("messages where has_paste:true", limit=..., offset=...)`. The tests monkeypatch `Polylogue.filter` and `Polylogue.get_session` to **raise**, so the retired shape cannot pass. AC1 (`total=None` when the page filled, `total_is_exact`, `matched_so_far` separate) was already satisfied at head and was verified, not rewritten. **Anti-vacuity, executed:** reintroducing `await poly.filter().list_summaries()` at the top of the handler turns both tests red. The predicate fixture seeds a paste-bearing message while `sessions.paste_count` stays 0 — asserted in the fixture — so a session-aggregate lowering returns zero rows. ## /api/attachments is not convertible by this predicate Stated plainly rather than left as an unexplained gap. Attachments hang off `attachment_refs(message_id, session_id)`; `messages` carries **no** attachment column (verified against the full column list); `attachment_count` lives on `session_profiles` at session grain; and there is no attachment query unit. Its `state` filter is derived at read time from availability, not stored, so it cannot be pushed to SQL — a message-grain approximation would break AC4's exact-once pagination whenever `state` is set. Closing it needs a declared attachment-grain read: either a new `attachment` query unit (name, descriptor, payload model, row type, SQL lowering, CLI renderer, completions, MCP registry, regenerated surfaces) or a declared `ArchiveStore` read plus a product route. That is a separate cohesive change, not a rushed extension of this one. ## irtix sub-item D `AssertionEvidenceConflictError` is raised from `_judge_assertion_candidate_in_transaction` when the evidence digest read at capture no longer matches current. The test asserts both digests appear in the message and that the candidate stays `CANDIDATE`. A second test proves dedup is not reverted: two cycles over identical evidence keep one assertion id, record no `superseded_evidence_digest`, and accept unsighted. **Anti-vacuity, executed:** deleting the refusal call gives `DID NOT RAISE`. ## Corrections to the bead metadata - **Sub-item B is already satisfied at head** — no change manufactured. `_SQL_RECIPES_BY_HASH` and `_vector_derivation_hash_sql` resolve the full recipe from its hash, and all six named call sites pass a full recipe object. `git log -S` puts it in `d7d3ddae5` (#5224), together with its AC5 anti-vacuity test, which passes. The bead's design note still points at `identity.py:248` as the live defect; that line is now only a tests-only `model=` fallback. - **"D is the only sub-item outside the schema closure" is wrong in consequence.** `raw_reconciler.py` is indeed out, but the approval boundary is in `user_write.py`, which is **IN** — so D as implemented moves the identity. - Sub-item B's recorded `verification_commands` name three test paths that do not exist at head. ## Verification `119 passed` on the focused selection after rebase onto `f7bc76213`; `775 passed, 1 skipped` on the broad query-surface sweep for the new grammar field. `devtools verify --quick` all **23** gates ok. `render all --check` exit 0, zero `out of sync`. One inherited failure reproduced red on a clean worktree at the original base and now **passes** after rebasing — one of #5302/#5308/#5309 fixed it. Not mine in either direction. ## Behaviour change to confirm `daemon/judgment_automation.py` builds its bulk envelope without `expected_evidence_digest`, so an automated approval of a candidate whose evidence moved will now fail that item with the typed conflict. That is the correct default — automation approving unread evidence is the exact risk — but it is a live change someone should confirm rather than discover. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…er side effect (#5312) ## Summary The epic's central defect: `publish_prepared_session_profile` refreshed and **committed** the provider-usage rollup inside itself, so publication altered its own premise and then relied on another pass to notice. Usage reconciliation is now its own derivation, registered as a prerequisite of `session_profile`. Five production files are IN the derived schema closure — **this must land before any rebuild starts.** `INDEX_SCHEMA_VERSION` 104 → 105. **3 of 8 acceptance criteria are met.** The other five are stated below rather than claimed. ## The fix, with the defect reproduced Removed `_refresh_provider_usage_rollup(conn, ...)` and its `conn.commit()` from the publisher. Reconciliation is now `session_usage_rollup`, registered *before* `session_profile` and named as a concrete prerequisite key. **Anti-vacuity was measured, not asserted.** Restoring the publisher refresh + commit and dropping the prerequisite reproduces the doomed first pass exactly: ``` KeyOutcome(domain=session_profile, outcome=PENDING, reason=PendingReason.BINDING_MOVED) assert [PENDING] == [DONE] ``` Truthful refusal is proven separately: `publish_session_usage_rollup` returns `False` and `session_model_usage` is byte-identical, because the refresh now lives inside the same `BEGIN IMMEDIATE` the refusal rolls back. Pricing meaning is unchanged — the same reconciliation, disjoint token lanes and catalog repricing run; `session_insight_compute_binding` is retained as the exact-content backstop, which AC6 requires until the input writers adopt the revision contract. ## AC1 was already satisfied — no change manufactured `derivation.py:88-99` already opens with `tuple(dict.fromkeys(assertion_ids))` and compares SQL set cardinality against the deduplicated length. The three-line correction the bead describes is present at head. ## The inherited reds were vacuous *and* red Three `test_session_profile_derivation.py` failures reproduced on clean worktrees at both `f7bc76213` and the branch base. Cause: `SessionBuilder` leaves `messages.input_tokens` NULL, so `input_tokens + 4096` evaluated to NULL — **the mutation was a no-op**. The parametrizations were simultaneously vacuous and failing. Fixed forward in `2d0af1bb1`; that file now has zero failures. ## Ratchet movement, stated deliberately ``` schema-closure-baseline.json 563 → 564 added ['.../usage_rollup.py'] removed [] writer-module-census-baseline +1 entry {'file': '.../usage_rollup.py', 'tiers': ['index']} ``` Genuine growth from one new production module that defines derived-tier behaviour and mutates the index tier. **No pre-existing member was dropped from either baseline.** ## Version conflict resolved, not overwritten `#5308` had already claimed `INDEX_SCHEMA_VERSION 104` for the trigram drop. Resolved during rebase by keeping master's v104 block and moving `session_usage_rollup_bindings` to v105 with its own classification comment. ## Not done, and why - **AC4/AC7 (marker lifetime).** The profile-driven marker-presence gate is still live. Retiring it needs a durable applied-position sink in `user.db` — and `user.db` has no version chain at head, so that is additive DDL in `USER_DDL`, not a numbered migration. Shape recorded for the next worker: a `session_marker_delivery` derivation whose publish runs `lower_markers` and advances the applied position in one transaction, after which the gate is deleted. - **AC3/AC6 sequence item D** (migrate profile input writers to a same-commit fence + pending demand, then retire the scan and the backstop) is the next unit and is independent of the marker work. - **`ia88n` option (b)** not started. Its stated blocker — this derivation kernel — is now landed and production-adopted, so it is dispatchable with no remaining prerequisite and no write-scope collision. ## Bead-status accuracy `bp12n.1`'s rollup reports **"3/3 children complete — eligible for close"**. It is not close-eligible: 5 of 8 acceptance criteria remain unsatisfied at this candidate. ## Risk identified, not reproduced — worth its own bead `security/excision.py:1266` hard-deletes assertions by `target_ref`. `lower_markers` preserves terminal judgments only when the row still **exists**, so a hard-deleted row makes `existing is None` and it re-inserts as `CANDIDATE`. Meanwhile `_marker_assertions_present` counts rows regardless of status, so a hard-deleted marker assertion leaves the profile permanently STALE and republishing every pass. If the excised session or message survives in the index, that loop would **resurrect deliberately excised material**. I did not build the reproduction — it needs a real excision-then-converge run. Stated as a risk, not a confirmed defect. ## Verification `172 passed` across the session-derivation, kernel-law and daemon-convergence suites after rebase. `devtools verify --quick` all 23 gates ok. `render all --check` exit 0, zero `out of sync`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
## Summary Deletes `session_phases` and `session_work_events` — a heuristic session segmentation whose structural half duplicates `action_pairs` and whose inference half was already self-marked `heuristic_label`. ## Problem Both tables yield a single span covering the whole session for 82% (work events) / 84% (phases) of sessions, and their index-synthesized endpoints invert on 13,743 rows. `action_pairs` already carries the same file/tool evidence at real per-call granularity. The `heuristic_label` marking in `inference_json` was copied into top-level columns that dropped the marking, so surfaces presented a heuristic as a measurement. ## Solution Removed together, so no surface advertises an insight with no relation behind it: the two tables and `session_work_events_fts`, the `session_profiles.work_event_count`/`phase_count` columns, the `threads` view's `work_event_breakdown_json`, both materializers, the timeline read/write query band, both registry descriptors (which regenerate the MCP tool contracts, the CLI `phases`/`work-events`/`timeline` commands and the insight docs), both rigor contracts, the readiness/status/workload-probe and export-bundle entries, the resume-brief citations, the daemon insights-browser panels, and the `work_event`/`phase` user-state target and ref kinds. `engaged_duration_ms` was the one genuine consumer deriving value from the phase intervals, so it is preserved exactly: `compute_engaged_duration_ms` in `archive/semantic/timing.py` reproduces the same 5-minute-gap segmentation over message timestamps (with the session-event fallback for the ~30% of the archive whose messages carry none) without materializing a span table. `engaged_duration_source` reports `engagement_intervals` where it previously reported `phase_sum`. **`INDEX_SCHEMA_VERSION` 106** (master is at 105 after #5308 took 104 and #5311 took 105): semantic — an existing `index.db` must be rebuilt from `source.db`. `analysis/registry.py` and `storage/derived/session/{rebuild,profiles,threads}.py` are in the derived schema-identity closure, so this moves the identity stamp and must land before any rebuild starts. No rebuild is running. ## Verification - `devtools test tests/unit/storage tests/unit/analysis` — green - `devtools render all --check` — no `out of sync` - `devtools verify --quick` — static gates pass - Inherited reds per `/realm/tmp/work/polylogue-known-red.md` at f6f899c are unchanged by this branch. ## Residuals The commit message on `2f27200f3` says version 104; that prose predates the restack onto 106. The code is correct — this PR body is the squash subject's body and states 106. Closes polylogue-cuxz.7. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at bf68918):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Six beads delivered from the storage/daemon core cluster; thirteen reported unattempted with a stated reason rather than half-done. Seventeen production files are IN the derived schema closure — this must land before any rebuild starts, never mid-run.
nv356 — the trigram index is gone, and the open question is answered
blocks_command_trigram, its three write triggers, and its rebuild/repair machinery are absent from a freshly opened index tier. Index schema v101; an existing tier stamped at the old identity now raisesSchemaSkew.The premise is confirmed, not refuted. Repo-wide grep at head found the name only in its own DDL and triggers, its rebuild helpers, one FTS-parity gap check, and comments. Its one historical consumer (
devtools/affordance_usage.py::_cli_action_rows) was deleted 2026-08-25 with no product-surface replacement. The open question recorded atindex.py:365-369is now answered: no query consumer exists.polylogue-xul7should close against this rather than re-investigating.Scope necessarily exceeded the bead's declared
write_scope: the table had five writer call sites inwrite.py, a readiness rebuild and a trigger-guard fallback inarchive.py, a cold-replay rebuild inrevision_backfill.py, an FTS-parity check, same-version trigger variants inschema_manifest.py, and theblocks.tool_detail_textgenerated column whose only consumer was the trigram table. Leaving any would have left a compatibility surface, which AC1 forbids.dhkuu — the non-termination, fixed at its actual root
The watcher's stale-tail probe read the whole tail and repeated forever. The loop was not the read size:
except OSError: return Truereturned without callingrecord_deferred_append_cursor, so the cursor kept its old observation and the identical probe re-ran every pass. Now catches(OSError, MemoryError)and falls through to the deferral record, and scans 1 MiB chunks stopping at the first newline.Content-identity re-read gains
STRUCTURAL_IDENTITY_MAX_BYTES(256 MiB); above it the payload is not read and the streaming SHA-256 is reused. The skip is never silent — a structured event plus a recorded reason on the record, because a byte digest and a structural identity are not interchangeable. The ceiling sits far above any member of the measured 6,966-blob corpus.8v4rm — the preservation-critical edit
source_attachmentsadded toBLOB_OWNERS. The direction is provably safe:_direct_surfacesappends, so adding an owner can only move a hash from unreferenced to live — no path can make a currently reachable hash collectable. It pins exactly the hashes a row claims were stored, so it does not blanket-pin and does not hide a genuine orphan.record_source_attachmentsno longer usesON CONFLICT DO NOTHING: identical replay is a no-op,pending → terminalis the one declared progress transition, and anything else raises a typed conflict naming field, stored and offered values.xvwpi and 3sic0
combine_outcomesfiltered onand entry.reason, so an error or degraded part with a blank reason contributed no gap and composed took— and nesting kept only a composite's first gap. NowUNNAMED_GAPlabels it and every subordinate gap carries forward.All four
GROUP_CONCAT(DISTINCT session_id)sites emitjson_group_arrayinstead; the three comma-splitting readers go through one helper. Re-verified on SQLite 3.51.2 thatgroup_concat(DISTINCT x, <sep>)is refused.Reported unattempted, with reasons
Thirteen beads. The ones worth knowing:
irtixsub-item A must not be started without explicit reconvergence authorization — length-prefix framing changes every storedcontent_identity, and the bead says so itself.20d.17deletesdaemon/status.py(3,565 lines) and depends on unlandedbp12n.1.9m93snamesi07pwas its predecessor and has an AC withdrawn by a later ruling while the recorded text still demands it.fzbzkstays deferred.q54dtAC2/AC3 need a decision: the declared bounded route has no message-grain paste predicate.query_unitsacceptshas_paste, but it lowers tosessions.paste_count > 0(filter_builder.py:111), while the handler deliberately reads message-grainmsg.has_paste. Adding one touches five query modules plus CLI/API/MCP parity and moves the schema identity — far outside this bead's scope. AC3 explicitly rejects the cheaper alternative, so nothing partial was manufactured.Verification
devtools verify --quickexit 0, all 22 gates.devtools render all --checkexit 0, zeroout of sync. Two anti-vacuity mutations executed and red as expected.Three inherited reds proven against pristine baselines rather than assumed — including
test_blob_gc_durable_intent.py, which sits in the 8v4rm blast radius and was baselined deliberately for that reason. One correction:test_live_watcher.py::test_ingest_files_emits_observable_batch_metricswas red at the old base and is green at9d0fdac8b— #5300 fixed it.Interaction to record
STRUCTURAL_IDENTITY_MAX_BYTESis a deliberate, recorded exception towzgpf's "structural content identity is the authority" rule. The corpus reclassification work must account for it.🤖 Generated with Claude Code
https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq