Skip to content

feat(harness): workspace-cwd bash — run tests/builds in the folder (P1.5) - #103

Merged
mlubbad merged 11 commits into
mainfrom
feat/harness-bash
Jul 22, 2026
Merged

mlubbad merged 11 commits into
mainfrom
feat/harness-bash

Conversation

@mlubbad

@mlubbad mlubbad commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Workspace-cwd bash — Harness P1.5 fast-follow

Completes the harness coding loop: when a chat is attached to a code workspace, bash now runs build/test runners in the attached folder (cwd=workspace_root), not just the read-only SANDBOX_ROOT. Follow-up to #102 (Harness P1), which noted this as a deliberate deferral. Spec/plan: docs/superpowers/specs/2026-07-21-workspace-cwd-bash-design.md.

What changed

Two existing layers, one touched — integrations.run_bash gains keyword-only root/allow/timeout (all defaulting to today's behaviour, so non-workspace bash is byte-for-byte unchanged); the agent's bash dispatch passes the workspace params when a ws context is present. The permission decision layer (rules.gate) is untouched: runners stay out of SAFE_BASH, so they prompt in default/acceptEdits unless rule-allowed, and the catastrophic-bash breaker still hard-denies rm -rf /-class in every mode.

  • Curated runner allowlist (WORKSPACE_BASH_ALLOW): pytest, npm/pnpm/yarn, node, python, go, cargo, make, tsc, ruff, mypy, eslint, jest, vitest, git, tox, poetry, uv. find/npx/env deliberately excluded.
  • Interpreters run the repo's own script files, never inline code: -c/-e/-p/--eval/--print/stdin - are blocked in every form (spaced, attached -cCODE, =-joined --eval=CODE, and value-fronted node --require x.js -e …), and bare REPLs are blocked — via an -m-boundary rule (an eval flag counts only before any -m, so python -m pytest -c cfg — pytest's own -c — is correctly allowed).
  • Arg-jail re-rooted to the workspace and extended to inspect --flag=<path> values (closes git --git-dir=<outside>).
  • Secret env stripping: the subprocess no longer inherits secret-shaped env vars (OCD_API_TOKEN, *_KEY, *_TOKEN, provider keys) so a workspace script can't read them.
  • Single-command-only (no && | ; > < .. $()), 120s timeout (OCD_WORKSPACE_BASH_TIMEOUT_SEC), output cap, secret scrub — all retained.

Safety

Host execution behind the mode gate + jail + breaker (P1's local-first posture) — not a sandbox; the P4 container runner remains the answer for untrusted repos. pytest/npm/make run the project's own scripts (semi-trusted, the user's repo), which is why they prompt by default.

Adversarially verified (a fresh subagent tried to defeat the guard): attached/joined inline-eval, node -p/--print, value-fronted eval, --flag=path arg-jail, symlink/junction jail, DoS/timeout, metacharacter smuggling, missing/rogue root, PATH-hijack, and secret-env exfiltration. Four hardening rounds closed every escape found; the -m-boundary rule is closed-form (no enumerable flag list to fall behind on).

Testing

25 tests in test_bash_jail.py (+ the agent-wiring test) — the pre-existing test_run_bash_still_allows_safe_relative fails only on Windows (no standalone echo binary), green on Linux CI. Non-workspace bash, HITL, and permission suites unchanged. Full-repo ruff clean.

🤖 Generated with Claude Code

mlubbad and others added 11 commits July 22, 2026 01:45
Let a workspace-attached agent run build/test runners in the attached folder
(cwd=workspace_root) via a curated allowlist + inline-eval guard, still behind
the mode gate + catastrophic breaker. Stacked on feat/harness (PR #102).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5 TDD tasks: config+constants, root-parameterized arg-jail, run_bash workspace
mode (cwd=root, runner allowlist, inline-eval guard), agent wiring, adversarial
verify + docs. Stacked on feat/harness (PR #102).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The interpreter-front / bare-REPL / missing-root fixes moved into the Task 3
review pass (060271f); Task 5 becomes final adversarial-confirm + docs incl.
SECURITY.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…TY/spec

Adversarially verified across 4 hardening rounds: attached inline-eval, node
-p/--print, value-fronted eval (-m boundary rule), --flag=path arg-jail, bare
REPL, DoS/timeout, and secret-env stripping. README/SECURITY/spec mark it
shipped; the P1 as-built "bash cwd is NOT the workspace" bullet is updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mlubbad
mlubbad merged commit f794444 into main Jul 22, 2026
6 checks passed
@mlubbad
mlubbad deleted the feat/harness-bash branch July 22, 2026 06:48
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