Repository navigation
refactor(sandbox): host URLs, local grants and the trust CA read ON_THIS_MACHINE, so a VM provider on this machine needs no core edits - #178
Merged
Conversation
…HIS_MACHINE, so a VM provider on this machine needs no core edits A provider whose sandboxes run on this machine in VMs, not on this machine's Docker, needed four edits outside its module: host_url_for and the local store's grants_reach were keyed on the provider's type name, start_trusting ran docker cp on this machine, and the local grant server listened only where this machine's containers reach it. Core now reads what the provider declares. HOST_ADDRESS says where a sandbox's requests to this machine arrive: None for containers on this machine's Docker, a loopback address for a VM here whose networking forwards this machine's names to it. on_this_machine_provider resolves a type to its class when that class declares ON_THIS_MACHINE, and None for an unknown type or one whose extra isn't installed. host_url_for and grants_reach use it; grants_reach also refuses a grant URL naming this machine's loopback, which inside any sandbox is the sandbox itself. start_trusting installs the CA through a VmSandbox hook, and the grant server serves the platform default on loopback too. The trust hook and the loopback bind are lifted from #157. Co-authored-by: BinBin He <8340774+BinSquare@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The test fetched its grant without trusting the local transfer CA, which the store fixture does for the others; the test is Linux-only, so it ran first in CI. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…only an address the server serves With one bind address the retry loop ran once but re-raised only on the last of five attempts, so an unavailable explicit grant_bind_host lost its error and startup went on with no sockets. And grants_reach took the default bind to serve whatever loopback address a VM provider declared; the default serves 127.0.0.1, so another address needs the server bound to it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…AT names the declaration; grants_reach names its questions grant_server() now hands GrantServer the tuple of hosts to bind, computed once, instead of a flag it re-derives a list from, and the same-port bind with its retry lives in _bind_same_port, which raises a host's own bind failure at once and retries only a port lost between two binds. HOST_ADDRESS, which read as the host's address, is REACHES_HOST_AT. The local store's grants_reach reads as two cases with a named _serves predicate, and drops a branch for 0.0.0.0, which check_local_host already refuses as an advertised host. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
A sandbox provider whose sandboxes run on this machine, but in VMs rather than on this machine's Docker, currently needs four edits outside its own module to work with the local stores:
host_url_forand the local object store'sgrants_reachare keyed on the provider's type name,start_trustingcopies the local CA into the agent container withdocker cpon this machine, and the local grant server listens only where this machine's containers reach it. #157 (the SmolVM provider) had to make all four. This lets such a provider keep its changes in its module, by having core read what the provider declares.What changes
SandboxProvider.REACHES_HOST_AT, a declaration besideON_THIS_MACHINE: for a provider on this machine, where a request from its sandboxes to this machine's names arrives. None for containers on this machine's Docker (the addresshost.docker.internalmaps to); a loopback address for a VM here whose networking forwards this machine's names to it.on_this_machine_provider(sandbox_type), next toreachable_url: the registered class for a type when its sandboxes run on this machine, else None, including for an unknown type or one whose extra isn't installed here.host_url_forrewrites loopback tohost.docker.internalfor any provider on this machine, not onlylocal; a type it can't resolve leaves the URL as it is, as before.LocalFilesystemObjectStore.grants_reachreads the declaration instead of a type-name constant: grants reach a sandbox on this machine when the server listens where its requests arrive and the grant URL names this machine by a name the sandbox resolves. A loopback literal orlocalhostin the URL reaches nothing, since inside any sandbox that is the sandbox itself; a VM here reaches only its declared loopback address, served by default or when bound there, and no address by number. Containers on this machine's Docker keep today's behaviour.VmSandbox.copy_trust_dir_into_container:start_trustinginstalls the local CA through the sandbox, writing the files into the VM anddocker cp-ing there, where the container is.LocalSandboxkeeps the direct copy, since its shell would rewrite the path.grant_bind_hostis served as given. Five attempts cover losing the port to another process between the two binds.The last two are lifted from #157 with their author's credit; the SmolVM PR can then drop its
host_url_forandgrants_reachcases, itsLOCAL_NAMESand SAN-list additions, and its core hook, and declareREACHES_HOST_AT = "127.0.0.1".Verified
Unit suite 7627 passed / 16 skipped (a gateway time-trigger test, untouched here, failed once under parallel load and passes alone); plugin API check vs
main: no break (REACHES_HOST_ATis an addition);uv lock --checkclean. The declaration-driven paths are pinned with config-registered test providers: a VM-here provider gets the host rewrite and reaches grants at the default and loopback bind hosts but not at a bridge address or by an address in the URL; built-in providers all declare noREACHES_HOST_AT;start_trustingon a VM sandbox never runs Docker on this machine. The loopback-bind test binds a second loopback address and so runs on Linux only. The VM-side behaviour was also exercised live on a SmolVM on an Apple Silicon Mac against this tree's predecessor: the CA files landed in the container through the sandbox and the container fetched a grant as issued.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no blocking issue remains.Summary
The PR lets providers declare how sandboxes on this machine reach local services.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD Provider["Provider declarations"] --> Rewrite["Rewrite host URLs"] Provider --> Reach["Check whether grants reach the sandbox"] Reach --> Server["Grant server on configured addresses"] CA["Local CA files"] --> Sandbox["Sandbox copies trust files"] Sandbox --> Docker["Docker on the sandbox's host"]Reviews (4) · Last reviewed commit: "refactor(store): the grant server takes ..." · Reviewed by Greptile