Files
clawmates/migrations/0066_mission_backend.sql
T
Omar SobhandClaude Opus 5 6687f8b808 feat(fleet): B4.3 — per-mission rootfs selection (missions.backend)
`vm_create` takes a backend name and boots `rootfs-<backend>.ext4`; NULL
or "default" boots the golden image. Makes the per-CLI images from B4.1
actually reachable (one image per CLI, per A6).

A missing image is an ERROR naming the file and how to build it, never a
quiet fall back to the default. That fallback is the tempting version and
the wrong one: it would run a claude mission in a kimi VM, or in a rootfs
with no CLI at all, and report success for whatever came out. Verified on
real hardware, not just in a unit test — the selftest asks for an image
that does not exist and FAILS if it boots.

`create` now reports the rootfs that actually booted, not the one that was
requested, so a mission artifact can show the wrong VM ran.

The migration adds no CHECK constraint listing the CLIs. Which images
exist is a property of the NODES, not the schema; a constraint would need
migrating for every new image while still not guaranteeing the image
exists anywhere. The node validates and names what is missing. Backend
names are `[A-Za-z0-9_-]` and rejected rather than sanitised, since they
become filenames.

Verified on tank: default backend 8/8; `CLAWMATES_FC_BACKEND=agent-terminal`
9/9 including the absent-image check, create in 910ms on a rootfs built
from a real Docker image. 435 tests green, no leaked processes or VM dirs.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-05 10:38:45 -07:00

18 lines
1003 B
SQL

-- Which CLI a mission runs on, and therefore which rootfs image its microVM
-- boots (per A6: one image per CLI, independently versioned).
--
-- NULL means "the default" rather than a specific CLI, so existing missions
-- keep their current behaviour without a backfill: the microVM path reads NULL
-- as the golden rootfs, and the container path ignores the column entirely.
--
-- No CHECK constraint listing the CLIs. The set of images is a property of the
-- NODES (which ones have been built there), not of the schema, and a constraint
-- here would have to be migrated every time an image is added while still not
-- guaranteeing the image exists anywhere. The node validates and reports a
-- missing image by name; a wrong value fails loudly at launch rather than
-- silently booting something else.
ALTER TABLE missions ADD COLUMN IF NOT EXISTS backend text;
COMMENT ON COLUMN missions.backend IS
'CLI/rootfs backend for microvm runtime_kind (e.g. claude, kimi, glm). NULL = default image.';