schedule: every 20m
strategy: greenfield
source-language: python
target-languages: [go]
target-metric: 1.0
metric_direction: higher
APM CLI: Python to Go -- Full Rewrite
Complete rewrite of the APM CLI from Python to Go. The Python implementation
stays in place for benchmarking and parity verification throughout the
migration. The Go version is built incrementally module-by-module, but the
end state is 100% Go with no Python in the shipping binary.
Source
- Language: Python 3.10+ (CPython)
- Runtime: CPython with Click CLI framework, Rich output, PyInstaller packaging
- Paths:
src/apm_cli/ -- all application code (302 files, ~25 modules)
tests/ -- unit, integration, acceptance, benchmark suites
- Key dependencies: click, rich, requests, pyyaml, gitpython, ruamel.yaml, watchdog
Target
- Languages: Go (latest stable)
- Runtime: Native binary (replaces PyInstaller onedir packaging)
- Paths:
cmd/apm/ -- CLI entry point
internal/ -- all internal packages (mirroring src/apm_cli modules)
pkg/ -- any public library APIs
- Bridge: None. Go binary fully replaces Python. Python kept only for
benchmark parity during migration.
Strategy
Greenfield -- the Go implementation is built in parallel alongside the existing
Python codebase. This is the right choice because:
- The Python version must stay runnable for benchmark parity testing throughout.
- No external consumers depend on Python internals (only CLI surface matters).
- The end state is a clean Go codebase, not a Python/Go hybrid.
Milestone ordering
Milestone 0 -- Go test/benchmark harness (MUST complete before any code migration):
Build a Go-based test and benchmark harness that exercises the existing Python
CLI binary. This harness must achieve 100% behavioral coverage of the Python
implementation. It becomes the parity oracle for all subsequent milestones.
- Acceptance tests calling the Python binary via subprocess
- Benchmark suite capturing latency and resource baselines for every command
- Parity check framework: run identical inputs against Python and Go, diff outputs
Milestone 1 -- Build scaffolding:
go.mod, go.sum, toolchain setup
- CI integration (go test, go build in existing workflows)
- Binary packaging parity with PyInstaller output
Milestone 2+ -- Module-by-module migration (suggested order):
utils/, constants, config -- foundational, no external deps
models/, primitives/ -- data structures
deps/ -- dependency resolution
cache/ -- HTTP/git caching
core/ -- auth, target detection, orchestration
install/ -- install pipeline and phases
commands/ -- CLI command handlers (cobra replacing click)
integration/ -- file integrators
compilation/ -- compilation pipeline
runtime/ -- runtime adapters
policy/, security/ -- policy engine
marketplace/, registry/ -- marketplace and registry
bundle/, output/ -- packing and output
cli.py entry point -- final wiring
Each milestone: port module, pass parity tests, pass benchmarks >= Python baseline.
Verification
cd cmd/apm && go test -json ./... | go run .crane/scripts/score.go
The scoring script will output JSON:
{
"migration_score": 0.0,
"progress": 0.0,
"parity_passing": 0,
"parity_total": 302,
"source_tests_passing": 247,
"target_tests_passing": 0,
"perf_ratio": 1.0
}
migration_score = (parity_passing / parity_total) * correctness_gate
where correctness_gate is 1.0 if all target tests pass, 0.0 otherwise.
Out of scope
src/apm_cli/ -- Crane must NOT modify the Python source (kept for benchmarking)
tests/ -- existing Python test suite (kept as-is for parity reference)
docs/ -- documentation updates happen after migration completes
build/apm.spec -- PyInstaller spec (kept for Python benchmark builds)
.apm/ -- APM primitives (language-agnostic, no migration needed)
packages/ -- downstream packages
templates/ -- project templates
schedule: every 20m
strategy: greenfield
source-language: python
target-languages: [go]
target-metric: 1.0
metric_direction: higher
APM CLI: Python to Go -- Full Rewrite
Complete rewrite of the APM CLI from Python to Go. The Python implementation
stays in place for benchmarking and parity verification throughout the
migration. The Go version is built incrementally module-by-module, but the
end state is 100% Go with no Python in the shipping binary.
Source
src/apm_cli/-- all application code (302 files, ~25 modules)tests/-- unit, integration, acceptance, benchmark suitesTarget
cmd/apm/-- CLI entry pointinternal/-- all internal packages (mirroring src/apm_cli modules)pkg/-- any public library APIsbenchmark parity during migration.
Strategy
Greenfield -- the Go implementation is built in parallel alongside the existing
Python codebase. This is the right choice because:
Milestone ordering
Milestone 0 -- Go test/benchmark harness (MUST complete before any code migration):
Build a Go-based test and benchmark harness that exercises the existing Python
CLI binary. This harness must achieve 100% behavioral coverage of the Python
implementation. It becomes the parity oracle for all subsequent milestones.
Milestone 1 -- Build scaffolding:
go.mod,go.sum, toolchain setupMilestone 2+ -- Module-by-module migration (suggested order):
utils/,constants,config-- foundational, no external depsmodels/,primitives/-- data structuresdeps/-- dependency resolutioncache/-- HTTP/git cachingcore/-- auth, target detection, orchestrationinstall/-- install pipeline and phasescommands/-- CLI command handlers (cobra replacing click)integration/-- file integratorscompilation/-- compilation pipelineruntime/-- runtime adapterspolicy/,security/-- policy enginemarketplace/,registry/-- marketplace and registrybundle/,output/-- packing and outputcli.pyentry point -- final wiringEach milestone: port module, pass parity tests, pass benchmarks >= Python baseline.
Verification
The scoring script will output JSON:
{ "migration_score": 0.0, "progress": 0.0, "parity_passing": 0, "parity_total": 302, "source_tests_passing": 247, "target_tests_passing": 0, "perf_ratio": 1.0 }migration_score = (parity_passing / parity_total) * correctness_gatewhere
correctness_gateis 1.0 if all target tests pass, 0.0 otherwise.Out of scope
src/apm_cli/-- Crane must NOT modify the Python source (kept for benchmarking)tests/-- existing Python test suite (kept as-is for parity reference)docs/-- documentation updates happen after migration completesbuild/apm.spec-- PyInstaller spec (kept for Python benchmark builds).apm/-- APM primitives (language-agnostic, no migration needed)packages/-- downstream packagestemplates/-- project templates