Skip to content

multi-engine C6: Pulumi URN to graph node #4456

Closed

Description

@lex00

The mapping rule for Pulumi resources in the graph, change sets and drift records. Accepted when the stack-export render and the preview-based change set map the same resource to the same node.

Part of #4450.

Acceptance: read verdict lines and recorded artifacts, never exit codes alone. Anything that needs an emulator corpus, an estate run or a real cloud is run by the maintainer by hand. Red-first only for new guards.

Activity

  1. added
    multi-engine
    on Oct 25, 2026
  2. lex00 commented on Oct 25, 2026

    @lex00
    ContributorAuthor

    Merged into integration/pulumi-engine as b7a2b96 (unit branch unit/c6-pulumi-urn-node, commit fe818c9).

    What landed

    The rule lives in packages/core/src/pulumi-urn.ts, imported as @intentius/chant/pulumi-urn (core's ./* export). The node key is the URN without its stack and project, <qualified type>::<name> (for example aws:s3/bucket:Bucket::assets, my:web:Site$my:web:Cdn$aws:cloudfront/distribution:Distribution::site-cdn). Inside a workspace the id is <member>/<key>, the same as the terraform lexicon's <root>/<block key>. Provider resources (pulumi:providers:* at any depth, checked on the last type in the $ chain) and the root pulumi:pulumi:Stack get null, so a change-set entry or drift record for one ends up with node: null. Exports: parsePulumiUrn, pulumiNodeKey, pulumiNodeId, isPulumiNodeless, pulumiNodeCandidates({member, address}) (the same shape as changeSetNodeCandidates in change-set-graph.ts:108) and pulumiPreviewNodes(previewJson, member). Like change-set.ts, it has no runtime imports, so the change-set and drift-record bundles can include it.

    The stack-export render (lexicons/terraform/src/workspace-member.ts:86-88) now calls the rule instead of its local urnTail. Node ids are the same as before, with one change: the root stack node <member>/pulumi:pulumi:Stack::<name> is gone, and so are the parent edges that pointed at it. workspace-member.test.ts and the pulumi row in docs/.../reference/workspace-kinds.mdx are updated to match.

    The fixtures are in lexicons/terraform/src/testdata/pulumi-urn-node/: stack-export.json and preview.json of the same program. The program has a top-level bucket, a component with a component-scoped provider, a child policy, a nested component with a distribution that gets replaced (three steps on one URN), a create that isn't in the export yet, and a delete. lexicons/terraform/src/pulumi-urn-node.test.ts checks that every resource present in both files maps to the same node, that the three replace steps land on one node, that the new create maps to an id the graph doesn't hold, that providers and the stack map to nothing, and that the key ignores stack and project. The test was written but not run.

    Decision on the node id

    The recommendation was to nest ids by component name (<component name>/<child name>). I didn't do that. The id is a function of the URN alone, because:

    1. change-set mapping takes only {member, planner, address} (change-set-graph.ts:108);
    2. a drift record carries only the URN in address;
    3. a component's name isn't part of its children's URNs, and a --targeted preview or a delete step need not include the parents' records, so an id built from names could differ between the export and the change set.

    The parent type chain is still in the key through the qualified type. A child sits under its component in the graph through the parent edge, which the render already draws. This also kept every existing node id unchanged apart from the stack root.

    Still missing

    • The change-set planner value pulumi and its case in changeSetNodeCandidates are C3's (multi-engine C3: the pulumi lexicon #4453). The adapter should set address to the URN and return pulumiNodeCandidates(entry) there.
    • When C3 moves the member kind into lexicons/pulumi, workspace-member.ts, its two tests and both testdata directories move with it. pulumi-urn.ts stays in core.
    • The maintainer has to run the tests by hand: npx vitest run lexicons/terraform/src/pulumi-urn-node.test.ts lexicons/terraform/src/workspace-member.test.ts.
    • preview.json is hand-written from the documented pulumi preview --json shape (steps[].op/urn/oldState/newState), not recorded from a real run.

    Compile check: npx tsc --noEmit -p packages/core is clean. npx tsc --noEmit -p lexicons/terraform only reports TS6059/TS6307 rootDir errors for core files this change doesn't touch (yaml.ts, which-chant). With --rootDir . it's clean.

  3. lex00 commented on Oct 25, 2026

    @lex00
    ContributorAuthor

    Path 2 of the multi-engine engine tier is on main: plunge d6db28acdf, chant 867a12c, behold 9f7066ee (merge commits of integration/pulumi-engine, trees identical to the tested tips; path 1 was already on main). Acceptance met at epic-ready: pulumi-urn-node.test.ts passes (the stack-export render and the preview-based change set map each resource to the same node).

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

    multi-engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions