Skip to content

test(storage): stop lifecycle report tests drifting with new declarations - #3322

Merged
Sinity merged 1 commit into
masterfrom
feature/test/z2fj-stale-lifecycle-literals
Jul 27, 2026
Merged

test(storage): stop lifecycle report tests drifting with new declarations#3322
Sinity merged 1 commit into
masterfrom
feature/test/z2fj-stale-lifecycle-literals

Conversation

@Sinity

@Sinity Sinity commented Jul 27, 2026

Copy link
Copy Markdown
Owner

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.py9 passed
  • mypy --strict tests/unit/storage/test_index_fast_forward_lifecycle.pySuccess: 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

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.

…ions

Problem: three tests in test_index_fast_forward_lifecycle.py monkeypatched
by appending a synthetic declaration onto the REAL module-level
INDEX_DELTA_DECLARATIONS tuple, then asserted an exact literal
invalid_versions/missing_versions result. index_delta_declaration_report()
flags any declaration whose version exceeds the version under test, and
accumulates missing_versions across the whole expected range -- so every
schema version declared after these tests were written (38, 39, 41, 42, 43)
silently widened the actual result past the hardcoded literal, or (for the
missing_versions case) would have let any future undeclared gap leak into
an unrelated assertion.

What changed: all three tests now build an isolated declarations tuple
(filtered to only the versions each test actually needs, e.g. <=36 or
<=INDEX_SCHEMA_VERSION) before monkeypatching lifecycle.INDEX_DELTA_DECLARATIONS,
instead of splicing onto the live tuple. This matches the isolation
convention already used by other tests in this file (e.g.
test_semantic_delta_routes_a_plan_away_from_sql_fast_forward,
test_plan_orders_declarations_before_validating_contiguity), so the
asserted literals are stable regardless of how many future schema versions
get declared.

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
- ruff check / ruff format --check on the touched file -> clean
- Future-proofing proof: temporarily added a throwaway v44 IndexDeltaDeclaration
  to the real module-level INDEX_DELTA_DECLARATIONS tuple in lifecycle.py and
  reran the suite. All 3 previously-fixed tests still passed unchanged (their
  isolated fixtures ignore versions beyond what each test needs). Only
  test_current_index_schema_has_a_complete_delta_declaration failed, which is
  expected/correct: a declaration beyond the current INDEX_SCHEMA_VERSION is
  itself an invalid state per the report's own semantics, not a test bug.
  Reverted the throwaway declaration afterward (lifecycle.py has zero diff).

Ref polylogue-z2fj

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: 6b9d8cf7-19f4-43c3-af75-00c28df84f44

📥 Commits

Reviewing files that changed from the base of the PR and between 441158e and 5086399.

📒 Files selected for processing (1)
  • tests/unit/storage/test_index_fast_forward_lifecycle.py

📝 Walkthrough

Walkthrough

Three lifecycle tests now filter INDEX_DELTA_DECLARATIONS to relevant versions before applying monkeypatches, preventing future declarations from affecting invalid-version and schema-policy assertions.

Changes

Lifecycle test isolation

Layer / File(s) Summary
Filter declaration fixtures for rejection tests
tests/unit/storage/test_index_fast_forward_lifecycle.py
The tests restrict declarations to versions at or below the relevant threshold before adding invalid declarations or checking schema-policy results.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: isolating lifecycle tests so they do not drift with new declarations.
Description check ✅ Passed The description covers summary, problem, solution, and verification, and the missing changelog is acceptable for a test-only PR.
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/test/z2fj-stale-lifecycle-literals

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 7b7358c into master Jul 27, 2026
3 checks passed
@Sinity
Sinity deleted the feature/test/z2fj-stale-lifecycle-literals branch July 27, 2026 13:09
Sinity added a commit that referenced this pull request Jul 27, 2026
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