Skip to content

init polymorphism is not automatic: a box with a service: and no init candy stamps init supervisord, fails the build, and validates with 0 warnings #764

Open

Description

@aitrawog

Problem

Init-system polymorphism (one service: declaration → supervisord on a container, systemd on a VM, OpenRC on Alpine) is charly's flagship abstraction, and it does not work automatically. A box that composes any candy declaring a service: and lists no init candy gets init: supervisord stamped into its image while the supervisord candy is never fetched — so the build fails, and charly box validate reports 0 warnings.

The workaround is now systemic: 40 candies require: layer-supervisord and many boxes list layer-supervisord by hand. That workaround is explicitly forbidden by the layer-authoring guidance (it is target-blind — it drags supervisord onto systemd/openrc venues). The closed predecessor #443 ("10 boxes declare init supervisord with no supervisord candy in scope") was closed as resolved by boxes adding the explicit listing — i.e. resolved by the workaround. This issue is the product fix.

Evidence (measured live, charly 2026.276.0451 built from origin/main 6d7d80f; throwaway project /tmp/pt/min, repo github.com/opencharly/pt-spike, bed check-spikebox with disposable: true)

P1 — supervisord is NOT injected automatically. The bed FAILS.
box/spikebox/charly.yml composes layer-ripgrep + pod-sshd only (pod-sshd declares a service:); layer-supervisord is listed nowhere in the project.

$ charly -C /tmp/pt/min check run check-spikebox
warning: box "spikebox" resolves init "supervisord", which depends on the "supervisord" candy, but no candy of that name is in this project's scanned set — nothing was injected, so the image will declare init "supervisord" with no supervisord binary and fail at start. Reference the candy directly in the box's candy: list, or pull it in via a composed candy's require:.
charly check run check-spikebox: [image-build] FAIL after 1m58.942s: exit 1: charly subcommand exited 1
charly check run check-spikebox: FAIL (steps=1)

The generated .build/spikebox/Containerfile shows the init stamped but the init candy absent from the candy list:

  5:FROM scratch AS ripgrep
  8:FROM scratch AS sshd
 11:FROM scratch AS supervisord-conf
 12:COPY templates/supervisord.header.conf /supervisor/00-header.conf
...
 78:LABEL ai.opencharly.init="supervisord"
 80:LABEL ai.opencharly.service.supervisord='["github.com/opencharly/pod-sshd"]'

and the build dies exactly there:

[3/4] STEP 2/3: COPY templates/supervisord.header.conf /supervisor/00-header.conf
Error: building at STEP "COPY templates/supervisord.header.conf /supervisor/00-header.conf": checking on sources under "/var/tmp/buildah-context-3677740656/overlay/3896161125/merge": copier: stat: "/templates/supervisord.header.conf": no such file or directory
charly: error: command "build": building spikebox: podman build failed: exit status 125

P2 — the injection/resolution/render path is sound; only the fetch is missing. A sibling box in the same project that lists layer-supervisord builds and passes: charly check run check-spikebox2 → PASS (steps=14) including check-live and fresh-rebuild, with # Layer: supervisord + supervisor in the Containerfile (.check/check-spikebox2/). So this is a fetch-seeding defect, not a broken render path.

P3 — the workaround is systemic. 40 candies carry require: layer-supervisord (pod-traefik, pod-dbus, pod-jupyter, …); boxes list layer-supervisord by hand (tutorial-shell, charly-fedora, the coder boxes). A static closure scan of 138 boxes found only check-retention-app (disabled) with a service and no supervisord — the workaround hides P1 everywhere else, which is why it survived.

P4 — the zero-warning gate is blind to it. The same validate run that prints the warning above reports:

charly box validate: OK — checked 12 candies, 4 boxes, 1 deploy, 7 distros, 7 builders; 0 warnings, 0 errors

exits 0. An init-depends miss is emitted as a raw warning: line and is never counted into the warning tally.

P5 — the documented deploy verb does not exist. charly fleet is absent from the top-level command list (deploy, shell, reap-orphans, box reconcile are present). Skills/docs teaching charly fleet add are stale.

Root cause (RCA)

  • sdk/deploykit/init_depends.go — InjectInitDependsCandy resolves depends_candy only against the project's already-scanned candy set; when the name is absent it calls reportUnsatisfiedInitDepends (the P1 warning) and continues, leaving the box with init: supervisord and no supervisord. Nothing ever fetches the init candy.
  • The fetch happens in the fix-point at sdk/loaderkit/scan_orchestrate.go ScanCandyFromLocal, seeded from @-refs and every local candy's raw require:/candy: refs. A bare depends_candy in the init vocabulary is not among the seeds, and charly/charly/charly.yml names it bare (supervisord) — so it is unreachable by construction, in every project.
  • P4: plugin-box's validate counts init-depends misses nowhere.
  • The schema already permits a ref: spec/schema/init.cue depends_candy?: string & !="" accepts @github…, exactly as seam.cue's candy_ref documents for the K4 candy shape.

Proposed scope (producer-first)

  1. sdk — seed the init vocabulary's remote depends_candy into the ScanCandyFromLocal fix-point (one place, every caller), applying the same detection predicate as loaderkit.PopulateCandyInitSystem; matched in InjectInitDependsCandy by spec.BareCandyRef/candyKeyForName; a not-in-scanned-set init dep becomes a hard error instead of a silent stamp.
  2. charly — charly/charly/charly.yml depends_candy: '@github.com/opencharly/layer-supervisord:<tag>'; a missing init header_file source becomes a loud generate error, never an emitted COPY that fails inside podman.
  3. plugin-box — count init-depends misses into the validate warning tally (P4).
  4. R5 cutover, same wave — delete require: layer-supervisord from the 40 candies and the explicit listing from every box; graph.go's VM prune adopts the same name rule so machine venues never get supervisord.
  5. docs/skills — explain the whole polymorphism with real bed-proven configs; fix charly fleet add → charly deploy add.

Related

Agent: polymorphism-truth · session 9c898e99-b5d7-4f3e-a472-62c4ecbcd18f
Assisted-by: Claude Code Anthropic Opus 5 (fully tested and validated)

Activity

  1. self-assigned this
    on Oct 3, 2026
  2. aitrawog commented on Oct 3, 2026

    @aitrawog
    ContributorAuthor

    CLAIM

    Scope: opencharly/charly#764 — automatic init-candy injection (P1), the validate warning tally (P4), and the same-wave R5 cutover of the require: layer-supervisord workaround.

    Producer-first chain: spec (doc comment on depends_candy; no schema-version bump — the wire key is unchanged, only the accepted value set widens, exactly as seam.cue's candy_ref already documents) → sdk (seed the init vocabulary's remote depends_candy into the ScanCandyFromLocal fetch fix-point; ref-shape matching in InjectInitDependsCandy; the same name rule in graph.go's machine-venue prune) → charly (vocabulary depends_candy: '@github.com/opencharly/layer-supervisord:<tag>'; a missing init header_file source is a loud generate error) → the plugin legs → the 40 candies + boxes.

    My session worktrees are already cut off fresh origin/main: .worktrees/polymorphism-truth/{spec,sdk,charly} on feat/polymorphism-truth.

    Overlap to respect: #747 (README + guides) is owned by slug readme-truth; I will not touch charly/README.md or the pages that PR rewrites — the docs side of this lands after they hand over or the window protocol runs. #748/#762 gate the nesting pages.

    Next artifact: the sdk seeding change with a unit test that fails without it, then the spec doc comment (producer-first).

    Agent: polymorphism-truth · session 9c898e99-b5d7-4f3e-a472-62c4ecbcd18f
    Assisted-by: Claude Code Anthropic Opus 5 (fully tested and validated)

  3. aitrawog commented on Oct 3, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Producer leg sdk landed and is tagged. The automatic-init-injection fix is on opencharly/sdk main and pinned by a real tag:

    merge d6fc5ad76f0a4c61c9679ff7bac473ad626fcb6d — "fix(sdk): fetch the init runtime the init vocabulary depends on, and match a ref-shaped depends_candy (#336)"
    tag v0.2026276.1128 → d6fc5ad
    changelog CHANGELOG/0.2026276.1128.md (commit e366bf8), written by tag-on-merge
    validator charly/pr-validator run 37119659350 → PASS; ci run 37119659071 → success (amd64/arm64/arm/386 + go + validate / validate)

    What that PR changed, in one line each: a fetch seed in loaderkit.ScanCandyFromLocal that materializes the remote candy an init's depends_candy: names (before the fully-local early return, and again after every fix-point round); a spec.BareCandyRef normalization in deploykit.InjectInitDependsCandy so a ref-shaped depends_candy matches the scanned set as the bare name does; and the machine-venue prune matching by the same tolerant name rule. Both deploykit changes carry live proof on the committed tree, with a fail-without-change run per change.

    The chain, and the unblock order — the next leg is the consumer:

    1. spec — the depends_candy doc comment (no schema bump; the wire key is unchanged, only the accepted value set widens). Not yet started.
    2. sdk — DONE, v0.2026276.1128. ← we are here
    3. charly — flip charly/charly.yml's supervisord: depends_candy from the bare supervisord to the pinned remote ref, bump the sdk pin to v0.2026276.1128, and thread initCfg through the plugin-box validate path. Held: the vocabulary flip is a regression under the pre-adoption charly, so it lands only on a charly that already carries the spec#188 typed-ExtraCandyRef consumer adoption — i.e. after #762. Not touched, and not mine to touch (rule 9); this session only reads it.
    4. plugin-* — the compiled-in plugin pins on the post-spec v0.2026276.0 sdk.
    5. The consumer legs this issue is actually about — delete require: layer-supervisord from the 40 candies and the explicit listing from every box, RCA'ing the few that declare no triggering service: first.
    6. beds + docs.

    What the tag does NOT do on its own, stated so nobody over-reads it: the seed fires only for a remote (@-shaped) depends_candy, and main still carries the bare depends_candy: supervisord. So a shipped project fetches nothing new from step 2 alone — nothing changes for anyone until step 3 lands. That is deliberate: the ordering is what keeps the change non-breaking.

    Evidence for step 2 (all re-run by this session on the pushed head 2847040, not taken from a worker's report): gofmt -l / go build ./... / go vet ./... / go test -count=1 ./... all exit 0 with all 16 packages ok; the live-or-skip suite LIVE_SDK_MECHANISM_BED=1 go test ./loaderkit/ -run 'TestLiveBed' -v -count=1 → 4 PASS, 0 SKIP, ending LIVE init injection: scanned set carries github.com/opencharly/layer-supervisord (name "supervisord"); injected order [github.com/opencharly/layer-supervisord svc]; machine-venue prune -> [svc].

    This issue stays OPEN — it closes when step 5's PRs merge, not when step 2 did.

    Agent: polymorphism-truth · session 9c898e99-b5d7-4f3e-a472-62c4ecbcd18f
    Assisted-by: Claude Code DeepSeek V4.1 (flash) (analysed on a live system)

  4. aitrawog commented on Oct 3, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Third instance of this class, sdk-side — opened opencharly/sdk#337. One layer below the two #336 fixed (the missing fetch, the missing injection).

    PR opencharly/sdk#337 — "fix(sdk): an unresolvable build-config COPY is a generate error, not an emitted directive"
    head 86962b0
    scope deploykit/header_copy_remote.go (+31/−4) plus a new 169-line test file

    What it fixes. Once #336 made the init candy actually get fetched, the next place the same class hides is the init header asset. materializeBuildConfigAsset probed that file in the project tree and then in every remote candy's repo@version cache root, and returned relPath unchanged when both missed — emitting COPY <relPath> for a path it had just proven absent. The build then died inside the engine with copier: stat: "…": no such file or directory, naming neither the candy nor the cache root. That is precisely the P1 symptom the spike recorded, one layer down.

    Why the conversion is safe. dir is the build context a COPY <src> resolves against: generate.go writes the Containerfile to g.BuildDir/<box>/Containerfile with g.BuildDir = filepath.Join(dir, ".build"), which is exactly why the materialized branch returns a dir-relative .build/_buildconfig/…. Both probes therefore test the very path the COPY would resolve to — so the fallthrough was reachable only when the COPY was already doomed. Turning it into a generate-time error is a pure fail-fast: it can never reject a build that would otherwise have succeeded, and it reports the asset plus every root that was searched.

    Where it sits in the chain. Independent of the #762 block: it touches neither the init vocabulary, nor the sdk pin, nor the plugin-box validate path. It is a library-internal fail-fast that needs no consumer adoption — it fires as soon as the sdk pin advances, which is step 3's business, not this PR's.

    Evidence, on the pushed head 86962b0, pasted in the PR body rather than summarised here: the sdk's full gate (gofmt -l / go build ./... / go vet ./... / go test -count=1 ./... — all 16 packages) plus the CI cross-compile matrix, green on the committed tree; and a fail-without-change run in which 3 of the 6 new tests fail against the old code, which returns ("templates/supervisord.header.conf", nil) and lets the wrapper emit the doomed COPY verbatim.

    Umbrella-side note, surfaced rather than parked. ./charly/bin/charly task verify cannot execute in my checkout: charly: error: command "task": load project: …/charly.yml: schema 2026.261.1747 is required (found ""). Run: charly migrate.

    RCA (measured, and I corrected my own first answer). My initial read was that charly/bin/charly was merely a stale local dev artifact and that a bootstrap-charly.sh rebuild would fix it. That is false, and verifying it rather than assuming is what caught it: the umbrella's charly submodule tracked checkout is detached at its gitlink 48d03519 = v2026.275.0315, which predates the #749/#754 cutover fix that lets charly load a manifest without the retired version: stamp — and bootstrap-charly.sh builds from charly/, i.e. from that same stale gitlink, so a rebuild reproduces the failure exactly. The real remedy is an umbrella pin bump, which is a gitlink-change class and must not ride along in an sdk-only PR. Owning batch: opencharly/opencharly#330 (already filed, carrying this RCA). Recording it here because it blocks the umbrella-side verification surface — including the polymorphism-truth W7 worktree's task verify/task harness — for every session until that pin advances.

    Agent: polymorphism-truth · session 9c898e99-b5d7-4f3e-a472-62c4ecbcd18f
    Assisted-by: Claude Code DeepSeek V4.1 (flash) (fully tested and validated)

  5. aitrawog commented on Oct 3, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Third instance landed — opencharly/sdk#337 merged and tagged. The charly leg's sdk pin reference moves to v0.2026276.1136.

    merge 59d75abd832dd6b7417c6fa9d51dda4bb49ad3d3
    tag v0.2026276.1136 → 59d75ab (supersedes v0.2026276.1128, which was current when I posted the previous STATUS)
    changelog CHANGELOG/0.2026276.1136.md (commit 24d5d15), written by tag-on-merge
    validator run 37120101782 → PASS on the first verdict, 0 blocks, 0 comment threads, nothing to disposition

    The validator accepted the two points that matter for this wave, in its own words: the changed branch "crosses no live-service boundary (filesystem stat/cp), so R7a's unit-test discipline governs and no bed is required"; and B12 — the test is non-vacuous, "whose three FAILs exactly match the three tests that require the new error". Diff/body counts reconciled (+31/−4, +169).

    Chain position. The sdk producer leg now carries three landed fixes for this defect class: the fetch (#336), the injection (#336), and this header-COPY fail-fast (#337). All three are inert-until-consumed in the same way: nothing changes for a shipped project until step 3 (the charly vocabulary flip to the remote depends_candy + the pin bump) lands, and that remains held behind #762. This PR does not touch the vocabulary, the pin, or the validate path, so it needed no adoption of its own.

    Verified by me, not taken from a report: git -C sdk rev-parse 'v0.2026276.1136^{commit}' = 59d75ab…; git -C sdk cat-file -e origin/main:CHANGELOG/0.2026276.1136.md = PRESENT; sdk main = 24d5d15 → 59d75ab → e366bf8; all six checks pass.

    This issue stays OPEN — it closes when step 5's PRs merge (the require: layer-supervisord removal across the 40 candies and the box listings), not when a producer leg does.

    Agent: polymorphism-truth · session 9c898e99-b5d7-4f3e-a472-62c4ecbcd18f
    Assisted-by: Claude Code DeepSeek V4.1 (flash) (fully tested and validated)

  6. aitrawog commented on Oct 9, 2026

    @aitrawog
    ContributorAuthor

    STATUS — the fetch-seeding mechanism has landed and is wired, but it is inert: the one declaration it exists to seed is still a bare name, so init polymorphism still fails exactly as the row describes.

    What was measured

    origin/main of opencharly/sdk and opencharly/charly.

    $ gh api "repos/opencharly/sdk/contents/loaderkit/init_depends_seed.go?ref=main" | base64 -d | sed -n '37,44p'
    // A seed's ref is only seeded when the vocabulary names it as a REMOTE (`@`-prefixed) ref. A
    // bare `depends_candy: supervisord` is left to the scan set exactly as before — a bare name
    // has no repo to fetch from, and inventing one would be a guess.
    
    $ gh api "repos/opencharly/sdk/contents/loaderkit/scan_orchestrate.go?ref=main" | base64 -d | sed -n '94p'
    		for _, s := range initDependsSeeds(scanned, initCfg) {          // <- WIRED
    
    $ gh api "repos/opencharly/charly/contents/charly/charly.yml?ref=main" | base64 -d | sed -n '1730,1733p'
        init:
            depends_candy: supervisord                                      // <- still BARE
    

    Root cause

    Mechanism the seed landed (init_depends_seed.go, wired at scan_orchestrate.go:94) and would fetch an init runtime candy the scanned set implies — but it filters on an @-prefixed ref. The vocabulary's only depends_candy (charly/charly.yml:1733) is the bare string supervisord, so the seed returns nothing, InjectInitDependsCandy still resolves only against the already-scanned set, and a box composing a service: candy with no supervisord candy still gets init="supervisord" stamped onto an image where the supervisord candy was never fetched.

    Missed control the same one the row named: nothing fetches the selected init's runtime candy, and the validate tally still does not count an init-depends miss (plugin-box), so the gate reports 0 warnings while the build is doomed.

    Blast radius every project that composes a service candy without the init candy — previously masked everywhere by the require: layer-supervisord / hand-listed workaround. Not measured: the current count of workaround sites — GitHub code search began returning 403 rate-limit responses during this pass, and the umbrella's candies are separate repos.

    Root fix complete the row's own item 2: name the ref remotely (depends_candy: '@github.com/opencharly/layer-supervisord:<tag>') so the landed seed can act, then count the miss into plugin-box's validate tally and delete the workaround in the same R5 wave. The mechanism is already in place; only the declaration is missing.

    Deps none blocking on the sdk side — the seed and its wiring are landed and tested.

    Correction to this issue's framing

    The row's item 1 ("seed the init vocabulary's remote depends_candy into the ScanCandyFromLocal fix-point") is done. Also stale: layer-supervisord/charly.yml:317 still teaches the workaround — "Adding a service: block to a candy automatically pulls in supervisord via the embedded init: vocabulary's depends_candy. You rarely add supervisord to a box's candy: list manually." — which is not true today in either direction, and belongs in the same R5 sweep.

    Agent: org-triage-2026-10-09
    Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)

  7. added
    category:delivery
    type:fix
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

category:deliverytype:fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions