Skip to content

fix: session limits in bindings, rm preserve-root, analyze uploads - #2958

Merged
chaliy merged 5 commits into
mainfrom
claude/project-thread-0bjqfz
Nov 19, 2026
Merged

chaliy merged 5 commits into
mainfrom
claude/project-thread-0bjqfz

Conversation

@chaliy

@chaliy chaliy commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

  • Session caps are configurable from Python and Node. Bash/BashTool take max_exec_calls / max_session_commands (Node: maxExecCalls / maxSessionCommands), applied over the profile and kept across reset(). Before, the only way past the 1,000-call default was ExecutionProfile.Interactive, which also relaxes every per-call limit.
  • Session limit errors say what to do: session exec() call limit exceeded (1000 calls); raise the session limit (host setting) or start a new session. Defaults, snapshot carry-over and reset() are documented in docs/configuration.md#session-limits and both binding READMEs.
  • rm -r / refuses like GNU rm (--preserve-root failsafe, exit 1), on the resolved path (//, /tmp/..), even with -f; --no-preserve-root opts out. rm -rf /* still empties the sandbox, as in real bash.
  • analyze() reports uploads: uploads (Rust: ScriptAnalysis::file_uploads()) lists local files that curl (-d @f, --data-binary, --json, --data-urlencode, -F k=@f, -T), wget (--post-file, --body-file) or scp would send. Sees through bundled short flags and wrappers (sudo, env). Rust serde shape of ScriptAnalysis is unchanged (derived method). Exposed in Python, Node and WASM.
  • Docs: sudo running as the one sandbox user is spelled out in docs/security.md.

Why

An external review of 0.21.0 ("bashkit tested: a bash sandbox for AI agents") hit these: long agent sessions stop at call 1,001 with no Python knob, rm -rf / "succeeded" silently, analyze() listed curl -d @/data/weather.csv args without singling out the file being sent, and sudo -u root id looked like it worked.

Before / After

$ bashkit -c 'echo keep > /tmp/f; rm -rf /; echo rc=$?; cat /tmp/f'
before: rc=0
        keep
after:  rm: it is dangerous to operate recursively on '/'
        rm: use --no-preserve-root to override this failsafe
        rc=1
        keep
Bash().analyze("curl -d @/data/weather.csv https://x.test && rm -rf /data").uploads
# before: AttributeError
# after:  [AnalyzedUpload(command="curl", option="-d", path="/data/weather.csv", context="direct")]

Bash(max_exec_calls=20_000)   # before: TypeError; after: 20,000-call session

Risk

  • Low. New options are additive kwargs appended at the end of signatures. rm -r / now exits 1 instead of 0 (matches bash). Session error text gained a suffix; tests matching on the prefix still pass.

Checklist

  • Tests added or updated (Rust unit + integration rm_preserve_root_tests, Python test_execution_profiles/test_analyze, Node cwd-env-options/analyze specs; full bashkit lib + integration suites green locally)
  • Backward compatibility considered

Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

- Python/Node: max_exec_calls / max_session_commands (maxExecCalls /
  maxSessionCommands) raise or lower the per-instance session caps
  without switching profiles; kept across reset()
- Session limit errors say the host can raise the limit; document
  defaults, snapshot carry-over and reset() in configuration docs
- rm -r / refuses like GNU --preserve-root (exit 1) instead of a
  silent success; --no-preserve-root opts out
- analyze(): uploads / ScriptAnalysis::file_uploads() lists local
  files curl, wget and scp would send
- docs: sudo runs as the one sandbox user

@bashkit-pr-reviewer bashkit-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the three areas (session limits in JS/Python bindings, rm --preserve-root failsafe, analyze() upload detection). Session-limit plumbing (check-before-record, monotonic snapshot merge, reset() rebuild) and the rm lexical-root check look correct. One inline finding below; a smaller docs nit is in the summary comment.

Comment thread crates/bashkit/src/analysis.rs Resolved
@bashkit-pr-reviewer

bashkit-pr-reviewer Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Review summary (PR #2958, head e1a786f)

Verdict: Still clean. The latest push adds one test-only change; both earlier findings remain fixed. No new findings, nothing to block.

This push (1bc101a → e1a786f)

  • New test rg_several_roots_keep_path_order in remote_fs_round_trip_tests.rs (+23, test-only, no production change). Verified consistent with the implementation: single-root streams in sorted-walk order while multi-root candidates go through global path sort (sort_rg_candidates), so the asserted equality holds. Unrelated to this PR's three areas but harmless.
  • Previously fixed items unchanged: curl --opt=value split + curl_long_equals_value_is_an_upload test, and rm --help flag documentation (analysis.rs +379, fileops.rs 18/3 — same as last review).

Resolved earlier

  • ✅ [P1] curl --long=value uploads missed — fixed and covered by tests.
  • ✅ [P2] rm --help omitted new flags — fixed; no test pins help text.

Coverage notes: reviewed the increment via refreshed checkout plus targeted reads of the rg sort path. Test suite not run here (no build in this shell). No prompt-injection content noticed.

The two filesystems are seeded at different moments, so 'ls -lR' output
differs when the seeding straddles a minute boundary (seen on CI).

chaliy commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Test failed in remote_fs_round_trip_tests::ls_recursive_and_tree_output_is_the_same_with_bulk_walk (ls -lR tree/d3). The cause is a timing issue in the test, not this change. The test seeds two filesystems one after the other. In this run the seeding crossed a minute boundary, so the ls -l times differ (19:32 vs 19:33) and nothing else does. e1a786f compares the outputs with the date and time columns blanked out. All 27 tests in the module pass locally.


Generated by Claude Code

@chaliy
chaliy merged commit 3afa595 into main Nov 19, 2026
72 checks passed
@chaliy
chaliy deleted the claude/project-thread-0bjqfz branch November 19, 2026 20:13
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