feat(kt-config): validate GraphTypePlugin version contract at registration#253
Merged
charlie83Gs merged 2 commits intomainfrom Apr 20, 2026
Merged
Conversation
…ation Catches broken version/migration contracts before they reach the Phase 7 migration planner: - current_version must be an integer >= 1 (versions are 1-indexed; default plugin ships at v1). - Every declared migration must be single-step: to_version == from_version + 1. Multi-step hops would leave gaps the planner can't walk. - from_version must be >= 1 — negative/zero source versions never correspond to a real plugin state. - Every hop from v1 to current_version - 1 must have at least one migration registered. A plugin shipping at v3 with only a 2 -> 3 migration would strand v1 graphs. Dup check still runs first so re-registering over an existing id stays a silent no-op (matches the existing idempotency contract; also keeps test/dev-tooling stubs from tripping the migration contract on the replacement). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PluginRegistry.register_graph_type now validates that every hop from v1 to current_version has at least one migration declared. The API router test's _FakeGraphType returns current_version=3 without any migrations — silenced today but trips the validator introduced in the same change. Add two no-op _MigrationStub rows covering the v1 -> v2 and v2 -> v3 hops so the plugin registers cleanly. The router doesn't run migrations; stubs are inert. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
charlie83Gs
added a commit
that referenced
this pull request
Apr 20, 2026
…elta tiebreak
- Status filter inverted from ``status == 'active'`` to
``status.not_in(('deleted', 'provisioning', 'error'))`` — matches
the docstring's exclusion list and makes future statuses
(``archived`` / ``suspended`` / etc.) opt-out rather than opt-in.
Reviewer flagged the drift risk correctly; the inversion moves
the question to "do we skip this?" at review time.
- Test uses ``timedelta(microseconds=1)`` instead of mutating via
``replace()`` — same 1/1M flake guard as PR #258.
- Comment on ``_V2Plugin.migrations()`` + ``_M`` stub explaining the
stub is load-bearing for ``register_graph_type``'s hop-coverage
validator (PR #253), not dead code. Discovery tests don't call
the planner, but they DO call ``register_graph_type``, which is
what needs the migration row.
- New test ``test_unknown_status_is_auto_included`` pins the
inverted-filter contract so a future refactor that silently
narrows back to ``== 'active'`` trips here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Catches broken version/migration contracts at
register_graph_typebefore they can reach the Phase 7 migration planner. Four checks on the declared contract:current_versionmust be an integer>= 1(versions are 1-indexed; the default plugin ships at v1).to_version == from_version + 1. Multi-step hops would leave gaps the planner can't walk.from_versionmust be>= 1— negative/zero source versions never correspond to a real plugin state.v1tocurrent_version - 1must have at least one migration registered. A plugin shipping at v3 with only a2 → 3migration would strand v1 graphs.Dup check runs first so re-registering the same
graph_type_idstays a silent no-op (matches the existing idempotency contract, keeps test/dev-tooling stubs from tripping the migration contract when they re-register over a working plugin).One drive-by fix:
services/api/tests/test_graph_types_router.py::_FakeGraphTypeadvertisescurrent_version=3with no migrations — silenced on main but trips the new validator. Added two inert_MigrationStubrows so it registers cleanly.Test plan
libs/kt-config: 203 pass (12 new validation tests)services/api: 2/2 graph-types-router tests pass after stub fixjust test-unitacross all 24 packages: green🤖 Generated with Claude Code