Repository navigation
feat(cache): OCI Image Layout ArtifactStore — content-addressed, registry-portable - #148
Conversation
…stry-portable Replace the keyed one-JSON-file-per-key cache with ONE content-addressed artifact store whose on-disk form is a standard OCI Image Layout (oci-layout + index.json + blobs/<alg>/<digest>). Each cached artifact is a real OCI manifest: the config blob carries the validity metadata (resolved/components/validator), layers[0] the payload, and annotations the cache key + org.opencontainers.image.ref.name tag. A named cache is one OCI index, so a whole store can be pushed/pulled to a registry unchanged (the verb:oci cache-push/cache-pull transport lands next). The file backend uses stdlib + opencontainers/image-spec + go-digest ONLY; no go-containerregistry in the contract module. The legacy Store API (Open/OpenNamed/OpenLimited/Read/ReadTTL/WriteValue/ PutEntry/entryPath) is DELETED in the same cutover; consumers migrate in this change (refs submodule verdicts, container image list + labels) and in the sdk change (loaderkit materialized tree). repoCacheProvenanceVersion 2 hard-rejects the legacy bare-commit sidecar: a v1 export cannot certify its tree (the pre-cutover loader rewrote it in place — auto-migrating charly.yml to the consumer's schema CalVer), so it is treated as not-cached and re-fetched once pristine. IsRepoCached now enforces this, so immutable-tag caches self-heal too. This is the root-cause fix for the poisoned @main cache that failed check-substrate's deploy-add. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (syntax check only)
…gocritic, unconvert) - cache.go: drop the redundant Versioned selector on the embedded field. - cache_test.go: derive the determinism check from fresh values (avoid SA4000). - container/engine_ops.go: if/else chain -> tagged switch (gocritic). - container/engine_ops_test.go: drop the unnecessary string() conversions. The two container findings pre-date this branch (they block the module gate, so they are fixed here per R2 rather than deferred). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (syntax check only)
… was stored stale)
The validator caught a real regression: the new Fill persisted via put(), which
preserves the caller's Resolved, whereas the legacy Fill persisted via Put(),
which stamped Resolved=now. A fill callback returning an Entry with a zero
Resolved (a degrade/empty result) was therefore stored with Resolved=zero:
instantly TTL-stale (defeating compute-once for any TTL caller) and sorted as
the OLDEST entry for reclamation.
Fill now stamps e.Resolved = time.Now() before persisting, matching Put and the
legacy contract. The fill guard is also per-key again (locks/<tag>.fill.lock),
matching the documented per-key flock rather than the interim store-wide lock.
TestFillStampsResolved fails without the stamp:
--- FAIL: TestFillStampsResolved (0.00s)
Fill must stamp Resolved=now so the entry is TTL-fresh; got 0001-01-01...
Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
…nger stamps it The validator found a doc/impl divergence: the Entry.Key comment still claimed "Set by the Store on Put", but the new keyed-by-tag layout reconstructs the key from the manifest annotation on Get and no longer stamps it on write. Fix the comment to match the implementation. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (documentation reviewed)
Body-only update (the class gate is now evidenced by the committed ci.yml run green on the head + the merged #143/#144/#145 precedent, and the no-disposable- target proof uses a real path). No source change — this empty commit moves the head so the fresh validator run keys to a head whose body is already final. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (documentation reviewed)
Review — BLOCKHead SHA: Change class: Go library ( Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Body-only update (the class gate is now evidenced by the committed ci.yml run green on the head + the merged #143/#144/#145 precedent, and the no-disposable- target proof uses a real path). No source change — this empty commit moves the head so the fresh validator run keys to a head whose body is already final. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (documentation reviewed)
Review — PASSHead SHA: Change class: Go library ( Security screen: PASS — no secrets/egress, no weakened guardrails, no self-modifying-security change; only Comment dispositions: 1 comment (github-actions[bot], Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…ctStore) The materialized-tree cache + DeriveRepoView work landed against a local `replace` while the ArtifactStore was in flight. That cutover is now merged and tagged (opencharly/spec#148, tag v0.2026266.1044), so drop the replace and pin the merged tag — the normal producer-to-consumer order (B6). No source change in this commit: the replace removal + require bump only. Verified against the merged tag: gofmt clean, go vet clean, go test ./... green (the full module), go build ./... green. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
…iveRepoView (#274) 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) Co-authored-by: Andreas Trawoeger <[email protected]>
…an OCI registry Adds the registry TRANSPORT for the OCI-manifest-native cache: two new verb:oci ops that move a whole named ArtifactStore (opencharly/spec#148) to and from an OCI registry, losslessly. Because spec/cache's ArtifactStore is already a standard OCI Image Layout, a cache IS an OCI image — its config blob carries entry validity, its layers the payloads, its index the named store. So the transport is a thin bridge: cache-push = layout.ImageIndex() -> remote.WriteIndex; cache-pull = remote.Index -> layout.Write. No bespoke format, no bespoke registry code. Auth rides authn.DefaultKeychain (docker config / credential helpers); Insecure permits a plain-HTTP local registry. - cache_transport.go: CacheTransferRequest{Dir,Ref,Insecure} + the two legs. - plugin.go: OciOp dispatch gains cache-push / cache-pull. - go.mod: bump spec -> v0.2026266.1044 and sdk -> v0.2026266.1111 (the merged ArtifactStore + the sdk tag that consumes it). Tests: TestCacheLayoutRoundTrip (deterministic — a real ArtifactStore survives layout index -> layout write with payloads/components/validator intact) and TestCachePushPullLiveRoundTrip (LIVE_REGISTRY; SKIPS cleanly when unset, per R7a). The live test was driven green against a real registry:2 on localhost:5000 — push then pull, entries byte-identical; the pushed artifact verified as a real OCI image index carrying the cache-key annotation. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
…an OCI registry (#4) * feat(oci): cache-push / cache-pull — read and write a named cache to an OCI registry Adds the registry TRANSPORT for the OCI-manifest-native cache: two new verb:oci ops that move a whole named ArtifactStore (opencharly/spec#148) to and from an OCI registry, losslessly. Because spec/cache's ArtifactStore is already a standard OCI Image Layout, a cache IS an OCI image — its config blob carries entry validity, its layers the payloads, its index the named store. So the transport is a thin bridge: cache-push = layout.ImageIndex() -> remote.WriteIndex; cache-pull = remote.Index -> layout.Write. No bespoke format, no bespoke registry code. Auth rides authn.DefaultKeychain (docker config / credential helpers); Insecure permits a plain-HTTP local registry. - cache_transport.go: CacheTransferRequest{Dir,Ref,Insecure} + the two legs. - plugin.go: OciOp dispatch gains cache-push / cache-pull. - go.mod: bump spec -> v0.2026266.1044 and sdk -> v0.2026266.1111 (the merged ArtifactStore + the sdk tag that consumes it). Tests: TestCacheLayoutRoundTrip (deterministic — a real ArtifactStore survives layout index -> layout write with payloads/components/validator intact) and TestCachePushPullLiveRoundTrip (LIVE_REGISTRY; SKIPS cleanly when unset, per R7a). The live test was driven green against a real registry:2 on localhost:5000 — push then pull, entries byte-identical; the pushed artifact verified as a real OCI image index carrying the cache-key annotation. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * feat(oci): cache-push / cache-pull — read and write a named cache to an OCI registry Adds the registry TRANSPORT for the OCI-manifest-native cache: two new verb:oci ops that move a whole named ArtifactStore (opencharly/spec#148) to and from an OCI registry, losslessly. Because spec/cache's ArtifactStore is already a standard OCI Image Layout, a cache IS an OCI image — its config blob carries entry validity, its layers the payloads, its index the named store. So the transport is a thin bridge: cache-push = layout.ImageIndex() -> remote.WriteIndex; cache-pull = remote.Index -> layout.Write. No bespoke format, no bespoke registry code. Auth rides authn.DefaultKeychain (docker config / credential helpers); Insecure permits a plain-HTTP local registry. - cache_transport.go: CacheTransferRequest{Dir,Ref,Insecure} + the two legs. - plugin.go: OciOp dispatch gains cache-push / cache-pull. - go.mod: bump spec -> v0.2026266.1044 and sdk -> v0.2026266.1111 (the merged ArtifactStore + the sdk tag that consumes it). Tests: TestCacheLayoutRoundTrip (deterministic — a real ArtifactStore survives layout index -> layout write with payloads/components/validator intact) and TestCachePushPullLiveRoundTrip (LIVE_REGISTRY; SKIPS cleanly when unset, per R7a). The live test was driven green against a real registry:2 on localhost:5000 — push then pull, entries byte-identical; the pushed artifact verified as a real OCI image index carrying the cache-key annotation. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * fix(oci): real errors from the cache-transport legs + a deterministic gate that drives them Round-1 review fixes: - cachePushLeg/cachePullLeg now return a REAL non-nil error on failure (runCachePush/ runCachePull return (reply, error)); a failure is no longer a success-shaped reply with "error: …" stuffed into Digest. - remoteOpts takes no argument (plain-HTTP is selected by name.Insecure in parseOpts, not by the remote options); the dead param + false comment are gone. - TestCacheTransportDeterministic drives the REAL legs through an in-memory registry (httptest + go-containerregistry pkg/registry) and asserts byte-identical entries + matching push/pull digest. Verified FAIL-without-the-change (breaking runCachePush fails it). Adds TestCachePushLegErrorsOnBadRef + TestCacheInsecureOptionParsed. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * fix(oci): correct charly.yml test references + make the Insecure assertion real Round-2 review fixes: - charly.yml description + the oci-cache-transport-present ADE check named TestCacheLayoutRoundTrip, which does not exist (the deterministic test is TestCacheTransportDeterministic). Both references corrected (R1 doc-vs-reality). - TestCacheInsecureOptionParsed: replace the tautological url.Parse no-op with a real assertion (parseOpts(true) yields name.Insecure, and a plain-HTTP reference parses only with it). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * fix(oci): assert components in the transport round-trip; correct the Insecure comment Round-3 review fixes: - TestCacheTransportDeterministic now asserts got.Components == orig.Components (reflect.DeepEqual), so the lossless round-trip claim the body and the charly.yml ADE check make is actually locked (components were set but never read back). - TestCacheInsecureOptionParsed: the comment was false (name.Insecure sets the registry SCHEME, it does not gate parsing). It now asserts the parsed scheme is http WITH Insecure and https WITHOUT, on a non-localhost host (localhost defaults to http, so it would not discriminate). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * chore: re-freeze the PR body against the final head Tree-neutral empty commit: the prior validator run on this head was INCONCLUSIVE (engine attempt-timeout, no code finding), and the two findings from the last real BLOCK (missing components assertion; false Insecure comment) are fixed. A fresh SHA keys a fresh run to the already-final body. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * fix(oci): drop the stale cachePushFn comment reference in runCachePush Round-4 review fix (R1/R5): runCachePush's doc claimed an injection seam "via cachePushFn" that does not exist — the tests drive the real legs through req.Ref (in-memory registry in the default suite, real registry under LIVE_REGISTRY). Comment restated truthfully; identifier sweep is clean. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * docs(oci): drop the forward-looking plugin-cache claim from the transport header The package header named candy/plugin-cache as a consumer; that wrapper does not exist yet, so the claim was ahead of reality. Restated to state only what ships: callers reach the transport over verb:oci. (R1: no doc ahead of the code.) Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * chore: re-trigger the validator (prior runs INCONCLUSIVE — engine timeout) The last two validator runs on this PR returned INCONCLUSIVE (engine attempt-timeout at 15m, provider_unanswered, no code finding), not verdicts. All four BLOCK findings from the last real review are fixed and the diff has been swept for doc/code divergence. Tree-neutral empty commit for a fresh run. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) --------- Co-authored-by: Andreas Trawoeger <[email protected]>
Summary
Replaces
spec/cache.Store(keyed, one-JSON-file-per-key) with one content-addressed artifact store whose on-disk form is a standard OCI Image Layout —oci-layout+index.json+blobs/<alg>/<digest>.Each cached artifact is a real OCI manifest:
configblob = the validity metadata (resolved/components/validator);layers[0]= the cached payload;annotations= the cache key (ai.opencharly.cache.key) + the tag (org.opencontainers.image.ref.name).A named cache is one OCI index, so a whole store can be pushed to / pulled from an OCI registry unchanged (the
verb:ocicache-push/cache-pulltransport lands in the next,plugin-ocichange). Docker cache principles throughout: content addressing, manifest/index entry point, tags for lookup, CAS blob reuse, and no in-place mutation (a write publishes new blobs + atomically swapsindex.json).The file backend uses stdlib +
opencontainers/image-spec+opencontainers/go-digestONLY — nogo-containerregistryin the contract module (both promoted from indirect to direct).Changed files (14):
cache/cache.go,cache/cache_test.go;refs/cache.go,refs/git.go,refs/cache_test.go,refs/git_test.go,refs/git_fresh_test.go,refs/submodule_cache_test.go;container/image_inspect.go,container/local_image_coneb.go,container/cache_test.go,container/engine_ops.go,container/engine_ops_test.go;go.mod. Thecontainer/engine_ops*.gopair is the behavior-neutral lint fix described below; everything else is the cache cutover or its tests. (B15: 4 source commits + one or more tree-neutral body-only empty re-freeze commits, all non-changelog — intended as one squash-merge.)The legacy
StoreAPI (Open/OpenNamed/OpenLimited/Read/ReadTTL/WriteValue) and the legacy voidStore.PutEntry/Store.Read/Store.Writeare deleted in this change (hard cutover, no shim).Layout.PutEntryis retained — it is the caller-controlled-Resolvedwrite seam (the TTL-backdating test path), now returning an error; it is a new signature on the new type, not the legacy method. Consumers migrated in this change:spec/refs(submodule verdicts) andspec/container(image list, image labels). A second commit clears the module'sgolangci-lintfindings — two in the changed files (cache.gostaticcheck QF1008,cache_test.goSA4000) and two pre-existing incontainer/engine_ops.go+container/engine_ops_test.go(gocriticif/else-chain,unconvertdouble conversion); the latter are behavior-neutral (anif/else-ifchain rewritten as aswitch; a redundantstring()on astring-typed value) and are fixed here because they block the module gate (R2).In-place mutation — the root cause this also removes
repoCacheProvenanceVersion 2hard-rejects the legacy bare-commit sidecar. A v1 export cannot certify its tree — the pre-cutover loader rewrote the fetchedcharly.ymlin place (auto-migrating it to the consumer binary's schema CalVer) — so a v1 export is treated as not cached and re-fetched once pristine.IsRepoCachednow enforces this, so immutable-tag caches self-heal too (the immutable short-circuit previously bypassedrepoCacheFreshentirely). This is the proximate fix for the poisoned~/.cache/charly/repos/github.com/opencharly/charly@main(schema 261 in a 249 world) that failedcheck-substrate'sdeploy-add.How tested
This is the
speccontract/library module, and this repo's own committed CI is its authoritative change-class gate —.github/workflows/ci.yml(workflowci, jobgo,on: pull_request) runs exactlygo build ./...+go test ./...+gofmt -l .+golangci-lint run ./...on every PR. That workflow was added deliberately as this module's gate — its own header says: "This repo had NO Go CI at all … The only enforcement was the local.claude/hooks/pre-commit-gate.sh, so nothing keptmaingreen between commits." It is the class gate run by name, and it ran on this PR's exact head:This is the run for head
1219be667152on branchfeat/oci-cas-cache-v2. The tree it gated is the tree this PR ships. Proof — the git tree hash is IDENTICAL at the gated commit and the final head, so the post-CI commits are provably content-free re-freezes:Commit count is not a stable claim across re-freeze rounds; the 4 source commits are the substance (any later commit is an empty, tree-neutral body-only re-freeze).
#143— this change's immediate ancestor, which likewise replacedspec/cache's public API and deletedcache.Read/Write/Invalidate/File— landed on this same gate, answeringR10 — N/A — no disposable deploy target in this repo; the module gate (gofmt/vet/test on the final tree) is the change-class gate:Executed proof that no disposable deploy target exists here (the R10-exception claim — a negative claim needs executed proof), using this tree's real path:
So there is no
disposable: truetarget and nocharly.ymlproject inspec— a bed cannot exercise this change (the "wasted verification" case), and the committedcigate above is the module's change-class gate.Why this is the sanctioned class gate — the MATRIX now has the row (merged). The previous round's BLOCK was correct: the R10 change-class matrix (
/charly-check:check"R10 gate by change class", whose SOLE OWNER islayer-charly-check) had six rows and none for a contract/library module, so no provision sanctioned the module-suite gate. That gap is now fixed onmain:The merged row (from
layer-charly-check#20, landed 2026-09-23) states for this exact class: "Run the repo's OWN committed module CI (.github/workflows/ci.yml:go build ./...+go test ./...+gofmt -l .+golangci-lint run ./...) GREEN on the PR head — the module suite IS the gate, because no bed CAN exist … Tier:fully tested and validated. Explicitly NOT required: acharly check runbed in the module repo." The maintainer also posted explicit T4 sign-off on that PR authorizing the row. This PR complies with that provision exactly. The same three most recent mergedspeccontract-module PRs confirm the practice:#143(the SAME public-API replacement ofspec/cache, deletingcache.Read/Write/Invalidate/File) likewise landed atfully tested and validatedon this gate:This PR reproduces that precedent with the committed
cigate green on its head.Local re-run on the final tree:
New coverage that fails without the change:
TestOnDiskIsOCILayout— the store dir is a valid OCI layout: marker +index.json+ every referenced blob present, size-correct, atblobs/<alg>/<encoded>.TestPutIsContentAddressedAndIdempotent— two keys with identical payloads share ONE blob.TestGCReclaimsUnreferencedBlobs— a superseded payload blob is reclaimed, the live one kept.TestTTLValidity/TestComponentsValidity/TestValidatorRoundTrip— the three validity modes through the OCI config blob.TestFillComputesOnceUnderConcurrency— the flock double-check.TestFillStampsResolved—FillstampsResolved=now(a zero-Resolved callback result must not be persisted instantly-stale). Verified FAIL-without-fix:TestPruneReclaimsOldest,TestDeleteRemovesEntry,TestOpenNamedLayoutResolvesUnderRoot.TestIsRepoCached_LegacyProvenanceIsNotCached— a v1 sidecar is rejected, so a polluted cache self-heals.Live execution of the changed path against the REAL poisoned cache (executed)
The changed
refs/cachecode was executed against this host's actual~/.cache/charly/repos/github.com/opencharly/charly@main(schema2026.261.1747, a legacy v1.ref) — the very cache that failedcheck-substrate'sdeploy-add:R5 sweep + consumer liveness, checked against consumers'
origin/main(executed)The removed API is the legacy
cache.Store+Open/OpenNamed/OpenLimited/Read/ReadTTL/WriteValue+ the legacy voidStore.PutEntry. Swept the spec repo on the final tree — no live caller remains:Out-of-tree consumers of the removed API, checked against their own
origin/main(not a sibling branch):Both are producer-ordered follow-ups in their own repos, tracked by the named batch opencharly/charly#632 (landing order spec → sdk → plugin-oci → remaining consumers). This mirrors
#143exactly, which deletedcache.Read/Writeand deferred these same consumers to their own producer-ordered changes.Consumer-build spike (executed, evidence of independence)
To prove this change does not introduce consumer breakage, I built charly against
spec origin/main+sdk origin/mainwith NO cache change present — the SAME 5 plugins fail:Those failures are prior cutovers' fan-out (
entry.Engine string→spec.EngineNamefrom spec#144;JumpPodmanExec'sspec/exec→sdk/kitmove), pre-existing pin skew, not this change. Their migration is the exit this PR advances: the named batch opencharly/charly#632 (step 5 covers the engine-class/Jump fan-out; steps 1–4 the ArtifactStore consumers).Rulebook compliance
/charly-internals:strict-policy,/charly-internals:go,/charly-internals:cutover-policy,/charly-build:migrate,/charly-internals:git-workflow.Fillstopped stampingResolved) is fixed here with a FAIL-without-fix test, and round 4's body-evidence gaps are addressed with executed output.container/lint findings that block the module gate are fixed here rather than deferred; the out-of-tree consumers land in producer-to-consumer order (named above with theirorigin/mainliveness proof).StoreAPI and the v1 provenance format are deleted in this change; the identifier-keyed sweep above is clean.feat/oci-cas-cache-v2off freshorigin/main; no force-push; append-only review commits.spec/refstest that touches the network is the pre-existing git-latest-tag test, which skips cleanly when offline).N/A — spec builds libraries + internal/schemagen; no main/deployable target, so the module suite is the class gate, now a merged matrix provision (layer-charly-check#20, landed 2026-09-23 — theContract / library modulerow). R8's emitted-artifact boundary is additionally checked byTestOnDiskIsOCILayout(the OCI layout: marker + index + digest-addressed blobs, size-checked). The module's committedcigate (.github/workflows/ci.yml: build + test + gofmt + golangci-lint) is green on this PR's head.schema/cache.cuedescribes the per-hostcharly.ymlcache:section, which is untouched (the store is the on-disk~/.config/charly/cache/area).Change classification
gofmt+go vet+ freshgo test ./...+golangci-linton the final tree (module gate — no disposable deploy target in this repo, the#143precedent).fully tested and validated.Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)