Skip to content

feat(schema): add defaults.buildkit, the buildkitd daemon settings - #447

Merged
github-actions[bot] merged 3 commits into
mainfrom
feat/buildkit-daemon-config
Nov 27, 2026
Merged

github-actions[bot] merged 3 commits into
mainfrom
feat/buildkit-daemon-config

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the project-level buildkit daemon surface to the contract: #Buildkit (the [worker.oci] settings charly manages), referenced by #Box (so a box entity's buildkit: is validated), by #NodeDoc (so the authored defaults.buildkit is validated by the load-time document gate, not silently decoded), and by #BuildResolveReply (so the build drive receives the authored settings and renders them into buildkitd.toml).

Fields: process_mode, max_parallelism, snapshotter, no_process_sandbox, the GC budget (reserved_space / max_used_space / min_free_space), per-record gcpolicy entries, registry_mirror, and a raw extra TOML escape hatch for any daemon setting charly does not model. Every field is optional; an empty value selects the daemon's own default — except the GC budget, which the drive always writes (100 GB), because buildkitd's compiled free-space target (373 GB) prunes the cache to its ~10 GB floor on a host with less free space. That is the measured cache-invalidation driver in opencharly/charly#1292: the small arch RUN stays CACHED while the builder's large pacman -Syu layers re-execute and change the artifact.

Producer/consumer order: this schema lands first; opencharly/sdk (the renderer + 100 GB default, PR #650) is independent of it; opencharly/plugin-build reads the shape and passes it to the daemon; opencharly/charly bumps the pins and runs the bed.

How tested

Contract-module change class (no deployable target in spec; its charly.yml is the maintenance manifest only): the repo's module CI is the gate, run on this head (799ed881c0406be534c81c9227e58834f69574c7).

$ git status --porcelain                       # (clean)

$ git diff --stat $(git merge-base origin/main HEAD)..HEAD
 schema/box.cue          |   5 ++
 schema/buildkit.cue     |  57 ++++++++++++++++++++
 schema/buildkit_test.go | 156 ++++++++++++++++++++++++++++++++++++++++++++++++
 schema/buildresolve.cue |   4 ++
 schema/node.cue         |   7 ++-
 spec/cue_types_gen.go   |  80 +++++++++++++++++++++++++++
 6 files changed, 308 insertions(+), 1 deletion(-)

$ GOWORK=off go build ./...                 # exit 0
$ GOWORK=off go vet ./...                   # exit 0
$ test -z "$(gofmt -l .)"                   # exit 0
$ GOWORK=off go test ./...                  # PASS (schema, spec, schemaparams, schemaretag, storeroot, ...)

The generation remains reproducible (TestGenReproducible, part of the ./spec/ suite above — ok). Generated types on the head: Buildkit, BuildkitGCPolicy, Box.Buildkit *Buildkit and BuildResolveReply.Buildkit *Buildkit; BoxConfig is a Go ALIAS of Box (spec/charly_names.go: BoxConfig = Box), so both spellings name the same generated field.

R10 coverage (the test fails without the change)

schema/buildkit_test.go binds to the SAME schemaconcat concatenation + #NodeDoc gate the runtime loader uses (not a hand-built copy), and spec.Buildkit / spec.BuildResolveReply for the decode:

$ GOWORK=off go test ./schema/ -run 'TestBuildkit' -v
=== RUN   TestBuildkitDefaultsAcceptedAndDecoded
--- PASS: TestBuildkitDefaultsAcceptedAndDecoded (0.12s)
=== RUN   TestBuildkitDefaultsRejectsNegativeParallelism
--- PASS: TestBuildkitDefaultsRejectsNegativeParallelism (0.04s)
=== RUN   TestBuildkitDefaultsRejectsUnknownKnob
--- PASS: TestBuildkitDefaultsRejectsUnknownKnob (0.03s)
ok  	github.com/opencharly/spec/schema	0.209s

The RED arm — the same test with defaults?: _ restored (the unmodified tree):

$ git stash -- schema/node.cue   # (equivalent: revert the defaults typing)
$ GOWORK=off go test ./schema/ -run 'TestBuildkit'
--- FAIL: TestBuildkitDefaultsRejectsNegativeParallelism (0.04s)
    buildkit_test.go:130: a negative max_parallelism must be rejected by #Buildkit (int & >=0)
--- FAIL: TestBuildkitDefaultsRejectsUnknownKnob (0.04s)
    buildkit_test.go:138: an unknown buildkit knob must be rejected by the closed #Buildkit def
FAIL	github.com/opencharly/spec/schema	0.210s

That red arm is also the defect the review's R10 block surfaced: defaults was _, so defaults.buildkit was never shape-checked. schema/node.cue now types exactly that one block (defaults?: {buildkit?: #Buildkit}) and leaves every other defaults key open.

Spike

RCA claim (from charly#1292): the repeated-build cost is the daemon's default GC pruning the cache, not the per-build tag; the project needs an explicit, authorable GC budget.

Instrument: a throwaway probe compiled against the shipped schema (schemaconcat + #NodeDoc, the load-time gate) that unifies one candidate document per arm and prints ACCEPTED/REJECTED with the CUE error. Run twice — SP-1 on this head, SP-2 with schema/node.cue's defaults?: _ restored (the pre-change tree) — so each candidate is measured, not argued.

=== SP-1  this head (defaults.buildkit typed)
A scalar defaults.buildkit_max_parallelism = -1      ACCEPTED
A scalar defaults.buildkit_max_parallelism = 4       ACCEPTED
C opaque defaults.buildkit = "[worker.oci]..."       REJECTED  #NodeDoc.defaults.buildkit: conflicting values "[worker.oci]\n  max-parallelism = 4\n" and {process_mode?:string,max_parallelism?:(int & >=0),...} (mismatched types string and struct)
B struct defaults.buildkit {max_parallelism: 4}      ACCEPTED
B struct defaults.buildkit {max_parallelism: -1}     REJECTED  #NodeDoc.defaults.buildkit.max_parallelism: invalid value -1 (out of bound >=0)
B struct defaults.buildkit {max_paralellism: 4}      REJECTED  #NodeDoc.defaults.buildkit.max_paralellism: field not allowed
B struct defaults.buildkit {} (empty block)          ACCEPTED
exit=0

=== SP-2  pre-change tree (defaults?: _)
A scalar defaults.buildkit_max_parallelism = -1      ACCEPTED
A scalar defaults.buildkit_max_parallelism = 4       ACCEPTED
C opaque defaults.buildkit = "[worker.oci]..."       ACCEPTED
B struct defaults.buildkit {max_parallelism: 4}      ACCEPTED
B struct defaults.buildkit {max_parallelism: -1}     ACCEPTED
B struct defaults.buildkit {max_paralellism: 4}      ACCEPTED
B struct defaults.buildkit {} (empty block)          ACCEPTED
exit=0

Reading the round:

  • A — scalar fields on defaults (defaults.buildkit_max_parallelism, …). ACCEPTED in BOTH trees, including the out-of-range -1: a scalar scatter leaves the value unvalidated and cannot express a [[worker.oci.gcpolicy]] list. Eliminated.
  • C — one opaque defaults.buildkit TOML string. ACCEPTED on the pre-change tree and REJECTED on this head: once the field is typed it is not a string, and if it stays untyped nothing is checked. It cannot be the primary surface; it survives only as extra. Eliminated as the surface, kept as extra.
  • B — a nested #Buildkit def referenced by #Box, #NodeDoc and #BuildResolveReply. The only arm that is ACCEPTED for a valid document and REJECTED for -1 and for a mistyped knob, while the empty block stays legal. Winner.

Winner: B. RCA verdict: confirmed — the def compiles, regenerates reproducibly, the generated types round-trip the shape into the resolve wire, and only B enforces the range/closedness that the authored surface needs.

Rulebook compliance

  • R0 — image/layer/go/design/strict-policy/git-workflow loaded before the work.
  • R1 — the review's four findings are addressed: the coverage gap (above), the argument-only spike (replaced by the two-tree instrument), the evidence contradiction (git diff --stat + the exact Box.Buildkit type above), and the missing D-id (R11 below). The label-position and tag hypotheses were tested and disproved on the charly side and recorded in the base builder is rebuilt under a new CalVer tag on every build, so no layer is ever reused charly#1292.
  • R2 — one #Buildkit def serves the ingress, the load gate and the wire; no second shape.
  • R3 — no defaults are guessed at the contract layer: an empty field means the daemon's own value, stated in each field's doc.
  • R5 — no legacy field or spelling is left: the shape is new and #Buildkit is closed, so an unknown knob is an error (proved by the max_paralellism arm).
  • R7 — the two negative arms fail on the unmodified tree (pasted above); generation is reproducible.
  • R10 — contract/library class: the module suite is the gate, and the changed surface now has coverage that fails without it (schema/buildkit_test.go). spec declares no disposable: true entity. The consumer bed rides the charly pin-bump PR.
  • R11 — this adds an authored field and a new shape, which D-LAW-4 (schema first), D-SCH-1 (every authored shape is defined once, in CUE; no hand-written Go mirror, no Go validator restating a rule) and D-LAW-5 (a default exists only where the schema declares it; fail loud at the source) govern. It conforms: one CUE def, generated Go only, the >=0/closedness rules live in CUE (the test unifies, it does not restate), and the 100 GB GC budget is declared at the layer that renders it (sdk#650), not hidden in code here. No DESIGN amendment is needed and none is made.
  • R12 — the two-tree instrument above (A eliminated, C eliminated as surface, B the only arm that validates).

Change classification

Additive schema: defaults.buildkit becomes authorable, validated by the load-time gate, and carried to the drive; existing configs are unchanged (the block is new and every field optional). Breaking change + rollback: none — absent means the daemon default; rollback is a revert of this squash (the generated types disappear with the def).

Filed issues

Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)

One buildkitd serves every box a project builds, so its settings are
project-level (`defaults.buildkit`). #Buildkit models the [worker.oci] surface
charly manages - process mode, max-parallelism, snapshotter, noProcessSandbox,
the GC budget (reserved/max-used/min-free), per-record gcpolicy entries, the
registry mirror - plus a raw `extra` TOML escape hatch for any setting charly
does not model. #BuildResolveReply carries the same shape to the build drive so
the drive can render it into buildkitd.toml.

The GC fields are the measured cache fix for opencharly/charly#1292: the
compiled default free-space target (373 GB) prunes the cache to its ~10 GB
floor on a host with less free space, so an unchanged tree re-executes.

Generated with the in-process schemagen pipeline (params + vocab);
TestGenReproducible passes on the committed tree.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5`* · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*
*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 3e1104e7465e2314273fe101c1212c28fcfdf3bd (branch: feat/buildkit-daemon-config)

Change class: contract/schema module (CUE source + regenerated Go types); no deployable target. Placement is CORRECT (a wire shape belongs in spec, CUE-first — not a finding).

Blocks

  1. R10 — the change ships no coverage that would fail without it. The whole diff is new contract surface (schema/buildkit.cue, schema/box.cue:132, schema/buildresolve.cue:106, spec/cue_types_gen.go:1200), and not one test or hook is added anywhere in it. TestGenReproducible is pre-existing and only proves the generated file is in sync — it does not exercise the new behaviour. Add a test that fails on the unmodified tree and passes with this change, e.g. a schema/ validation test asserting a defaults.buildkit: {max_parallelism: -1} config is REJECTED (the >=0 constraint) and a valid one with gcpolicy/extra is accepted and round-trips through the generated Buildkit struct, plus the corresponding negative case.

  2. R12 — the spike block is argument, not a spike. Under ### Spike, candidates A ("scalar fields on defaults") and C ("opaque TOML string only") are rejected by prose reasoning with no instrument, no pasted command output, no exit code, no result line — the only pasted output (go test ./spec/ -run TestGenReproducible) belongs to the winner, not to any candidate. Per R12 a candidate "spiked" by reading/arguing is not a spike. Either paste the actual per-candidate instrument and its output (a CUE cue vet/schemagen run per candidate shape showing it compiles/validates or fails, with exit code), or drop the candidates that were never spiked and state honestly which single candidate was proven. No R12 exemption is claimed, and none applies (this is not a typo/comment/prose-only/revert).

  3. A2 / R10 — the pasted evidence contradicts the diff. The body's git diff --stat block lists three files (schema/box.cue, schema/buildresolve.cue, spec/cue_types_gen.go) and omits schema/buildkit.cue — the 57-line new def that is the entire point of the PR, and the file without which the generated types cannot exist. The evidence therefore does not cover the changed tree. Secondary contradiction in the same section: the body claims the generated type is BoxConfig.Buildkit *Buildkit, while the diff at spec/cue_types_gen.go:1200 shows Box.Buildkit *Buildkit. Re-paste a git status --porcelain + git diff --stat (or git show --stat) covering all four files on this head, and state the generated type exactly as it appears in the diff (or show the BoxConfig alias if one exists).

  4. R11 — no governing D-id cited for the new authored field/shape. This change adds an authored field (defaults.buildkit) and a new shape (#Buildkit, #BuildkitGCPolicy) — exactly the "adds a field / shape" case R11 governs. The body's R11 line cites only D-STORE-1 (store roots via spec/storeroot), which does not govern the authored config surface and is untouched by this diff. Name the DESIGN requirement id that actually governs defaults.* authored config, and for it state one of: conforms / amends DESIGN (with the design-check output on this tree plus a maintainer sign-off comment) / design debt filed as an issue under ## Filed issues. A new authored mechanism with no applicable D-id cited is a BLOCK.

Non-blocking note (A3, tool-limited): *Assisted-by: OpenCode DeepSeek V4.1 Flash …* — confirm "DeepSeek V4.1 Flash" is the provider's actual model identifier for the authoring runtime; I cannot verify a model of that name and it should not be a guessed label. The tier itself is fine for a contract module.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

`defaults` was an untyped document directive, so #Buildkit was reachable only from #Box and the resolve reply: an authored defaults.buildkit was never validated by the load-time gate, and a mistyped or out-of-range knob reached the Go decode silently. Typing the one block closes that hole without closing the rest of defaults.

The new test binds to the SAME schemaconcat/load gate the runtime uses: a full buildkit block is accepted and decodes into spec.Buildkit (gcpolicy + extra included), a negative max_parallelism is rejected by the >=0 constraint, an unknown knob is rejected by the closed def, and the resolve-reply wire half is exercised. The two negative arms fail on the unmodified tree.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*

*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
@aitrawog

Copy link
Copy Markdown
Contributor Author

STATUS

All four blocks are addressed on the new head d52ebb60f7bf5ff656a83e552d7ec38e3f95d9c9.

  • R10 coverage — schema/buildkit_test.go binds to the same schemaconcat + #NodeDoc gate the runtime uses: a full block is accepted and decodes into spec.Buildkit (gcpolicy + extra included), max_parallelism: -1 is rejected, an unknown knob is rejected, and the resolve-reply wire half is exercised. With defaults?: _ restored the two negative arms FAIL (pasted in the body) — which also surfaced the real gap: defaults was untyped, so defaults.buildkit was never validated at all. schema/node.cue now types exactly that one block.
  • R12 — the argument is replaced by a compiled probe run on BOTH trees (SP-1 this head, SP-2 pre-change): A is ACCEPTED even for -1 (unvalidated), C is ACCEPTED pre-change and REJECTED post-change (string vs struct), B is the only arm that accepts the valid document and rejects -1 + a mistyped knob. Full output, with exit codes, is in ### Spike.
  • A2 / evidence — the body now pastes git status --porcelain (clean) and git diff --stat over all six changed files (including schema/buildkit.cue), and states the generated type exactly as it appears: Box.Buildkit *Buildkit (BoxConfig = Box is an alias, spec/charly_names.go).
  • R11 — cites the requirements that govern an authored field/shape: D-LAW-4, D-SCH-1, D-LAW-5, with the conformance stated.

Gate on the head: go build ./..., go vet ./..., gofmt clean, go test ./... PASS (including TestGenReproducible).

Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)

The typed defaults.buildkit must not close the defaults directive: a realistic project document keeps platform/registry/build/keep_images/context_ignore/stage_parallelism and still loads. Pinned so a later tightening of the node gate cannot quietly reject every real charly.yml.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*

*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 799ed881c0406be534c81c9227e58834f69574c7 (branch: feat/buildkit-daemon-config)

Security screen: PASS — no secrets, no guardrail weakening, no supply-chain change, no injection; the diff adds a CUE def, its generated types, and a test only.
Checklist: All applicable rules PASS or NA (contract/schema module — ADE/R9/R7-Containerfile and live-service rules are NA; placement: CORRECT, a wire shape belongs in spec, CUE-first).

Comment dispositions:

  • @github-actions[bot] #7216202240 — stale-superseded: its four blocks (R10 coverage, R12 argument-not-spike, git diff --stat omitting schema/buildkit.cue + wrong BoxConfig.Buildkit spelling, missing D-id) are all cured on the current head — schema/buildkit_test.go added and shown red without the node.cue typing; the two-tree SP-1/SP-2 spike now pastes per-candidate ACCEPTED/REJECTED with exit codes; the stat lists all six files and states Box.Buildkit *Buildkit matching spec/cue_types_gen.go:1200; D-LAW-4/D-SCH-1/D-LAW-5 are cited with conformance.
  • @aitrawog #7217969960 — verified-non-blocking: a valid STATUS coordination comment; its claims re-derive against the current body/diff and hold.

Non-blocking notes (no block):

  • R11 — the governing D-ids are cited with conforms stated, but DESIGN.md is not in my context, so I cannot independently confirm the ids exist; accepted as stated (tool-limited).
  • The round appends two commits (d52ebb60, 799ed88) rather than one; the content is a single cohesive cutover (typing + test + the follow-on "keep the rest of defaults open" fix), squashed on merge with no scope split — noted only.
  • Producer/consumer order is stated, but sdk#650 is declared independent and the charly leg is gated by filed charly#1300, so no open item is explicitly blocked by this PR and no WAITING/HOLDING comment is required.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 27, 2026 12:21
@github-actions
github-actions Bot merged commit ff534e4 into main Nov 27, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 27, 2026
github-actions Bot pushed a commit to opencharly/plugin-build that referenced this pull request Nov 27, 2026
…ngs (#71)

* feat(build): render defaults.buildkit into the buildkitd daemon settings

The project's authored defaults.buildkit (spec #Buildkit) now reaches the
drive: resolve fills BuildResolveReply.Buildkit, and the drive maps it onto
buildkitdrive.DaemonOptions (process mode, max-parallelism, snapshotter,
noProcessSandbox, the GC budget, gcpolicy entries, registry mirror, extra).
An unauthored field keeps the drive's fallback (the resolved stage
parallelism, the CHARLY_BUILD_REGISTRY_MIRROR env); the GC budget itself
defaults in sdk/buildkitdrive to 100 GB - the measured fix for the cache
eviction that made an unchanged tree re-execute its layers
(opencharly/charly#1292).

Depends on opencharly/spec#447 (#Buildkit) and opencharly/sdk#650
(DaemonOptions + the 100 GB default). Producer-first: the go.mod requirement
bumps land after those merge and tag.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*
*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*

* fix(build): adopt sdk v0.2026331.1440 + spec v0.2026331.1221, and track the content-addressed candy stage dir

The daemon-config mapping needs the released DaemonOptions (the #Buildkit fields and the 100 GB GC default) and defaults.buildkit from spec. Adopting them surfaced one real integration break the gate caught: spec#445 made CandyStageDirName CONTENT-ADDRESSED (name.<sha256[:16]>) with the version-keyed form only as the fallback, and remote_candy_copies_test.go hardcoded marker.<version>. The test now asks the same deploykit.CandyStageDirName the emitter uses, so the guard tracks the contract rather than a stale spelling.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*

*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*

* test(build): pin the daemon TOML the mapping actually renders

The mapping was pinned only at the struct level, so the artifact the drive writes was unproven and a reviewer could not tie the pasted TOML to this code. This test renders driveConfig.daemonOptions() through sdk's DaemonConfig and asserts the exact keys the daemon loads, including the two buildkitd spellings (process-mode, max-parallelism) alongside the camelCase worker/GC fields, and that an unauthored project still renders the stage parallelism and the 100 GB GC default. Red arm: restoring the two-field Ensure behaviour fails it.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*

*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
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