Repository navigation
refactor(storage): Trim dead derived-schema columns and render the embeddings tier from specs - #5309
Conversation
polylogue-wohv. `messages_fts` is a contentless FTS5 table (content='',
contentless_delete=1) that also declared block_id/message_id/session_id/
block_type UNINDEXED. SQLite discards UNINDEXED values at insert in that
mode, so those four columns stored nothing and `SELECT block_id FROM
messages_fts` returned NULL even though the INSERT supplied a value -- the
DDL implied a retrievability the storage mode forbids. Every production
reader already resolves identity by joining `blocks` on rowid
(search/query_builders.py, search/runtime.py, archive_tiers/archive.py) or
through `messages_fts_identity`.
The declaration now carries only the indexed `text` column, and the three
sync triggers, the four repair/insert SQL builders, the derivation writer
and `rebuild_archive_messages_fts` stop passing values that were discarded.
`contentless_unindexed=1` is deliberately NOT added: the blocks join is
needed for display fields regardless, so persisting would only grow the
index.
Classification: INDEX_ONLY (derived tier). The indexed column set, tokenizer
and rowid binding are unchanged, so the search index rebuilds with identical
content and no parsed row is re-derived. INDEX_SCHEMA_VERSION 100 -> 101;
the DDL edit moves the derived schema identity and the archive reconverges
through the daemon route.
Two bulk-build parity helpers were selecting those four always-NULL columns
off the index, so their "identical FTS rows" proofs compared `text` alone;
both now join `blocks` and compare real identity.
Verification:
devtools test tests/unit/storage/test_schema_safety.py
tests/unit/storage/test_fts_repair_sql.py
tests/unit/storage/test_fts_derivation.py -> 59 passed
devtools test tests/unit/archive/test_source_freshness.py
tests/unit/daemon/test_health_check_paths.py tests/unit/storage/test_pl_fold.py
tests/unit/storage/test_bulk_fts_prefix_reextract.py
tests/unit/storage/test_bulk_build_lifecycle.py
tests/unit/storage/test_fts5_query_correctness.py
tests/unit/storage/test_fts_bloat_invariants.py
tests/unit/storage/test_bulk_replace.py
tests/unit/storage/test_bulk_delete_guarded.py
tests/property/test_fts_identity_state_machine.py -> 225 passed
devtools verify --quick -> all 22 gates ok
devtools render all --check -> exit 0, no "out of sync"
devtools schema closure: IN for storage/fts/sql.py, storage/fts/derivation.py,
archive_tiers/index.py, archive_tiers/write.py.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
polylogue-a7xr.22. `delegations` was the only view in index.db with zero
joins: `SELECT <28 columns> FROM delegation_facts`. It renamed nothing and
computed nothing; its sole difference from the table was hiding the
`delegation_id` primary key. All six SQL read sites in
archive_query_reads.py (the ancestry and subtree recursive CTEs, the
aggregate-count FROM map, the structural EXISTS predicate, the two
`get_delegation_attempt` lookups and `query_delegations`) now read
`delegation_facts`. `_archive_delegation_query_row` maps by column name, so
the extra `delegation_id` on `SELECT *` is inert there.
The delegation work-evidence snapshot also moves to the table, and its
`ORDER BY` moves to the `delegation_id` primary key: that key is
content-derived (`COALESCE(instruction_tool_use_block_id, parent ||
':' || child)`), so the digest gains a total order where the previous
parent/child ordering left ties free to permute between runs.
The PUBLIC query-unit token is still `delegations`
(archive/query/metadata.py, discovery.py, docs/search.md). That is grammar
vocabulary and is untouched by this change.
Classification: METADATA_ONLY (derived tier). No stored row and no derived
value changes; the removed object was a pure projection of a table that stays
exactly as it is. INDEX_SCHEMA_VERSION 101 -> 102, because the DDL edit moves
the derived schema identity and the archive reconverges through the daemon.
AC2 (no replacement rename view) gets a law of its own:
test_no_rename_only_view_over_delegation_facts asserts no `delegations` view
exists and that any surviving view reading `delegation_facts` joins, filters
or computes something. tests/unit/storage/test_delegations_view.py is renamed
test_delegation_facts.py since the object it names is gone.
Verification:
devtools test tests/unit/storage/test_delegation_facts.py
tests/unit/storage/test_archive_tiers_ddl.py
tests/unit/insights/test_delegation_work_evidence_materializer.py
tests/unit/insights/test_delegation_work_evidence.py
tests/unit/pipeline/test_delegation_provider_fixtures.py -> 75 passed
devtools test tests/unit/cli/test_query_exec_laws.py -k delegation -> passed
devtools verify --quick -> all 22 gates ok
devtools render all --check -> exit 0, no "out of sync"
devtools schema closure: IN for archive_tiers/index.py,
archive_tiers/archive_query_reads.py, archive_tiers/archive_tiers_specs.py,
surfaces/payloads.py, core/refs.py, archive/session/models.py,
archive/session/runtime.py, archive/semantic/pricing.py; out for
analysis/delegation_work_evidence_materializer.py and api/archive.py.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
polylogue-cuxz.12 AC1. `threads` declared `NULL AS dominant_repo_id` -- a
column that was NULL on every one of the 9,914 live rows because nothing could
ever produce a value for it. The schema disposition projection already carried
it as PURGE with exactly that evidence ("no production writer, reader,
hydration, or intended identity join; dominant_repo remains authoritative"),
so this executes a decision that was already recorded and removes the now-dead
special case from schema_disposition.py. `dominant_repo` (the repo name, by
member count) keeps the real repository attribution.
Classification: METADATA_ONLY (derived tier). The column carried no value on
any row, so no stored row and no derived value changes.
INDEX_SCHEMA_VERSION 102 -> 103 because the DDL edit moves the derived schema
identity and the archive reconverges through the daemon.
The remaining acceptance criteria are reported, not manufactured:
AC3 (threads_fts confirmed or removed) is satisfied at head. `threads_fts`
was dropped in INDEX_SCHEMA_VERSION 62/63 with its rationale recorded at
archive_tiers/index.py:1153-1161 and storage/fts/sql.py:170-173: its only
MATCH reader (session_insight_thread_queries.list_threads) had zero
production callers, and the live "analyze threads" path was already a LIKE
scan.
AC2 (session_ids_json removed in favour of thread_sessions) rests on a premise
that no longer holds. Both `threads` (index.py:1035) and `thread_sessions`
(index.py:1168) are VIEWS over `sessions`; `session_ids_json` is
`json_group_array(m.session_id)` evaluated at query time, not a stored FK list.
There is no stored duplication to remove and no row count to reduce -- the two
are one derivation written twice inside one view, and `ThreadRecord.session_ids`
(queries/mappers_insight_timelines.py:158) is a real production consumer.
Replacing the aggregate with a join over another query-time view of the same
`sessions` rows would move SQL without changing what is stored or answered.
AC4 (the concept is not deleted) holds: the view, its lineage semantics and
`thread_sessions` are untouched.
Verification:
devtools test tests/unit/storage/test_archive_tiers_ddl.py
tests/unit/storage/test_schema_disposition.py -> 50 passed
devtools test tests/unit/api/test_facade_contracts.py -k thread -> passed
devtools test tests/unit/insights -k thread -> passed
devtools verify --quick -> all 22 gates ok
devtools render all --check -> exit 0, no "out of sync"
devtools schema closure: IN for archive_tiers/index.py and
archive_tiers/schema_disposition.py.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
…tatements
polylogue-cuxz.11. The Codex wire restates the whole policy on every
turn_context, and the writer stored a row per observation. That made
`session_agent_policies` a change-log of non-changes: 402,869 rows carrying
3,053 distinct facts across 3,031 sessions, 99.3% of which never changed
policy at all -- roughly 132 rows per session for one fact.
`_write_session_events` now retains a row only when the
(approval, sandbox, network) tuple differs from the last retained value, and
compares against the session's highest-position stored row so an append
continues the interval instead of restarting it. A full replace clears the
session's rows first (`_clear_session_projection_rows`), so the first
observation of a fresh write is always retained. `position` still marks where
the retained value took effect: a row is the START of an interval that runs
until the next row (AC1, AC2).
AC3: nothing is dropped. `network_policy` and `source_message_id` both have
named producers at the write boundary -- network comes from the same
`agent_policy` payload as approval/sandbox, and `source_message_id` is the
resolved message the observation attached to, with its own partial index and
prefix-delete clear path (`clear_session_agent_policies_source_message_sql`).
Per the 2026-09-07 audit note, a field is not dropped for having been constant
in one census; what is dropped is the restatement of an unchanged value.
AC4: measured on a synthetic fixture rather than the live archive -- six
observations carrying two distinct values now store two rows at positions
0 and 3 (test_agent_policies_store_value_change_intervals_not_restatements).
Applied to the recorded census that is 402,869 -> 3,053 rows; the live number
is whatever the archive's own reconvergence produces, not a number this change
can assert.
Classification: derived-row content, no DDL change, so no INDEX_SCHEMA_VERSION
bump. `archive_tiers/write.py` is IN the derived schema closure, so the writer
fingerprint moves the tier's identity on its own and existing archives meet it
as a typed SchemaSkew; reconvergence re-derives the table from retained raw
evidence through the normal replay route.
Verification:
devtools test tests/unit/pipeline/test_archive_write.py -> 27 passed
devtools test tests/unit/cli/test_file_edits_and_agent_policies_views.py
tests/unit/sources/test_parsers_codex.py tests/unit/sources/test_compaction.py
tests/unit/core/test_facade_api.py -> 212 passed
devtools verify --quick -> all 22 gates ok
devtools render all --check -> exit 0, no "out of sync"
devtools schema closure: IN for archive_tiers/write.py.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
polylogue-wohv follow-up. Dropping the four UNINDEXED columns moved `text`
from column ordinal 4 to 0, but four `snippet(messages_fts, 4, ...)` call
sites still named the old ordinal, so every FTS read that requested a snippet
raised `sqlite3.InterfaceError: column index out of range` at execute time
(reproduced by tests/unit/cli/test_query_expression.py::
TestDaemonSessionIdFilter::test_contains_filters_without_query).
The snippet value itself is NULL either way: a contentless FTS5 index cannot
reconstruct the source text, which is why all three readers already select
`b.search_text AS fallback_text` beside it. The ordinal still has to be valid
for the statement to run at all.
The wohv regression test now issues a snippet() call on the production
schema, so a stale ordinal fails there instead of in an unrelated CLI filter
test.
Verification:
devtools test tests/unit/storage/test_schema_safety.py
tests/unit/cli/test_query_expression.py
tests/unit/archive/test_query_multi_aggregate.py
tests/unit/coordination/test_envelope.py -> 506 passed, 1 skipped
devtools test tests/unit/storage/test_fts5_query_correctness.py
tests/unit/archive -k search -> passed
devtools schema closure: IN for archive_tiers/archive.py; out for
storage/search/runtime.py and storage/search/query_builders.py.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
…ON bundle
polylogue-dab.1. The bead's headline -- drop payload_json from the three
run-projection TABLES' DDL -- is satisfied at head and was not re-done:
`session_runs`, `session_observed_events` and `session_context_snapshots`
no longer exist in the index tier at all (no match in
archive_tiers/index.py or archive_tiers_specs.py), and the materialized read
branch already refuses (`projected_run_from_row` /
`observed_event_from_row` / `context_snapshot_from_row` raise on
`row_source == "materialized"`, run_projection_relations.py:461-466,
498-503, 530-535).
What was still live is the residual the bead's design section names: the
source relation bundled values it had already computed as typed columns into
a `json_object(...) AS payload_json`, and every consumer json_extract-ed them
back out one field at a time.
- observed_events now exposes tool_name, tool_id, command, handler_kind and
status as typed columns. `tool_finished_base` already computed all five;
the session_started arm supplies NULLs (a session_started row has no tool,
and the origin/native_id its old bundle carried had no reader anywhere).
- `observed_event_from_row` reads them directly instead of json.loads-ing.
- The query-unit aggregate keys, the aggregate value expressions and the
observed-event field predicates for tool/handler/status lower to the
columns instead of json_extract over the bundle.
- `_proof_payload_from_row` reads the typed `status`; its `outcome`/
`exit_code` fallbacks were never present in that bundle.
- The run and context-snapshot relations carried `NULL AS payload_json`
columns no reader ever touched; those are gone.
Equivalence: `json_extract(json_object('k', col), '$.k')` is `col` for every
value these columns hold, including NULL, so no answer changes; what changes
is that SQLite no longer builds and reparses a JSON document per row to read
a column it already had.
Classification: derived relation shape, expressed in SQL-producing Python,
not in tier DDL -- no CREATE statement changes and no INDEX_SCHEMA_VERSION
bump. run_projection_relations.py and archive_query_reads.py are IN the
derived schema closure, so the tier identity moves and the archive reconverges
through the daemon route.
Verification:
devtools test tests/unit/insights/test_run_projection_materialization.py
-> 6 passed
devtools test tests/unit/coordination/test_envelope.py
tests/unit/archive/test_query_multi_aggregate.py
tests/unit/cli/test_query_expression.py -> 506 passed, 1 skipped
(with tests/unit/storage/test_schema_safety.py in the same selection)
devtools verify --quick -> all 22 gates ok
devtools render all --check -> exit 0, no "out of sync"
devtools schema closure: IN for storage/sqlite/run_projection_relations.py and
archive_tiers/archive_query_reads.py; out for coordination/envelope.py.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
…d vocabularies
polylogue-a7xr.27 and polylogue-3szyi, one coherent tier-scoped slice rather
than a 89-table sweep -- a7xr.27's own campaign-boundary ruling says the
mechanical conversion is not required to reconstruct the archive, so this
takes the tier where the conversion and the CHECK-ownership gap are the same
change.
a7xr.27: all five STRICT tables of the embeddings tier
(message_embeddings_meta, message_embedding_refs, embedding_status,
embedding_derivation_state, embedding_failures) now render
`EMBEDDINGS_TABLE_SPECS[name].ddl_body`, exactly as the index tier's 41 tables
do. Adding a column touches the spec and the tier's lifecycle delta only.
`message_embeddings` is the one table that cannot and states its reason in
place: `USING vec0(...)` is an extension-defined virtual-table declaration,
not a column list a TableColumnSpec can render (AC1).
3szyi: the tier's two string-enumeration CHECKs now generate from their Python
owner (AC2), both moved to archive_tiers/types.py beside the delegation
literals so the declaration and the writer share one owner without an
archive-tier import cycle:
- `embedding_failures.lifecycle_state` -- `EmbeddingFailureState` already
existed as a `Literal` in embedding_write.py and matched the hand-typed SQL
list exactly; the DDL simply did not use it. Moved, not duplicated.
- `embedding_derivation_state.attempt_state` -- had NO Python owner at all.
Its four values were bare string literals at a dozen call sites in
embedding_write.py. Introduced as `EmbeddingAttemptState` and applied at the
one site that assigns it (AC2's "unknown ownership is zero" for this tier).
That is 2 of the embeddings tier's 4 hand-written CHECK lists; the other two
are `needs_reindex IN (0, 1)` and `retryable IN (0, 1)`, integer booleans with
no domain vocabulary to own them, which stay as they are.
Equivalence: the spec-rendered DDL is semantically identical to the
hand-written DDL it replaces. Checked by building both and comparing
`_normalize_schema_sql` per sqlite_master row -- 14 objects, zero differences
-- so no embeddings rebuild is forced by shape. EMBEDDINGS_SCHEMA_VERSION
stays 6.
Classification: no semantic DDL change (identical normalized objects), but
all four edited production files are IN the derived schema closure, so the
identity moves and the archive reconverges through the daemon route.
The atlas anchor for the tier's DDL is re-pointed at its new line range.
Verification:
devtools test tests/unit/storage/test_archive_tiers_ddl.py -> 43 passed
devtools test tests/unit/storage -k embed -> passed
devtools test tests/unit/storage/test_archive_tiers_ddl.py
tests/unit/storage/test_schema_policy_contracts.py
tests/unit/storage/test_archive_tiers_common.py -> 76 passed
devtools verify --quick -> all 22 gates ok
devtools render all --check -> exit 0, no "out of sync"
Inherited red, proven on a clean origin/master worktree at 005b688:
tests/unit/cli/test_embed_status_fast.py fails 10/35 there, including the
three that surfaced in a `-k embedding` selection here.
devtools schema closure: IN for archive_tiers/embeddings.py,
archive_tiers/archive_tiers_specs.py, archive_tiers/types.py and
archive_tiers/embedding_write.py.
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 45 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 (41)
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: 085f637c46
ℹ️ 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".
…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]>
## Summary Deletes a hand-written restatement of `SESSIONS_SPEC` from the session-insight rebuild path and binds row decoding once per cursor instead of per row. ## Problem `storage/derived/session/rebuild.py` carried `_row_to_session_insight_session`, a 23-line hand-written restatement of `SESSIONS_SPEC`'s 17 projected fields plus coercions that the spec transforms and `SessionRecord` validators already own. Two representations of one field inventory, with nothing forcing agreement. ## Solution `bind_session_row_mapper` / `bind_block_row_mapper` join the existing `bind_*_row_mapper` family in `storage/sqlite/queries/mappers_archive.py`, the declared owner. The mirror is **deleted, not relocated**. The one-row `_row_to_session` / `_row_to_message` / `_row_to_content_block` route is unchanged, so `rebuild.py`'s bounded large-session tail still pays no per-row planning — the bead's own rule that unmigrated callers must not be taxed by the migration. `_tail_session_record` was left alone: it is a distinct fact (a synthetic non-persisted record with a placeholder content hash), not a mirror. ## Verification - `devtools test` over five storage/sources selections — **57 passed, 1 failed**. The failure is `test_column_spec_reordering.py::test_index_ddl_uses_every_declared_table_spec` on `message_embeddings_meta`, listed verbatim on the known-red baseline as "embeddings-tier spec from #5309". Inherited. - **Two anti-vacuity mutations executed**, not asserted: - Reverting `load_sync_batch`'s session loop to the per-row route reddened *exactly* `test_batch_loaders_plan_each_cursor_once` (`per_cursor` lost its `sessions` entry) while the other two stayed green — which independently confirms the deleted mirror was **output-identical** to the declared route. - Shifting `bind_record_mapper`'s bound column position by one reddened all three, proving the decode tests detect a mis-bound position. - `devtools verify --quick` — exit 0, 23 gates - `devtools render all --check` — exit 0, `grep -c 'out of sync'` = 0 ## ⚠ Landing constraint All three edited production files are **IN** the derived closure. Identity move measured directly: `55020aae…` → `56a26be8…` (ops tier unchanged). Must land before a rebuild starts, never during one. The worker flagged the live corpus run as a blocker for landing. That is over-cautious and I am proceeding: `agentctl job 1564` executes `devtools verify --all` against the **working tree** of `/realm/project/polylogue`, which a merge to `origin/master` does not move. The hazard is a checkout moving under a running rebuild, not a merge to the remote. ## Two refuted claims worth recording **Six cursor sites, not four.** An earlier reader found four; all six are at head in `storage/sqlite/queries/message_query_reads.py` — `_own_messages:117`, `get_messages_batch:377`, `get_messages_paginated:476`, `get_message_edge_windows` `:572` and `:587`, `iter_messages:679`. **CLI and MCP do not share a read chokepoint.** Only one production caller reaches `execute_read_operation`: `operations/daemon_execution.py:250-252`, entered from `cli/operation_kernel.py:298`, `daemon/operation_runtime.py:354,476` and `daemon_client.py:445`. MCP takes a separate route — `mcp/server_cutover.py:254,335,1058,1070` → `operations/session_reads.execute_session_operation` → `archive/query/transaction`. Nothing under `polylogue/mcp/` imports `daemon_reads`, `execute_operation` or `daemon_client`. **Any parity claim resting on a shared read chokepoint is currently false.** Filed separately. ## Residual `message_query_reads.py` still spells `tuple(column[0] for column in cursor.description or ())` inline six times instead of calling the new `mappers_archive.cursor_column_names` — left unadopted deliberately to keep the conflict surface small while other lanes are in flight. Mechanical follow-up. Advances polylogue-o21. 🤖 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]>
… 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]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 0914f89):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
Seven commits covering six of eight assigned beads. Two bead clauses were found already satisfied at head and reported with file:line rather than re-implemented. One regression introduced in the first commit was caught in this lane, fixed, and covered by a test.
All edited production files are IN the derived schema closure — this must land before any rebuild starts. Three edits step
INDEX_SCHEMA_VERSION100 → 103.The self-caught regression
wohvdropped four write-only UNINDEXED columns from contentlessmessages_fts. That movedtextfrom ordinal 4 to ordinal 0 — and foursnippet(messages_fts, 4, ...)call sites kept the old ordinal, so every snippet-bearing FTS read raisedsqlite3.InterfaceError: column index out of range. It surfaced in an unrelated CLI test.Fixed across
search/runtime.py,search/query_builders.pyandarchive_tiers/archive.py, and thewohvregression test now issues asnippet()call itself, so a stale ordinal fails there rather than somewhere unrelated.A vacuous proof, found incidentally
Two bulk-build parity helpers were
SELECTing the four always-NULL columns off the index, so their "identical FTS rows" proofs were comparingtextalone. Both now joinblocksand compare real identity.a7xr.27 + 3szyi, and a policy correction that matters
Delivered as one embeddings-tier slice rather than an 89-table sweep, per
a7xr.27's own recorded campaign-boundary ruling. All five STRICT tables render from specs;message_embeddingsstates why it does not (vec0 is extension-defined). Both string-enumeration CHECKs now generate from their Python owner —EmbeddingFailureStatealready existed as aLiteralthe DDL simply did not use;EmbeddingAttemptStateis new because that vocabulary had no Python owner at all.3szyiAC2 as written is now FORBIDDEN for the durable tiers.devtools/verify_durable_enum_checks.pyrefuses any source/user/audit membership list whose member set equals an enum's value set, because pinning an enum into durable DDL makes every later token a durable migration — vocabulary is validated at the write boundary instead. So of 40 remaining hand-written lists, 27 are deliberate and must not be converted; the genuinely convertible residue is index 3 + ops 7 + specs 3.a7xr.27's framing that it "lands the durable-tier CHECK gap in the same stroke" is superseded by that gate.Already satisfied at head — no change manufactured
cuxz.12AC3:threads_ftswas dropped at v62/63, rationale recorded in-tree; its only MATCH reader had zero production callers.cuxz.12AC2: premise no longer holds — boththreadsandthread_sessionsare views, andsession_ids_jsonis evaluated at query time, not a stored FK list. No stored duplication to remove.dab.1headline: the three tables no longer exist in the index tier at all; only the residual named in the bead's DESIGN was live.cuxz.7 — not attempted, with a reason
Its AC1 forbids a partial removal leaving a registered-but-unbacked insight, and the measured blast radius is 40 production files and 31 test files: two registry descriptors (which regenerate MCP tool contracts, the CLI
phasescommand and two docs), thethreadsview'swork_event_breakdownCTE backing a public field, andSESSION_WORK_EVENT_FTS_TRIGGER_DDL.That last edit lands inside the same
FTS_TRIGGER_DDLconstruction W1 is restructuring for the trigram retirement. Per the instruction to keep shared-file edits tight, this lane did not open that function. Everything is intact at head. Recommend dispatching after W1 lands, with the registry/MCP/docs regeneration budgeted in.Verification
Final focused run on the rebased head: 164 passed. Per-bead runs recorded individually.
devtools verify --quickall 22 gates ok.devtools render all --checkexit 0, zeroout of sync.DDL equivalence proved for the embeddings slice: pre-change hand-written DDL and spec-rendered DDL built into separate in-memory databases and compared per
sqlite_masterrow through_normalize_schema_sql— identical normalized DDL for 14 objects. No embeddings rebuild is forced by shape.Every added test names its anti-vacuity mutation. Two inherited reds proven on a clean baseline worktree.
New finding, not filed
snippet(messages_fts, ...)returns NULL on every row — a contentless FTS5 table cannot reconstruct source text. All three production readers already selectb.search_text AS fallback_textbeside it, so the call is dead weight on the hot search path. Outside every assigned bead and in code W1 is touching, so it was left alone.Also unresolved:
cuxz.11's suppression interacts with_next_session_event_position, which takesMAX(position)+1across three tables. Reasoned safe (no stored row occupies suppressed positions, every new position still exceeds every stored one,policy_idstays unique) but no dedicated append-after-suppression test was written.🤖 Generated with Claude Code
https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq