Repository navigation
refactor(loaderkit): materialized tree on the OCI ArtifactStore + DeriveRepoView - #274
Conversation
…iveRepoView Folds the materialized-tree cache onto the new spec/cache ArtifactStore (the OCI-Image-Layout content-addressed cache merged in opencharly/spec#148) and replaces the in-place repo-cache schema migration with DeriveRepoView. - load_cache.go: cache.Store/Open/OpenLimited -> cache.Layout/OpenLayout/ OpenLayoutLimited; Entry{Payload, Components}; the components-digest key is unchanged. Docker-cache rule preserved: components-only validity, no TTL. - refs_collect.go: EnsureRepoDownloaded DERIVES a schema-keyed view (<cachePath>.view.<headSchema>) instead of mutating the fetched export in place. A behind-HEAD tree is copied to a private staging dir, migrated there, marker-stamped, and published by atomic rename; an at-HEAD tree is returned as-is. The pristine export is NEVER written — not even on a lock failure (which now fails the derive). This is the root fix for the check-substrate deploy-add failure, where the loader rewrote @main in place to the consumer's schema CalVer (261) and poisoned every 249 consumer. - go.mod: pin the merged spec tag v0.2026266.1044 (no replace in the shipped tree). Tests: DeriveRepoView never mutates / reuses / at-head-identity / never migrates-pristine-on-lock-failure. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (all 5 files accounted for in the body), no secrets/egress, no guardrail weakening, spec bump + two indirect deps trace to the merged spec#148. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
Folds the materialized-tree cache onto the new
spec/cacheArtifactStore (the OCI-Image-Layout, content-addressed cache merged in opencharly/spec#148) and replaces the in-place repo-cache schema migration withDeriveRepoView.Materialized tree →
ArtifactStore.loaderkit/load_cache.goopens the shared store ascache.OpenLayoutLimited(dir, N)(wascache.Store/Open/OpenLimited), reads/writes viaLayout.Get/PutwithEntry{Payload, Components}, and keys on the same components digest (cache.HashHex/KeyDigest, unchanged). The Docker-cache rule is preserved: components-only validity, no TTL; prune stays storage-only.DeriveRepoView— derive, never mutate.loaderkit/refs_collect.go'sEnsureRepoDownloadedno longer auto-migrates the fetched cache in place. Instead:<cachePath>.view.<headSchema>) materialized once by copying + migrating a private staging dir, published by atomic rename with a completeness marker — so a crash never publishes a torn view, and the pristine export is never rewritten.markRepoAutoMigrating) now keys on the VIEW path (a migration re-entersLoadUnified→EnsureRepoDownloadedfor the same view; the per-view once-per-process guard terminates the cycle).Why this is the root fix for the
check-substratedeploy-addfailure. The pre-cutover loader rewrote~/.cache/charly/repos/github.com/opencharly/charly@main/charly.ymlin place to the consumer binary's schema CalVer (261), poisoning the shared cache for every 249 consumer — the exact errorconfig schema 2026.261.1747 is newer than this charly supports (max 2026.249.2125). With a derived view, each schema version reads its own tree and the pristine export stays exactly as fetched. (The spec half — v2 provenance hard-rejecting the legacy sidecar so an already-poisoned cache self-heals — is in #148.)github.com/opencharly/specto the merged tagv0.2026266.1044(the fix(ci): tag sdk under its Go-module scheme v0.<YYYYDDD>.<HHMMZ> #148 merge tag). (The branch was developed against a temporary localreplacefor the in-flight art; the NET diff drops it —git diff origin/main -- go.mod | grep -c replace→ 0 — andgo.modnow pins the published tag, noreplacedirective in the shipped tree.)How tested
sdkis a contract/library module — nocharly.ymlproject, nomain/deployable target, therefore nodisposable: trueentity (executed proof below). The R10 change-class matrix'sContract / library modulerow (merged inlayer-charly-check#20, tag-on-merge 2026-09-23; the matrix's sole owner is thecheckskill inlayer-charly-check) covers this class. Its text, so the exemption is verifiable in this context without fetching the corpus:A change observable only at a consumer's live boundary names the consumer PR running that bed — here, the charly consumer PR (tracked in opencharly/charly#632).
The module's committed gate —
.github/workflows/ci.yml(gofmt + go vet + go test ./... + cross-archgo build), run on the PR head:New coverage that fails without the change (
loaderkit/refs_collect_test.go):TestDeriveRepoViewNeverMutatesPristine— a behind-HEAD tree derives a SEPARATE view; migrate runs exactly once and never on the pristine export; the pristinecharly.ymlis byte-identical before/after.TestDeriveRepoViewReusesBuiltView— a built view is reused (migrate runs once across two calls, same path).TestDeriveRepoViewAtHeadIsIdentity— an at-HEAD tree is returned as-is with no copy and no migrate.TestDeriveRepoViewNeverMigratesPristineOnFailure— forces the view-lock acquire to fail and asserts migrate is NEVER called with the pristine path and the pristinecharly.ymlis byte-identical after. This is the guard for the round-1 finding (the pre-fix lock-error branch fell back to migrating the pristine export in place — deleted here). Verified FAIL-without-fix:Consumer boundary (B6)
The behaviour this changes is observable at charly's live boundary — the
check-substratedisposable bed'sdeploy-add, which drivesEnsureRepoDownloaded. That bed rides the consumer PR (the charly re-pin to this sdk + spec), not this library PR, per the matrix row. The charly consumer leg is tracked in opencharly/charly#632.Rulebook compliance
/charly-internals:go,/charly-internals:plugin,/charly-internals:git-workflow.DeriveRepoView's lock-error branch fell back to migrating the pristine export in place (the exact defect this change removes), reachable under concurrency. Fixed here to fail the derive instead, with a FAIL-without-fix test; no warning survives.DeriveRepoViewis the ONE derive helper.feat/oci-cas-cacheoff freshorigin/main; no force-push.DeriveRepoViewtests); no new live-service boundary.N/A — spec/sdk build libraries; no main/deployable target, so the module suite is the class gate(the mergedContract / library modulematrix row). The consumer-boundary bed rides the charly consumer PR (B6).Commit structure (B15)
ONE commit on the branch (
a53d0fb), no(WIP)marker — a fresh branch createdfrom
origin/mainwith the final, fix-complete tree. (The prior head carried a(WIP)feature commit; the round-1 fix removed the unfinished part — thepristine-mutation fallback — and this fresh branch re-lands the whole net change
as one clean commit.)
Change classification
gofmt+go vet+go test ./...+go build ./...) on the PR head.fully tested and validated.Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)