Public: anyone can read this; the crew can change it.

A new pinned machine fetches only its pinned commit, not the whole repository… #16518

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

The pinned boot now fetches only its pinned commit at depth 1, instead of cloning the whole repository. I haven't seen it on a real deploy, so the "edge log shows seconds" part of the proof is still open. Tests and tsc --noEmit passed locally, and I ran gate.ts --fix first.

Notes

shipped production is serving it deploy 3256dd5

opened this

The pinned boot now fetches only its pinned commit at depth 1, instead of cloning the whole repository. I haven't seen it on a real deploy, so the "edge log shows seconds" part of the proof is still open.

Tests and tsc --noEmit passed locally, and I ran gate.ts --fix first. I did not run the full suite or the design lint.

What changed

  • src/cloud/machine.ts: the boot now runs git init, then git fetch -q --depth 1 <source> <version> (same 5 tries, 15 s apart), then git checkout -q --detach FETCH_HEAD.
  • test/pinned-harden.test.ts has a new test that the boot fetches depth 1 by commit and never runs git clone.
  • test/pinned-forge.test.ts, test/pinned-hetzner.test.ts and test/own-forge.test.ts were asserting the old checkout --detach <sha> / git clone strings, so I updated them to the new commands.
  • The ordering check in test/own-forge.test.ts used to compare against a string that was never found, so it passed vacuously. It now compares against the real checkout command.
  • New test/fetch-by-id.test.ts runs the real advertiseRefs and serviceRpc behind Bun.serve. It checks that a depth-1 fetch of a non-tip commit by id works over protocol v0 and v2, and that an id the repository doesn't hold is refused.

Where the issue didn't match the code

  • The forge's upload-pack already serves commits by id. src/git/smart-http.ts sets uploadpack.allowAnySHA1InWant=true, which is broader than allowReachableSHA1InWant, and I left it. Partial clones fetch blobs by id, and the fork-boundary checks in own_refs.ts rely on it (test/boundary-fork-objects.test.ts).
  • The "not our ref" refusal comes from a plain git upload-pack with no -c flags. I reproduced that locally; it doesn't come from the forge's served path.
  • Because any id the repository holds is served, a present-but-unreachable object is not refused. My refusal test therefore covers an id the repository doesn't have.
  • If you want only reachable commits served, that is a separate change and would break v0 blob fetches.

Pack pacing

  • I did not exempt pinned machines from pacing. They aren't identifiable at the git door today, and the exemption that exists is only for loopback fetches (wasInternal).
  • A depth-1 fetch should send a few MB instead of about 50 MB, so even at roughly 120 KiB/s that is tens of seconds rather than seven minutes. I haven't measured it.
  • If it is still slow on a real boot, exempt the pinned machines' source address from pacer.pace.

To try it: bun test test/fetch-by-id.test.ts test/pinned-harden.test.ts. To confirm the speed, boot a pinned machine and look for its git-upload-pack line in the edge log. I did not post a comment on the issue, so the pacing decision above needs to be copied there.

🤖 Generated with Claude Code

Closes #16355

commented

The pinned boot now fetches only its pinned commit at depth 1, instead of cloning the whole repository. I haven't seen it on a real deploy, so the "edge log shows seconds" part of the proof is still open.

Tests and tsc --noEmit passed locally, and I ran gate.ts --fix first. I did not run the full suite or the design lint.

What changed

  • src/cloud/machine.ts: the boot now runs git init, then git fetch -q --depth 1 <source> <version> (same 5 tries, 15 s apart), then git checkout -q --detach FETCH_HEAD.
  • test/pinned-harden.test.ts has a new test that the boot fetches depth 1 by commit and never runs git clone.
  • test/pinned-forge.test.ts, test/pinned-hetzner.test.ts and test/own-forge.test.ts were asserting the old checkout --detach <sha> / git clone strings, so I updated them to the new commands.
  • The ordering check in test/own-forge.test.ts used to compare against a string that was never found, so it passed vacuously. It now compares against the real checkout command.
  • New test/fetch-by-id.test.ts runs the real advertiseRefs and serviceRpc behind Bun.serve. It checks that a depth-1 fetch of a non-tip commit by id works over protocol v0 and v2, and that an id the repository doesn't hold is refused.

Where the issue didn't match the code

  • The forge's upload-pack already serves commits by id. src/git/smart-http.ts sets uploadpack.allowAnySHA1InWant=true, which is broader than allowReachableSHA1InWant, and I left it. Partial clones fetch blobs by id, and the fork-boundary checks in own_refs.ts rely on it (test/boundary-fork-objects.test.ts).
  • The "not our ref" refusal comes from a plain git upload-pack with no -c flags. I reproduced that locally; it doesn't come from the forge's served path.
  • Because any id the repository holds is served, a present-but-unreachable object is not refused. My refusal test therefore covers an id the repository doesn't have.
  • If you want only reachable commits served, that is a separate change and would break v0 blob fetches.

Pack pacing

  • I did not exempt pinned machines from pacing. They aren't identifiable at the git door today, and the exemption that exists is only for loopback fetches (wasInternal).
  • A depth-1 fetch should send a few MB instead of about 50 MB, so even at roughly 120 KiB/s that is tens of seconds rather than seven minutes. I haven't measured it.
  • If it is still slow on a real boot, exempt the pinned machines' source address from pacer.pace.

To try it: bun test test/fetch-by-id.test.ts test/pinned-harden.test.ts. To confirm the speed, boot a pinned machine and look for its git-upload-pack line in the edge log. I did not post a comment on the issue, so the pacing decision above needs to be copied there.

🤖 Generated with Claude Code

Approved

Clean. The boot interpolates only values already validated in core/pinned.ts (a 40-hex id or vN.N.N tag), so no new injection surface. A tag fetches by name at depth 1 and FETCH_HEAD peels on checkout. The retry loop wipes the checkout before each try. The tests would fail without the change, and the own-forge ordering assertion that used to pass vacuously is now real. No secrets, no new dependency, no page or terminal surface. Not seen on a real deploy: the speed proof and the pacing decision stay open, as the description says.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs