8000 feat(mctx): default cache reads to the R2 mirror (cache.minimal.dev) by bryan-minimal · Pull Request #1234 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

feat(mctx): default cache reads to the R2 mirror (cache.minimal.dev) - #1234

Merged
bryan-minimal merged 1 commit into
mainfrom
feat/r2-default-read
Aug 18, 2026
Merged

bryan-minimal merged 1 commit into
mainfrom
feat/r2-default-read

Conversation

@bryan-minimal
@bryan-minimal bryan-minimal commented Aug 17, 2026 •
Copy link
Copy Markdown
Member

DRAFT until infra#422 is deployed and verified — the cache.minimal.dev custom domain + index.shisha bypass route must be live before this default can ship. I'll mark ready-for-review with the verification transcript once the domain passes the three-curl parity check (artifact bytes ≡ .farm ≡ GCS, fresh index, 404 passthrough).

What flips

Read-side default only. Precedence after this change: MINIMAL_REMOTE_CACHE_URL env override → explicitly configured location → https://cache.minimal.dev/. Ends the per-repo whack-a-mole (webapp#380, pkgs#613, build-servers#239 — all become harmless no-ops) and covers every laptop and future consumer with zero wiring.

What deliberately does NOT change

  • Writes: still derive from the configured gs:// bucket; an HTTPS mirror remains read-only. The read default cannot leak into the writer (new test pins this).
  • In-cloud readers: res-servers pin gs:// explicitly (buildbot sends remote_cache_gcs_bucket unconditionally — verified at the single call site), keeping free same-region GCS reads.
  • Escape hatch: MINIMAL_REMOTE_CACHE_URL=gs://minimal-staging-cache returns any client to direct GCS.

Also in here

The chosen read location + source is now logged at info — selection was previously silent, which made "is this client actually on the mirror?" unanswerable from logs (this month's egress attribution took GCS access-log forensics; that gap dies here).

Safety case

Same objects, byte-identical (R2 is Sippy-fed from authoritative GCS; verified); every artifact is sha256-verified client-side regardless of source; the mutable root index.shisha is served fresh from GCS by the edge Worker on both hostnames; per-commit snapshots (the default read path since #912/#995) are immutable. The env-var version of this exact routing has run in webapp CI since July 8 and is canaried by dogfood (#667).

Local validation: cargo check -p mctx clean; clippy findings identical to baseline (10 pre-existing); mctx's test target doesn't compile on macOS at baseline either (pre-existing, unrelated) — Linux CI is authoritative for the new test.

🤖 Generated with Claude Code

Note

Default remote cache reads to the R2 mirror (cache.minimal.dev) in mctx

  • ConfigBuilder.build now selects the read URL by precedence: env override (MINIMAL_REMOTE_CACHE_URL) > explicitly configured value > new DEFAULT_REMOTE_CACHE_READ_URL constant pointing at https://cache.minimal.dev/.
  • Write bucket derivation is unchanged — it continues to come from the explicitly configured location via parse_remote_cache_url.
  • An info log is emitted at build time indicating the selected read URL and which precedence level chose it.
  • Behavioral Change: unconfigured builds now read from the R2 mirror instead of the GCS default.

Macroscope summarized d502ef2.

Summary by CodeRabbit

  • New Features
    • Improved remote cache configuration by using a faster default read source.
    • Preserved existing cache write behavior while separating read and write locations.
    • Added clearer logging to indicate the selected cache source.

Reads were GCS-by-default with R2 as an opt-in env override, which
made zero-egress reads something every CI fleet and laptop had to
discover and wire individually (webapp#380, pkgs#613,
build-servers#239, ...). Flip the default for READS ONLY, precedence:
MINIMAL_REMOTE_CACHE_URL env override, then an explicitly configured
location, then https://cache.minimal.dev/.

The write path is untouched: the writer still derives its bucket from
the configured value (default gs://minimal-staging-cache), and an
HTTPS mirror still cannot be written to. In-cloud readers are
unaffected: res-servers pin gs:// explicitly (buildbot always sends
remote_cache_gcs_bucket), keeping free same-region reads. Escape
hatch back to direct GCS: MINIMAL_REMOTE_CACHE_URL=gs://<bucket>.

Also logs the chosen read location + source (env-override /
configured / default-r2-mirror) at info — selection was previously
silent, and attributing egress took GCS access-log forensics.

Gated on infra PR (cache.minimal.dev custom domain + index.shisha
bypass route) being deployed and verified.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner August 17, 2026 18:20
@coderabbitai
coderabbitai Bot commented Aug 17, 2026 •
Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a10d62c9-f6bf-4291-a4d2-292020379f23

📥 Commits

Reviewing files that changed from the base of the PR and between de61b28 and d502ef2.

📒 Files selected for processing (1)
  • crates/mctx/src/config.rs

📝 Walkthrough

Walkthrough

The cache configuration adds an R2 mirror for default reads. Explicit settings and environment overrides retain precedence. Default writes continue to use the GCS bucket. A test verifies the reader and writer split.

Changes

Remote cache configuration

Layer / File(s) Summary
Cache read/write selection
crates/mctx/src/config.rs
Adds DEFAULT_REMOTE_CACHE_READ_URL. ConfigBuilder::build selects reads using environment override, explicit configuration, then the R2 default. Writes continue to use the configured or default GCS location. A test verifies the default reader and writer locations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: twitchyliquid64, 0chroma

Poem

I’m a rabbit with a cache to share,
R2 reads hop through the air.
GCS writes stay in their place,
Config chooses paths with grace.
Hop, hop, tested bright—
Read and write now split just right.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/r2-default-read

Comment @coderabbitai help to get the list of available commands.

@bryan-minimal
bryan-minimal marked this pull request as draft August 17, 2026 18:33
@bryan-minimal
Copy link
Copy Markdown
Member Author

cache.minimal.dev is live — verification transcript (2026-08-17)

Deployed via infra#422 (custom domain) + infra#423 (zone-plane routes; also opts the cache host out of the *minimal.dev/* analytics-Worker wildcard). Cloudflare stack re-preview settles clean (68 unchanged).

1. Artifact byte-parity — same object from all three hosts, sha256 f3099f7e66d2cb4b53b3a2ad… (which is also its object name — content addressing self-verifies):

  • cache.minimal.dev ✓ · cache.minimal.farm ✓ · authoritative GCS ✓

2. Mutable root index served fresh — GET cache.minimal.dev/index.shisha → HTTP 200, cache-control: no-store (the bypass Worker answering, not R2/Sippy), byte-identical to the live GCS object (506c3a0564d0…).

3. Semantics intact — missing object → clean 404 (the reader's "empty index" signal, unrewritten); per-commit closure snapshot serves correctly (62,424 bytes).

Ready for review — un-drafting is @bryan-minimal's call per the plan. Smoke-test the flip today without waiting for the channel build:

MINIMAL_REMOTE_CACHE_URL=https://cache.minimal.dev/ min session activate --name r2test --sync tarball

@bryan-minimal
bryan-minimal marked this pull request as ready for review August 18, 2026 16:04
@bryan-minimal
bryan-minimal merged commit 0490d38 into main Aug 18, 2026
32 of 33 checks passed
@bryan-minimal
bryan-minimal deleted the feat/r2-default-read branch August 18, 2026 16:05
bryan-minimal added a commit that referenced this pull request Aug 20, 2026
…#1252)

The gcs_access_logs forensics for 2026-08-18/19 show 25-36 GB/day of
billed GCS internet egress from GitHub-hosted runners, and the index
objects those readers fetch (github.com/gominimal/pkgs/b1a1b1b7....shisha
— this repo's own .minimal pin) attribute it to our CI: jobs run the
min built from the branch under test, so any PR branched before #1234
defaults the package-cache reader to gs:// and pays internet egress
for every artifact. Only one ci.yml step had the override (the
build-servers#145 canary), still pointing at the legacy hostname.

Set MINIMAL_REMOTE_CACHE_URL=https://cache.minimal.dev/ at workflow
level in the eight workflows that exercise min, and move the ci.yml
canary to the canonical hostname. Harmless where a job never reads the
package cache; the mutable index.shisha is edge-bypassed to live GCS
(infra#277), and artifacts are immutable + edge-cached (infra#429).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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

0