Skip to content

feat(sandbox): vendor the GitHub CLI (gh) into the sandbox images - #661

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:feat/sandbox-gh
Oct 29, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:feat/sandbox-gh

Conversation

@pdettori

Copy link
Copy Markdown
Member

Why

docs/sbx/user-guide.md §6 promises that gh works in a sandbox — `gh pr create` under the sbx credentials feature — but no image carried the binary. gh is not in the UBI 9 repositories, so every sandbox shipped without it and each gh call failed with exit 127 inside an otherwise healthy, attached sandbox.

What

  • remote-worker/Dockerfile / Dockerfile.runtime: a gh build stage, vendored the way rg is — upstream release tarball pinned by version (2.103.3) and per-arch sha256, sha256sum -c fails the build closed, fetched in its own stage so the unpack tools never reach the runtime image. The upstream binary links glibc only, which ubi-minimal carries; gh --version at the end of the RUN fails the build if that ever changes (live-verified in a RHEL 9.8 rootfs chroot on the SBX0 KVM host).
  • cmd/worker/main.go: gh joins probed, so Hello.capabilities advertises it.
  • dockerfile_parity_test.go: a provides entry for gh (vendored token, so a comment cannot satisfy it) and TestVendoredGhIsPinnedAndChecksummed mirroring the rg pinning test — gh runs against the user`s GitHub identity under the sbx credentials feature, so a tampered download is not acceptable.
  • build-snapshot.sh / build-rootfs.sh: the guest capabilities probe and REQUIRED_TOOLS gain gh. Both are pinned against the Go probed list by their own tests, which drove this change test-first (adding gh to probed failed all three suites until each file caught up).

Test evidence

  • go test ./cmd/worker/ — ok (was red on the un-mapped gh entry before the Dockerfiles changed)
  • deploy/microvm/tests/build-rootfs.test.sh — PASS (REQUIRED_TOOLS includes 'gh' was red first)
  • deploy/microvm/tests/build-snapshot.test.sh — PASS (guest probe includes 'gh' was red first)
  • Live: gh 2.103.3 verified end-to-end on the SBX0 rig (snapshot rebuilt with it, gh api user returns the PAT owner through moca-egress credential injection)

Assisted-By: Claude Code

docs/sbx/user-guide.md promises gh works in a sandbox (gh pr create under
the sbx credentials feature), but no image carried the binary: gh is not
in the UBI 9 repositories, so sandboxes shipped without it and every gh
call failed with exit 127 in an otherwise healthy sandbox.

Vendor gh the way rg is vendored: upstream release tarball pinned by
version (2.103.3) and per-arch sha256, sha256sum -c fails the build
closed, fetched in its own stage so the unpack tools stay out of the
runtime image. The upstream binary links glibc only, which ubi-minimal
carries; gh --version at the end of the RUN fails the build if that ever
stops being true (live-verified in a RHEL 9.8 rootfs chroot).

- both remote-worker Dockerfiles gain the stage and the COPY
- probed gains gh, so Hello.capabilities advertises it;
  dockerfile_parity_test.go maps it and pins the gh pinning itself
- build-snapshot.sh's guest probe and build-rootfs.sh's REQUIRED_TOOLS
  gain gh (both are pinned against the Go probed list by their tests,
  which is what made this change test-first)

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori requested a review from cwiklik as a code owner October 29, 2026 13:40
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 29, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vendors gh 2.103.3 into both remote-worker images, the same way rg is vendored (pinned version, per-arch sha256, sha256sum -c fails closed, separate fetch stage). It also adds gh to probed, the microVM guest probe, and REQUIRED_TOOLS, and pins the vendoring with a new parity test.

I verified that both pinned digests match the upstream gh_2.103.3_checksums.txt (amd64 4c80…d91d, arm64 ee32…ce63). v2.103.3 is a non-prerelease release, the current latest. Every hard-coded probed list I could find (build-rootfs.sh REQUIRED_TOOLS, build-snapshot.sh guest probe) is updated, and both are already pinned against the Go list by their tests. All 17 checks are green, including hadolint, deploy-scripts and deploy-scripts-bash32.

One nit on the Dockerfile comment: the linux gh binary is statically linked, not glibc-dynamic.

Assisted-By: Claude Code

Comment thread remote-worker/Dockerfile Outdated
# repositories, and adding GitHub's own dnf repo would put a third-party repository into an image
# that executes model-authored commands. Upstream release tarball, pinned by version and checked
# against the sha256 the release publishes (gh_<version>_checksums.txt). The upstream binary is
# dynamically linked against glibc only, which ubi-minimal carries; the `gh --version` at the end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The comment says the upstream binary is "dynamically linked against glibc only". It isn't. I downloaded gh_2.103.3_linux_amd64.tar.gz (sha256 matches the pin) and file reports it as "ELF 64-bit LSB executable, x86-64, … statically linked, Go BuildID=…". gh's linux release builds are CGO-free static Go binaries. This doesn't change behaviour; if anything it's safer, because there's no libc coupling. But the comment gives the wrong reason for the gh --version guard. Suggest: "The upstream binary is a static Go build, so it needs nothing from ubi-minimal; gh --version at the end of the RUN still fails the build closed if a release ever ships a broken or wrong-arch binary." The same wording is in the other Dockerfile.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the pinned tarball: file reports statically linked, Go BuildID. Comment corrected in 840825f — the gh --version guard stays, restated for what it actually covers (a release shipping a binary that does not run on the built arch).

Comment thread remote-worker/Dockerfile.runtime Outdated
# repositories, and adding GitHub's own dnf repo would put a third-party repository into an image
# that executes model-authored commands. Upstream release tarball, pinned by version and checked
# against the sha256 the release publishes (gh_<version>_checksums.txt). The upstream binary is
# dynamically linked against glibc only, which ubi-minimal carries; the `gh --version` at the end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The same "dynamically linked against glibc" wording is here; see the comment on remote-worker/Dockerfile:82. The release binary is statically linked.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same correction in 840825f.

The gh stage's comment claimed the upstream binary is dynamically linked
against glibc only; it is a static, CGO-free Go build (file: "statically
linked, Go BuildID"), so it needs nothing from ubi-minimal's libc. The
gh --version guard stays, restated for the reason it actually covers: a
release shipping a binary that does not run on the built arch.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori merged commit b432da3 into rossoctl:main Oct 29, 2026
16 of 17 checks passed
@pdettori
pdettori deleted the feat/sandbox-gh branch October 29, 2026 17:26
webchang added a commit to webchang/moca that referenced this pull request Nov 2, 2026
Takes upstream's 11 commits after 071b213: gh vendored into the sandbox images (rossoctl#661), the sandbox image pulled on every run in both VM paths (rossoctl#665) and in compose (rossoctl#664), a cached login matched by endpoint (rossoctl#667), a kind-ci fix (rossoctl#663). No conflicts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants