feat(py): the construction-time sandbox gate and the worker's address-space limit - #352
Draft
jat255 wants to merge 1 commit into
Draft
feat(py): the construction-time sandbox gate and the worker's address-space limit#352jat255 wants to merge 1 commit into
jat255 wants to merge 1 commit into
Conversation
This was referenced Sep 10, 2026
jat255
marked this pull request as draft
September 11, 2026 04:08
…-space limit protection_mode() decides, before an agent is built, whether this host can sandbox the code execution worker: Linux needs seccomp plus either Landlock or unprivileged user namespaces, macOS needs seatbelt, and anything else is refused. A refusal names the reason and what to check. COMMONS_ALLOW_UNSAFE_ FALLBACK downgrades it to guardrails; there is no keyword for it, because accepting weaker protection should take a deliberate act outside the code. sandbox_capabilities() is the shape the four ctypes probes fill in. Until they exist it reports every mechanism unavailable, which refuses every host. Nothing calls the gate yet: run_python registration wires it in. _runtime/ holds what mutates the worker process, starting with the 8 GiB address-space cap. A smaller inherited limit wins, and a kernel that will not set RLIMIT_AS at all is reported rather than treated as fatal, since the cap guards against a runaway allocation and is not the security boundary.
jat255
force-pushed
the
jat255/t7d4-sandbox-gate-rlimits
branch
from
September 11, 2026 19:47
4078c63 to
445d22e
Compare
jat255
added this pull request to stack #364
September 11, 2026 19:48
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.
This PR adds
protection_mode(), which decides before an agent is built whether this host can sandbox the code execution worker, and the 8 GiB address-space cap the worker puts on itself at startup. Nothing calls the gate yet;run_pythonregistration wires it in.Agent-written detail
sandbox_capabilities()is the shape the four ctypes probes fill in. Until they exist it reports every mechanism unavailable, so the gate refuses every host. That is why it is not wired intoCommons.__init__here: doing so now would abort construction everywhere, for a tool that is not registered yet.Two departures from
run_r_protection_mode(). The opt-in isCOMMONS_ALLOW_UNSAFE_FALLBACKrather than an option, and there is deliberately no keyword for it, so accepting weaker protection takes an act outside the code. Only the address-space limit is set, not a CPU limit:RLIMIT_CPUis cumulative over the worker's whole life, so a long session would be killed mid-call rather than hit the parent's per-call timeout. Noted on katat7d4.A kernel that will not set
RLIMIT_ASis reported rather than treated as fatal. Recent macOS is such a kernel, so the three clamp tests skip locally and run on the Ubuntu leg of CI.roborev flagged the protection-mode decision table as a cross-language contract held twice, once per suite. Fixing it here would pull
pkg-r/into a Python-only task, so katadkev, which already owns the shared sandbox fixture, has been widened to cover the table.