Add a loam runner and make it sluice's runner #13

Merged
jhgaylor merged 2 commits from loam-runner into main 2026-10-12 06:46:30 +00:00
Owner

moor and every sandpitd are being retired (home-cloud #226). sluice runs every stage in a moor sandbox, so it needs another substrate before then. This gives it a loam runner instead of shutting it down. sluice's Runner interface (start, exec, putFile, getFile, destroy, health) maps one-to-one onto loam's public API.

What changes

  • src/runner/loam.ts: LoamRunner, selected by RUNNER=loam, sitting next to MoorRunner. It uses POST /v1/sandboxes (image by digest, resources, sluice/* labels, idle.action: none, a delete deadline in place of moor's TTL), exec/run (bash -c, as sprite, up to 3600 s), fs/file (as sprite, mkdir, mode), DELETE, and whoami for health. A 409 on the run's sandbox name deletes the leftover sandbox and creates it again. A 503 capacity requeues the run through the existing isCapacity.
  • The executor and the stage plans are unchanged. The loam sandbox has the same sprite user and /home/sprite/.sluice layout that moor sandboxes had. Secrets still go in as files, and stages still run detached and get polled (stream.ts). The path constants move from moor.ts to types.ts, and the bootstrap-script loader moves to bootstrap.ts.
  • images/sandbox/Dockerfile is FROM ghcr.io/arugula-salad/loam-guest@sha256:a0a0513e… (the base template's digest from loam's deploy/k8s/templates.json on main). It adds the sprite user and runs scripts/sandbox-bootstrap.sh at build time: terraform 1.14.0, tofu 1.13.1, node 22, choudoufu, terragucci, chant and hcl2json, all pinned and checksummed. I built it locally and it works: terragucci 0.3.1, node v22.23.3.
  • .forgejo/workflows/sandbox-image.yml builds that image to ghcr.io/arugula-salad/sluice-sandbox, because loam only accepts images by digest from that registry. The tag is the tree hash of its inputs, so the image is rebuilt only when they change. The workflow pins the digest into k8s/deployment.yaml as LOAM_IMAGE.
  • When there's no image yet (LOAM_IMAGE empty), the runner uses loam's base template, creates sprite as root and cold-bootstraps. That's slower, but it works. The bootstrap script now removes a different node major's bundled npm before installing node 22, since loam-guest ships node 24.
  • k8s/deployment.yaml: RUNNER=loam, plus LOAM_API_URL and LOAM_IMAGE. The MOOR_* values stay, so setting RUNNER=moor rolls back while moor still runs.
  • Config: production now accepts RUNNER=loam with LOAM_TOKEN. estates.runner gains loam; the column is text, so no migration is needed.
  • Docs: docs/OPERATIONS.md has a new section, "The runner: loam", covering setup, the switch, how to verify it, rollback and the cleanup once moor is gone. SPEC, ARCHITECTURE and README are updated to match.
  • Tests: test/loam-runner.test.ts runs against an in-process fake loam: create body, prepare/bootstrap, buffered and detached exec, files, the 409 path, capacity, connection retries and timeouts. The production-config test covers loam. test/setup.ts now strips SECRETS_KEY, so a local .env no longer fails that test. bun test: 376 pass, 0 fail.

Why not loam's brokered secrets

The clone token is minted per run, and the cloud credentials are web-identity token files that the SDKs send in request bodies. A project-wide secret injected into request heads can carry neither. Both stay as files, as they were on moor.

Before merging (merging is the switch)

  1. loam project sluice with key sluice-runner, created by loam's admin. Its secret goes into Infisical (project sluice → prod) as LOAM_TOKEN.
  2. Forgejo Actions secret GHCR_TOKEN on jhgaylor/sluice: a GitHub token with write:packages on arugula-salad. loam's nodes must be able to pull ghcr.io/arugula-salad/sluice-sandbox, either with the org ghcr credential or by making the package public (it holds nothing secret). Without this secret, runs still work through the cold-bootstrap fallback, just slowly.
  3. Merge while the console shows nothing running. Then follow "Switch" in OPERATIONS.md: a plan on terragucci-hello-world, then one on sluice-kubernetes-hello, which proves a loam sandbox can reach k8s.inevitable.fyi through the hairpin.

This must land, and be verified, before moor's sandpitd stops (home-cloud #226). After that there's no rollback.

🤖 Generated with Claude Code

moor and every sandpitd are being retired (home-cloud #226). sluice runs every stage in a moor sandbox, so it needs another substrate before then. This gives it a loam runner instead of shutting it down. sluice's `Runner` interface (`start`, `exec`, `putFile`, `getFile`, `destroy`, `health`) maps one-to-one onto loam's public API. ## What changes - **`src/runner/loam.ts`: `LoamRunner`**, selected by `RUNNER=loam`, sitting next to `MoorRunner`. It uses `POST /v1/sandboxes` (image by digest, resources, `sluice/*` labels, `idle.action: none`, a delete `deadline` in place of moor's TTL), `exec/run` (`bash -c`, as `sprite`, up to 3600 s), `fs/file` (as `sprite`, `mkdir`, `mode`), `DELETE`, and `whoami` for health. A 409 on the run's sandbox name deletes the leftover sandbox and creates it again. A 503 `capacity` requeues the run through the existing `isCapacity`. - **The executor and the stage plans are unchanged.** The loam sandbox has the same `sprite` user and `/home/sprite/.sluice` layout that moor sandboxes had. Secrets still go in as files, and stages still run detached and get polled (`stream.ts`). The path constants move from `moor.ts` to `types.ts`, and the bootstrap-script loader moves to `bootstrap.ts`. - **`images/sandbox/Dockerfile`** is `FROM ghcr.io/arugula-salad/loam-guest@sha256:a0a0513e…` (the `base` template's digest from loam's `deploy/k8s/templates.json` on main). It adds the `sprite` user and runs `scripts/sandbox-bootstrap.sh` at build time: terraform 1.14.0, tofu 1.13.1, node 22, choudoufu, terragucci, chant and hcl2json, all pinned and checksummed. I built it locally and it works: terragucci 0.3.1, node v22.23.3. - **`.forgejo/workflows/sandbox-image.yml`** builds that image to `ghcr.io/arugula-salad/sluice-sandbox`, because loam only accepts images by digest from that registry. The tag is the tree hash of its inputs, so the image is rebuilt only when they change. The workflow pins the digest into `k8s/deployment.yaml` as `LOAM_IMAGE`. - **When there's no image yet** (`LOAM_IMAGE` empty), the runner uses loam's `base` template, creates `sprite` as root and cold-bootstraps. That's slower, but it works. The bootstrap script now removes a different node major's bundled npm before installing node 22, since loam-guest ships node 24. - **`k8s/deployment.yaml`: `RUNNER=loam`**, plus `LOAM_API_URL` and `LOAM_IMAGE`. The `MOOR_*` values stay, so setting `RUNNER=moor` rolls back while moor still runs. - **Config:** production now accepts `RUNNER=loam` with `LOAM_TOKEN`. `estates.runner` gains `loam`; the column is text, so no migration is needed. - **Docs:** `docs/OPERATIONS.md` has a new section, "The runner: loam", covering setup, the switch, how to verify it, rollback and the cleanup once moor is gone. SPEC, ARCHITECTURE and README are updated to match. - **Tests:** `test/loam-runner.test.ts` runs against an in-process fake loam: create body, prepare/bootstrap, buffered and detached exec, files, the 409 path, capacity, connection retries and timeouts. The production-config test covers loam. `test/setup.ts` now strips `SECRETS_KEY`, so a local `.env` no longer fails that test. `bun test`: 376 pass, 0 fail. ## Why not loam's brokered secrets The clone token is minted per run, and the cloud credentials are web-identity token files that the SDKs send in request bodies. A project-wide secret injected into request heads can carry neither. Both stay as files, as they were on moor. ## Before merging (merging is the switch) 1. loam project `sluice` with key `sluice-runner`, created by loam's admin. Its secret goes into Infisical (project sluice → prod) as `LOAM_TOKEN`. 2. Forgejo Actions secret `GHCR_TOKEN` on `jhgaylor/sluice`: a GitHub token with `write:packages` on arugula-salad. loam's nodes must be able to pull `ghcr.io/arugula-salad/sluice-sandbox`, either with the org ghcr credential or by making the package public (it holds nothing secret). Without this secret, runs still work through the cold-bootstrap fallback, just slowly. 3. Merge while the console shows nothing running. Then follow "Switch" in OPERATIONS.md: a plan on `terragucci-hello-world`, then one on `sluice-kubernetes-hello`, which proves a loam sandbox can reach `k8s.inevitable.fyi` through the hairpin. **This must land, and be verified, before moor's sandpitd stops (home-cloud #226).** After that there's no rollback. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add a loam runner and make it sluice's runner
Some checks failed
test / test (pull_request) Has been cancelled
6cf57b4b69
moor and every sandpitd are being retired (home-cloud #226), and sluice
runs every stage in a moor sandbox on fireball. sluice's Runner interface
(start, exec, putFile, getFile, destroy, health) maps one to one onto
loam's public API, so this adds LoamRunner beside MoorRunner rather than
shutting sluice down.

LoamRunner keeps MoorRunner's shape so the executor and the stage plans
do not change: commands run as `sprite` under /home/sprite, secrets go
in as files, and stages run detached and are polled. A sandbox is made
from the new sandbox image (loam-guest plus the bootstrap script's
toolchain, built to ghcr.io/arugula-salad by sandbox-image.yml and
pinned as LOAM_IMAGE), with no idle rule and a delete deadline in place
of moor's TTL. Without an image it falls back to loam's base template,
creates the sprite user and cold-bootstraps.

The Deployment switches to RUNNER=loam; RUNNER=moor rolls back while
moor still runs. OPERATIONS.md has the setup, switch and rollback.

Also: test/setup.ts strips SECRETS_KEY like the other secrets, so a
developer's .env no longer fails the production-config test locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sandbox-image: skip cleanly without GHCR_TOKEN
All checks were successful
test / test (pull_request) Successful in 3m23s
2f2bcbaa20
Until the GHCR token exists the workflow would fail at login on every
change to the image's inputs. Skipping keeps it green and leaves
LOAM_IMAGE as it is (empty: the base template, cold-bootstrapped).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jhgaylor changed title from WIP: Add a loam runner and make it sluice's runner to Add a loam runner and make it sluice's runner 2026-10-12 06:38:24 +00:00
jhgaylor force-pushed loam-runner from 2f2bcbaa20
All checks were successful
test / test (pull_request) Successful in 3m23s
to 412c384bee
All checks were successful
test / test (pull_request) Successful in 4m14s
2026-10-12 06:42:09 +00:00
Compare
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!13
No description provided.