Skip to content

feat: integrate wolfeidau/content-cache for git and registry endpoints#138

Draft
lox wants to merge 1 commit intomainfrom
lachlan/content-cache-integration
Draft

feat: integrate wolfeidau/content-cache for git and registry endpoints#138
lox wants to merge 1 commit intomainfrom
lachlan/content-cache-integration

Conversation

@lox
Copy link
Copy Markdown
Contributor

@lox lox commented Apr 2, 2026

Summary

Embeds wolfeidau/content-cache to serve git and OCI registry requests through a shared content-addressed cache with singleflight deduplication across sandboxes.

What changed

New files

File Purpose
contentcache.go Constructor — wires CAFS, BoltDB, git + OCI handlers with credential-injecting HTTP client
contentcache_types.go ContentCache struct, accessors, credentialInjector RoundTripper, registryHostname helper
git_cached.go Policy wrapper — scope check, host allowlist, push rejection, strips /git prefix
oci_cached.go Policy wrapper — scope check, prefix→host mapping, method filter, rewrites /registry//v2/
*_test.go 13 tests covering policy enforcement, path rewriting, method filtering

Modified files

  • server.go: ContentCache field on ServerConfig; route setup prefers cached handlers with fallback to existing behaviour
  • serve.go: Creates ContentCache with git allowed hosts, wires into gateway config
  • .mise.toml / go.mod: Go 1.23 → 1.26, added content-cache@v1.2.0

Architecture

Gateway (identity + policy) → cachedGitHandler / cachedRegistryHandler → content-cache handlers → CAFS → BoltDB + filesystem
  • Git: Caches git-upload-pack responses keyed by BLAKE3(request body). info/refs always proxied fresh. Replaces full bare mirror clones for the HTTP serving path.
  • Registry: Full OCI Distribution caching proxy. Manifests by tag cached with TTL, blobs/digests cached immutably.
  • Credentials: credentialInjector RoundTripper bridges per-sandbox CredentialProvider into content-cache's static-client model.
  • Fallback: When ContentCache is nil, existing mirror-backed git handler and registry stub are used unchanged.

Notes

  • GitMirrorStore is preserved for the snapshot/control-service path (EnsureMirrorContains) — that's orthogonal to the HTTP cache.
  • OCI registries are not yet configured in serve.go (only git allowed hosts) — registry config can be wired from runtime config in a follow-up.

@lox lox force-pushed the lachlan/content-cache-integration branch from 0f13db8 to f2d2c36 Compare April 3, 2026 04:30
Embed content-cache's CAFS, BoltDB metadata index, and protocol handlers
to serve git and OCI registry requests through a shared content-addressed
cache with singleflight deduplication across sandboxes.

- Add ContentCache layer wrapping content-cache's git and OCI handlers
  with a shared CAFS blob store and BoltDB metadata index
- Add cachedGitHandler: policy enforcement wrapper that validates sandbox
  scope, checks host allowlist, rejects pushes, then delegates to
  content-cache's git handler for caching and upstream proxying
- Add cachedRegistryHandler: policy enforcement wrapper that rewrites
  /registry/ to /v2/, maps prefixes to upstream hosts for policy checks,
  and delegates to content-cache's OCI handler
- Add credentialInjector RoundTripper to bridge per-sandbox credential
  resolution into content-cache's static-client upstream model
- Wire into gateway server with fallback to existing mirror-backed git
  handler and registry stub when content cache is not configured
- Upgrade Go 1.23 -> 1.26, GOTOOLCHAIN local -> auto

Amp-Thread-ID: https://ampcode.com/threads/T-019d4351-d9c5-742f-8805-f909845b4f2b
@lox lox force-pushed the lachlan/content-cache-integration branch from f2d2c36 to 17d1f78 Compare April 3, 2026 05:41
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.

1 participant