omar espinosa , index
ES , Read in Spanish

[ ci cache engine ]

ci-cache

One cache for agents and CI, without poisoning main.

A Cloudflare Worker over R2 for Turborepo and sccache, tiered by identity.

agent sandboxagent sandboxPR CIPR CImain's CImain's CItier from identitytier from identitybranches · 7 daysbranches · 7 daysmain/ · 30 daysmain/ · 30 days

A CI cache engine on Cloudflare R2. One Worker stores the remote cache of Turborepo (Remote Cache API v8) and of sccache (WebDAV) for each repository. A coding agent compiling in its sandbox and the CI of its pull request read and write the same cache, so the PR reuses what the agent already built instead of compiling it again.

Numbers from the first repo

The first repo onboarded is klav: a Rust workspace of 12 crates, a browser extension, two Docker images and a Postgres suite, in one CI job with seven parallel tasks.

BeforeAfter
CI job, median of first attempts12.4 min (n = 53)~10 min (n = 4)
Rust cache hit rate, warm main—99.84 %
PR CI reusing the agent's compiled objects—96 % (1,302 of 1,355)
Docker task406–485 s23 s warm
Browser extension task~636 s287 s at best
sccache read, average0.869 s0.067 s

Every comparison is between first attempts on the same machine class: fast machines ran the same job in ~333–434 s and slow-I/O ones in ~536–702 s, a bigger gap than most of the changes being measured.

The client never picks its tier

Who writes where
  1. Agent sandbox or CI job
  2. POST /v1/session GitHub OIDC or a sandbox key
  3. Tier from identity
  4. Turbo / sccache
  5. R2 main/ 30 days · branches 7 days

Only the push CI of main, with an OIDC token signed by GitHub, writes to main/. Pull requests, other branches and every sandbox key write to their own branch prefix and read it first, then main/. An artifact an agent got wrong can, at most, be reused by that same branch; it never reaches main or anyone else. A leaked sandbox key can only write branches that expire in seven days.

Where the bucket lives matters most

Measured from a sandbox in Warsaw, every R2 operation took ~180 ms with the bucket in western North America and 50–120 ms in western Europe; average sccache reads dropped from 0.869 s to 0.067 s. Moving the Worker next to the bucket was worse: the body crossed the Atlantic and a 512 KB read went to ~0.9 s.

No dashboard

Each cache request writes one point to Workers Analytics Engine. A JSON API, documented in OpenAPI 3.1, returns hits, misses, bytes and time saved by tier and protocol, and raises reuseAlert when an agent writes 20 or more objects on a branch and that branch's CI reuses none of them: almost always a cache key that differs between the sandbox and CI.

With boated-ci

It pairs with the boated-ci skill. boated-ci brings a pull request down to one machine start; ci-cache makes that start warm. Its own skill carries the measurement protocol: five or more first attempts per variant, cold and warm runs kept apart, each run classified by machine before comparing.

Stack TypeScript · Hono · Cloudflare Workers · R2 · Analytics Engine · Turborepo · sccache · GitHub OIDC · OpenAPI