Skip to content

feat(terraform): TerraformWatchOp, describeResources() over terraform show -json, and the GitHub cron watch (#2087) - #2099

Merged
lex00 merged 2 commits into
mainfrom
feat/2087-terraform-observe
Sep 6, 2026
Merged

lex00 merged 2 commits into
mainfrom
feat/2087-terraform-observe

Conversation

@lex00

@lex00 lex00 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #2087.

The observe position for the terraform lexicon. TerraformWatchOp (Init, Plan with -detailed-exitcode, Drift search attribute, optional Report) returns { op, schedule? }; issue and pull-request modes hand the -no-color plan text to reconcilePr as a caller-supplied body, and a test proves no plan JSON can reach it. describeResources() reads terraform show -json per declared root and keys rows the way buildRoots() does; a root whose init or show fails reports every declared entity as not-observed with read-failed, never absent. Ownership is the state file: a resource in state is owned, a declared block the state has no row for is unknown (and withheld as filtered under --owned), and the observation page says so with a link to the lifecycle-models third axis. ownershipChannel is declared and the observation conformance suite runs with it. A scheduled-watch example generates the GitHub cron workflow through generateOpsPipeline, asserted for the cron, workflow_dispatch, the concurrency group, issues: write, and the terraform install line.

Two decisions to note. reconcilePr gains an optional body, used verbatim and suppressing the chant lifecycle plan derivation; its pull-request mode still regenerates chant TypeScript, which is not a terraform answer, so issue is the mode with an end-to-end story today and the composite's doc says so (HCL regeneration is #2089). The schedule is built with core's createResource("Temporal::Schedule", ...) rather than importing the temporal lexicon, since no lexicon imports another at runtime and a project installing terraform alone must still load it.

Acceptance

  • src/composites/terraform-watch-op.ts returns { op, schedule? }; a test pins phases, the Drift outcome attribute, and that omitting schedule returns no schedule.
  • report, issue and pull-request each produce the expected step wiring; report opens nothing.
  • A test asserts the issue/PR body is the -no-color plan text and that no plan JSON reaches it.
  • src/describe-resources.ts maps values.root_module.resources[] addresses to buildRoots() keys, pinned by a recorded show -json fixture.
  • A failed init or show yields not-observed with reason read-failed for every declared entity of that root, never absent.
  • Everything in state reports owned, a resource found outside state reports unknown, both tested.
  • ownershipChannel declared on the plugin and passed to the conformance suite.
  • describeObservationConformance runs green with at least one present, one not-observed and one ownership scenario.
  • An example directory with a scheduled watch Op plus a test asserting the generateOpsPipeline YAML: cron, workflow_dispatch, concurrency group, issues: write, the terraform install line.
  • The lexicon doc page states the state-file ownership position and links concepts/lifecycle-models.

Gates: vitest on lexicons/terraform, lexicons/temporal and packages/core/src/op (982 passed), tsc --noEmit clean, repo-wide typecheck no regressions, check-lexicons.ts 18 of 18 at 23/23, prose ratchet and diataxis check clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JFvsuJmNqWXGUzzhJgb2oe

lex00 and others added 2 commits September 5, 2026 19:46
…how -json

The observe position for the terraform lexicon (#2087).

TerraformWatchOp inits, plans with -detailed-exitcode, and reports the
result as a Drift search attribute. Its issue and pull-request modes hand
the plan to the temporal lexicon's reconcilePr rather than growing a second
copy of the gh calls; that activity had no way to be handed a body, so
ReconcilePrArgs gains one field (body), used verbatim and suppressing the
change-set derivation. Only the -no-color render can reach it: the plan JSON
carries every attribute value the plan touches, and a test pins that no
reference to it exists anywhere in the Op.

describeResources runs init then show per configured root and matches
values.root_module.resources[] (child_modules included) against the
<root>/<address> keys buildRoots produces. The state file is the ownership
answer here: an address the state carries is owned, anything else is
unknown, which is why a declared module block reads present-but-unknown. A
failed init or show reports every entity of that root read-failed with the
root named, never absent.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFvsuJmNqWXGUzzhJgb2oe
…on docs page

examples/scheduled-watch is the recipe for a project with no Temporal: a
TerraformWatchOp on a cron, with findingMode "issue", plus the
generateOpsPipeline call that turns it into a GitHub Actions workflow.
examples.test.ts pins that workflow against the real generator and the real
Op discovery: the cron, workflow_dispatch, the per-Op concurrency group,
issues: write and nothing wider, and a pinned terraform release unzip
supplied through beforeScript, asserted to run before `chant run`.

docs/pages/observation.mdx is the reader's version of why terraform sits on
the trusted-state-file row of the third axis in concepts/lifecycle-models,
and the lexicons overview gains its runtime observation coverage row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JFvsuJmNqWXGUzzhJgb2oe
@lex00 lex00 added enhancement New feature or request area:lifecycle plan/diff/apply/observe/drift/prune/search --live area:terraform Terraform lexicon labels Sep 6, 2026
@lex00
lex00 merged commit 13c1d3f into main Sep 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:lifecycle plan/diff/apply/observe/drift/prune/search --live area:terraform Terraform lexicon enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terraform: observe — TerraformWatchOp, describeResources() over terraform show -json, and the GitHub cron watch

1 participant