Skip to content

spec/cache's store resolves the WRONG root (~/.config/charly/cache) and is a hand-written mechanism inside the contract module — D-STORE-1/D-SDK-1/D-SPEC-1 #233

Open

Description

@aitrawog

What is wrong

spec/cache's store deviates from DESIGN in two ways that the operator's one-store mandate now makes load-bearing:

  1. Its root is under the CONFIG root. spec/cache/cache.go:194-205 StoreRoot() returns CHARLY_CACHE_DIR if set, else filepath.Join(filepath.Dir(DefaultDeployConfigPath()), "cache") — i.e. ~/.config/charly/cache. DESIGN D-STORE-1 puts the cache at $XDG_CACHE_HOME/charly with the single CHARLY_CACHE_DIR override.
  2. It is a hand-written store inside the CONTRACT module. DESIGN D-SDK-1 lists "the store and its roots (§17)" as a shared sdk mechanism and D-CORE-1 has core build "the store instance (built on the sdk store)"; D-SPEC-1 says spec holds the §3.2 packages "and the code generated from them; no mechanism, no hand-written logic beyond behaviour methods on generated types".

Measured while building sdk/storekit (the new mechanism): the deviation is real, it has ~6 consumers, and — importantly — it is NOT merely cosmetic: anything resolving the cache root through spec/cache today lands in a different tree from the sdk roots, which is how a second cache root quietly appears.

RCA

  • Mechanism. The store was authored before DESIGN's module graph was enforced, when spec still carried mechanism; the root was chosen from the config path because that was the only path resolution available to the package at the time.
  • Missed control. Nothing asserts that a cache root equals $XDG_CACHE_HOME/charly, and nothing asserts that spec holds no mechanism — both claims live only in DESIGN prose.
  • Blast radius. Every cache-shaped path resolved through this function; a consumer that mixes spec/cache and the sdk roots resolves two different trees for one logical cache.
  • Root fix. Migrate the store to sdk (D-SDK-1's home), resolve through sdk/storekit's roots, and delete spec/cache's own resolution in the same phase (R5, no dual path). A charly clean sweep plus a migration note covers the legacy <config>/cache directory; it is left untouched, never deleted silently.

Interim, already landed

spec/cache.StoreRoot() resolves the SAME D-STORE-1 rule as sdk/storekit (the interim shim) so the two cannot diverge while this migration is pending. The shim is temporary and this issue is its exit.

Agent: oci-plugin-lead · session task-2 — filed from opencharly/spec#232's round-2 review (CONC(b): a ledger note is not a filing).

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (theoretical suggestion)

Activity

  1. aitrawog commented on Oct 14, 2026

    @aitrawog
    ContributorAuthor

    STATUS — measured evidence added from the consumer side, which makes one part of this issue sharper and one part smaller.

    1. A LOCK LIVES INSIDE THE STORE TREE (new, measured live by cache-migration-lead). The materialized store ~/.config/charly/cache/materialized/ carries a .lock file and a populated locks/ directory beside its oci-layout + index.json + blobs/. Per the homes rule this codebase adopted: a lock is transient runtime state with no content address — and a digest-keyed lock could even be SHARED between two processes that must not share it — so it belongs to the STATE root (host-global arbitration) or the RUNTIME root (per-boot), never inside a store. sdk/storekit now documents that rule and guards it with a test that runs a full store lifecycle and asserts no lock artifact exists anywhere under a store tree. Where this store still places one, it is part of THIS issue's debt — consumers must not work around it.

    2. The store ROOT gates more than the cache surface. spec/cache/cache.go:196-205 resolves to <dir of DefaultDeployConfigPath>/cache, i.e. the CONFIG root; the materialized store therefore lives at ~/.config/charly/cache/materialized/ while ~/.cache/charly/materialized is empty. So phases 3 and 4 of the one-store wave (the materialized/load cache and the vm-images download cache) cannot be correct until this issue's root fix lands — and sdk/kit/http_fetch.go:61-72 hardcodes ~/.cache/charly/vm-images/ with no override at all. Both should consume sdk/storekit's root resolver rather than each resolve their own.

    3. One part of this issue is SMALLER than the ledger said. The materialized cache is ALREADY an OCI layout (sdk/loaderkit/load_cache.go:85-99 opens cache.OpenLayoutLimited and falls back to cache.StoreDir("materialized")), and the payload-vs-config split is already implemented (validity in the config blob; the only absolute-path field is json:"-"). So TODO 7.3's prose claiming timestamps and temporary paths in the payload is STALE — that is a ledger correction, not a code change. What remains here is the ROOT and the lock placement, plus deleting the CHARLY_MATERIALIZED_CACHE override.

    Agent: oci-plugin-lead · session task-2 — consumer-side evidence for the store-deviation issue.

    Assisted-by: DeepSeek Harness deepseek-v4.1-flash (theoretical suggestion)

  2. aitrawog commented on Nov 11, 2026

    @aitrawog
    ContributorAuthor

    STATUS — evidence for this issue's "Interim, already landed" claim: the shim shares the OVERRIDE but not the DEFAULT, so the two roots still diverge.

    Measured today on spec 70528371bf06c226ba689eee2ee34e35af0fdc5f with a scratch probe calling both
    resolvers in one process (never committed):

    === condition: no override, XDG pinned
    spec/cache.StoreRoot() = "/home/atrawog/.cache/crr/xdg/config/charly/cache" (err <nil>)
    storeroot.CacheDir()   = "/home/atrawog/.cache/crr/xdg/cache/charly" (err <nil>)
    same root: false
    === condition: CHARLY_CACHE_DIR absolute
    spec/cache.StoreRoot() = "/home/atrawog/.cache/crr/xdg/relocated-cache" (err <nil>)
    storeroot.CacheDir()   = "/home/atrawog/.cache/crr/xdg/relocated-cache" (err <nil>)
    same root: true
    

    So the interim shim agrees with D-STORE-1 only when CHARLY_CACHE_DIR is set; with it unset
    spec/cache still lands under the CONFIG root (StoreRoot → filepath.Join(filepath.Dir(DefaultDeployConfigPath()), "cache")).
    Anyone resolving through spec/cache on a default install therefore still reads a different tree
    from the one sdk/storekit writes — the second-cache-root failure this issue exists to end.

    This is unchanged by, and not absorbed into, the resolver move now landing: the
    change feat(storeroot) moves only the FOUR-ROOT resolver into spec/storeroot (contract side, so
    the plugin host may import it), and leaves spec/cache's store and its root exactly as this issue
    describes. storeroot's package doc names this issue as the legacy store it does not serve.

    No action requested here; recording the measurement so the migration starts from a verified state
    rather than from the comment that says the shim already closed the gap.

    Agent: cache-root-resolver

    Assisted-by: DeepSeek Harness ollama-cloud/deepseek-v4.1-flash (analysed on a live system)

  3. added
    category:delivery
    type:chore
    on Nov 23, 2026
  4. aitrawog commented on Dec 1, 2026

    @aitrawog
    ContributorAuthor

    STATUS

    Measured on 2026-12-01 while cleaning this host: the legacy <config>/cache tree is live and 165M,
    and charly clean --cache does not sweep it.

    $ du -sh ~/.config/charly/cache
    165M	/home/atrawog/.config/charly/cache
    $ du -sh ~/.config/charly/cache/*
    80M	/home/atrawog/.config/charly/cache/submodules
    43M	/home/atrawog/.config/charly/cache/materialized
    35M	/home/atrawog/.config/charly/cache/project
    7.6M	/home/atrawog/.config/charly/cache/labels

    charly clean --cache --dry-run enumerates only the <cache root> stores (images, labels,
    materialized, plugin-build, probes, project, registry, submodules, retired images) — it
    prints no <config>/cache line:

    $ ./charly/bin/charly clean --cache --dry-run 2>/dev/null | grep '^cache'
    cache images (spec/cache): ...
    cache materialized (spec/cache): ...
    cache project (spec/cache): ...
    cache plugin-build (storekit): ...
    cache registry (storekit): ...
    cache retired images: would remove 374.3 KiB (/home/atrawog/.cache/charly/images)

    This confirms the root fix's "A charly clean sweep plus a migration note covers the legacy
    <config>/cache directory" item is still outstanding. I have not touched the tree; it is left for
    the migration this issue owns.

    Agent: charly · Claude Code session ff8c795b-0e41-4612-8cb0-faa15134e8ce
    Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:deliverytype:chore

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions