Documentation
¶
Overview ¶
Package storeroot resolves charly's FIVE roots — configuration, cache, state, runtime and data — and owns the single environment override that relocates the cache.
Why the roots are a CONTRACT, not a mechanism ¶
A root is not an implementation detail: the host and every plugin it serves must agree on WHERE the shared trees are, or a plugin writes its cache into a tree the host never sweeps and the host looks for a store the plugin never wrote. That agreement is a contract between two separately-built processes, so it lives on the contract side (this module), and it is the reason a plugin may import it just as freely as the host does.
The placement is forced by the host's own boundary law, not chosen for taste: core imports only permitted contract surfaces (spec/* + proto) and may never import an sdk mechanism kit, while `sdk/storekit` — where these roots used to be computed — is a mechanism kit. Leaving the ONE resolver there gave the host exactly two options, hand-build the paths (which is what it did: `charlyDaemonPids` composed `$XDG_CACHE_HOME/charly` and `$XDG_RUNTIME_DIR/charly` itself, and so could not see `CHARLY_CACHE_DIR` at all) or import across the boundary it is forbidden to cross. Resolving here satisfies both rules as written: the host reaches the ONE resolver through a permitted surface, and the mechanism kits re-export it rather than keeping a second copy (see `sdk/storekit`).
The one override ¶
`CHARLY_CACHE_DIR` relocates the CACHE root, and only that root: it is the single environment override in the whole system, and every named store lives under it. The value is used exactly as the operator wrote it — the resolver never absolutises, cleans or rewrites it, so a relative value stays relative. No other root has an override.
This package resolves paths; it does not own the store ¶
The content-addressed store, its entries, views and garbage collection are the sdk mechanism layer's (`sdk/storekit`, which re-exports the symbols below). The legacy config-root store that `spec/cache` still carries resolves a DIFFERENT root (`opencharly/spec#233`) and is not served by this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶
CacheDir resolves the cache root: `$XDG_CACHE_HOME/charly`, or `CHARLY_CACHE_DIR` when set. Every named store lives under it.
func DataDir ¶ added in v0.2026322.1111
DataDir resolves the data root: `$XDG_DATA_HOME/charly`, or `$HOME/.local/share/charly` when that variable is unset.
It sits beside CacheDir() rather than being reached through Dir(RootData) alone because the two roots are the pair a caller actually compares: an artefact belongs in the data root when losing it costs a rebuild, and in the cache root when it can be re-derived. A caller that has to spell one of them by hand is the duplication this package exists to end.
Types ¶
type Root ¶
type Root string
Root names one of the five roots.
const ( // RootConfig — `$XDG_CONFIG_HOME/charly`: what the USER sets. RootConfig Root = "config" // RootCache — `$XDG_CACHE_HOME/charly`: everything content-addressed and // re-derivable. The single `CHARLY_CACHE_DIR` override relocates this one and // therefore every store. RootCache Root = "cache" // RootState — `$XDG_STATE_HOME/charly`: durable state that is NOT cache — install // ledgers, process locks, anything a restart must not lose and a `cache clear` // must not touch. RootState Root = "state" // RootRuntime — `$XDG_RUNTIME_DIR/charly`: per-boot runtime state. RootRuntime Root = "runtime" // RootData — `$XDG_DATA_HOME/charly`: durable, operator-visible DATA that a // re-derivation cannot replace — the artefacts a build produces. The one tenant // today is the engine-neutral image store (`images/`, an OCI layout). // // It is deliberately NOT under the cache root: a cache is disposable by contract // (a `cache clear` must be able to delete it), while a built image is a product // whose loss costs a rebuild. For the same reason `CHARLY_CACHE_DIR` does not // relocate it — an override meant to make the cache disposable must not carry the // durable artefacts along with it. RootData Root = "data" )