Repository navigation
Description
The problem
driveConfig.buildImage writes a full OCI export archive to the persistent BuildKit stage dir (~/.cache/charly/buildkitd/export/<safeName>.oci.tar) and removes it only on the SUCCESS path. Every failure between the export write and the last bridge step leaves the archive behind:
runner.Run(buildctl ...)returns an error (the archive was already written by the OCI exporter);annotateExportfails;storeAddfails;importExportfails.
The success-path comment already names the reason the archive must go: "one per build on a persistent root is storage nobody reclaims". The failure paths have no such cleanup, so a repeatedly failing build accumulates image-sized archives.
Evidence
Measured while proving opencharly/.github#279: a deliberately failed live run of TestBuildImage_LivePushOutsideTargetsIsNotPublished (the build failed at the registry push) left
~/.cache/charly/buildkitd/export/127.0.0.1_1_leg4-live-push-279_2026.308.1917.oci.tar
behind. The next go test ./... run's sibling live test reported it:
--- FAIL: TestBuildImage_LiveBuildsAndBridgesIntoTheRunEngine (1.42s)
buildkit_live_test.go:90: the export archive 127.0.0.1_1_leg4-live-push-279_2026.308.1917.oci.tar survived the build
The archive was removed after the fact; the leak is reproducible from any failed build.
Root cause
candy/plugin-build/buildkit.go:204 returns immediately on a buildctl failure:
if _, err := runner.Run(ctx, buildkitdrive.BuildctlBinary, args...); err != nil {
return fmt.Errorf("building %s: %w", box.Name, err)
}and the later failure returns likewise, each before the os.Remove(dest) that closes the success path.
Intended scope
Remove the export on EVERY exit path once it has been written (a defer that removes dest, with its own failure REPORTED and never allowed to mask the build error). The test-side fixture collision that surfaced this (the failing archive's name matching an unrelated test's leg4-live scan) is fixed separately in the #279 change.
Non-blocking relative to opencharly/.github#279: the push-policy fix is correct and complete without this cleanup, and the two are separable.
Agent: containerd-crabbox-program/279 · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code ollama-cloud/deepseek-v4.1-flash (syntax check only)
Activity