Skip to content

fix(sandbox): a stop gate that times out inside the sandbox passes the turn #860

Closed

Description

@ajianaz

Version

develop at 822cbfb (after #859, [sandbox.consumers] turnend)

Operating system

Linux (bubblewrap)

What happened?

With [sandbox.consumers] turnend = "required" (or "optional", which counts as required because a stop gate is always unattended), a stop gate that runs longer than its 30 s budget inside the sandbox is killed and ProcessHook::run_raw returns Err("... timed out ..."). ToolRegistry::turnend_denial treats an Err as an infrastructure failure of the gate (the #110 contract: non-blocking), logs it and lets the turn finish. The gate PASSES. A gate that cannot finish therefore approves the final message, and code the agent wrote can make the gate time out on purpose (for example sleep 40 in the test suite the gate runs).

For the unsandboxed path (turnend = "off") that non-blocking contract is old and deliberate (#110). For a sandboxed gate it is not: the owner opted into a sandbox for the gate because the gate runs code the agent wrote, and "a refusal is never a pass" (the rule of #748) was applied to a missing sandbox, a refused layout and a failing launcher, but not to a timeout. Reproduced by the independent reviewer of #859.

What did you expect to happen?

A gate that ran through the launcher and timed out (or was killed) is a deny: exit 126 with the reason "the stop gate timed out after Ns inside the sandbox and was killed; a timeout is not a pass", counted toward the 3-denial cap like any denial. The unsandboxed path stays as it is, byte for byte.

Steps to reproduce

  1. User config: [sandbox.consumers] with turnend = "required", bubblewrap installed.
  2. tole run --on-turnend ./gate.sh "do it" with gate.sh containing sleep 60.
  3. After 30 s the gate is killed; the run finishes instead of being blocked (exit 0, not 6).

Scope

Only the sandboxed path of ProcessHook::run_raw. Also in this fix: docs that a gate script inside the writable workspace can be rewritten by the agent (outside the profile's protection), that tole serve and tole acp bind the process working directory (a gate there is refused if it is $HOME or /), and an API note in the CHANGELOG (Consumer::TurnEnd and SANDBOX_REFUSED are new public items in tole-core; an exhaustive match on Consumer needs a new arm). Refs #748.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions