Skip to content

feat(box): leave out a tool whose program is not installed - #490

Merged
opieter-aws merged 5 commits into
mainfrom
feature/leave-out-missing-tool
Nov 18, 2026
Merged

opieter-aws merged 5 commits into
mainfrom
feature/leave-out-missing-tool

Conversation

@opieter-aws

@opieter-aws opieter-aws commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

A library caller writes one box.toml for many hosts. Today one [tool.<name>] whose program is not installed stops the whole box, even when the workload never runs that tool.

Now Box leaves that tool out and starts. It prints one line on stderr for each:

strands-box: [tool.tsx] left out: tsx not found

What the operator gets:

  • Not installed means nothing exists at an absolute path, or nothing with a bare name's spelling exists in any absolute directory on the tool's search path. A search-path entry that is a file or that Box cannot search holds nothing, and so does an absolute path beneath a file. A non-executable file, a directory, or a symbolic link that loops, with that name on the search path, is not "not installed", so the box does not start.
  • A dangling symbolic link counts as not installed. Box follows the link and finds nothing, so it is the same case as an absent file.
  • Every other check still stops the box: a file that is not executable, not a regular file, a relative path, a write grant or writable hard link that reaches it, a program that holds ${ (a program is never expanded), and a command argument whose ${NAME} no run can expand. Both token checks run for a left-out tool too, through the helpers Boundary::translate uses, so a token typo is still reported.
  • A left-out tool brings nothing of its own. No filesystem grants, no reach judgement of its lists, no egress for its leaf, no file bound to its grammar, no bare name, and no tool selection.
  • Its grammar still applies by program name. A grammar decides spawns by program name, so a left-out git tool's grammar still decides another installed git tool. The startup line that says so is kept: Box reads the grammars from the record before it leaves tools out.
  • The tool set is fixed at start. A file that appears later at a left-out tool's path is not selected by that table. It runs only through an exec entry of the agent's own, in the agent's boundary.
  • A typo in a tool's command path no longer stops the box. The left out line is the only sign. The owner chose this ("leave out always") over an opt-in optional = true key.

How it is built:

  • commands::leave_out_absent makes the choice once, in prepare_contract, right after the record is stored and the sources are verified. It removes the tool from the run's in-memory Record, so every later step sees the same set of tools.
  • The stored record is unchanged. A host where the program is installed later gets the tool on its next run with no reconfigure.
  • The policy keeps the tool's grammar in its catalog, so a policy that names its actions still loads. Dropping it would refuse such a policy and stop the box, which is the failure this change removes. Grammars are shared by program name on main too, so keeping the grammar changes nothing for the tools that remain.

Interfaces that move: box.toml behavior for a [tool.<name>] whose program is not installed (approved by the owner), and one new stderr startup line. No new key, CLI flag, record shape, policy action, or protocol change.

Docs: docs/user/config.md (new section, refusal table, startup refusals list, the "file the workload has not built yet" note), docs/design/architecture.md (startup step), and the box contract in crates/box/AGENTS.md.

Out of scope: [mcp.<name>] servers with a missing command, and a program installed during the run.

Related Issues

Closes #486

Type of Change

New feature

Testing

All runs on d280c883 (on ab29afd3), Linux: the full suite, build, clippy, and fmt.

  • cargo build, clippy --all-targets, and fmt --check for strands-box --all-features: pass, zero owned clippy warnings. Cargo.lock unchanged.
  • cargo test -p strands-box --all-features: all new tests pass. No skipping: message from the new end-to-end test.
  • Two existing binaries flake only under parallel load. Each passes with --test-threads=1. Neither touches this change:
    • runtime_mcp_start (two_servers_whose_commands_expand_to_one_command_are_refused_at_start, overlapping_wildcard_commands_are_refused_before_the_workload_starts) times out in 8 s. The same two fail the same way on unmodified main on this host.
    • mcp_alias_fallback hits ETXTBSY (text file busy) when it spawns the alias it just copied while another test thread forks.
    • modern_cancellation_releases_active_capacity and runtime_ignores_workspace_and_private_generated_schema_artifacts hit their deadlines in the full run, and pass alone.

New tests:

  • a_tool_whose_program_is_not_installed_is_left_out: a bare name, an absolute path, and a dangling link, by bare name and by path, are left out. So is a bare name whose search path holds a file entry, an unsearchable entry, and an entry that is itself a link loop, and an absolute path beneath a file. The installed tool still loads.
  • a_program_that_exists_is_never_left_out: a non-executable file, a directory, and a link loop, by absolute path and by bare name, and a relative path stay in, and the load refuses them.
  • a_left_out_tool_with_an_unexpandable_token_is_refused: an unknown ${NAME} in an argument, and ${ in an absolute or bare program, still stop the box. A known argument token passes.
  • a_left_out_tool_brings_no_reach: a left-out tool's lists are not judged, and it has no approved table.
  • a_file_planted_at_a_left_out_tools_path_never_runs_with_its_reach: the security pin. A file copied to the left-out path after start is not selected by the tool's table, and runs only under the agent's own exec entry with the agent's grants.
  • startup_names_each_tool_it_leaves_out: the stderr line, with control characters escaped.
  • startup_discloses_a_left_out_tools_grammar_for_each_tool_it_still_decides, and a_left_out_tools_grammar_is_disclosed_for_the_installed_tool_it_decides (end to end): an installed git tool keeps its grammar line when the git tool that carries the grammar is left out.
  • a_tool_whose_program_is_not_installed_is_left_out_and_the_box_starts (end to end): the box starts, prints both left out lines, and a script the agent writes at the left-out path does not run.

Each guard was proven by introducing the defect, seeing the test fail, and restoring:

  • Not removing the tool from the record: the planted-file, no-reach, and left-out tests fail.
  • Counting a directory as not installed, or a non-executable bare-name match: a_program_that_exists_is_never_left_out fails.
  • Counting only NotFound as nothing: a_tool_whose_program_is_not_installed_is_left_out fails on the file and unsearchable entries.
  • Dropping the argument check, or the program-token check: a_left_out_tool_with_an_unexpandable_token_is_refused fails.
  • Not calling leave_out_absent at startup: the end-to-end test fails with path does not exist.
  • Reading the grammars after the trim: a_left_out_tools_grammar_is_disclosed_for_the_installed_tool_it_decides fails.
  • Counting a link loop at a bare name as nothing: a_program_that_exists_is_never_left_out fails. Counting a search-path entry that loops as holding something: a_tool_whose_program_is_not_installed_is_left_out fails.

Not run: macOS. CI covers it.

  • I ran the relevant suites (cargo test -p strands-box --all-features)
  • If I touched Rust, I ran cargo fmt and cargo clippy --all-targets --all-features

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread crates/box/src/run/commands.rs Resolved
@github-actions

Copy link
Copy Markdown

Assessment: Request Changes

The design holds up: the choice is made once, the left-out table is removed from the in-memory Record, and the planted-file test pins the security case. Two inputs reach the "not installed" branch even though they are not missing programs. Both are described inline and both were checked with probe tests on 004e621.

Assumptions and rules checked that held
  • An absent absolute path or a dangling link is left out. A non-executable file, a directory, or a relative path at an absolute location is still refused.
  • An unexpandable ${NAME} in an argument still stops the box, through argument_refusal, which shares arguments_with with expanded_arguments.
  • The stored record is unchanged: project_matches_record and configure::write run on request.record before leave_out_absent.
  • Every later consumer (ConfiguredCommands::load, bind_tool_grammars, bare_names, HostedBox::open, the per-tool Boundary::translate disclosure, credential stores) reads the trimmed locked.record, so they all see one set of tools.
  • is_absent and Boundary::translate resolve on the same spec.search_path().
  • The grammar catalog still comes from request.grammars, so a policy that names the left-out tool's actions still loads, and nothing binds to those actions.
  • Root AGENTS.md: the owner approved the interface change (A box doesn't start when a [tool.<name>] program isn't installed #486, "leave out always"), and docs/user/config.md and crates/box/AGENTS.md change in the same commit.

@github-actions

Copy link
Copy Markdown

Assessment: Comment

fc056e7 fixes both earlier findings. A program that contains ${ is now refused before the tool can be left out, through one shared environment::program_refusal. A bare name is now left out only when nothing at all is found at that name on the search path. One input that comes from the host still blocks the feature: a PATH entry that is not a searchable directory (inline).

Assumptions and rules checked that held
  • An absolute /x/${USER}/tsx and a bare ${TSX} are refused with "a program is never expanded". Boundary::translate and leave_out_absent share one message, so the refusal is not written in two places.
  • A bare name whose match on PATH is a non-executable file or a directory stays in and hits its real refusal (a_program_that_exists_is_never_left_out, with the new bare-name rows).
  • A non-executable match earlier in PATH plus an executable match later still resolves to the later one, the same as on main.
  • Empty and relative PATH entries are skipped in the same way by is_absent and Resolver::resolve.
  • The crates/box/AGENTS.md bullet and docs/user/config.md now match the code.
  • Lib tests on fc056e7: the three left_out_tests, a_file_planted_at_a_left_out_tools_path_never_runs_with_its_reach, and a_token_in_the_program_is_refused pass. a_left_out_tool_brings_no_reach needs the built trampoline binary, which a --lib-only run does not have here. It fails the same way on 004e621, so this environment, not the change, causes the failure.

Thanks for the quick, well-tested fixes.

@github-actions

Copy link
Copy Markdown

Assessment: Approve

f0db36e fixes the last finding. For a bare name, any failed lookup in a search-path entry now counts as nothing there. For an absolute path, a parent that is a file (NotADirectory) counts as absent. This matches what Resolver::resolve can find, so a PATH that comes from the host no longer stops the box for a tool that is not installed. I have no new findings.

Assumptions and rules checked that held
  • PATH entry that is a file, an entry Box cannot search (000), and an absolute path below a file: each is left out (a_tool_whose_program_is_not_installed_is_left_out, new odd_path and under_a_file rows).
  • A non-executable file or a directory at a bare name still has metadata, so it stays in and hits its real refusal (a_program_that_exists_is_never_left_out).
  • A symlink loop or an over-long name at a bare name now counts as nothing. resolve also finds nothing there, so the two stay consistent.
  • An absolute path whose parent the operator cannot search is still refused. Box cannot prove that nothing is there, so this choice is conservative.
  • ${ in the program and unexpandable arguments still stop the box (a_left_out_tool_with_an_unexpandable_token_is_refused, a_token_in_the_program_is_refused).
  • The crates/box/AGENTS.md bullet and docs/user/config.md match the new rule.
  • On f0db36e, Linux: the left-out tests, the planted-file pin, and a_left_out_tool_brings_no_reach all pass. The last one passes once the containment trampoline is built, which shows the earlier failure came from my environment. clippy --all-targets --all-features reports no warnings and fmt --check passes.

The fixes are narrow and every one has a test that would catch a regression.

@opieter-aws
opieter-aws force-pushed the feature/leave-out-missing-tool branch from f0db36e to 1881e48 Compare November 17, 2026 22:07
@github-actions

Copy link
Copy Markdown

Assessment: Approve

Since my last review, the branch was rebased onto main, which now includes monty = false (#444), and one commit was added: 1881e482 adds monty: true to the left-out test record. git range-diff shows the three earlier commits are unchanged apart from rebase context, so my earlier approval of their logic still holds. I have no new findings.

Assumptions and rules checked that held
  • The rebase did not change the code: range-diff from f0db36e shows commits 2 and 3 as identical (=). Commit 1 differs only in a hunk header (write_grammar_disclosures → write_monty_disclosures).
  • monty = false interaction, case 1: when [tool.python3] is left out because its program is not installed, write_monty_disclosures reads the trimmed record. It reports the file PATH finds for python3, or "not found" when PATH has none. That matches what the hosted Shell then does, and the left out line also prints.
  • monty = false interaction, case 2: when monty = true, a left-out tool under python3 or python prints no "not used for a bare" line. That is correct, because the tool is not in the run.
  • bare_names with the record.monty filter (commands.rs) also reads the trimmed record, so all bare-name sources see one set of tools.
  • On 1881e482, Linux: the left-out tests, the planted-file pin, the token-refusal tests, the monty tests, and all 55 hosted::tests pass once the workspace binaries are built. clippy --all-targets --all-features reports no warnings and fmt --check passes.

Comment thread crates/box/src/command/run.rs Resolved
…ecides, and refuse a link loop at a bare name
@github-actions

Copy link
Copy Markdown

Assessment: Approve

d280c883 makes two changes, and I have no findings on either:

  • Grammar disclosure: the startup disclosure now reads the grammar programs from the record before the trim. So an installed [tool] or stdio [mcp] that a left-out tool's grammar still decides by program name is disclosed.
  • Link loops: a symbolic link that loops at a bare name in a searchable PATH directory now stops the box. A PATH entry that itself loops still counts as holding nothing.

The PR description, docs/user/config.md, docs/design/architecture.md and the crates/box/AGENTS.md bullet now all say the grammar "still applies by program name", replacing "no grammar binding".

Assumptions and rules checked that held
  • Grammar disclosure matches binding. The policy catalog comes from request.grammars, from before the trim, and bind_tool_grammars declares every remaining tool and contained MCP under its bound_name or called_name. Computing grammar_programs before the trim therefore gives exactly the set of tables that get decided. When no other table shares the program, no line prints.
  • No second owner. grammar_programs is the same bound_name set that write_grammar_disclosures built inline before. It is only computed earlier.
  • ELOOP cases:
    • A loop at dir/name with dir a directory stops the box.
    • A PATH entry that loops, or one whose parent component loops, gives ELOOP with metadata(dir) failing, so it counts as nothing.
    • A PATH entry that is a symlink to a directory is followed, so its contents still count.
    • An absolute program that loops is still refused, because ELOOP is neither NotFound nor NotADirectory.
  • libc comes from [target.'cfg(unix)'.dependencies], and layout.rs already matches libc::ELOOP. Cargo.lock is unchanged.
  • Gates on d280c883, Linux:
    • With the workspace binaries built, 13 lib tests pass: left-out, planted-file pin, token refusal, monty, and grammar disclosure. clippy --all-targets --all-features reports no warnings and fmt --check passes.
    • a_left_out_tools_grammar_is_disclosed_for_the_installed_tool_it_decides reported ok but printed skipping: the namespace launcher is not usable on this host, so it did not exercise the code here. CI needs to run it.

@opieter-aws
opieter-aws merged commit 3bde34b into main Nov 18, 2026
34 of 37 checks passed
@opieter-aws
opieter-aws deleted the feature/leave-out-missing-tool branch November 18, 2026 19:07
yesyayen added a commit that referenced this pull request Nov 18, 2026
…-fetch

This brings main into this branch, through the merge of the branch below.

Four files had a conflict.

- crates/box/src/command/run.rs, four hunks. Three are the `cfg` of `prepare` and of its two calls: main (#188) removed `box_native_adapter_tests`, and this branch made `prepare` return `(LockedRun, SecretSources)`. The merge keeps both, so the Linux form gives the checked sources too. The fourth is in `prepare_contract`: main (#490) leaves out each tool whose program is not installed, after the record is stored, and this branch checks the secret sources before the record is stored.
- docs/design/architecture.md, step 2 of the startup order: the merge keeps both texts, in the order of the code, and adds one sentence: the check reads no table of a left-out tool.
- docs/user/config.md, "Configured command integrity": the merge keeps main's sentence and this branch's sentences about the program of a secret source. The sentence that each tool program must exist stays removed, as on main.
- crates/box/README.md, the sentence with the record version: this branch's text, with version 39.

The order in `prepare_contract` is a choice. `settle_tools` leaves out each tool whose program is not installed once, on the run's copy of the record, before `SecretSources::check`, and the check judges that copy. So the check judges each process table that the run starts and no other, as `ApprovedReach::judge_with` does, and a list of a left-out tool refuses no run. A check of the stored record judges a list that Box says it does not check: in the new unit test on Linux, it refused a left-out tool for a write grant with no read grant. The check stays before `BoxRoot::initialize_first_use`. The `left out` lines and a refusal of the choice stay after the record is stored, as on main.

`the_secret_source_check_judges_no_table_of_a_left_out_tool` pins the order in `settle_tools`. On macOS, `a_left_out_tool_with_a_write_grant_over_a_secret_source_program_stops_no_box` pins it through the binary. `crates/box/AGENTS.md` says where the choice is made.

One difference from main follows, for a box with or without a secret source. The tools are now chosen before the run writes `bin/` into a new box directory. So a tool whose program is a file that Box writes there is left out on the first run of that directory, and each later run refuses it, as each run did before. `run_config.rs::a_tool_program_that_box_writes_is_left_out_on_the_first_run_alone` pins it, and `crates/box/AGENTS.md` states it.

`docs/user/config.md`, "What Box protects", now says that `run` checks the tables of the tools that it keeps, and that `policy generate-schema` leaves no tool out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A box doesn't start when a [tool.<name>] program isn't installed

3 participants