Skip to content

build: fold provenance — record which composite parameter produced which emitted field #2161

Closed

Description

@lex00

Sub-issue 2 of #2159.

A composite is the one lossy thing chant emits. It takes a few typed arguments and expands to several resources, so when reconcile regenerates source from live it produces flat typed resources and the composite is gone from the diff. That is the partial-view problem landing on chant's record, and it is why reconcile is deferred for stock Terraform in #2089.

chant can do what no other generator can here, because its evaluated subset is restricted on purpose. The fold already walks the program to a value and the EVL rules already decide what is foldable (packages/core/src/lint/engine.ts, examples/fold-differential.test.ts). The same pass can record where each emitted field came from.

Record, per emitted property path, one of three origins: a composite and the parameter path that flowed into it, a literal the composite fixes, or the author's own declaration. Store it beside the build output rather than inside it, since it must never reach the apply-bound document, the way effect receipts are withheld today. A field whose origin cannot be determined records that it could not, rather than guessing; an unknown origin is a legal answer and consumers must handle it.

Then use it in the return leg. Given a drifted field on a declared path (#2160 having already ruled out the undeclared ones), reconcile resolves three ways. Traced to a composite parameter, propose changing that parameter: a one-line diff, with the composite intact. Traced to a literal the composite fixes, refuse by name, saying which composite fixes the field and that the choice is to parameterize it or stop using the composite there. Origin unknown, fall back to today's behaviour and say that is what happened.

Scope this to the provenance itself plus the reconcile classification. Actually rewriting a parameter in the user's source is a source-edit problem (the generator half of chant import), and it can be a follow-up: this issue may propose the change as a described action without performing the edit, as long as the description names the file, the composite call, and the parameter.

Blocked on #2160. Parallel with #2162.

Acceptance

  • The build records emitted-path to origin (composite parameter, composite literal, direct declaration, or unknown) for every emitted field, and the record never enters the apply-bound output.
  • A fixture with a composite proves all four origin kinds, including one field the composite fixes and one it parameterizes.
  • Reconcile classifies a drifted field by origin and, for a parameter, names the file, the composite call and the parameter path.
  • A field the composite fixes produces a named refusal, not a flattened resource in the diff.
  • An unknown origin falls back to today's behaviour and says so.
  • The composites authoring page describes what provenance a composite gives up when it hardcodes a field.

Activity

  1. added
    enhancement
    area:core
    area:lifecycle
    on Sep 6, 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:corearea:lifecycleenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions