Repository navigation
fix(storage): validate manifests on readable opens - #4546
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 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: 1042f6db04
ℹ️ 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".
Flattened from feature/packet/polylogue-o0j93 onto current master; lane text excluded. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz
1042f6d to
f0e7b1d
Compare
#4594) ## Summary Fixes 20 of the 22 Codex review findings recorded for storage. One is refuted with evidence, one is confirmed only in part, and two are deferred with reasons. Five commits, one per seam: 1. `material-protocol` — semantics versioning and read gating 2. `storage` — derived schema identity, manifests, lifecycle admission 3. `storage` — writer provenance, tool verdicts, session kind 4. `storage` — vector counting and index attachment 5. `storage` — provider cost attribution on append Every finding was re-confirmed by behavior at this branch's base (`c1d2544f0`); the recorded line numbers were treated as hints, since they were captured against `cc58ef3e6`. ## Problem ### Semantics versioning (#4554, #4557) - **20** — `material_protocol/v1/constants.py:22`: `SEMANTICS_VERSION` was 3 while attachment records had gained `direction`, `producer_ref` and `caption`, so the encoder emitted bytes the declared version did not describe. `test_checked_in_bytes_match_a_fresh_encode` was red on master. Confirmed by decoding both sides: the fresh encode carries the three keys, the checked-in fixture does not. - **21** — `material_protocol/v1/verify.py:50-92`: `resolve_anchor` verified an anchor's digest, record id and seq but never the manifest's semantics version. Only `verify_revision` called `require_current_semantics`, so the single-record read path decoded records whose shape this reader may not implement. - **22** — `material_protocol/v1/manifest.py:194`: `int(payload["semantics_version"])` coerced before comparison, so a declared `3.9` truncated to a supported `3`. ### Schema identity, manifests, lifecycle (#4544, #4546, #4548, #4560, #4556) - **10** — `archive_tiers/index.py` appends `schema_identity` to `INDEX_DDL`, but `tests/infra/reindex_differential.py::compared_table_census` raises on any DDL table with no declared classification, so the rebuild differential raised on every current archive. - **11** — `schema_manifest.py`: `canonical_schema_manifest` executed the whole tier DDL into a fresh `:memory:` database on every call, and every read open asserts against it. - **12** — `schema.py:73`: `except (RuntimeError, sqlite3.Error)` reported `rebuild_index` for both, so a SQLite failure that never inspected the schema was indistinguishable from real drift — and told the operator to destroy a sound index. - **13** — `schema_manifest.py:33`: the projection filtered only `NOT LIKE 'sqlite_%'`, so FTS5 shadow tables were compared and an FTS5 build change would read as archive schema drift. - **15** — `archive_tiers/bootstrap.py`: `open_initialized_tier_connection` ran `initialize_archive_tier` before `assert_tier_schema_supported`. `_apply_archive_tier_convergence` rewrites `user_version` to the spec version (bootstrap.py:387-388), so the check validated a value the same call had just written: a tier at some other version was restamped into apparent currency and admitted. `initialize_archive_database` gets this right (it reads the stored version first, bootstrap.py:553); this route did not. - **16** — `stamp_derived_schema_identity` issues an `INSERT ... ON CONFLICT` and never commits. It runs *after* `_materialize_archive_tier`'s own commit, so it sits in its own open transaction and rolls back on close. Some callers committed afterwards; `open_initialized_tier_connection` and the OPS same-version reapply did not. - **17** — `connection_profile.py`: the post-materialization check read only `PRAGMA user_version` and never the derived identity — the one thing the stamp exists for, and the only one of the two that materialization has not just overwritten. - **18** — `raw_failure_lifecycle.py:111`: `validate_schema=False` on the admission path (callers `bulk_rebuild.py`, `archive_verification.py`). - **19** — `archive_readiness.py:269`: bare `sqlite3.connect(...mode=ro)` with no version check, reached from `readiness/capability.py`'s frontier source-selection. Its result is surfaced to users as `source_embedded_messages`. ### Writer (#4506, #4561) - **1** — `write.py`: `session_kind` is derived once at admission from `session.branch_type` alone. `_refresh_session_projection` later re-derives `branch_type` from resolved `session_links` — including hook-authoritative edges the parser never saw — but its `UPDATE`s never touched `session_kind`, so a subagent child discovered after admission stayed `PRIMARY` permanently. - **2** — `write.py::_coalesce_block_row`: `tool_outcome`, `tool_result_is_error`, `tool_result_exit_code` and `tool_result_outcome_unknown_reason` were each coalesced independently by `_coalesce_scalar`, so a merge could persist a fresh `success` beside a stale `is_error=1`/`exit_code=1` that contradicts it. - **4** — `write.py::_attachment_provenance`: with no `message_id` fallback, a model turn whose provider supplied no message id derived `("model_output", None)`, which the writer then rejects — failing the whole session write. **Superseded during this work**: #4587 landed the same fix with a better implementation (`resolved_message_id`, applied to the parser-declared path as well as the role-derived one). This branch drops its own version and keeps master's. Finding 5 is still fixed here, because #4587 did not touch the stale test. - **5** — `tests/.../test_archive_tiers_write.py`: `test_writer_refuses_attachment_without_derived_direction` still asserted the refusal contract #4561 replaced, and was red on master with `DID NOT RAISE`. ### Embeddings and vector search (#4538) - **7** — `sqlite_vec_runtime.py:98`: `ATTACH DATABASE ?` with no existence check. ATTACH creates the file, so a missing active index silently became an empty database and the projection reported an archive with no eligible messages. - **9** — `sqlite_vec_queries.py:277-293`: `count_session_embeddings` counted rows in `current_embedding_messages` — the *eligible-message* projection, which has no relation to `message_embeddings` — so a session mid materialization or with failed embeds reported vectors it did not have. The value reaches users through `repository_vectors.py` → `daemon/similarity.py` → `web_shell_similar.py` as "N embedded messages". ## Solution Semantics: bump `SEMANTICS_VERSION` to 4 and regenerate the checked-in cross-repo fixture; gate `resolve_anchor` on the version as `verify_revision` already was; read the declared version as an exact integer, rejecting `bool`, non-integral floats and strings. Schema identity: commit the stamp inside `initialize_archive_tier`, the single choke point every derived-tier materialization passes through; admit the stored version in `open_initialized_tier_connection` *before* materialization can restamp it; assert the derived identity in `assert_tier_schema_supported` alongside the version; split `assert_readable_archive_layout`'s handler so a SQLite failure reports a new `retry` lifecycle action instead of `rebuild_index`; cache the canonical manifest per declared schema, keyed on the DDL so a substituted schema cannot take a stale hit; exclude FTS5 shadow tables by exact suffix; route raw-failure admission and frontier source selection through the schema-enforcing open; classify `schema_identity` in the rebuild differential as comparable, since a rebuild producing a different identity is exactly what that differential is for. Writer: take all four tool-verdict columns from one row together; re-derive `session_kind` through `admitted_session_kind` wherever the projection writes `branch_type`; replace the stale attachment-direction refusal test with tests for the derivation #4587 introduced. Vectors: count distinct stored refs joined to vector metadata; refuse a missing active index instead of creating one. ## Half-refuted, half-fixed - **3** — "`_seed_session_model_usage_rows` never clears rows for a previous model, so `usage.py`'s `SUM(provider_cost_usd)` double-counts after a model switch." **Refuted for the full-replace path**, which is the mechanism as stated. Every full-replace write first calls `_clear_session_projection_rows`, whose table list includes `session_model_usage` (write.py:1217), so no stale row survives to be summed. Two existing tests cover exactly this and pass: `test_provider_usage_model_switch_on_reingest_does_not_double_count` and `test_provider_usage_model_vanishing_on_reingest_leaves_no_stale_rollup`. **Confirmed for merge-append**, which that clearing cascade does not cover. master already carries a test for the intended contract — `test_merge_append_replaces_prior_provider_total_on_model_switch`, added by #4505 — and it has been failing ever since, because nothing clears the prior model's `provider_cost_usd`. Verified by exercising the writer directly at master's `write.py` and at this branch's: both returned `[gpt-new 2.0, gpt-old 1.0]` where the test requires `gpt-old` to be `None`. The fifth commit clears the prior attribution, and that same probe now returns `[gpt-new 2.0, gpt-old None]`. ## Refuted, not fixed - **14** — "`SameVersionSchemaVariant` has no upper bound; the index tier is at v85 while the v78 SEMANTIC_REPARSE entry's variant is still unbounded." There is no v78 variant. `INDEX_SAME_VERSION_SCHEMA_VARIANTS` contains exactly one entry, `introduced_version=63` (`remove_fts_bulk_guard` on three trigram triggers), and always has. The named entity does not exist, so there is no concrete input with a wrong outcome. The open-ended applicability of that one entry is a deliberate property of a permanently retained benign trigger-body variant, not a defect. ## Deferred, with reasons Two findings are real and unfixed here because each is a design change rather than a review-sweep patch. Both warrant their own tracked work: - **6** — the embedding contract refresh commits data and metadata non-atomically, and both `writer_lock()` and `recover_interrupted()` call `_generations()`, which raises on the resulting mismatch with no path out. Confirmed still true. A fix means making `generation.json` publication crash-safe and giving recovery a way to re-derive the contract from the committed database; that is the embeddings lifecycle's durability contract, not a patch. - **8** — `sqlite_vec_runtime._get_connection` rebuilds the full `current_embedding_messages` projection — a whole-archive scan and join with a per-row hash — on every connection, and every query opens its own connection. Confirmed still true. A fix needs a cache keyed on index generation or a pooled connection, with the invalidation and concurrency design that implies. Also worth noting: there is no `devtools` command to regenerate the material-protocol golden fixture. It was regenerated here through `encode_session_revision` + `write_revision` and verified byte-for-byte against a fresh encode; a supported regeneration route would be a reasonable follow-up. ## Verification ``` devtools verify --quick devtools test tests/unit/storage/test_writer_verdict_and_kind_projection.py \ tests/unit/storage/test_derived_schema_identity_admission.py \ tests/unit/storage/test_archive_tiers_write.py \ tests/unit/storage/test_vec_session_seed.py \ tests/unit/material_protocol/v1/ \ tests/unit/storage/test_archive_readiness.py \ tests/unit/storage/test_derived_schema_identity.py \ tests/unit/storage/test_cost_queries.py -n 4 ``` All twelve static gates pass, including `schema-versioning`. Anti-vacuity was checked by mutation, not assumed. Reverting the `conn.commit()` in `initialize_archive_tier` turns `test_schema_identity_stamp_survives_the_connection_that_wrote_it` red; deleting the stored-version admission from `open_initialized_tier_connection` turns `test_a_skewed_tier_is_refused_before_materialisation_restamps_it` red. Both were run and observed. Every new test's docstring names the specific mutation that makes it fail. ## Residual risk - Asserting the derived identity in `assert_tier_schema_supported` refuses a tier at the current version whose stamp does not match this runtime. That is the intent, and `initialize_archive_database` already enforced the same check on its own route, so an archive in normal use is already stamped. The check is deliberately *not* on every `open_connection` — an earlier draft put it in `_assert_schema_supported`, which would have made every read open recompute `derived_schema_identity` (uncached, over three fingerprints) and would have refused any never-stamped archive on a read-only path. - `lifecycle_action="retry"` is a new value in that field. It is free-form and forwarded to MCP payloads; no closed vocabulary or dispatch consumes it. - The FTS5 shadow filter matches the five exact FTS5 suffixes rather than a name prefix. A prefix would have wrongly dropped `messages_fts_identity` and the three `messages_fts_a{i,d,u}` triggers, which are ours; the test asserts both halves. - Bumping `SEMANTICS_VERSION` to 4 makes this reader reject v3 bytes by contract. `constants.py` notes the fixture is checked in "in lockstep with the Sinex counterpart (sinex-4j2.1)"; that repo pins the same version and will need the corresponding bump. Nothing in this repo reads v3 bytes from disk outside the regenerated fixture. - `tests/unit/storage/test_archive_readiness.py` builds stub two-table index databases to exercise gap classification. Now that the probe reads through the schema-enforcing open, those fixtures stamp the precondition explicitly via a named helper rather than relying on the probe not checking. ## Inherited failure `tests/unit/storage/test_connection_profile.py::test_open_readonly_connection_uses_descriptor_bound_database` fails identically on clean `origin/master` (verified by stashing this branch's changes and rerunning). It is not touched or fixed here. `test_merge_append_replaces_prior_provider_total_on_model_switch` was also inherited-red, confirmed the same way; unlike the above it is fixed here, because it is the merge-append half of finding 3. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01YGi8wLWGR2HYBh8p8fXFXz --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
) ## Summary Lands worker 8's review-debt fixes for `polylogue-1tyq5.107`, `.108` and `.109` (storage reads, usage, query objects, connection profile), rebased onto current master and reviewed. Of 52 findings: 24 fixed with regression tests, 9 already fixed on master, 19 not reached. ## Problem The worker's commit could not be run by its author. On review, several fixes were right in intent but wrong in shape: - the writer refusal of unprovisioned tiers also removed the index version-zero exemption and changed attached-sibling and reader checks; - `ReadFrame.resume` rebound on every external commit, which resets `data_version` and would hide a mixed source census from `_require_current_source_census_frame`; - the effective-context fix changed the API route only, leaving the pinned `read.effective_context` operation reading own rows with the old boundary rule; - the profile snapshot fix covered only the batch read; - the attachment-library order used `attachment_refs.position`, an identity coordinate rather than a display ordinal; - the subscription conversion reported $0 for an unrated model or an undeclared tier. ## Solution - Worker commit, rebased unchanged. - Follow-up commit: writers refuse a never-provisioned tier only when they open it directly; every reader path keeps master's absent-tier answer. `resume` rebinds only for a held read transaction and refuses while a stream pins the snapshot. `effective_context_window` plus one boundary query is now the single owner for both effective-context routes, and both compose the lineage transcript. Single, batch and list profile reads hold one snapshot. Library pages order by attachment ID within a message, matching the session read. Checkpoint blockers stay named when the checkpoint failed. The cumulative lane uses the same counter-evidence rule as the request lane. Subscription equivalents are `None` when the rate or tier is unknown. `put_query` raises instead of asserting. No Origin to Provider reversal is added. `coverage.provider` was already present and is unchanged. ## Verification - `agentctl job start polylogue verify_quick --workspace /realm/worktrees/salvage-w8 --wait` → job 2311 `succeeded` (head 65a248e762, same tree as 02c3d8c). - `agentctl job start polylogue pytest_focused --workspace /realm/worktrees/salvage-w8 --wait -- <30 test files>` → job 2314: `790 passed, 4 failed`. All four failures are inherited: job 2294 reproduces them with every production file reset to `origin/master`: - `test_diagnostics.py::test_latency_plain_zero_rows_reports_unknown_drop_accounting` - `test_facade_contracts.py::test_archive_facet_buckets_count_unique_sessions_for_duplicate_hits` - `test_facade_contracts.py::test_no_undiscovered_async_methods` - `test_mapped_bytes_budget.py::test_async_attached_tier_profiles_map_main_only[configure_read_connection]` - Anti-vacuity: in a worktree with every changed production file reset to `origin/master`, the new regression tests fail on their assertions (job 2262: `40 failed`; job 2315: `3 failed`, covering the revised attachment test, the updated budget test and the cumulative-lane test). ## Self-review - **Siblings and owners.** Effective context had two deciders, the API route and `operations/read_view_extras.py`. Both now call `effective_context_window`. The one-snapshot fix covers all three profile reads. Reportedness now uses the same counter-evidence rule for the request and cumulative lanes. The schema refusal applies only where a writer opens a tier. Reader, sibling, sealed-staging and `assert_tier_schema_supported` callers keep master behaviour. - **The fix itself.** Rebinding on any stale `revalidate()` would have defeated the census end check, so it was dropped. `ReadFrameExpiredError` from `resume` during a stream is an existing typed error, and the census never resumes mid-stream. The `assert` in `put_query` became a raise. - **Memory and limits.** Session-cost IDs page at the connection's physical bind limit, with no new cap. Both effective-context routes still compose the whole transcript, as `get_messages` already did. See residuals. - **Cost per unit.** Attachment-library paging still uses the existing OFFSET. The new `LEFT JOIN messages` is on the primary key. - **Interruption.** The added read transactions roll back in `finally`. `ReadFrame.close` retires stream cursors before closing the connection. - **Ordering and races.** Messages, boundary and blocks are read in one snapshot, as are profile rows and usage. `resume` never proves an anchor on a held snapshot. - **Failure classification.** A canonical-DDL build failure is `upgrade_runtime`, separate from `retry` and drift. Checkpoint blockers are kept on error. - **Silent outcomes.** A lane without counter evidence is `unavailable`, and a lane with an explicit zero is `reported`. An unknown subscription rate or tier is `None`, not $0. - **Cleanup on failure.** Every added `BEGIN DEFERRED` ends with `ROLLBACK` in `finally`. - **Identity and keys.** No hash or ID changes. - **Lossless transforms.** Not applicable. - **Degenerate inputs.** NaN and infinite snapshot bounds are refused. Negative or reversed boundary ranges fall back to the plain prefix. An empty ID list returns early. - **Consumers.** The CLI renderer uses the lane fields. `test_mapped_bytes_budget` was updated to three writers. `read_view_extras` uses the new owner. - **Tests and stubs.** The monkeypatch targets (`_own_messages`, `read_model_usage_batch_async`, `_resolve_subscription_tier_setting`) exist and are called on the production route. Each test states its anti-vacuity condition. - **Trust boundaries.** No change. ## Per-finding dispositions | key | disposition | evidence | test | |---|---|---|---| | 107-01 (#4642) | not reached | still real: Invalidation returns children, not the former parent cohorts; only the current session receives an explicit delegation refresh. | — | | 107-02 (#4690) | not reached | still real: LIKE requires an immediate subagents basename and the parent check uses parts[-3]. | — | | 107-03 (#4642) | not reached | still real: Retired-alias invalidation selects only resolved links to the withdrawing claimant; graph inbound lookup only addresses the written session. | — | | 107-04 (#4690) | not reached | still real: Unresolved multi-name observations are skipped and sidecars can bind the known sibling; no full parent cohort revisit on a second child arrival. | — | | 107-05 (#4056) | not reached | still real: Every controller submits to one four-worker adapter, regardless of its capacity. | — | | 107-06 (#4606) | fixed-already | `polylogue/storage/sqlite/connection_profile.py:900-910; :1193-1206` holds on current master | — | | 107-07 (#4610) | fixed-already | `polylogue/storage/sqlite/connection_profile.py:932-945` holds on current master | — | | 107-08 (#4611) | fixed-already | `polylogue/storage/sqlite/connection_profile.py:932-945` holds on current master | — | | 107-09 (#4687) | fixed | `_assert_schema_supported` keeps the empty-tier exemption for read-only opens only; `open_connection`/`open_daemon_connection` on a never-provisioned tier now raise `SchemaSkew` before any SQL. Attached siblings keep the absent-tier read answer. | `test_writers_refuse_an_uninitialized_durable_tier` | | 107-10 (#5248) | fixed | `mapped_bytes_budget` and `MappedBytesBudgetCheck.concurrent_profile_budget_bytes` count three ordinary writer profiles (index, source, publication reservation). | `test_memory_budget_includes_source_and_reservation_writers` | | 107-11 (#4794) | not reached | still real: A pathname stat after opening can stamp the connection with a replacement inode. | — | | 107-12 (#4794) | fixed | `ReadFrame.resume` rebinds a live frame whose connection holds a read transaction before proving the anchor, and refuses with `ReadFrameExpiredError` while a stream pins the snapshot. | `test_resume_releases_a_held_snapshot_before_proving_the_anchor, ::test_resume_refuses_while_a_stream_pins_the_snapshot` | | 107-13 (#5401) | not reached | still real: Cancel interrupts a running statement but leaves a cursor suspended at yield open. | — | | 107-14 (#5401) | fixed | `ReadFrame.close` closes registered stream cursors before the connection, so later generator cleanup has nothing to do. | `test_stream_can_be_closed_after_its_frame` | | 107-15 (#5401) | fixed | `read_frame` and `ReadFrame.__init__` refuse NaN and infinite snapshot bounds. | `test_read_frame_rejects_nonfinite_snapshot_bounds` | | 107-16 (#4183) | fixed | `format_session_markdown` uses the recorded `source_url` when an attachment has no local path. | `test_markdown_uses_remote_attachment_urls_without_a_local_path` | | 107-17 (#5454) | not reached | still real: The session filter selects physical attachment refs only, excluding a composed parent prefix. | — | | 107-18 (#5454) | fixed | The attachment library orders by session sort key (newest first), then message position/variant, then attachment ID within a message (as the session read does), before LIMIT/OFFSET. | `test_attachment_library_pages_keep_session_and_transcript_order` | | 107-19 (#5420) | fixed-already | `polylogue/analysis/archive_models.py:79; polylogue/storage/derived/session/profiles.py:248; polylogue/storage/sqlite/queries/mappers_insight_profiles.py:54-56` holds on current master | — | | 107-20 (#4985) | fixed | `effective_context_window` (the single owner, used by both the API and the pinned `read.effective_context` operation) falls back to the plain prefix unless 0 <= start <= end. | `test_effective_context_rejects_invalid_ranges` | | 107-21 (#4985) | fixed | The boundary query selects the newest compaction first; an incomplete newest row yields the plain prefix instead of an older summary. | `test_newest_incomplete_compaction_does_not_reuse_an_older_summary` | | 107-22 (#4357) | fixed | Both effective-context routes now compose the lineage transcript before applying the local boundary. | `test_effective_context_includes_a_forks_inherited_prefix, ::test_pinned_operation_and_api_share_one_effective_context_decision` | | 107-23 (#4357) | fixed | Messages and the boundary are read in one deferred read transaction. | `test_effective_context_reads_boundary_in_the_message_snapshot` | | 107-24 (#4577) | fixed | Single, batch and list profile reads hold one read snapshot across the profile rows and the usage overlay. | `test_profile_rows_and_usage_overlay_share_one_snapshot` | | 107-25 (#4630) | not reached | still real: LIMIT is applied to thread ids before hydration drops roots without profiles. | — | | 108-01 (#4200) | fixed | `put_query` returns the persisted row (including promotion metadata) after the idempotent insert. | `test_put_query_returns_existing_promotion_contract` | | 108-02 (#4200) | not reached | still real: The tombstone predicate checks only the caller-provided result_set_id. | — | | 108-03 (#4357) | fixed | `get_effective_context` hydrates blocks and derived text inside the same snapshot as the messages. | `test_effective_context_hydrates_structured_tool_blocks` | | 108-04 (#4799) | fixed | Compaction context snapshots take `event position + 1`, leaving position 0 to the session-start snapshot. | `test_context_snapshot_start_precedes_the_first_compaction` | | 108-05 (#4546) | fixed-already | `polylogue/storage/sqlite/schema_manifest.py:92-129` holds on current master | — | | 108-06 (#4546) | fixed | A failure to build the canonical index manifest is classified `upgrade_runtime`, separately from archive read failures (`retry`) and drift. | `test_canonical_ddl_runtime_failure_requests_runtime_upgrade` | | 108-07 (#4579) | fixed-already | `polylogue/storage/sqlite/archive_tiers/archive.py:6694-6697; :8603-8616; polylogue/storage/sqlite/queries/sessions_search.py:25-27; polylogue/mcp/server_support.py:546-555` holds on current master | — | | 108-08 (#4637) | fixed-already | `polylogue/storage/sqlite/schema.py:113-128; polylogue/storage/sqlite/schema_bootstrap.py:87-101` holds on current master | — | | 108-09 (#4637) | not reached | still real: An installed read-only source tree cannot host the persistent memo, so short-lived processes recompute source closures. | — | | 108-10 (#4601) | not reached | still real: The existing async identity-adoption helper inserts without a commit. A compliant fix must remove unsupported legacy adoption rather than perpetuate it. | — | | 108-11 (#5401) | fixed | Read frames are named as checkpoint blockers only when the checkpoint left busy pages or undrained log, or failed. | `test_successful_checkpoint_does_not_label_current_snapshot_as_a_blocker` | | 108-12 (#4317) | not reached | still real: Cumulative input always subtracts cache; origin is explicitly discarded. | — | | 108-13 (#4317) | not reached | still real: Duplicate non-Codex disjoint-input report, retained separately. | — | | 108-14 (#4317) | not reached | still real: The exported canonical projection has no production caller; writer paths still fold usage separately. | — | | 108-15 (#4317) | not reached | still real: Each cumulative session rebuilds the entire grouped dictionary. | — | | 108-16 (#4317) | not reached | still real: Default tuple ordering compares nullable model names against strings in projection and rollup. | — | | 108-17 (#4317) | fixed-already | `polylogue/storage/usage.py:237-247` holds on current master | — | | 108-18 (#4317) | not reached | still real: Reasoning-only or total-only evidence can become a complete zero-cost projection. | — | | 108-19 (#4317) | not reached | still real: Costs are rounded to six decimal places before further aggregation. | — | | 108-20 (#4927) | fixed-already | `polylogue/storage/usage.py:589-595` holds on current master | — | | 108-21 (#4927) | fixed | The plaintext usage report renders `provider_request_lanes`/`provider_cumulative_lanes` and prints `unavailable` for an unreported lane. | `test_usage_cli_renders_disjoint_lanes_and_unavailable_requests` | | 108-22 (#4927) | fixed | Request-lane reportedness counts events that carry a last/request counter (`request_counter_event_count`), in both the SQL and streaming stats paths. The cumulative lane follows the same counter-evidence rule. | `test_request_lane_reportedness_requires_request_counter_evidence` | | 108-23 (#4927) | fixed | Same change: cumulative-only events stay `unavailable`; an explicit request zero stays `reported`. | `test_request_lane_reportedness_requires_request_counter_evidence` | | 108-24 (#4293) | fixed | The cache-rate coverage check runs before a stored priced cost is reused. | `test_stored_price_does_not_hide_a_missing_cache_rate` | | 108-25 (#4217) | fixed | `session_usage_costs_for_connection` batches IDs at the connection's `SQLITE_LIMIT_VARIABLE_NUMBER`. | `test_session_cost_lookup_pages_at_the_connection_bind_limit` | | 109-01 (#4217) | fixed | Model names are normalized before the credit lookup; a token-bearing row whose model still has no credit rate makes the session's subscription amount unknown (None), not $0. | `test_session_subscription_fallback_normalizes_provider_qualified_models, ::test_session_subscription_amount_is_unknown_without_a_rate_or_tier` | | 109-02 (#4217) | fixed | Credits pass through `credits_to_usd` with the archive's configured tier (default `pro`); a tier the catalog no longer declares yields None. | `test_session_subscription_amount_is_dollars_not_raw_credits` | Worker claims narrowed rather than rejected: 107-09, 107-12, 107-18, 107-22 and 107-24 (see Problem), and 109-01/109-02 (fail closed). No worker `fixed` claim was dropped as not real. ## Derived-identity closure `devtools schema closure` on the changed files. IN: `storage/sqlite/connection_profile.py`, `queries/attachment_records.py`, `queries/message_query_reads.py`, `query_objects.py`, `query_store_archive.py`, `run_projection_relations.py`, `schema.py`, `wal_checkpoint.py`, `storage/usage.py`. Out: `cli/commands/diagnostics.py`, `operations/read_view_extras.py`, `rendering/core_markdown.py`, `queries/session_insight_profile_reads.py`. Land this before a rebuild starts. ## Residuals - 19 findings remain not reached, and their beads stay open. - The pinned `read.effective_context` operation returns messages without hydrated blocks. The API route hydrates them. This predates the PR. - Both effective-context routes compose the full transcript in memory, as `get_messages` does. - `_attach_sibling_tiers` still admits an empty sibling tier on a writer connection. Only direct writer opens refuse. - Four inherited test failures on master are listed above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
Readable current-version index opens now validate the canonical semantic schema manifest and reject missing, extra, or incorrectly defined SQLite objects with typed rebuild guidance. Contract tests cover extra-object drift and updated read-only drift expectations.
Problem
assert_readable_archive_layoutchecked the schema version and one sessions column but did not compare the full semantic manifest. A current-version read-only index with undeclared objects or missing runtime indexes could therefore be admitted.Solution
Call
assert_schema_manifestfrom the readable current-version path. Convert manifest and SQLite inspection failures intoSchemaVersionMismatchErrorwith generation metadata, rebuild lifecycle action, and the mismatch detail.Verification
bash nix/devtools-wrapper.sh test tests/unit/storage/test_schema_policy_contracts.py -k readable_layoutpassed: 2 passed, 16 deselected.bash nix/devtools-wrapper.sh test tests/unit/storage/test_schema_policy_contracts.pypassed: 18 passed, 1 warning.bash nix/devtools-wrapper.sh verify --quickpassed all reported checks, including ruff format, ruff check, mypy, render all, layering, patterns, CI commands, JavaScript tests, doc commands, schema roundtrip, schema versioning, oracle integrity, consumer reachability, definition closure, timestamp doctrine, insight honesty, schema promotion audit, and schema privacy registry.Residual risk
The full corpus was not run in this lane, per the worker contract. The quick gate output closed before its final summary line, but every reported quick check completed with
ok.Receipt: harvest-3c3005f22921c941f7f469c511154664