Skip to content

Day-2 action buttons on an app card, with the gate card and the action history #1037

Closed

Description

@lex00

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

Day-2 actions from behold: an app card lists the actions its template offers, a button asks terragucci to run one, and the card's history shows each request, its approval and how it ended. behold approves nothing here; the approval is a person's, as for a wave.

Today

  • The terragucci timeline (GET /api/terragucci/timeline?root=, src/terragucci-timeline.ts) reads audit.jsonl and the inspect pane filters it to a card's root (web/terragucci-timeline.js:3).
  • The lifecycle read (GET /api/terragucci/lifecycle) lists wave gates with their states and approve lines; it reads _gates/tf-apply.jsonl only.
  • behold never approves on a terragucci repo; the remedy names npx terragucci approve ... (AGENTS.md "Invariant").

To build

  • The app card's inspect pane lists the template's actions (from template.yml, through /api/templates/apps), one button each, labelled with the action's name.
  • POST /api/templates/action {root, address} dispatches terragucci's action workflow with those inputs (GitHub through gh, Forgejo through its dispatch API), allowlisted on a terragucci repo, and follows the run.
  • /api/terragucci/lifecycle reads _gates/tf-action.jsonl and _gates/tf-action/applied.jsonl too, so a pending action shows as a gate card with state waiting and its approve line (terragucci approve action <root> --plan <digest>), then applied with the result.
  • The card's history reads the timeline's action-requested and action entries for the root: who asked, who approved, the digest, ok or failed, and the run link.

Done when (build, checked in CI)

  • With a fixture template.yml naming action.aws_lambda_invoke.rotate, the orders inspect pane shows one button rotate; clicking it runs gh workflow run terragucci-action.yml -f root=apps/orders -f address=action.aws_lambda_invoke.rotate (spawn spy).
  • POST /api/templates/action with an address not listed in the template answers 422 {code: "unknown-action"} and starts nothing.
  • A fixture chant/lifecycle with a pending tf-action fact makes /api/terragucci/lifecycle list a gate {op: "tf-action", state: "waiting", command: "npx terragucci approve action apps/orders --plan sha256:..."}; with an applied and finished line it lists state: "applied" and applied.result: "ok".
  • web/terragucci-timeline.test.js: an action entry renders as "rotate on apps/orders, approved by , ok" with its run link.
  • src/terragucci-repo.test.ts passes with the action route allowlisted; with --public the route answers 405.
  • docs/src/content/docs/using/templates.mdx describes the buttons, the gate card and the history; npm test and npm run typecheck pass.

Done when (run, recorded on the harness)

  • tg-behold-action (terragucci harness, claim behold/action-button). Plain arm: base apps/orders with the rotate action applied; out-of-band stack/harness/check.sh behold-action apps/orders action.aws_lambda_invoke.rotate (exit 0), outcome ledger: {op: "tf-action", status: "gated", count: 1}; out-of-band stack/harness/check.sh chant-approve tf-action ... as the second identity; out-of-band the resume job, outcome ledger: {op: "tf-action", status: "ok", count: 1}; out-of-band stack/harness/check.sh behold-history apps/orders action asserting one action entry with result: ok (exit 0). BREAK arm: overlays/break approves as the requester's identity, the request stays gated, and the ok outcome does not hold (caught). not run: emulator runs dropped by maintainer ruling 2026-10-28

Depends on: #1036 (apps on the graph); INTENTIUS/terragucci#1310 (day-2 actions).

Tracker: INTENTIUS/chant#4642

Activity

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

    @lex00
    ContributorAuthor

    Landed on integration/self-service as merge 7fd1ec0384340d0d0048e8648bd889055c19c1e0 (unit commit 1d600ce on unit/ss-behold-1037), on top of #1036's merge, built on the published chant 0.124.54.

    What landed

    • POST /api/templates/action {root, address} in src/templates.ts.
      • It reads the apps again. A root no app has answers 422 not-an-app. An address the root's actions (terragucci#1309) does not list answers 422 unknown-action with the offered addresses. Neither starts anything.
      • Ruling E: a root on OpenTofu or choudoufu answers 422 action-engine, naming the engine and where behold read it. The sources, in order, are terragucci.yml's binary, .opentofu-version/.terraform-version, and .tofu files in the root, the way terragucci detects it but without the PATH check. /api/project carries terragucciActionRefusal, so the pane keeps the buttons, switched off, with the refusal beside them.
      • It dispatches terragucci-action.yml with exactly root and address through Apps on the graph: an app and its add-ons in one frame, with drift, add-on and upgrade buttons #1036's shared dispatch-and-follow helper: gh workflow run terragucci-action.yml -f root=apps/orders -f address=module.app.action.aws_lambda_invoke.rotate on GitHub, the dispatch API on Forgejo. An action opens no pull request, so the helper now takes the branch as optional and looks for none. 409 no-action-workflow when the workflow is not committed. 409 terragucci-too-old when it takes neither input. GitLab answers 422 request-forge with npx terragucci action <root> <address>.
      • It is on TERRAGUCCI_ALLOWED_WRITES and refuses on its own off a terragucci repo with templates, like the request and the upgrade. The non-allowlisted route walker still answers 409 for every other write. --public answers 405.
    • src/terragucci-lifecycle.ts: terragucci's lane spec gains actions. The read takes _gates/tf-action.jsonl and _gates/tf-action/applied.jsonl into a separate actions list on /api/terragucci/lifecycle, so wave-shaped code is untouched. Each entry is {op: "tf-action", gate: "<root>:<address>", root, address, name, requester, state, digest, command}. It is decided by chant's gate-decision under the mode the request records, else the mode at base. The requester's own approval is left out and listed under uncounted with the reason. While waiting, command is npx terragucci approve action <root> --plan <digest>. Once applied and finished, applied.result is ok or failed, taken from the finished line's detail.result, with exit.
    • Audit: audit.schema.json is re-vendored from terragucci integration at c5e88fc5. AUDIT_KINDS and the kinds fixture gain action-requested and action, plus the three kinds that were unowned: unrecorded-write, agent-run and request. An entry's detail.root now counts as its root.
    • Web:
      • appButtons gives one button per action, labelled with its name. renderAppSection draws the root's action gate cards (Copy only) and its action history. web/terragucci-timeline.js words an action as rotate on apps/orders, approved by dana, ok and links its run (<repo>/actions/runs/<run_id>, from the ledger commit URL).
      • The Terragucci tab's lane draws the action cards after the waves. The card DOM is now one exported gateCardElement.
    • AGENTS.md: the Invariant and the exceptions name the action dispatch.
    • Docs: the draft page using/templates.mdx has a "Day-2 actions" section. It also notes the issue or PR comment form (chant#4654 ruling).

    Tests

    • npx vitest run src/templates.test.ts: 36 passed (7 new). src/terragucci-repo.test.ts: 30 passed. src/terragucci-lifecycle.test.ts: 41 passed (3 new). src/terragucci-timeline.test.ts: 15 passed. web/terragucci-timeline.test.js: 7 (2 new). web/terragucci-lifecycle.test.js: 10 (2 new). web/template-apps.test.js: 10 (4 new).
    • npm test: 4971 passed, 26 skipped (340 files, 9 skipped). npm run tsc clean, npm run build passes, just check passes, node docs/scripts/lint-prompts.mjs passes.

    Build-level choices

    • The address is terragucci#1309's module address, module.app.action.aws_lambda_invoke.rotate, not the action.aws_lambda_invoke.rotate this issue's first check names. That check is ticked on the module address, which is what terragucci lists and dispatches.
    • Action gates are listed under actions, not gates, because a gate there is a wave. The third check is ticked on actions[0].
    • The docs item stays unticked. The docs went to the draft page because the feature needs an unreleased terragucci, and npm run typecheck does not exist (npm run tsc passes).
    • terragucci's stack/harness/check.sh is not touched. The run item needs behold-action <root> <address> (POST /api/templates/action; exit 0 on 202, nonzero on any refusal) and behold-history <root> action (GET /api/terragucci/timeline?root=; exit 0 when exactly one action entry for the root has result: ok). chant-approve exists already.
    • Pulumi actions (plywood#39) are not covered: behold has no plywood repo detection, stacks read or plywood lane today.
  3. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

    Build choice (2026-10-28): Pulumi actions on a plywood repo are not part of this unit (its build items are terragucci's). They are filed as behold#1038; until then Pulumi actions run from plywood action and the /plywood action comment.

  4. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

    The terragucci harness side of the run item landed on terragucci integration/self-service in merge b37f7eeb2a8794bffe78026dcef15898cca64df4 (branch unit/ss-terragucci-harness): stack/harness/scenarios/tg-behold-action/scenario.json and the helpers behold-action and behold-history in stack/harness/check.sh.

    • check.sh behold-action <root> <address>: POST /api/templates/action with {root, address}; exits 0 only on 202.
    • check.sh behold-history <root> <kind>: waits for the repo's runs to settle, then runs terragucci audit (in the tofu CI image on the stack's network) into s3://terragucci-reports/hs-<id>/audit.jsonl in floci, the record the scheduled audit job writes. It then starts behold with that record as its --terragucci directory, with --terragucci-project taken from the record, and reads GET /api/terragucci/timeline?root=<root>. It exits 0 when exactly one <kind> entry for the root has result: ok.
    • check.sh chant-approve approves as the author under BREAK=1 when the scenario's overlays/break holds an approve-as file saying author.
    • Base: apps/orders is an app made from the fixture template acme/app/aws 1.0.0, on Terraform. The catalog lists its aws_lambda_invoke.rotate action, so the apps read offers module.app.action.aws_lambda_invoke.rotate. Terraform takes a module download's location only from the X-Terraform-Get header, so this scenario's modules come from the stack's new template-registry service (profile templates, stack/harness/template-registry.mjs). That service answers from the repo's own files on Forgejo.
    • Plain arm (expected pass): the base push applies orders's function; check.sh behold-action apps/orders module.app.action.aws_lambda_invoke.rotate (exit 0); check.sh settle with outcome gated: {op: "tf-action", status: "gated", count: 1}; check.sh chant-approve tf-action apps/orders:module.app.action.aws_lambda_invoke.rotate as the reviewer; check.sh rerun terragucci-resume.yml with gated: {op: "tf-action", status: "ok", count: 1}; check.sh behold-history apps/orders action (exit 0).
    • BREAK arm (expected caught): the author, who asked, approves. That approval does not count, the request stays gated, and the resume step's gated ok outcome does not hold.
    • Run: BEHOLD="node <behold checkout>/bin/behold.js" npx tsx stack/harness/harness.ts run tg-behold-action

    The issue's ledger outcomes are chant#4650's gated outcome: a gated request writes no op-run record. terragucci's harness.ts now passes the driver the gated requests it reads, which tg-action-run needs too. The address is the module address, as the merge comment above says. Not checked without a run: the exact shape of the action entries in behold's timeline (kind: "action", result: "ok", roots holding the root), and whether terragucci audit needs more than --bucket here.

    How the behold helpers work: each one clones main of the scenario repo and starts behold serve on that clone. This checkout's terragucci comes first on PATH, FORGEJO_TOKEN is the author's token and FORGEJO_URL is the stack's Forgejo. The helper makes the same call a person's browser makes (same-origin, JSON), prints the answer and stops behold. BEHOLD names the behold command, for example BEHOLD="node <behold checkout>/bin/behold.js" on a build of behold's integration/self-service. Without it the helpers use behold from PATH. Under BREAK=1 the scenario's overlays/break is copied over the clone first. behold_up, behold_call and behold_checkout in stack/harness/check.sh are the shared pieces, so a new helper is one more case arm.

    The scenarios read the fixture module registry stack/harness/fixtures/templates/, which runs on the local Forgejo and floci only (details on terragucci#1308). The issue's plan, approve and apply steps are terragucci out-of-band checks here (pr-run, review, main-runs) because terragucci writes no chant pr-report. Before a run: just stack-up forgejo, just images and just build-cli in terragucci. harness.ts run exits 0 when the row holds. Nothing was run on the stack, and no run item is ticked. In terragucci at b37f7eeb2a8794bffe78026dcef15898cca64df4, npx tsx stack/harness/harness.ts lint reports 16 of 16 hold, and just check-unit, just lint-docs and npx tsc --noEmit -p tsconfig.json pass.

  5. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

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

    Built: integration merge 7fd1ec0.

    On main: e3cfbee (push CI green: ci 40791621907, docs 40791621919).

    Left: the docs item (draft page using/templates.mdx) and the run item tg-behold-action. Pulumi actions on a plywood repo are filed as #1038.

    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.

  6. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

    Close-out (2026-10-28)

    behold: chant 0.124.58 bump merged to main at 1b8a812. The template-request feature-detect is now a static import and the TS2322 in src/component-status.test.ts is fixed. CI green: ci 40818247582, docs 40818247650. The using/templates guide is published, so the docs item is ticked. Run items are struck: the maintainer dropped the emulator harness runs on 2026-10-28, so they were not run.

  7. lex00 commented on Oct 29, 2026

    @lex00
    ContributorAuthor

    Docs item now names using/templates.mdx, where the content shipped (behold main 1b8a812).

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

    enhancementepic:self-serviceproduct-pipelines

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions