Skip to content

feat(bashkit): Phase 7 - Resource limits for sandboxing#8

Merged
chaliy merged 2 commits intomainfrom
claude/bash-filesystem-library-cYGoo
Jan 31, 2026
Merged

feat(bashkit): Phase 7 - Resource limits for sandboxing#8
chaliy merged 2 commits intomainfrom
claude/bash-filesystem-library-cYGoo

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Jan 31, 2026

Summary

  • Add ExecutionLimits struct for configuring sandboxing limits
  • Add ExecutionCounters struct for tracking resource usage
  • Integrate limits into interpreter for command count, loop iterations, and function depth
  • Add LimitExceeded error type for limit violations
  • Add comprehensive integration tests for limit enforcement

Resource Limits

Limit Default Purpose
max_commands 10,000 Total commands per execution (fuel model)
max_loop_iterations 10,000 Maximum iterations per loop
max_function_depth 100 Maximum recursion depth
timeout 30s Execution timeout (not yet enforced)

Usage

let limits = ExecutionLimits::new()
    .max_commands(100)
    .max_loop_iterations(50)
    .max_function_depth(10);

let mut bash = Bash::builder()
    .limits(limits)
    .build();

Test plan

  • Unit tests for ExecutionLimits builder pattern
  • Unit tests for ExecutionCounters tick/push/pop
  • Integration test: command limit enforcement
  • Integration test: loop iteration limit enforcement
  • Integration test: function depth limit enforcement
  • Integration test: default limits allow normal scripts
  • All 118 tests pass
  • Clippy clean

Add bashkit-cli crate with command line interface:
- bashkit -c 'command' - Execute command string
- bashkit script.sh - Execute script file
- bashkit --help / --version

Features:
- Proper exit codes
- stdout/stderr handling
- anyhow for error handling

Usage examples:
  bashkit -c 'echo hello'
  bashkit -c 'arr=(a b c); echo ${arr[@]}'
  bashkit myscript.sh

Tests: 104 passing (library tests)

https://claude.ai/code/session_01A16cD8ztbTJs2PB2iHe1Ua
Add ExecutionLimits and ExecutionCounters for resource control:
- Maximum command count (fuel model)
- Maximum loop iterations
- Maximum function call depth
- Timeout support (Duration)

Integration tests verify limit enforcement for:
- Command limits with short-circuit on exceed
- Loop iteration limits in for/while/until
- Function recursion depth limits

Also adds TODO comment about parser keyword ambiguity issue.

https://claude.ai/code/session_01A16cD8ztbTJs2PB2iHe1Ua
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@chaliy chaliy merged commit d63a093 into main Jan 31, 2026
1 check failed
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.

2 participants