Skip to content

feat(cache): OCI Image Layout ArtifactStore — content-addressed, registry-portable - #148

Merged
github-actions[bot] merged 6 commits into
mainfrom
feat/oci-cas-cache-v2
Sep 23, 2026
Merged

github-actions[bot] merged 6 commits into
mainfrom
feat/oci-cas-cache-v2

Conversation

@aitrawog

@aitrawog aitrawog commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • config blob = 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:oci cache-push/cache-pull transport lands in the next, plugin-oci change). 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 swaps index.json).

The file backend uses stdlib + opencontainers/image-spec + opencontainers/go-digest ONLY — no go-containerregistry in 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. The container/engine_ops*.go pair 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 Store API (Open/OpenNamed/OpenLimited/Read/ReadTTL/WriteValue) and the legacy void Store.PutEntry/Store.Read/Store.Write are deleted in this change (hard cutover, no shim). Layout.PutEntry is retained — it is the caller-controlled-Resolved write 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) and spec/container (image list, image labels). A second commit clears the module's golangci-lint findings — two in the changed files (cache.go staticcheck QF1008, cache_test.go SA4000) and two pre-existing in container/engine_ops.go + container/engine_ops_test.go (gocritic if/else-chain, unconvert double conversion); the latter are behavior-neutral (an if/else-if chain rewritten as a switch; a redundant string() on a string-typed value) and are fixed here because they block the module gate (R2).

In-place mutation — the root cause this also removes

repoCacheProvenanceVersion 2 hard-rejects the legacy bare-commit sidecar. A v1 export cannot certify its tree — the pre-cutover loader rewrote the fetched charly.yml in 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. IsRepoCached now enforces this, so immutable-tag caches self-heal too (the immutable short-circuit previously bypassed repoCacheFresh entirely). This is the proximate fix for the poisoned ~/.cache/charly/repos/github.com/opencharly/charly@main (schema 261 in a 249 world) that failed check-substrate's deploy-add.

How tested

This is the spec contract/library module, and this repo's own committed CI is its authoritative change-class gate — .github/workflows/ci.yml (workflow ci, job go, on: pull_request) runs exactly go 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 kept main green between commits." It is the class gate run by name, and it ran on this PR's exact head:

$ gh pr checks 148 --repo opencharly/spec
go                   pass    .../runs/35848873085
$ gh run view 35848873085 --repo opencharly/spec --json workflowName,event,headSha,conclusion
workflow: ci   event: pull_request   head: 1219be667152   conclusion: success
$ gh run view 35848873085 --repo opencharly/spec --json jobs
go => Build success, Test success, gofmt success, golangci-lint success   ("0 issues.")

This is the run for head 1219be667152 on branch feat/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:

$ git rev-parse 1219be6^{tree}   # the CI-gated commit
0086abf08f21c66482d70abd2eb5748449b63ce9
$ git rev-parse HEAD^{tree}      # the final head
0086abf08f21c66482d70abd2eb5748449b63ce9

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 replaced spec/cache's public API and deleted cache.Read/Write/Invalidate/File — landed on this same gate, answering R10 — N/A — no disposable deploy target in this repo; the module gate (gofmt/vet/test on the final tree) is the change-class gate:

$ gh pr view 143 --repo opencharly/spec --json body | grep R10
- **R10** — N/A — no disposable deploy target in this repo; the module 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:

$ git grep -c "disposable: true" -- "*.cue" "*.yml"
(exit 1 — no matches, no output: no disposable config entity)
$ git ls-files | grep -cE "(^|/)charly\.yml$"
0

So there is no disposable: true target and no charly.yml project in spec — a bed cannot exercise this change (the "wasted verification" case), and the committed ci gate 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 is layer-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 on main:

$ git -C layer-charly-check show origin/main:charly.yml | grep -c 'Contract / library module'
1
$ git -C layer-charly-check log --oneline origin/main -2
9b07adf docs: add CHANGELOG 2026.266.1023 for PR #20
335ac03 docs(check): add the Contract/library-module row to the R10 gate-by-change-class matrix (#20)

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: a charly check run bed 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 merged spec contract-module PRs confirm the practice:

$ gh pr view 145 --repo opencharly/spec --json body | grep R10
- **R8/R9/R10:** `N/A — spec builds libraries + internal/schemagen; the module suite is the class gate`.
$ gh pr view 144 --repo opencharly/spec --json body | grep R10
- **R8/R9/R10:** `N/A — spec builds libraries + internal/schemagen; no main/deployable target, so the module suite is the class gate`.

#143 (the SAME public-API replacement of spec/cache, deleting cache.Read/Write/Invalidate/File) likewise landed at fully tested and validated on this gate:

$ gh pr view 143 --repo opencharly/spec --json body | grep R10
- **R10** — N/A — no disposable deploy target in this repo; the module gate

This PR reproduces that precedent with the committed ci gate green on its head.

Local re-run on the final tree:

$ gofmt -l .            # empty
$ go build ./...        # clean
$ go vet ./...          # clean
$ go test ./...
ok  github.com/opencharly/spec/cache
ok  github.com/opencharly/spec/refs
ok  github.com/opencharly/spec/container
... (full module green)

$ golangci-lint run ./cache/... ./container/... ./refs/...
0 issues.

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, at blobs/<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 — Fill stamps Resolved=now (a zero-Resolved callback result must not be persisted instantly-stale). Verified FAIL-without-fix:
    $ # remove the `e.Resolved = time.Now()` stamp in Fill
    --- FAIL: TestFillStampsResolved (0.00s)
        cache_test.go:362: Fill must stamp Resolved=now so the entry is TTL-fresh; got Resolved=0001-01-01 00:00:00 +0000 UTC
    
  • 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/cache code was executed against this host's actual ~/.cache/charly/repos/github.com/opencharly/charly@main (schema 2026.261.1747, a legacy v1 .ref) — the very cache that failed check-substrate's deploy-add:

$ CHARLY_REPO_CACHE=<copy of the real poisoned cache> go run .
=== R10-lite live proof: the poisoned-cache self-heal root cause ===
1. legacy .ref: ReadRepoCacheProvenance -> ok=false (bare-commit v1 cannot certify its tree)
2. IsRepoCached(legacy v1) -> false (forces one pristine re-fetch, healing the poisoned cache)
3. after WriteRepoCacheProvenance: ok=true version=2 commit=777d9a6c9e13
4. IsRepoCached(v2 pristine) -> true (a certified export stays a cache hit)
5. ArtifactStore round-trip -> hit=true payload={"merged":"tree"}
6. on-disk shape: index.json exists=true oci-layout exists=true blobs/ exists=true
7. freshness: FreshComponents(matching)=true FreshComponents(drifted)=false

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 void Store.PutEntry. Swept the spec repo on the final tree — no live caller remains:

$ grep -rn --include=*.go -E 'cache\.(Store|Open|OpenNamed|OpenLimited|ReadTTL|WriteValue)\b' .
(no hits)
# `PutEntry` is retained on the NEW type (Layout.PutEntry, returning error) — the
# backdating seam; only the legacy void Store.PutEntry is gone.

Out-of-tree consumers of the removed API, checked against their own origin/main (not a sibling branch):

$ git -C sdk             grep -n 'opencharly/spec/cache' origin/main -- '*.go'
origin/main:loaderkit/load_cache.go:55:  "github.com/opencharly/spec/cache"   # Store/Open/OpenLimited/HashHex/KeyDigest
$ git -C plugin-substrate grep -n 'opencharly/spec/cache' origin/main -- '*.go'
origin/main:candy/plugin-substrate/status_probes.go:24:  "github.com/opencharly/spec/cache"  # cache.Read/cache.Write (the #143-deferred consumer)

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 #143 exactly, which deleted cache.Read/Write and 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/main with NO cache change present — the SAME 5 plugins fail:

$ # charly + spec@origin/main + sdk@origin/main (no cache change)
# github.com/opencharly/plugin-box/candy/plugin-box
# github.com/opencharly/plugin-check/candy/plugin-check
# github.com/opencharly/plugin-fleet/candy/plugin-fleet
# github.com/opencharly/plugin-pod/candy/plugin-pod
# github.com/opencharly/plugin-substrate/candy/plugin-substrate

Those failures are prior cutovers' fan-out (entry.Engine string→spec.EngineName from spec#144; JumpPodmanExec's spec/exec→sdk/kit move), 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

  • R0 — loaded /charly-internals:strict-policy, /charly-internals:go, /charly-internals:cutover-policy, /charly-build:migrate, /charly-internals:git-workflow.
  • R1 — the validator's rounds were each read in full and root-caused before remediation; the one real code regression it found (round 3 — Fill stopped stamping Resolved) is fixed here with a FAIL-without-fix test, and round 4's body-evidence gaps are addressed with executed output.
  • R2 — the whole refactor is in this PR; the two pre-existing 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 their origin/main liveness proof).
  • R3 — this PR CREATES the one content-addressed abstraction; no second cache format is introduced (the OCI layout is the external canonical spec, not a re-definition).
  • R4 / R4a — no sleeps/retries/workarounds; concurrency is a per-key flock; the v1-provenance rejection is a root fix, not a doc-caveat over a defect.
  • R5 — the legacy Store API and the v1 provenance format are deleted in this change; the identifier-keyed sweep above is clean.
  • R6 — feat/oci-cas-cache-v2 off fresh origin/main; no force-push; append-only review commits.
  • R7 / R7a — coverage that FAILS without the change (the OCI-layout shape, CAS dedup, GC, the three validity modes, fill-concurrency, fill-stamp, legacy-provenance rejection); the changed path additionally ran live against the real poisoned cache. R7a: this change introduces no new live-service boundary (the file backend is pure local IO; the spec/refs test that touches the network is the pre-existing git-latest-tag test, which skips cleanly when offline).
  • R8 / R9 / R10 — 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 — the Contract / library module row). R8's emitted-artifact boundary is additionally checked by TestOnDiskIsOCILayout (the OCI layout: marker + index + digest-addressed blobs, size-checked). The module's committed ci gate (.github/workflows/ci.yml: build + test + gofmt + golangci-lint) is green on this PR's head.
  • SDD — no schema-shaped wire type changed; schema/cache.cue describes the per-host charly.yml cache: section, which is untouched (the store is the on-disk ~/.config/charly/cache/ area).

Change classification

  • Change class: Go library (the shared cache mechanism) — contract-module cache-format cutover.
  • Verification gate: gofmt + go vet + fresh go test ./... + golangci-lint on the final tree (module gate — no disposable deploy target in this repo, the #143 precedent).
  • Attribution tier: fully tested and validated.

Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

…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)
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 1219be667152 (branch: feat/oci-cas-cache-v2)

Change class: Go library (spec contract module) — cache-format cutover; no disposable deploy target.

Blocks

  1. A1 / rule 2 — the body's "How tested" evidence is not for the current head. The body asserts the ci gate "ran on this PR's exact head", but pastes head: 080a8320a58e — the 4th commit — while the current head is 1219be667152 (5th commit, "docs: re-freeze the PR body against the final head"). The body also runs gh pr checks 147 for a PR numbered feat(cache): OCI Image Layout ArtifactStore — content-addressed, registry-portable #148, states "B15: four commits" (the commit list has five), and names the branch feat/oci-cas-cache (actual feat/oci-cas-cache-v2). Re-freeze the body against the current head: cite 1219be667152, the correct commit list, and the correct branch, and paste the class-gate result for that head — or state explicitly that the only post-CI delta is a tree-neutral, body-only commit.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

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)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 73353b812d9384da01cb1e0be6358265d070dfcc (branch: feat/oci-cas-cache-v2)

Change class: Go library (spec contract module) — cache-format cutover; no disposable deploy target; module suite is the class gate.

Security screen: PASS — no secrets/egress, no weakened guardrails, no self-modifying-security change; only opencontainers/go-digest + image-spec promoted indirect→direct (already in the graph).
Checklist: All applicable rules PASS or NA. The prior BLOCK's four body-staleness findings (gh pr checks 147→148, head 080a8320a58e→1219be667152, "four commits"→"4 source + tree-neutral re-freeze", branch feat/oci-cas-cache→feat/oci-cas-cache-v2) are all corrected in the current body, which now states the post-CI delta is a tree-neutral, body-only commit and pastes the tree-hash identity proof — satisfying the prior demand. No surviving finding reproduces against the current diff/body.

Comment dispositions: 1 comment (github-actions[bot], 1219be667152) — stale-superseded: every claim was body-staleness now fixed in the current body; re-derivation against the current head/diff/commits confirms none survives.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 23, 2026 10:44
@github-actions
github-actions Bot merged commit a3ae9cb into main Sep 23, 2026
2 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 23, 2026
aitrawog pushed a commit to opencharly/sdk that referenced this pull request Sep 23, 2026
…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)
github-actions Bot pushed a commit to opencharly/sdk that referenced this pull request Sep 23, 2026
…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]>
aitrawog pushed a commit to opencharly/plugin-oci that referenced this pull request Sep 23, 2026
…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)
github-actions Bot pushed a commit to opencharly/plugin-oci that referenced this pull request Sep 23, 2026
…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]>
@aitrawog
aitrawog deleted the feat/oci-cas-cache-v2 branch September 25, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants