Skip to content

Guard bbox-init embed behind bbox_full build tag#197

Merged
JAORMX merged 1 commit into
mainfrom
fix/110-stub-bbox-init-embed
Jun 26, 2026
Merged

Guard bbox-init embed behind bbox_full build tag#197
JAORMX merged 1 commit into
mainfrom
fix/110-stub-bbox-init-embed

Conversation

@JAORMX

@JAORMX JAORMX commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #110 — embedding the bbox-init guest binary unconditionally made brood-box uncompilable as a Go module dependency.

internal/infra/vm/initbin/embed.go used //go:embed bbox-init, but that binary is built by task build-init and is .gitignored. The module proxy serves the package without it, so any downstream consumer importing brood-box as a library hit a hard compile failure:

.../brood-box/internal/infra/vm/initbin/embed.go: pattern bbox-init: no matching files found

The dependency chain that pulls this in for library consumers:

pkg/runtime → pkg/sandbox → internal/infra/vm → internal/infra/vm/initbin (embed)

Approach (Option A from the issue — build-tag guard)

  • embed_full.go (//go:build bbox_full) — the real //go:embed bbox-init directive.
  • embed_stub.go (//go:build !bbox_full) — exports an empty Binary []byte.
  • task build and task install now build the bbox CLI with -tags "embed_runtime bbox_full".
  • Every other build — go test, golangci-lint, and library consumers — uses the stub and compiles cleanly without the bbox-init file present.

Fail-fast safety

InjectInitBinary now checks len(initbin.Binary) == 0 and returns an actionable error before writing, so a stub-built binary that tries to boot a VM fails clearly instead of writing a zero-byte init:

bbox-init binary not embedded: rebuild bbox with the 'bbox_full' build tag (e.g. `task build`)

The init-binary hook tests are split by build tag: content/permission assertions run under bbox_full; a new stub test asserts the guard error and that no file is written.

Verification

  • go build ./internal/... ./pkg/... with the bbox-init file deleted (reproduces the original failure → now compiles).
  • go build -tags bbox_full with the binary present.
  • task build produces a working bin/bbox (embedded runtime + init).
  • task test (stub) and go test -tags bbox_full ./internal/infra/vm/ both pass.
  • task lint — 0 issues.

🤖 Generated with Claude Code

The bbox-init guest binary is built by `task build-init` and is
.gitignore'd, so the Go module proxy serves the initbin package without
it. Embedding it unconditionally made brood-box uncompilable for any
downstream consumer importing it as a library (pkg/runtime -> pkg/sandbox
-> internal/infra/vm -> initbin):

  pattern bbox-init: no matching files found

Split the embed behind a `bbox_full` build tag (Option A from the issue):
embed_full.go carries the real //go:embed under the tag, embed_stub.go
exports an empty Binary by default. The bbox CLI build and install
targets now pass `bbox_full`; every other build (go test, golangci-lint,
library consumers) uses the stub and compiles without the file present.

The rootfs hook validates Binary is non-empty before use, so a stub
build that attempts to boot a VM fails fast with an actionable error
rather than writing a zero-byte init. Init-binary hook tests are split
by build tag accordingly.

Fixes #110

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VP887qH8BMW4PMUXBuEqGc
@JAORMX JAORMX merged commit f509f25 into main Jun 26, 2026
8 checks passed
@JAORMX JAORMX deleted the fix/110-stub-bbox-init-embed branch June 26, 2026 06:49
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.

Embedded bbox-init binary prevents use as a Go module dependency

1 participant