Repository navigation
feat(hooks): escalate unrecognized command forms to a prompt - #159
Merged
Merged
Conversation
Line-based grep let a newline inside a quoted argument satisfy an anchored rule by itself. It also hid every multi-line commit message from the rules. Match one NUL-free record instead. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Git ignores *-workspace directories as agent-local state, but ls-lint still scanned them. Pre-commit then failed on files the repository does not own. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The rule accepted one double-quoted message or repeated single-quoted ones, nothing else. Accept any number of -m arguments in either quoting style, for amended commits as well. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Every parameter expansion was refused, so the documented verification command was uninspectable. Accept a plain HOME expansion and a leading tilde; every other expansion still requires review. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Unlisted forms of allow-prefixed commands and uninspectable commands were refused outright. Return an ask decision for those cases instead. Exit 2 remains for deny prefixes, forbidden patterns, dangerous Git, and invalid policy files. Provider adapters that cannot prompt harden the ask into a denial. Escalations are audited with the governed prefix as a label. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
The scope check denied the session scratch directory and every cd into a sibling repository. Treat TMPDIR and the Claude temp directories as in scope, and ask for other outside targets. A missing or corrupt registration is still denied. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
… decision commits.md names the one commit form the hooks accept without review. ADR-0033 records why mismatches now reach the user instead of being refused. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Inside the sandbox, git can neither read the signing key nor reach the SSH agent socket. Every agent commit therefore failed, or had to be made unsigned. The command hooks and permission rules still govern the commit itself. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…r works Inside the sandbox the gh credential helper cannot read its configuration, so every push failed. The dangerous-Git guard and the permission rules still govern what may be pushed. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Compound commands run inside the sandbox, where signing cannot reach the key or the agent. The credential helper cannot read its configuration there either, so pushes fail the same way. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
furedea
force-pushed
the
feat/escalate-unrecognized-command-forms
branch
from
October 15, 2026 04:56
ff7dd16 to
869ce52
Compare
The sandbox docs keep cd, git -C, pipes, redirections, and chains inside the sandbox regardless. Name them all so commit and push are issued in the one shape that signs and authenticates. Refs #158 Co-Authored-By: Claude Fable 5.1 <[email protected]>
This was referenced Oct 15, 2026
furedea
added a commit
that referenced
this pull request
Oct 15, 2026
## Summary Makes the OS sandbox the safety boundary for ordinary commands and asks only for effects that escape it or cannot be undone. Audit evidence from one afternoon after #159: 94 hook escalations, 82 of them "syntax" (a glob, `$VAR`, `$(...)`, or heredoc anywhere in the call), the rest `grep`/`rg`/`cat` arguments that merely contained `\` or `$` inside quotes; script execution prompted on every call. - **Run-time words are reported, not refused.** The shell inspection now marks a glob or a parameter other than `$HOME` as dynamic and keeps its source text instead of raising. Command, process, and arithmetic substitution, heredocs, and dollar-quoted strings are still refused. - **Read-only programs are judged structurally.** `rg`, `grep`, `cat`, `ls`, `find`, `jq`, and the other programs listed in `allowed_commands.json` may take any literal, glob, or variable argument as long as no redirection writes a file (`/dev/null` and fd duplication are fine). `rg -n "def \w+" agents`, `rg foo *.py`, and `cat $FILE` are allowed; `rg foo > out.txt` still asks. - **Any other program with a run-time argument asks**, including `git push $FLAGS`, `cd $DIR`, and a dynamic program name. A literal deny prefix such as `rm -rf $DIR` still denies, and the forbidden hook no longer escalates; escalation is the allowed hook's job. - **Sandbox-contained execution and edits move from ask to allow:** `python3`, `python`, `node`, `uv run python`, `uv run --frozen python` (scripts, `-c`/`-e`, and a short module list), `sed -i`, `perl -i`, `tee`, `truncate`. `python -m pip` is denied like `pip`. `uvx`, `npx`, `pnpm dlx`, `bunx`, dependency changes, `rm`, merges, publishing, and the sandbox escape still ask. - **Trivial builtins** (`echo`, `printf`, `pwd`, `date`, `true`, `false`, `test`, `basename`, `dirname`, `realpath`, `readlink`, `seq`) are allowed so they no longer reach the classifier. - A `cd` or `git -C` to a run-time directory asks in the verification scope check instead of resolving a literal `$DIR` path. - ADR-0034 records the decision and supersedes ADR-0031; the README paragraph is updated. Closes #162 ## Verification - `uv run --frozen pytest tests/agents`: 1492 passed. - `uv run --frozen ruff check`, `ruff format --check`, and `ty check` are clean; lefthook pre-commit and commitlint passed on both commits. - The Codex execpolicy rows for `uv run python` and `sed -i` now expect `allow`; `uvx` and `npx` rows expect `prompt`. - Live check after `home-manager switch`: run `rg -n "def \w+" agents` and `python3 -c 'print(1)'` in a new session and confirm neither prompts; run `rg foo > out.txt` and confirm it asks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
1 task done
furedea
added a commit
that referenced
this pull request
Nov 12, 2026
agent-config 0.1.2(`3b3d9c5`)を取り込みます.#74 のモデル判定まわりの残りがすべて入ります. | 取り込む変更(furedea/agent-config) | 中身 | | --- | --- | | #172 | 「ルールの見本のフォルダ」の判定を 1 か所にまとめる | | #173 | jev-lint の子プロセスに `GIT_LITERAL_PATHSPECS=1` を渡す(#159) | | #174 | 時間に頼らないタイムアウトのテスト(#171) | | #175,#178 | Go と Rust のルールの穴と,境目の見本(#164) | | #180 | 読み取り専用の GraphQL の問い合わせのあとに `jq` を付けてよくする | | #177 | Stop のテストの行を,ランナーごとに 1 つの件数にまとめる(Rust は `312 passed` のように合計する) | - [x] `darwin-rebuild switch` で反映済み ほかのセッションが main の古い `flake.lock` で反映すると,これらが取り消されます.早めにマージします. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Reduces the friction the agent harness adds to ordinary Git delivery (add, commit, push, PR creation) without widening any hard denial.
grep --null-data). This closes a bypass where a newline inside a quoted argument could satisfy an anchored rule by itself, and lets multi-line quoted commit messages match.git commitaccepts any number of-marguments in single or double quotes, mixed, for amended commits too.permissionDecision: askinstead of exit 2. Deny prefixes, forbidden patterns, dangerous Git operations, secret policies, and invalid policy files still exit 2. The Codex, Devin, Hermes, and pi adapters harden the ask into a denial because their hooks cannot prompt. Escalations are audited with the governed prefix asdetail.$HOME,${HOME}, and a leading~are resolved statically in shell inspection; every other expansion still requires review.TMPDIR,CLAUDE_TMPDIR, andCLAUDE_CODE_TMPDIRas in scope and asks, instead of denying, for other out-of-worktree targets. A missing or corrupt registration is still denied.git commit *andgit push *run outside the Claude sandbox: inside it, SSH signing can neither read the key nor reach the agent socket, and the gh credential helper cannot read its configuration. The command hooks, the dangerous-Git guard, and the permission rules still govern both commands.*-workspacedirectories.Closes #158
Verification
uv run --frozen pytest tests/agents: 1438 passed before the docs and settings commits; the subsets those commits touch (Claude settings, skill layout, sandbox escape, hook generation) passed afterwards.uv run --frozen ruff check,ruff format --check, andty checkare clean.verification_session.py verify): the latest run reports 1544 passed, full suite. An earlier run had 3 errors intests/hermes/test_hermes_gateway.py, whosenix buildfixture asserts an empty stderr while Nix warns that the Git tree is dirty; that came from uncommitted changes that predate this branch and is unrelated to this change.home-manager switch, in an interactive Claude Code session:cat README.md > /dev/null(an allowed prefix in an unlisted form) showed a permission prompt and ran after approval, so a hookasktakes precedence over a matching allow rule in auto mode."$HOME/.claude/hooks/verification_session.py" status <record>passed the hook, and a Write into the session scratchpad passed the scope check.git commit *andgit push *sandbox exclusions take effect. A standalonegit commitin the session that was running during the switch still failed to sign, so the exclusions appear to need a new session; check in a fresh one.Departures from the plan
git -c commit.gpgsign=false) and the pushes needed the sandbox disabled for those commands, which is what the sandbox exclusions above fix for future sessions.🤖 Generated with Claude Code