Skip to content

feat(terragucci): serve --terragucci draws an estate from its reports, locally and read-only (#490) - #494

Merged
lex00 merged 1 commit into
mainfrom
terragucci-serve-490
Oct 10, 2026
Merged

lex00 merged 1 commit into
mainfrom
terragucci-serve-490

Conversation

@lex00

@lex00 lex00 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Closes #490.

npx @intentius/behold serve . --terragucci <dir|s3://bucket/prefix|https://…> draws the checkout's roots and marks each card with what terragucci's newest runs found. The marks are dated, never a fill and never "live".

Done-when, item by item

  • Draws the declared roots, painted from the newest tf-plan and tf-drift report. index.json gives each run's path. Then behold makes one GET of report.json, only for the newest runs that hold each root (bounded at 12 runs per stage). No cloud read. On terragucci's example that is 5 report GETs.
  • Every mark shows its age and source run. A card corner shows ⚠ drift · 4h, ~ plan · 2h or ⏸ wave · 1h. The inspect pane says "drift found 06:04 UTC, 4h ago: deleted outside Terraform" with links to the report, job, PR and trace. Nothing sets _status, and a test asserts it.
  • A waiting wave is a gate card whose only action is the copyable line. That line is npx terragucci approve wave-<k> --plan <digest>, which is terragucci's own wording, bound to the set digest. There is no approve route, and the route test asserts one doesn't exist. Every behold write already refuses on a terragucci repo (Never in the way: behold refuses to apply a terragucci repo, export works, an empty workspace draws instead of crashing #489).
  • Counts and waiting waves come from estate.json when present. The tab quotes the estate page's own numbers and links estate.html. Without estate.json, it falls back to terragucci's rule over the index (projectState). behold's part is the resource graph.
  • Validates against terragucci's schemas when present, and refuses structurally otherwise. With @intentius/terragucci resolvable from the repo or beside behold, behold checks each document with ajv against the package's report, report-index and estate schemas. Without it, behold checks the schema id and the fields it reads. Refusals come back as 422 {code: "terragucci-report", error, remedy}.
  • A test and a local e2e against terragucci's example reports.
    • example-terragucci-reports/ is a bucket for terragucci's own example. It was written by terragucci's buildReport / uploadReport / buildEstate at cb2381d2; the script only supplies the plans. All 9 JSON documents validate against the schemas in 0.4.4 and on main. Its README lists the runs.
    • Unit and route tests read it: src/terragucci-{reports,overlay,route}.test.ts and web/terragucci.test.js.
    • e2e/terragucci-e2e.sh (just e2e-terragucci) serves a copy of terragucci's example/ with the built CLI and the real Terraform read. It asserts 15 roots, the 4 flagged cards, every change placed, the waiting wave's line, the sandboxed report page, and the write refusals. It passes locally both without @intentius/terragucci ("structural") and with 0.4.4 installed ("schema"). Without the lexicon or TERRAGUCCI it skips, so CI is unaffected.

Notes

  • S3 reads go through the operator's aws s3 cp <key> -. It needs GetObject only, never a list call, and behold ships no SDK and holds no credentials.
  • Report pages open through GET /api/terragucci/file, which reads them from the same source, so links work for a private bucket. Keys are relative paths with a report file's extension, and the page is served with content-security-policy: sandbox, so its scripts can't reach behold's routes.
  • ajv becomes a declared dependency (it was already in the tree through chant) and stays external to the bundle.
  • --terragucci-project picks a project when a bucket holds several and none is the checkout's git remote.

Tests

  • tsc and build are clean.
  • vitest: 2304 passed, 1 failed. The failure is events.test.ts > watchSources, the real-fs.watch timing test, which also fails 1 run in 3 on a clean copy of main on this machine.

🤖 Generated with Claude Code

…, locally and read-only (#490)

`behold serve . --terragucci <dir|s3://bucket/prefix|https://…>` draws the
checkout's Terraform roots and marks each card with what terragucci's
newest runs found. index.json gives each run's directory; one GET of a
run's report.json follows, only for the newest tf-plan, tf-drift and
tf-apply runs that hold each root. No cloud is read and nothing writes
_status: every mark is dated by its run ("drift found 06:04 UTC, 4h ago")
and links its report, job, pull request and trace.

- src/terragucci-source.ts: a directory, s3:// through the operator's own
  `aws s3 cp <key> -` (GetObject only, no SDK, no credentials held), or an
  https address serving the bucket.
- src/terragucci-reports.ts: the reads. Each document is checked against
  terragucci's JSON Schemas when @intentius/terragucci resolves (ajv,
  draft 2020-12), structurally otherwise; refusals are
  `code: "terragucci-report"` with a remedy. Waiting waves and counts come
  from estate.json when the source has one, else terragucci's own rule
  over the index.
- src/terragucci-overlay.ts: root path to attrs.root, instance address to
  block path. Changes no card is, and reported roots the checkout lacks,
  are listed, never dropped.
- src/terragucci-view.ts: GET /api/terragucci (the marks, roots, waiting
  waves, estate counts) and GET /api/terragucci/file (a report file from
  the same source, sandboxed). No approve route.
- web/terragucci.js and app.js: a corner glyph and age on each flagged
  card, the marks with links in the inspect pane, and a Terragucci tab:
  a legend that says "not live", terragucci's estate counts linking
  estate.html, each waiting wave as a gate card whose only action is
  copying `npx terragucci approve wave-<k> --plan <digest>`, and every
  root's newest drift, plan and apply ("no report" kept apart from "no
  changes").

example-terragucci-reports/ is a bucket for terragucci's own example
estate, written by terragucci's buildReport, uploadReport and buildEstate
at cb2381d2 (scripts/terragucci-example-reports.ts supplies only the
plans), and valid against @intentius/terragucci 0.4.4's schemas. The
tests read it; e2e/terragucci-e2e.sh (`just e2e-terragucci`) serves a copy
of terragucci's example with it through the built CLI and the real
Terraform read.

ajv becomes a declared dependency (already in the tree through chant) and
stays outside the bundle.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@lex00
lex00 merged commit 5bca521 into main Oct 10, 2026
3 checks passed
@lex00
lex00 deleted the terragucci-serve-490 branch October 10, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

behold serve --terragucci: draw a terragucci estate from its reports, locally, read-only

1 participant