Repository navigation
fix(add_candy): fail loudly when a pinned ref cannot be honoured, instead of running another version's plan - #113
Conversation
…tead of running another version's plan
`rp.CandyModels` is keyed by candy IDENTITY (`BareRef`: no `@`, no `:version`), which is right for
the graph — `include:`/`require:` edges are bare refs and the dep walk is literally
`layers[BareCandyRef(ref)]` — but it cannot distinguish two coordinates of ONE repo. When two
scopes in the same project pin the same repo at different tags, the loader FETCHES both
(`sdk/loaderkit/refs_collect.go`'s per-`(repo, tag)` fetch set, `scan_orchestrate.go`'s
`materials[repoVer{repo,ver}]`) and then `PickCandyVersion` keeps ONE winner per identity — the
losers are dropped at that exact point. So `candyAddSteps`' bare lookup returns the arbiter's
winner whatever the deploy pinned, and a bed's child plan is another version's plan.
MEASURED (#112): `distro-arch`'s bed pins
`layer-direnv:v2026.287.2155` while `layer-agent-forwarding:v2026.274.0608` transitively pins
`layer-direnv:v2026.272.0057` (three boxes in the same manifest). The fetched artifact carried the
pinned manifest (`grep -c context` = 12, `id: direnv-hook-wired-at-venue`), yet the child
`check live` ran the OLD plan — `9 steps: 6 passed, 3 failed, 0 skipped`, none of the new steps —
before and after the pin move, and with `charly cache bypass` on (so the cache is refuted as the
cause).
This change is the MISSED CONTROL, not the fix. The stamp the scan already writes
(`ws.Model.Version = winner.GitTag`) makes the collision DETECTABLE: an authored ref that names a
version and receives a model stamped with a different one is an unresolvable input, so it now
fails loudly (infra exit) naming the ref, the wanted version, the model's version and the issue,
instead of silently running the wrong plan. Narrow by design:
- a version-less ref keeps the identity lookup (no pin to honour);
- an UNSTAMPED model is not gated — that is the documented local-shadow case
(sdk/loaderkit gives a local candy of the same name precedence, as INFO, and a local candy has
no git tag);
- a local bare-name ref has no version.
It does NOT unblock `opencharly/distro-arch#52`: the pin still cannot be honoured here. That needs
the per-coordinate models carried on the resolved-project envelope (spec schema + `cue-gen` → the
loader's exit → this lookup), which is a spec-level change because the scan's exit is the
`ScanCandyFromLocal` seam method with 7 call sites across charly, plugin-build ×4 legs,
plugin-loader and the vendored mirrors — filed as the next row rather than half-landed.
Test: `TestCandyAddStepsRejectsAPinTheModelCannotHonour` (with the guard disabled it reports
"got 1 step(s) and no error" — the negative control) plus
`TestCandyAddStepsToleratesAnUnpinnedRefAndAnUnstampedModel` for the two boundaries; `go build`,
`go test ./...` and `gofmt -l` clean.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
Review — PASSHead SHA: Security screen: PASS — the diff adds a fail-closed guard (no secrets, egress, dependency, or weakened gate); T4 not triggered. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…st, so the child phase asserts the PINNED coordinate (#147) * fix(check): a deploy's add_candy refs ride the resolved-project request, so the child phase asserts the PINNED coordinate The child `check live` phase composed its plan from `rp.CandyModels[deploykit.BareRef(ref)]` — an identity-keyed lookup — in a resolution that never MATERIALIZED the coordinate the deploy pinned: the envelope's candy scan is reachability-scoped over the project's IMAGE closure, and a deploy's `add_candy:` refs sit outside it (candy/plugin-build's own cache-key comment states the consequence: ExtraCandyRefs "is the ONLY way a host-side plugin candy that no image closure reaches enters rp.Candies at all"). So the phase read whatever OTHER coordinate of that repo the closure reached — an older tag transitively required by a composed layer — and, since #113, refused naming the mismatch. A bed's pin could be read, fetched and still not change what the phase asserted (#112). The fix is at the request, where the mechanism lives: the live and feature-live arms now pass the deploy's own `add_candy:` refs (scoped with spec.ScopedExtraCandyRefs/spec.BoxScope, the same construction the host's deployNodePluginContext uses, and over the same plugin-side merged-tree resolver) as `ResolvedProjectRequest.ExtraCandyRefs`, so the pinned coordinate becomes a CANDIDATE, the arbiter resolves it, and `candyAddSteps` reads the pinned model. Evidence: the new in-repo R10 bed `check-addcandy-pin-honoured` (a disposable kind:local bed driving the child phase of testdata/addcandy-pin-fixture, which pins layer-direnv at the newer of two coordinates that project references) PASSES on this tree and FAILS on the previous binary; unit tests pin the request field and the collection rule, both mutation-proven. Agent: fix-112 Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system) * fix(check): name the bed that actually witnesses #112, and state the collector duplication Round-1 review found the new unit test's header naming two beds that this diff never creates (`check-addcandy-pin-advanced` / `-stale`): draft names, replaced by `check-addcandy-pin-honoured` before the beds were authored and never re-read. The header now names the real witness and describes what it actually does — the fixture pins layer-direnv at the NEWER of the two coordinates the project references, so the phase must compose the PINNED plan rather than refuse on the other one; it does not "advance a pin". No behaviour change: comments only, in the file the finding named. Agent: fix-112 Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system) * refactor(check): consume spec's ScopedAddCandyRefs, so this diff carries no duplicate traversal Round-2 review was right that a stated duplication is not a cured one: `scopedAddCandyRefs` re-implemented the host's ref-collection half in NEW code this change introduced, which R2 marks blocking regardless of which repo the other copies live in. `opencharly/spec#310` now owns that traversal - spec.DeployNode.ScopedAddCandyRefs(scope), beside the member-tree accessors it walks and the scope constructors it tags with - so this package deletes its copy and calls the shared one. The plugin's own two facts stay here: WHICH node the deploy name denotes (over the plugin-side merged tree, with the host's node-lookup contract) and which composition scope the refs take (spec.BoxScope(name)). The spec pin advances to the tag spec#310 minted, v0.2026317.1828. That tag also carries opencharly/spec#308 (the #1131 connect-seam wire field), which is additive and changes nothing this package consumes; the bump is go.mod + two go.sum lines and `go mod tidy` is clean. Behaviour is unchanged, and that is measured, not assumed: the deleted local collector and the shared method were dumped over the same node (a node with two add_candy refs, an in-substrate member carrying a third, and a deploy-level sibling carrying a fourth that must NOT appear) and the two dumps are byte-identical; the witness bed and both directions of the fixture A/B are re-run on this head. Agent: fix-112 Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system) --------- Co-authored-by: charly <[email protected]>
Summary
rp.CandyModelsis keyed by candy identity (BareRef: no@, no:version), which is rightfor the graph —
include:/require:edges are bare refs and the dep walk is literallylayers[BareCandyRef(ref)]— but it cannot distinguish two coordinates of one repo. When twoscopes in the same project pin the same repo at different tags, the loader FETCHES both
(
sdk/loaderkit/refs_collect.go's per-(repo, tag)fetch set,scan_orchestrate.go'smaterials[repoVer{repo,ver}]) and thenPickCandyVersionkeeps one winner per identity — thelosers are dropped at exactly that point. So
candyAddSteps' bare lookup returns the arbiter'swinner whatever the deploy pinned.
This change is the MISSED CONTROL, not the fix. The scan already stamps the winning source git
tag onto the model (
ws.Model.Version = winner.GitTag), which makes the collision detectable: anauthored ref that names a version and receives a model stamped with a different one is an
unresolvable input, not a plan to run. It now fails loudly (infra exit) naming the ref, the wanted
version, the model's version and the issue, instead of silently asserting a version the deploy never
named. The guard is narrow by construction:
Version == "") is not gated — that is the documented local-shadow case(a local candy of the same name wins, as INFO, and carries no git tag);
It does NOT unblock
opencharly/distro-arch#52— and it says so. The pin still cannot behonoured here; with this guard in the tree
#52's child phase fails LOUDLY (naming both versions)rather than quietly asserting the wrong one. A guard that pretended to unblock would be the fake fix.
Honouring the pin needs the per-coordinate models carried on the resolved-project envelope: a
#ResolvedProjectfield (spec/schema/resolvedproject.cue, CUE-sourced →cue-gen) plus theloader's exit — which is the seam method
ScanCandyFromLocal(spec/spec/loader_seam.go:362)with 7 call sites across charly, plugin-build ×4 legs, plugin-loader and the vendored charly
mirrors. That is filed as the next row in
opencharly/plugin-check#112, never half-landed.The cheap green is refused in writing on
#112: making the whole project agree on ONE coordinatefor that repo (a
layer-agent-forwardingtag + three box bumps) would turn#52green while thebare-keyed lookup kept silently ignoring pins — the next pin bump anywhere would re-open the class
with the same silence.
How tested
Change class: compiled-in plugin Go code (
plugin-check's ownAGENTS.md: the plugin is bakedvia
github.com/opencharly/plugin-check/candy/plugin-checkincharly/go.mod, and the R10 witnessis the disposable
check-localbed inopencharly/charly). That bed is a consumer artefact(it composes this plugin through a pin), so its run rides the consumer change — the same
producer→consumer order as every other leg of this campaign. What I can prove on this head, I pasted
below: the module gates, the unit test with its negative control, and a LIVE A/B of the changed path
on the measured bed's own deployment.
Module gates on this head (
7ce151e, 3 files, +120/−14):The negative control (R7: a test that cannot fail is invalid). With the guard's condition
disabled in place and everything else identical:
The LIVE A/B — the changed path executed on the measured bed's deployment. Same command, same
venue, same tree; the ONLY difference is which
plugin-checkran:Two things that A/B establishes beyond the guard working:
identity —
v2026.272.0057, the transitive coordinate reached throughlayer-agent-forwarding:v2026.274.0608(composed by three boxes in that manifest) — against thebed's pinned
v2026.287.2155. That is the collision, named by the engine itself.CHARLY_PLUGIN_DIRis INERT for a BAKED plugin, and that is why the live proof needed arebuilt host: the loader never consults a plugin directory for a plugin linked into
charly/go.mod. Measured twice (noserved fromline, identical plan), independently reproducedby
lane-beds.Provenance of the guarded host binary, stated exactly because the instrument matters:
/tmp/charly-guard-build/charly-guard, built from the umbrella'scharly/tree (the submodule atits gitlink) with a scratch
go.workin/tmpthatuses the charly module plus thisworktree's
candy/plugin-checkmodule — the same shape-dev-plugin's generatedgo.work.devhas.charly version→2026.286.2307. No repo file was written: the workspace and the binary liveunder
/tmp. The scratch workspace also carries onereplace— theplugin-buildpin movementbelow — which is what made the assembled build compile at all.
Pin-skew evidence, added to
opencharly/plugin-cache#10: the first assembled build attemptfailed on EXACTLY the mechanism that issue measures —
[email protected]no longer compiles against loaderkit'sNamespaceAncestorsseam onceMVS raises
sdk(this plugin module requires the storekit tag). The scratchreplacetov0.2026286.1121(the pin movement#10names) compiles. That is an existing issue's evidence, nota new finding, and the real fix belongs in
charly/go.mod(charly#910's row).Rulebook compliance
## Filed issuesfollows, and the attribution footer is the LAST line.check-localbed, consumer-side; module gates + live A/B pasted).analysed on a live system— a live invocation of the changed path produced retained output (the A/B), and the class's assembled bed is the consumer's./charly-internals:git-workflowand/charly-internals:strict-policyloaded before any git/PR action; this repo'sAGENTS.mdread.CHARLY_PLUGIN_DIRoverrides a baked plugin — is now recorded rather than hidden. The class and the next row are filed (## Filed issues).git status --shortclean before and after the single commit; no amend after push planned, no force-push, no bypass, no direct push tomain; no repo outside this worktree was written (the host build lives in/tmp).got 1 step(s) and no error) and the changed path executed LIVE (the A/B).2026.286.2307), including the scratch workspace that composed this plugin; no new runtime dependency.check-localbed is the consumer's, and this PR states that it has not run on this head.plan:and grader contract are untouched, and the guard exists to stop a plan being assembled from the wrong version.spec/schema/*.cue, wire shape or generated type is touched here (the schema field belongs to the next row).disposable: truebed's deployment; nothing was destroyed, rebuilt, or mutated (with the guard the plan never executes).gofmt -lempty,go build ./...clean,go test ./...green (pasted).STATUSonopencharly/plugin-check#112(the class),lane-bedstold the outcome of the probe on their venue, andplugin-checkwas checked for contention before branching (no open PRs; three stale worktrees on other files, none touched).R5 sweep, executed on this head (the claim is worth its pasted lines):
Read precisely: the clause survived on the base at
cmd_helpers.go:86while the code below it hadalready been changed to LOOK UP remote refs — a comment asserting the opposite of its function — and
on this head both greps return
exit=1(no match). The replacement states the map-key rule the codeactually implements.
Change classification
plugin-checkGo source:candy/plugin-check/cmd_helpers.go(the guard + the returned error),candy/plugin-check/live_gather.go(propagation),candy/plugin-check/cmd_helpers_addcandy_test.go(the collision test + the two boundary cases). Zero schema, zero pin, zero plan text. Tier on this
push:
analysed on a live system.Filed issues
opencharly/plugin-check#112— the class this change guards: a pin that changes the fetchedartifact and not the plan is a lookup that ignores the version. The comment on it carries the
design answer (the bare key is deliberate at its layer; the losers are dropped at
PickCandyVersion), the 7-call-site measurement for the real fix, the live proof, and the refusedcheap-green route.
opencharly/plugin-box#45— the validator arm that should have refused the inertcontext: [deploy]-on-a-check:-step combination (the sibling class from#111).opencharly/plugin-cache#10— evidence added, not filed: the assembled build fails on exactlythe
plugin-buildpin skew its body measures, and thev0.2026286.1121pin movement it names iswhat compiles.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)