Skip to content

emrg: bash tool sandbox — file-level isolation for task sessions - #886

Merged
argszero merged 2 commits into
masterfrom
feature/bash-sandbox
Aug 20, 2026
Merged

argszero merged 2 commits into
masterfrom
feature/bash-sandbox

Conversation

@argszero

@argszero argszero commented Aug 20, 2026 •

Copy link
Copy Markdown
Owner

Implement file-level isolation for the bash tool, per host design-finalized rant 2026-08-20T15:46:50 (learned from DeepSeek Harness's sandbox modes).

Design (EMRG-minimal, per host spec)

Three per-task sandbox tiers, default = danger-full-access (current behavior, zero breakage):

  • danger-full-access — no checks (unchanged)
  • read-only — blocks destructive writes: rm -r/-rf/-R, rmdir, mv, cp -r, and shell redirects (> / >> / 2> / &>) to any non-/dev/null target
  • workspace-write — blocks writes to protected daemon files (~/.emrg/config.toml, emrgd.token, tasks.yml, projects.yml, rants.jsonl), to ~/.emrg itself, and to absolute paths outside the workspace root (OS temp dir allowed — mirrors dsh's workspace + backend-promised temp area)

Enforcement is honestly reported: checked modes report partial (static heuristic scan — no bwrap/Seatbelt/ACL, per host's explicit no-heavy-dependency decision); danger-full-access reports full. Blocked commands return a ⛔ [sandbox:...] ... not executed ToolResult; successful sandboxed runs tag output with [sandbox:<mode> enforcement=partial] ok.

Wiring

  • TaskRequest.sandbox field (protocol) → daemon tool loop injects it into bash tool args (the agent cannot choose its own sandbox — config decides)
  • Scheduler resolves tier per task: explicit sandbox: field in tasks.yml wins; builtin defaults — emrg-task → workspace-write, *-opensource-task → read-only, custom tasks → full access; upgrade sessions run workspace-write
  • task_create / task_update accept and validate the sandbox field; hot-reload diff signature includes it
  • +23 tests (pytest 958 → 981, Agent.md count synced); full suite green (980 passed + 1 skipped), import + CLI OK

Acceptance (from the rant)

  1. ✅ Task-configurable sandbox (3 tiers, default full-access = compatible)
  2. ✅ read-only: obvious destructive writes blocked with explanation
  3. ✅ workspace-write: in-workspace writes fine, protected/outside-workspace blocked
  4. ✅ enforcement honestly reported (full/partial)
  5. ✅ evolution/opensource/upgrade tasks get the suggested default tiers
  6. ✅ unconfigured tasks = danger-full-access = current behavior
  7. ✅ full test suite passes (pytest + import + CLI)

…t 2026-08-20T15:46:50)

Per-task sandbox tier (read-only / workspace-write / danger-full-access,
default = danger-full-access = current behavior) injected into the bash
tool's static command scan:

- read-only: blocks destructive writes (rm -r / rmdir / mv / cp -r and
  shell redirects to non-/dev/null targets)
- workspace-write: blocks writes to protected daemon files
  (config.toml / emrgd.token / tasks.yml / projects.yml / rants.jsonl),
  to ~/.emrg itself, and to absolute paths outside the workspace (OS temp
  dir allowed, mirroring dsh's workspace + temp area)
- enforcement honestly reports partial (static heuristic, no OS-level
  boundary — no bwrap/Seatbelt/ACL)

Wiring: TaskRequest.sandbox (protocol) → daemon tool loop injects it into
bash args → scheduler resolves tier per task (explicit tasks.yml sandbox
field wins; emrg-task → workspace-write, *-opensource-task → read-only,
custom tasks → full access). Upgrade sessions run workspace-write.
task_create/task_update accept and validate sandbox; hot-reload diffing
includes it. +23 tests (pytest 958 → 981, Agent.md synced).
@argszero argszero changed the title emrg: add DeepSeek Harness to vs-the-competition comparison table emrg: bash tool sandbox — file-level isolation for task sessions Aug 20, 2026
… fix)

ntpath.isabs('/etc/hosts') returns False (rooted-relative, no drive), so
the workspace-write check treated out-of-workspace absolute targets as
in-workspace relative ones on Windows. _is_absolute_path now also
classifies '/...' and '\...' as absolute (review #886 test-windows ❌).

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle (full suite 980 passed + 1 skipped locally; test + test-windows CI green after the Windows drive-less-root fix)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 2 (independent re-review: sandbox tiers, static check, honest partial/full enforcement, task wiring all match the design; CI test + test-windows green)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 3 (head unchanged since cycle 2, CLEAN/MERGEABLE, CI green) — merging

@argszero
argszero merged commit 49a02f1 into master Aug 20, 2026
2 checks passed
argszero added a commit that referenced this pull request Aug 20, 2026
Co-authored-by: EMRG Evolution <emrg@argszero.dev>
@argszero
argszero deleted the feature/bash-sandbox branch August 23, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant