Repository navigation
sandbox2: hardlink CS mirror contents into rootfs (#228 follow-up) - #234
Conversation
PR #228's MINIMAL_INTERNAL_CS_BUILD bundle had the right intent but the cache-delivery half didn't survive integration. The container.symlink("/state/cs-mirror/<cache>", "/<cache>") calls assumed /state was shared across all sandboxes — but /state inside each per-build sandbox defaults to base_dir.join("state"), a per-build location not shared with the orchestrator's outer state dir. The symlinks all dangled, and `[ -d /cargo-vendor ]` checks in package build.shs took their online-fallback branch (which fails in CS because there's no egress). Fix: when the flag is set, hardlink contents from the convention path /root/.cache/minimal/cs-mirror into the sandbox rootfs root. This is the same mechanism the (since-removed) public extra_rootfs field used; here it's triggered behind the existing CS flag with a hardcoded internal-convention path, so no new public API surface. - Still one env var: MINIMAL_INTERNAL_CS_BUILD - Still boolean semantics (== "1") - /root/.cache/minimal/cs-mirror is project-internal convention (same category as /state and /run — convention, not configuration) The /proc bind-mount + MountFallback runctl from #228 stay — that part of the bundle was correct. Inert when the env var is unset; inert when the convention path doesn't exist (tests, dev environments, non-CS callers). The hardlink_dir_contents call is the same one already exercised immediately above for the synth-dir copy. Validated end-to-end in the minimalmertic deployment over 2026-05-25/26: 260+ packages signed under the new bundle (C, Go, Cargo, npm, pnpm, pypi), and `bash-bootstrap@5.3` reached a self-reproducing fixed point across three build cycles using the mechanism (CS-attested artifact → trust anchor for cycle 2 → same sha out, no Mac/CI prebuilt left in the chain). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthrough
ChangesCS-Only Cache Delivery Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/sandbox2/src/lib.rs (1)
478-486: 💤 Low valueAvoid hardcoded line numbers in comments.
Line 480 references "lib.rs near line ~105" but the CS hardlink logic is at lines 124–128, and will drift further as the file evolves. Consider removing the line number or referencing the construct by name only.
- // by the hardlink_dir_contents call in Sandbox::new — see - // lib.rs near line ~105. Earlier iteration of this PR + // by the hardlink_dir_contents call in Sandbox::new (search + // for "MINIMAL_INTERNAL_CS_BUILD" in this file). Earlier iteration of this PR🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/sandbox2/src/lib.rs` around lines 478 - 486, The comment uses a hardcoded line number ("lib.rs near line ~105"); update it to reference the code by symbol/name instead: remove the numeric line reference and mention Sandbox::new and the hardlink_dir_contents call (and optionally base_dir.join("state")) so readers can find the logic by identifier rather than a drifting line number.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/sandbox2/src/lib.rs`:
- Around line 478-486: The comment uses a hardcoded line number ("lib.rs near
line ~105"); update it to reference the code by symbol/name instead: remove the
numeric line reference and mention Sandbox::new and the hardlink_dir_contents
call (and optionally base_dir.join("state")) so readers can find the logic by
identifier rather than a drifting line number.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0c008d79-9166-466d-9282-1b0b52bbec9c
📒 Files selected for processing (1)
crates/sandbox2/src/lib.rs
sandbox2: hardlink CS mirror contents into rootfs (fix #228 follow-up)
Follow-up to #228 (sandbox2 + op: CS-compatible nested-sandbox plumbing). The
MINIMAL_INTERNAL_CS_BUILD=1bundle landed with the right intent, but the cache-delivery half didn't survive integration: thecontainer.symlink("/state/cs-mirror/<X>", "/<X>")calls pointed at/state/cs-mirror/...assuming/statewas shared across all sandboxes — but/stateinside each per-build sandbox isbase_dir.join("state"), a per-build location, so every symlink dangled. Pkg build.shs that probe[ -d /cargo-vendor ]all took their online-fallback branch, which fails in CS because there's no egress.Fix
Replace the six broken symlinks with a single
hardlink_dir_contentscall from a hardcoded convention path. Same mechanism the (since-removed) publicextra_rootfsfield used; now triggered behind the existing CS flag with no new public API.The convention: minimalmertic's hermetic-builder-rs stages its CS bundle (
cargo-vendor,npm-cache,pnpm-store,bun-cache,pip-wheels,rust-stage0,goproxy) at/root/.cache/minimal/cs-mirror/. The hardlink presents these as/cargo-vendor,/goproxy, etc. at sandbox rootfs root — the same top-level paths the build.sh offline-cache idiom already references.The
/procbind-mount +MountFallbackrunctl from #228 stay — that half of the bundle was correct.Why hardlink + convention path rather than a config field
Per the #228 review thread, the constraint was no new configurables / boolean-flag-only. This PR honors that:
MINIMAL_INTERNAL_CS_BUILD== "1")/root/.cache/minimal/cs-mirroris a project-internal convention (same category as/state,/run) — not operator-configurableIf a future use case needs operator configurability, the right move is a separate proposal for that use case, not a
config.extra_rootfsfield that could be repurposed.Safety
MINIMAL_INTERNAL_CS_BUILD == "1";minimal packageinvocations see no behavior changecs_mirror.exists()check before the call. Tests, dev environments, and any non-CS caller with the flag accidentally set won't break.hardlink_dir_contentsruns just above this call for the synth-dir copy. The same code path that's been working inminimal packagesince forever.Validation
Validated end-to-end in the minimalmertic deployment over 2026-05-25/26:
bash-bootstrap@5.3reproducibility: built three times — once against gominimal's prebuilt, once as a rebuild, once against its own CS output — all produced sha1d99e33f…perl@5.42.0builds from source CS-side after a separate-std=gnu17fix to itsbuild.shBoth formerly-trust-pinned bootstrap_artifacts (bash-bootstrap, perl) graduated out via this mechanism. The bundle is exercised continuously by the production builder.
Diff size
Single file, single commit, applies cleanly to current main.
🤖 Generated with Claude Code
Summary by CodeRabbit