Repository navigation
feat(chat): run commands through one sandboxed gateway, and approve similar actions once - #80
Merged
Merged
Conversation
…imilar actions once Chat could diagnose problems but not act on them: a request to stop 65 duplicate maestro MCP servers ended with Chat telling the user to run pkill. Chat lost its shell in 60f39c4 because one Allow could run any command the model wrote. This brings commands back without that hole. Chat gets one new tool, run_command, taking literal argv or an explicit script. Every request is prepared, authorized, executed and recorded by the broker, never by the model. An approval is single-use and bound to a hash of exactly what the card showed. Commands are parsed with mvdan.cc/sh and classified on argv as Read, Process, Other, Destructive or Never. Wrappers that run other commands are judged by what they run, and fail closed to a card when that cannot be determined. Commands run in a native sandbox: Seatbelt on macOS and bubblewrap with a sealed seccomp filter on Linux. Writes are limited to the project and a per-conversation scratch directory, there is no network unless granted, credential and Driga state are unreadable, and the environment is stripped. Windows has no sandbox yet, so only reads and process control work there. kill, pkill, killall, taskkill and Stop-Process are a command family, not a new tool. Driga resolves the exact process snapshot itself, shows it on the card, re-checks each identity just before signalling, and never re-runs a pattern match. Force needs a second card. Other users' processes, process groups and Driga's own tree are refused. Full auto now runs reads and sandboxed work but still asks before process control and destructive commands. Chat can never approve another agent's permission prompt by itself. One approval can now cover similar actions. "Allow similar" grants are created only by a click in the app, last at most 30 minutes, show as "allowed by your grant" with a revoke link, and are offered to other agents only for a short list of reads whose behaviour no environment or config can change. Prompts from one session within 3 seconds show as one card with "Allow all N", each item still deniable. Command output is kept with the conversation under the existing capture policy (migration 0007). driga doctor gains a chat_sandbox check, and CI runs the real sandboxes on macOS and Linux and native process tests on Windows. Claude-Session: https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4
…utside the project Protect Git hooks, configuration, attributes, direnv scripts and editor execution settings in project, scratch and resolved worktree metadata roots. Reserve absent paths in both sandbox backends while preserving writes to ordinary Git state. Refuse replaceable protected symlinks and Git pointers that would grant unrelated host write access. Require read operands and the working directory to resolve inside the selected project or scratch. Keep outside and unresolved reads behind individual cards in every mode, including Full auto, and exclude them from similarity grants. Disclose worktree write roots on cards and bind grants to those roots. Add regression tests with red evidence, generated profile and mount checks, and real sandbox tests for persistence denials and successful commits. Document the protected paths and read approval rule. Validate with native and UTC package tests, required Seatbelt integration tests, and native, Linux and Windows vet checks. Claude-Session: https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4
…s correct on Windows Require an explicit user namespace before disabling nested namespaces, as bubblewrap 0.9 validates this before expanding --unshare-all. Capture bounded, scrubbed backend stderr in probe reasons and print the result before CI tests. Cover the namespace requirement and policy descriptor numbering with tests. Use confined native Windows type reads and current-user SIDs in command fixtures. Preserve outside-read approval, grant lifetimes and exact sandbox refusals, and correct platform-specific path and socket permission fixtures. Check Windows read handles for hard links without changing Unix boundaries. Validated formatting, native/Linux/Windows vet, command and chat tests in the native time zone and UTC, Windows test compilation, and targeted CLI tests. Native Linux and Windows execution remains for CI. Claude-Session: https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4
4 tasks done
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 changed
Chat can run commands again, through one Driga-owned tool,
run_command, instead of Claude's Bash. Every command is parsed and classified on its argv, run in a native OS sandbox (project and scratch writable, git hooks and other later-executed paths read-only, no network), and approved on a card bound to exactly what will run. Stopping processes (kill,pkill,killall,taskkill,Stop-Process) resolves an exact process snapshot and signals only those identities. One approval can also cover similar actions: revocable 30-minute "Allow similar" grants, and burst cards with "Allow all N". Design:docs/specs/2026-10-29-chat-commands-design.md.Why
A user asked Chat to stop 65 duplicate
maestro.cli.AppKt mcpservers. Chat diagnosed it and then told the user to runpkillthemselves, because60f39c4removed its shell: one Allow could run any command the model wrote. Separately, one cleanup took 9 approval prompts. The owner rejected both outcomes and also rejected a purpose-built tool per incident. A single gateway with a sandbox, an argv policy and an exact-target preview generalizes without reopening the hole. Native Seatbelt and bubblewrap were chosen over Anthropic'ssandbox-runtimebecause Driga ships as one Go binary without Node.Risk and rollout
0007_chat_command_output.sql, additive (a table of command output chunks linked to Chat action messages, pruned with them). A downgrade ignores the table.~/.claude,~/.codexor other agent settings.capture_textpolicy and retention; summaries keep head and tail.killaction's force escalation now points torun_command.bubblewrap;driga doctorreports a missing sandbox.Contract changes
driga mcp --chatonly): newrun_commandtool (argvorscript,cwd,timeout_secondsdefault 120 max 600,network). It is not exposed on the publicdriga mcpserver./grant-revoke,/grant-history) and burst (/prompt-bursts,/burst-decide) routes, plus asimilarfield on decide and prompt-answer, all app-authenticated.driga doctor: newchat_sandboxcheck.Verified
go test ./...,TZ=UTC go test ./...andgo test -raceon chat, command, kill and web. All pass exceptTestPermissionHookBuiltBinary, which fails identically onmainon this Mac (module-cache cleanup permission) and passes in CI.DRIGATEST_REQUIRE_SANDBOX=1: they deny writes outside the project, network, Unix sockets, protected reads and host signals, and clean up children on timeout.TestChatCommandsBuiltBinary: a fake Claude callspkill -fand the card lists exactly 65 spawned processes. Allow stops only those, and a 66th started after the snapshot survives. Subtests cover all outcome categories with a second force card, Deny, Stop, automatic reads, Full auto cards, replay, grants and revocation, delegated-allow containment and burst membership.GOOS=linux go build ./...,go vetfor native, Linux and Windows, andgofmtclean. Linux bubblewrap and native Windows process tests run in the new CI jobs.bun run design-check(1,212 browser tests)..envrcand editor hook folders inside the project, and reads outside the project skipping the card.https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4