Repository navigation
feat(infra): nix.moq.dev serves from Backblaze B2 - #9625
Merged
Merged
Conversation
Quest-Claim: 5e4d2a22a82a90f6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cted one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 25, 2026 20:52
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… object Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
nix.moq.dev's Worker serves the release and CI Nix caches from R2 (
nix-moq-dev,nix-ci-moq-dev). The quest nix-b2 moves them to private Backblaze B2 buckets in theus-east-005account, whose credits cover storage, beside the Rust cache's move (moq-dev/moq#9624).Approach
infra/nix/src/worker.ts): the R2 bindings become path-style S3 GETs/HEADs tos3.us-east-005.backblazeb2.com/<bucket>/<key>, signed (SigV4) by aws4fetch with each bucket's read-only key, held as the Worker secretsB2_RELEASE_*andB2_CI_*. Release first, then CI, as before. aws4fetch's default 10 retries with backoff are off, so a failed read stays a quick miss.no-store(logged), so the other bucket can still serve and Nix otherwise builds from source. A 401/403 (a rejected key; the account sets no cap that would also answer 403), a 200 withoutContent-LengthorETag, or a missing secret throws: a deploy error. Any other answer, such as a 404 or a 400 for a key too long, is a plain cacheable miss.+in the key is sent as%2B, since aws4fetch signs a path's+as a space and B2 then rejects the signature.Range: bytes=<sent>-withIf-Match: <first etag>: 206 continues, 412 ends the stream ("object changed"), anything else counts against the same 5-resume cap. New: a body that errors after its last byte closes cleanly instead of resuming into a 416.just infra nix push,roots, andrefreshtarget B2's S3 endpoint and region; rclone's remote becomesb2:(providerOther).cache.ymlreadsNIX_B2_CI_*andrelease-nix.ymlreadsNIX_B2_RELEASE_*fromcache-write. Thereleasecopy is backported in moq-dev/moq#9628.infra/nix/lifecycle.json, now B2's format, keyed by bucket): CI hides objects 14 days after their newest upload; both buckets delete a hidden or superseded version a day later.refresh's copy-onto-itself therefore restarts an object's age, and its old version is gone a day later.just infra nix lifecycle <bucket>applies the file with the B2 CLI and that bucket's write key;createis gone (buckets are made in the console).infra/README.md's Nix bootstrap describes the B2 buckets, keys, and secrets. The quest is rewritten to what remains after this merges (below).Done outside the tree
nix-moq-dev("Keep only the last version") andnix-ci-moq-dev(custom: hide after 14 days, delete a day later), both private. Rules confirmed withbackblaze-b2 bucket get, applied once more throughjust infra nix lifecycle.nix-release-read,nix-ci-read(Read Only) in the Worker'sB2_RELEASE_*/B2_CI_*secrets on the live Worker (harmless to the R2 code it still runs);nix-release-write,nix-ci-write(Read and Write) incache-write'sNIX_B2_RELEASE_*/NIX_B2_CI_*. Each restricted to its bucket.release-nix.ymlrun queued or in progress, the R2 token behindNIX_R2_*("Nix Cache", R2 -> API Tokens) is deleted, so a pre-backport tag fails loudly. A fresh listing of R2nix-moq-devthen matched the copied one key for key (1,629 objects, size and etag), so the top-up copy had nothing to add and needed no short-lived key.nix-moq-dev's 1,628 cache objects (1.81 GB) copied to B2 through nix.moq.dev; sizes and MD5s match R2's listing for every key (itsnix-cache-infois the Worker's, which it answers itself anyway).Impact
Public API: none. Wire: none. Operational: GitHub secrets
NIX_B2_{RELEASE,CI}_*replaceNIX_R2_*, and the Worker needsB2_{RELEASE,CI}_*.Alternatives
nix copydoes not upload multipart by default.Decisions
Answered by the maintainer on 2026-11-25 (/quest-run), with the pick to
/quest-mergeonce #9628 landed:writeBuckets, so acache-writejob could change its bucket's settings, as with mbx's keys.just infra nix lifecycle <bucket>stays, run with a short-lived write key for that bucket.Recorded earlier as recommendations, standing:
nix-moq-dev/nix-ci-moq-dev, sojust infra nix push <bucket>call sites are unchanged.release's stale Worker and recipes wait for the next cut.cache.ymlrunning frommain.Landing order
moq-dev/moq#9628 merged into
releaseas cdcc9f2, so this can land. After it lands, the Worker deploys oncejust gh cache-revreaches this PR's merge, then the substitution checks run and R2 is deleted; the rewritten quest holds these steps.Validation
wrangler devwith the read keys: a narinfo and NAR pushed tonix-ci-moq-devserve after a release-bucket miss (GET/HEAD 200,Content-Lengthand cache headers right, NAR bytes hash to the narinfo'sFileHash), an absent key 404s cacheably, andnix copy --fromthe Worker into a scratch store verifies the signature.docker.io/nixos/nixcontainer withcache.nixos.orgplus that Worker as its only substituters,github:moq-dev/moq/moq-relay-v0.17.18#moq-relay(copied from R2) builds nothing, fetchesmoq-relay-0.17.18from the Worker, and printsmoq-relay 0.17.18.just infra nix push nix-ci-moq-dev <path>with a throwaway signing key,roots, andrefreshall pass;rclone touchmoved the object's upload time from 20:35:40 to 20:35:53 and left the old version for the lifecycle to delete. Test objects removed afterward.wrangler dev:GET /log/abc-libsigc++-2.drvand a 2000-character key each answer 404 with no exception (signature accepted, refusal a plain miss).infra/nix:bun test, 24 pass.tsc --strictagainst@cloudflare/workers-typesonworker.ts: clean.bun run deploy --dry-run: builds.just check: passes.main(all after merge).Follow-ups
None.
Models
(Written by Claude Opus 5.5)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 9691e64
Base: origin/main at 5bb7578
Risk: high,
A bad change to the Worker's signed B2 reads or the release-nix.yml write path could stop nix.moq.dev from serving released packages to Nix users and downstream flakes that pin old tags, and the diff also changes workflows under .github/workflows/, which the risk file always marks high; reverting the code is quick, but a bad deploy or secret swap reaches those users before a check catches it.Classified: high by Claude Code, claude-haiku-5-5, low effort, session
99ea0355-2cc1-4c21-b91c-ce38b76b2291Reviewer: Codex, gpt-6.2-sol, high effort
Session:
01a21472-e67d-7fb2-853f-f09fefef11a4, round 5Score: 10/10,
The runbook records the completed release-cache migration steps and keeps the Worker cutover gated on a B2-backed revision selected by Smoke.Rounds: 5; first round 2 (medium 2); findings 2 (medium 2): fixed 2, refuted 0, open 0
Findings: none
Reviewer: Claude Code, claude-opus-5-5, high effort, second
Session:
68a4523a-c6e8-44c2-8f1c-e376259be6b1, round 5Score: 9/10,
Since the last round, the branch merged origin/main, which brought the mbx B2 move (#9624) into the README, and added one commit that marks quest steps done (backport merged, R2 write token deleted, B2 listing checked against R2). Nothing in that changes the nix Worker or workflows, and no finding is open.Rounds: 5; first round 2 (medium 2); findings 2 (medium 2): fixed 1, refuted 1, open 0
Findings: none