Repository navigation
fix(build): downloads cache mount follows the task's stage user - #79
Conversation
EmitDownload always emitted a shared root-owned cache mount for the content-addressed downloads cache: the first root-stage download made the backing root-owned, after which every non-root stage's download failed with curl: (23) write error — reproduced serially on any box with a non-root download step. The mount now follows the task's stage user via the new taskRunsAsRoot (root RunAs, or a root image build user when RunAs is empty): non-root stages get an uid/gid-owned cache (id=charly-tmp-downloads-uid<uid>, the pixi/npm-cache ownership pattern); root stages keep the shared form. TaskCacheMounts uses the same decision — it previously mapped an empty RunAs to root via ResolveUserSpec and shared the same latent bug. Verified: TestTaskRunsAsRoot + TestEmitDownload_DownloadsCacheOwnership; full GOWORK=off battery green; live proof: a previously curl-23-failing image builds past the download step with a root-owned shared cache present on the host. Assisted-by: Kimi Code (Moonshot K3; analysed on a live system)
pr-validator — APPROVED ✅Bound identities (verified live, read-only):
Change class: charly/sdk Go (build-emission fix in Checklist
Comments consideredNone — the PR carries no comments or reviews (verified via Cross-PR interactions considered
Observation (verified-non-blocking)
DecisionCompliant on every applicable item at the honestly-claimed tier. The changed emission path executed live in a fresh full build of the maximal affected image against the exact failing environment (host root-polluted shared cache), and I verified the fix at the emitted-artifact boundary, in the built binary (content marker), and through my own full gate re-runs (fmt/vet/build/test/lint, all zero-warning). Merge-time CalVer finalization (placeholder rename + H1 re-stamp), status re-post on the new head, squash-merge, and the sdk Go-module tag ( Assisted-by: Kimi Code (Moonshot K3; analysed on a live system) |
Assisted-by: Kimi Code (Moonshot K3; analysed on a live system)
Bumps the sdk submodule to the merged opencharly/sdk#79 squash (2e2ad01, tag v0.2026201.1313) — the downloads-cache ownership fix, producer leg of this cutover — and the charly/go.mod require to the same version. Assembly re-gated on the merged tree: full go test ./... ok, go vet clean, golangci-lint 0 issues, task build:binary rebuilt (2026.201.1241, taskRunsAsRoot present), box validate exit 0. Assisted-by: Kimi Code (Moonshot K3; analysed on a live system)
Consumer leg of opencharly/sdk#79 (merged, tag v0.2026201.1313): the downloads cache mount now follows the task's stage user — non-root stages get a uid/gid-owned cache (id=charly-tmp-downloads-uid<uid>, uid=/gid=), root stages keep the shared form — fixing the curl-23 class where one root-stage download permanently broke every non-root stage's download. - charly/tasks_test.go: EmitDownload mount-form assertions updated to the corrected contract (uid1000-owned for the non-root testResolvedBox); new TestEmitDownload_DownloadsCacheRootShared pins the root/shared case. - sdk gitlink + charly/go.mod require bumped to the merged sdk commit 2e2ad01 (v0.2026201.1313) per B2 producer→consumer order. - CHANGELOG finalized at the merge-time CalVer 2026.201.1353. Validated by a fresh pr-validator: full core Go gate re-run green on both the candidate and the final merged tree (go test ./..., go vet, golangci-lint 0 issues, task build:binary + nm content marker, task cue:gen no-drift, charly box validate); producer behavior live-proven against the exact failing environment (host root-polluted shared cache). Assisted-by: Kimi Code (Moonshot K3; analysed on a live system)
Summary of changes
EmitDownloadalways emitted a SHARED root-owned cache mount(
--mount=type=cache,id=charly-tmp-downloads,dst=/tmp/downloads) for thecontent-addressed downloads cache. The first root-stage download made the
shared backing root-owned; after that, EVERY non-root stage's download
failed with
curl: (23) client returned ERROR on write— a uid-1000 stagecannot write into a root-owned cache dir. Reproduced serially on any box
with a non-root download step (e.g. the coder images' installer downloads);
the host's shared cache is still polluted with root-owned files today, so
every non-root download build was broken.
Concrete edits (the entire diff is accounted for here):
deploykit/tasks_emit.go: the downloads mount now follows the task'sstage user via the new
taskRunsAsRoot— root RunAs, or a root imagebuild user when RunAs is empty (a task RUN inherits the stage's USER).
Non-root stages get an uid/gid-owned cache
(
id=charly-tmp-downloads-uid<uid>,uid=/gid=— the same per-uidownership the pixi/npm caches already use); root stages keep the shared
form.
TaskCacheMounts(candy-declaredcache:paths) uses the samedecision — it previously mapped an empty RunAs to root via
ResolveUserSpec's USER-directive mapping and shared the same latent bug.deploykit/tasks_emit_test.go:TestTaskRunsAsRoot(the stage-usermatrix) +
TestEmitDownload_DownloadsCacheOwnership(non-root → ownedmount, root → shared mount, no uid-scoped id for root).
CHANGELOG/2026.201.1237.md: the placeholder entry (merge-time CalVer isfinalized by the pr-validator).
Change class
charly-or-sdk Go — build-engine emission fix in sdk deploykit. Consumer:
the superproject charly PR (test updates + sdk gitlink bump), landing after
this per B2.
How R10-tested — exact gate, commands, and pasted output
GOWORK=offtidy/verify/build/vet/test) + live build proof with the consumer binary.
N/A — the proof is the live image build against a root-polluted host cache, not a disposable bed.go tool nm bin/charly | grep taskRunsAsRootpresent (content marker).curl-23-failing image (
openclaw-full) builds past the download stepwith a root-owned shared cache present on the host (the new
charly-tmp-downloads-uid1000backing is fresh and writable).state; the fix gives each uid its own backing (correct isolation instead
of a shared root-owned dir), no lock introduced.
Attribution tier
analysed on a live system — the changed emission path executed live in a
real build against the polluted cache, but no disposable-bed roster ran.
Harness rulebook compliance — state HOW each is satisfied (or
N/A — <reason>)git-workflow+go+generateloaded by path; B2producer→consumer order.
missing ownership (permission denied reproduced in isolation), not treated
as a flake.
(
TaskCacheMounts' empty-RunAs root mapping) is fixed in the SAME commit.taskRunsAsRoot) used byboth emitters; the pixi/npm owned-mount pattern reused, no new mechanism.
only for root stages.
origin/main; status checked.(proven by unit tests + the live build).
present; no new OS deps.
(
TestEmitDownload_DownloadsCacheOwnership— the mount form assertion);live repro of the failure mode now passes.
(root-owned cache → uid-1000 permission denied) before the fix, and the
fix is proven against that same polluted state. ADE/SDD N/A.
main.
canonical home); no core surface touched.
gofmtclean,go vetclean,go test ./...green,golangci-lint run ./...0 issues.CHANGELOG/2026.201.1237.mdstaged (placeholder — thepr-validator finalizes it at merge).
Assisted-by: Kimi Code (Moonshot K3; analysed on a live system)