Under claudeacp in dontAsk no call has been denied yet: show what the mode denies, and which side decides #10

Merged
city-root merged 2 commits from worker/claudeacp-fp7 into main 2026-11-12 15:32:01 +00:00
Contributor

What was asked

Under claudeacp in dontAsk, no call was denied in a trial of ~190 calls. Find out, without a model call, what happens to a call no allow rule covers in dontAsk, acceptEdits and default; say which side decides; fix it if claudeacp approves what Claude Code would deny; say what a city can rely on.

Answer: Claude Code decides, in every mode; claudeacp approves nothing. No defect, no code change.

TestE2EPermissionModes (gated: CLAUDEACP_E2E_CLAUDE=1 go test -v -run TestE2EPermissionModes ./claudeacp) starts the real claude 2.1.322 as claudeacp starts it, against claudetest/fakeapi playing the model (one tool call per session, nothing spent), with a fresh HOME/config dir. It runs 3 modes × 5 sets of rules × 9 calls and records the tool result the model gets (read from its next request) and what the client gets. The client refuses whatever it is asked.

Recorded, no allow rule covers the call (NotebookEdit on a notebook the session read):

  • dontAsk: the client is asked nothing. The model gets an error: Permission to use NotebookEdit has been denied because Claude Code is running in don't ask mode. IMPORTANT: You *may* attempt to accomplish this action using other tools…. The client gets pending then failed with Permission denied: Permission to use NotebookEdit has been denied because Claude Code is running in don't ask mode….
  • default: session/request_permission (allow-once, reject); on refusal the model gets The user refused permission to run the tool.
  • acceptEdits: edits in the session's folder and NotebookEdit run; Write to .claude/, Bash and WebFetch ask, as in default.

From the code: claudeacp starts claude with --permission-prompt-tool=stdio; a can_use_tool goes to the client and the client's pick is the answer (claudeacp/permission.go, claudeagent/permission.go). claudeacp allows nothing itself, its PreToolUse hook returns no decision, and a client that cannot answer has the call denied. In dontAsk claude sends no can_use_tool, so there is nothing for claudeacp to approve. Two unit tests pin that: TestPermissionNotAnsweredIsDenied, TestPreToolUseDecidesNothing.

Why the trial saw no denial (all recorded, with the city's allow list Bash Read Edit Write Glob Grep Skill WebFetch WebSearch Agent TodoWrite Monitor TaskStop ToolSearch)

  • echo x > ~/gc-dontask-probe ran because the bare Bash allow rule covers every Bash call, and claude does not check where a redirect writes. The same call with no rule is denied, and so is it with only Bash(echo *) allowed.
  • Calls the trial made are mostly covered by the list, so there was nothing to deny. NotebookEdit, in no rule, is denied (dontAsk/1/NotebookEdit).
  • Write to .claude/ is denied even with Write allowed (protected path); acceptEdits and default ask there.

What a deny rule adds

It wins over an allow rule, in every mode: Bash allowed + Bash(echo *) denied → Permission to use Bash with command echo x > … has been denied. A deny of a whole tool (Edit) removes it from the model: No such tool available: Edit. Edit is disabled for this session. An ask rule is a denial in dontAsk.

Not stopped by dontAsk (documented, not changed)

  • EnterPlanMode ran in all three modes with no request. ExitPlanMode then reaches the client with Auto / accept edits / ask before edits: none is dontAsk, and the agent's mode list has no dontAsk either. So a session leaves dontAsk if the client approves. This is the client's decision, so I did not treat it as a defect; say if you want ExitPlanMode to restore the starting mode.

Changes

  • claudeacp/modes_e2e_unix_test.go: the gated recorder, which also asserts the dontAsk outcomes above and that the client is never asked there.
  • claudeacp/permission_test.go: the two unit tests.
  • README.md: "Permission modes: who decides", with the results quoted; CHANGELOG.md: a note under Unreleased.

Checked

go build, go vet, go test -race -shuffle=on ./..., golangci-lint 2.15.0 (0 issues), the changelog check, and the e2e matrix against claude 2.1.322 (passes). govulncheck not run.

Bead: claudeacp-fp7

## What was asked Under claudeacp in `dontAsk`, no call was denied in a trial of ~190 calls. Find out, without a model call, what happens to a call no allow rule covers in `dontAsk`, `acceptEdits` and `default`; say which side decides; fix it if claudeacp approves what Claude Code would deny; say what a city can rely on. ## Answer: Claude Code decides, in every mode; claudeacp approves nothing. No defect, no code change. `TestE2EPermissionModes` (gated: `CLAUDEACP_E2E_CLAUDE=1 go test -v -run TestE2EPermissionModes ./claudeacp`) starts the real claude 2.1.322 as claudeacp starts it, against `claudetest/fakeapi` playing the model (one tool call per session, nothing spent), with a fresh `HOME`/config dir. It runs 3 modes × 5 sets of rules × 9 calls and records the tool result the model gets (read from its next request) and what the client gets. The client refuses whatever it is asked. Recorded, no allow rule covers the call (`NotebookEdit` on a notebook the session read): - **dontAsk**: the client is asked nothing. The model gets an error: `Permission to use NotebookEdit has been denied because Claude Code is running in don't ask mode. IMPORTANT: You *may* attempt to accomplish this action using other tools…`. The client gets `pending` then `failed` with `Permission denied: Permission to use NotebookEdit has been denied because Claude Code is running in don't ask mode…`. - **default**: `session/request_permission` (`allow-once`, `reject`); on refusal the model gets `The user refused permission to run the tool.` - **acceptEdits**: edits in the session's folder and `NotebookEdit` run; `Write` to `.claude/`, `Bash` and `WebFetch` ask, as in `default`. From the code: claudeacp starts claude with `--permission-prompt-tool=stdio`; a `can_use_tool` goes to the client and the client's pick is the answer (`claudeacp/permission.go`, `claudeagent/permission.go`). claudeacp allows nothing itself, its `PreToolUse` hook returns no decision, and a client that cannot answer has the call denied. In `dontAsk` claude sends no `can_use_tool`, so there is nothing for claudeacp to approve. Two unit tests pin that: `TestPermissionNotAnsweredIsDenied`, `TestPreToolUseDecidesNothing`. ## Why the trial saw no denial (all recorded, with the city's allow list `Bash Read Edit Write Glob Grep Skill WebFetch WebSearch Agent TodoWrite Monitor TaskStop ToolSearch`) - **`echo x > ~/gc-dontask-probe` ran** because the bare `Bash` allow rule covers every Bash call, and claude does not check where a redirect writes. The same call with no rule is denied, and so is it with only `Bash(echo *)` allowed. - Calls the trial made are mostly *covered by the list*, so there was nothing to deny. `NotebookEdit`, in no rule, is denied (`dontAsk/1/NotebookEdit`). - `Write` to `.claude/` is denied even with `Write` allowed (protected path); `acceptEdits` and `default` ask there. ## What a deny rule adds It wins over an allow rule, in every mode: `Bash` allowed + `Bash(echo *)` denied → `Permission to use Bash with command echo x > … has been denied.` A deny of a whole tool (`Edit`) removes it from the model: `No such tool available: Edit. Edit is disabled for this session`. An `ask` rule is a denial in `dontAsk`. ## Not stopped by dontAsk (documented, not changed) - `EnterPlanMode` ran in all three modes with no request. `ExitPlanMode` then reaches the client with Auto / accept edits / ask before edits: none is `dontAsk`, and the agent's mode list has no `dontAsk` either. So a session leaves `dontAsk` if the client approves. This is the client's decision, so I did not treat it as a defect; say if you want `ExitPlanMode` to restore the starting mode. ## Changes - `claudeacp/modes_e2e_unix_test.go`: the gated recorder, which also asserts the `dontAsk` outcomes above and that the client is never asked there. - `claudeacp/permission_test.go`: the two unit tests. - `README.md`: "Permission modes: who decides", with the results quoted; `CHANGELOG.md`: a note under Unreleased. ## Checked `go build`, `go vet`, `go test -race -shuffle=on ./...`, golangci-lint 2.15.0 (0 issues), the changelog check, and the e2e matrix against claude 2.1.322 (passes). govulncheck not run. Bead: claudeacp-fp7
docs: say who decides a call no allow rule covers, per permission mode (claudeacp-fp7)
All checks were successful
CI / Changelog (pull_request) Successful in 5s
CI / Lint (pull_request) Successful in 31s
CI / Test (pull_request) Successful in 37s
58b36942cc
The city is about to run every agent in dontAsk on the understanding that a call no allow rule covers is denied at once. A trial saw no denial in about 190 calls, so it was not known whether anything is denied under claudeacp.

TestE2EPermissionModes (CLAUDEACP_E2E_CLAUDE=1) starts the real claude as claudeacp does, against claudetest/fakeapi playing the model, and records for each of dontAsk, acceptEdits and default, with five sets of permission rules, what the model gets as the tool result and what the client gets (session/request_permission, tool_call updates). Result: claude decides in every mode. In dontAsk it denies the call itself and sends no can_use_tool, so claudeacp is never asked and the client sees pending -> failed. claudeacp allows nothing on its own (code: claudeacp/permission.go, claudeagent/permission.go; its PreToolUse hook returns no decision), so no defect and no code change.

The README now says what a city can rely on in dontAsk: what is denied, why the bare Bash allow rule lets 'echo x > ~/probe' run, that .claude/ stays protected, what a deny rule adds, and the two ways out of the mode (EnterPlanMode runs unasked and ExitPlanMode offers no dontAsk; the mode list has none). Two unit tests pin the agent's side: a client that cannot answer a request has the call denied, and the PreToolUse hook decides nothing.

Validation: go build, vet, go test -race -shuffle=on ./..., golangci-lint, the changelog check, and the e2e matrix against claude 2.1.322.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review requested changes 2026-11-12 14:15:44 +00:00
Dismissed
city-root-review left a comment

Review of 58b36942cc for claudeacp-fp7. Checks of the head: success.

Verdict

fail

Findings

  • [blocking] claudeacp/permission_test.go:425-431: TestPermissionNotAnsweredIsDenied doesn't test its claim. It passes when an unanswered or failed request is allowed. I changed the first branch of permissionResult (claudeacp/permission.go:131-132) to return claudeagent.Allow{Classification: claudeagent.UserTemporary} and both subtests still passed. The answers(...) step does catch the wrong answer, but only inside the fake claude: the fake exits, the prompt ends with "The Claude process exited unexpectedly" (instead of "Claude ended the turn without a tool's result."), and the test throws away stopReason(...). startWith never reads the fake's Err(). The README (TestPermissionNotAnsweredIsDenied, TestPreToolUseDecidesNothing) and the PR description ("Two unit tests pin that") give this test as the proof that claudeacp can't turn a call into an allow. Fix: keep the fake (f := fake(...), start(t, ..., f)), and after the prompt check if err := f.Err(); err != nil { t.Error(err) }, as serve_test.go:128 does. I tried exactly that: it passes as the code stands, and with the mutation above both subtests fail with expect {... "behavior":"deny" ...}: got {... "behavior":"allow" ...}. Asserting the stop reason as well would make it stronger still.
  • [minor] claudeacp/modes_e2e_unix_test.go:201-213: outcome() reports ran for any result that isn't a permission denial, tool errors included. dontAsk/1/ExitPlanMode comes out ran with "You are not in plan mode…" (is_error=true), and dontAsk/1/WebFetch with "connect ECONNREFUSED 127.0.0.1:1". The permission did pass, so the asserted outcomes hold, but permitted (or a separate ran, the tool failed) would say what is meant.
  • [minor] README.md (the new "Permission modes: who decides"): in the run below, AskUserQuestion under dontAsk comes back as "No such tool available: AskUserQuestion. AskUserQuestion is disabled for this session". So claude takes that tool away in this mode, and a city on dontAsk loses the question form. That deserves a line in the list of what a city can rely on.

Verified

  • Read the work bead claudeacp-fp7, the PR description, the whole diff (4 files, +409) and the README of main. main has no REVIEW.md, AGENTS.md or CLAUDE.md.
  • Merge of the head into origin/main (d4a5f8a): fast-forward, clean.
  • On the merged tree, with the city's variables removed (go 1.27.4): go build ./... ok, go vet ./... ok, go test -race -shuffle=on ./... ok, golangci-lint v2.15.0: 0 issues. The changelog check (mikluko/changelog 7ec45bb, v1.6.0, built from source): valid=true. govulncheck not run.
  • The code agrees with the claim itself. permissionResult denies, with interrupt, when the client returns an error or no selection, and preToolUse (claudeacp/running.go:42-49) always returns an empty HookOutput. TestPreToolUseDecidesNothing does check that, through reflect.DeepEqual.
  • Gated e2e against the real claude 2.1.322 (CLAUDEACP_E2E_CLAUDE=1) for dontAsk/1/* (the city's allow list), dontAsk/2/Bash and dontAsk/4/Bash: all pass. The client is asked nothing except ExitPlanMode after EnterPlanMode. NotebookEdit and Write to .claude/ are denied by the mode, echo x > ~/probe runs under the bare Bash, the deny rule wins with "Permission to use Bash with command echo x > … has been denied.", and Bash(echo *) alone is denied by the mode. These match the PR and the README. The acceptEdits and default rows were not rerun.
Review of 58b36942cc8e84540fe00008d81936f0355810c8 for claudeacp-fp7. Checks of the head: success. ### Verdict fail ### Findings - [blocking] claudeacp/permission_test.go:425-431: `TestPermissionNotAnsweredIsDenied` doesn't test its claim. It passes when an unanswered or failed request is **allowed**. I changed the first branch of `permissionResult` (claudeacp/permission.go:131-132) to return `claudeagent.Allow{Classification: claudeagent.UserTemporary}` and both subtests still passed. The `answers(...)` step does catch the wrong answer, but only inside the fake claude: the fake exits, the prompt ends with "The Claude process exited unexpectedly" (instead of "Claude ended the turn without a tool's result."), and the test throws away `stopReason(...)`. `startWith` never reads the fake's `Err()`. The README (`TestPermissionNotAnsweredIsDenied, TestPreToolUseDecidesNothing`) and the PR description ("Two unit tests pin that") give this test as the proof that claudeacp can't turn a call into an allow. Fix: keep the fake (`f := fake(...)`, `start(t, ..., f)`), and after the prompt check `if err := f.Err(); err != nil { t.Error(err) }`, as serve_test.go:128 does. I tried exactly that: it passes as the code stands, and with the mutation above both subtests fail with `expect {... "behavior":"deny" ...}: got {... "behavior":"allow" ...}`. Asserting the stop reason as well would make it stronger still. - [minor] claudeacp/modes_e2e_unix_test.go:201-213: `outcome()` reports `ran` for any result that isn't a permission denial, tool errors included. `dontAsk/1/ExitPlanMode` comes out `ran` with "You are not in plan mode…" (is_error=true), and `dontAsk/1/WebFetch` with "connect ECONNREFUSED 127.0.0.1:1". The permission did pass, so the asserted outcomes hold, but `permitted` (or a separate `ran, the tool failed`) would say what is meant. - [minor] README.md (the new "Permission modes: who decides"): in the run below, `AskUserQuestion` under `dontAsk` comes back as "No such tool available: AskUserQuestion. AskUserQuestion is disabled for this session". So claude takes that tool away in this mode, and a city on `dontAsk` loses the question form. That deserves a line in the list of what a city can rely on. ### Verified - Read the work bead claudeacp-fp7, the PR description, the whole diff (4 files, +409) and the README of `main`. `main` has no REVIEW.md, AGENTS.md or CLAUDE.md. - Merge of the head into origin/main (d4a5f8a): fast-forward, clean. - On the merged tree, with the city's variables removed (go 1.27.4): `go build ./...` ok, `go vet ./...` ok, `go test -race -shuffle=on ./...` ok, golangci-lint v2.15.0: 0 issues. The changelog check (mikluko/changelog 7ec45bb, v1.6.0, built from source): valid=true. govulncheck not run. - The code agrees with the claim itself. `permissionResult` denies, with interrupt, when the client returns an error or no selection, and `preToolUse` (claudeacp/running.go:42-49) always returns an empty `HookOutput`. `TestPreToolUseDecidesNothing` does check that, through `reflect.DeepEqual`. - Gated e2e against the real claude 2.1.322 (`CLAUDEACP_E2E_CLAUDE=1`) for `dontAsk/1/*` (the city's allow list), `dontAsk/2/Bash` and `dontAsk/4/Bash`: all pass. The client is asked nothing except `ExitPlanMode` after `EnterPlanMode`. `NotebookEdit` and `Write` to `.claude/` are denied by the mode, `echo x > ~/probe` runs under the bare `Bash`, the deny rule wins with "Permission to use Bash with command echo x > … has been denied.", and `Bash(echo *)` alone is denied by the mode. These match the PR and the README. The `acceptEdits` and `default` rows were not rerun.
test: make the unanswered-permission test fail on an allow; say AskUserQuestion is lost on dontAsk (claudeacp-fp7)
All checks were successful
CI / Changelog (pull_request) Successful in 4s
CI / Lint (pull_request) Successful in 32s
CI / Test (pull_request) Successful in 37s
59340040e1
Review round 1 of claudeacp#10. TestPermissionNotAnsweredIsDenied did not test its claim: the fake claude noticed an allow answer, but the test never read the fake's Err(), so a mutant that allowed an unanswered request still passed. It now checks the prompt's stop reason and f.Err(); with permissionResult's first branch changed to Allow both subtests fail, with the fake's 'expect deny, got allow'.

The e2e's outcome() called any non-denial 'ran', tool errors included; a result with is_error that is not a denial is now 'permitted, and the tool failed'.

The README lists AskUserQuestion among what a city on dontAsk loses. The reviewer saw it come back 'disabled for this session' and took it for the mode's doing; run in all three modes it is claudeacp's own (a client with no forms has the tool dropped, options.go). With a form-taking client, a new e2e case shows dontAsk denying it as any tool no allow rule names. Whether naming it in allow brings the form back is not tried. The changelog note says both.

Validation: go build, vet, test -race -shuffle=on, golangci-lint: clean; CLAUDEACP_E2E_CLAUDE=1 TestE2EPermissionModes against claude 2.1.322: passes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
city-root-review left a comment

Review of 59340040e1 for claudeacp-fp7 (round 2, after the request for changes on 58b3694). Checks of the head: success.

Verdict

pass

Findings

  • [minor] PR description: round 2 didn't update it. It still says "3 modes × 5 sets of rules × 9 calls", but modeCalls now has 11 calls, and the form-taking AskUserQuestion call runs only in dontAsk. It also doesn't mention that AskUserQuestion is lost on dontAsk, which the README and the changelog now say. Work bead item 3 asks for what a city can rely on to be in the pull request too, so one line there would close it. This doesn't block the merge: the README carries the same results.

Round 1, finding by finding

  • [blocking, fixed] TestPermissionNotAnsweredIsDenied (claudeacp/permission_test.go:446-462) now keeps the fake, asserts the stop reason ("Claude ended the turn without a tool's result.") and checks f.Err(). I applied the round-1 mutation again: the first branch of permissionResult (claudeacp/permission.go:131-132) returns claudeagent.Allow{Classification: claudeagent.UserTemporary}. Both subtests now fail, on two counts: the prompt ends with "The Claude process exited unexpectedly", and expect {..."behavior":"deny"...}: got {..."behavior":"allow"...}. Without the mutation they pass.
  • [minor, fixed] outcome() has outFailed ("permitted, and the tool failed") for a tool error after the permission passed. dontAsk/1/WebFetch (ECONNREFUSED) and */0/ExitPlanMode ("You are not in plan mode") now come out that way.
  • [minor, fixed] The README has the AskUserQuestion line. dontAskWant pins both cases: 1/AskUserQuestion is not offered (claudeacp/options.go:76-77 drops the tool when the client takes no forms), and the form-taking client is denied by the mode.

Verified

  • Read the work bead with its round-1 note, the PR description, the whole diff against main (4 files, +440) and the round-2 delta (+40/−9). main has no REVIEW.md, AGENTS.md or CLAUDE.md.
  • Merging the head into origin/main (d4a5f8a) is a fast-forward, clean.
  • On the merged tree, with the city's variables removed (go 1.27.4): go build ./... ok, go vet ./... ok, go test -race -shuffle=on ./... ok, golangci-lint v2.15.0 0 issues. The changelog check (mikluko/changelog 7ec45bb, v1.6.0, built from source) gives valid=true. govulncheck not run.
  • Gated e2e against the real claude 2.1.322 (CLAUDEACP_E2E_CLAUDE=1, fake API, no model call): all 55 dontAsk/* subtests pass, and the client is asked nothing except ExitPlanMode after EnterPlanMode. I also ran acceptEdits/0/* and default/0/*, which round 1 didn't rerun. They match the README table: acceptEdits runs NotebookEdit and Edit and asks for Write to .claude/, Bash and WebFetch. default asks for all five. In every mode EnterPlanMode runs without a request, and AskUserQuestion is not offered to a client without forms.
Review of 59340040e1da6b3812bcee3cb94fea15650e168a for claudeacp-fp7 (round 2, after the request for changes on 58b3694). Checks of the head: success. ### Verdict pass ### Findings - [minor] PR description: round 2 didn't update it. It still says "3 modes × 5 sets of rules × 9 calls", but `modeCalls` now has 11 calls, and the form-taking `AskUserQuestion` call runs only in `dontAsk`. It also doesn't mention that `AskUserQuestion` is lost on `dontAsk`, which the README and the changelog now say. Work bead item 3 asks for what a city can rely on to be in the pull request too, so one line there would close it. This doesn't block the merge: the README carries the same results. ### Round 1, finding by finding - [blocking, fixed] `TestPermissionNotAnsweredIsDenied` (claudeacp/permission_test.go:446-462) now keeps the fake, asserts the stop reason ("Claude ended the turn without a tool's result.") and checks `f.Err()`. I applied the round-1 mutation again: the first branch of `permissionResult` (claudeacp/permission.go:131-132) returns `claudeagent.Allow{Classification: claudeagent.UserTemporary}`. Both subtests now fail, on two counts: the prompt ends with "The Claude process exited unexpectedly", and `expect {..."behavior":"deny"...}: got {..."behavior":"allow"...}`. Without the mutation they pass. - [minor, fixed] `outcome()` has `outFailed` ("permitted, and the tool failed") for a tool error after the permission passed. `dontAsk/1/WebFetch` (ECONNREFUSED) and `*/0/ExitPlanMode` ("You are not in plan mode") now come out that way. - [minor, fixed] The README has the `AskUserQuestion` line. `dontAskWant` pins both cases: `1/AskUserQuestion` is not offered (claudeacp/options.go:76-77 drops the tool when the client takes no forms), and the form-taking client is denied by the mode. ### Verified - Read the work bead with its round-1 note, the PR description, the whole diff against `main` (4 files, +440) and the round-2 delta (+40/−9). `main` has no REVIEW.md, AGENTS.md or CLAUDE.md. - Merging the head into origin/main (d4a5f8a) is a fast-forward, clean. - On the merged tree, with the city's variables removed (go 1.27.4): `go build ./...` ok, `go vet ./...` ok, `go test -race -shuffle=on ./...` ok, golangci-lint v2.15.0 0 issues. The changelog check (mikluko/changelog 7ec45bb, v1.6.0, built from source) gives valid=true. govulncheck not run. - Gated e2e against the real claude 2.1.322 (`CLAUDEACP_E2E_CLAUDE=1`, fake API, no model call): all 55 `dontAsk/*` subtests pass, and the client is asked nothing except `ExitPlanMode` after `EnterPlanMode`. I also ran `acceptEdits/0/*` and `default/0/*`, which round 1 didn't rerun. They match the README table: `acceptEdits` runs `NotebookEdit` and `Edit` and asks for `Write` to `.claude/`, `Bash` and `WebFetch`. `default` asks for all five. In every mode `EnterPlanMode` runs without a request, and `AskUserQuestion` is not offered to a client without forms.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/claudeacp!10
No description provided.