Repository navigation
fix: enforce tool grammar checks when a local server starts - #386
Conversation
## Problem A missing or unreadable MCP server program leaves no startup grammar binding. A later executable can then receive general process-start permission instead of the installed grammar check, with the server's filesystem grants. ## Solution Require the existing program-file and called-name binding at each matching server-start request, including when the policy engine has no bound files. Refuse only that start if its binding is unavailable. Keep on-demand startup and allow a retry through an already-bound program. A new program identity requires a new Box run. The operator explicitly approved this shared Linux/macOS request-time refusal on November 10, 2026. The refusal is the changed observable behavior; no configuration keys, policy actions, public exports, or protocol shapes change. Update the operator and design guides and include the explanatory figure. ## Tests The three a_server_requires_its_grammar regressions and eight missing_server_checks tests all pass. Before the repair, six assertions fail; five compatibility controls pass on both revisions. a_late_server_is_refused_until_its_path_reaches_an_approved_program passes natively on Linux Arm64 and fails on unchanged d9346bf at the refusal assertion. It proves no execution on refusal, continued Box operation, an unrelated server start, and a same-Box retry through an already-bound file. The trusted test host supplies that retry link and client. scripts/test-all.sh reports 5,264 passes and 18 ignored entries. Two initially skipped script-boundary tests pass separately after helper placement. The existing alias-read assertion and live credentials-daemon fixture remain gaps. No scripted examples exist and no live SDK tutorial ran. The deterministic suite passes all 131 Linux cases and records ten declared macOS-only skips, with no quarantine or integrity problems. Both affected packages build with all features and without default features. Formatting, workspace Clippy with the justfile allowlist, and all 27 site-manifest tests pass. Native macOS validation has not run locally.
|
Assessment: Comment The fix is correct for every case I traced: a server start whose called name matches a grammar now has to go through a binding recorded at startup. The remaining gaps are prose that the change makes wrong, one case that Box doesn't report at startup, and tests that compare substrings instead of whole values. Review Categories
Assumptions and rules checked that held
The regression tests are thorough, especially the native refusal-and-retry test. |
## Problem The refusal tests checked message fragments, so they did not pin the reported called name and program path. The binding decision still described three pre-policy refusal cases and agent-copy fallback without the new server rule. The recovery guide also did not explain files that were unreadable at startup. ## Solution Compare complete UnboundServer values in all three policy regressions, including the canonical path in the policy-engine case. Explain the fourth pre-policy refusal, limit ordinary copy fallback to unbound agent commands, and require new or previously unreadable executables to be readable and executable before a new Box run. Preserve the same-name retry and replacement checks. The runtime implementation remains unchanged from 0cc3633. ## Tests The strengthened policy regressions pass with all features (3 tests) and the default features (2 tests). Formatting, both policy Clippy configurations, and all 27 site-manifest tests pass. The full default policy suite at 0cc3633 passed 427 tests with 6 ignored; unchanged production code is covered by that suite and the previous all-feature and native runs. Strict default-feature policy documentation passed including dependencies. Strict all-feature policy-only documentation passed. The extra all-feature dependency documentation build failed on unchanged strands-shell links; its three affected files match the PR base byte for byte. The first hosted run passed all 12 new regressions on Linux and macOS. Its macOS workspace failed the unchanged five-second diagnostics replay timeout; the new branch run must complete before a final CI success claim.
|
Assessment: Approve I re-reviewed at Re-checked at this head
The rules and cases from the previous summary still hold, because the runtime code is unchanged. |
Problem: Main now supports absolute MCP executable commands and conflicts with the server-start guidance. The grammar-binding repair also needs native coverage for absolute commands. Solution: Merge main at ec5ef77, preserve both documentation changes, and exercise the same refusal and approved-file retry scenario for bare and absolute configured commands. The repair guard is unchanged. Tests: Full local workspace: 5,274 primary passes, zero failures, 18 ignored. All 22 native server-start tests and 27 site checks pass. The absolute test fails at the intended refusal assertion on ec5ef77 with only the test changes. Formatting and workspace Clippy pass. Two existing runtime exclusions and example coverage limits remain documented.
|
Assessment: Approve I re-reviewed at Cases and rules checked that held
|
|
Assessment: Approve I re-reviewed at Checks that held
|
|
Assessment: Approve I re-reviewed at Cases and rules checked that held
|
Human readable section
Problem. Strands Box uses tool grammars to translate command arguments into policy actions. If a local Model Context Protocol (MCP) server's executable was missing or unreadable at Box startup, Box did not record that file for its grammar. An executable created later could then receive general permission to start, without the required grammar check. It could run with the server's filesystem grants.
Solution. Before the workload starts, Box records available executable files and their command names for each grammar. These records are grammar bindings.
When the agent requests a server, Box checks whether an installed grammar covers the executable's filename. If so, the file and name must match a startup record. If no record matches, Box refuses that server start. Box remains usable. General permission to start a process cannot substitute for this record.
Trade-off. Servers still start on demand, and an unused missing executable does not prevent Box startup. A later request can succeed if its path reaches an executable that Box already recorded under the same command name. Existing replacement checks still apply. If the executable is new to this run, restart Box before this server can use it.
Figure 1: Local server starts keep their grammar check. Box first checks whether a recorded path now points to a different file under the same command name. It refuses that start even if another startup record identifies the replacement file. The diagram assumes these replacement checks pass.
Editable diagram.
Description
The repair checks this requirement in
GrammarBindings::coverage_for. It also checks before the policy engine returns early because it has no grammar bindings. Existing replacement checks retain their order. The repair adds no configuration key, policy action, public export, or protocol shape.This is a deliberate change to server startup on Linux and macOS. The operator approved this behavior change during implementation planning. The user and design guides describe the refusal and limits on retries. Thirteen regression tests cover unavailable bindings, general and grammar permissions, ordinary process starts, replaced files, and a later successful retry.
Codex helped prepare the code, tests, diagram, and description.
Related Issues
Issue #38 tracks tool packs and their grammar support. Tool packs configure tools and can include grammars. Issue #385 discusses how Box selects executable files for tool commands.
Type of Change
Bug fix
Testing
The current head is
527bbca41554621126009945b832948ed3c82a80. Hosted continuous integration (CI) tests merge commit194c294573b779d7f665fa6358078acbf27fbfd8. The two commits have identical file trees. Local checks use Amazon Linux 2023 Arm64 as a non-root user.The totals count primary test results. They exclude duplicate summaries from child processes.
d9346bf. The absolute-command regression fails on unchangedec5ef77. Each control adds only the native test changes and fails at the missing-refusal assertion. Six policy/composition assertions fail before the repair, while five compatibility controls pass.--no-deps. These earlier runs used the same policy code.The native regressions test bare program names and absolute executable paths. They verify that the refused executable never runs, Box remains usable, and an unrelated server starts. The trusted test host then creates a link to a program that Box already recorded. That host opens a new client to verify the successful retry. Box does not approve arbitrary new files.
The local workspace failures were:
box_telemetry::an_otlp_target_receives_the_records_with_the_secret_attached: its fixture reported an empty HTTP header. The complete target then passed 25 tests with one ignored at its usual parallelism. The same case passed in both hosted suites. The local failure's cause remains unresolved.mcp_alias_fallback::an_incompatible_frame_after_readiness_fails_without_fallback: the fixture could not start its executable (Text file busy, operating-system error 26). A repeat of the target, with its usual parallelism, failed at the same fixture step in a different test. The same error occurred in three tests on unchanged upstream8a5f9ba. Six tests passed. All nine alias tests passed in both hosted suites. The error also occurs without this repair, but its exact cause remains unresolved.These repeats and upstream controls do not make the local full-suite result a pass. An earlier local attempt exhausted disk space while the linker combined the build outputs. It executed no tests. The counts above come from the completed retry.
The Linux assertion for alias reads and the test that needs a live credentials daemon were unavailable. An optional assertion about process groups lacked its instrumentation. Eight of the 20 ignored Linux entries are child-only entrypoints that passing parent tests call. Other ignored cases did not run.
Example packages built, but there were no example scripts. No live tutorial for the software development kit (SDK) ran. Hosted CI ran the native macOS checks. The development host did not run those checks locally. The supplemental macOS checks could not run the full suite for signed native enforcement. The required SDK and a current signed receipt were unavailable.
The development host lacks
just, so local workspace lint used Cargo to run the exactjustfilerecipe. The recipe allows these lints:too_many_arguments,only_used_in_recursion,await_holding_refcell_ref,explicit_auto_deref,chunks_exact_to_as_chunks,dead_code, andnon_snake_case.An additional documentation build checked all features and dependencies with strict settings. It failed on existing links in
strands-shell. All three affected Shell files are byte-identical to the original PR base. This failure is separate from the required documentation check with default features and the additional policy-only check. Both of those checks passed.The current head includes upstream #394. That change fixes the initializer in a test helper that prevented the preceding CI run from compiling. The failed run executed neither platform's workspace suite. The current results above come from the repaired tree.
The pinned draw.io desktop 32.4.1 container exported the figure at scale 2 and border 20. Layout checks reported no errors or warnings. The control render of the committed diagram produced identical bytes. Visual inspection covered the full-size PNG and the image at PR width.
just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe Clippy attestation includes the lint allowances above, which the repository documents.
Checklist
Local agent reviews are complete. The human author still needs to confirm a review of every line of code, so that checkbox remains unchecked.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.