Run terragucci 0.4: plan notes carry the plan's diff, and an estate's version is honoured in a templated sandbox #3

Merged
lex00 merged 1 commit from lex00/sluice:terragucci-040 into main 2026-10-08 08:03:39 +00:00
Collaborator

terragucci 0.4.0 is on npm. It puts the plan's diff in the plan note: each group's diff and each root's whole plan, cut to the forge's comment limit, with links to report.html and plan.txt. This PR moves sluice to it and fixes a bug that kept an estate's own terragucci version from reaching its sandbox.

What changes

Defaults:

  • TERRAGUCCI_VERSION defaults to 0.4 (src/config.ts), and estates.terragucci_version defaults to 0.4 (src/db/schema.ts).
  • scripts/sandbox-bootstrap.sh installs 0.4.0 when it gets no version argument.
  • Migration drizzle/0002_terragucci_04.sql was generated with bun run db:generate, then I added one data statement to it. It sets the column default and moves estates on the old default "0.3" to "0.4". 0.4.0 reads every 0.3 terragucci.yml unchanged, so those estates get plan diffs without anyone touching them. An exact pin such as "0.3.1" stays where it is.

The version is now honoured:

  • Before this PR, buildDeps created MoorRunner with no terragucciVersion, and the executor's StartInput had no version either. As a result every cold sandbox got the bootstrap script's default (0.3.1), whatever the estate said. Now StartInput carries estate.terragucciVersion, and MoorRunner falls back to config TERRAGUCCI_VERSION when a run doesn't name one.
  • bootstrap() used to check only command -v terragucci, so a sandbox from a template with an older terragucci would never be upgraded. It now reads the installed version (from the global package.json, the same file the script reads) and runs the bootstrap with the requested version when terragucci is missing or doesn't match. A request for "0.4" accepts any 0.4.x, and "0.4.0" accepts only 0.4.0. The script applies the same rule, so it does nothing on a sandbox that already matches.

Tests

bun test: 380 pass, 3 skip, 0 fail. bun run typecheck is clean.

New tests in test/moor-runner.test.ts:

  • a sandbox without terragucci is bootstrapped with the run's version
  • a template whose terragucci matches skips the bootstrap
  • a template with 0.3.1 is bootstrapped to the estate's version (and an exact pin is installed even when the minor matches)
  • the runner's default is used when the run names no version
  • unit cases for terragucciSatisfies

test/executor.test.ts checks that the estate's version reaches runner.start. I also checked the migration by hand on PGlite: estates on 0.3 and on the column default move to 0.4, 0.3.1 stays.

Deploy

  • The migration runs at boot. No env var is needed, unless TERRAGUCCI_VERSION is set in sluice-secrets, in which case it overrides the new default.
  • No template rebuild is needed for correctness: every run installs the estate's version if its sandbox lacks it. moor-tpl-sluice (built in moor's scripts/build-templates.ts from this script) bakes 0.4.0 the next time it is built.

An admin can already set an estate's terragucci version to 0.4 on the estate's settings page in the console. Before this PR, though, that value didn't reach the sandbox, which installed the script's default. After this PR it does.

terragucci 0.4.0 is on npm. It puts the plan's diff in the plan note: each group's diff and each root's whole plan, cut to the forge's comment limit, with links to report.html and plan.txt. This PR moves sluice to it and fixes a bug that kept an estate's own terragucci version from reaching its sandbox. ## What changes Defaults: - `TERRAGUCCI_VERSION` defaults to `0.4` (`src/config.ts`), and `estates.terragucci_version` defaults to `0.4` (`src/db/schema.ts`). - `scripts/sandbox-bootstrap.sh` installs `0.4.0` when it gets no version argument. - Migration `drizzle/0002_terragucci_04.sql` was generated with `bun run db:generate`, then I added one data statement to it. It sets the column default and moves estates on the old default `"0.3"` to `"0.4"`. 0.4.0 reads every 0.3 `terragucci.yml` unchanged, so those estates get plan diffs without anyone touching them. An exact pin such as `"0.3.1"` stays where it is. The version is now honoured: - Before this PR, `buildDeps` created `MoorRunner` with no `terragucciVersion`, and the executor's `StartInput` had no version either. As a result every cold sandbox got the bootstrap script's default (0.3.1), whatever the estate said. Now `StartInput` carries `estate.terragucciVersion`, and `MoorRunner` falls back to config `TERRAGUCCI_VERSION` when a run doesn't name one. - `bootstrap()` used to check only `command -v terragucci`, so a sandbox from a template with an older terragucci would never be upgraded. It now reads the installed version (from the global package.json, the same file the script reads) and runs the bootstrap with the requested version when terragucci is missing or doesn't match. A request for `"0.4"` accepts any 0.4.x, and `"0.4.0"` accepts only 0.4.0. The script applies the same rule, so it does nothing on a sandbox that already matches. ## Tests `bun test`: 380 pass, 3 skip, 0 fail. `bun run typecheck` is clean. New tests in `test/moor-runner.test.ts`: - a sandbox without terragucci is bootstrapped with the run's version - a template whose terragucci matches skips the bootstrap - a template with 0.3.1 is bootstrapped to the estate's version (and an exact pin is installed even when the minor matches) - the runner's default is used when the run names no version - unit cases for `terragucciSatisfies` `test/executor.test.ts` checks that the estate's version reaches `runner.start`. I also checked the migration by hand on PGlite: estates on `0.3` and on the column default move to `0.4`, `0.3.1` stays. ## Deploy - The migration runs at boot. No env var is needed, unless `TERRAGUCCI_VERSION` is set in `sluice-secrets`, in which case it overrides the new default. - No template rebuild is needed for correctness: every run installs the estate's version if its sandbox lacks it. `moor-tpl-sluice` (built in moor's `scripts/build-templates.ts` from this script) bakes 0.4.0 the next time it is built. An admin can already set an estate's terragucci version to `0.4` on the estate's settings page in the console. Before this PR, though, that value didn't reach the sandbox, which installed the script's default. After this PR it does.
Run terragucci 0.4, and honour an estate's terragucci version in a templated sandbox
All checks were successful
test / test (pull_request) Successful in 3m58s
95475b611c
terragucci 0.4.0 puts the plan's diff in the plan note. The defaults move to it:
TERRAGUCCI_VERSION and the estates.terragucci_version default are "0.4", and
sandbox-bootstrap.sh installs 0.4.0 when it is handed no version. Migration 0002
sets the new column default and moves estates on the old default "0.3" to "0.4"
(0.4.0 reads every 0.3 terragucci.yml unchanged); an exact pin like "0.3.1" stays.

The estate's version never reached the sandbox: deps built MoorRunner without a
version and the executor's start input had none, so every cold sandbox got the
script's default. StartInput now carries the estate's terragucci_version, and
MoorRunner falls back to config TERRAGUCCI_VERSION. bootstrap() probes the
installed version instead of only `command -v terragucci`, and bootstraps when
terragucci is missing or does not meet the request ("0.4" takes any 0.4.x,
"0.4.0" only that). The script applies the same rule, so it is a no-op on a
sandbox that already meets it.

Tests: missing terragucci bootstraps with the run's version; a template that
meets it skips; an older template is bootstrapped to the estate's version; the
runner default applies when a run names none; the executor passes the estate's
version to runner.start.
lex00 merged commit c9afe7da50 into main 2026-10-08 08:03:39 +00:00
Sign in to join this conversation.
No reviewers
No labels
terraform-plane
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jhgaylor/sluice!3
No description provided.