fix(storage): declare index schema v40 query-unit-frame delta - #3319
Conversation
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>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe SQLite lifecycle registry adds index schema version 40 with an index-only clone-forward operation that creates ChangesSQLite index schema update
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…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>
Summary
Adds the missing
IndexDeltaDeclaration(version=40, ...)entry topolylogue/storage/sqlite/lifecycle.py'sINDEX_DELTA_DECLARATIONSregistry sodevtools lab policy schema-versioningrecognizes the index-tier v39→v40 schema bump.Problem
devtools lab policy schema-versioningwas failing on master: "undeclared index schema deltas found: 1, missing: [40]". PR #3068 ("bind query_units continuations to the archive epoch", polylogue-z9gh.9) bumpedINDEX_SCHEMA_VERSIONfrom 39 to 40 -- adding thequery_unit_frame_statetable plus its insert/update/delete triggers onsession_links,sessions,messages,blocks,session_tags,session_profiles, anddelegation_facts-- but never added the matchingIndexDeltaDeclaration.INDEX_DELTA_DECLARATIONSjumped straight fromversion=39toversion=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: oneFastForwardOperation(kind=REPLACE_TABLE) whoseobjectslist thequery_unit_frame_statetable and all 21query_unit_frame_*triggers, matching exactly what df86837 (#3068) added toINDEX_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-versioningbefore: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 viagit stashto already fail identically on master, caused by a separate latent bug whereinvalid_versionsflags every declaration withversion > current_versionregardless of the v40 gap. Out of scope here.mypy --strict polylogue/storage/sqlite/lifecycle.py: no issuesruff check/ruff format --checkon the touched file: cleandevtools render all --check: no driftdevtools verify --quick(pre-push hook): passedRef polylogue-5h5y
Co-Authored-By: Claude noreply@anthropic.com
Summary by CodeRabbit