Skip to content

feat(spec): one canonical deploy add_candy ref collection - #310

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix-112/scoped-addcandy-refs
Nov 13, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix-112/scoped-addcandy-refs

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Head ad1a8e6baa24bfe3a29e47a2477d63075ac14a12 — one commit, 2 files, +84/−0 (git rev-parse HEAD), branched from origin/main at 83ad4dd.

Summary

opencharly/spec#309: the question "which add_candy: refs does this deploy contribute, and at what composition scope?" had three hand-written answers. This adds the ONE mechanism — (*Deploy).ScopedAddCandyRefs(scope string) []ExtraCandyRef in spec/deploy_addcandy.go, beside the member-tree accessors it walks (member_tree.go) and the scope constructors it tags with (resolve_opts.go).

The three consumers it must serve:

consumer site
the host's plugin-LOADING collection charly/charly/plugin_loader.go:1164 (deployNodePluginContext)
the pod-overlay build charly/charly/build_overlay.go:360 (overlayCandies)
the externalized check command's resolved-project widening opencharly/plugin-check's addCandyRefsForEntity (opencharly/plugin-check#147)

The last one exists because a plugin cannot import core, and neither ResolvedProject nor spec.CheckLoadPluginsReply carries the refs (go doc … ResolvedProject | grep -ci extracandy → 0; the reply is empty by design), so ResolvedProjectRequest.ExtraCandyRefs — a REQUEST field — is the only channel and every caller must supply the input. Without a shared home each caller hand-writes the loop; that is the duplication this removes.

The traversal contract (the thing all three must agree on, and what the test pins):

  • a member authored INSIDE the kind body (Member.InSubstrate()) is deployed into its parent's venue, is part of its parent's composition, and shares its scope;
  • a DEPLOY-LEVEL member (Member.Alongside() — a sibling of the kind key) is its own composition, addressed by its own name, and is not visited;
  • scope is the caller's, normally spec.BoxScope(<deploy name>), because a deploy IS its box — a constant label is the charly#739 false-conflict bug (two independent deploys legitimately pin one candy at different tags).

What this does NOT do: it does not migrate the two charly call sites. Those are that repo's own write scope in the campaign that found this (charly-plugins is live in charly), and opencharly/spec#309 stays open until they consume this and delete their loops. This PR is the shared home the consumers need, which is the part that must exist first.

How tested

$ GOWORK=off go build ./... ; echo "build rc=$?"
build rc=0

$ GOWORK=off go test ./... 2>&1 | tail -5
ok  	github.com/opencharly/spec/spec	2.718s
?   	github.com/opencharly/spec/sshx	[no test files]
ok  	github.com/opencharly/spec/storeroot	0.003s
?   	github.com/opencharly/spec/testkit	[no test files]
ok  	github.com/opencharly/spec/transport	0.184s

$ gofmt -l spec/
(no output)

$ GOWORK=off go test ./spec/ -run TestScopedAddCandyRefs -v
=== RUN   TestScopedAddCandyRefs
--- PASS: TestScopedAddCandyRefs (0.00s)
PASS
ok  	github.com/opencharly/spec/spec	0.007s

The new test is mutation-proven: dropping the in-substrate recursion from the traversal turns it RED (the nested candy's ref disappears and the count drops from 3 to 2), and the restored tree is GREEN.

$ GOWORK=off go test ./spec/ -run TestScopedAddCandyRefs      # recursion removed
--- FAIL: TestScopedAddCandyRefs (0.00s)
    deploy_addcandy_test.go:27: collected 2 ref(s), want 3: [{Ref:@github.com/opencharly/layer-direnv:v2026.287.2155 Scope:box=check-arch-vm} {Ref:local-candy Scope=box=check-arch-vm}]
FAIL
FAIL	github.com/opencharly/spec/spec	0.006s

$ GOWORK=off go test ./spec/ -run TestScopedAddCandyRefs      # restored
ok  	github.com/opencharly/spec/spec	0.007s

The test also pins the two shapes a real tree reaches: a node with no add_candy: collects nothing, and a nil receiver does not panic (a member entry can carry no node body).

No schema is touched, so charly task cue-gen stays a no-op — this is hand-written behaviour beside the generated types, the same class as member_tree.go's accessors. No cue-gen artefact is in the diff:

$ git diff --name-only origin/main...HEAD
spec/deploy_addcandy.go
spec/deploy_addcandy_test.go

Rulebook compliance

  • R0 — loaded before the work: git-workflow, root-cause-analyzer, check; this repo's AGENTS.md read first, including its Go gate (build, test, gofmt, lint under the declared toolchain).
  • R1 — this PR IS the R1 cure for a finding raised on fix(check): a deploy's add_candy refs ride the resolved-project request, so the child phase asserts the PINNED coordinate plugin-check#147 (a duplicate ref-collection traversal in new code); the remaining half — migrating the two charly sites — is opencharly/spec#309's own close condition, recorded there rather than claimed here.
  • R2 — the whole point: one canonical implementation of the collection, in the module that owns both the member tree and the scope vocabulary. No second copy is added anywhere by this diff.
  • R3 — no sleep, retry, fallback or magic value; the method is a pure traversal over an authored tree.
  • R4 — product before prose: the mechanism exists before any consumer is asked to describe using it.
  • R5 — nothing is deleted or renamed here, so no legacy path exists to sweep; the stale per-consumer loops are removed by the consumers' own migrations, tracked by spec#309.
  • R6 — git status --short before staging listed exactly the two new files; one appended commit; no force-push, no bypass; Agent:/Assisted-by: trailers in order.
  • R7 — the test fails without the traversal (mutation pasted above), and the mechanism is exercised by a real caller in the round that follows this tag.
  • R8 — no service boundary is involved: the method is pure over spec.DeployNode.
  • R9 — this module ships no binary; the change is source-only and the gates above are the module's own.
  • R10 — no disposable: true target is involved: spec ships no image and composes no box (charly.yml says so), so there is no bed this change could alter. The live proof of the shared mechanism is its first consumer's bed, which is fix(check): a deploy's add_candy refs ride the resolved-project request, so the child phase asserts the PINNED coordinate plugin-check#147's own R10 run.

Change classification

An additive exported method on an existing type (spec.DeployNode, alias of Deploy) plus its unit test. No schema, wire, generated file or pin changes. Breaking change + rollback: none — nothing existing is renamed or removed, and no call site changes in this repo; consumers adopt it on their own schedule (spec#309). Rollback is to revert this one commit.

Agent: fix-112
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)

ScopedAddCandyRefs answers "which add_candy: refs does this deploy contribute, and at
what composition scope" ONCE, beside the member-tree accessors it walks and the scope
constructor it tags with. Three consumers need exactly this traversal and must agree on
it: the host's plugin-LOADING collection (charly/plugin_loader.go's
deployNodePluginContext), the pod-overlay build (charly/build_overlay.go's
overlayCandies), and the externalized check command's resolved-project widening
(opencharly/plugin-check#147's addCandyRefsForEntity). A plugin cannot import core, and
neither ResolvedProject nor CheckLoadPluginsReply carries the refs, so the shared home is
this module - otherwise each consumer hand-writes the same loop (#309).

The traversal boundary is the authored POSITION: an in-substrate member is part of its
parent's composition and shares its scope; a deploy-level member is its own composition and
is not visited. Scope is the caller's (normally BoxScope of the deploy name) - a constant
label is the charly#739 false-conflict bug.

No schema change: a hand-written method beside member_tree.go's accessors, with a unit
test that fails when the in-substrate recursion or the scope tag is dropped.

Agent: fix-112
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: ad1a8e6baa24bfe3a29e47a2477d63075ac14a12 (branch: fix-112/scoped-addcandy-refs)

Security screen: PASS
Checklist: All applicable rules PASS or NA.

  • Additive-only exported method + mutation-proven unit test; diff matches the body's accounting (+84/−0, 2 files) and the pasted git diff --name-only/build/test/gofmt output is internally consistent (mutation → 2 refs matches the pasted FAIL).
  • Placement: spec is the correct shared home for a kind-blind traversal over spec.DeployNode/BoxScope (consistent with existing member_tree.go/resolve_opts.go); no schema/wire/generated file touched, so SDD is NA.
  • Non-blocking note: migrating the two charly consumers is genuinely cross-repo and tracked by the pre-existing umbrella opencharly/spec#309, not a parking phrase without a filed issue — acceptable (no ## Filed issues section required since this PR files/updates no new issue).

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 13, 2026 18:28
@github-actions
github-actions Bot merged commit 78518e8 into main Nov 13, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 13, 2026
aitrawog pushed a commit to opencharly/plugin-check that referenced this pull request Nov 13, 2026
…ies 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)
github-actions Bot pushed a commit to opencharly/plugin-check that referenced this pull request Nov 13, 2026
…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]>
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.

1 participant