Skip to content

fix(storage): declare index schema v40 query-unit-frame delta - #3319

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/index-schema-v40-delta-declaration
Jul 27, 2026
Merged

fix(storage): declare index schema v40 query-unit-frame delta#3319
Sinity merged 1 commit into
masterfrom
feature/fix/index-schema-v40-delta-declaration

Conversation

@Sinity

@Sinity Sinity commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the missing IndexDeltaDeclaration(version=40, ...) entry to polylogue/storage/sqlite/lifecycle.py's INDEX_DELTA_DECLARATIONS registry so devtools lab policy schema-versioning recognizes the index-tier v39→v40 schema bump.

Problem

devtools lab policy schema-versioning was failing on master: "undeclared index schema deltas found: 1, missing: [40]". PR #3068 ("bind query_units continuations to the archive epoch", polylogue-z9gh.9) bumped INDEX_SCHEMA_VERSION from 39 to 40 -- adding the query_unit_frame_state table plus its insert/update/delete triggers on session_links, sessions, messages, blocks, session_tags, session_profiles, and delegation_facts -- but never added the matching IndexDeltaDeclaration. INDEX_DELTA_DECLARATIONS jumped straight from version=39 to version=41 (the latter added by a later, unrelated PR for polylogue-2i2w), silently skipping 40.

Solution

Added IndexDeltaDeclaration(version=40, classes=(DerivedDeltaClass.INDEX_ONLY,), operations=(...)) describing the actual v40 delta: one FastForwardOperation (kind=REPLACE_TABLE) whose objects list the query_unit_frame_state table and all 21 query_unit_frame_* triggers, matching exactly what df86837 (#3068) added to INDEX_DDL. No canonical DDL, executor, or runtime behavior changes -- this is a declaration-only fix; the schema itself already exists and is deployed.

Verification

  • devtools lab policy schema-versioning before: undeclared index schema deltas found: 1 / missing: [40]; after: undeclared index schema deltas found: 0 / Schema evolution policy intact.
  • devtools test tests/unit/storage/test_index_fast_forward_lifecycle.py tests/unit/storage/test_index_fast_forward_executor.py: the two tests this fix targets (test_current_index_schema_has_a_complete_delta_declaration, test_schema_policy_rejects_an_index_bump_without_a_delta_declaration) now pass. Two unrelated pre-existing failures remain (test_nonsemantic_delta_without_operations_is_rejected, test_delta_without_a_declared_class_is_rejected) -- confirmed via git stash to already fail identically on master, caused by a separate latent bug where invalid_versions flags every declaration with version > current_version regardless of the v40 gap. Out of scope here.
  • mypy --strict polylogue/storage/sqlite/lifecycle.py: no issues
  • ruff check / ruff format --check on the touched file: clean
  • devtools render all --check: no drift
  • devtools verify --quick (pre-push hook): passed

Ref polylogue-5h5y

Co-Authored-By: Claude noreply@anthropic.com

Summary by CodeRabbit

  • Improvements
    • Added a storage upgrade that introduces query-unit frame state tracking.
    • Improved synchronization of session, message, block, tag, profile, and delegation changes through automatic database updates.
    • Existing data is upgraded automatically when the application applies the new storage version.

Problem

devtools lab policy schema-versioning was failing on master:
"undeclared index schema deltas found: 1, missing: [40]". PR #3068
(polylogue-z9gh.9) bumped INDEX_SCHEMA_VERSION from 39 to 40, adding the
query_unit_frame_state table plus its insert/update/delete triggers on
session_links, sessions, messages, blocks, session_tags,
session_profiles, and delegation_facts -- but never added the matching
IndexDeltaDeclaration the policy lint requires for every version bump.
INDEX_DELTA_DECLARATIONS jumped straight from version=39 to version=41
(added later by polylogue-2i2w), silently skipping 40.

What changed

Add IndexDeltaDeclaration(version=40, ...) to
polylogue/storage/sqlite/lifecycle.py describing the real v40 delta:
classes=(DerivedDeltaClass.INDEX_ONLY,) with one FastForwardOperation
(kind=REPLACE_TABLE) whose objects list the query_unit_frame_state
table and all 21 query_unit_frame_* triggers, matching the exact set
added in df86837 (#3068). No canonical DDL, executor, or runtime
behavior changes -- this is purely a documentation-shaped fix that
lets the schema-versioning lint recognize a clone-safe delta that
already exists and is deployed.

Verification

- `devtools lab policy schema-versioning` before: "undeclared index
  schema deltas found: 1, missing: [40]"; after: "undeclared index
  schema deltas found: 0" / "Schema evolution policy intact."
- `devtools test tests/unit/storage/test_index_fast_forward_lifecycle.py
  tests/unit/storage/test_index_fast_forward_executor.py`: the two
  tests this fix targets
  (test_current_index_schema_has_a_complete_delta_declaration,
  test_schema_policy_rejects_an_index_bump_without_a_delta_declaration)
  now pass. Two unrelated pre-existing failures remain
  (test_nonsemantic_delta_without_operations_is_rejected,
  test_delta_without_a_declared_class_is_rejected) -- confirmed via
  `git stash` to already fail identically on master, caused by a
  separate latent bug where invalid_versions flags every declaration
  with version > current_version regardless of the version-40 gap.
  Not in scope for this fix.
- `mypy --strict polylogue/storage/sqlite/lifecycle.py`: no issues
- `ruff check` / `ruff format --check` on the touched file: clean
- `devtools render all --check`: no drift

Ref polylogue-5h5y

Co-Authored-By: Claude <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7ffa1db5-f1db-49f4-aeda-652ac25216f8

📥 Commits

Reviewing files that changed from the base of the PR and between b397f7e and a6aab6d.

📒 Files selected for processing (1)
  • polylogue/storage/sqlite/lifecycle.py

📝 Walkthrough

Walkthrough

The SQLite lifecycle registry adds index schema version 40 with an index-only clone-forward operation that creates query_unit_frame_state and associated insert, update, and delete triggers.

Changes

SQLite index schema update

Layer / File(s) Summary
Declare version 40 index objects
polylogue/storage/sqlite/lifecycle.py
Adds an INDEX_ONLY declaration using REPLACE_TABLE for query_unit_frame_state and triggers on session, message, block, tag, profile, and delegation tables.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • Sinity/polylogue#2788: Adds related planning and policy logic for the SQLite index fast-forward declaration registry.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the missing v40 index schema delta declaration.
Description check ✅ Passed The description covers summary, problem, solution, and verification; missing sections are reasonably skippable for this internal declaration-only fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/index-schema-v40-delta-declaration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 9a0e5ec into master Jul 27, 2026
3 checks passed
@Sinity
Sinity deleted the feature/fix/index-schema-v40-delta-declaration branch July 27, 2026 12:07
Sinity added a commit that referenced this pull request Jul 27, 2026
Sinity added a commit that referenced this pull request Jul 27, 2026
…ration tuple (#3322)

## Summary

Fixes 3 tests in
`tests/unit/storage/test_index_fast_forward_lifecycle.py` that hardcoded
exact literal `invalid_versions`/`missing_versions` results computed
against the *real*, ever-growing module-level `INDEX_DELTA_DECLARATIONS`
tuple in `polylogue/storage/sqlite/lifecycle.py`.

## Problem

`test_nonsemantic_delta_without_operations_is_rejected` and
`test_delta_without_a_declared_class_is_rejected` monkeypatched by
appending a synthetic declaration onto the *live*
`INDEX_DELTA_DECLARATIONS` tuple, then asserted `invalid_versions ==
(37,)`. `index_delta_declaration_report()` flags any declaration whose
version exceeds the version under test (`current_version=37` in these
tests), so every schema version declared since these tests were written
(38, 39, 41, 42, 43) widened the actual result to `(38, 39, 41, 42, 43,
37)`, breaking the literal assertion.

`test_schema_policy_rejects_an_index_bump_without_a_delta_declaration`
asserted `missing_versions == [INDEX_SCHEMA_VERSION + 1]`, but
`missing_versions` accumulates across the *whole* expected range
(`compatibility_floor+1 .. current_version`), so any
currently-undeclared gap elsewhere in the live tuple (e.g. the v40 gap
that existed before polylogue-5h5y/#3319) leaked into the same
assertion.

These were real, ongoing test-staleness bugs — correct when the
declarations tuple was short, silently masking/breaking indefinitely as
more versions get declared.

## Solution

All three tests now build an **isolated** declarations tuple — filtered
from the live `INDEX_DELTA_DECLARATIONS` to only the versions each test
actually needs (`<= 36` for the first two, `<= INDEX_SCHEMA_VERSION` for
the third) — before monkeypatching `lifecycle.INDEX_DELTA_DECLARATIONS`,
instead of splicing a synthetic declaration onto the unbounded live
tuple.

This matches the isolation convention already used elsewhere in the same
file: `test_semantic_delta_routes_a_plan_away_from_sql_fast_forward` and
`test_plan_orders_declarations_before_validating_contiguity` both fully
replace `lifecycle.INDEX_DELTA_DECLARATIONS` with a small,
self-contained fixture rather than layering onto the live tuple. Only
`lifecycle.py`'s test file changed — no production code touched.

## Verification

- `devtools test
tests/unit/storage/test_index_fast_forward_lifecycle.py` → `9 passed`
- `mypy --strict
tests/unit/storage/test_index_fast_forward_lifecycle.py` → `Success: no
issues found in 1 source file`
- `ruff check` / `ruff format --check` on the touched file → clean
- Pre-push quick verification baseline
(format/lint/mypy/render/topology/layering/closure-matrix/schema-roundtrip/manifests/etc.)
→ all green

**Future-proofing proof (per polylogue-z2fj step 5):** temporarily added
a throwaway `IndexDeltaDeclaration(version=44, ...)` to the real
module-level `INDEX_DELTA_DECLARATIONS` tuple in `lifecycle.py` and
reran the suite. All 3 fixed tests still passed **unchanged** — their
isolated fixtures ignore versions beyond what each test needs, so the
extra declaration never leaked in. The only failure was
`test_current_index_schema_has_a_complete_delta_declaration`, which is
expected/correct: a declaration beyond the current
`INDEX_SCHEMA_VERSION` is itself an invalid state per the report's own
semantics (`declaration.version > current_version`), not a test bug this
PR is scoped to fix. Reverted the throwaway declaration afterward —
`lifecycle.py` has zero diff in the final PR.

Ref polylogue-z2fj

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Improved lifecycle validation tests to remain reliable as additional
schema declarations are introduced.
* Preserved coverage for rejecting invalid or undeclared index version
changes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant