Repository navigation
feat(storeroot): add the data root ($XDG_DATA_HOME/charly) - #372
Conversation
The engine-neutral image store (W3.6) lives at `$XDG_DATA_HOME/charly/images`, and `storeroot` had no root covering it: config, cache, state and runtime are all something else. Both alternatives were wrong. Putting the store under the cache root would let `CHARLY_CACHE_DIR` carry a built image into a tree the operator expects to be disposable, and would let a cache clear delete it; and resolving `$XDG_DATA_HOME` inside each consuming plugin is a second roots resolver, the duplication this package exists to end. `RootData` is a fifth root with no override, deliberately: the one override relocates the cache because the cache is re-derivable, and a built image is not. `DataDir()` sits beside `CacheDir()` because the two roots are the pair a caller actually compares — an artefact belongs in data when losing it costs a rebuild, in cache when it can be re-derived — so a caller never spells either by hand. Refs opencharly/sdk#458 Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (diff is exactly the five-root addition + doc/test update the body describes), no secrets/egress, no guardrail weakening, no new deps; body content is data, no embedded directives. Checklist: All applicable rules PASS or NA (R0–R10, A1–A3, PIL/ADE/SDD, CONC, HC, ARCH, DISP, QUAL, COORD). ARCH placement: CORRECT — a kind-blind root-resolution mechanism in the shared Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…stry store's entries (#556) * feat(storekit): own the charly image store's OCI layout and archive W3.6's image store — the `oci-layout` marker, one `index.json`, `blobs/<alg>/<digest>`, the atomic index rewrite under a cross-process lock, streamed blob copies and the `io.containerd.image.name` naming contract — lived package-private in plugin-build/candy/plugin-build/imagestore.go, so the image resolver (#459) could only reach it through an interface. Two callers need that layout from now on (the resolver here, the build drive there), so it moves to its natural home: `sdk/storekit`, the ONE roots/layout mechanism, as the named `charly` store. - `storekit.ImageStore`: `Lookup`, `List`, `Add` (an exported archive into the store) and `Archive`/`WriteArchive` (one stored image as an OCI archive carrying `io.containerd.image.name`). It WRAPS `*Store` rather than embedding it: `Store`'s `Entries`/`PutEntry` vocabulary is the CACHE store's and would misparse an image index. - `storekit.ImageStoreDir()` resolves `<data root>/images` through `Dir(RootData)` — the contract module's ONE resolver — and honours `CHARLY_IMAGE_STORE_DIR`. The `WORKAROUND (#458)` note in the moved code is gone, because the data root now exists (opencharly/spec#372) and a second `$XDG_DATA_HOME` computation with it. - `storekit.RootData` re-exports the contract's fifth root beside the four existing consts, and the root tests pin it (including that `CHARLY_CACHE_DIR` does not move it). - The shared `Store`, not a second layout: `EnsureLayout` (the marker a second process needs), a STREAMING atomic write the buffered one is now a wrapper over, an `index.json` path const, and a stricter digest path — `..` in either half is refused, because an archive's member names are data. - `deploykit`: the production `CharlyImageSource` (`NewCharlyImageSource`) over that store, and the resolver now REMOVES the archive it asked for — an archive is as large as the image, so a successful resolve must not leave a copy behind. - `storekit.AnnotationImageName` is the ONE definition of the naming annotation; deploykit's package-private copy is deleted (R5 sweep: no hits). Adopts `github.com/opencharly/spec v0.2026322.1111` — the tag that lands `storeroot.RootData` / `DataDir()` — as a plain `require`; the tree carries no `replace`. Steps 1 and 2 of #460. plugin-build is untouched: its reduction is step 3, which lands only after this replacement is merged (add-before-delete). Refs: #460 Agent: sdk-store Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * fix(storekit): make the image store the registry store's entries under the cache root The ruling on #460's conflicts: the CODE conforms to DESIGN.md, not the prose. Three consequences, in the order the rows force them. D-STORE-1 / D-STORE-3 / D-STORE-10 — the store moves under the ONE cache root as the `registry` NAMED store (`storekit.StoreDir`), the store plugin-clean's retirement record already names as image content's home and the one the registry surface reads: a built image must BE an entry of that store, or D-STORE-10's "view of store entries" could never serve it. `$XDG_DATA_HOME/charly/images` and its `CHARLY_IMAGE_STORE_DIR` override are DELETED — `CHARLY_CACHE_DIR` is the one override that relocates a bed's store — and the `RootData`/`DataDir` re-exports go with them (opencharly/spec#375 reverts the root). D-STORE-3 / D-STORE-5 / D-LAW-7 — an artifact is now a `storekit.Entry`: Key is the reference the caller asked for (the input identity), Payload the artifact's own digest (the resolution), MediaType what it is. A rebuild replaces the index POINTER and mutates no entry; the previous artifact stays addressable by digest until the sweep reclaims it, which is the retention mechanism itself. The stored payload carries no name and no timestamp (D-STORE-6), and `Archive` re-applies the export annotation — the one surface that crosses the engine boundary. D-STORE-7 — the store is sweepable now, which needed two fixes it did not have: - `indexEntry` publishes the `oci-layout` marker, so every storekit store is discoverable by `NamedStores()` and therefore by `charly clean --cache`. Measured before this commit: no storekit-created store carried the marker at all, so no named store was reachable by the sweep. - `ReachableBlobs` walks an artifact entry's image graph (ONE walk, shared with `Archive`), so a live image's config and layers stay reachable. A sweep that marked the root alone would keep a manifest and delete the layer it names. Refs: #460 Agent: sdk-store Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * fix(storekit): key an image entry by its digest — a rebuild appends, never replaces The validator's block on the previous head was the parked disposition, and the ruling settles the substance: the store must resolve the mutable name to a digest BEFORE it reaches the index, and a rebuild must leave the previous artifact reachable. D-STORE-5 / D-LAW-7 — the entry's KEY is now the artifact's own digest; the reference is an ANNOTATION on the entry (`io.containerd.image.name`) beside the build time, which is D-STORE-6's one sanctioned home for a resolution time (the payload carries neither the name nor the timestamp). `Lookup(ref)` answers from the annotations, newest build time first (the store appends, so index order breaks a tie), so the mutable name never becomes an identity the store keys on. D-STORE-3 / "do not delete the old artifact on rebuild" — `Add` no longer replaces anything. A rebuild is a different digest, hence a different key: the store appends a second entry and the previous artifact stays a first-class entry, addressable by its own digest. Reclaiming a superseded artifact is D-STORE-7's sweep decision — made from what `Entries()` exposes (key, reference, build time) via `DeleteEntry` + `UnreferencedBlobs` — not something a build does. D-FORM-2's key is the same digest seen from the other side: for a reproducible build the artifact's content address IS the function of its start artifact and its IR, and this store keys on the digest the build produced because it cannot compute the input key beforehand and does not pretend to. Refs: #460 Agent: sdk-store Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * test(storekit): assert the append property before the resolution in the rebuild arm The identity mutation must be killed BY the property the ruling turned on — a rebuild appends and the old artifact stays addressable by its digest — and not by a downstream consequence of it. Deriving the two artifact digests from `Entries()` (rather than from `Lookup`) puts the append assertion first: a `PutEntry` keyed by the reference leaves ONE entry, and that is what the arm now reports. Refs: #460 Agent: sdk-store Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * test(storekit): split the rebuild arm so the sweep's decision is its own test gocyclo flagged the combined arm (36 > 30): two properties were being asserted in one function. The append-and-addressable property and D-STORE-7's sweep decision are now one test each, so a failure names which half broke. Refs: #460 Agent: sdk-store Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Summary
storeroothad four roots, and the image store lives on a fifth. W3.6 puts every builtimage in ONE engine-neutral OCI layout at
$XDG_DATA_HOME/charly/images—plugin-build'simagestore.gosays so and names opencharly/sdk#458 as the reason it resolves the path by hand.None of config, cache, state or runtime is that root, and both available alternatives are wrong:
CHARLY_CACHE_DIRrelocates it, so an override meant to make a cachedisposable would carry every built image into a tree the operator expects to be reclaimable, and
a cache clear could delete a build's output. A cache is re-derivable by contract; a built image
costs a rebuild.
$XDG_DATA_HOMEinside each consuming plugin — the second roots resolverstorerootexists to end (roots.go: "It is THE resolver: no caller builds a.cachepath byhand.").
So
RootDatais a fifth root, with no override, andDataDir()sits besideCacheDir()becausethose two are the pair a caller actually compares: data when losing it costs a rebuild, cache when
it can be re-derived.
Why now — measured on this host, 2026-11-18
The store had grown to 619 GiB across 1609 index entries, and nothing in charly could reclaim
any of it:
charly clean --imagesprunes the engine's local storage (kit.ListLocalImages→<engine> images), whilecharly clean --cachereachesspec/cache's config-root store andstorekit.NamedStores()under the cache root. BothNamedStores()andStoreDir()resolvethrough
CacheDir(), so the data-root store is structurally invisible to the sweep.That is the chain this change starts:
storekitkeep_imagesprunes the charly image storeThe diff — every file
storeroot/roots.goRootDataconst + itsDirarm; the unknown-root error now names five;DataDir(); the package/type/Dirdocs corrected from "four" to "five"storeroot/roots_test.goCacheOverrideRelocatesOnlyTheCacheRootnow also asserts the override does not move data; the no-XDG fallback (~/.local/share/charly); the unknown-root error listing five; aDataDir()≡Dir(RootData)agreement assertioncache/cache.gospec/storerootowns the four roots" claimHow tested
Four module gates, on the committed tree (
7fe8a11):The coverage fails without the change — proved by mutation, not asserted. Removing only the
case RootData:arm, while keeping the const so this stays a behaviour mutation rather than acompile break, turns three tests red:
This change touches no CUE, so
cue-gen/wire-genare no-ops by construction;TestGenReproduciblewas run anyway and is green.
Rulebook compliance
R0 — skills loaded before the first tool call:
go,plugin,git-workflow,check,strict-policy,root-cause-analyzer,cutover-policy,agents,clean.R1 — the failure and its RCA are already on record (storekit: add the data root ($XDG_DATA_HOME/charly) the W3.6 image store is specified on sdk#458; the store's
unbounded growth measured above). The divergence sweep found two stale prose claims of "four
roots" on the changed surface (
roots.go) and a sibling (cache/cache.go); both are fixed here.Historical hits in
CHANGELOG/are left alone, as R5 permits.R2 — one resolver.
DataDir()is an accessor overDir(RootData), not a second pathcomputation; no caller hand-builds
$XDG_DATA_HOME.R3 — no workaround: no hand-built XDG path, no sleep, no retry, no magic number.
R5 — claim-keyed sweep, run rather than asserted:
with
roots.go:74andcache/cache.go:196fixed in this commit, and no live hit remaining.R7 — the mutation proof above: the coverage fails without the change and passes with it.
R9/R10 — the module's gates ran on the committed tree. No disposable target is affected:
nothing consumes
RootDatayet, so no bed can fail on this change (the bed that can is the oneplugin-clean#21 will carry).
Change classification
Additive. A new constant and accessor; no existing surface changes meaning, and the four original
roots resolve to exactly the paths they did before (pinned by
TestDirResolvesTheFiveRoots/TestCacheOverrideIsUsedVerbatim).Breaking change + rollback: none — reverting
7fe8a11removes a constant no consumer importsyet, and leaves every pre-existing root resolving unchanged.
Filed issues
None filed: the gap was already tracked as opencharly/sdk#458, whose resolution comment records
that spec#303 and sdk#499 moved the roots into this module — so the fifth root's home is
spec/storeroot. This PR implements it there; the issue is referenced, not duplicated.Agent: lead
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)