Skip to content

pulumi lexicon: a gated stack action, a command resource replaced on request #4654

Closed

Description

@lex00

Unit of #4642 (epic: self-service from templates). Paths at chant origin/main b1b9e44.

The Pulumi side of day-2 actions. Pulumi has no action block, so an action is a resource whose replacement is the operation: a command provider resource (command:local:Command, command:remote:Command) named by its URN. Running it is a preview and an update with --target <urn> --replace <urn>, under a gated request, recorded like the stack operations plywood already has (question F on the tracker; this unit builds option a).

Today

  • lexicons/pulumi/src/stack-ops.ts runs gated stack operations under op pulumi-stack-ops (PULUMI_STACK_OPS_OP at :87), each a GatedRequest, with requestGate imported at :60 and gatedStackExport at :240.
  • lexicons/pulumi/src/run.ts:341 already passes --target for each URN to an update, and :697 builds a preview with targets.
  • plywood calls these through packages/plywood/src/stack-ops.ts:86 in plywood (gatedStackExport, gatedStackCancel, gatedStackMove).

To build

  • gatedStackAction({ dir, stack, engine, urn, ... }) in lexicons/pulumi/src/stack-ops.ts:
    1. pulumi preview --json --target <urn> --replace <urn>; refuse (action-scope) unless the preview's steps are exactly one replace of urn (plus its own create and delete halves).
    2. The request (kind stack-action) binds the stack, the URN and the preview's digest; requestGate returns gated with no counting approval.
    3. With one: spend, pulumi up --yes --target <urn> --replace <urn>, finish with { result, exit, tail }.
  • The URN's type must be a command: resource type; any other type is refused (action-type) before a preview.
  • plunge stacks take the same path through the engine the stack names (engine option), as the other stack operations do.

Done when (build, checked in CI)

  • With an injected exec and ledger, the first call returns gated and the fake exec saw preview --json --target <urn> --replace <urn> and no up.
  • A preview fixture with a second resource replaced is refused action-scope, naming that URN, with no request recorded.
  • A URN of type aws:s3/bucket:Bucket is refused action-type before any exec call.
  • After a fake approval by a second principal, up --yes --target <urn> --replace <urn> runs once and applied and finished lines are written; a repeat returns spent.
  • npm run typecheck and npm test -- lexicons/pulumi/src/stack-ops pass.

Done when (run, recorded on the harness)

  • pw-action (plywood, claim action/gated-replace): plain arm: plywood action prod-us rotate exits 3 with a pending pulumi-stack-ops request, a second identity approves, the re-run exits 0 and the ledger shows {op: "pulumi-stack-ops", status: "ok", count: 1}. BREAK arm: the break overlay adds a second resource that depends on the command's output, so the preview replaces two resources and the run exits 1 with action-scope (caught at the exit outcome). not run: emulator runs dropped by maintainer ruling 2026-10-28

Tracker: #4642

Activity

  1. added
    enhancement
    area:lifecycle
    epic:self-service
    on Oct 28, 2026
  2. lex00 commented on Oct 28, 2026

    @lex00
    ContributorAuthor

    Build note for self-service (2026-10-28): this unit also carries the generator side plywood#39 needs: the /plywood action comment command and workflow_dispatch stack and action inputs. plywood writes no job YAML itself. It builds on the action word from #4653.

  3. lex00 commented on Oct 28, 2026

    @lex00
    ContributorAuthor

    Build note for self-service (2026-10-28): core's productPipelineJobs refuses a product word mapped onto action, because the pipeline has no job for it. This unit adds an opt-in actions: true to ProductPipelineOptions that counts action as answered by the product's own workflow. terragucci#1310 and plywood#39 pass it. The action command itself landed in packages/core/src/ci-product-words.ts with #4653 (merge 64ac529).

  4. lex00 commented on Oct 28, 2026

    @lex00
    ContributorAuthor

    Landed on integration/self-service in merge ddf94a1 (unit commit 926c3a1).

    What landed:

    • gatedStackAction({ dir, stack, urn, name?, engine?, anew?, ... }) in lexicons/pulumi/src/stack-ops.ts, exported from the lexicon root. A URN that does not parse or names another stack is refused action-urn, a non-command: type action-type, both before any engine call. Each call previews preview --json --target <urn> --replace <urn> --stack <s>; any changing step on another URN, or a step on the URN that is not part of its replacement, is refused action-scope (the error carries code and urns), with no request recorded. The request is kind stack-action, subject action:<stack>:<name> (the URN when no name is given), fields stack, urn, engine, preview (the changed-only preview digest) and name. After an approval by someone other than the requester: spend, up --yes --target <urn> --replace <urn> --stack <s>, finish. The finished line keeps applied | failed; detail carries result: ok | failed, exit, tail and urn. A repeat of an applied request answers spent unless anew. plunge stacks take the same two argv under plunge.
    • run.ts: the up form joins PULUMI_GATED_COMMANDS and PLUNGE_GATED_COMMANDS (same URN after --target and --replace, nothing else); PULUMI_APPLY_COMMANDS still refuses --replace. Builders pulumiActionPreviewArgs and pulumiActionUpArgs.
    • Build note 2: actions: true on ProductPipelineOptions counts action as answered by the product's own workflow and fills comments.action; no job is written.
    • Build note 1: actionJob on the pull request loop options (chant build --pr-loop --action-job, also accepted by productPipelineJobs, returned as action). On GitHub and Forgejo the workflow gets an action job, started by /<product> <action word> (writer association on GitHub) or by workflow_dispatch with inputs <noun> and action (so stack and action for plywood; names overridable through actionJob.inputs). It checks out the target branch's commit, holds the apply identity when one is set, and runs <bin> <action word> --from-event, with the comment and inputs in CHANT_ACTION_COMMENT, CHANT_ACTION_MEMBER, CHANT_ACTION. The verb reads them with productActionFromEnv(words, env) from @intentius/chant/ci-product, which applies the comment grammar's rules to both. Exit 3 (waiting) is a green job. A dispatch that names an action does not start the green apply. GitLab refuses --action-job by name. Feature-detect on PRODUCT_ACTIONS_FLOOR (NEXT_RELEASE).
    • Docs: lexicons/pulumi/README.md (gated stack operations), docs concepts/ci-products.mdx.

    Tests (unit tests inject the runner and an in-memory ledger; no engine runs):

    • CHANT_SKIP_ARTIFACT_CHECK=1 npx vitest run --project unit lexicons/pulumi/src/stack-ops lexicons/pulumi/src/run.test: 2 files, 74 tests passed.
    • CHANT_SKIP_ARTIFACT_CHECK=1 npx vitest run --project unit packages/core/src/components/product-actions packages/core/src/components/product-pipeline packages/core/src/components/pr-pipeline packages/core/src/ci-product-words packages/core/src/cli/parse-args lexicons/github/src/components/generate-pr-pipeline lexicons/forgejo/src/components/generate-pr-pipeline lexicons/gitlab/src/components: 52 files, 346 tests passed. New goldens: lexicons/github/src/components/golden/pr-loop-action.github.yml and lexicons/forgejo/src/components/golden/pr-loop-action.forgejo.yml.
    • npx tsc --noEmit -p for packages/core, lexicons/pulumi, lexicons/github, lexicons/gitlab: no errors in touched files (the rest is the fresh worktree's missing generated lexicons). Repo-wide npm run typecheck left to CI, so that box stays unticked.
    • npx eslint on every touched file: clean. npm run lint:docs-prose: no regressions. npm run lint:docs-citations: clean.

    Build-level choices:

    • Pre-ask refusals throw PulumiStackActionRefused (message starts with the code), as the other stack operations throw before asking; the outcome union is unchanged apart from the kind.
    • The digest bound is pulumiPreviewDigest(preview, { changedOnly: true }), so the stack's own same step does not move it.
    • plunge accepting up --target --replace without --plan is not checked here (plunge is outside the repos this unit reads). The harness run settles it.
    • The action job's command contract (--from-event plus the three variables) is for plywood#39 to implement in its action verb.
  5. lex00 commented on Oct 28, 2026

    @lex00
    ContributorAuthor

    Typecheck checked on integration/self-service at ddf94a1 with generated lexicon artifacts: npm run typecheck reports 26 baselined failures and no regressions; npx vitest run --project unit over pulumi stack-ops, run.test and core ci-product-words: 3 files, 84 tests pass. One wording note on the first build item: the first call's status is waiting, the word Pulumi stack operations already use, where the item says "gated"; the behaviour the item describes holds.

  6. lex00 commented on Oct 28, 2026

    @lex00
    ContributorAuthor

    Ruling for self-service (2026-10-28): Issue or PR (Recommended). Keep today's behaviour. The gate still needs a second approver, and behold can post the request on an issue for an app that has no open pull request.

  7. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

    Handoff (self-service-1, 2026-10-28).

    Built: integration/self-service merge ddf94a1. All build items ticked. Ruling (2026-10-28): an action comment is accepted on a plain issue or a pull request.

    Not on main yet. chant main moved while this epic ran (ci-products-1 cp6 a0c3037, cp7 4073bb3), and its cp8 is in flight. Next: once ci-products-1 has no chant merge or release in flight, merge origin/main into integration/self-service, rerun the suite one suite at a time, then merge to main with a merge commit and the tree check. integration/self-service was green at 4794d23 (unit 31847 pass, typecheck no regressions, docs prose and citations clean; see chant#4642).

    Left: the run item pw-action (plywood; bench prepared by plywood#44). Unverified until then: plunge accepting up --target --replace without --plan.

    Harness runs have not been made. They run on the emulator only (local Forgejo, floci on 127.0.0.1, wrapped in chant e2e safe-run --scan), one repo at a time, after ci-products-1's pw22 round, with the products built against chant's integration/self-service (or a chant release carrying chant#4650-4655). Commands and expected verdicts: engine-wt/goals/self-service-1-runs.md.

  8. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

    Close-out (2026-10-28)

    Merged to main at 8c18b27 (integration/self-service). CI green: chant 40814401598, docs 40814401604, chant-ci-green 40815002521. Released as chant 0.124.58 (publish run 40816550044), which carries chant#4650-4655. Run items are struck: the maintainer dropped the emulator harness runs on 2026-10-28, so they were not run.

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:lifecycleenhancementepic:self-service

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions