Skip to content
CodArchthe living map of the architecture
ESEN

Migration plan to Rust (M4)

This document validates the migration lens on CodArch itself. The numbers come from codarch analyze . and change with the code; they are not a commitment, they are a snapshot for prioritising.

SignalValue
Files analysed211
TS/JS211 files · 33,621 rloc
Rust0
WASM/Node0
Bridges2
FFI edges0
Migration debt5,871

Debt is (maxComplexity + 1) × (1 + fanIn) per TS/JS file. It does not count lines: a large, trivial file weighs less than a complex one with many consumers. Test fixtures no longer enter: this repo’s .codarch.yml excludes them with ignore (ADR 0038), so the snapshot measures only production code.

DebtRLOCFile
357499packages/render/src/model.ts
210281packages/parsers/src/migration.ts
195682packages/metrics/src/diff.ts
185313packages/parsers/src/analyze-core.ts
132234apps/cli/src/commands/compare.ts
1262,588apps/web/src/App.tsx
117359packages/schema/src/legacy.ts
112732apps/mcp/src/store.ts
108237packages/parsers/src/graph.ts
105147packages/versions/src/index.ts
104256packages/addons/src/index.ts
102535apps/cli/src/commands/serve.ts
901,910apps/desktop/src/renderer/App.tsx
9095packages/metrics/src/report.ts
90124packages/parsers/src/walk.ts
  1. Pure contracts. schema/identity, schema/stats, schema/tree and the data structures. They are deterministic code, with no I/O or tree-sitter; the first Rust crate can be validated against the same fixtures and checksums.
  2. Graph and metrics. graph, diff, risk and rules. They are pure transformations over data; ideal for property tests and for comparing JSON byte by byte with the TS implementation.
  3. TS parser. parsers/walk, resolve and the tree-sitter parser. It is the riskiest phase: import resolution, grammars and metrics. Keeping a napi boundary with the current parser allows migrating file by file and comparing results.
  4. Render and adapters. The render can stay in TS or move to WASM; the CLI and MCP are thin adapters. They are not the priority: they change more and do not concentrate the debt.
  5. GitHub Action. YAML and render-comment.mjs; do not migrate. It consumes the published CLI.

The natural strategy is a Rust crate with a stable API exposed through napi, and TS adapters that replace module by module. Each replacement must compare snapshots and checksums of the same commit. The migration lens measures the progress: rust goes up, migrationDebt goes down, and ffiCrossings says how much new coupling the bridge introduces.

Ventana de terminal
npm run analyze -- .
npm run inspect -- .codarch/snapshot.cc.json --metric migrationDebt --top 15
npm run render -- .codarch/snapshot.cc.json -o .codarch/sitio
  • Rust is measured, not parsed: there are no Rust imports or complexity in v1.
  • napi edges are not observable without the generated glue; only the bridge is marked.
  • This repo’s test fixtures are excluded in .codarch.yml; they are not production debt.
  • Debt prioritises; it does not estimate weeks or people.