Repository navigation
feat(box): leave out a tool whose program is not installed - #490
Conversation
|
Assessment: Request Changes The design holds up: the choice is made once, the left-out table is removed from the in-memory Assumptions and rules checked that held
|
|
Assessment: Comment
Assumptions and rules checked that held
Thanks for the quick, well-tested fixes. |
|
Assessment: Approve
Assumptions and rules checked that held
The fixes are narrow and every one has a test that would catch a regression. |
…fore leaving a tool out
…hed as holding nothing
f0db36e to
1881e48
Compare
|
Assessment: Approve Since my last review, the branch was rebased onto Assumptions and rules checked that held
|
…ecides, and refuse a link loop at a bare name
|
Assessment: Approve
The PR description, Assumptions and rules checked that held
|
…-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.
Description
A library caller writes one
box.tomlfor 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:
What the operator gets:
${(a program is never expanded), and acommandargument whose${NAME}no run can expand. Both token checks run for a left-out tool too, through the helpersBoundary::translateuses, so a token typo is still reported.gittool's grammar still decides another installedgittool. The startup line that says so is kept: Box reads the grammars from the record before it leaves tools out.execentry of the agent's own, in the agent's boundary.commandpath no longer stops the box. Theleft outline is the only sign. The owner chose this ("leave out always") over an opt-inoptional = truekey.How it is built:
commands::leave_out_absentmakes the choice once, inprepare_contract, right after the record is stored and the sources are verified. It removes the tool from the run's in-memoryRecord, so every later step sees the same set of tools.runwith no reconfigure.maintoo, so keeping the grammar changes nothing for the tools that remain.Interfaces that move:
box.tomlbehavior 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 incrates/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(onab29afd3), Linux: the full suite, build, clippy, and fmt.cargo build,clippy --all-targets, andfmt --checkforstrands-box --all-features: pass, zero owned clippy warnings.Cargo.lockunchanged.cargo test -p strands-box --all-features: all new tests pass. Noskipping:message from the new end-to-end test.--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 unmodifiedmainon this host.mcp_alias_fallbackhitsETXTBSY(text file busy) when it spawns the alias it just copied while another test thread forks.modern_cancellation_releases_active_capacityandruntime_ignores_workspace_and_private_generated_schema_artifactshit 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 ownexecentry 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, anda_left_out_tools_grammar_is_disclosed_for_the_installed_tool_it_decides(end to end): an installedgittool keeps its grammar line when thegittool 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 bothleft outlines, 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:
a_program_that_exists_is_never_left_outfails.NotFoundas nothing:a_tool_whose_program_is_not_installed_is_left_outfails on the file and unsearchable entries.a_left_out_tool_with_an_unexpandable_token_is_refusedfails.leave_out_absentat startup: the end-to-end test fails withpath does not exist.a_left_out_tools_grammar_is_disclosed_for_the_installed_tool_it_decidesfails.a_program_that_exists_is_never_left_outfails. Counting a search-path entry that loops as holding something:a_tool_whose_program_is_not_installed_is_left_outfails.Not run: macOS. CI covers it.
cargo test -p strands-box --all-features)cargo fmtandcargo clippy --all-targets --all-featuresChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.