Repository navigation
feat(clean): implement D-STORE-7 (--store) and route cache sweeps by store identity - #29
Conversation
…store identity charly clean --store implements DESIGN.md:2488 (D-STORE-7) for the charly image store: it keeps the entries the host's charly state still references (the container engine's containers and the quadlet units), evicts the rest, frees the blobs no surviving entry reaches, and reports the retained size against a size budget AUTHORED in schema/clean.cue — under DESIGN.md:2482's ONE root, on DESIGN.md:2484's one-layout store, with DESIGN.md:2489's injected roots in every test. It refuses — evicting nothing — when a state surface cannot be read. charly clean --cache now chooses each store's reader from the store's OWN index instead of from the root it sits under, so the storekit-written registry store is never handed to the image-blind spec/cache GCStats when CHARLY_CACHE_DIR makes the two roots coincide (#27). Refs: #21, #27 Filed: #28, opencharly/plugin-vm#98 Agent: clean-retention Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
The routing fix was asserted; its two recorded EFFECTS were not, and a D-STORE-3 claim that only a
comment makes reads green because nothing looks. This adds the assertions a dependent leg can cite:
* the store directory's immediate entries after a REAL `--cache` are exactly
{oci-layout, index.json, blobs} — no lock, no sidecar (D-STORE-3, DESIGN.md:2484) — and it was the
storekit reader that swept it (asserted on the router and on the report, not inferred from a
count);
* a store whose identity cannot be decided is REFUSED, named in the report with its reason, and
left byte-for-byte intact — asserted with real bytes in it;
* the reference still resolves to content that EXISTS after the sweep (the defect's tell was
Lookup(ref) = (digest, true) over deleted bytes), as its own test so both halves of the pair
fail with their own message on the red arm.
The `--cache` report now names the reader that swept each store (`cache registry (storekit): ...`):
after #27 the wrong reader and the right one produced identical lines, so the
one fact that matters was invisible in the product.
Agent: clean-retention
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
Review — BLOCKHead SHA: Change class: code/config (Go plugin) + docs. Blocks
Non-blocking notes
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
The reviewer's blocking finding: `planStoreEviction` resolved the keep set only through
`inv.refs` (tagged references) and, for a tagged entry annotation, did `if hasTag { continue }`
without ever consulting `inv.repos`. A state surface naming a bare repository -- a quadlet's
`Image=vision-gate`, or a digest-only reference `normImageRef` folds to a bare repository -- did
not keep that repository's TAGGED store entries, so a false evict destroyed a running deployment's
image. The inventory's own `repos` doc already promised the conservative behaviour; it is now
implemented, ahead of the exact-match case, and a bare reference keeps EVERY tag of its repository.
The old covering test used an UNTAGGED annotation on both sides, which is why it passed: with a
bare state reference the bare rule keeps every tag and the superseded path is never reached. It is
now a tagged-vs-tagged fixture (the Lookup path), and a new tagged-entry/bare-reference test covers
the hole that was there.
Also from the same round:
* `storeBlobBytes` now returns an error instead of a comfortable zero, so an unmeasurable store
REFUSES before anything is evicted rather than letting the budget verdict print "within budget"
for a size nobody measured -- the body's "aborts on a store that cannot be enumerated" claim
would otherwise have been false.
* `classifyStore` no longer returns an error that every path returned `nil` for; the dead guard in
`discoverStores` is gone.
Agent: clean-retention
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
Round 1 — every finding fixed in
|
Review — BLOCKHead SHA: Change class: code/config (Go plugin) + docs. Blocks
Comment disposition
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — BLOCKHead SHA: Change class: code/config (Go plugin) + docs. Blocks
Comment dispositions
Notes (non-blocking)
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
`printRetentionResult` printed "cache: no named cache stores found" whenever no store was SWEPT, which is exactly the all-refused case: one named store was found, its reader could not be decided, and the very next line names it as REFUSED. That is a self-contradicting report in a reachable state, and the refusal test built the fixture that produces it while asserting only the REFUSED line, so it could not fail. The empty line is now gated on there being no swept AND no refused store, and the refusal test asserts the false line is ABSENT (red arm: mut8). Agent: clean-retention Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)
Review — BLOCKHead SHA: Change class: code/config (Go plugin) + docs. Blocks
Comment dispositions
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Review — PASSHead SHA: Security screen: PASS — no secrets/egress, no weakened guardrail, no supply-chain anomaly beyond the declared Checklist: All applicable rules PASS or NA. Body is re-keyed to the current head, the four commits are named, the gate fence and eight mutation red-arms are pasted, the tier ( Comment dispositions:
Non-blocking note (rulebook gap): R10's disposable bed lives in Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
charly cleannow implementsD-STORE-7(DESIGN.md:2488) — "keeps what state references andevicts the rest within a size budget; locks die with their holder" — for the charly image store,
and the
--cachesweep no longer destroys that store's content (opencharly/plugin-clean#27).The two are one story seen from both ends:
charly cleanreclaims what is unreferenced and neverdestroys what is live. A sweep that deletes a live image's bytes and a budget that evicts a
referenced entry are the same defect class.
The row was implemented nowhere:
keep_images/keep_check_runscount TAG ROWS in theengine's storage, and no size budget existed in any schema or code. The image store — the
registrynamed store under the cache root, one immutable entry per build that a rebuild APPENDSto rather than replaces — therefore grew by one artifact per rebuild forever.
#21's re-scoperecords the operator's measurement on this host (619 GiB, 1609 entries, 66 image families, nothing
ever removing one); the pre-rename store beside it, which I read while designing this, carried the
same 66 families across 172 entries.
1.
--store— the entry policypodman ps -a)charly status --jsonpublishes asimage_refdeploykit.QuadletDir(),charly-*.container,Image=)status --allrow carries noimage_ref)Every state reference is resolved to an entry through
ImageStore.Lookup— the store's own "thenewest entry whose annotation names this reference" — because state names a REFERENCE while the
store keys on the artifact's DIGEST. That resolution is also what makes a superseded rebuild of a
referenced tag reclaimable (five entries under
vision-gate: the name resolves to the newest, theolder four are evicted with the reason
superseded: …). An entry whose own content address acontainer names is kept outright. An entry with no
io.containerd.image.nameannotation is kept asunclassifiable— the only verdict that cannot be wrong.A state reference that names a bare REPOSITORY — a quadlet's
Image=vision-gate, or a digest-onlyreference
normImageReffolds to one — keeps every tag of that repository, and that match ischecked BEFORE the exact-tag one: the state named the repository, not one build of it, and a build a
bare reference covers may not be evicted on a guess. The price is that a bare reference also protects
superseded rebuilds; that is the conservative direction, and it is the one that cannot delete a
deployment.
The refusal is the contract, not a fallback. An unreadable surface is not an empty one: "nothing
is referenced" is how a sweep deletes the image a running deployment was built from. A failed
podman ps, a quadlet that cannot be read, a charly quadlet with noImage=line, an index thatdisagrees with its own entries, or a store that cannot be enumerated aborts the whole sweep with
an error naming the surface and the path, and evicts nothing.
--dry-runrefuses on exactly the sameinputs. A live build makes the sweep decline (
SKIPPED, in place of its count), because anartifact's blobs are published before its entry.
The budget is authored, and it never authorises evicting live state.
schema/clean.cue#CleanPlugin.store_budget.bytes(32 GiB) — CUE first, the Go derived from it, no constant. Thesweep reports the RETAINED bytes against it and says
within budgetorOVER budget by <bytes>;being over budget is reported, never "fixed", because the entries left are the ones state
references.
--storedeclaresbare: false, so it never fires on a plaincharly clean.What a dry run can and cannot say. The DECISION is identical in both modes (same entries, same
reasons — pinned by mutation). The BYTE figure is not: a dry run measures the store as it is
(
N held of <budget>) plus the blobs already unreferenced, while the retained size after evictionneeds the eviction — the store's public surface cannot size a hypothetical entry set without
deleting it, and a number that looked like the post-sweep size while being the pre-sweep one is the
kind of figure this report exists to avoid. The real run measures both exactly.
2.
--cache— one reader per store, chosen by IDENTITY (#27)gcCacheStoresused to sweep in two halves and to skip the storekit half whenever the two storeroots resolved to the same directory. With
D-STORE-1's one resolver (DESIGN.md:2482) that isalways:
cache.StoreRoot()andstorekit.CacheDir()both returnstoreroot.CacheDir(). So everyhost handed the storekit-written
registrystore tospec/cache's image-blindGCStats, whichdeleted a live image's manifest, config and layers and left the entry answering
Lookup(ref)forbytes that were gone. The mirror mistake was equally reachable:
storekit.NamedStores()lists thespec/cachelayouts too, and storekit's reader would have decoded their manifests as empty entriesand freed their payloads.
The reader is now chosen from the store's own index (
classifyStore): every descriptor anapplication/vnd.opencharly.store.entry.v1+jsonentry manifest → storekit; every descriptor an OCIimage manifest →
spec/cache; anything else (a mixed index, an unknown media type, an unreadableindex) → refused and reported by name, never swept. The two enumerations are deduped into ONE
inventory by resolved directory, so no store is skipped and none is swept twice, and
sameStoreRootis deleted. Because the image store is never opened by
spec/cacheany more, no.lockis writteninside its tree either (
DESIGN.md:2484). The one per-store reclaim (sweepStoreBlobs) is nowshared by
--cacheand--storerather than duplicated.The
--cachereport now NAMES the reader that swept each store (cache registry (storekit): 3 live entry(ies); removed 0 unreferenced blob(s) (0 B)). That is a report-format change on purpose: after#27, "swept by the wrong reader" and "swept by the right one" produced identical lines, so thefact that matters most was invisible in the product. A consumer that parses
cache <name>:must betold.
The same report no longer says
cache: no named cache stores foundwhen a store WAS found andrefused — those two lines read as "there are none, and here is the one there is".
--store's ownreport is unaffected.
Files
candy/plugin-clean/store_eviction.gocandy/plugin-clean/store_identity.goclassifyStore,discoverStores,sweepStoreBlobscandy/plugin-clean/store_sweep_test.gocandy/plugin-clean/schema/clean.cuestorecategory row + the authoredstore_budgetcandy/plugin-clean/categories.gostorein the plan +declaredStoreBudget, one shared schema compilecandy/plugin-clean/command.go--storereport, the budget verdict, the cache refusal linescandy/plugin-clean/retention.gogcCacheStoresrouted by identity, the store category,sameStoreRootdeletedcandy/plugin-clean/charly.ymlstore-category ADE stepcandy/plugin-clean/command_test.go--storecases in the derived-grammar tablecandy/plugin-clean/gc_cache_test.gogcCacheStores's new returncandy/plugin-clean/gc_cache_storekit_test.gocandy/plugin-clean/go.mod,go.sumsdk v0.2026322.1227(the merged #556 tag), noreplace, plus thego/indirect deltas accounted for belowREADME.md,.agents/skills/clean/SKILL.mdWhy
go.modis not a two-line diffTwo deltas, both mechanical and both named here because an unexplained 30-line
go.modchange in aclean-events PR is a fair question:
go 1.26.4→go 1.26.8. Not a choice:github.com/opencharly/[email protected]'s owngo.moddeclaresgo 1.26.8, and Go refuses a dependency whose language version is newer thanthe main module's.
containerd/v2,cuelabs.dev/go/oci/ociregistry,logrus,x/oauth2,x/sync,go-internal,errdefs,log). It comes from ONE import this changeadds:
deploykit— fordeploykit.QuadletDir(), the only exported resolver for the quadletdirectory, which is one of the two state surfaces.
deploykit/vm_box_emit.goimportssdk/buildkitdrive, so the whole package's graph comes with it. In the COMPILED-IN placement(characters:
command:clean) the marginal cost is zero — charly already linksdeploykit— andit lands only on
cmd/serve, the out-of-process plugin binary. Resolving the path by hand wouldbe a second copy of a rule whose
os.UserHomeDir()(notos.UserConfigDir()) detail ahand-rolled version gets wrong, so the narrow fix is filed against the sdk instead:
deploykit.QuadletDir pulls containerd v2 + ociregistry into any consumer (move the path helpers to kit) sdk#559 (move the pure path helpers to a light package).
How tested
The gates, on this head
Four commits, squashed at merge:
a46c3a6(the feature and the routing fix),5cc74b0(the#27/D-STORE-3assertions),dfe5acc(round 1: the bare-repository keep, the unmeasurable-storerefusal, the dead
classifyStoreerror, thego.modaccounting) andb644e09(round 2: the cachereport no longer claims "no stores found" while refusing one). Everything below was run on
b644e09.The coverage fails without the change — eight run-time mutations of THIS head's code
Each mutation edits the tree in place, runs the test, and restores from a copy — never from
git checkoutin a dirty tree, so a restore cannot take unrelated work with it. The finalgit statusis the proof every one was restored.
mut1restores the PRE-FIX ROUTER (every store to the image-blindspec/cachereader) andreproduces
#27's two effects in one run: the store tree gains.lock, and the entry stopsanswering for content that exists.
mut2removes the reference rule (everything evicted),mut3keeps everything,
mut4drops the budget comparison,mut5stops refusing when the state surface isunreadable,
mut6removes the bare-repository keep (round 1's blocking finding — a tagged entrywhose repository the state names bare is then evicted),
mut7turns an unmeasurable store back intoa zero-byte one, and
mut8restores the false "no named cache stores found" line beside a refusal.The three assertions
#27andD-STORE-3now carry by nameTestCleanCacheSweepsTheImageStoreWithItsOwnReaderasserts the router (
discoverStores→storeReaderStorekit), the report's reader, the zeroremoved-blob count, every blob the entry reaches still present, and then the directory's
immediate entries are exactly
{"blobs", "index.json", "oci-layout"}—D-STORE-3(
DESIGN.md:2484) made falsifiable. Its red arm prints the tree, so the.lockhalf is shown,not argued:
its tree is now [.lock blobs index.json oci-layout].TestCleanCacheRefusesAStoreItCannotClassifywrites REAL bytes into a storewhose index mixes descriptor media types, asserts the refusal names it and the media types,
that those bytes are still there afterwards, and that the report carries
cache mixed: REFUSED at <dir> — …. A refusal that only existed as a Go value would be arefusal an operator never sees.
#27's data.TestCleanCacheLookupResolvesToExistingContentasserts the reference still resolves AND that theresolved digest's payload still reads back — the defect's tell was
Lookup(ref) = (digest, true)over deleted bytes. Two tests rather than one because the blob count can be right while the
reference is dead, and the reference can be live while the graph is missing bytes.
A fourth assertion joined them in round 1, and it is the one the reviewer found missing:
a bare-repository state reference keeps the repository's TAGGED entries
(
TestStoreSweepKeepsEveryTagOfABareRepositoryReference, red armmut6). The previous coveringtest used an untagged annotation on both sides, so it could not see the hole: with a bare reference
the bare rule keeps every tag and the superseded path is never reached. It is now a tagged-vs-tagged
fixture (the
Lookuppath) and the tagged-vs-bare pair is the new test's job.The red arm for all four is the
mut1/mut6block above; the green arm is the same tests on thishead, in the gate fence.
The live arms — a real store, a real binary, both directions
The store is synthesised through
storekitin a temporaryCHARLY_CACHE_DIR(D-STORE-8's injectedroot), one image entry per build: 3 entries = 13 blobs, because two entries share a config blob. The
quadlet surface is an injected
HOME; the container-engine surface is this host's realpodman ps -a. The binary is built from this head (go build ./cmd/serve).The refusal arm — the same store, with a container engine that cannot be listed:
#27, live: a REAL--cacheover a store holding image entries, withCHARLY_CACHE_DIRset (thecoincident-root case the issue measures). The report names its reader, every blob survives, and the
tree is the layout and nothing else:
The same call with the pre-fix router is the
mut1red arm: 4 of the 5 blobs gone,.lockinsidethe tree, and the entry still answering
Lookupfor the missing payload.Rulebook compliance
R0 — every skill the dispatcher selects for this area was loaded before the first tool
call:
/charly-core:clean,/charly-internals:plugin,/charly-internals:go,/charly-internals:git-workflow,/charly-internals:strict-policy,/charly-internals:root-cause-analyzer,/charly-internals:cutover-policy,/charly-check:check,/charly-internals:disposable, plusplugin-clean/AGENTS.md;/charly-internals:local-infraand/charly-core:charly-statuswhen the state-surface investigation reached the install ledger andcharly status --json.R1 — every anomaly got a fresh RCA before remediation, and each was fixed or filed.
(a) The storekit test's comment claimed storekit "never writes" the
oci-layoutmarker; it does,from its one index writer (
indexEntry→EnsureLayout), so the comment was corrected and thefixture now writes the marker deliberately rather than out of necessity. (b)
sameStoreRoot()was found to be always true under the current
specresolver, which widened clean --cache deletes the image store's manifests, configs and layers when CHARLY_CACHE_DIR makes the two store roots coincide #27 from theCHARLY_CACHE_DIRclass to every host — that is in the Summary and themut1red arm. (c) Reading the sdk'sGCStatswhile routing it exposed a second, mirror-image hazard (storekit readingspec/cachelayouts), closed by the same classifier and pinned by
TestClassifierRoutesEachStoreByItsOwnIndex.(d) The dry run's byte figure cannot be the real run's; that is stated in the report text, the
skill and here rather than papered over with a number. (e)
DeleteEntryreturningfalse(aconcurrent writer got there first) is reported as
AlreadyGone, not silently folded into thecount. Non-blocking findings were filed:
opencharly/plugin-clean#28,opencharly/plugin-vm#98. Zero warnings in every gate above.(f) Round 1 (the BLOCK at
5cc74b0). The blocking finding — a bare-repository state referencedid not keep that repository's TAGGED entries, so the command could false-evict a running
deployment's image — is fixed in
dfe5acc: the bare match is checked BEFORE the exact-tag match andkeeps every tag of the repository, proven by
TestStoreSweepKeepsEveryTagOfABareRepositoryReference(red arm
mut6). The missed control: the property was asserted for the bare case and for thetagged case SEPARATELY and never as the mixed pair that crosses them, while the
reposdoc commentdescribed exactly that pair and the one test covering the rule used an untagged annotation on both
sides — a fixture that cannot fail. The control is now the mixed-pair test, plus the rule that a
conservative behaviour written down in a doc comment gets an assertion in the SAME commit. The same
round fixed the two notes:
storeBlobByteserrors instead of returning a comfortable zero (anunmeasurable store refuses BEFORE evicting,
mut7), andclassifyStore's always-nil error is gone.(g) Round 2 (the BLOCK at
dfe5acc). The cache report printed "cache: no named cache storesfound" whenever the cache sweep produced no row, so an all-refused host printed that line beside the
refusal that names the store it had just found.
b644e09gates the line on there being neither a swept nor arefused store (the
mut8arm above is its red half), and the refusal test now asserts the falseline's ABSENCE as well as the expected one. The missed control: that test built the very fixture
which produces the contradiction and asserted only the line it EXPECTED — "the output contains X"
cannot see a false Y beside it, and a self-contradicting report needs the absence assertion.
R2 — one implementation per behaviour:
sweepStoreBlobsis the ONE per-store reclaim, calledby
--cacheand by--store(the two copies clean --cache deletes the image store's manifests, configs and layers when CHARLY_CACHE_DIR makes the two store roots coincide #27's halves used to be are gone);listContainerImageRefsis the ONE container→image collector (the dangling sweep's own, reusedfor the keep set);
pluginSchemais ONE compile of the served schema for the category set andthe budget;
classifyStoreis the ONE reader decision. No sibling-host/-podanything.R3 — no sleeps, retries, suppressions or magic numbers. The budget is an authored CUE value,
not a constant; the live-build guard is the package's existing
liveBuildFloorseam; theconcurrency handling is the store's own file lock plus a re-read inside
RemoveBlob, never aretry loop; no
podman/systemctlis invoked outside the sanitizedcharlysurfaces thispackage already owned.
R4 — product before prose: the sweep's report, its refusal and its budget verdict are the
product's own, and the docs (
README.md, the authoredcleanskill, the candy description) wereswept to match what the product now does.
R5 — the deleted surface is deleted:
sameStoreRootis gone (grep below), and every claimthat described the two-half routing ("HALF TWO skips when the roots coincide", "spec/cache's
reader sweeps every store") was swept from
retention.go's header,gc_cache_storekit_test.go,the candy description,
README.mdand the skill.$ git grep -n sameStoreRoot
CHANGELOG/2026.288.2246.md:22:So the halves must PARTITION the stores rather than overlap.
sameStoreRoot()compares the resolved paths — not the environment variable — and skips the second half when they agree; comparing resolved paths keeps it true if either resolver changes, and a resolver error reports "not the same root" so a broken root is never hidden behind a skip.