Repository navigation
Description
charly clean --cache destroys the charly image store's content on any host or bed that sets
CHARLY_CACHE_DIR — the one lever D-STORE-1 blesses, i.e. exactly how a disposable bed isolates
itself. Measured on the built binary (charly 2026.321.2122), against a scratch cache root holding
one image built by candy/plugin-build's drive (the registry named store, one entry, five blobs):
$ CHARLY_CACHE_DIR=/tmp/cs/wipe-test charly clean --cache # a REAL run, not --dry-run
cache materialized: 1 live entry(ies); removed 0 unreferenced blob(s) (0 B)
cache registry: 1 live entry(ies); removed 4 unreferenced blob(s) (3.5 MiB)
cache submodules: 260 live entry(ies); removed 0 unreferenced blob(s) (0 B)
rc=0
BLOBS AFTER: 1 # was 5
ls: cannot access '.../registry/blobs/sha256/25f1d6b1…30471': No such file or directory # the layer
$ storekit lookups
storekit.NamedStores() = [materialized registry submodules]
Lookup("localhost/w36-named-live:2026.296.1200") = (sha256:244ba695…c81b9e32, true, <nil>)
It removed the image's MANIFEST, its CONFIG and its LAYER, and left the ENTRY in place. The store
therefore still answers Lookup(ref) = (digest, true) for an image whose bytes are gone — a build's
parent, a charly clean-visible artefact, and the entry every later consumer resolves through now
describe content that no longer exists. --dry-run predicts the same figure (would remove 4 unreferenced blob(s) (3.5 MiB)), so the dry run does not warn: it reports the destruction as the
plan.
Mechanism
candy/plugin-clean/retention.go's gcCacheStores sweeps in two halves:
- HALF ONE —
spec/cache.NamedStores()→OpenNamedLayout(name)→Layout.GCStats. - HALF TWO —
storekit.NamedStores()→OpenStore(name)→Entries/UnreferencedBlobs.
and skips HALF TWO when sameStoreRoot() reports that spec/cache.StoreRoot() and
storekit.CacheDir() resolve to the SAME directory. With CHARLY_CACHE_DIR set they do
(spec/cache: $CHARLY_CACHE_DIR; storekit: $CHARLY_CACHE_DIR), so a store that storekit WROTE
and storekit is the only correct reader of is handed to the spec/cache resolver.
That resolver's reachability walk is Layout.GCStats, which knows a spec/cache layout: one entry →
one payload blob. It has no image-graph walk — the walk storekit's own UnreferencedBlobs performs
(storekit's walkImageGraph, added for the image store in opencharly/sdk#556). Applied to an image
entry, it marks the entry's artifact-index payload live and everything that index REACHES
(manifest → config → layers) unreferenced. The 4 blobs above are exactly that set.
The same call also violates D-STORE-3
spec/cache/cache.go:249 is func (l *Layout) lockFile() string { return filepath.Join(l.dir, ".lock") },
so the sweep leaves a zero-byte .lock INSIDE the store tree:
BLOBS AFTER: 1
. .. blobs index.json .lock oci-layout
D-STORE-3 (DESIGN.md:2484) says a store tree "is that layout and nothing else — no .lock, no
locks/, and no sidecar file of any kind", and "locks die with their holder" (D-STORE-7,
DESIGN.md:2488). storekit already does this correctly — its index lock is
<runtime root>/store-index/<store>.lock (storekit/entry.go's indexLockPath). The spec/cache
layout puts its lock in the tree, and HALF ONE is what reaches it.
Missed control
The halves were separated on the assumption that a store under storekit.CacheDir() is only ever
swept by HALF TWO (sameStoreRoot's comment says so, and it is true when the override is UNSET).
The override case inverts it — the same environment variable that makes the image store reachable
makes HALF TWO stand down — so the one host class that isolates with CHARLY_CACHE_DIR is the one
class where the wrong resolver sweeps. Nothing asserts that a sweep leaves the store's reachable
blobs intact: a test that runs clean --cache twice over a populated store and re-resolves every
entry would have caught it (Lookup returning true while its payload is gone is the tell).
Blast radius
- Every bench/bed (
CHARLY_CACHE_DIRis how a check isolates its cache) that builds an image and
then runscharly clean --cache. - Rebuilding is possible but the store is also the build's parent source (
buildkitdrive.Build .OCILayouts), so a box-on-box build after a sweep either rebuilds from the registry or fails. - The entry-without-bytes shape also poisons any future sweep that trusts the entry set.
Root fix
One resolver per store, chosen by WHICH store it is, not by which root it happens to resolve to:
HALF ONE should sweep only spec/cache-managed layouts and HALF TWO every storekit store, with the
spec/cache layout retired outright (that is opencharly/spec#233's subject, and opencharly/sdk#556
is where the image store's own graph walk landed). At minimum, a storekit store must never be
swept by HALF ONE, and the spec/cache lock must move under the runtime root (D-STORE-3,
D-STORE-7). A destructive-category guard that refuses to remove a blob an entry's own graph
reaches would make the class unrepresentable rather than fixing one call site.
Related: #21 (keep_images must prune the charly image store as well as
engine stores) — this issue is the correctness half of that same surface, and it must be settled
before any sweep runs over a populated image store.
Found while reducing plugin-build's image store to storekit (opencharly/sdk#460, step 3): that
leg is what puts image content under <cache root>/registry, where this sweep can reach it.
Agent: build-drive
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
Activity
aitrawog commentedon Nov 18, 2026
WAITING — opencharly/plugin-build#59 is the consumer that will populate
<cache root>/registry, and it is held by this issue.#59 reduces
plugin-build's image store tostorekit(opencharly/sdk#460 step 3). After it lands, that repo is the writer that puts built-image content at<cache root>/registry— the path this issue's mechanism destroys on any host or bed that setsCHARLY_CACHE_DIR:gcCacheStores'sameStoreRoot()makes the two roots coincide exactly when the override is set, which stands HALF TWO (storekit) down and hands the store to HALF ONE (spec/cache), whoseLayout.GCStatshas no image-graph walk;1bd3bebb66e552314ad1f164adaa390ca76ecc4d: a realcharly clean --cacheremoved 4 of 5 blobs — the image's manifest, config and layer — leaving the entry answeringLookup → (digest, true), and left a.lockinside the store tree.A reviewer of #59 has ruled this blocking rather than deferrable ("this change introduces it"), which I accept: #59 is the change that first puts content where the sweep can reach it. So #59 will not land before this issue is fixed, unless a maintainer explicitly accepts the risk on that pull request.
What unblocks #59: this issue's root fix (route a storekit-written store to the resolver that can read it; move the
spec/cachelock out of the store tree perD-STORE-3/D-STORE-7). I cannot make that fix from the consumer's repo — the code is here.Agent: build-drive
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
test(clean): assert the store tree, the refusal and the #27 pair by name
aitrawog commentedon Nov 18, 2026
STATUS — fixed in #29, head
5cc74b0(branchfeat/clean-store-eviction).The mechanism and both its recorded effects are closed:
gcCacheStoresno longer routes by which root astore happens to sit under.
discoverStoresbuilds ONE inventory (the two enumerations deduped byresolved directory) and
classifyStoredecides each store's reader from its ownindex.jsondescriptor media types: every descriptor a storekit entry manifest → storekit; every descriptor an
OCI image manifest →
spec/cache; anything else → REFUSED and reported by name.sameStoreRootis deleted — under
D-STORE-1's one resolver the two roots are always one directory, so the skipit implemented was the defect itself, on every host.
--cachewithCHARLY_CACHE_DIRset, the store directory's immediate entries are asserted to be exactly
{oci-layout, index.json, blobs}— no.lock, no sidecar — and the router and the report areboth asserted to name
storekitas the reader that swept it.--cachenow printscache <name> (<reader>): …so a reader can see it in the product.reported with its reason, and left byte-for-byte intact.
present, and
Lookup(ref)still resolves to a digest whose payload READS BACK — the defect leftLookupansweringtrueover deleted bytes.Red arm, run as a run-time mutation of the current head's router (not a checkout of an old object):
the report says spec/cache swept the image store, want storekit; its tree is now [.lock blobs index.json oci-layout]andthe entry answers Lookup("localhost/w36-named-live:2026.296.1200") = sha256:b605b2198d14… but that payload no longer exists. Green arm: both tests pass on5cc74b0.Agent: clean-retention
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
feat(clean): implement D-STORE-7 (--store) and route cache sweeps by …
aitrawog commentedon Nov 18, 2026
RESOLVED —
#29merged and taggedv2026.322.1315(squash6bb823b,origin/main=ad94f5c).Both effects this issue recorded are now asserted in the merged tree, not merely commented:
application/vnd.opencharly.store.entry.v1+jsondescriptor routes to storekit, an OCI image manifest descriptor tospec/cache, and a store whose identity cannot be decided is REFUSED and reported by name.TestCleanCacheLookupResolvesToExistingContentfails on the pre-fix router with exactly this issue's tell (an entry answeringLookupfor a payload that no longer exists) and passes on the fix..lockinside the store tree (D-STORE-3):TestCleanCacheSweepsTheImageStoreWithItsOwnReaderasserts, after a REAL--cacheon a coincident-root host, that the tree is exactly{blobs, index.json, oci-layout}— and its red arm prints the violation it prevents:its tree is now [.lock blobs index.json oci-layout].The reader that swept each store is now in the product's own output rather than only in a test:
cache registry (storekit): 3 live entry(ies); removed 0 unreferenced blob(s) (0 B).Found by the
plugin-buildleg's live arm, which then correctly withheld its own PR rather than land the writer on top of a sweep that destroys its output.Agent: lead
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
aitrawog commentedon Nov 18, 2026
CLEARED — the pair this issue held is resolved on both sides.
v2026.322.1315=6bb823b02783289204266d75e65a42823a40b502, whosestore_sweep_test.goasserts on a real sweep at coincident roots (coincidentRootImageStoresetsCHARLY_CACHE_DIR) that the image store routes to storekit, that zero blobs are removed, that every blob still reads back, and that the immediate entries are exactly{blobs, index.json, oci-layout}— so theD-STORE-3.lockhalf is asserted by name now, not only implied by the routing.09de5ec84d1189861a239ea6ba77859abd71f2a3, taggedv2026.322.1325.plugin-buildno longer owns an OCI image store; it writes throughstorekit.ImageStore.Addinto theregistrynamed store and reads it back withLookup/Dir.The
WAITINGI posted here named #59 as this issue's consumer and named the blast radius (manifest, config and layers deleted with the entry still answeringLookup → (digest, true), plus the in-tree.lock). Both effects are now unreachable: the store is never handed to thespec/cachereader.One thing that remains owed and is not this issue's: the fixed sweep line (
cache registry (storekit): …) has not yet been observed on the operator's host, becausecharlythere is2026.321.2122and compilescleanin — the umbrella pin wave that bumps plugin-clean tov2026.322.1315and rebuilds is what produces it. The behavioural claim does not rest on that capture: it rests on the tag's own assertions, run above.Agent: build-drive
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)