Skip to content

fix(deploy): connect the substrate deploy provider at the resolution boundary - #1042

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/1038-deploy-add-connect
Oct 23, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/1038-deploy-add-connect

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

Fixes #1038: charly deploy add <new-name> failed at target resolution with
target "pod" is a known substrate but its deploy provider is not connected, while
charly config on the same binary served the same substrate.

The resolution boundary now connects the deploy provider for the resolved substrate before its
registry lookup (ResolveTarget → ensureDeployProviderConnected). That helper is the ONE
connect step (R2): dispatchLifecycleTarget's separate connectPluginByWord call is deleted, and
deployNodePluginContext no longer injects the canonical substrate ref — the second connect path
that only fired when the deploy NAME already resolved to a node, which is exactly why a new name
failed. loadDeployPlugins still loads the plugins a deploy's PLAN and add_candy: list
reference.

Verified mechanism on the pre-fix tree:

  • charly/unified_targets.go:524 ResolveTarget did a bare
    providerRegistry.ResolveDeploy(node.Target) with no lazy connect.
  • charly/plugin_loader.go:1071 deployNodePluginContext resolved name → node and returned
    (nil,nil) for a new name, so loadDeployPlugins had no substrate ref to connect.
  • charly/pod_lifecycle_verb.go:49 called connectPluginByWord(ClassDeployTarget, …)
    explicitly, which is why config worked on the same binary.

How tested

Worktree .worktrees/fix1038/charly, branched off fresh origin/main (2b7de1e0). The primary
umbrella checkout and its pre-existing dirty submodules were not touched.

# head ac087698 (git rev-parse HEAD); tree cc5036a7
$ git status --short
(empty)

Gate derived from .github/workflows/ci.yml, run under the toolchain CI pins via
setup-go (go-version-file: charly/go.mod = go 1.26.8). Each command's own exit code:

$ cd <worktree> && GOTOOLCHAIN=go1.26.8 go test ./charly/...
ok  	github.com/opencharly/charly/charly	481.315s
ok  	github.com/opencharly/charly/charly/internal/pluginsgen	136.118s
rc=0

$ for d in tools/*/; do [ -f "$d/go.mod" ] || continue; ( cd "$d" && GOWORK=off go test -count=1 ./... ) || fail=1; done
tools tests rc=0

$ gofmt -l charly tools
(empty, rc=0)

$ cd charly && GOTOOLCHAIN=go1.26.8 go run github.com/golangci/golangci-lint/v2/cmd/[email protected] run ./...
0 issues.
rc=0

Environment RCA (R1): the first lint attempt used the host default Go 1.27.3 and failed with 12
typecheck errors on internal/pluginsgen
(cannot decode "encoding", export data version 5 is greater than maximum supported version 4) —
the pinned linter cannot read Go 1.27 export data, and there was no code finding. CI's setup-go
uses charly/go.mod (1.26.8). Re-run under GOTOOLCHAIN=go1.26.8: 0 issues. The missed control
was using the host default instead of the go.mod toolchain; every gate command above is now run
with the CI toolchain.

R7 mutation control — remove the single ensureDeployProviderConnected(node.Target) line and the
new tests reproduce #1038's exact error; the already-connected control still passes:

--- FAIL: TestResolveTarget_NewDeployNameConnectsBakedSubstrate
    ResolveTarget(new name, baked substrate provider) = deployment "brand-new-baked-deploy":
    target "exampledeploy" is a known substrate but its deploy provider is not connected
    (the @github.com/opencharly/plugin-example-deploy/candy/plugin-example-deploy plugin candy
    is not compiled-in or failed to load)
--- FAIL: TestResolveTarget_NewDeployNameConnectsProjectScanSubstrate
    ResolveTarget(new name, project-scan substrate provider) = deployment "brand-new-scan-deploy":
    target "exampledeploy" is a known substrate but its deploy provider is not connected (...)
--- PASS: TestResolveTarget_AlreadyConnectedSubstrateStillResolves

The two new-name tests drive the REAL connect chain on both legs: a plugin-example-deploy
binary + .providers manifest under $CHARLY_PLUGIN_DIR (baked), and the same plugin candy
vendored into a fixture project (project scan). Both build and exec the real plugin out of process.

Live before/after (R8: the real plugin-deploy-pod plugin, no mocks; R10: a throwaway clone of
opencharly/plugin-pod with an isolated HOME/XDG_*, discarded after the run — the probe
creates no deployment). Both binaries were built from source with the same Go 1.26.8 toolchain:

# pre-fix control: origin/main 2b7de1e0, version 2026.296.1339
$ sha256sum <control>/bin/charly
ab54deb98c5d92ee728cdcde0ea362f9e6545f9ea003afa249aab86617fed378
# fixed: ac087698, version 2026.296.1616
$ sha256sum <worktree>/bin/charly
a8b5408c3d92251baa4f11704921e6eaff057ffa4b6c0d6800b1e44f5a901008
command (project opencharly/plugin-pod@ffd05f4, isolated HOME/XDG) pre-fix post-fix
config verify-baked-control (baked provider) rc=1; provider served, then image not found in local storage rc=1; identical
deploy add verify-baked-control check-pod --tag 0.0.0-none (baked, NEW name) rc=1; target "pod" ... deploy provider is not connected rc=1; provider served, proceeds past resolution, then the separately-filed unknown box "verify-baked-control" (plugin-fleet#39)
deploy add verify-scan-control check-pod --tag 0.0.0-none (project scan, NEW name) rc=1; same not-connected error rc=1; provider built + served from the project scan, proceeds past resolution, then unknown box "verify-scan-control" (plugin-fleet#39)
deploy add check-pod check-pod --tag 0.0.0-none (baked, EXISTING node) rc=1; provider served; overlay short-name "check-pod" did not resolve rc=1; identical (no regression)
deploy add check-pod check-pod --tag 0.0.0-none (project scan, EXISTING node) rc=1; provider served; same overlay failure rc=1; identical (no regression)

R5 claim-keyed sweep — the duplicate connect path is gone; only the shared helper calls the
connect:

$ git grep -n 'connectPluginByWord(ClassDeployTarget' -- charly
charly/plugin_loader.go:636:	connectPluginByWord(ClassDeployTarget, target)

$ git grep -n 'canonicalProviderRef(ClassDeployTarget' -- charly
charly/deploy_plugin_load_test.go:100:		got := canonicalProviderRef(ClassDeployTarget, word, "", "")
charly/deploy_plugin_load_test.go:108:		if canonicalProviderRef(ClassDeployTarget, word, "", "") == "" {
charly/unified_targets.go:566:		ref := canonicalProviderRef(ClassDeployTarget, target, "", "")

unified_targets.go:566 is the error-message lookup, not a connect; the deployNodePluginContext
injection site is deleted.

R10 disposable bed (charly check run check-pod on opencharly/plugin-pod, disposable: true):

$ <worktree>/bin/charly check run check-pod     # opencharly/plugin-pod@ffd05f4, check-pod = disposable: true
charly check run check-pod: [image-build] PASS after 11.136s
charly check run check-pod: [check-image] PASS after 28.777s
charly check run check-pod: [deploy-add] PASS after 16.624s
charly check run check-pod: [config] PASS after 8.195s
charly check run check-pod: [start] PASS after 7.284s
charly check run check-pod: [wait-ready] PASS after 2.34s
charly check run check-pod: [check-live] PASS after 30.464s
charly check run check-pod: [feature-run] PASS after 24.172s
charly check run check-pod: [update] PASS after 42.109s
charly check run check-pod: [rebuild-ready] PASS after 2.249s
charly check run check-pod: [check-live-rebuild] PASS after 29.23s
charly check run check-pod: [feature-run-rebuild] PASS after 23.166s
charly check run check-pod: [cleanup] PASS after 8.19s
charly check run check-pod: PASS (steps=16)

# .check/check-pod/2026.296.1623/summary.yml
ok: true
driver_version: 2026.296.1616
diagnostics: {errors: 0, warnings: 0, advisories: 0, allowlisted: 15}
# the 15 allowlisted findings are the documented dev-worktree-binary-notice (#328) — one per
# process, informational, deliberately allowlisted by the runner; there are no unallowlisted
# warnings. `update` is the destroy + fresh-rebuild leg, so R10's fresh-rebuild is exercised.

The first (isolated-HOME) bed attempt failed in image-build on the /tmp tmpfs quota
(tar: Wrote only 9216 of 10240 bytes, 84% full) — an environmental cap, not the change; the bed
was re-run in the real user environment with podman storage on the root fs, where it passed all 16
steps. The failed run left no deployment.

Rulebook compliance

  • R0: skills loaded before source: internals/git-workflow, internals/go, internals/strict-policy,
    internals/root-cause-analyzer, core/deploy, check/check, internals/disposable,
    internals/cutover-policy, internals/plugin, internals/go-quality, charly/AGENTS.md.
  • R1: The lint toolchain failure got a fresh RCA (missed control: host default Go instead of
    go.mod; root fix: every gate command runs with the CI toolchain) before the re-run. The live
    post-fix run exposed a downstream defect past resolution; RCA'd to the ref being dropped from the
    wire request in opencharly/plugin-fleet, a different repo and separable from this change's
    claim (the command now CONNECTS and proceeds past resolution, which is this issue's fix). Filed
    as plugin-fleet#39 and listed below. Zero warnings in the final gate.
  • R2: One connect mechanism, ensureDeployProviderConnected, called from the resolution
    boundary. The duplicate in pod_lifecycle_verb.go and the node-keyed inject in
    deployNodePluginContext are deleted (R5).
  • R3: No sleep, retry, fallback branch, magic fixture, or ad-hoc infrastructure command. The
    connect uses the existing connectPluginByWordRef chain (baked first, then project scan).
  • R4: Product before prose; no documentation was routed around a defect.
  • R5: The second connect path and its claims are deleted in the same cut; the greps above are
    the sweep.
  • R6: git status was captured before any action; the primary checkout and other sessions'
    dirty submodules were not touched. No force-push, amend-after-push, or direct push to main.
  • R7: Both new tests fail without the fix (mutation control pasted) and pass with it; the live
    changed path executed with pasted output and rcs.
  • R8: Live runs use the real plugin-deploy-pod binary/project scan; nothing is mocked.
  • R9: Worktree-local CalVer build via scripts/bootstrap-charly.sh;
    ./bin/charly version → 2026.296.1616; binary sha256 pasted above.
  • R10: The change-class gates above passed on the committed tree; the disposable check-pod bed
    result is pasted. No agent merges.

Change classification

Runtime Go change in charly core (unified_targets.go, plugin_loader.go,
pod_lifecycle_verb.go) plus Go regression tests. No schema, wire, CLI-surface, or packaging
change. Gate: the repo's CI workflow commands plus the live reproduction and the disposable R10 bed.

Filed issues

Closes #1038
Agent: containerd-crabbox-program/fix1038 · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

#1038)

`ResolveTarget` looked the deploy provider up in the registry with no lazy
connect, and the only connect on the `deploy add` path was the node-keyed
canonical-ref inject in `deployNodePluginContext`. A deploy name that was
not already a node in the merged project tree therefore never connected
its substrate: `charly deploy add <new-name>` failed with `target "pod" is
a known substrate but its deploy provider is not connected`, while
`charly config` on the same binary succeeded because
`dispatchLifecycleTarget` called `connectPluginByWord` directly.

ResolveTarget now calls `ensureDeployProviderConnected`, one shared step
that is idempotent and uses the existing baked-then-project-scan chain.
The duplicate connect in `pod_lifecycle_verb.go` is deleted, and the
canonical-ref inject in `deployNodePluginContext` is deleted with it: it
was the second connect path, it worked only when the name already
resolved to a node, and it collided with a baked provider instead of
deduplicating.

Regression tests drive both real connect legs (baked and project scan)
from the resolution boundary with a new deploy name; both fail on the
pre-fix tree with #1038's exact error. The already-connected control
keeps the existing-node and config paths green.

Closes #1038
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
@aitrawog

Copy link
Copy Markdown
Contributor Author

STATUS — #1042

Head ac087698 on feat/1038-deploy-add-connect, based on fresh origin/main (2b7de1e0).

Done: the substrate provider is connected at the resolution boundary (ResolveTarget → ensureDeployProviderConnected); the duplicate connectPluginByWord in the lifecycle path and the node-keyed canonical-ref inject in deployNodePluginContext are deleted. Full CI gate green under the go.mod toolchain (Go 1.26.8): go test ./charly/..., the tools/* sweep, gofmt, and the pinned golangci-lint (0 issues). New baked and project-scan tests fail on the pre-fix tree with #1038's exact error. Live before/after on the issue's reproduction, and the disposable check-pod R10 bed PASS (16 steps, errors 0 / warnings 0). Filed opencharly/plugin-fleet#39 for the downstream ref-scoping defect exposed past resolution.

Next: awaiting the fresh charly/pr-validator verdict; every finding will be fixed or rebutted in full before any further push.

Agent: containerd-crabbox-program/fix1038 · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

What the change does

The diff implements exactly what the body claims: ResolveTarget now calls ensureDeployProviderConnected(node.Target) immediately before providerRegistry.ResolveDeploy, and that helper (plugin_loader.go) is the single connect step (connectPluginByWord → connectPluginByWordRef, baked-first then project scan, registry-hit short-circuit). The two former duplicate paths are removed in the same cut:

  • pod_lifecycle_verb.go: the explicit connectPluginByWord(ClassDeployTarget, node.Target) is deleted; dispatchLifecycleTarget still reaches the connect because it calls ResolveTarget right after loadDeployPlugins.
  • plugin_loader.go deployNodePluginContext: the node-keyed canonicalProviderRef injection into addCandy is deleted; refWords still surfaces every substrate word (including nested children) to scope the scan, and the provider itself is connected at resolution.

The comment updates in unified_targets.go and deploy_plugin_load_test.go accurately describe the new mechanism; no stale comment still claims the deleted inject exists. The R5 greps in the body are consistent with the diff (connectPluginByWord(ClassDeployTarget appears only inside the helper; the remaining canonicalProviderRef(ClassDeployTarget hits are the test and the error-message lookup, not a connect).

Correctness / honesty

  • The pre-fix mechanism described in the body (ResolveTarget bare lookup, deployNodePluginContext returning no node for a new name, pod_lifecycle_verb.go explicit connect) matches the removed lines in the diff.
  • File count (5), the per-file +/- counts, and the commit (single ac087698) are internally consistent with the diff headers.
  • The fix is genuinely targeted: ensureDeployProviderConnected is idempotent (registry hit is the whole operation; connectPluginByWordRef re-checks before both legs), so the already-connected and config/lifecycle paths are not turned into a second connect.
  • The behavioral difference (externalized substrate connected at ResolveTarget instead of during loadDeployPlugins) is the same chain config already used successfully, and the live table covers the existing-node case on both baked and project-scan legs.

Tests

  • deploy_provider_connect_test.go adds real regression coverage for both connect legs (baked binary + .providers; vendored candy in a fixture project) plus an already-connected no-regression control that also exercises dispatchLifecycleTarget("config", …).
  • The tests drive the real out-of-process plugin (build + exec), are gated behind -short like the existing external-plugin suites, and assert the routed type is *pluginDeployTarget.
  • The mutation control in the body (removing the single ensureDeployProviderConnected line reproduces deploy add: 'target pod is a known substrate but its deploy provider is not connected' while the same binary serves config #1038's exact error; the already-connected control still passes) is the right control for this fix.

Security / scope

No secrets, no injection surface, no privilege change; only test-local file copies and plugin exec, consistent with existing test infrastructure. Scope is coherent — one helper, one call site, two deletions, tests — with no leftover legacy path or dead code.

Comments

The single comment (@aitrawog) is a status update by the PR author, not a maintainer sign-off; no designated maintainers are configured, so it is not treated as approval. Its claims (head ac087698, the same deletions, green gate, filed plugin-fleet#39) match the current diff and body and are not contradicted by anything in the PR state.

Minor, non-blocking observations

  • The doc comment above registeredCloserCount in the new test file describes closeClosersFrom rather than the function it annotates.
  • closeClosersFrom closes the delta closers but leaves them in providerRegistry.closers; this is harmless given the LIFO snapshotProviderState restore, but a follow-up could remove the closed entries for tidiness.

Neither affects the fix's correctness, and the full go test ./charly/... gate plus the live and R10 runs stand as evidence.

Verdict: PASS


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

View action run

@aitrawog

Copy link
Copy Markdown
Contributor Author

STATUS — both post-merge observations are addressed in #1043.

  1. The closeClosersFrom doc comment now sits on closeClosersFrom; registeredCloserCount has its own one-line doc.
  2. The comment now records why the closed entries deliberately stay in providerRegistry.closers (snapshotProviderState's LIFO restore replaces the slice), so observation 2 needs no behavior change.

#1043 is a comment-only follow-up (0 non-comment lines), gated by gofmt, go vet, the targeted package test, and the pinned golangci-lint (0 issues).

Agent: containerd-crabbox-program/fix1038 · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed)

github-actions Bot pushed a commit that referenced this pull request Oct 23, 2026
…tion (#1042) (#1043)

The post-merge pr-validator observation on #1042: the `closeClosersFrom`
doc comment sat above `registeredCloserCount`, describing the wrong
function. Move it onto `closeClosersFrom`, and state why that helper
keeps the closed entries in the registry slice — snapshotProviderState's
LIFO restore replaces the slice, so truncating in the helper would
duplicate the restore's work (the validator's second observation).

Comment-only; no behavior change.

Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed)

Co-authored-by: Andreas Trawoeger <[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.

deploy add: 'target pod is a known substrate but its deploy provider is not connected' while the same binary serves config

2 participants