Skip to content

chant graph --live --overlay ignores build params, so a tier lens is dead under the overlay #1483

Closed

Description

@lex00

chant graph honours a build parameter supplied by environment variable. chant graph --live --overlay does not — it returns the graph for the parameter's default whatever the environment says.

That makes an env-var-driven axis (a tier, a size, a profile) work in the declared view and go flat the moment the live overlay is turned on, which is the view anyone actually operating an estate is looking at.

Reproduction

kubemicrovm-ops declares tier as a build param with env: "KMV_TIER" and a default of minimal. minimal declares a bare MicroVM; prod-ha declares a MicroVMReplicaSet, a MicroVMClass and a MicroVMNetwork instead — a different resource set, not different values.

Same shell, same estate, chant 0.38.0:

tier=minimal  flags=<none>                       nodes=11
tier=prod-ha  flags=<none>                       nodes=13     <- honoured
tier=minimal  flags=--env dev --live --overlay   nodes=11
tier=prod-ha  flags=--env dev --live --overlay   nodes=11     <- ignored

The overlay run at prod-ha returns minimal's Kubernetes resources:

KubeMicroVM::MicroVMImage, Core::Namespace, KubeMicroVM::MicroVM, Core::Namespace

where the non-overlay run at the same tier returns

KubeMicroVM::MicroVMImage, KubeMicroVM::MicroVMNetwork, Core::Namespace,
KubeMicroVM::MicroVMReplicaSet, KubeMicroVM::MicroVMClass, Core::Namespace

Exact commands:

export AWS_ENDPOINT_URL=http://localhost:4566 AWS_REGION=us-east-1
KMV_TIER=prod-ha npx chant graph src --detail 3 --format ir
KMV_TIER=prod-ha npx chant graph src --detail 3 --env dev --live --overlay --format ir

Why it matters beyond one repo

The overlay compares declared source against live. If the declared half is built at the wrong parameter, the comparison is against an estate nobody deployed — so every resource the real tier declares and the default does not reads as absent, and every resource the default declares and the real tier does not reads as pending. The colouring is confidently wrong rather than missing.

Concretely here: a live prod-ha estate that has fully converged (image SUCCESSFUL, connector ACTIVE, readyReplicas 2/2) overlays as four un-observed Kubernetes resources, because it is being compared against minimal's declarations.

behold surfaces this directly — its tier picker (.behold.json's tiers.envVar) sets the var on the spawned chant process, which is the documented mechanism and works for /api/graph. Under /api/overlay the picker stops doing anything. I traced it there first and it is not behold's: the two commands above reproduce it with behold uninvolved.

Adjacent

Under --live --overlay the IR is split across stdout and stderr — piping stdout alone yields truncated JSON intermittently. The non-overlay form does not do this. Probably the same code path and worth a look while it is open, though it is a separate defect.

Expected

--live --overlay builds the declared side with the same parameter resolution as a plain chant graph, so an env-var-supplied param reaches it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XsCknJvqegvVkB9WKUeBgG

Activity

  1. lex00 commented on Aug 4, 2026

    @lex00
    ContributorAuthor

    Traced it. The mechanism in the description is wrong, and the real one is narrower — correcting the record before anyone digs from the wrong end.

    Build params are not ignored under --live --overlay. The declared-overlay side resolves them correctly; [param] tier = "prod-ha" (env) does print. What runs on defaults is the build the observation is scoped from.

    packages/core/src/cli/handlers/graph.ts:147:

    const buildResult = await build(resolve(args.src ?? config.sourceDir ?? "."), plugins.map((p) => p.serializer));

    No params, where the non-live path 380 lines down does pass them:

    const buildParams = await graphBuildParams(ctx, projectPath);
    if (!buildParams) return 1;
    const result = await discover(projectPath, { buildParams });

    buildResult is what tells observeResources which entities to look for, so the observation enumerates the default parameter's estate. The stderr ordering shows it plainly — at KMV_TIER=prod-ha the not-observed warnings name image, operatorNs, vm, workloadNs, which is minimal's entity set (vm, not replicaSet), and only afterwards does [param] tier = "prod-ha" (env) print from the declared pass.

    So the two halves of the overlay are built at different parameters. The symptom in the description stands; the cause is one call site, not parameter resolution.

    build() already forwards options.buildParams to discover, so the fix is to resolve them before that call and pass them through. Verified against kubemicrovm-ops with the patch applied to an installed 0.38:

    before   tier=minimal -> 11 nodes    tier=prod-ha -> 11 nodes
    after    tier=minimal -> 11 nodes    tier=prod-ha -> 13 nodes
                                         (+ MicroVMReplicaSet, MicroVMClass, MicroVMNetwork)
    

    PR incoming, with a regression test that fails without the change.

    One correction to the "Adjacent" note too: the split-stream output is not overlay-specific. [param] lines and warnings go to stderr by design (build-params-cli.ts:103), and the IR to stdout — my measurement harness was merging them. Nothing to fix there; disregard that paragraph.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01XsCknJvqegvVkB9WKUeBgG

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions