Repository navigation
refactor(loaderkit): fold the materialized-tree cache onto spec/cache.Store - #271
Conversation
….Store Delete loaderkit's private content-addressed cache mechanism — the SHA-256 key derivation, the per-file entry layout, the tmp+rename publish, the per-key flock plus double-check, and the Docker-style prune — and fold it onto the ONE shared spec/cache.Store at spec v0.2026265.2108, the same mechanism the status caches use. This is R3: one cache mechanism, no private copy. loaderkit now owns only the materialize-specific inputs: the components, being the config hash plus schema CalVer plus loader identity, and the tree wire codec. The store path is unchanged at ~/.cache/charly/materialized, overridable by CHARLY_MATERIALIZED_CACHE. The cache validity contract — component-based with no time expiry — is unchanged. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: Go library refactor ( Placement: CORRECT — the PR deletes a private duplicate cache mechanism and delegates to the shared Store (outward dedupe); no capability code into core, no new alias file, no new core import. Comments: none in the thread (empty), so nothing to re-derive. Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Address the validator BLOCK on #271: - The materialized-tree cache root MOVED from the private ~/.cache/charly/ materialized to the shared cache dir ~/.config/charly/cache/materialized (so it sits under the ONE cache home, CHARLY_CACHE_DIR overridable). The package doc now states the new root; the CHANGELOG records the one-time re-materialize for pre-existing entries. - R1: MaterializeLoadedProjectCached's failure-contract comment claimed a Store error could fail a load. Store.Fill degrades every store-internal failure to a direct compute, so the only error it returns is the materialize callback's own (the real load error). The comment now says exactly that. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
The branch was brought up to date with origin/main so the strict required check can pass. This empty commit records the authoring attribution for the updated head; no source change. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
Fold
sdk/loaderkit's materialized-tree cache onto the ONE sharedgithub.com/opencharly/spec/cache.Store(spec v0.2026265.2108) and delete theprivate copy of the cache mechanism. R3: this was the second content-addressed
cache implementation in the tree; it now shares the mechanism the status caches
use.
Deleted from
loaderkit/load_cache.go(now owned byspec/cache.Store):<sha256>.json) and its path helpers;materializedCacheEntry/sha256Hex.What loaderkit KEEPS — the materialize-specific inputs the shared Store cannot
know:
loadedProjectCacheKey— the components (config-envelope hash + schema CalVerloaderIdentity— the sdk-version component that re-keys on a loader-logicchange (the Phase-3 RCA gate);
MarshalMaterialized/UnmarshalMaterialized);MaterializeLoadedProjectCachedface, now drivingStore.Fill.Cache-root CHANGE (explicit)
The materialized-tree cache root MOVES from the private
~/.cache/charly/materialized/to the shared cache home,~/.config/charly/cache/materialized/(cache.StoreDir("materialized")), soevery cache the tree owns sits under ONE directory and
CHARLY_CACHE_DIRrelocates them together.
CHARLY_MATERIALIZED_CACHEstill overrides the rootoutright.
Consequence, stated rather than hidden: pre-existing entries in the old root are
ORPHANED, so every existing user pays a ONE-TIME re-materialize on the next load
(the cache is disposable and self-heals — the correctness contract below is
unchanged). The old directory is not read or deleted; it is simply no longer
consulted, and can be removed with
rm -rf ~/.cache/charly/materializedonceconvenient. This is a cache-location change only: no authored config, no schema,
no wire type.
Contract preserved (unchanged): validity is component-based with NO time expiry;
a same-state load re-materializes exactly once; a config change, schema bump, or
loader-identity change re-keys and re-materializes; a corrupt entry degrades to a
direct materialize; Store-internal failures never fail a load.
How tested
The existing cache contract tests all pass against the folded implementation and
FAIL without it:
TestMaterializedCache_SameStateMaterializesOnce— the second same-state loadperforms NO unify (the materializer call-count is the witness).
TestMaterializedCache_ValidWhileInputsUnchanged— a component-matched entryis served regardless of age (the Docker rule); ages the entry through
Store.PutEntry.TestMaterializedCache_PruneReclaimsStorage— the cap reclaims the oldest;asserts
Store.Len().TestMaterializedCache_CorruptEntryDegradesAndSelfHeals— seeds corrupt bytesat the Store's own filename and asserts re-materialize + self-heal.
TestMaterializedCache_KeySensitiveToEnvelope/_ConfigChangeReMaterializes/_LoaderIdentityDriftReKeys/_ConnectPassBypassesCache/_LoadUnifiedEndToEnd.Rulebook compliance
/charly-internals:plugin,/charly-internals:go,/charly-internals:cutover-policy.failure-contract comment the first validator round surfaced are fixed here.
shares the ONE mechanism.
flock) is deleted in the same change, and the tests updated to the Store seam.
feat/cache-storeoff freshorigin/main; no force-push.call-counts and entry state the private mechanism produced).
(disposable cache state; the one-time re-materialize is stated above). No
authored config, label, or wire type changes.
(gofmt/vet/test on the final tree) is the change-class gate. The end-to-end
loader path is proven by the in-repo
TestMaterializedCache_LoadUnifiedEndToEnd.Change classification
gofmt+go vet+ freshgo test ./...on the finaltree (module gate; the loader cache is exercised by the in-repo end-to-end
test).
fully tested and validated.Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)