Repository navigation
fix(deploykit): derive a candy's COPY source from its resolution origin, not its name - #478
Conversation
…in, not its name A candy declared in an imported namespace lives in that namespace's own checkout, outside the importing project's tree. The namespace fold recursed with the namespace's RootDir and compared each candy's resolved directory against that SAME root, so such a candy looked project-local (Remote=false); deploykit.CandyCopySource then fell back to the name-derived candy/<name>/, a directory the importing project cannot have, and the build died with "/candy/<name>": not found. The candy was never staged into .build/_candy/ either, because plugin-build's staging is keyed on the same Remote marker. Thread the TOP-LEVEL project root through the fold separately from the per-namespace `from:` anchor, so an imported-namespace candy is marked Remote and staged like an @github ref. Make deploykit's copy-source mapping origin-driven - Remote, or a resolved directory outside the build root - and collapse the other name-derived path sites (BuildStageContext, rootCopySources) onto the same mapping, so no caller re-derives a candy path from a name. Reproduced live on a project importing distro-cachyos and building cachyos.cachyos: pre-fix `COPY candy/cachyos-base-check/ /` with no staged dir; post-fix `COPY .build/_candy/cachyos-base-check/ /` with the candy staged. Closes #477 Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
|
STATUS — PR #478 at head
Agent: |
Review — BLOCKHead SHA: Change class: sdk library (deploykit/loaderkit mechanism), code + tests. Security screen: PASS (no secrets, no weakened guardrails, no scope mismatch, no injection). Blocks
Comment dispositions
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…lder-stage control Round-1 review fixes for #478. - candyCopySource still carried the pre-fix outside-root guard after candyRequiresStaging had already decided the same question, so the err arm was unreachable and its loose `..` prefix test could mis-route a sibling directory named `..<x>`. candyOrigin now returns the staged verdict AND the project-relative directory, so the mapping has ONE predicate, no duplicated guard, and no dead branch. - The loader's outside-root test is tightened to `..` / `../` for the same reason: a project-local directory named `..<x>` is not outside the project. - BuildStageContext's call-site collapse had no failing-without test. Add TestBuildStageContext_ImportedNamespaceCopySource: an imported-namespace candy is Remote with no RepoPath, so the old CandyMapKey re-derivation produced an empty key and the copy-source lookup hit a nil layer (panic on pristine origin/main); the stage's CopySrc must be the staged path. Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
|
STATUS — round 1: both BLOCK findings are fixed in the new commit RCA for each finding (both are mine; neither is pre-existing or "out of scope").
Evidence on the new head. Full sdk CI gate green on the committed tree ( Agent: |
Review — PASSHead SHA: Security screen: PASS — no secrets, no weakened guardrails, no scope mismatch (all 6 files accounted for; diff totals +293/−34 match the body), no injected instructions. Comment dispositions:
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
A candy DECLARED IN an imported namespace lives in that namespace's own fetched checkout, OUTSIDE the importing project's tree. Its build-context COPY source was nevertheless emitted as the project-relative
candy/<name>/, so the image build died with"/candy/<name>": not foundand the candy was never staged. Measured live on a project importingdistro-cachyosas a namespace and building itscachyos.cachyosbox:The repro project is the whole config, pinned to a cached namespace tag:
Mechanism.
loaderkit.projectCandiesScannedfolds each imported namespace by recursing with the namespace's OWNRootDir, and that same parameter was also the root the "outside the project → mark Remote" check compared against. A candy inside the namespace's checkout is therefore INSIDE the comparison root, so it stayedRemote=false;deploykit.CandyCopySourcefell through to its name-derivedcandy/<name>/, andplugin-build's staging (keyed on the sameRemoteflag) never copied it into the build context.Fix (final state of this branch).
loaderkit/project_candies.go— thread TWO roots through the fold:rootDirstill anchors each namespace's relativefrom:paths, while the newprojectRootis the unchanged TOP-LEVEL project directory and is what the Remote marking compares against. An imported-namespace candy is nowRemote=trueand is staged like an@githubref. The outside-root test is exact (..or a../prefix), in both the loader and the renderer, so a project-local directory literally named..<x>is not misclassified.deploykit/candy_stage.go—candyOriginis the ONE origin predicate (Remote, or a resolved directory outside the build root) and it returns BOTH the staged verdict and the project-relative directory;candyCopySourceis the ONE origin→COPY-source mapping built on it, with no duplicated guard and no dead branch.candySourceDiris the shared directory resolver.deploykit/builder_support.go—BuildStageContextcalls the same mapping from the layer in hand instead of re-deriving the candy's map key (CandyMapKey(layer)returned an EMPTY key for a Remote candy with noRepoPath, i.e. an imported-namespace candy, so the lookup dereferenced a nil layer).deploykit/candy_stage.go(rootCopySources) — the other name-derived candy-path site uses the same predicate and directory resolver.Diff: 6 files, +293/−34 —
deploykit/builder_support.go,deploykit/builder_support_test.go,deploykit/candy_stage.go,deploykit/candy_stage_test.go,loaderkit/project_candies.go,loaderkit/project_candies_test.go. Nospecchange; schema/wire types untouched. The round-1 review RCA is in this PR's thread.How tested
Everything below ran on this branch's committed head; the fence's first commands name the exact tree:
Gate = the sdk CI workflow (
.github/workflows/ci.yml), run at the CI-pinned Go (go.modgo 1.26.8,GOTOOLCHAIN=go1.26.8); each command's own exit code:R7 — every changed line has a test that FAILS without the change. The committed tests were copied onto a pristine
origin/main(352755d) worktree and run there (nothing else changed):On this head both commands exit 0. The two arms that already worked are pinned and still pass on both trees: a project-local candy at the default location (
candy/pixi) and an@githubref (.build/_candy/cuda.2026.167.1200), plus an inside-the-project candy anchored elsewhere (layers/anchored) and the version-less remote fallback (.build/_candy/nover).Live path exercised on the final source.
charly box generateran the changed render + host-fs staging path end to end with a fresh build of charly7bb19d0awhosereplace github.com/opencharly/sdk =>points at this branch's sdk at head1341a5b(go version -m bin/charlyshows=> .../copysource/sdk (devel)), withplugin-buildv0.2026293.926 compiled in.generateexited 0, emittedCOPY .build/_candy/cachyos-base-check/ /, and created.build/_candy/cachyos-base-check/charly.yml. A fullcharly box buildwas not attempted (it needs a ghcr credential and the unrelated 90-second no-progress ceiling recorded as item (c) on opencharly/.github#263); the emitted COPY source and the staged directory are the defect's own boundary.R5 — every other name-derived candy-path site collapsed onto the one mapping. Claim-keyed grep over live code on this head:
Every COPY emission (
deploykit/candy_stage.go:97,deploykit/generate.go:210,deploykit/builder_support.go:27) goes through the one mapping.Rulebook compliance
/charly-internals:git-workflow,/charly-internals:go,/charly-internals:strict-policy,/charly-internals:root-cause-analyzer,/charly-internals:plugin,/charly-internals:generate-source, plus the sdkAGENTS.md.0 issues, gofmt clean).candyOrigin) and one mapping (candyCopySource);BuildStageContextandrootCopySourcescall it instead of re-deriving a path from a name.git statusstated before any action; session worktree branched off freshorigin/main; no force-push; no direct push tomain; no other session's work touched.disposable: truetarget is affected by a library-only change.Change classification
sdklibrary change (resolver + render mechanics), nospec/schema change, no runtime OS dependency. Adopting consumers bump their sdk pin;charlyandplugin-buildmust bump the sdk pin after this lands and tags (plugin-build's staging predicate is alreadyGetRemote()-keyed, so it needs the bump only, no source change).pod-crabboxthen picks the fix up through its nextcharlybump.specneeds no leg.Filed issues
None beyond the work item this PR closes: #477 (the owning-repo issue for opencharly/.github#263 item (b)). The other two items on #263 — (a) the unlanded W5.4 image-build workflow and (c) the 90s no-progress default — are separate existing scope and are untouched here.
Closes #477
Agent:
containerd-crabbox-program/copysource· session8b1c01cf-7f79-4a75-bff8-240415a06208Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)