Skip to content

Op waves plan and apply through chant's capabilities, so terragucci and plywood both apply through chant #4545

Closed

Description

@lex00

terragucci runs tf-apply on chant's op waves, and the result works well for Terraform and OpenTofu users today. chant decides each wave's gate, records the pending fact and spends the approval. The engine calls themselves still happen in terragucci: the wave spec's planWave and applyWave hooks call back into terragucci's own process over a local socket, and terragucci plans and applies there.

Evidence (terragucci 4b9ba61, chant 930cb99):

  • terragucci/packages/terragucci/src/chant-waves.ts:8-12: the spec's planWave, applyWave and hooks call back into the job's own process, so the planning stays terragucci's.
  • terragucci/packages/terragucci/src/chant-waves.ts:94-95: planWave: input.call("plan", ...) and applyWave: input.call("apply", ...).
  • terragucci/packages/terragucci/src/apply.ts:1539-1564: the plan call runs planRoots or planUnits (:1981, :3843), and the apply call runs the job's own j.apply (:2136, :4132).
  • chant core already plans wave components through the capability registry (planWaveComponent in packages/core/src/components/wave-plan.ts), and terraform-apply is a chant capability.

Ruling (maintainer, 2026-10-27, ruling 1 on INTENTIUS/plywood#1): the engine runs the same way for every product. The apply lives in chant, through the pulumi lexicon's apply capability (#4541) for Pulumi and plunge, and through chant for terragucci's waves too. Neither product holds apply capability. This is the #4530 rule.

plywood needs this because its up waves would otherwise copy terragucci's callbacks and run pulumi up inside the product. With the engine call in chant, terragucci and plywood apply through one path, and each product only switches it on in its own words.

Missing:

  1. An op wave that plans and applies its runs through the capability registry (terraform-apply now, the pulumi capability from Pulumi and plunge stacks as components that plan and apply, so plywood can run them #4541 next), with no planWave or applyWave call back into the product.
  2. A home in chant, or in a hook that runs no engine, for the other calls terragucci's callbacks serve today (WaveCall in chant-waves.ts:39: hold, gate, migrate-check, migrate), plus Terragrunt unit discovery, share jobs, and the apply outcomes stood-down, held and replan (apply.ts:1579).
  3. terragucci moved onto it, with its plan and apply callbacks removed.

Acceptance:

Related: INTENTIUS/terragucci#1280 (the audit lists chant-waves.ts as a candidate), #4530, #4541, INTENTIUS/plywood#1.

Activity

  1. lex00 commented on Oct 27, 2026

    @lex00
    ContributorAuthor

    From the chant-consumption audit (finding 1) and two new maintainer rulings on INTENTIUS/plywood#1:

    • Ruling F: terragucci and plywood share chant CI features as far as possible, even when chant CI has to grow for it.
    • Ruling G: Terraform- or Pulumi-specific capability lives in chant's terraform or pulumi lexicon, not in the product.

    terragucci's callbacks do more than plan and apply. Before they can go, each piece needs a chant home:

    Callback piece (terragucci 83fac46) Home
    cone plans (src/apply.ts:797) terraform lexicon, as an option on terraform-apply
    lock-timeout args terraform lexicon
    Atmos reads (src/apply.ts:781-792) terraform lexicon
    root steps before and after plan and apply (src/apply.ts:793, :826-845) core: op-wave stage hooks already exist (packages/core/src/op/op-waves.ts, #3762); run them around the capability step
    policy and cost holds core: a wave hold that any product switches on, with the policy and cost engines as lexicon or product presets
    hold, gate, migrate-check, migrate calls (src/chant-waves.ts:39) core gate ledger, see #4551 for the gated request

    Other runs of the binary outside waves also belong in the terraform lexicon: ephemeral copies (src/ephemeral.ts:406, :810, :950), state migrations (src/migrate.ts:612) and the state-lock release (src/unlock.ts:269, :303).

    Related: #4530, INTENTIUS/terragucci#1280, #4550, #4551.

  2. added
    epic:ci-products
    epic:plywood
    on Oct 27, 2026
  3. lex00 commented on Oct 27, 2026

    @lex00
    ContributorAuthor

    Built on integration/ci-products, merge 45a43d0 (unit branch unit/cp-chant-4545, commit 0bbb3ad), on the rulings of #4550 (apply on merge on op waves through capabilities), #4551 (one run record per chant run wave job) and #4553 (moved 4, held 5, denied 7).

    Core (packages/core/src/op/)

    • op-waves-capability.ts (new). An op-waves spec takes step, { kind, ...input } as a component's deploy step, in place of plan and apply. Each string of the input gets {target}, {op} and {wave} per run, and a run's new input field is laid over it. The deciding job, and each share or group job for its slice, plans every run with capability.plan in its own process. planDigest is the member digest, empty and destructive come from the change-set part, and a member with holes and no artifact fails the plan with the holes' reasons. The apply is capability.run with the plan's artifact in ctx.plans. A run refused with planMoved is listed under moved and the job exits 4; any other error fails the run. The runs' parts compose into the wave's change-set document, which the pending fact cites through CI products: gate, approval, apply and run records go on the workspace ledger through chant, not product git writes #4551's storeChangeSet. Each run's plan file at {plan} carries the digest, the member, the artifact and the part, so perRun hooks read the plan.
    • The step contract for CI products: one chant PR pipeline that takes the product's words for statuses, comments and gates #4550: a generated spec sets step and nothing else changes in the job (chant run wave --spec <file> --wave <k> [--decide | --share i | --group g]). runOpWave takes capabilities for a product that runs chant in process (ruling C); otherwise the registry is the project's (fanOutRegistry), loaded once per job behind a dynamic import so wave-runtime.mjs stays without the config loader. A spec with a step therefore needs the full chant install or a product bin passing capabilities.
    • assertOpWavesSpec refuses step beside plan, apply, planWave or applyWave, with discover, and with hooks.apply.runBy: "apply".
    • The wave hold any product switches on: holds, read at base with the policy (readOpWavePolicy, holdsAtBase). policy: true runs ci.policy from the declaration at base (prLoopPolicyAt and runPrPolicy, packages/core/src/components/pr-policy.ts:71, :151) over each run's change-set part, and marks runs denied or held exactly as a plan file's denials and holds do, so overrides, heldBy and exit 7 are the existing paths. A policy that cannot run fails the wave. cost: { command, approveAbove, format?, currency? } prices each changing run ({target}, {plan}, {planJson}), reads infracost's JSON or { "monthlyDelta" }, and sums the wave. Over approveAbove, or with a run it could not price, the wave waits whatever its gate. The sum is a digest member, (monthly cost), and --record-plans adds the same member to the head's digest. A policy hold set at base or in the change holds; a cost hold at base wins over the change's. Command plan files may now carry changeSet so holds.policy works without a step.

    terraform lexicon (lexicons/terraform/src/)

    • terraform-apply takes lockTimeout (default 5m, false for none). plan and apply pass -lock-timeout unless TF_CLI_ARGS or TF_CLI_ARGS_<command> already sets one (lock-timeout.ts, from terragucci's lockTimeoutArgs).
    • cone: a revision. A live choudoufu root other than an estate file plans with plan -cone=<base>; the cone's targets join the plan digest through conePlanDigest with terragucci's digest kind kept, so approvals recorded before the move still match. Such a root plans with plan, never as a one-root set (cone.ts, moved from terragucci's cone.ts). The activity gained cone and lockTimeout args and returns cone on the plan result.
    • reads: [{ var, root, output }]: vars read from another terraform.roots entry's outputs, Atmos's !terraform.state. Each upstream is read once and passed as -var under the step's own vars. An upstream with no such output yet makes the member a hole naming the upstream to apply first. atmosStateReads maps terragucci's edges file into this form (state-reads.ts).
    • Every plan writes its show -json beside the plan file and names it as artifact.planJson; cost-hold.ts exports terraformCostHold({ approveAbove }), the infracost preset over it.

    Docs: guide/op-waves (two new sections and two refreshed line citations), the terraform lexicon's ops page (step inputs table), and a changelog entry, since -lock-timeout=5m now reaches every terraform-apply run. Prose lint has no regressions; docs citations pass.

    Tests: packages/core/src/op/op-waves-capability.test.ts and lexicons/terraform/src/op-wave-step.test.ts. Only npm ci, scripts/ci-lexicon-artifacts.sh --steps generate,bundle and scripts/typecheck.ts ran (no regressions). The suites wait for epic-ready, and no box is ticked.

    Still missing

    Open question
    A. Where does the 5m lock wait apply?

    • (a) Every terraform-apply run (fan-out, pr-apply, promote and op waves), with lockTimeout: false to turn it off. (recommended) One behaviour for the capability, and a lock wait never changes a plan, only how long a run waits for a lock.
    • (b) Only when an op wave's step sets lockTimeout, with no flag by default.
      I built (a).
  4. lex00 commented on Oct 27, 2026

    @lex00
    ContributorAuthor

    Lock wait: option (a), the recommended one, as built. The 5m lock wait applies to every terraform-apply run (fan-out, pr-apply, promote and op waves), with lockTimeout: false to turn it off; the changelog records the change.

  5. lex00 commented on Oct 28, 2026

    @lex00
    ContributorAuthor

    Epic-ready fix, merged into integration/ci-products at 653e81e (unit commit 8a8cf89).

    planRoot writes the plan document at join(planned.dir, ...), and the terraformPlan fake in lexicons/terraform/src/components/capability-plugin.test.ts returned no dir, so most plan tests threw on an undefined path. The fake now returns dir as the real TerraformPlanResult does. No code change.

  6. lex00 commented on Oct 28, 2026

    @lex00
    ContributorAuthor

    Epic-ready fix, merged into integration/ci-products at 9f00e0b (unit/cp-chant-fix-bundles).

    op/op-waves.ts imported op/op-waves-capability.ts for opWaveStepProblems and opWaveHoldsProblems. That module also loads fan-out-support (config loader, zod, component discovery, esbuild) and pr-policy (declaration, picomatch, ajv), so the stage-hooks, gated-waves and gate-decision bundles went red once the release-port edge (#4615) was cut.

    The step and holds shapes and checks (OpWaveStep, OpWaveHolds, OpWaveCostHold, OP_WAVE_COST_FORMATS, OP_WAVE_COST_MEMBER, opWaveStepProblems, opWaveHoldsProblems, opWaveHoldsAt) moved to packages/core/src/op/op-waves-capability-spec.ts, which imports one type. op-waves-capability.ts re-exports all of them, so no importer changed. op-waves.ts now imports the spec file. The bundle lists name it.

  7. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

    Close-out (2026-10-29)

    On main: 45a43d0 (op waves plan and apply through the capability registry with a step, policy and cost holds, terraform-apply lockTimeout, cone and reads), 2c4690e (product pipeline), 653e81e and 9f00e0b (epic-ready fixes). The pulumi-up capability registers under the same contract (b6b425e), so box 2 is ticked.

    Left unticked: box 1. terragucci main runs plain-root tf-apply waves through wavesStepSpec and chant's terraform-apply step, but Terragrunt, numeric-wave and grouped waves still use the planWave and applyWave callbacks (packages/terragucci/src/chant-waves.ts, apply.ts stepWaveReasons). Box 3 mixes terragucci's wave tests with its recorded wave runs, so it is left as is.

    Remaining: terragucci moving Terragrunt and grouped waves onto the step (terragucci#1282) and removing the plan and apply callbacks.

  8. lex00 commented on Nov 2, 2026

    @lex00
    ContributorAuthor

    Closing per the close-out comment of 2026-10-29 above: the work is on main and released.

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

    epic:ci-productsepic:plywood

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions