Skip to content

feat(build): render defaults.buildkit into the buildkitd daemon settings - #71

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

The project's authored defaults.buildkit (spec #Buildkit) now reaches the build daemon. buildkitdrive.Ensure was called with only max-parallelism and the registry mirror; the drive now maps the whole authored surface onto buildkitdrive.DaemonOptions:

  • process_mode, max_parallelism, snapshotter, no_process_sandbox;
  • the GC budget (reserved_space / max_used_space / min_free_space) and gc: false;
  • per-record gcpolicy entries, registry_mirror, and the raw extra TOML;
  • an unauthored field keeps the drive's fallback (the resolved stage_parallelism, the CHARLY_BUILD_REGISTRY_MIRROR env), and an unauthored GC budget takes sdk's 100 GB default — the measured fix for the cache eviction in the base builder is rebuilt under a new CalVer tag on every build, so no layer is ever reused charly#1292.

Dependencies are the released producer tags: sdk v0.2026331.1440 (the DaemonOptions surface + the 100 GB default) and spec v0.2026331.1221 (#Buildkit), in go.mod/go.sum.

One real break the version bump surfaced, fixed here. spec#445 made CandyStageDirName content-addressed (<name>.<sha256[:16]>) with the version-keyed <name>.<version> only as a fallback, and remote_candy_copies_test.go hardcoded marker.2026.181.1430. The package gate caught it (remote candy source not staged at …/marker.2026.181.1430/copied.dat). The test now asks the same deploykit.CandyStageDirName the emitter uses, so the guard tracks the contract rather than a spelling; the production path was already consistent (it calls that function).

How tested

$ GOWORK=off go build ./...        # exit 0
$ GOWORK=off go vet ./...          # exit 0
$ test -z "$(gofmt -l .)"          # exit 0
$ GOWORK=off go test .             # ok — full package suite, resolved against the RELEASED tags

TestDaemonOptions_MapsAuthoredBuildkit pins the mapping at the struct level: every authored field wins, gc: false is a pointer (absent = enabled with the 100 GB budget), and a project mirror beats the env fallback.

TestDaemonOptions_RendersTheDaemonConfig pins the mapping's end-to-end artifact — driveConfig.daemonOptions() → buildkitdrive.DaemonConfig — asserting the exact TOML keys the daemon loads (both buildkitd spellings process-mode/max-parallelism and the camelCase worker/GC fields, plus the gcpolicy entry), and that an unauthored project still renders max-parallelism = 4 and the 100 GB budget. Red arm — the pre-change two-field Ensure behaviour:

--- FAIL: TestDaemonOptions_RendersTheDaemonConfig (0.00s)
    the rendered daemon config must carry "max-parallelism = 8":
    the rendered daemon config must carry "snapshotter = \"overlayfs\"":
    the rendered daemon config must carry "noProcessSandbox = true":
FAIL

Spike

RCA claim: a project must be able to author the daemon settings, and the TOML the drive renders from them must be accepted by a real buildkitd.

Candidates:

  • A. Map each authored field onto DaemonOptions (chosen). Instrument: render the PR's own path — driveConfig.daemonOptions() → buildkitdrive.DaemonConfig — then start a real rootless buildkitd with exactly that file.

    The artifact, produced by the mapping (test probe: buildkitdrive.DaemonConfig(c.daemonOptions())):

    # Rendered by sdk/buildkitdrive. Do not hand-edit: the drive writes it from the
    # resolver's roots on every ensure.
    [worker.oci]
      process-mode = "sandbox"
      max-parallelism = 8
      snapshotter = "overlayfs"
      noProcessSandbox = true
      gc = true
      reservedSpace = "40GB"
      maxUsedSpace = "80GB"
      minFreeSpace = "5GB"
    
    [[worker.oci.gcpolicy]]
      all = true
      maxUsedSpace = "60GB"
      filters = ["type==source.local"]
    

    The daemon started with it — full log, no parse/unknown-field error:

    $ rootlesskit --net=host buildkitd --rootless --root <tmp> --addr unix://<tmp>/b.sock --config mapped-real.toml
    level=warning msg="NoProcessSandbox is enabled. Note that NoProcessSandbox allows build containers to kill ..."
    level=warning msg="CDI setup error /etc/buildkit/cdi: failed to monitor for changes: no such file or directory"
    level=warning msg="failed check for fsverity support" error="enable fsverity failed: inappropriate ioctl for device"
    level=info msg="found worker \"zny8dlhcbnx4kanxt9kb3jnhh\", labels=map[... oci.process-mode:no-sandbox ... worker.snapshotter:overlayfs ...]"
    level=info msg="found 1 workers, default=\"zny8dlhcbnx4kanxt9kb3jnhh\""
    level=info msg="running server on .../b.sock"
    
    $ buildctl --addr unix://<tmp>/b.sock debug workers
    ID                              PLATFORMS
    zny8dlhcbnx4kanxt9kb3jnhh       linux/amd64,linux/amd64/v2,…,linux/arm/v6
    # exit 0
    

    The worker labels are the proof the settings TOOK EFFECT: oci.process-mode:no-sandbox (from noProcessSandbox = true) and worker.snapshotter:overlayfs (from snapshotter). The mixed casing (process-mode/max-parallelism kebab, the GC fields camelCase) is buildkitd's OWN accepted form — this daemon started from exactly that file, so it is not a renderer defect and nothing is silently ignored. A [[worker.oci.gcpolicy]] entry is present and accepted in the same file.

  • B. Expose only the raw extra TOML (no first-class fields). Rejected by the spec spike that produced #Buildkit (feat(schema): add defaults.buildkit, the buildkitd daemon settings spec#447): an untyped blob cannot be validated or defaulted, so the 100 GB GC default — the half of #1292 that keeps the cache — could not exist, and a typo would be a silent no-op. It survives as the extra escape hatch.

  • C. Ignore defaults.buildkit and rely on the sdk defaults alone. Rejected: it makes "all buildkit settings configurable in charly.yml" false (the explicit ask), and leaves process_mode/snapshotter/gcpolicy unreachable. TestDaemonOptions_MapsAuthoredBuildkit is the guard A needs and C would not have.

On the casing question: the mix is deliberate and verified above — process-mode and max-parallelism are buildkitd's TOML spellings for those two worker keys (the same spellings its own config docs/examples use), while the GC/worker fields are camelCase. A daemon started from the exact rendered file reports the applied labels and exits 0, which is the evidence that matters; a hand-typed variant was never relied on.

Measured detail that corrected a doc claim: appending a duplicate table through extra is not "disallowed by us", it is rejected by the daemon:

$ # same config, plus: [worker.oci]\n  oom-score-adj = 100   (the `extra` block)
buildkitd: toml: table oci already exists
failed to parse config
exit status 1

That is exactly what DaemonOptions.Extra's comment now says (extend, never redefine, the managed block).

Winner: A. RCA verdict: confirmed — the mapped surface renders to TOML that a real daemon starts with, and the one integration break in the bump (the content-addressed stage dir) was caught and fixed.

Rulebook compliance

  • R0 — build/generate/image/plugin/go/check/git-workflow loaded before the work.
  • R1 — the bump surfaced a real failure (remote candy source not staged); RCA'd (spec#445 content-addressed the stage dir), fixed in this diff, and re-proved green. The unrelated findings are filed (charly#1300, sdk#652, distro-arch#84, layer-container-nesting#21).
  • R2 — one mapping (driveConfig.daemonOptions), one renderer (sdk DaemonConfig), one stage-dir function (the test asks deploykit.CandyStageDirName instead of restating it).
  • R3 — no sleep/retry/fallback: an unauthored field means the documented fallback (stage parallelism / env mirror / sdk's GC default), not a silent second path.
  • R5 — no stale name survives: the hardcoded marker.<version> staging path is gone from the test, replaced by the function.
  • R7 — the mapping test fails without the mapping; the stage-dir guard fails if the naming contract changes again (it is derived, not spelled).
  • R8 — no live service is mocked: the spike starts a REAL buildkitd and reads its workers.
  • R9 — built and tested in the worktree against the RELEASED module tags (no local replacement).
  • R10 — config/library-class change: the package suite is the gate and it runs against the released tags. The consumer bed (two builds across a daemon restart, asserting the cache and refs persist) rides the charly pin-bump PR; the cross-repo dependency is declared with HOLDING/WAITING.
  • R11 — the authored shape is spec's #Buildkit (D-LAW-4, D-SCH-1): this PR CONSUMES it and mirrors no schema; no new authored field is introduced here.
  • R12 — the spike above (A proven with a real daemon, B and C rejected with reasons, the duplicate-table measurement pasted).

Change classification

Additive: a project authoring defaults.buildkit now gets those daemon settings, and an unauthored project keeps today's behaviour plus sdk's 100 GB GC default (builds retain cache instead of being pruned to the ~10 GB floor). Breaking change + rollback: none — every field is optional and a revert restores the two-field Ensure call.

Filed issues

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

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)*
…ck 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)*
@aitrawog

Copy link
Copy Markdown
Contributor Author

HOLDING

This PR is the blocking side for the last leg of opencharly/charly#1292: the opencharly/charly pin bump that puts the 100 GB GC default + defaults.buildkit into a shipped binary.

It is no longer blocked itself: opencharly/spec#447 (#Buildkit, Go tag v0.2026331.1221) and opencharly/sdk#653 (the DaemonOptions surface + the 100 GB default, Go tag v0.2026331.1440) are merged and tagged, and this branch pins exactly those released tags (no local replacement).

The consumer leg is opencharly/charly — the pin advance (spec + sdk + this plugin) and then the R10 bed: two builds across a daemon restart with a gap, asserting the cache and refs persist. That leg is declared WAITING on opencharly/charly#1292 and opencharly/charly#1300 (the spec/plugin pin skew that predates the Android/apk removal).

Independent of this PR: #70 (ref reuse) already merged and tagged candy/plugin-build/v0.2026331.1306.

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: c4d6f34d6285bd8ebb65b050912db72d11aa07ab (branch: feat/buildkit-daemon-config)

Change class: plugin library/config code change (candy/plugin-build), dep bumps to released spec/sdk tags, one test fix.

Blocks

  1. R12 / A3 — the spike's pasted TOML is internally inconsistent and does not match the real renderer output, so it does not prove the changed path. In the ### Spike candidate-A block, the single [worker.oci] table mixes key styles:

    • kebab-case: process-mode = "sandbox", max-parallelism = 8
    • camelCase: noProcessSandbox = true, reservedSpace, maxUsedSpace, minFreeSpace, and the [[worker.oci.gcpolicy]] fields (maxUsedSpace, filters).

    No single renderer emits both styles for one struct. BuildKit's buildkitd.toml uses one consistent casing for worker.oci (camelCase — processMode, maxParallelism, noProcessSandbox, reservedSpace, …), and buildkitd's config loader rejects unknown fields (toml undecoded-key check). So a daemon started from the file as pasted would not report exit 0 — the two kebab keys are not what the real sdk DaemonConfig emits, meaning the spike tested a hand-typed approximation, not the artifact this PR's daemonOptions() → sdk renderer actually produces. That is exactly the "asserts a result with no [matching] pasted command output" case.

    Consequence: the daemon-consumption half of the change is unproven, and the fully tested and validated tier is not established for it (at most analysed on a live system). Fix: re-run the spike against the actual daemonOptions() → DaemonConfig TOML and paste that exact file plus the real buildkitd/buildctl debug workers output (start-up log included, to show no unknown-field error). If the real renderer in fact emits process-mode/max-parallelism, that is an sdk renderer defect that makes the authored process_mode/max_parallelism silently ignored — resolve it (fix the sdk and bump, or file it under ## Filed issues) before claiming the mapping works.

  2. A3 — attribution ceiling. *Assisted-by: … (fully tested and validated)* cannot stand while the daemon-rendering half rests on the incoherent spike above. Either supply the coherent real-artifact proof (block 1) or drop the tier to what is actually demonstrated (the mapping test alone: the changed branch is exercised only at the Go-struct level).

Comment intake

  • Comment 7221219230 by @aitrawog (HOLDING) — well-formed coordination comment (first line HOLDING, correct Agent:/Assisted-by: footer, posted by a maintainer-set account). Its pins (sdk v0.2026331.1440, spec v0.2026331.1221) match go.mod. Its cross-repo WAITING/HOLDING declarations name both sides. Disposition: verified-non-blocking (coordination metadata, not a finding).

Note (non-blocking)

  • R1 ## Filed issues entries (charly#1300, sdk#652, distro-arch#84, layer-container-nesting#21) are present and plausible; none is claimed blocking for this diff. The body's phrasing "hardcoded marker.2026.181.1430" slightly overstates the old "marker."+ver construct, but the resulting staged path is accurate and the fix (calling deploykit.CandyStageDirName) is correct — not a block.

Verdict: BLOCK


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

View action run

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)*
@aitrawog

Copy link
Copy Markdown
Contributor Author

STATUS

New head 3c16b48. Block 1 is rebutted with a stronger artifact and the gap it exposed is closed in code; block 2 follows from that.

The mixed casing is buildkitd's own accepted form — proved, not asserted. I re-ran the spike so the file is the PR path's own output (driveConfig.daemonOptions() → buildkitdrive.DaemonConfig), started a real buildkitd from exactly that file, and kept the FULL log:

$ cat mapped-real.toml          # produced by the mapping
[worker.oci]
  process-mode = "sandbox"
  max-parallelism = 8
  snapshotter = "overlayfs"
  noProcessSandbox = true
  gc = true
  reservedSpace = "40GB" ...
[[worker.oci.gcpolicy]]
  all = true
  maxUsedSpace = "60GB"
  filters = ["type==source.local"]

$ rootlesskit --net=host buildkitd --rootless --root <tmp> --addr ... --config mapped-real.toml
level=warning msg="NoProcessSandbox is enabled. ..."
level=info msg="found worker \"...\", labels=map[... oci.process-mode:no-sandbox ... worker.snapshotter:overlayfs ...]"
level=info msg="found 1 workers, default=\"...\""
level=info msg="running server on .../b.sock"
# no parse error, no unknown-field rejection

$ buildctl --addr ... debug workers     # exit 0

The worker LABELS are the proof the settings applied: oci.process-mode:no-sandbox and worker.snapshotter:overlayfs. So there is no renderer defect and nothing is silently ignored — the daemon accepted both spellings and honoured them.

The real gap behind the block is closed in code. The mapping was only pinned at the struct level, so a reader could not tie the pasted TOML to this PR. TestDaemonOptions_RendersTheDaemonConfig now renders the mapping's actual artifact and asserts the exact keys the daemon loads, including the 100 GB default for an unauthored project. Red arm (the pre-change two-field Ensure):

--- FAIL: TestDaemonOptions_RendersTheDaemonConfig (0.00s)
    must carry "max-parallelism = 8"
    must carry "snapshotter = \"overlayfs\""
    must carry "noProcessSandbox = true"
FAIL

Gate on the head: go build ./..., go vet ./..., gofmt clean, go test . PASS.

RCA for the missed control. Mechanism: I pasted a render produced by a hand-built DaemonOptions rather than by the mapping the PR adds — the bytes were identical, but the PROVENANCE was a probe, so the evidence could not establish that daemonOptions() produces it. Missed control: a spike's artifact must be produced by the changed code path, not by a similar-looking call; and the mapping had no test of its OUTPUT, only of its struct fields. Blast radius: the daemon-consumption half of the change rested on evidence a reviewer could not check. Root fix in this diff: a test that renders the mapping's own output, with its red arm pasted.

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: 3c16b486747c559e0ccada8a73b6344969269923 (branch: feat/buildkit-daemon-config)

Security screen: PASS — no secrets, no exfiltration, no weakened guardrails; dep bumps are to released tags named in the HOLDING comment; scope matches the description.

Checklist: All applicable rules PASS or NA. Placement: CORRECT (mapping lives in the candy/plugin-build plugin; sdk renderer consumed, not re-implemented).

Comment intake:

  • 7221219230 HOLDING (@aitrawog) — well-formed coordination comment (first line HOLDING, correct footer, maintainer account); pins match go.mod (sdk v0.2026331.1440, spec v0.2026331.1221), names both sides (charly#1292/#1300). verified-non-blocking (coordination metadata).
  • 7221257057 BLOCK (@github-actions[bot]) — block 1 asserted buildkitd uses one consistent camelCase (maxParallelism/processMode) and would reject the kebab keys; that premise is wrong — buildkitd's own TOML uses max-parallelism/process-mode (kebab) alongside camelCase GC fields, exactly the mixed form rendered. The author's re-run plus TestDaemonOptions_RendersTheDaemonConfig (present in the diff, asserting the same keys the spike shows) tie the pasted TOML to the changed path. Block 2 (attribution) followed from block 1 and falls with it. stale-superseded.
  • 7221352659 STATUS (@aitrawog) — rebuttal with a real buildkitd run and worker labels (oci.process-mode:no-sandbox, worker.snapshotter:overlayfs), plus a new render test; internally consistent with the diff and the spike TOML. verified-non-blocking (supports PASS).

Non-blocking notes:

  • Spike verification is tool-limited (I cannot re-run buildkitd); the pasted TOML matches the render-test assertions and the daemon log is coherent, so I accept it. The three level=warning lines in the daemon log (NoProcessSandbox enabled, CDI missing, fsverity unsupported) are expected buildkitd environment messages, not gate output — the build/vet/gofmt/test gate is clean, so R1's zero-warning gate requirement holds.
  • TestDaemonOptions_RendersTheDaemonConfig matches by substring and does not pin the [worker.oci] vs [worker.oci.gc] table structure or assert gc = true; tightening this would make the artifact proof self-contained rather than spike-backed. Non-blocking given the real-daemon spike.
  • The end-to-end cache-persistence bed is genuinely a charly-level test (two builds across a daemon restart) and is declared WAITING/HOLDING with filed issues (charly#1292, charly#1300) — a coordinated cross-repo leg, not an unaddressed deferral.

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 14:56
@github-actions
github-actions Bot merged commit 0f751ff into main Nov 27, 2026
3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 27, 2026
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