Repository navigation
fix(sdk): an unresolvable build-config COPY is a generate error, not an emitted directive - #337
Conversation
…an emitted directive materializeBuildConfigAsset probed a build-config asset in the project tree and then in every remote candy's repo@version cache root, and returned relPath unchanged when both missed — emitting `COPY <relPath>` into a Containerfile whose build context IS the probed `dir`. That directive can only fail inside the engine, with a `copier: stat: "<relPath>": no such file or directory` naming neither the candy nor the cache. This is the third instance of the "the init runtime was never materialized" defect class this wave exists for; the first two were the missing fetch and the missing injection. `dir` is the build context the emitted COPY resolves against: the Containerfile is written to buildDir/<box>/Containerfile and the build runs with `dir` as its context, which is exactly why the materialized branch returns a `.build/_buildconfig/...` path relative to `dir` rather than to buildDir. Both probes therefore test the very path that a `COPY <relPath>` would resolve to, so the fallthrough was reachable ONLY when the COPY was already doomed — failing there is a pure fail-fast conversion that can never reject a build which would otherwise have succeeded. The error names the asset, the project-tree path that was tried, and every cache root that was searched, so the failure is diagnosable without the engine log.
Review — PASSHead SHA: Security screen: PASS (T1–T4 clear — no spec/rulebook/guardrail edit, no secrets or egress, no new deps or Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Relates to opencharly/charly#764 — the init-polymorphism defect class. This is the third
instance of that class, one layer below the two
#336already fixed (the missing fetch, the missinginjection).
Summary
sdk/deploykit/header_copy_remote.gomakes a build-config asset referenced by a remotely-includedbuild.yml— the initheader_file— reachable from the image build. It probed the asset in theproject tree, then in every remote candy's
repo@versioncache root, and returnedrelPathunchanged when both missed:
The caller (
rewriteHeaderCopyForRemote, reached fromdeploykit/init.go:257) puts that valuestraight into the emitted
COPY <src>, so a miss produced a directive naming a source that had justbeen proven absent, and the image build then died inside the engine with
copier: stat: "<relPath>": no such file or directory— naming neither the candy nor the cache root.That is exactly the P1 symptom this wave is about.
RCA — is the fallthrough ever correct?
No, and that is what makes the fix safe.
diris the build context aCOPY <src>resolvesagainst:
deploykit/generate.gowrites the Containerfile tog.BuildDir/<box>/Containerfilewithg.BuildDir = filepath.Join(dir, ".build")(render_generator_from_project.go:160), and the buildruns with
diras its context. That is exactly why the materialized branch returns.build/_buildconfig/<relPath>— adir-relative path, not abuildDir-relative one. Both probesin the function therefore test the very path a
COPY <relPath>would resolve to.Once both probes have missed, the directive cannot do anything but fail. The fallthrough was
reachable only when the COPY was already doomed, so turning it into a generate-time error is a
pure fail-fast: it can never reject a build that would otherwise have succeeded, and it converts an
opaque engine error into one that reports the asset and every root that was searched.
What changed
deploykit/header_copy_remote.go(+31/−4) — the cache roots are bound once(
roots := remoteBuildConfigCacheRoots(candies)) instead of being recomputed in the loop header,and the fallthrough becomes a hard error naming the asset, the project-tree path that was tried,
and every cache root searched. When there is no remote candy at all the message says
no remote candy is in the resolved setrather than printing an empty list. The doc comments nowstate the build-context invariant the reasoning rests on, and that a non-COPY line still passes
through as-authored (the new error must not over-fire).
deploykit/header_copy_remote_test.go(new, 169 lines) — six tests covering: the missingasset being a hard error that names asset + local path + searched root; the no-remote-candy
wording; the remote cache root still materializing to a
dir-relative source that really existsthere; the local project asset still passing through unchanged; the wrapper propagating rather
than swallowing; and non-COPY lines passing through verbatim.
How tested
All of the following was run on the final committed tree,
86962b0(
git rev-parse HEAD→86962b0f68e4bbe15c78d6b2ca0bbad7eb820c11), after the fail-without-changeround-trip below had been restored —
git status --shortwas empty first. The repo's own gate, perits
AGENTS.md:Plus the CI cross-compile matrix (
.github/workflows/ci.yml):The test fails without the change
git checkout HEAD~1 -- deploykit/header_copy_remote.go(fix reverted, test kept):The failure text is the defect itself: the old code returns the unresolvable
relPathwith anilerror, and the wrapper emits the doomed
COPYverbatim.Restore verified —
git checkout HEAD -- deploykit/header_copy_remote.gothen:Why a unit test is the right boundary here (R7a)
This function crosses no live-service boundary: it is a filesystem
statplus acp, with nonetwork, no
ghcall, no engine call.R7arequires the live-or-skip discipline for a boundary thattalks to a real service and explicitly keeps "pure/deterministic in-repo logic unit-testable
normally". No mock or stub of any external service is involved — the tests exercise the real exported
mechanism against real temporary trees. There is no
LIVE_-gated test indeploykittoday, becausenone of its surface needs one.
The live end-to-end path
RewriteHeaderCopyForRemoteis wired byNewRenderGeneratorFromProjectand driven by a plugin overthe reverse channel. Its success branches are unchanged by this PR (same inputs → same outputs);
only the previously-unreachable-and-doomed branch changes behaviour. Driving it end to end against a
real charly requires a charly binary built against this sdk, which is the consumer leg held behind
opencharly/charly#762— so that run is downstream of this PR, not a substitute for it.Rulebook compliance
/charly-internals:plugin(its "when touse" names
sdk/**code explicitly),/charly-internals:go,/charly-internals:install-plan(thethree the sdk
AGENTS.mdlists),/charly-internals:git-workflow(before any git/PR action),/charly-internals:root-cause-analyzer(the RCA above is its 8 steps).expected behaviour (the fallthrough leaves the directive as-authored), actual (it emits a directive
that cannot resolve), mechanism (both probes test the same path the COPY resolves to, so a double
miss is a guaranteed engine failure), missed control (nothing ever asserted the asset existed),
blast radius (any project whose remote
build.ymlnames a header asset no cache root carries),root cause (a "not found" branch that returned success), root fix (fail where both paths are still
known), documented (here +
charly#764).outright; no compatibility shim or toggle is added.
remoteBuildConfigCacheRootsand states the invariant in the doc comment over the singleimplementation.
(
sdk), one layer below the two#336landed. The symptom it removes was previously "workedaround" only by the operator reading an engine log.
git status --shortis empty after every step;the fail-without-change round-trip was done with
git checkout <ref> -- <path>and verifiedrestored, never with a stash.
pasted above; the fail-without-change run proves the test is not vacuous.
one is introduced.
the failure path changes, and it changes from a silently-broken artifact to no artifact plus an
error.
plus test.
the round-trip restore, not from an edited state, and the change ships a test that fails without it.
.worktrees/polymorphism-truth/sdk, onfeat/polymorphism-truth-headercopy; thesdksubmodule'stracked checkout stays detached at its gitlink.
The search-first check found no existing thread for this defect in
sdk;#334/#310are othersessions' PRs and were left alone.
head
86962b0before the push;charly#764's live comments were read first and are answered by theSTATUScomment posted alongside.Change classification
sdk/deploykit). No schema, wiretype, or public API change; no new dependency; no pin touched.
sdkrepo's own full gate —gofmt -l/go build ./.../go vet ./.../go test -count=1 ./...(all 16 packages) plus the CIcross-compile matrix (
linux/{amd64,arm64,arm,386},CGO_ENABLED=0) — run in full on the finalcommitted tree
86962b0, output pasted above, plus a test that fails without the change.fully tested and validated../charly/bin/charly task verifyis the umbrella's gitlink pinningaudit, and this PR touches no gitlink — it changes one sdk library function, so that gate is not
this change's gate. I ran it anyway to check, and it cannot execute in this checkout:
charly: error: command "task": load project: …/opencharly/charly.yml: schema 2026.261.1747 is required (found ""). Run: charly migrate. RCA (measured, not assumed): the umbrella'scharlysubmodule checkout is detached at its gitlink
48d03519=v2026.275.0315, which predates the#749/#754cutover fix that lets charly load a manifest without the retiredversion:stamp.So the umbrella's entire
task …maintenance surface is unusable — and acharly/scripts/bootstrap-charly.shrebuild reproduces it exactly, because that script buildsfrom
charly/, i.e. from the same stale gitlink. The remedy is an umbrella pin bump, which isa gitlink-change class and must not ride along in this diff. Owning batch:
opencharly/opencharly#330(already filed, carrying this RCA) — the same routing the umbrellaharness-config PR carries. Surfaced here rather than parked; out of scope for an sdk-only PR.
Agent:
polymorphism-truth· session9c898e99-b5d7-4f3e-a472-62c4ecbcd18fAssisted-by: Claude Code DeepSeek V4.1 (flash) (fully tested and validated)