Repository navigation
Description
Rewritten. The original filing claimed
ResolveInitSystemcould return""while
ActiveInitfound candidates. That premise is false — the two apply the same
initDefRequirementsMetpredicate to the same triggers with the samecaps, so an empty
InitSystemimplies an emptyactiveInitsand the guard has no keys to miss. I verified the
disproof myself rather than accepting it. A real variant with the same consequence survives, and
the issue is now about that one.
The disagreement that is actually reachable
EmitInitAssembly enables a use_packaged: system unit through the image's RESOLVED init only:
if initName == img.InitSystem {That makes correctness depend on img.InitSystem always naming a key of img.ActiveInits. The two
come from separate functions in spec/spec/init_config_methods.go, and they agree only because the
same capability filter is written into both — except on one path where it is not.
ResolveInitSystem's explicit-override branch returns before caps is ever computed:
// Explicit override
if explicit != "" {
if def, ok := ic.Init[explicit]; ok {
return explicit, def // <- returns here
}
}
caps, _ := AggregateCandyCapabilities(layers, candyOrder) // <- never reached
...
for initName := range initHits {
if !initDefRequirementsMet(def, caps) { // <- the predicate that makes
delete(initHits, initName) // the two sets agree
}
}ActiveInit applies initDefRequirementsMet unconditionally. So for an explicit init whose
requires_capability: is unmet: ResolveInitSystem returns it, ActiveInit excludes it,
img.InitSystem names a non-key, the guard matches nothing, and every use_packaged: unit in
the image goes silently un-enabled.
Why the consequence is worse than the arithmetic
The failure is silent by construction: no build error, no warning, no diagnostic line. The image
builds clean and the service never starts on boot. That is the same shape as the defect the
narrowing was introduced to fix (#320), inverted — that one emitted an enable command nothing could
run; this one emits no enable command at all.
Latent today
All three build-path call sites pass explicit = "":
sdk/deploykit/init_depends.go:94 ResolveInitSystem(layers, order, "")
sdk/deploykit/render_prep.go:67 ResolveInitSystem(g.Candies, candyOrder, "")
sdk/deploykit/render_prep.go:196 ResolveInitSystem(g.Candies, candyOrder, "")
A whole-tree grep finds no non-test caller passing a non-empty explicit. So this is unreachable
through any path that exists — the parameter is there for a caller that has not been written yet,
and it is that caller that would trip the hole.
The durable fix is the duplication, not the branch
initDefRequirementsMet is applied twice, from two separate loops, in two functions that must
agree. Nothing makes them agree except that someone wrote the same predicate in both places — and
one copy already has the hole above. Patching the explicit branch to compute caps first would
close this instance and leave the drift surface exactly as it was.
Unifying the predicate — one filtered-candidate computation both ResolveInitSystem and
ActiveInit consume — closes the latent variant and removes the mechanism that produced it, in one
change. That is an R3 refactor with a concrete defect already attached to it, which is the best
kind to do.
Coverage worth adding with it: a test that pins img.InitSystem ∈ keys(img.ActiveInits) for a
composition with a capability-gated init and an explicit override, so the invariant the guard rests
on is asserted rather than inferred from two functions happening to match.
Provenance
Found during pr-validator review of opencharly/sdk#142 while stress-testing whether the
resolved-init narrowing could silently stop enabling a unit a correctly-configured image needs. The
original framing was mine and wrong; the disproof and the surviving variant are the validator's,
verified here against the source. Not a finding against that PR — this applies to f9feb20 on
main.
Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)
Activity
atrawog commentedon Aug 18, 2026
Correction from the originating validator — the premise as filed is refuted, but a real variant of it survives
This was filed from my round-1
pr-validatornote on opencharly/sdk#142. I closed the question in round 2, after this issue was written, and the central claim is wrong. Since it is my finding and it was filed as an unchecked assumption, here is the check.The
InitSystem == ""path cannot reach the failureThe issue rests on
img.InitSystembeing""whileactiveInitsis non-empty. That state is unreachable, because the two computations are not as separate as they look — they apply the same filter to the same triggers.ResolveInitSystem(spec/spec/init_config_methods.go:96-124) buildsinitHitsfromlayer.HasInit(initName)plus, when a layer declares relay ports, every def with a non-emptyRelayTemplate— then filters the result throughinitDefRequirementsMet.ActiveInit(:157-182) walks the same candies and admits an init onHasInit(initName) && initDefRequirementsMet(def, caps), plus the same relay-port clause with the same requirements check inline. Same triggers, same predicate, samecapsfrom the sameAggregateCandyCapabilitiescall — so the two sets coincide.And a non-empty
initHitsalways yields a name. The tail (:126-141) ispreserve_user→systemd, then supervisord, thenfor initName := range initHits { return initName, … }, and only thenreturn "", nil— which is therefore reached only wheninitHitsis empty:Both are called from the same place with the same arguments (
render_prep.go:62and:67, both ong.Candies, candyOrder), and both short-circuit to empty on a nil receiver. Soimg.InitSystem == ""impliesactiveInitsis empty, the guard has no keys to miss, and nothing goes silently un-enabled.The narrowing on
f9feb20is safe as landed, and the "newly reachable" framing does not hold — there is no reachable state to newly reach.The variant that IS real, and it has the same consequence
The issue describes the right failure mode against the wrong mechanism. There is a genuine asymmetry between the two functions, and it is in the branch the analysis above skipped — the explicit override:
That branch returns before
capsis ever computed, so it never appliesinitDefRequirementsMet— the one predicate that makes the two sets agree. An explicit init whose capability requirements are unmet is therefore returned byResolveInitSystemand excluded byActiveInit.img.InitSystemthen names an init that is not a key inactiveInits,if initName == img.InitSystemmatches nothing, and everyuse_packaged:+scope: systemunit in the image goes un-enabled — silently, exactly as this issue describes.It is latent today, and I want that stated as plainly as the issue's original "not claimed" section did. All three call sites in the build path pass
explicit = "":and a whole-tree grep finds no non-test caller anywhere in the superproject or the candies. So nothing reaches it now; the first caller that wires an explicit init selector does, with no test standing in the way.
The R3 point added when this was filed is the durable half, and it is the fix
The observation that
initDefRequirementsMetis applied twice from two separate loops is correct and is the most useful thing here — not because the two loops currently disagree (they do not), but because nothing makes them agree except that someone wrote the same predicate twice, and one of the two copies already has a hole in it. The explicit-override gap above is that hole. Unifying the filter — one function producing the candidate set, withResolveInitSystemselecting from it andActiveInitreturning it — closes the latent variant and removes the drift surface in the same change.Suggested disposition
Retitle to the mechanism that is actually reachable-in-principle, and rewrite the body around it:
with the shared-predicate refactor as the fix and a test pinning
ResolveInitSystem(…, explicit) ∈ ActiveInit(…)for every explicit value. Keep the "not claimed" honesty section, updated: the state is unreachable today because no caller passes a non-emptyexplicit.Closing it outright would also be defensible, since nothing reaches either path today. I would keep it, because the R3 duplication is real and the refactor that fixes it is small.
Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)
[-]EmitInitAssembly's resolved-init guard has no defined behaviour when InitSystem is empty: every use_packaged: unit silently goes un-enabled[/-][+]ResolveInitSystem's explicit-override branch skips the capability filter ActiveInit applies, so InitSystem can name a non-key and every use_packaged: unit goes silently un-enabled[/+]atrawog commentedon Aug 18, 2026
Rewritten per the correction above — thank you for disproving your own note rather than leaving it standing.
I verified the disproof independently before editing, since a retraction is a claim like any other.
spec/spec/init_config_methods.go:85-88returns from the explicit-override branch beforecapsis computed at:91and before theinitDefRequirementsMetfilter at:118, whileActiveInitapplies it unconditionally — so the mechanism you describe is real and the one I originally filed is not. All three build-path call sites passexplicit = ""(init_depends.go:94,render_prep.go:67,render_prep.go:196), confirming it is latent.The issue is now titled and written around the explicit-override branch, with the R3 unification as the fix rather than a patch to that branch — for the reason you gave: patching it closes the instance and leaves the mechanism. I kept the "latent today" section explicit so nobody reads this as a live outage, and added the invariant worth asserting alongside the refactor (
img.InitSystem ∈ keys(img.ActiveInits)for a composition with a capability-gated init and an explicit override), so the guard's precondition is pinned rather than inferred from two functions happening to match.Left open rather than closed, as you suggested, so the R3 refactor has somewhere to land.
Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)
atrawog commentedon Aug 28, 2026
Validation (2026-08-28) — RESOLVED
Verified against current
specmain.spec/init_config_methods.gonow computescandidates, caps := ic.activeInitWithCaps(layers, candyOrder)BEFORE the explicit-override branch, and the override is "honored only when it names a viable candidate" — an override for an init whose capability is unmet falls through to auto-detect. The comment in the code describes the exact bug this issue filed ("the explicit-override branch below returned before the filter was ever applied").Closing as resolved.