Repository navigation
feat(storeroot): resolve the four charly roots in the contract module, where the host may import them - #303
Conversation
The four roots (config/cache/state/runtime) and the single `CHARLY_CACHE_DIR` override had exactly one implementation, in `sdk/storekit` — a mechanism kit the plugin HOST may not import. Core therefore composed its own `.cache` path and could not see the override. A root is a contract before it is a mechanism: the host and every plugin it serves must agree on where the shared trees are, so the resolver belongs on the surface both sides may import. This adds `spec/storeroot` carrying the four-root computation and the override, moved from `sdk/storekit/roots.go` (which re-exports it in the sibling change; no second copy remains here or there). Resolution is unchanged: `Dir`/`CacheDir` were diffed against the sdk implementation under four conditions (default, absolute override, relative override, no XDG at all) and the output is byte-identical. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
…queue Both runs the first head created sat `queued` with zero jobs for 40+ minutes while the org's runners were online and idle, so no verdict could be produced. An empty round commit mints a new head (and a fresh `validate / validate` run on it) without moving the tree; the body is re-keyed to the new SHA. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no secrets/egress/guardrail weakening; PR content is technical data with no embedded instructions (T1–T4 clean). Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…re-exported by the sdk kit (#990) * docs: state where the four roots are resolved — the contract module, re-exported by the sdk kit DESIGN.md's D-STORE-1 said the roots are "resolved by one sdk package", and two other places repeated the same home: the CI-gates sentence ("store roots only via sdk") and TODO.md's store phase. That was true until opencharly/spec#303 / opencharly/sdk#499: the resolver now lives in spec/storeroot, because the plugin HOST may import only spec/* and must reach the SAME four roots every plugin reaches, and sdk/storekit re-exports it (type alias, four consts, two delegating functions) so no plugin's import changes. The record now says what the tree does, without restating D-SDK-1's list as if the roots were still an sdk-owned mechanism. Pure prose: no requirement id is added or renumbered, no table shape changes, and scripts/design-consistency.sh stays green. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (documentation reviewed) * docs: hold D-STORE-1's change to the resolver's home The D-STORE-1 row also gained a parenthetical about the runtime root falling back to the state root. That is real behaviour — spec/storeroot documents it and charly#1121 states it as the one deliberate consequence — but it is not a claim this PR is correcting, and mixing it in made the body's "three claims move, and nothing else" false. Dropped, so the diff is exactly the resolver's home plus the two sentences that repeated it. design-consistency.sh stays green. Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (documentation reviewed) --------- Co-authored-by: aitrawog <[email protected]>
Summary
charlycore cannot reach the org's ONE cache-root resolver. The four roots and the singleCHARLY_CACHE_DIRoverride have exactly one implementation, and it lives ingithub.com/opencharly/sdk/storekit— a mechanism kit thatcharly's own boundary law forbids theplugin HOST from importing. So core composed its own
.cachepath (charlyDaemonPidsbuilt$XDG_CACHE_HOME/charlyand$XDG_RUNTIME_DIR/charlyby hand), and therefore could not seeCHARLY_CACHE_DIRat all, nor the detachedbuildkitda relocated install puts there.This PR is leg 1 of 3 of the resolution recorded in opencharly/charly#1119: move the resolver to
the surface both sides may import. A root is a contract before it is a mechanism — the host and
every plugin it serves must agree on WHERE the shared trees are, or a plugin writes into a tree the
host never sweeps — so the resolver belongs in the contract module, and the mechanism kit
re-exports it instead of keeping a second copy.
Scope, stated exactly:
spec/storerootnow ownsRoot,RootConfig/RootCache/RootState/RootRuntime,DirandCacheDir— moved fromsdk/storekit/roots.go, same identifiers, same strings, same errortext, same fallbacks.
StoreDirandNamedStoresare not rootcomputation (they join a store name onto the cache root and test the OCI
oci-layoutmarker), sothey remain in
sdk/storekitand now inherit the cache root from here.opencharly/sdk) makesstorekit/roots.goa re-export and bumps this tag; leg 3(
opencharly/charly) pointscharlyDaemonPidsat this package, which is what makes that repo'simport-purity gate pass as written.
Files in this diff:
storeroot/roots.goCHARLY_CACHE_DIRoverride (moved, not re-derived)storeroot/roots_test.gogit diff --stat origin/main...HEAD:This head is
The tree under test is the content commit
96f9eb460f5c1f368acd89ee7e00b0dcd54a4153's — thehead adds one empty round commit, because the first push's two runs sat
queuedwith zero jobsfor 40+ minutes and never produced a verdict; an empty round commit mints a new head and a fresh
run on it without moving the tree.
How tested
Every command below was run against the content commit this head carries
(
96f9eb460f5c1f368acd89ee7e00b0dcd54a4153) and pasted from its capture file. Nothing here is a claim about a tree other than the committed one.1. The move is a MOVE — four conditions, byte-identical output
A scratch probe (
probe_roots_scratch/main.go, never committed) calls the resolver and prints allfour roots plus
CacheDir. It was built twice: once againstsdkatorigin/main(storekit.Dir/
storekit.CacheDir, the OLD implementation) and once against this head (storeroot.Dir/storeroot.CacheDir). Both binaries were then run under four environment conditions.The scratch directory was untracked and removed before the commit —
git status --shortwas emptyat commit time and lists only the two committed files now:
Before —
sdk@origin/main,storekit($S/before/A_default.txt, all four conditions):After — this head,
spec/storeroot($S/after/A_default.txt, same four conditions):diff -u <before> <after>→rc=0, and no output at all:Zero verdicts moved. The four conditions, and what each one pins:
XDG_*set to a distinct scratch path,CHARLY_CACHE_DIRunsetDir(RootCache)andCacheDir()agreeCHARLY_CACHE_DIR= an absolute pathCHARLY_CACHE_DIR=rel-cache(relative)XDG_*unset,HOMEpinned/tmp)2. The module's own Go gate, on the committed tree
(
grep -E 'FAIL'printed nothing andgofmt -l .printed nothing — both empty.)The new package's six arms, verbose:
Lint, and which toolchain was used.
golangci-linton this host is v2.13.2 built withgo1.27.3-X:nodwarf5, and the hostgois the samego1.27.3-X:nodwarf5— the combination whoseembedded type-checker reads only export-data v4 while go1.27 writes v5. The lint was therefore run
under
GOTOOLCHAIN=go1.26.8, the toolchainci.ymlinstalls:3. The generators — verified, not assumed
This is Go, not CUE, and nothing under
schema/is touched, so no regeneration is owed. Verifiedby running the repo's own reproducibility gate, which regenerates in-process and byte-compares
against the committed files — it runs and passes as part of the
go test ./...above:4. It can fail — a planted break red on ASSERTIONS, restored byte-identical
The break compiles — it is a wrong VERDICT, and three tests catch it on their assertions. The sed
pattern names a literal that appears twice (the config root and the cache root both join
"charly"), so one plant exercised two roots at once; that is why three tests go red, not one.5. Attribution evidence (A3)
Rulebook compliance
R0 — skills first. Loaded before the first tool action, per the umbrella dispatcher:
/charly-internals:git-workflow(branch/PR/pin mechanics),/charly-internals:go(the Go gateand the SDD generation rules),
/charly-internals:strict-policy(R1–R5, RDD) and/charly-internals:go-quality(the lint invocation, the formatter gate, the--fixhazard).spec's ownAGENTS.mdwas read fromorigin/mainbefore the first edit — andsdk's andcharly's too, since this move is one cutover with two consumer legs.R1 — RCA every anomaly, then fix it or file it. One anomaly fired: the first run of
TestRootsFallBackToHomeWithoutXDGwas RED on my own/tmpguard. RCA — the predicatestrings.HasPrefix(rt, "/tmp")conflated two propositions, "the resolver chose the shared tempdirectory" and "the test's own pinned
HOMEhappens to live under/tmp"; undergo testonthis host the second is always true, so the arm was red for a reason unrelated to the code under
test. The PRODUCT was correct; a test predicate was not. Root fix: compare the resolved directory
against
os.TempDir()andos.TempDir()/charly(equality, not a prefix) and state thedistinction in a comment. The substantive assertion —
Dir(RootRuntime) == Dir(RootState)— wasalready there and is unchanged. Green after the fix (pasted in section 2). No other finding.
R2 — no duplication. The implementation MOVES: this PR adds the one copy, and the sibling
sdkPR deletes the other in the same cutover, leaving a re-export (a type alias, four consts,two delegating funcs) rather than a second computation. In this repo
storerootis the onlyplace the cache path is composed:
(The wider predicate
grep -rn 'UserCacheDir\|"\.cache"' storeroot/matches twice — theproduction call above plus
roots_test.go:132, which is the expectation table spelling the XDGdefault
".cache"for a pinnedHOME, i.e. a test asserting the resolved path, not composingone.)
spec/cache's config-root store is a DIFFERENT root with an open migration issue (below),not a copy of this rule.
R3 — no workarounds. No sleep, retry, magic number, suppression or environment shim. The
runtime→state fallback is carried over verbatim and documented, not a hidden default.
R4 — fix the product first. This change IS the product fix; no documentation routes around
any defect. Every path the package resolves is the path the code returns, proved by the
four-condition dump in section 1.
R5 — hard cutover, legacy deleted. Nothing in
specis renamed or retired by this leg, so noidentifier is owed a sweep here; the deleted copy is in the
sdkleg, where the sweep is pasted.The claim-sweep this leg owes is of its OWN new prose: the package doc names where the store
lives and says explicitly that it does NOT serve
spec/cache's legacy store, so the new textcannot be read as claiming that debt is paid.
R6 — preserve user work; Git safety.
git statusread before the first edit and after everystep. The session worktree is
feat/storeroot-resolveroff freshorigin/main(
70528371bf06c226ba689eee2ee34e35af0fdc5f). No reset, no checkout of foreign work, noforce-push, no hook bypass, no direct push to
main. Both scratch probes were untrackeddirectories, removed, and
git status --shortwas empty at commit time and after it.R7 — prove behaviour, not compilation. The coverage fails without the change — section 4
plants a break, pastes the assertion-level red, and restores byte-identically. The changed path
ran live: two probe binaries under four conditions, plus the module's own 30-package suite.
R8 — live or skip, never fake. N/A, reasoned: this package's only boundary is the
filesystem's XDG layout — no service, no credential, no network, so there is nothing that could
be mocked and nothing that must skip.
R9 — binary equals source. N/A, reasoned:
specships no binary. The module's equivalentfreshness proof is section 2's
go build ./...+go test ./...on the committed tree, with thetoolchain named (
GOTOOLCHAIN=go1.26.8).R10 — fresh disposable proof. This is a contract-LIBRARY change:
specdeclares no per-repocandy gate and carries no
disposable: truebed (AGENTS.md: "this repo carries no per-repocandy gate"), so the gate that owns it is CI's Go gate — run here on the committed tree, zero
warnings (
0 issues.). The assembled-bed proof belongs to the CONSUMER legs and is named, notclaimed:
charly's leg is where the changed path executes inside the host, and that PR carriesthe evidence.
Change classification
Additive contract surface. A new package; no existing symbol, type, field or file of this repo
moves, so every current importer of
github.com/opencharly/speccompiles against this head exactlyas against
70528371bf06c226ba689eee2ee34e35af0fdc5f. Nothing inschema/,proto/or thegenerated Go changes, so no authored wire key moves, no
charly migrateis owed, and there is no#SchemaVersionmachinery to bump (it was deleted byCHANGELOG/0.2026270.938.md).Breaking change + rollback: nothing breaks for
spec's consumers — the diff is two NEW filesand zero modified ones, so no import path, exported type or generated artifact moves. The
deliberate consequences land in the sibling repos and are declared there:
sdk'sstorekit/roots.gostops computing and starts re-exporting (its public API is unchanged:Root,the four consts,
Dir,CacheDir,StoreDir,NamedStores), andcharly'scharlyDaemonPidsgains behaviour it did not have — it follows
CHARLY_CACHE_DIR, and throughDir(RootRuntime)itnow includes the state root when
XDG_RUNTIME_DIRis empty instead of dropping the runtime rootentirely (the resolver's documented fallback; it can only WIDEN the set of daemons the idle guard
follows). Rollback for THIS repo is one inverse commit: revert
96f9eb4. Because legs 2 and 3depend on this tag, their rollback is the pin —
sdkandcharlyreturn to the previousgithub.com/opencharly/specversion and their code reverts with it. There is no data migration ineither direction: the roots resolve to the directories they always did.
Filed issues
spec/cache's store resolves the configroot (
<config>/charly/cache) rather than D-STORE-1's cache root, so the module this PR editsstill carries a second, wrong root. Measured today at
70528371bf06c226ba689eee2ee34e35af0fdc5fwith one probe calling both resolvers: with no override,
spec/cache.StoreRoot()=<XDG_CONFIG_HOME>/charly/cachewhilestoreroot.CacheDir()=<XDG_CACHE_HOME>/charly(
same root: false); withCHARLY_CACHE_DIRset both return the override (same root: true).That evidence is posted on the issue, correcting its "the interim shim resolves the SAME rule"
line. Non-blocking by the discriminator — this change's claim ("ONE resolver for the four roots")
is true without touching that store, this PR's gate passes without it, and its fix is a store
LOCATION migration with its own consumers and its own R10 story — so it stays filed rather than
smuggled in.
fifth root (
$XDG_DATA_HOME/charly) tostorekit. After leg 2 the roots computation lives here,so the addition lands in
spec/storerootwithstorekitre-exporting it. Named so the nextsession does not edit a file that has become a re-export.
Agent: cache-root-resolver
Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (fully tested and validated)