Repository navigation
fix(sdk): fetch the init runtime the init vocabulary depends on, and match a ref-shaped depends_candy - #336
Conversation
…match a ref-shaped depends_candy The init vocabulary declares, per init system, the candy that installs that init's runtime (`depends_candy:`). Declaring a `service:` is what SELECTS an init, but nothing ever FETCHED the selected runtime candy: InjectInitDependsCandy resolved `depends_candy` only against the project's already-scanned set, so a project that never happened to compose the init candy built clean, stamped ai.opencharly.init="supervisord" onto an image with no supervisord binary, and died inside podman on the render stage's COPY of the init candy's own template. Every service candy carrying `require: layer-supervisord` is the target-blind workaround this replaces — it drags supervisord onto systemd and OpenRC venues. - loaderkit: extract candyTriggersInit as THE one detection predicate (R3) and add initDependsSeeds, the pure seed resolving the vocabulary's remote `depends_candy` into fetch coordinates. - loaderkit/scan_orchestrate: seed the fetch fix-point both before the local-only early return and after EVERY round — a remote service candy's trigger is only visible once its round has scanned it. Seeding is idempotent, so the loop drains; the seed is sorted, so the network fix-point does not vary run to run. - loaderkit/scan_orchestrate: the seed is a FALLBACK. A composition that already names the init runtime — in the fetch set it arrived with, or already materialized — is left alone, so the arbiter's newest-wins rule can never silently move a project's own explicit pin. - deploykit: normalize a ref-shaped `depends_candy` to its bare ref before every presence check, and reuse the tolerant name rule in the machine-venue prune so a ref-keyed layer-supervisord is pruned exactly as the bare name is. Assisted-by: Claude Code DeepSeek V4.1 (flash) (analysed on a live system)
Review — BLOCKHead SHA: Change class: code — sdk library + runtime-behaviour change ( Security screen: PASS — no secrets, no egress, no guardrail/rulebook weakening, no embedded directives, no dependency/CI edits; all 8 changed files are accounted for by the body (diff counts +704/−67 match the file list exactly). Blocks
Notes (non-blocking): no comments to disposition ( Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Add TestLiveBedInitDependsSeedFetchesTheInitRuntime to the loaderkit live
mechanism bed: a fully-local project whose only candy declares a non-packaged
`exec:` service triggers supervisord, so ScanCandyFromLocal must FETCH
supervisord's runtime candy (the new init-depends seed) through the REAL
repo-cache fetch + manifest scan and resolve it at the vocabulary's tag. The
existing stubbed unit tests pin the seed's shape; this bed pins that the
production legs materialize and parse the real layer-supervisord tree it names.
The bed also exercises two production facts the pre-existing live beds never
reached:
- liveBedParse now threads a hand-built, production-modelled spec.Threaded
snapshot (liveBedThreaded) instead of an empty one, so ParseCandyManifest's
node-form branch desugars the authored `command:` verb sugar exactly as
production does. The bed's MigrateCache is a documented no-op, so it also
drops the pristine export's legacy top-level `version:` stamp before the
parse (writing a stripped temp copy; the shared read-only view is never
mutated) — production's command:migrate reshapes that stamp away first.
- spec.OpInContext, the process-wide DI hook FinalizeScannedCandies ->
CompleteCandyRunOps calls for every scanned candy, is wired in this test
binary (production charly wires it in its own init()). The real
layer-supervisord candy carries a `run:` step, so the nil hook panicked;
the classifier is a verbatim port of charly's opInContext/
opEffectiveContexts, the same port deploykit/plan_compile_test.go carries.
The bed is live-or-skip: it skips visibly unless LIVE_SDK_MECHANISM_BED is set
and the warmed repo cache holds the init runtime, and never fakes the boundary.
Assisted-by: Claude Code DeepSeek V4.1 (flash) (analysed on a live system)
Review — BLOCKHead SHA: Change class: code — sdk library + runtime/deploy behaviour change ( Comment disposition. The one prior comment (by Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Extract the pure spec.OpInContext classifier — which deploykit's compiler tests and loaderkit's live bed each carried as a verbatim port — into one sdk-internal helper, internal/spectest (R3: one canonical implementation per behaviour, with no "a second copy is fine" threshold). Add a live bed that drives the REAL InjectInitDependsCandy and the REAL PruneContainerInitForSystemd, unmodified, over the SAME real layer-supervisord materialization the seed bed fetches, with the vocabulary's real ref-shaped depends_candy. That gives this PR's two deploykit behaviour changes live proof ON THE COMMITTED TREE — what the end-to-end charly bed cannot supply while opencharly/charly#762 is unmerged. Verified to fail with either change reverted.
…runtime
`unsatisfiedInitDepends`'s message interpolated `depends_candy` into the slot that
names the binary the image will fail to exec. That slot only ever READ correctly
while the vocabulary spelled the field bare (`supervisord` == the binary). With the
ref-shaped `depends_candy` this PR's cutover introduces, the same warning printed
... declare init "supervisord" with no @github.com/opencharly/layer-supervisord:v... binary
naming a ref where a binary belongs. The init's own name is the runtime the entrypoint
execs, so interpolate THAT and state "no <init> implementation installed"; the candy the
field names still leads the sentence, where it is correct. No test pinned the default
text (both cases swap the `unsatisfiedInitDepends` hook), so nothing else moves.
Review — PASSHead SHA: Security screen: PASS — no secrets, no egress, no guardrail/rulebook/validator-spec weakening, no embedded directives, no new deps or CI edits; all 11 changed files are accounted for by the body. Comments (both Checklist: All applicable rules PASS or NA. Placement is Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Fetches the init runtime an init's
depends_candy:names, so a composition that only declares aservice:gets its init installed instead of an image that stampsai.opencharly.init="supervisord"with no supervisord binary to run.Relates to opencharly/charly#764 (the umbrella issue for automatic init injection + the
require: layer-supervisordcutover).This revision answers the second review's three blocks (head
e3fc4b3, run 37118911153): (1) the twodeploykitbehaviour changes now have live proof on the committed tree, not only on a back-port; (2) the duplicated op-context predicate is extracted into one sharedsdk/internal/spectesthelper rather than conceded; (3) the body accounting is corrected below —deploykit/init_unit_files.go's actual diff is described as what it is (the rewordedunsatisfiedInitDependswarning), and the Rulebook section answers every applicable rule.Summary
charly/charly.yml'sinit:vocabulary declares, per init system, the candy that installs that init's own runtime (supervisord:→ the supervisord candy;systemd:/openrc:→ none — they install with the OS). Declaring aservice:in a candy is what selects an init and assembles its config — but nothing ever fetched the selected init's runtime candy.deploykit.InjectInitDependsCandyresolveddepends_candyonly against the project's already-scanned set, so a box that never happened to compose the init candy built and validated clean, bakedai.opencharly.init="supervisord"plus an assembled/etc/supervisord.conf, and then died inside podman on the render stage's COPY of the init candy's own template:The field workaround is target-blind: 40 candies carry
require: layer-supervisordand boxes list it by hand, which drags supervisord onto systemd/openrc venues.What changed — 11 files,
+969/−100:loaderkit/init_depends_seed.go(new, +98) —initDependsSeeds(scanned, initCfg)returns, for each init the scanned set actually triggers, its remotedepends_candyas a fetch coordinate:RepoPath,Version(the authored:version; empty ⇒ resolved to the repo's default branch by the caller), the bareRef, and alayer=init:<name>scope. Only a REMOTE (@-prefixed)depends_candyis seeded; a baredepends_candy: supervisordnames no repo and is left to the scan set exactly as before.loaderkit/finalize_candy.go(+43/−29) — extractscandyTriggersInit(sc, def), the ONE "does this candy trigger this init" predicate, out ofPopulateCandyInitSystem's inline loop so the seed and the finalizer cannot drift (R3). Behaviour-preserving: the sameIsPackaged/SupportsPackaged/ServiceTemplaterouting and the samecandy_fileglob arm.loaderkit/scan_orchestrate.go(+104/−5) — runs the seed (a) overlocalScannedBEFORE thelen(downloads) == 0early return (a fully-local project must fetch too) and (b) after EVERY fix-point round over everything materialized so far — essential, because a distro service candy is itself remote, so itsservice:trigger only becomes visible once round 1 has fetched and scanned it. The seed is idempotent (theseededmap) so the fix-point drains instead of re-adding forever.deploykit/init_depends.go(+32/−28) — normalize a ref-shapeddepends_candythroughspec.BareCandyRefbefore every presence check, so@github.com/opencharly/layer-supervisord:v2026.271.1817matches the scanned set exactly as the bare name does, and ask the tolerant name rule before injecting a duplicate. The "not in the scanned set" branch's comment is re-based: with the fetch seed in place, reaching it means the fetch failed, not that the project forgot to list something.deploykit/graph.go(+17/−1) —PruneContainerInitForSystemdstops comparing to the literal"supervisord"and asksorderSatisfiesInitDependsinstead, against a new namedconst containerInitCandy = "supervisord". That is the ONE change that is not conditional on the vocabulary flip: a resolved order carrying the candy under its ref key (github.com/opencharly/layer-supervisord) is now pruned on a machine venue where before it survived onto a systemd guest. Intended, and covered by the live bed's second assertion.deploykit/init_unit_files.go(+12/−5) — the rewordedunsatisfiedInitDependswarning. Its text previously taught the pre-fix workaround verbatim ("Reference the candy directly in the box'scandy:list, or pull it in via a composed candy'srequire:"); it now names the actual cause — the fetch that should have materialized the candy did not — and points at the vocabulary'sdepends_candyref. The message also no longer interpolatesdepends_candyinto the slot naming the missing binary (that slot read correctly only while the field was spelled bare, and the ref form would have printed... with no @github.com/opencharly/layer-supervisord:v2026.271.1817 binary); it names the init's own runtime there instead. The dedupe key(box, init, candy)and the hook-swap contract are unchanged, and no test pinned the old text.internal/spectest/opincontext.go(new, +53) — the ONE canonical port of the pure op-context classifier (spec.OpInContext/spec.OpEffectiveContexts), plusInstall()to wire the DI hook. Two sdk test binaries need it (deploykit's compiler tests andloaderkit's live bed); underinternal/it stays unimportable from outside the module, so the published surface and the placement test are untouched.deploykit/plan_compile_test.go(+9/−29) — its own verbatim copy of that classifier is deleted; the file now callsspectest.Install()ininit(). (The copy in theplugin-fleetrepo atcandy/plugin-fleet/deploy_test_helpers_test.gostays: that package is out-of-module and cannot importsdk/internal.)loaderkit/scan_live_bed_test.go(+195/−3) — the live-or-skip beds below, plus a new bed (see "How tested") and two things a reallayer-supervisordmaterialization forced, both confined to that test file: the sharedliveBedParsefixture now threads a hand-built, production-modelledspec.Threadedsnapshot and drops a legacy top-levelversion:before parsing (the real cached manifest carriesversion: 2026.261.1747at~/.cache/charly/repos/github.com/opencharly/[email protected]/charly.yml:1, which production'scommand:migratereshapes away before the parse;ParseCandyManifest's node-form branch — the only branch that desugars authored verb sugar — rejects a scalar top-levelversion:, so without the strip the bed would fall back to a decoder that does not desugar the manifest'scommand:verb sugar).loaderkit/init_depends_seed_test.go(new, +317): local-only project fetches; remote trigger seeds on the next round; termination; nodepends_candy⇒ no fetch;use_packaged-only ⇒ no supervisord; baredepends_candy⇒ no fetch; a project's own pin is NOT overridden, in both the root-repo and pre-cutover sub-path shapes. Anddeploykit/init_depends_ref_test.go(new, +89): the ref-shapeddepends_candymatches the scanned key and the machine-venue prune drops it.The seed is a fallback, never a version override: it adds nothing when the composition already names the init runtime, so
PickCandyVersion's newest-wins rule can never move a project's own explicit pin.How tested
Gate on the committed tree, head
2847040cca345d6fd048a8dee1d7aad01045c3d0(re-run by the PR author on the pushed head, not taken from a worker's report):The whole live suite, on that same committed tree (4 PASS, 0 SKIP — quoted in full, because a partial run could not show that the shared-fixture change left the two pre-existing beds green):
It ran live: no test skipped,
grep -c SKIPon the log is0. The bed drives the realEnsureRepoDownloadedfetch, the realScanRemoteCandymanifest scan and — the new part — the realdeploykit.InjectInitDependsCandyand the realdeploykit.PruneContainerInitForSystemd, unmodified, over the real materialization the scan produced. No mock of any boundary; a cold cache skips visibly instead.The new bed fails without each of the two
deploykitchanges, separately. That is the discrimination the previous revision could not offer, and it is what makes this live proof a proof of these diffs rather than of the pipeline around them. Each run reverts exactly one file toorigin/main, runs the bed, and restores:Read the RUN A output closely and the two changes separate cleanly: the seed did its job (the warning fires only because the candy was fetched and scanned), and the injection still missed it, because without the normalization the ref-shaped
depends_candymatches no scanned key.Live end-to-end under the assembled pipeline — charly built from a worktree with
replace github.com/opencharly/sdk => <a mechanically identical back-port of this tree, see "Reconciling the spec pin" below>, then adisposable: truebed whose box composes nolayer-supervisordand never names the init candy. The whole pod lifecycle passes — 14/14 steps, 0 errors, 0 warnings:and the emitted image proves the fetch + injection (
.check/check-spikebox/2026.276.1052/image-build.log):The
COPYthat failed in the defect now resolves, and the init runtime was materialized at the vocabulary's pinned tag on a box that never listed it. Independently, the bed's own log records the deploy-name alias resolving a fully-qualified source:Overlay image ready: ghcr.io/opencharly/spikebox:check-spikebox-2026.276.1037.The
deploy-addfailure this PR previously reported is root-caused, and it was my own test state — not a defect of this change. Replaying the failing command by hand recovered what the plugin's silent executor had discarded:So
reply.BaseImagewas the bare short namespikebox—build_overlay.go'sdefault:fallback, taken whencontainer.ResolveNewestLocalCalVer(engine, "spikebox")errors. It errored because of[email protected] container/local_image_coneb.go:619:electResolvedImagerefuses with an ambiguous short name error that names every candidate when the top candidate has neither a label-CalVer nor a tag-CalVer and the candidates span more than one repository. Bothspikeboxcandidates were mine, and they spanned two registries —ghcr.io/opencharly/spikebox:check-spikebox-2026.276.1041and a leftoverghcr.io/example/spikebox:check-spikebox2-2026.276.0845from an earlier spike of mine that usedregistry: ghcr.io/example. Removing my own scratch artifacts removed the ambiguity, and the same box, same binary, same commit then passeddeploy-addand the entire lifecycle above. Real pod beds never hit this because all their candidates share one registry.The residual finding is diagnosability, and it is routed to its owning batch:
opencharly/plugin-deploy-pod#19("a failingpodman tagreports onlycommand exited 125— the fire-and-forget helper discards the cause").tagDeployAliasrunspodman tagthroughexec.VenueRunSilent(spec/exec/executor.go:229), the fire-and-forget helper, which discards both streams and returns onlycommand exited %d— so a cross-venue failure arrives with no cause at all. Its siblingVenueCapture(:211) already surfaces stderr. That issue isplugin-deploy-pod's, not this repo's, and this PR changes no deploy-venue code.Reconciling the spec pin (correcting the revision before this one)
An earlier revision asserted "R10 — verified from the final committed tree, not an edited state" while also admitting a local adaptation. Those two statements were mutually inconsistent, and the claim was wrong. The claim is withdrawn and is not restated anywhere in this body. The accurate account:
go.modpinsgithub.com/opencharly/spec v0.2026276.0, andspec.LayerScopeexists there (spec/resolve_opts.go:82:func LayerScope(candy string) string { return "layer=" + candy }). Sogo build ./... → 0above is a real statement about the committed tree.spec.LayerScopeis additionally already used, pre-existing and untouched, atloaderkit/refs_collect.go:511— this PR did not introduce the dependency.spec v0.2026276.0yet: the plugins charly pins still declare[]stringwhere the newer spec wants the typedExtraCandyRef. To run the end-to-end bed at all, the spike used a back-port of these same files onto the spec version charly can build with (v0.2026272.1512, which lacksLayerScope; hence the one-line substitution). It is the same source, mechanically re-expressed — not an edit to the committed tree, which contains no such adaptation and builds as shown.charly versionfor the binary used in the live run:2026.276.0451, built from the charly worktree at6d7d80fc.opencharly/charly#762(spec#188), which is also what unblocks flipping the vocabulary to the remote ref.Honest limits of this proof
deploykitruntime changes now DO have live proof on the committed tree — the end-to-end assembled run still does not. The previous revision's block 1 is answered byTestLiveBedInjectionResolvesTheSeedsRealMaterialization: the committedInjectInitDependsCandyand the committedPruneContainerInitForSystemdexecute, unmodified, over the real[email protected]materialization, with the fail-without-change discrimination pasted above. What remains one step removed is the assembled proof — the full charly pipeline, which ran on the back-port because charly cannot yet consumespec v0.2026276.0(opencharly/charly#762). That is the whole of the remaining gap, it is stated rather than glossed, and it is why the tier below stays at analysed on a live system.graph.go's is not. The fetch seed is inert until the vocabulary names a remote ref (main still carries the baredepends_candy: supervisord, so no shipped project fetches anything new from this PR alone). ButPruneContainerInitForSystemd's switch from a literal to the shared name rule changes behaviour on its own, with no vocabulary flip required: a resolved order carrying the candy under its ref key (github.com/opencharly/layer-supervisord) is now pruned on a machine venue where before it survived onto a systemd guest. That is the intended change — one name rule for one divergence (R3) — and RUN B above shows the live bed is what detects it.spec.OpInContextport is no longer duplicated — it is one shared helper. The previous revision conceded a second copy across two sdk packages (block 2). It is nowsdk/internal/spectest:deploykit/plan_compile_test.go's copy is deleted and both it andloaderkit/scan_live_bed_test.gocallspectest.Install(). The only surviving copy of that classifier anywhere in the org is theplugin-fleetrepo's owncandy/plugin-fleet/deploy_test_helpers_test.go, which is an out-of-module package and cannot importsdk/internalby the language's own rule — the reason is in that file's comment.charly/charly.ymlto the pinned remote ref, bumping the sdk pin, and threadinginitCfgthrough the validate path socharly box validatestops reporting a state the build disproves — isopencharly/charly#764, and it is behindopencharly/charly#762.Rulebook compliance
Every applicable rule of the umbrella
AGENTS.mdandcharly/AGENTS.md, each answered with a one-line HOW or an explicit N/A and its reason.sdk/AGENTS.md) was loaded by path from the marketplace tree —internals/skills/plugin/SKILL.md,internals/skills/install-plan/SKILL.md,internals/skills/go/SKILL.md— plusinternals/skills/git-workflow/SKILL.mdand itsreferences/pre-validator-self-audit.mdfor the git/PR surface. No edit, branch, commit orghaction preceded them.depends_candywas resolved against the already-scanned set while nothing in the pipeline fetched it, so a composition triggering an init built an image stamping that init with no binary (opencharly/charly#764, with thecharly box validate"nothing was injected" line and the[image-build]COPY templates/supervisord.header.conffailure as evidence). Thedeploy-addfailure this PR's own gate surfaced is separately root-caused above to my own cross-registry scratch artifacts, with the residual diagnosed and routed. The nil-OpInContextpanic that blocked the live bed was root-caused to a DI seam only charly core wires, and fixed by sharing that port, not by mocking the seam.ScanCandyFromLocalis the single chokepoint, and every production call site of it is covered by changing it once. There are exactly four on disk, all inplugin-build(resolve.go:98,resolve_project_word.go:105,resolve_project_tolerant.go:77,resolve_legs.go:465;grep -rn 'ScanCandyFromLocal' --include=*.goover the org finds no fifth), plus thespec.ProjectLoader.ScanCandyFromLocalseam that charly core reaches through instead of importingloaderkit. The name rule is unified across the injection and the prune in the same change. The cutover's other half is not deferred, it is sequenced: therequire: layer-supervisordremoval from the 40 candies + the box listings is the consumer leg ofopencharly/charly#764, and it is only possible once this PR supplies the automatic fetch — this PR is the replacement home, so R2/B15's "removed from A while its replacement home on B is deferred" cannot apply.candyTriggersInit, consumed by both the finalizer and the seed); the injection and the machine-venue prune now share ONE name rule (orderSatisfiesInitDepends, named once ascontainerInitCandy); and the op-context port is collapsed intosdk/internal/spectestwith both in-module copies deleted in this same change.require: supervisord(which/charly-image:layerforbids as target-blind) or special-casing a project. The warning text change removes the workaround instruction rather than teaching a new one.depends_candybare spelling is not legacy:spec.BareCandyRefis identity on it and the seed ignores it, so both spellings stay valid with no stranded path. The 40require: layer-supervisordlines are this cutover's deletion half and are owned by#764(see R2)..worktrees/polymorphism-truth/sdkonfeat/polymorphism-truth; no force-push, no direct push tomain, no history rewrite, no hook bypass (--no-verify/core.hooksPath), nogit add -A, and no other session's file, branch or worktree touched.git status --shortis empty on the head.deploykitchange failing the bed on its own.t.Skipnaming the missing cache or the unsetLIVE_SDK_MECHANISM_BED) and mocks no boundary;grep -c SKIPon the pasted run is0.(box, init, candy)and its hook-swap contract are unchanged, and no test or machine consumer parses its text.gofmt/build/vet/test) ran on head2847040; the live beds run test binariesgo testbuilds from that same tree; and the assembled run's binary is identified ascharly version 2026.276.0451, built from the charly worktree at6d7d80fc, against the back-port declared in "Reconciling the spec pin" — stated, not glossed.disposable: truebed's own resources, and no proof is taken from an edited state — the withdrawal of the earlier "verified from the final committed tree" claim is exactly that rule being applied to the end-to-end portion.disposable: true; no shared or operator-owned resource was created, mutated or reaped. (The one teardown-venue hazard discovered during this work —charly deploy delwith no venue falling back to the host executor — is tracked atopencharly/charly#765and is why no roster containingcheck-kind-host-vmwas run.)charly task sync/charly task verifywas run (they are the gitlink writers); no--tagorbed_domainwas shared with another session; the only shared writable surface touched was the read-only-when-warm repo cache, through its sanctioned boundary (EnsureRepoDownloaded: source-keyed path, per-binary flock, atomic rename).sdk/internal/spectest— importable only within the module, so the sdk's published surface is unchanged and the placement test's boundary holds; the change adds no capability code and no kind-specific branch to a mechanism package; thedeploykitandloaderkitchanges are pure functions of the config and the scanned set.Change classification
sdk(loaderkitfetch fix-point;deploykitinjection and prune matching; a runtime warning's text), with test-only additions.gofmt -l/go build/go vet/go test -count=1 ./...on the committed pushed head2847040(all green, all 16 packages incl.internal/spectest); the whole live-or-skip bed suite on that same tree, against the real fetch, scan, injection and prune (4 PASS, 0 SKIP); the live bed's per-change fail-without-change runs (2/2 FAIL as designed, then restored); and the assembled end-to-enddisposable: truebed on the mechanically identical back-port — 14/14 steps, 0 errors, 0 warnings.deploykitruntime path itself now has committed-tree live proof), and the project's gate for that tier,./charly/bin/charly task verify, cannot run at the umbrella root because of the pin defect owned byopencharly/opencharly#330— a pin-advance change class this PR does not touch.Agent:
polymorphism-truth· session9c898e99-b5d7-4f3e-a472-62c4ecbcd18fAssisted-by: Claude Code DeepSeek V4.1 (flash) (analysed on a live system)