Repository navigation
docs: add a user guide for tool grammars - #351
Conversation
## Problem Tool grammars are on `main` behind `[experimental-features] tool-grammars`, but no page tells an operator how to write one or how to write rules against it. `docs/user/config.md` said that a guide was "coming later". The reference pages also did not list the fields that a grammar action carries. An operator who adds a grammar can lose a `shell:spawn` forbid, permit `unmodeled` by mistake, or write a temporal rule that a test in another directory satisfies. The `config.md` entry told the operator to "move" the `shell:spawn` rules. That is not sufficient: a copy of the program at another path is still a `shell:spawn`, so a broad `shell:spawn` permit lets the copy past a grammar forbid. ## Solution Add `docs/user/tool-grammars.md`. It is a how-to: turn on the switch, add a git grammar, forbid a force push through its effect, start the box and read the startup line, and allow a push only after `cargo test` exited 0 in the project. It states that a grammar action replaces `shell:spawn`, that `unmodeled` is outside `"*"` and denied by default, that a rule covers one grammar, and that a temporal predicate cannot name the group. It states which files a grammar binds, what a grammar governs (a spawn that reaches the Shell, and not a child of a spawned program), and what it cannot see (environment, configuration files, child processes, another name or a copy). The page describes the behaviour of the multi-name change that is in progress: another name of a bound file is decided as `shell:spawn`. It does not document the startup refusal for a file with several names, because that change removes it. Add a "Tool grammar actions" section to `docs/user/policy/actions.md` with each field and its type. Change the `config.md` entry to link the guide and to say "keep `shell:spawn` permits narrow". Add the page to `docs/user/README.md` and to `docs/site-manifest.json`. ## Tests - Each behaviour claim is traced to a test on `main`: `tool_grammars.rs` (switch, startup line, forbid and permit, `unmodeled`, `sh -c`, push after a test, restart), the schema cases in `grammar/schema.rs` (effect of another grammar, two families, the group in a temporal predicate, `v2` namespace), the shell adapter tests (no `shell:spawn` for a bound program, `input.cwd` pin, durable response), `bindings.rs` (links, copies, replaced file), `box_shell.rs` (`xargs`), and the git corpus (`--dry-run` removes `force_push`, `-C` with a push). - I extracted every `toml` and `cedar` block on the page into one `box.toml` and `policy.dw` and ran `strands-box run` on Linux. Both grammars and every rule loaded, and `run` printed both startup lines. The run then stopped at a mount-table check of this host, after validation. - A local probe showed that a temporal predicate with `input.args: ["test"]` is refused, so the page pins the arguments through the grammar's `usage`. - `cargo test -p strands-box --test site_manifest --all-features` passes. - The `docs-reviewer` skill gave "Ship it" after three rounds. `check-prose.sh` is clean. - Not run: the end-to-end grammar suite, because this host cannot start a box. The behaviour of another name of a bound file comes from the pending multi-name change and not from `main`.
…e change decides them
|
Assessment: Request Changes Head Checked and held
The walk-through itself is clear and well structured. Once the multi-name behaviour question is settled, it should be ready. |
|
Thanks. The blocking point is answered inline: this PR now states that it depends on the multi-name PR and must merge after it. The |
|
Assessment: Comment Re-reviewed at Checked on this head and held
Apart from the dependency, this is ready. |
|
Assessment: Comment I re-reviewed at Checked on this head and held
Once the multi-name PR merges and this is retargeted, I have no further findings. |
|
Assessment: Request Changes I reviewed head Checked and held
The walk-through itself is well organized. Once it describes the code that's actually in this tree, it should be close to ready. |
|
Assessment: Request Changes I re-reviewed at Checked against #352 and held
|
…-guide # Conflicts: # docs/user/config.md
|
The merge-order blocker is now closed. #352 is merged to |
|
Assessment: Approve I re-reviewed at Checked on this head and held
Thanks for handling the merge order and the conflict resolution carefully. |
Description
This is the PR that documents how the tool grammars feature works. AppSec review also asked us to be clear about what a grammar does not cover, like git hooks and other programs that git starts. This adds
docs/user/tool-grammars.md, a walk-through with a git grammar, a force-push forbid, and the push-after-tests rule.Related Issues
#38
Type of Change
Documentation update
Testing
I traced every behaviour claim on the page to a test on main. I put all the page's config and policy examples into one box and ran it on Linux, and both grammars and all the rules loaded. I couldn't run the end-to-end grammar tests on my machine, because it can't start a box. A quick probe showed that a temporal rule can't pin the arguments as a list, so the page pins them through the grammar instead. The site manifest test passes. The docs reviewer gave "Ship it" after three rounds. No diagrams, so there was nothing to compile.
just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.