Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ptr727/ProjectTemplate
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.703
Choose a base ref
...
head repository: ptr727/ProjectTemplate
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.0.706
Choose a head ref
  • 4 commits
  • 14 files changed
  • 2 contributors

Commits on Sep 26, 2026

  1. Contain Each Bash Tool Call in a Task- and Memory-Capped Scope (#1900)

    ## Summary
    
    Closes on promotion: #1890
    
    A probe's self-recursive command shim grew past half a million processes
    and took the host down. The write guard reads command text, and that
    recursion lived in a script file the command only named, so this bounds
    every Bash tool call's process tree instead, per the layering agreed in
    #1890's comment.
    
    **Structural layer (primary).**
    
    - `host-setup/agent-safety/claude/tool-containment.py` is registered as
    `CLAUDE_CODE_SHELL_PREFIX`. It runs each Bash tool call in a transient
    `systemd-run --user --scope` with `TasksMax` (default 8192) and
    `MemoryMax` (default 25%), named `claude-tool-<session>-<pid>-<random>`.
    The maintainer can raise either ceiling through
    `AGENT_CONTAINMENT_TASKS_MAX` / `AGENT_CONTAINMENT_MEMORY_MAX`.
    - Hooks and stdio MCP servers pass through the prefix unscoped. A
    PreToolUse hook exiting non-2 is a non-blocking error, so a scope that
    failed to start under the write guard would let the command it denies
    run.
    - The SessionEnd sweep now first stops the session's tool-call scopes
    and reports what they held, then runs its existing report-only phase.
    - The installer registers the prefix only on Linux with a reachable user
    manager (under `XDG_RUNTIME_DIR`, else `/run/user/<uid>`), only where
    executing the deployed file directly passes its self-test, and never
    over a foreign value.
    - The spec gains requirement 9.
    
    **Behavioral layer.**
    
    - The self-recursive-shim rule is added to `shell-codestyle`.
    - Bounded, group-reaped, `pgrep`-verified probes are added to AGENTS.md
    "Commands".
    
    **Design decisions from #1890's open points.**
    
    - **`CLAUDE_CODE_SHELL_PREFIX` instead of `PreToolUse` `updatedInput`.**
    A rewritten command would break permission-rule matching and the shell's
    cwd tracking. The prefix wraps the whole string Claude Code builds, cwd
    bookkeeping included.
    - **Behavior was verified live on 2.1.283.** Claude Code passes the
    command as one argument, quotes the prefix value as one word, and
    applies it to hooks and MCP launches too.
    - **No `ulimit -u` fallback.** It caps every process the account owns,
    so it would fail unrelated work. Non-systemd hosts stay unregistered.
    - **Overhead** is about 35 ms per contained tool call and about 10 ms
    per direct pass-through.
    
    ## Verification
    
    - The issue's repro shim, run with a 64-task ceiling, failed fast with
    `fork: Resource temporarily unavailable`, and nothing survived.
    - In a nested `claude -p` session with the prefix set:
      - cwd persisted across calls,
      - each tool call ran in its `claude-tool-<session>-…` scope,
      - a `setsid`-detached process was stopped at session end,
      - gh-write-guard, run through the prefix as a hook, still denied.
    - Self-tests pass for all three hooks, `test_install` passes (81 tests),
    and mutation checks on the new tests were caught.
    - ruff, mypy, prose gate, markdownlint, cspell, editorconfig, and
    `spec/validate.py` are clean.
    
    ## Known limitations from the last local review pass
    
    Four local strict-review rounds ran, and each round's findings were
    fixed. The maintainer authorized rounds beyond the two-round budget. The
    final pass raised three items, carried here as context per the
    maintainer's call:
    
    1. **Out-of-range overrides pass validation.** A value such as a
    20-digit `AGENT_CONTAINMENT_TASKS_MAX`, or `99999999999E`, passes the
    prefix's check, and systemd then rejects it. Every tool call would fail
    until the override is corrected.
    2. **Capability is not checked against the cgroup controllers.** It
    never checks that the user manager actually delegates the `pids` and
    `memory` controllers. On a cgroup-v1 or hybrid host the scope starts
    without enforcing either ceiling, and the sweep's process count reads 0.
    3. **Requirement 9 overstates what the implementation does.** It says an
    unbounded host "says so on every run". The Claude implementation is
    silent where the prefix is not registered, and silent for a tool call
    that sources no snapshot.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    
    <!-- This is an auto-generated comment: release notes by coderabbit.ai
    -->
    
    ## Summary by CodeRabbit
    
    * **New Features**
    * Eligible Claude Code shell commands can now run with task and memory
    limits when the host supports them. When limits cannot be applied, the
    limitation is reported; hooks and tool-server launches remain outside
    this containment.
    * At session end, remaining containment scopes are stopped and reported.
    Other surviving process trees are reported without being terminated.
    * **Documentation**
    * Added guidance for bounded probes, command shims, and safety
    requirements across supported agent environments, including host
    limitations and verification steps.
    
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->
    
    ---------
    
    Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
    ptr727 and claude authored Sep 26, 2026
    Configuration menu
    Copy the full SHA
    81692b1 View commit details
    Browse the repository at this point in the history
  2. Say Only That the Kit Does Not Contain Under a Foreign Prefix (#1908)

    ## Summary
    
    This answers Copilot's two findings on promotion #1907. The installer
    and its `--report` said that a foreign `CLAUDE_CODE_SHELL_PREFIX` (a
    value this kit does not own) meant agent commands "run uncontained", or
    get "no containment". Another wrapper may contain them. Both messages
    now say only that this kit does not contain agent commands there.
    
    The `--report` note now offers the remove-and-re-run remedy only where
    the host can contain. Elsewhere it gives the reason instead. A test pins
    both wordings.
    
    ## Open from the last local pass
    
    The capability verdict that picks the note also counts a missing or
    broken deployed prefix as unable to contain, although re-running the
    installer fixes it. In that case the note gives the reason, and the
    remedy only appears on the next `--report`, after the re-run the STALE
    line already asks for.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    ---------
    
    Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
    ptr727 and claude authored Sep 26, 2026
    Configuration menu
    Copy the full SHA
    030dbc3 View commit details
    Browse the repository at this point in the history
  3. Tell the Maintainer to Correct, Not Unset, an Uncontainable Prefix (#…

    …1909)
    
    ## Summary
    
    This answers a previously-missed finding on promotion #1907. The
    `--report` drift message for this kit's prefix, registered where the
    host cannot contain, said to re-run the installer "to unset it". The
    same verdict also covers a missing or broken deployed prefix, which the
    re-run repairs and re-registers rather than unsets. It now says "to
    correct it", which holds on both paths.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
    ptr727 and claude authored Sep 26, 2026
    Configuration menu
    Copy the full SHA
    0bdde8d View commit details
    Browse the repository at this point in the history

Commits on Sep 27, 2026

  1. Promote Tool-Call Containment to Main (#1907)

    ## Summary
    
    Promotes develop to main. It carries one change:
    
    - #1900: Contain Each Bash Tool Call in a Task- and Memory-Capped Scope
    
    That change adds the agent-safety kit's `tool-containment.py` shell
    prefix, registered as `CLAUDE_CODE_SHELL_PREFIX`. The prefix runs each
    Bash tool call in a systemd user scope with `TasksMax`, `MemoryMax`, and
    `MemorySwapMax=0`. The SessionEnd sweep then stops the ending session's
    scopes before its report-only phase. The change also adds spec
    requirement 9, the self-recursive shim rule in `shell-codestyle`, and
    the bounded-probe rule in AGENTS.md "Commands".
    
    Fixes #1890
    
    ## Follow-ups filed from its reviews
    
    - #1903: bound and reap nested Claude sessions' tool-call scopes as one
    tree.
    - #1905: judge the installer's hook ownership by file name rather than
    substring. This predates #1900.
    - #1906: clear bash's hash, and test the shim after it exists, in the
    shim rule.
    
    ## Needs the maintainer
    
    - Copilot's final round on #1900 asked for validation by a human on
    representative Linux and WSL hosts. It was verified live on one Debian
    13 host (systemd 257, cgroup v2), including end-to-end in nested `claude
    -p` sessions. WSL was not exercised.
    - Machines pick the kit up only when the installer is re-run after
    release. The sweep's hook timeout also rises from 10s to 35s, so
    `--report` shows an existing install as STALE until then.
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    ptr727 authored Sep 27, 2026
    Configuration menu
    Copy the full SHA
    b8425b2 View commit details
    Browse the repository at this point in the history
Loading