Sandboxed shell in a cron agent job is always refused (denial=Path) when workspace_dir is inside action_dir; no per-job sandbox root
Summary
A cron agent job whose definition sets sandbox_mode = "sandboxed" cannot run a single shell command when the core's workspace_dir lies inside action_dir. Every call is refused before any executor is picked:
WRN:spawn_plan [sandbox:plan] the module refused the spawn denial=Path
Sandbox execution failed: Sandbox plan refused: the sandbox plan was refused (Path)
The refusal is correct. The gap is that a scheduled agent has no way to get a narrower sandbox root than the process-wide action_dir.
Seen on a production deployment (openhuman pin 83f6602153, tinysecurity v0.20.0): OPENHUMAN_ACTION_DIR=/srv/teeny (a checkout whose cron shell jobs are bin/... relative to it), OPENHUMAN_WORKSPACE=/srv/teeny/brain. The native jail is available (config_get_sandbox_settings → detected_backend: landlock). A builder agent run by a cron job failed shell 7 times in a row with different commands. file_read in the same run worked.
Trace
ShellTool::run_sandboxedbuilds the policy from the run's action dir:crates/openhuman-core/src/tools/impl/system/shell.rs:612(route_for_mode). The action dir comes fromeffective_action_dir_for_context(shell.rs:113), which issecurity.action_dirunless the run carries aWorkspaceDescriptor.sandbox/policy.rs:78setsworkspace_root: action_dir.spawn_plan/facts.rs:124(grant_ceiling) asks for it read-write.- TinySecurity admits grants before choosing an executor:
tinysecurity-sandbox/src/engine.rs:489→grants::admit→PathScope::validate_grant. Intinysecurity-policy/src/path_subtree.rs:104,subtree_restrictedrefuses any root thatoverlaps(root, &self.workspace_dir). Thentinysecurity-sandbox/src/grants.rs:25returnsSandboxDenial2::Path. facts.rs:182already states this behaviour ("a grant that overlapsworkspace_diris still refused"). Granting a jail RW over a tree that contains the core's state, secrets and code should be refused. It is not the bug.
The gap
Every sandboxed shell spawn is rooted at one directory: the process-wide action_dir, or a WorkspaceDescriptor on the run. Interactive paths can set a descriptor (sub-agent worktrees, agent.chat's cwd). A cron agent job cannot: CronJob (tinyflows-bus schedule/types.rs) has no root field, the agent definition has none, and cron/scheduler/agent_run.rs never calls RunContext::with_workspace. Cron shell jobs need action_dir to be the checkout (cron/scheduler/shell_job.rs:79 runs them there), so the operator cannot move action_dir without breaking every shell job.
So a deployment that keeps the core workspace under its action dir can never use sandbox_mode = "sandboxed" from cron. The refusal (Path) also does not say which grant failed or why.
Proposed fix
- Let a cron agent job carry a workspace root, either a
workspace/cwdfield on the agent job or an operator-trusted field on the agent definition. Thread it into the run as aWorkspaceDescriptor(RunContext::with_workspace,agent/tinyagents/host/run_context/behavior.rs:123), the wayagent.chat'scwddoes.security_for_tool_contextandeffective_action_dir_for_contextthen root the file tools and the shell there, and the sandbox grant becomes that directory. It must exist and must not overlapworkspace_dir(same checks asagent.chatcwd). - Optional: when the policy's
workspace_rootoverlapsworkspace_dir, fail with a clear host-side message (for example "the action dir contains the core workspace; sandboxed shell needs a separate root") rather than an opaquePathdenial. A boot-time warning whensandbox_mode = "sandboxed"agents exist andaction_dir ⊇ workspace_dirwould also help.
Regression test idea
Configure workspace_dir = <root>/brain, action_dir = <root>, and a cron agent job with a sandboxed definition rooted at <root>/work/job. Assert the spawn plans with exactly one RW grant, <root>/work/job. Today it is refused with Path.
Cron agent jobs have no way to supply a per-job sandbox root, so when workspace_dir is inside action_dir every sandboxed shell spawn is refused with an opaque Path denial; the request is to thread a workspace/cwd root into cron agent runs as a WorkspaceDescriptor and improve the diagnostics. No candidate reports the same problem.
Labelled priority: p2.