Skip to content

fix(ensure): pull an external base as written, and never build a box as its own base - #62

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/ensure-external-base
Nov 21, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/ensure-external-base

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

Fixes #61. From clean local storage, every debian- and ubuntu-family box deadlocked on its own image lock: charly box build debian (base: debian:13) and charly box build ubuntu (base: ubuntu:26.04) waited the full 30m on a lock that the same process held, then gave up. There were two defects in candy/plugin-build/ensure.go, and each is fixed at its source:

  1. An external base was never pulled. resolveImageRefPlugin returned "" for a ref that is neither a project box key nor a "full ref" (LooksLikeFullRef requires a slash), so the pull branch was skipped entirely. Now a ref that is not a box of this project is an external image, pulled as written; the engine normalizes debian:13.
  2. A ref was mapped onto a box by leaf name alone. buildableShortNamePlugin turned Docker Hub's debian:13 into the project box debian, which is the box being built. Now a ref maps onto a box only when it names that box: its bare key, or the box's own published repository (registry/name, computed from the config with no local-store probe). ghcr.io/opencharly/fedora:<calver> still builds fedora.

Plus the invariant, stated where the build would start: the ensure path for a box's base carries that box (self), and selfBaseError refuses a fallback onto that same box with a clear error instead of a self-wait. This also holds for a registry-less project, where rule 2 alone cannot tell debian:13 from debian. The build:ensure word passes no self, so its behaviour is unchanged.

file change
candy/plugin-build/ensure.go the pull rule, the naming rule (repositoryOf, publishedRepository), selfBaseError, self threaded
candy/plugin-build/buildkit.go ensureBaseImage passes the box whose base it ensures
candy/plugin-build/ensure_base_resolve_test.go new — the three rules
candy/plugin-build/base_image_test.go the seam signature

How tested

Head 39620228b3fe802e5ad54f98e1f9ac95d5c82fb0; git diff --stat --diff-algorithm=myers origin/main...HEAD: 4 files changed, 152 insertions(+), 19 deletions(-). This repo's gate (AGENTS.md), on that tree (GOTOOLCHAIN=go1.26.8):

$ GOWORK=off go test ./... -count=1      # ok  github.com/opencharly/plugin-build/candy/plugin-build
$ GOWORK=off golangci-lint run ./...     # 0 issues.

Before, with the current binary (2026.324.2014) on a pristine opencharly/distro-debian at eb7dc2c:

$ timeout 150 charly box build debian ; echo rc=$?
ensure-image: base debian:13 is not in local storage — ensuring it (resolve, pull, else build locally)
ensure-image: building debian locally
charly: waiting 30s for file lock …/image-afd901ec796eb462.lock — held by pid 185208 (the same process)
rc=124

The same happened for opencharly/distro-ubuntu (base: ubuntu:26.04).

After, with a worktree-local dev build of charly main plus this branch, on the same pristine tree:

$ charly box build debian ; echo rc=$?
ensure-image: base debian:13 is not in local storage — ensuring it (resolve, pull, else build locally)
ensure-image: pulling debian:13
ensure-image: base debian:13 is now present
… ghcr.io/opencharly/debian:2026.325.0855
rc=0

R7: each rule was reverted by a mutation the harness verified had applied, and its test failed:

$ python3 -I mut.py '<rule>' && GOWORK=off go test . -run 'ExternalImageIsPulled|OnlyARefThatNamesTheBox|CannotBeItsOwnBase' -count=1
  pull rule reverted    -> resolveImageRefPlugin(debian:13) = "", want it pulled as written
  naming rule reverted  -> buildableShortNamePlugin("docker.io/library/debian:13") = "debian", want ""
  self guard reverted   -> selfBaseError = <nil>, want the self-base refusal

Rulebook compliance

  • R0: loaded /charly-build:build, /charly-build:generate, /charly-image:image, /charly-internals:plugin, /charly-internals:git-workflow (this repo's AGENTS.md list), plus /charly-internals:strict-policy, /charly-internals:root-cause-analyzer, /charly-internals:go and /charly-check:check.
  • R1: RCA before the fix. The deadlock was reproduced on the current binary and a pristine tree, so it predates and is independent of the change that surfaced it (build: a skill carrier candy copies .agents/skills from the candy dir, but the bodies live at the repo root sdk#598). The mechanism was read in the code, and both defects are fixed.
  • R2: one mapping rule, one guard; the published-repository derivation reads the same registry fields resolveImageRefPlugin reads.
  • R3: no workaround: the base is not pre-pulled by hand, the lock is not given a shorter timeout, and no box is special-cased.
  • R4: no documented command changes meaning; box build now does what it says for an external base.
  • R5: nothing is replaced; the old leaf-only behaviour has no remaining caller.
  • R6: git status clean; branch fix/ensure-external-base off fresh origin/main; PR-only, no force-push, no hook bypass.
  • R7: each rule is tested and mutation-checked; the changed path ran live (How tested).
  • R8: the pull hit the real registry (Docker Hub); no service is mocked.
  • R9: the live run used a worktree-local dev build stamped 2026.324.2014 from charly main plus this branch; the gate ran on this exact commit.
  • R10: this repo's gate passed on this commit, and the changed path ran live on the box that deadlocked.
  • R11 (D-LAW-3): the ensure behaviour stays in the build plugin; core is untouched. No DESIGN requirement governs the ensure fallback's name mapping, and none is amended.

Change classification

Bug fix in the build plugin's ensure contract, with no wire or schema change. Behaviour change for one input class only: an unqualified external image that shares a project box's leaf name is now pulled, where before it was misbuilt as that box.

Filed issues

none — the defect fixed here is #61 itself.

Closes #61 · found while proving opencharly/sdk#598 (tracking opencharly/opencharly#1201).

https://claude.ai/code/session_01Tvdn3vtn8FoWTMqGwqn4ZT

Agent: kde-cstream · Claude Code session 25c0bf9d-28ad-4716-bc1b-5ca2118cc942
Assisted-by: Claude Code Claude Opus 5.5 (analysed on a live system)

…as its own base

plugin-build#61: from clean storage every debian- and ubuntu-family box deadlocked on its own image lock (`box build debian`, `base: debian:13`). Two defects, both fixed at their source: resolveImageRefPlugin returned "" for a ref that is not a project box, so an external image like debian:13 was never pulled; and buildableShortNamePlugin mapped any ref onto a box by leaf name, so Docker Hub's debian:13 became the box being built. Now an external image is pulled as written, a ref maps onto a box only when it NAMES that box (its bare key or its own published registry/name), and the ensure path for a box's base refuses a fallback onto that same box (selfBaseError — the invariant, which also holds for a registry-less project). Each rule is tested and mutation-checked.

Claude-Session: https://claude.ai/code/session_01Tvdn3vtn8FoWTMqGwqn4ZT

Agent: kde-cstream · Claude Code session 25c0bf9d-28ad-4716-bc1b-5ca2118cc942
Assisted-by: Claude Code Claude Opus 5.5 (analysed on a live system)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 39620228b3fe802e5ad54f98e1f9ac95d5c82fb0 (branch: fix/ensure-external-base)

Security screen: PASS — T1 (rules read from main; no spec/rulebook edit), T2 (no embedded directives; the session URL/Agent:/Assisted-by: footers are coordination metadata, not instructions), T3 (bug fix at source in candy/plugin-build, no secrets/egress/guardrail weakening, no scope mismatch — the 4 files match the body's table), T4 (does not touch security machinery).
Checklist: All applicable rules PASS or NA (A1–A3; R0–R11; ARCH placement: CORRECT — ensure logic stays in the build-plugin candy, core untouched; DISP NA — no autonomous destroy/rebuild; QUAL clean; COORD footer well-formed, 0 comments to disposition).

Verdict: PASS


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

View action run

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.

ensure-image builds a box as its own base (external debian:13 → box debian) and deadlocks on its own image lock

1 participant