Skip to content

graph IR: terraform entities produce no edges — the references are ${...} strings collectEdges cannot see #2265

Closed

Description

@lex00

Filed from INTENTIUS/behold#378's research. chant graph --format ir over a project whose lexicon is terraform emits a complete, fully-attributed, module-descended node set and zero edges.

Observed

@intentius/chant-lexicon-terraform 0.59.0, pointed at waterpark's six real root modules through a chant.config.ts that names five directories and edits no .tf:

nodes 247   edges 0
kinds: Terraform::Variable 108, ::Output 53, ::Resource 43, ::Terraform 14,
       ::Locals 10, ::Data 8, ::Module 7, ::Provider 4
node: {"id": "prod/aws_s3_bucket.waterpark_artifacts",
       "kind": "Terraform::Resource", "lexicon": "terraform",
       "attrs": {"address": "aws_s3_bucket.waterpark_artifacts",
                 "file": "s3_bucket.waterpark_artifacts.tf", "root": "prod",
                 "body": {...}, "source": "resource \"aws_s3_bucket\" ...",
                 "line": 1, "mode": "state"}}

Served through behold unmodified, that graph draws 247 cards and prints behold's own note: "no edges — nothing in this estate references anything else". The claim is true of the IR and false of the estate.

Why

collectEdges (packages/core/src/graph-ir.ts) walks the projected config bag for AttrRef objects and intrinsic markers. A TerraformEntity's references live in props.body as hcl2json strings — "${aws_vpc.main.id}", "${module.baseline.boundary_arn}" — which are neither. So the walk finds nothing, correctly, and the IR has no edges.

The information is not missing: it is in body verbatim, and the same repo already parses it into a real graph on the other path. packages/core/src/terraform/graph.ts's buildGraph resolves references from the hcl2json expression AST via getReferencesInExpression, and carve advise --json publishes the resulting edge set (each edge twice, once per direction, with producer and consumer attribute names). That parse then drops the bodies, which is why it cannot be the renderer's source. Two parses of the same HCL, in one repo, with exactly complementary losses — the lexicon's own header notes it:

core's parseTerraformDir() is NOT reused: it returns carve's TfGraph, a scoring-and-excision shape with no room for the per-block bodies a serializer and the post-synth checks read.

Ask

Emit IREdges between terraform entities. Either resolve "${...}" references at IR build, or have the lexicon contribute edges (an edges contribution alongside buildRoots()), whichever fits the plugin contract better — the caller does not care which.

Worth deciding explicitly, since a renderer will show whatever is chosen:

  • Which reference forms become edges. resource, module, data, output; and whether var and local are edges or noise. waterpark's 247 nodes are 108 variables and 53 outputs, so this is the difference between a graph and a hairball.
  • depends_on, which is an explicit edge with no attribute.
  • count / for_each. The lexicon has one node per block, not per instance, so an edge is block-to-block. That is the honest shape for a declared read; worth saying so in the field rather than leaving it inferred.
  • Attribute naming. carve's boundary edges already carry producer and consumer attribute names, and behold renders viaAttr as an edge's tooltip. Same field would let one renderer read both.

Not asked for

Cross-root edges by value. waterpark's roots read each other by name through a data source (data "aws_iam_policy" "boundary" { name = var.boundary_name }), never through a reference — deliberately, so a satellite never reads central's state. Reference resolution will not and should not produce those; behold has a value-match pass for that shape and will own it (behold#378).

Why it matters

This is the one thing between chant and a complete Terraform estate picture. Everything else the renderer needs — bodies, module descent, data sources, file and line provenance — the lexicon already emits, through the exact command every chant consumer already runs.

🤖 Claude Code — https://claude.ai/code/session_0124XP1LJTZxgJRy7Dh1UfXt

Activity

  1. added
    enhancement
    area:terraform
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:terraformenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions