Repository navigation
fix(sandbox): a stop gate that times out inside the sandbox is a deny, not a pass (#860) - #861
Merged
Merged
Conversation
…, not a pass (#860) A gate that went through the launcher and was killed at its timeout (or lost while running) now returns exit 126 with a reason and counts toward the 3-denial cap. The unsandboxed path keeps the #110 non-blocking contract. Docs: the gate script in the writable workspace is not protected, serve/acp bind the process cwd, and the new public items are noted for tole-core users.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
Fixes #860: with
[sandbox.consumers] turnendon, a stop gate that times out inside the sandbox now DENIES the turn instead of passing it. Refs #748.Why
A sandboxed gate killed at its 30 s budget made
ProcessHook::run_rawreturnErr, whichturnend_deniallogs as a non-blocking infrastructure failure (the #110 contract). Code the agent wrote (the tests a gate runs) could therefore time the gate out on purpose and approve the final message. "A refusal is never a pass" covered a missing sandbox, a refused layout and a failing launcher, not a timeout. Reproduced by the reviewer of #859.Changes
tole-corehooks.rs:run_rawhands a failed run tosandboxed_failure(e, sandboxed, timeout). When the gate went through the launcher (report.is_some()): a timeout returns exit 126 with "turnend: the stop gate timed out after Ns inside the sandbox and was killed; a timeout is not a pass"; a spawn failure keeps its existing deny reason; any other failure while running (lost child) is a deny "did not finish inside the sandbox ... not a pass". The turn is denied and it counts toward the 3-denial cap like any denial (turnend_denialtreats every non-zero code as a deny). Unsandboxed (turnend = off) theErris passed through unchanged: the feat: opt-in process hooks at the tool boundary (PreToolUse/PostToolUse, default OFF) #110 non-blocking contract, byte for byte.ProcessHook::with_timeout(#[doc(hidden)], consumes and returns the hook), so no test waits 30 s.docs/sandbox-design.md§9.4 (timeout is a deny when sandboxed; the feat: opt-in process hooks at the tool boundary (PreToolUse/PostToolUse, default OFF) #110 note kept for the unsandboxed path; a gate script inside the writable workspace (./gate.sh) can be rewritten by the agent and is outside the profile's protection;tole serveandtole acpbind the process working directory, so a gate there is refused if it is$HOMEor/), threat-model row (same), CHANGELOG (a Fixed entry that also carries the API note:Consumer::TurnEndandhooks::SANDBOX_REFUSEDare new public items intole-core, so an exhaustivematchonConsumerneeds a new arm;run_rawreturns 126 for a refused, unstartable or timed-out sandboxed gate;with_timeoutis a hidden test seam).Callers and impact:
ProcessHook::run_rawis called only byToolRegistry::turnend_denial(tool.rs), which already denies on any non-zero code; the tool hooks userun, untouched.sandboxed_failureis private. No format change.Testing
hooks.rs):a_sandboxed_gate_that_does_not_finish_is_a_deny(exact timeout text, exit 126, lost-child and spawn-failure reasons; unsandboxed returns the sameErr),an_unsandboxed_gate_timeout_stays_a_non_blocking_failure(a real script that sleeps past a 300 ms budget with the consumer off returnsErr, as before).stopgate_sandbox.rs, a target of CI'sSandbox (bubblewrap)job,TOLE_REQUIRE_BWRAP=1):a_sandboxed_gate_that_times_out_is_denied_not_passedruns a gate thatsleep 30s with a 2 s budget:Ok((126, ...))with the exact reason, returned well before the sleep ends, the gate did run; a quick gate in the same setup keeps its own verdict.sandboxed_failuretreating every run as unsandboxed => the unit test and the real-bwrap test fail; treating no run as unsandboxed => the unsandboxed unit tests fail (the old contract is pinned both ways).cargo fmt --all --check;cargo clippy --workspace --all-targets --all-features -- -D warnings;cargo clippy -p tole-core -p tole-cli -p tole-tui --no-default-features --all-targets -- -D warnings;cargo testof tole-core and tole-cli (default) and of tole-core, tole-cli, tole-tui with--no-default-features, withTOLE_REQUIRE_BWRAP=1: green, no SKIPPED. The attribution grep overorigin/develop..HEADis empty.scripts/review-local.shcannot run here (cora is not installed: exit 1, not a pass), so I self-reviewedgit diff origin/develop...HEADas an adversarial reviewer: the sandboxed branch is chosen byreport.is_some(), which isSomeonly for a wrapped command, sooffcannot reach it; everyErrofrun_with_timeout_stdinis now covered for a wrapped gate (noErrescapes a sandboxed run); the 126 code cannot be confused with a pass; the reason text carries only the timeout and an error string, no gate output or paths; no change to the verify path. A fresh independent reviewer will review this PR before merge.