Skip to content

feat(kt-config): GraphMigration planner (Phase 7 #56)#254

Merged
charlie83Gs merged 1 commit intomainfrom
feat/graph-migration-planner
Apr 20, 2026
Merged

feat(kt-config): GraphMigration planner (Phase 7 #56)#254
charlie83Gs merged 1 commit intomainfrom
feat/graph-migration-planner

Conversation

@charlie83Gs
Copy link
Copy Markdown
Contributor

Summary

Ships the migration planner for Phase 7. Pure function (no Hatchet, no DB) that walks a `GraphTypePlugin`'s declared migrations and returns the ordered list advancing `from_version` to `plugin.current_version`. The Phase 7 `graph_migration_wf` (next PR) consumes this output to dispatch one migration at a time, persisting audit rows between hops.

Unblocks #57 (Hatchet workflow), #58 (startup auto-dispatch), #60 (first v1→v2 bump), #62 (integration test), #63 (PR #7 rollup).

Contract

Trusts the plugin's shape — the registry already validates at `register_graph_type` that `current_version >= 1`, every migration is single-step, and every hop is covered. Planner is a walker, not a validator.

Error cases:

  • `from_version < 1` raises (v1 is the baseline)
  • `from_version > current_version` raises (forward-only framework; downgrades resolved by re-deploying the newer plugin)
  • `from_version == current` returns `[]` (canonical "nothing to do" signal for startup auto-dispatch)

Ordering: hops run in ascending order; migrations within a hop preserve declared list order (plugin author encodes dependencies via list position).

Out-of-window filtering: migrations whose `from_version` falls outside `[from_version, current_version)` are silently dropped. Covers two real cases:

  • behind-window migrations for completed hops (e.g. kept for re-migrate/audit)
  • staged forward migrations while `current_version` hasn't caught up yet

Test plan

  • 13 new tests in `test_migration_planner.py`: happy path (single/multi-hop, ordering preservation), trivial cases (at-current, v1-baseline), error cases (downgrade, `from < 1`), out-of-window filtering (before/after window)
  • `libs/kt-config`: 221 pass
  • `ruff check`/`format` clean, pyright green
  • pre-commit + pre-push lefthook green

🤖 Generated with Claude Code

Pure function walking a GraphTypePlugin's declared migrations and
returning the ordered list that advances from_version to
plugin.current_version. No Hatchet, no DB, no side effects —
consumed by the Phase 7 graph_migration_wf, which dispatches one
migration at a time and persists audit rows between hops.

Deliberately under-specified on execution concerns:
- does NOT check that migrations are runnable
- does NOT check if a migration was already applied
- does NOT enforce downgrade policy beyond rejecting them
Those belong to the workflow; the planner only answers "what
migrations, in what order, does the plugin declare for this walk?"

Error cases:
- from_version < 1 raises (v1 is the baseline)
- from_version > plugin.current_version raises (downgrades are
  unsupported; framework is forward-only by the to_version ==
  from_version + 1 invariant)
- from_version == current returns [] (startup auto-dispatch's
  "no migration needed" signal)

Migrations within a hop preserve declared order (plugin author
encodes dependency via list position). Out-of-window migrations
are silently filtered — a plugin may ship a staged v3 → v4 behind
a still-at-v3 current_version.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@charlie83Gs charlie83Gs merged commit 9ac44ab into main Apr 20, 2026
27 checks passed
@charlie83Gs charlie83Gs deleted the feat/graph-migration-planner branch April 20, 2026 18:07
@github-actions
Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.

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