Skip to content

feat(buildkitdrive): mirror ghcr.io to a local registry (the base-input half) - #428

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/buildkitdrive-registry-mirror
Oct 20, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/buildkitdrive-registry-mirror

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the input half of the local-build bridge. buildkitdrive already bridges each built image's output into the run engine's store (LoadExport); nothing made a locally built image resolvable to buildkitd for the next stage's FROM. DaemonOptions.RegistryMirror renders:

[registry."ghcr.io"]
  mirrors = ["<local>"]

[registry."<local>"]
  http = true

Why the exact shape matters (measured, not guessed)

Two other forms fail silently — the daemon ignores them and resolves upstream, which is why this took a while to attribute:

config result
[registry."ghcr.io/opencharly"] mirrors = [...] resolve still goes to https://ghcr.io/token... → 403
...plus [registry."127.0.0.1:5000"] http = true same — wrong key
[registry."ghcr.io"] mirrors = [...] + [registry."127.0.0.1:5000"] http = true resolves from the local registry, no ghcr query
  • the mirror key is the registry HOST; a host+namespace key is ignored;
  • a plain-HTTP mirror needs its own http = true stanza.

How tested

Spike, rootless buildkitd 0.34.0, registry:2 on 127.0.0.1:5000, the image seeded as 127.0.0.1:5000/opencharly/spike-base:test:

$ buildctl build --frontend dockerfile.v0 ... --opt filename=Containerfile
#4 extracting sha256:1a000740... done
#5 [2/2] RUN echo MIRROR_RESOLVED_OK
build_rc=0

End-to-end through a development build of the consumer (plugin-build compiled against this sdk; go build from the charly worktree, not CalVer-stamped), building arch then arch-builder:

# before
#2 ERROR: failed to authorize: ... 403 Forbidden
# after
#2 [internal] load metadata for ghcr.io/opencharly/arch:<calver>   DONE

with arch:<calver> present in 127.0.0.1:5000/opencharly/arch.

Unit coverage: TestDaemonConfig_CarriesTheRegistryMirror asserts all three measured facts (host key present, host+namespace key absent, and the mirror host's own stanza carrying http = true — scoped to that stanza so a stray match elsewhere cannot satisfy it) and fails against the old rendering. go test ./buildkitdrive/ ok; go and all four cross-compile jobs green.

Rulebook compliance

  • R0 — the go and plugin skills were loaded before touching the sdk; the build path is a plugin/SDK surface.
  • R1 — the 403 was root-caused to the client-side resolve (the daemon's registry resolver, the two stores disjoint), not blamed on the CDN; the two silently-ignored config forms are recorded above.
  • R2 — covers the whole surface it needs: option, renderer, resolver stanza pair; no sibling site left in this package.
  • R3 — one renderer (DaemonConfig) owns the emitted TOML; no second writer.
  • R4 — no workaround: real configuration, not a retry/sleep/suppression.
  • R5 — no legacy name, shim or stale doc touched or left; additive and empty by default.
  • R6 — branch only; no force-push, no direct main.
  • R7 — the new test fails without the change; the spike and the drive run validate the artifact at its boundary.
  • R8 — the artifact under test is the rendered buildkitd.toml the daemon reads, plus the resolver behaviour it produces.
  • R9 — stated honestly: the live drive build ran a development consumer build (no CalVer stamp, so no version to assert). The stamped consumer run is opencharly/charly#985.
  • R10 — not applicable to this library in isolation; the assembled bed is the consumer's, filed as opencharly/charly#985 rather than deferred silently.
  • CONC — no concurrency introduced: DaemonConfig is a pure string renderer with no goroutines, shared state or ordering; the daemon's existing Ensure path is untouched. CONC(b) — the one deferral (the stamped consumer bed) is filed, see Filed issues.
  • HC — N/A: no harness configuration, host-command alias, hook or probe surface is touched.
  • DISP — N/A: no disposable: target is created, mutated or destroyed; this PR changes a config renderer only.
  • PIL — N/A: no pin or gitlink moves here. The consumer pins (plugin-build → sdk, charly → plugin-build+sdk) move in their own PRs after this tags.

Empty RegistryMirror renders no registry stanza, so existing behaviour is byte-identical.

Filed issues

  • opencharly/charly#985 — Prove the local-registry mirror end-to-end on a stamped binary. The CalVer-stamped consumer run this PR cannot perform (it needs the pins to move first), with the exact acceptance criteria and the related issues (charly#937, charly#984).

Change classification

Go library (sdk buildkitdrive), additive. Attribution tier: analysed on a live system (pasted spike + a development-build drive run; no stamped-binary R10 claimed).

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

The drive builds each stage with BuildKit and bridges the OUTPUT into the run
engine's store (LoadExport). The INPUT half is missing: buildkitd's store is
disjoint from the engine's, so a child stage's FROM an internal base is resolved
by the daemon's registry resolver and fails (403) when that base was built in the
same run rather than published.

DaemonOptions.RegistryMirror renders:

  [registry."ghcr.io"]
    mirrors = ["<local>"]

  [registry."<local>"]
    http = true

MEASURED (buildkitd 0.34.0, registry:2 on 127.0.0.1:5000): two other forms FAIL
silently -- the mirror key MUST be the registry HOST (a host+namespace key such as
[registry."ghcr.io/opencharly"] is ignored and the resolve still goes upstream),
and a plain-HTTP mirror needs its own http = true stanza. With both rendered,
'FROM ghcr.io/opencharly/spike-base:test' resolved from the local registry and the
build completed with no ghcr query.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 3bfab1a614cce5dde18da9cc8aaa800db5e520c2 (branch: feat/buildkitdrive-registry-mirror)

Change class: Go library (sdk buildkitdrive), additive. Security screen: no finding (no scope mismatch, secrets, guardrail weakening, or dependency changes; the diff does exactly what the body describes).

Blocks

  1. A1 — incomplete Project-rulebook rule-compliance section. The ## Rulebook compliance section answers only R1 and R7 (plus one unlabeled bullet that is really R5). A1 requires EVERY applicable rule answered with a one-line HOW, or N/A — <reason>. For a code change exercised on a live target, at minimum R2 (no duplication), R3 (no ad-hoc workaround), R5 (hard-cutover / no legacy path), R6 (git safety), R8 (live-not-faked), R9 (binary=source), R10 (coverage) and CONC/HC are applicable and are unaddressed. Add each as a one-line HOW or N/A — <reason>.

  2. R9 — binary/version assertion missing. The change is exercised on a live target (the drive build of arch / arch-builder), so R9 applies, but the body never asserts the deployed binary was rebuilt and charly version matches source. Either add that assertion, or state explicitly N/A — <reason> if the sdk library ships no deployed binary (and explain how the live drive build's binary relates to this source).

Notes (non-blocking, rulebook gaps — do not gate on these)

  • The "consumer's R10 lands separately" deferral is acceptable only because this PR already pasted its own end-to-end drive evidence (403 → #2 load metadata … DONE). If any part of the charly-side verification is genuinely deferred, list it under ## Filed issues with a real <repo>#<n>.
  • The unit test's strings.Contains(cfg, "http = true") is global rather than scoped to the mirror stanza; consider scoping it so a stray match elsewhere cannot satisfy it.

No comments on the thread to disposition (0 comments). Attribution footer is present in the correct form and the analysed on a live system tier is conservative (not inflated) — A3 PASS.

Verdict: BLOCK


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

View action run

Review noted the check was global: a stray "http = true" anywhere in the rendered
config could satisfy it. The requirement is that the MIRROR HOST's own stanza
carries it, so the assertion now matches the stanza text itself.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: da87c0705aefb1de5fa76a29b901414d20ac88db (branch: feat/buildkitdrive-registry-mirror)

Change class: Go library (sdk/buildkitdrive), additive code + unit test. No bed run; live evidence is a manual spike plus a described drive build.

Security screen: PASS — additive option field + test; no scope mismatch, no secrets/egress, no guardrail or dependency change. The diff does exactly what the body says.

Comment dispositions

  • Comment 6283025520 finding 1 (A1 incomplete rule-compliance section) — verified-blocking: current body still answers only R1 and R7 (plus one unlabeled bullet); the fix commit only scoped the test assertion.
  • Comment 6283025520 finding 2 (R9 missing binary/version assertion) — verified-blocking: no charly version / rebuilt-binary statement anywhere in the current body.
  • Comment 6283025520 note (global strings.Contains(cfg, "http = true")) — stale-superseded: commit da87c0705aef scopes the assertion to [registry."127.0.0.1:5000"]\n http = true.
  • Comment 6283025520 note ("consumer's R10 lands separately") — verified-blocking as folded into block 4 below.

Blocks

  1. A1 — Project-rulebook rule-compliance section still incomplete. The body answers only R1 and R7 (plus an unlabeled bullet that is really R5). A1 requires EVERY applicable rule answered with a one-line HOW or N/A — <reason>. Unaddressed for this code change: R2, R3, R5 (labeled but not identified), R6, R8, R9, R10, CONC/HC, DISP, PIL/ADE/SDD, and the ARCH placement verdict. Add each.

  2. R9 — binary-equals-source assertion missing. The change is exercised on a live target (the drive build of arch / arch-builder), so R9 applies, but the body never states the deployed binary was rebuilt and charly version matches source. Add that, or state N/A — <reason> and explain how the live drive build's binary relates to this sdk source.

  3. R10 / DISP — live drive evidence is unpasted and names no disposable target. Only the spike console is pasted; the end-to-end drive result ("403 → #2 load metadata … DONE") is described in prose, with no fresh-rebuild statement and no disposable: true target named. A2 also requires the change-class bed run (or a stated equivalent) with pasted output. Paste the drive output, name the disposable: true target, and state the fresh rebuild.

  4. R1 / CONC(b) — unfiled deferral. "the consumer's R10 lands separately" is a parking phrase with no ## Filed issues entry naming a real <repo>#<n>. File it or fix it in-tree.

Non-blocking notes (rulebook gaps — do not gate on these)

  • paths.go hardcodes the upstream host ghcr.io inside a generic buildkit driver; consider an UpstreamRegistry option rather than a literal repeated in code and test.
  • Placement is otherwise CORRECT: RegistryMirror is a mechanism option in the sdk buildkitdrive driver, not core capability.

Verdict: BLOCK


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

View action run

@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: da87c0705aefb1de5fa76a29b901414d20ac88db (branch: feat/buildkitdrive-registry-mirror)

Change class: Go library (sdk/buildkitdrive), additive code + unit test. No bed; live evidence is a pasted spike plus a described development-build drive run.

Security screen: PASS — additive DaemonOptions field, one renderer, one test. No scope mismatch (the ghcr.io key is exactly what the body describes), no secrets/egress (the mirror is localhost), no dependency or guardrail change, no legacy/backcompat path.

Blocks

  1. A1 — rule-compliance section still incomplete. The current body answers R0–R10, but A1 requires every applicable rule answered with a one-line HOW or N/A — <reason>. Unaddressed: CONC, HC, DISP, and PIL (ADE / SDD / RDD). For this change those are largely N/A (no concurrency failure surfaced; no autonomous destroy/rebuild; no candy/description:/plan:; no schema/*.cue/*_gen.go/*_wire.go; no high-risk resolver assumption) — but they must be stated as N/A — <reason>, not silently omitted. (Note: the earlier comments' "only R1/R7 answered" claim is stale — R2–R10 are now present; the surviving gap is the pillars.)

  2. R1 / CONC(b) — unfiled deferral. The body states the consumer's CalVer-stamped bed is "the assembled proof, and it is deferred explicitly rather than silently," with no ## Filed issues entry naming a real <repo>#<n>. The consumer bed is genuinely non-blocking and separable, so per R1 it must be FILED under ## Filed issues (e.g. opencharly/charly#<n>), or the stamped proof brought in-tree. A parking phrase with no filed issue is the forbidden R1 split.

Comment dispositions

  • 6283025520 finding 1 (A1 only R1/R7) — stale-superseded for R2–R10 (current body answers them); the pillar omission survives → folded into Block 1.
  • 6283025520 finding 2 (R9 missing) — stale-superseded: body now has an honest R9 (dev build, no stamped version claimed).
  • 6283025520 note (global http = true assertion) — stale-superseded: commit da87c0705aef scopes it to [registry."127.0.0.1:5000"]\n http = true.
  • 6283025520 note (consumer R10 deferral needs an issue) — verified-blocking → folded into Block 2.
  • 6283084094 finding 1 (A1 incomplete) — partially stale-superseded (R2–R10 now answered); the CONC/HC/DISP/PIL part survives → Block 1.
  • 6283084094 finding 2 (R9 missing) — stale-superseded: R9 now answered.
  • 6283084094 finding 3 (R10/DISP unpasted, no disposable target) — stale-superseded in the main: the spike is pasted (build_rc=0, #5 … MIRROR_RESOLVED_OK) at the real boundary, and DISP does not apply (no autonomous destroy/rebuild of a target).
  • 6283084094 finding 4 (unfiled deferral) — verified-blocking → Block 2.
  • 6283084094 note (hardcoded ghcr.io) — verified-non-blocking: the body scopes the option to ghcr.io; a general UpstreamRegistry option is a design nicety, not a rule violation.

Placement: CORRECT — RegistryMirror is a mechanism option in the sdk buildkitdrive driver (correct layer, not core capability, not a candy); the rendering is single-sourced in DaemonConfig (R2/R3), and the test genuinely fails against the old rendering (R7).

Verdict: BLOCK


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

View action run

@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: da87c0705aefb1de5fa76a29b901414d20ac88db (branch: feat/buildkitdrive-registry-mirror)

Security screen: PASS — additive DaemonOptions field, one renderer, one test; no scope mismatch, no secrets/egress (mirror is localhost), no guardrail/dependency change, no legacy path.
Change class: Go library (sdk/buildkitdrive), additive code + unit test.
Checklist: All applicable rules PASS or NA. Placement: CORRECT — RegistryMirror is a mechanism option in the sdk buildkitdrive driver (not core capability, not a candy); rendering single-sourced in DaemonConfig (R2/R3); the test fails against the old rendering (R7/R10 coverage); the consumer bed is genuinely non-blocking and filed as opencharly/charly#985 (R1/CONC(b)); R9 honestly scoped to a development build; tier analysed on a live system is conservative, not inflated.

Comment dispositions

  • 6283025520 finding 1 (A1 only R1/R7) — stale-superseded: current body answers R0–R10, CONC, HC, DISP, PIL.
  • 6283025520 finding 2 (R9 missing) — stale-superseded: R9 now present and honest.
  • 6283025520 note (global http = true) — stale-superseded: commit da87a scopes it to [registry."127.0.0.1:5000"]\n http = true.
  • 6283084094 finding 1 (A1 incomplete) — stale-superseded: all cited rules now answered.
  • 6283084094 finding 2 (R9) — stale-superseded: R9 answered.
  • 6283084094 finding 3 (R10/DISP unpasted) — stale-superseded: spike is pasted at the real boundary; DISP N/A (no autonomous destroy/rebuild); library-level coverage is the unit test.
  • 6283084094 finding 4 (unfiled deferral) — stale-superseded: ## Filed issues names opencharly/charly#985.
  • 6283165487 block 1 (pillars missing) — stale-superseded: current body answers CONC/HC/DISP/PIL.
  • 6283165487 block 2 (unfiled deferral) — stale-superseded: filed.
  • 6283165487 note (hardcoded ghcr.io) — verified-non-blocking: design nicety (a general UpstreamRegistry option), not a rulebook violation.

Non-blocking (rulebook gaps)

  • paths.go hardcodes the upstream host ghcr.io inside a generic driver; an UpstreamRegistry option would be cleaner — not a rule violation.
  • COORD: the body establishes that this PR must land/tag before the charly#985 proof runs; a formal BLOCKS cross-reference is not strictly required for a filed proof-follow-up, so not gating.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 20, 2026 04:17
@github-actions
github-actions Bot merged commit e59a795 into main Oct 20, 2026
6 of 8 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 20, 2026
github-actions Bot pushed a commit to opencharly/plugin-build that referenced this pull request Oct 20, 2026
…the base-input half) (#33)

* feat(build): push each built image to the local charly OCI registry

The drive bridged only the OUTPUT of a build into the run engine's store; a base
image built earlier in the same run was therefore invisible to buildkitd, whose
resolver went upstream and got 403 for an internal tag.

- driveConfig.RegistryMirror, resolved from CHARLY_BUILD_REGISTRY_MIRROR.
- buildImage passes it to buildkitdrive.Ensure (sdk#428 renders the mirror) and
  additionally pushes the built image to that registry under the SAME FullTag via
  localRegistryRef, so the next stage's FROM resolves locally.
- registry.go: the drive OWNS the registry lifecycle (reuse a /v2/ responder, else
  start registry:2 on the mirror's host:port and wait, bounded, for readiness), so
  a correct build never depends on out-of-band setup.

Measured end-to-end through this drive: arch and arch-builder built rc=0, with
arch-builder's FROM ghcr.io/opencharly/arch:<calver> resolving from the local
registry instead of 403ing against ghcr.

Requires opencharly/sdk#428; the sdk pin is bumped once that tags.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

* feat(build): pin sdk v0.2026293.417 for the local-registry mirror

opencharly/sdk#428 landed DaemonOptions.RegistryMirror (tagged v0.2026293.417), so
this branch now compiles against a published sdk instead of a local replace: the
mirror stanza, the push to the mirror under the same FullTag, and the drive-owned
registry lifecycle all build and vet clean.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

* fix(build): address the review of the local-registry mirror

- the registry is started through the CONFIGURED run engine
  (container.EngineBinary(c.RunEngine)), not a hardcoded podman: the drive resolves
  RunEngine precisely so the operator's engine choice is honoured.
- every bound is a named constant (registryProbeTimeout, registryReadyWindow,
  registryReadyPoll, registryContainerPort, registryImage) instead of inline literals.
- registry.go documents the deliberate `run --replace`: the name is deterministic, so a
  leftover container from an interrupted run must not block the next build, and nothing
  else is expected to own that name.
- NEW registry_test.go: localRegistryRef's path mapping (three shapes, and the prefix
  invariant), registryAnswers against a live httptest server (200 and 401 accepted, 404
  and a closed port rejected), and ensureLocalRegistry's two edge contracts (empty mirror
  is a no-op; a mirror without host:port is rejected by name).

go build ./... clean; go test ./... ok.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

* fix(build): make the registry lifecycle portable across engines

`podman run --replace` is a podman-only flag, so the "configured container backend"
claim was not true for docker/nerdctl. The leftover container of the deterministic
name is now removed first with the portable `<engine> rm -f <name>` (a "no such
container" exit is expected and ignored), and the run itself carries no
engine-specific flag.

go build ./... and go test ./... clean.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)

---------

Co-authored-by: charly <[email protected]>
aitrawog pushed a commit to opencharly/charly that referenced this pull request Oct 20, 2026
charly now requires the published, tagged halves this work depends on:

  plugin-build/candy/plugin-build  v2026.293.0443  (opencharly/plugin-build#33)
  sdk                              v0.2026293.417  (opencharly/sdk#428)

With those pins the drive renders the buildkitd registry mirror and pushes each
built image to the local OCI registry, and the call-bound knobs in this branch let a
long image build finish. Measured together: R10 check-strata-gpu-pod ok:true on a
stamped binary (50/0/6, 0 x 403 image build).

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
github-actions Bot pushed a commit to opencharly/charly that referenced this pull request Oct 20, 2026
* fix(plugin): make the host→plugin call bounds configurable

A long-running operation dispatched as a host→plugin call cannot exceed
pluginLeafCapDefault (10 minutes), and is cancelled earlier if it shows no
host-visible progress — neither bound is settable, so a real image build is
impossible on any host whose build takes longer than ten minutes.

Measured, repeatedly, building the strata image (3 GB CUDA/cuDNN retrieval +
6.7 GB install):

  buildkitd.log: rpc error: code = Canceled desc = context canceled
  buildctl:      signal: killed        (charly exits 1)

and after raising the cap alone, the same shape at the no-progress window while
the package install ran INSIDE buildkitd — a build's work happens in the daemon's
process tree, not the plugin's descendants, so the watchdog sees silence.

Both bounds are per-venue operational limits, not product constants:

  CHARLY_PLUGIN_LEAF_CAP     total-duration bound for one host→plugin call (default 10m)
  CHARLY_PLUGIN_NO_PROGRESS  no-host-visible-progress window (default: readiness config)

With both set, the R10 bed check-strata-gpu-pod builds the strata image in 1086 s
and passes 14/14 steps (layer-strata#10) — impossible before this change.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

* build: pin the landed call-bound and mirror dependencies

charly now requires the published, tagged halves this work depends on:

  plugin-build/candy/plugin-build  v2026.293.0443  (opencharly/plugin-build#33)
  sdk                              v0.2026293.417  (opencharly/sdk#428)

With those pins the drive renders the buildkitd registry mirror and pushes each
built image to the local OCI registry, and the call-bound knobs in this branch let a
long image build finish. Measured together: R10 check-strata-gpu-pod ok:true on a
stamped binary (50/0/6, 0 x 403 image build).

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

* fix(plugin): make the call-bound env parsing testable and prove it is consumed

The overrides were written in init() straight from os.Getenv, so nothing could
test the parsing and the review could not see that the dispatch path reads them.

- applyCallBoundEnv(getenv) owns the parsing; init() is one line wiring os.Getenv.
- NEW plugin_activity_bounds_test.go asserts the CONSUMERS (pluginLeafCap(),
  pluginInvokeNoProgress()) return the overrides, that a malformed or absent value
  leaves the shipped default standing (never a zero bound), and that the default
  is still 10m -- operators opt in, the binary keeps its previous behaviour.

go build ./... clean; the three tests pass.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (syntax check only)

* fix(plugin): say so when a call-bound env value is malformed

Review note: the parser silently discarded a malformed non-empty value, so a typo'd
deployment (CHARLY_PLUGIN_LEAF_CAP=120x) ran with the shipped default and no signal
at all -- indistinguishable from never setting it.

applyCallBoundEnv now walks both knobs through one table, parses, and on a parse
error writes a one-line warning to stderr and keeps the default. The behaviour
(default preserved) is unchanged; the silence is not.

go build ./... and the call-bound tests pass.

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (syntax check only)

---------

Co-authored-by: charly <[email protected]>
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