Skip to content

feat(cli): add migrate planning command#19

Merged
nucleuskit merged 4 commits into
mainfrom
feat/migrate
Jun 20, 2026
Merged

feat(cli): add migrate planning command#19
nucleuskit merged 4 commits into
mainfrom
feat/migrate

Conversation

@nucleuskit

Copy link
Copy Markdown
Owner

Summary

Adds nucleus migrate as a first-class CLI subcommand for version migration planning and readiness checks.

The command now follows the established CLI package shape used by report, scenario, and verify: root only wires the command, while cmd/nucleus/internal/migrate owns flags, execution, typed output, report writing, diagnostics, and tests.

Motivation / Why

The previous migrate logic was too thin for a large open-source project: it lived in root.go, returned an ad-hoc map, and produced a generic suggested-edit list that did not behave like the rest of the CLI.

This PR turns it into an auditable, contract-first migration planning command that can be consumed by humans and automation without mutating service code.

Affected Areas

  • cmd/nucleus/internal/migrate: new command package with command.go, run.go, output.go, paths.go, constants, package docs, and command tests.
  • cmd/nucleus/internal/root: thin command wiring plus root-level migrate wiring test.
  • docs/concepts/migrate-command.md: public command behavior and output contract docs.
  • contract submodule pointer: updated to a contract main commit that contains contract/schema/migrate.schema.json.

Behavior / Output Contract

  • Adds required inputs: --from-version and --to-version.
  • Adds command options consistent with sibling commands: --json, --pretty, --check, and --report.
  • Emits a stable JSON envelope:
    • result_kind: nucleus.migrate_result
    • schema_version: migrate.v1
    • schema_ref: contract/schema/migrate.schema.json
    • ok, mode, summary, diagnostics, and migration.
  • --check converts readiness failures into diagnostics and a non-zero exit path.
  • --report writes the same JSON envelope only when the target path resolves inside the service directory.
  • The command is report-only and does not rewrite service code, call provider SDKs, or contact a control plane.

Compatibility

This is additive CLI surface area. Existing commands and public Go APIs are not changed.

The migration rules intentionally remain CLI-internal for now. The PR does not add a public contract/migration package or expand contract module API surface.

Validation

  • rtk go test ./... from repository root: 121 passed in 17 packages.
  • rtk go test ./... from contract: 93 passed in 10 packages.
  • rtk go run ./cmd/nucleus migrate --dir example/hello-http --from-version v0.1.0 --to-version v0.2.0 --check --json --pretty: emitted ok: true with 6 checks and 0 diagnostics.
  • rtk go run ./cmd/nucleus verify --dir example/hello-http --json: 7/7 verification steps passed.

Review Notes / Residual Risks

  • The current rule table is conservative and supports known forward paths plus a generic forward checklist. Future version-specific transformations should remain explicit and tested.
  • migrate is intentionally not an auto-upgrader; service owners still apply edits through the normal describe -> plan -> gen -> lint -> verify loop.
  • Local workspace still contains unrelated dirty submodule state for bridge, cap, and core; these are excluded from the PR compare.

dependabot Bot and others added 4 commits June 20, 2026 16:03
- 在根命令中注册 migrate 子命令
- 实现迁移计划和检查功能
- 添加迁移结果的 JSON 输出格式
- 创建迁移相关的常量定义文件
- 实现迁移命令的输出渲染逻辑
- 添加报告路径解析和安全路径处理
- 实现迁移规则解析和执行逻辑
- 添加迁移命令的测试用例
- 创建迁移结果的 JSON Schema 定义
- 实现迁移 Schema 的有效性验证测试
- 在根命令中注册 migrate 子命令
- 实现迁移计划和检查功能
- 添加迁移结果的 JSON 输出格式
- 创建迁移相关的常量定义文件
- 实现迁移命令的输出渲染逻辑
- 添加报告路径解析和安全路径处理
- 实现迁移规则解析和执行逻辑
- 添加迁移命令的测试用例
- 创建迁移结果的 JSON Schema 定义
- 实现迁移 Schema 的有效性验证测试
@nucleuskit nucleuskit requested a review from spelens-gud June 20, 2026 08:12
@nucleuskit nucleuskit marked this pull request as ready for review June 20, 2026 08:13
@nucleuskit nucleuskit merged commit aa5fc1b into main Jun 20, 2026
4 checks passed
@nucleuskit nucleuskit deleted the feat/migrate branch June 20, 2026 08:13
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.

3 participants