Skip to content

feat(remote-cache): add self-hosted public cache server - #718

Draft
fengmk2 wants to merge 17 commits into
mainfrom
feat/public-remote-cache
Draft

fengmk2 wants to merge 17 commits into
mainfrom
feat/public-remote-cache

Conversation

@fengmk2

@fengmk2 fengmk2 commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Add packages/remote-cache for the server in #716, using Cloudflare Workers, primary D1 metadata, and a private R2 bucket. The server supports public reads and GitHub Actions OpenID Connect checks for writes. Stores use streaming uploads, atomic publication, storage limits, and automatic data expiry.

One workflow deploys related changes to a persistent staging Worker, D1 database, and R2 bucket. Internal PRs, main pushes, and manual runs share these resources. The workflow runs deployments and smoke tests in sequence, then updates PR comments with the tested revision and manual instructions. Each deployment replaces the previous revision. Closing a PR keeps staging available. Setup uses repository secrets and variables. Repository maintainers can configure staging without a GitHub environment.

The e2e plan defines automated checks and manual exercises. PR runs check public reads and rejected writes. Pushes to main also check authorized uploads, multipart storage, replacement, concurrency, and quotas. Local tests repeat smoke checks against reused storage and retain maximum-payload and scheduled-handler coverage. Real Cron execution and maximum payloads on Cloudflare require separate release exercises.

/fetch returns only { kind: "fallback", key } for fallback matches and does not read R2. Exact matches return the value and blob_id. A missing or unreadable exact value returns 503. Fetch misses and unavailable blobs return plain-text 404, as specified in the local RFC.

Setup rejects incompatible origins and repositories before it changes existing policies or saved configuration. Each Worker has separate rate-limit counters that remain stable across revisions. Workers Free CPU support remains unverified. The guide recommends Workers Paid for the full payload limits.

Motivation

Maintainers need a cache service in their own Cloudflare account. Developers and fork contributors must reuse public task results without login. Only trusted jobs on main should publish those results. Reviewers need one persistent staging environment and a clear verification result after each related change.

@socket-security

socket-security Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  +0.91%  [ -5.81% ..  +7.55%]  overhead  +292.32%
dynamic/access             change  +0.30%  [ -1.63% ..  +4.63%]  overhead   +14.48%
dynamic/access-relative    change  +0.11%  [ -1.93% ..  +1.36%]  overhead   +59.28%
dynamic/access-contended   change  +0.40%  [-13.48% ..  +4.43%]  overhead   +14.43%
static/launch              change  -0.10%  [ -5.41% ..  +6.32%]  overhead  +747.10%
static/access              change  -0.00%  [ -1.95% ..  +1.59%]  overhead  +810.79%
static/access-relative     change  -0.11%  [ -1.45% ..  +1.67%]  overhead +1378.82%
static/access-contended    change  -0.05%  [ -8.10% ..  +2.48%]  overhead +3118.95%

macos

dynamic/launch             change  +0.37%  [ -4.01% ..  +5.00%]  overhead  +240.74%
dynamic/access             change  +0.32%  [-20.80% ..  +8.61%]  overhead    +7.70%
dynamic/access-relative    change  -1.27%  [-26.94% ..  +9.86%]  overhead  +260.87%
dynamic/access-contended   change  +1.74%  [ -7.51% .. +34.70%]  overhead    +4.77%

windows

dynamic/launch             change  -0.99%  [-11.36% ..  +8.94%]  overhead   +27.05%
dynamic/access             change  +1.20%  [-13.58% .. +27.46%]  overhead    +2.26%
dynamic/access-relative    change  -0.33%  [ -9.46% ..  +3.70%]  overhead    +1.38%
dynamic/access-contended   change  +0.43%  [-10.65% ..  +7.96%]  overhead    +3.51%

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Remote cache staging

Commit: 0c55376f703fa7456db036ea15996bdf4834c523

Cloudflare deployment or e2e verification failed. The staging deployment is not marked ready. See the workflow run.

Manual checks and complete e2e plan.

@fengmk2
fengmk2 force-pushed the feat/public-remote-cache branch from 194d39f to e461d47 Compare September 14, 2026 15:16
@fengmk2

fengmk2 commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

Deploy prompt:

Refer to the deployment instructions at https://github.com/voidzero-dev/vite-task/blob/feat/public-remote-cache/packages/remote-cache/docs/self-hosting.md to deploy a remote cache service for the current repo.

@wan9chi
wan9chi force-pushed the feat/public-remote-cache branch from df2d129 to e127e9b Compare September 27, 2026 16:04
@wan9chi
wan9chi changed the base branch from main to remote-cache-hardening September 27, 2026 16:04
@wan9chi
wan9chi added this pull request to stack #759 September 27, 2026 16:04
Base automatically changed from remote-cache-hardening to main September 27, 2026 16:32
@wan9chi
wan9chi force-pushed the feat/public-remote-cache branch from e127e9b to d4b0fea Compare September 27, 2026 16:32
@wan9chi
wan9chi force-pushed the feat/public-remote-cache branch from 58347c9 to c2f00bd Compare September 27, 2026 17:15
@wan9chi
wan9chi removed this pull request from stack #759 September 27, 2026 17:15
@wan9chi
wan9chi changed the base branch from main to remote-cache-fetch-404 September 27, 2026 17:15
@wan9chi
wan9chi added this pull request to stack #773 September 27, 2026 17:16
Base automatically changed from remote-cache-fetch-404 to main September 28, 2026 02:52
wan9chi added a commit that referenced this pull request Sep 28, 2026
## Motivation

The public cache service (#718) follows its RFC and answers a fetch that
matches neither key with HTTP 404 and a plain-text body. It never sends
`kind: "not_found"`. The client and the Node test backend still used a
200 response with `kind: "not_found"`, so a miss meant different things
depending on the server. This switches both to 404 and drops the
`not_found` kind, giving the client and both servers one miss contract.

## Changes

- `vt_remote_cache`: `Client::fetch` returns `Result<Option<Fetched>,
Error>`, with `None` for a 404 response. `Fetched` only describes the
body of a 200 response, so its `NotFound` variant is removed. A 200
response with `kind: "not_found"` is now a malformed response. Every
other non-200 status is still an error, and a 404 download still fails.
- Test backend (`packages/tools`): a fetch miss gets a 404 with the body
`Not found`, logged as `POST /fetch 404`.
- The remote cache e2e snapshots change only in those backend lines and
responses. The `vp run` output is unchanged.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
fengmk2 and others added 13 commits September 28, 2026 10:52
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Copy RFC #716 from c201f8e and adjust relative paths.

Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
Remove the obsolete cache size study and its RFC link.

Co-authored-by: GPT-6 Codex <codex@openai.com>
fengmk2 and others added 4 commits September 28, 2026 10:52
Co-authored-by: GPT-6 Codex <codex@openai.com>
Co-authored-by: GPT-6 Codex <codex@openai.com>
`npm_execpath` points to pnpm's standalone executable on the Linux and
Windows runners, so running it through `node` failed. Run it directly
unless it's a JavaScript entry point.

The remote cache package also brought esbuild and workerd into the
workspace, and a root `pnpm install` without `--ignore-scripts` failed
on their unapproved build scripts. Allow them, as the standalone package
already does.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…service

`remote-cache-server` now runs the Worker from `packages/remote-cache`
in workerd through Miniflare instead of the Node test backend, so the
e2e tests exercise `vp run` against the real service.

The wrapper proxies requests to the service. It signs an upload token
for each store with a key the service fetches in place of GitHub's. It
numbers the service's random blob IDs in upload order for the request
log, and copies each blob to `remote-cache/blobs/<number>`, storing a
changed copy on the next run so tests can still corrupt an archive.

The only snapshot change is the request log for a fetch miss, which the
service answers with a 404. The cases are skipped on musl because
workerd's prebuilt binaries require glibc.

The `remote_cache_backend` fixture only tested the old backend, and the
service has its own protocol tests, so it's removed along with
`cbor-http` and its EDN formatting.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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