mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
backend.Check(ctx, b) returns the first of a backend's Problems, in place of Check in the Backend interface (Lima's and the fake's go). ImageSpec.Validate and ToolsSpec.Validate hold the build specs' checks Lima made itself: a layer from a container image, a network that isn't a build's, a key that isn't one, a tools format other than the backend's, folders that aren't absolute. ToolsSpec gets Name, what it builds, for the refusal's vm. The registry hands out each backend behind a guard: CreateVM, Start, BuildImage and BuildTools run the spec's Validate and the review's refusal for spec.Features() (VMSpec's, Want's and Confinement's, ImageSpec's, ToolsSpec's) before the backend sees them, without a second warning for an unreviewed emulation let through. Callers' own Require calls stay as the clear error path; the guard is the backstop. Want.Features is new; VMSpec.Features uses it and adds agent-toggle when the VM is made ready for it. backend.As finds a backend's other interfaces behind the guard (KeyFiles, Storage, Locator, Forgetter, UsageReporter, StrayFinder, CacheCleaner). Structure test: execSites lists the 17 files whose 24 exec.Command* calls stay, each with why (they make a command a runner runs, or one that streams, asks on the terminal, outlives the run or carries a secret); a host command made anywhere else fails, as does a listed file making none. guardOwner: a type assertion or type switch to a backend package's type outside guard.go fails (use backend.As). TestRulesFail cases for both. Tests: TestCheck, TestImageSpecValidate, TestToolsSpecValidate, TestGuardRefuses, TestGuardLetsThrough, TestAs; TestFeaturesNeeded gains Want's and agent-toggle; Lima's refuse cases for what Validate owns move to the backend package. Docs: internals/backends.md (the guard behind the first check); contributing's How a backend plugs in (Check, the guard, Validate, As), the structure test's execSites and guardOwner, and the owners table. Co-Authored-By: Claude Opus 5.5 <[email protected]>