Skip to content

feat(carve): read-only Terraform peelability advisor (#214) - #993

Merged
lex00 merged 3 commits into
mainfrom
feat/terraform-carve-advisor
Jul 22, 2026
Merged

lex00 merged 3 commits into
mainfrom
feat/terraform-carve-advisor

Conversation

@lex00

@lex00 lex00 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Implements #214 — the read-only Terraform carve-out advisor, the committed/day-one slice of the strangler-fig design (#197). chant carve advise --from <tf-dir> ranks which Terraform resources are cheap to carve into native chant and which should stay. Read-only: emits nothing, patches nothing, touches no live resource.

Why now

Both #214 and #197 were refreshed against the current repo (see the ticket comments): the substrate they assumed as future machinery has largely shipped (live import, graph --live + edge reconstruction, diff --live --json, orphan classification, tier metadata), so the advisor is a smaller build than the ticket estimated. The carve advise surface is its own command (not folded into the single-file migrate seam), per that refresh.

What's here (maps to the ticket's T1–T5)

  • T1 terraform/: pure hcl2json-tree → dependency graph with inbound/outbound edge classification.
  • T3 peelability scoring (the design: strangler-fig carve-out from Terraform (observe-first, incremental) (DEFERRED) #197 model verbatim) + a curated TF-type → native-spec tier map, with S3-family sub-resource folding so an inlined _versioning isn't counted as boundary work.
  • T4 chant carve advise: banded human report + --json + --report <path>.
  • T2 opt-in --state <tfstate> overlays state-expanded instance counts for accurate count/for_each fan-out scoring.
  • T5 CLI docs page, a runnable sample-estate fixture with an e2e test pinning the doc's scores.

Notes / deviations

  • @cdktf/hcl2json (HashiCorp's own parser, wasm) is not a chant dependency — dev-only here, lazy-loaded, with a one-line install hint if absent. Only carve-out users pay for it.
  • No formal MCP "carve skill": core has no skills loader (they're lexicon-scoped), so the advisor points at the install instead. A core skills mechanism would be separate work.
  • The tier map is a curated seed. Unknown types score 0 (leave in Terraform) — the safe default; the advisor never claims a resource is carvable when it can't map it.
  • The emit / boundary-bridging / apply phases stay in design: strangler-fig carve-out from Terraform (observe-first, incremental) (DEFERRED) #197, gated on demand. This PR is analysis only.

Verification

  • 26 new tests; full 584-test CLI+terraform suite green.
  • Core tsc --noEmit clean, eslint clean.
  • Verified end-to-end through the real CLI (text + --json).

Closes #214.

lex00 added 3 commits July 21, 2026 21:49
`chant carve advise --from <tf-dir>` ranks which Terraform resources/modules
are cheap to carve into native chant and which should stay. Read-only: emits
nothing, patches nothing, touches no live resource.

- terraform/: pure hcl2json-tree -> dependency graph (inbound/outbound edges),
  peelability scoring (the #197 model), and a curated TF-type -> native tier
  map with S3-family sub-resource folding.
- @cdktf/hcl2json is NOT a core dependency (dev-only here); it is lazy-loaded
  and, if absent, the command fails with an install hint.
- carve advise command: banded human report + --json + --report <path>.

PR 1 of 3 (T1/T3/T4). .tfstate read (T2) and docs/skill (T5) follow.
`--state <tfstate>` overlays state-expanded instance counts onto the graph, so
a count/for_each fan-out is scored with its real instance count (the
-3*(instances-1) penalty) instead of assuming 1. JSON-only, no HCL/wasm.

Root-module managed resources only; data sources and module-nested resources
are skipped (the .tf graph models a module as one node). Pure-.tf path is
unchanged when --state is omitted.

PR 2 of 3.
…214 T5)

- docs/cli/carve.mdx: synopsis, scoring model, bands, a real banded example
  run against the bundled sample estate, and the on-demand parser install.
- __fixtures__/sample-estate: a runnable mixed estate (clean leaves, boundary
  work, load-bearing, unsupported) + an e2e test pinning the doc's scores.
- tier map: add the common network leaves (subnet, security_group,
  route_table, internet_gateway) surfaced by the fixture.
- drop references to a formal "carve skill": core has no skills loader, so the
  advisor points at the one-line install instead.

PR 3 of 3.
@lex00
lex00 merged commit c16169a into main Jul 22, 2026
6 checks passed
@lex00
lex00 deleted the feat/terraform-carve-advisor branch August 3, 2026 19:21
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.

feat: Terraform peelability advisor (read-only carve-out scoring) (DEFERRED)

1 participant