Skip to content

feat(tools): exec runs one program with an exact argv and no shell (T7) - #41

Merged
lg2m merged 1 commit into
feat/tool-layer-t6-classifierfrom
feat/tool-layer-t7-exec
Sep 14, 2026
Merged

lg2m merged 1 commit into
feat/tool-layer-t6-classifierfrom
feat/tool-layer-t7-exec

Conversation

@lg2m

@lg2m lg2m commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

T7: exec — one program, an exact argv, no shell

Spec: docs/plans/tool-layer.md § D5 (T7) Linear: ENG-777 Stacked on: #40 (T6) — merge that first; this PR's diff is the last commit.

What changed

  • New built-in exec {program, args, cwd, stdin, timeout_seconds, env}: spawns the program directly with the argument list. No quoting, globbing, $, or pipes — a filename with a space needs no escaping and $HOME is four literal characters. Bounds: program ≤ 256 B, args ≤ 64 × 4 KiB, stdin ≤ 64 KiB.
  • Shares everything after spawn with shell via a Launch enum: cleared environment + env allowlist, capture/spill, timeout and process-group kill, exec exit=<code> elapsed= bytes= header, built-in hint. stdin is written by its own task and closed, so a program that never reads it can't stall capture.
  • Policy sees one shape for both tools. An exec call is rendered as the equivalent command line with metacharacter arguments single-quoted (echo 'rm -rf /' '$HOME'), so the classifier, prefix grants (cargo test covers exec cargo [test, -p, x]), the strict nudge, and the approval preview all work unchanged — and rm -rf / as an argument is a literal word, while exec sudo ls is still Forbidden.
  • Prompt: "Prefer exec for a single program with arguments … reserve shell for pipelines and redirection." TUI renders Run program args…; exec is in the config vocabulary.

Scope note

The plan listed the env allowlist and the prefer-built-in nudge under T7. Both shipped in T6's shell-v2 commit because they share ShellPolicy plumbing with the cleared environment; T7 is exec alone. Recorded in the ledger.

How verified

  • cargo test --workspace: 1391 passed / 0 failed; fmt and clippy -D warnings clean.
  • exec_runs_an_exact_argv_without_shell_interpretation: literal $HOME/*/|/space arguments, stdin piped and closed, exit codes with header, missing program, typed failures (invalid_program, invalid_env, path).
  • exec_calls_classify_as_the_equivalent_command_line: prefix grant covers, auto allows, quoting of metacharacter args, sudo via exec Forbidden.
  • Built-in count 6 → 7 in two runtime tests; schema hash updated.

Compatibility

  • Additive: a new advertised tool (schema bytes grow; tool_dispatch unaffected — it never spawns). Tool declaration hash changed (asserted).
  • No protocol/store change beyond T6's.

Docs

  • docs/design/tools.md § Built-In Tools, § Shell Execution (exec); ledger T7 row + receipt.

@lg2m
lg2m force-pushed the feat/tool-layer-t7-exec branch from 1c82535 to e9a91aa Compare September 14, 2026 21:00
@lg2m lg2m mentioned this pull request Sep 14, 2026
@lg2m
lg2m added this pull request to stack #43 September 14, 2026 21:48
`exec {program, args, cwd, stdin, timeout_seconds, env}` shares
run_shell's environment, capture, spill, timeout, and header rules with
`shell` through a Launch enum, but spawns the program directly: no
quoting, globbing, $, or pipes. For policy the call is rendered as the
equivalent command line with metacharacter arguments single-quoted, so
the classifier, prefix grants (`cargo test` covers exec cargo [test …]),
the built-in-preference nudge, and the approval preview see one shape for
both tools — and `rm -rf /` as an exec argument is a literal word.
stdin is written by its own task so a program that never reads it cannot
stall capture. The prompt steers the model to exec for single programs
and shell for pipelines. Seven advertised built-ins; TUI renders
`Run program args…`.
@lg2m
lg2m force-pushed the feat/tool-layer-t7-exec branch from e9a91aa to dc92e5e Compare September 14, 2026 21:51
@lg2m
lg2m merged commit c3b5088 into main Sep 14, 2026
4 checks passed
@lg2m
lg2m deleted the feat/tool-layer-t7-exec branch September 14, 2026 21:59
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