Skip to content

feat(arcan-aios-adapters): shell gating utilities and binary capability extraction (BRO-216)#15

Merged
broomva merged 2 commits intomainfrom
feat/bro-216-shell-gating
Mar 25, 2026
Merged

feat(arcan-aios-adapters): shell gating utilities and binary capability extraction (BRO-216)#15
broomva merged 2 commits intomainfrom
feat/bro-216-shell-gating

Conversation

@broomva
Copy link
Copy Markdown
Owner

@broomva broomva commented Mar 25, 2026

Summary

  • Binary extraction for exec:cmd: capabilities: capabilities_for_tool("bash", {"command": "ls -la"}) now returns exec:cmd:ls (binary only) instead of exec:cmd:ls -la. This enables precise per-command whitelisting — the exec:cmd:ls token matches exactly against exec:cmd:ls in PolicySet::free().allow_capabilities
  • New shell_gate module: Documents and tests the two-layer shell enforcement model with ShellPolicy enum, shell_policy_for(), validate_shell_command(), and FREE_TIER_ALLOWED_COMMANDS constant

Architecture

Shell enforcement runs at two complementary layers:

  1. PolicySet / capability evaluation (aios-protocol + aios-policy): capabilities_for_tool("bash", input) returns exec:cmd:<binary>. The StaticPolicyEngine evaluates this against the session's policy — anonymous: immediately denied (no approval ticket); free: only whitelisted binaries allowed; pro/enterprise: all allowed via "*" wildcard
  2. Tier catalog filtering (BRO-214): The bash tool is hidden from the LLM's tool list for anonymous/free tiers

New exports

pub use shell_gate::{ShellPolicy, FREE_TIER_ALLOWED_COMMANDS, shell_policy_for, validate_shell_command};

Test plan

  • shell_derives_exec_cmd_binary_capability: "ls -la"exec:cmd:ls
  • shell_strips_path_prefix_from_binary: /usr/bin/python3 script.pyexec:cmd:python3
  • shell_cap_is_denied_by_anonymous_policy: exec:cmd:* NOT in anonymous gate
  • All shell_gate tests: tier mapping, command validation, path stripping, end-to-end denial
  • All 79 tests pass: cargo test -p arcan-aios-adapters

Depends on: broomva/aiOS#3

Closes BRO-216

🤖 Generated with Claude Code

…ty extraction (BRO-216)

capability_map.rs:
- Extract binary name from bash/shell command before building exec:cmd:<binary>
  capability (e.g. "ls -la" → exec:cmd:ls, "/usr/bin/python3" → exec:cmd:python3)
- Enables precise per-command whitelisting in PolicySet::free()
- shell_without_arg falls back to exec:cmd:* wildcard
- Updated tests to assert binary-level capability tokens

shell_gate.rs (new):
- ShellPolicy enum: Blocked | Whitelisted | Unrestricted
- shell_policy_for(&PolicySet): derives policy from capability set
- validate_shell_command(cmd, policy): validates command binary against policy
- FREE_TIER_ALLOWED_COMMANDS: safe read-only whitelist constant
- 20+ unit tests covering all tiers, path stripping, end-to-end denial

lib.rs: export shell_gate module and public symbols

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@linear
Copy link
Copy Markdown

linear bot commented Mar 25, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

Warning

Rate limit exceeded

@broomva has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 53 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 876976fa-e913-417f-994a-0a875711a165

📥 Commits

Reviewing files that changed from the base of the PR and between f454575 and 81a9ee4.

📒 Files selected for processing (3)
  • crates/arcan-aios-adapters/src/capability_map.rs
  • crates/arcan-aios-adapters/src/lib.rs
  • crates/arcan-aios-adapters/src/shell_gate.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bro-216-shell-gating

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…pace() (clippy)

split_whitespace() already handles leading/trailing whitespace, making the
preceding trim() call redundant. Fixes clippy::trim_split_whitespace lint.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@broomva broomva merged commit c5d419e into main Mar 25, 2026
17 of 19 checks passed
@broomva broomva deleted the feat/bro-216-shell-gating branch March 25, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant