Skip to content

fix(box): make openrc selectable via #Box.init - #57

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/box-init-openrc
Aug 28, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/box-init-openrc

Conversation

@atrawog

@atrawog atrawog commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The spec leg of batch B1 — service-render correctness, and its last piece.

The build vocabulary defines three init systems — supervisord, systemd, and openrc, the
last a first-class entity with its own service_template, management_command set and
unit_path_template — but #Box.init's enum listed only two:

init?: "supervisord" | "systemd"

So a box could not select openrc at all: init: openrc failed schema validation against an init
charly fully implements.

That was invisible until now for a specific reason. Before opencharly/sdk#175, #Box.init reached
nothing — all three ResolveInitSystem call sites passed a hardcoded "" — so the enum's
contents could not matter. Now that the field is actually read, an unselectable vocabulary word is a
live inconsistency between what the vocabulary defines and what a box may ask for.

The doc comment states the invariant the enum has to hold — every value must be an init the build
vocabulary actually defines
— so the next init added to charly.yml has a stated reason to appear
here too, rather than being omitted the way openrc was.

How tested

Coverage that fails without the change

schema/box_init_test.go compiles the shipped schema the way consumers do
(schemaconcat.ConcatSchema over the embedded FS) and unifies a #Box against each init:

--- PASS: TestBoxInitAcceptsEveryVocabularyInit
--- PASS: TestBoxInitStillRejectsAnUnknownInit
--- PASS: TestBoxInitDocumentsItsInvariant
ok      github.com/opencharly/spec/schema

Reverting only the enum, with the tests in place:

--- FAIL: TestBoxInitAcceptsEveryVocabularyInit
    box_init_test.go:48: #Box.init rejects "openrc", which the build vocabulary defines
    as a first-class init: a box cannot select an init charly implements

The second case is what keeps the first honest: widening by loosening the type to string would
make it pass while silently accepting typos, so sysvinit, runit, Systemd and "" are asserted
to stay rejected.

$ task cue:gen          # SDD: the CUE def is the single source
cue:gen: regenerated spec/{cue_types_gen.go,vocab_gen.go,version_gen.go}
GEN=0

Regeneration is reproducible — a second run produces the identical tree, and the only generated
change is the doc comment flowing onto Box.Init:

  Network string `yaml:"network,omitempty" json:"network,omitempty"`

+ // init — pin the box's init system instead of letting composition auto-detect it.
+ // Every value here must be an init the build vocabulary actually defines …
  Init string `yaml:"init,omitempty" json:"init,omitempty"`
$ go build ./... && go test ./...
18 packages ok, 0 failures
$ golangci-lint run
0 issues.

An environmental failure worth naming

Run from a checkout under /tmp, TestSweepStaleTemps_HonoursTMPDIR and
TestOpenedFilesByAnyProcess_HonoursTMPDIR fail — and say exactly why:

the alternate temp root … is itself under /tmp — this checkout cannot host the premise
of the $TMPDIR tests, which is a root the pre-fix hardcode does NOT cover; they would
pass without discriminating

They fail deliberately rather than passing vacuously. Confirmed environmental by a control run on
the pristine tree (identical failures), and both pass from a checkout outside /tmp — which is
where the 17/0 result above comes from. Not a defect, and nothing to fix.

Rulebook compliance

  • R0 — /charly-image:layer (init polymorphism) loaded before editing.
  • R1 — the two $TMPDIR failures got a control run on a pristine tree before any conclusion;
    they reproduce identically without this change and pass outside /tmp.
  • R2 — the pre-existing gofmt violation in fleet/deploy_fleet_ops_candykey_test.go blocks any
    commit to this module, so it is fixed here rather than deferred.
  • R3 — N/A — no duplication introduced; the enum is the single place a box's init is constrained.
  • R4 — no workaround: the enum was widened, not bypassed with a looser type.
  • R5 — N/A — nothing removed.
  • R6 — git status checked; branch off fresh main; no force-push, no bypass.
  • R7/R10 — the schema change is proven by validating the shipped schema directly, and the
    coverage fails without it (control run pasted). No bed applies: selecting init: openrc end to end
    needs an OpenRC-capable image, which no bed in the corpus provides — hence the capped tier.
  • B12 — new behaviour ships with a test that fails without it, verified by reverting the enum
    and re-running rather than by inspection.
  • R8 — the emitted artifact is the generated Go, asserted by regeneration being a no-op.
  • B13 — SDD honoured: the CUE def is the single source and the Go was regenerated with
    task cue:gen, never hand-edited. No banned @go(-) tag.
  • B16 — no version pin moved in this leg.

Change classification

  • Class: schema change (CUE) + its generated Go.
  • Verification gate: task cue:gen reproducible + module suite + lint.
  • Attribution tier: analysed on a live system — the schema compiles and regenerates cleanly and
    the suite is green, but selecting init: openrc end to end needs an OpenRC-capable image, which
    no bed in the corpus provides.

Not covered

  • No test mechanically checks the enum against charly's vocabulary. schema/box_init_test.go
    (added in the second commit) asserts the enum accepts every init the vocabulary defines by name,
    and that it still rejects unknown ones — but it cannot read charly.yml to derive that list,
    because spec does not and should not import charly. A third case therefore pins the doc comment
    itself, since that comment is the only thing telling the next init's author to come here. The
    mechanical cross-check belongs in charly's TestEmbeddedVocab_* family, which already reads that
    file.
  • init: openrc is not exercised. OpenRC is explicitly out of scope for the cstream program, so
    this leg makes it selectable and consistent, without claiming it is proven on a live image.

Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)

The build vocabulary defines three init systems - supervisord, systemd and openrc,
the last a first-class entity with its own service_template, management commands
and unit_path_template - but #Box.init's enum listed only two. A box could not
select openrc at all: `init: openrc` failed schema validation against an init
charly fully implements.

That mattered from the moment #Box.init started being read. Until sdk#175 the
field reached nothing, so the gap was invisible; now that ResolveInitSystem
receives it, an unselectable vocabulary word is a live inconsistency between what
the vocabulary defines and what a box may ask for.

The doc comment states the invariant the enum has to hold - every value must be an
init the vocabulary actually defines - so the next init added to charly.yml has a
stated reason to appear here too, rather than being omitted the way openrc was.

Regenerated with `task cue:gen` (SDD: the CUE def is the single source; the Go
comment is generated from it). Regeneration is reproducible - a second run is a
no-op.

Also fixes a pre-existing gofmt violation in
fleet/deploy_fleet_ops_candykey_test.go. It is untouched by this change but blocks
any commit to the module, so R2 puts it here rather than in a follow-up.

Assisted-by: Claude Code Anthropic Opus 5 (analysed on a live system)

Claude-Session: https://claude.ai/code/session_01Gf42A3bau77JigFYLALrnq
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 6a863042da8544e4bd113878fa830c9788c46fc2

Change class: schema change (CUE) + regenerated Go + gofmt fix in an unrelated test file.

Security screen: PASS — no scope mismatch (all three files accounted for in the body), no secrets/exfiltration, no weakened guardrails, no supply-chain changes.

Blocks

  1. B12 — new behavior ships with no test that would fail without it. The change widens #Box.init in schema/box.cue to accept openrc, making init: openrc valid where it previously failed schema validation. The body explicitly admits: "No test asserts the invariant the doc comment states" and "init: openrc is not exercised." The diff contains no test that would FAIL on the pre-change schema — the only test-file hunk (fleet/deploy_fleet_ops_candykey_test.go) is a trailing-blank-line gofmt fix, not a behavioral test of the new enum value. Per B12, a change whose new behavior has NO test that would fail without it BLOCKS. The body's routing of the invariant test to a named charly batch (R2) does not satisfy B12's coverage requirement for this change — a schema-validation test asserting init: openrc validates (which would fail on the old enum) can live in spec and must be added here.

Verdict: BLOCK


ollama/deepseek-v4-flash — pi-review-action.

View action run

Adds the coverage the enum widening shipped without. Three cases against the
SHIPPED schema, compiled the way consumers compile it
(schemaconcat.ConcatSchema over the embedded FS):

  - every vocabulary init validates. Fails on the pre-change enum: unifying
    #Box with init: "openrc" is a conflict, not a warning.
  - an unknown init is still rejected. Widening by loosening the type to
    `string` would make the first case pass while silently accepting typos, so
    the discrimination is asserted rather than assumed.
  - box.cue still states the invariant. It is the only place that says why the
    enum's membership is constrained, and spec cannot read charly's vocabulary
    to check it mechanically.

Caught by the pr-validator: B12 requires a test that fails without the change,
and the original diff's only test hunk was an unrelated gofmt fix.
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 90e16e7aef8b65fc01f94c210e35d7067e2a7dcd (branch: fix/box-init-openrc)

Change class: schema change (CUE) + regenerated Go + gofmt fix + new schema test.

Security screen: PASS — no scope mismatch (all 4 files accounted for in body), no secrets/exfiltration, no weakened guardrails, no supply-chain changes.

Comment intake: The single prior github-actions[bot] BLOCK (B12 — "no test that would fail without the change") is stale-superseded: it reviewed head 6a863042da85 (the fix commit only). The current head 90e16e7aef8b adds schema/box_init_test.go, whose TestBoxInitAcceptsEveryVocabularyInit unifies #Box with {init: "openrc"} — a conflict on the pre-change two-member enum, so it fails without this change. B12 is now satisfied.

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3: body complete, gate matches schema-leg class, tier analysed on a live system honestly capped (openrc not exercised end-to-end), Assisted-by: footer present.
  • B5/R1: the two $TMPDIR failures carry a genuine root-cause (checkout under /tmp defeats the test premise), confirmed by a pristine-tree control run — not a flake dismissal.
  • B6/R2: pre-existing gofmt violation fixed in-tree; the invariant test is routed to the NAMED B1 charly batch, not a vague deferral.
  • B13/SDD: CUE def is single source; cue_types_gen.go change corresponds to the box.cue source change; no banned @go(-) tag.
  • B16: placement CORRECT — the init constraint belongs in the #Box schema (wire shape), not core/sdk/candy.
  • B12: new behavior now covered by a test that fails on the old enum; regeneration reproducible; suite green.

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) August 28, 2026 15:49
@github-actions
github-actions Bot merged commit 4ba0672 into main Aug 28, 2026
1 check passed
charly-auto-merge Bot added a commit that referenced this pull request Aug 28, 2026
charly-auto-merge Bot added a commit that referenced this pull request Aug 28, 2026
@aitrawog
aitrawog deleted the feat/box-init-openrc branch September 25, 2026 19:09
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.

1 participant