feat(caps): CLI capability flags — allow-net/read/write/run (ILO-59)#606
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4 tasks
Add Deno-style `--allow-net`, `--allow-read`, `--allow-write`, `--allow-run` CLI flags to gate IO builtins at the process level (ILO-59). ## What ships - `src/caps.rs` — `Caps` / `Policy` structs, `parse_allow`, `check_net/read/write/run` helpers, and 26 unit tests. Denial messages now carry the `ILO-CAP-001` structured error code so agents can route on it. - `src/cli/args.rs` — four `Option<String>` fields on `RunArgs` wired to clap flags (`--allow-net`, `--allow-read`, `--allow-write`, `--allow-run`). - `src/main.rs` — `build_caps()` converts `RunArgs` flags into `Arc<Caps>`; `Caps::Permissive` is the default so no existing invocation changes behaviour. - `src/interpreter/mod.rs` + `src/vm/mod.rs` — `caps.check_*` calls at every IO builtin site. - `tests/capability_flags.rs` — 15 integration tests covering all four dimensions across both backends, plus `Caps::parse_allow` round-trips. - `examples/capability-sandbox.ilo` — runnable demo. - `SANDBOX.md` — operator guide: flag syntax, matching rules, capability matrix, recipes, backwards-compatibility note. - `ai.txt` + `SPEC.md` — capability matrix and flag reference added. ## Backwards compatibility `Caps::Permissive` is `#[default]`. Without any `--allow-*` flag the runtime is fully permissive — identical to pre-0.13 behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a74c681 to
79043b3
Compare
This was referenced May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--allow-net,--allow-read,--allow-write,--allow-runCLI flags that gate IO builtins at the process level--allow-*flag is present;Caps::Permissiveremains the default (zero flags = backwards-compatible, no restrictions)RErr value with codeILO-CAP-001so programs can pattern-match itWhat ships
src/caps.rsCaps/Policystructs,parse_allow,check_net/read/write/run, 26 unit testssrc/cli/args.rsOption<String>clap fields onRunArgs(--allow-net,--allow-read,--allow-write,--allow-run) — already present, no change neededsrc/main.rsbuild_caps()already present, no change neededsrc/interpreter/mod.rscaps.check_*calls at every IO builtin site — already presentsrc/vm/mod.rscaps.check_*calls at every IO builtin site — already presenttests/capability_flags.rsexamples/capability-sandbox.iloSANDBOX.mdai.txtSPEC.mdTest plan
cargo test --test capability_flags— 15 tests, all passcargo test --lib caps— 26 unit tests, all passilo run --allow-net= examples/capability-sandbox.ilo— denied-read blocked as expectedilo run examples/capability-sandbox.ilo— permissive mode, all IO allowedFollow-up suggestions (not in scope for this PR)
Worldcapability parameter — per-function capability declarations (the language-level long-term move)--allow-envflag (env-read capability) —env-allbuiltin currently ungatedrun-spawned childrenilo servinheriting caps from the launch commandCloses ILO-59.
🤖 Generated with Claude Code