Repository navigation
feat(sandbox): named egress rules for the broker - #212
Merged
Merged
Conversation
parseBrokerRules turns an admin-editable object of name → upstream URL into broker routes (/name on the guest stub), validating names, the reserved llm prefix, and http(s) upstreams — a malformed file fails the sandbox start with the parse message instead of silently granting less than intended. The desktop reads userData/sandbox-egress.json at each sandbox start and appends the rules to the gateway route; still an allowlist of named upstreams, never a general proxy. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 13, 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.
Phase 4c, first deliverable — the original Phase 4 headline item, now layered on the working broker.
What
parseBrokerRules(in@codev/sandbox): validates an object ofname → upstream URLinto broker routes — lowercase/digit/dash names,llmreserved for the gateway route, http(s) upstreams only. Throws on anything malformed so a bad config fails the sandbox start with the parse message — fail-closed and loud, never a silently smaller allowlist.resolveSandboxEgressreads the optionalsandbox-egress.jsonfrom the app's userData dir at every sandbox start and appends the rules to the gateway route. Example:{ "npm": "https://registry.npmjs.org", "pypi": "http://mirror.corp/simple" }Inside every sandbox each rule is reachable at
http://127.0.0.1:8788/<name>/...on all three backends (same guest stub the LLM route uses). Upstream calls go through the same Electron net fetch — host proxy/PAC/trust roots apply. There is deliberately no general-proxy escape hatch.Hand-editable file, no UI — matches how an admin would roll this out fleet-wide; a settings surface can come later.
Remaining 4c items and why they're not in this PR
setprivline — VZ's virtio-fs performs guest-side permission checks against host file uids, so a guest server at uid 1000 cannot write a workspace owned by host uid 501 (root currently masks this). Plan: carry the host uid intoboot.json, remap thecodevuser at init, then drop privileges — an image respin, to be bundled with the next image build. WSL has the same shape via drvfs automount options inwsl.conf(also image-coupled)..wslconfiglimits are VM-global); worth doing together with the add-dialog fields.Tests
New
parseBrokerRulessuite (valid, empty, array, bad name, reservedllm, non-http, non-string); package 89 pass / 2 skip; desktop typecheck green. CHANGELOG entry added. Fork-only files.🤖 Generated with Claude Code