Under claudeacp in dontAsk no call has been denied yet: show what the mode denies, and which side decides #10
No reviewers
Labels
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/claudeacp!10
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/claudeacp-fp7"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 indontAsk,acceptEditsanddefault; 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, againstclaudetest/fakeapiplaying the model (one tool call per session, nothing spent), with a freshHOME/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 (
NotebookEditon a notebook the session read):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 getspendingthenfailedwithPermission denied: Permission to use NotebookEdit has been denied because Claude Code is running in don't ask mode….session/request_permission(allow-once,reject); on refusal the model getsThe user refused permission to run the tool.NotebookEditrun;Writeto.claude/,BashandWebFetchask, as indefault.From the code: claudeacp starts claude with
--permission-prompt-tool=stdio; acan_use_toolgoes to the client and the client's pick is the answer (claudeacp/permission.go,claudeagent/permission.go). claudeacp allows nothing itself, itsPreToolUsehook returns no decision, and a client that cannot answer has the call denied. IndontAskclaude sends nocan_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-proberan because the bareBashallow 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 onlyBash(echo *)allowed.NotebookEdit, in no rule, is denied (dontAsk/1/NotebookEdit).Writeto.claude/is denied even withWriteallowed (protected path);acceptEditsanddefaultask there.What a deny rule adds
It wins over an allow rule, in every mode:
Bashallowed +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. Anaskrule is a denial indontAsk.Not stopped by dontAsk (documented, not changed)
EnterPlanModeran in all three modes with no request.ExitPlanModethen reaches the client with Auto / accept edits / ask before edits: none isdontAsk, and the agent's mode list has nodontAskeither. So a session leavesdontAskif the client approves. This is the client's decision, so I did not treat it as a defect; say if you wantExitPlanModeto restore the starting mode.Changes
claudeacp/modes_e2e_unix_test.go: the gated recorder, which also asserts thedontAskoutcomes 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
Review of
58b36942ccfor claudeacp-fp7. Checks of the head: success.Verdict
fail
Findings
TestPermissionNotAnsweredIsDenieddoesn't test its claim. It passes when an unanswered or failed request is allowed. I changed the first branch ofpermissionResult(claudeacp/permission.go:131-132) to returnclaudeagent.Allow{Classification: claudeagent.UserTemporary}and both subtests still passed. Theanswers(...)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 awaystopReason(...).startWithnever reads the fake'sErr(). 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 checkif 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 withexpect {... "behavior":"deny" ...}: got {... "behavior":"allow" ...}. Asserting the stop reason as well would make it stronger still.outcome()reportsranfor any result that isn't a permission denial, tool errors included.dontAsk/1/ExitPlanModecomes outranwith "You are not in plan mode…" (is_error=true), anddontAsk/1/WebFetchwith "connect ECONNREFUSED 127.0.0.1:1". The permission did pass, so the asserted outcomes hold, butpermitted(or a separateran, the tool failed) would say what is meant.AskUserQuestionunderdontAskcomes 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 ondontAskloses the question form. That deserves a line in the list of what a city can rely on.Verified
main.mainhas no REVIEW.md, AGENTS.md or CLAUDE.md.d4a5f8a): fast-forward, clean.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.permissionResultdenies, with interrupt, when the client returns an error or no selection, andpreToolUse(claudeacp/running.go:42-49) always returns an emptyHookOutput.TestPreToolUseDecidesNothingdoes check that, throughreflect.DeepEqual.CLAUDEACP_E2E_CLAUDE=1) fordontAsk/1/*(the city's allow list),dontAsk/2/BashanddontAsk/4/Bash: all pass. The client is asked nothing exceptExitPlanModeafterEnterPlanMode.NotebookEditandWriteto.claude/are denied by the mode,echo x > ~/proberuns under the bareBash, the deny rule wins with "Permission to use Bash with command echo x > … has been denied.", andBash(echo *)alone is denied by the mode. These match the PR and the README. TheacceptEditsanddefaultrows were not rerun.Review of
59340040e1for claudeacp-fp7 (round 2, after the request for changes on58b3694). Checks of the head: success.Verdict
pass
Findings
modeCallsnow has 11 calls, and the form-takingAskUserQuestioncall runs only indontAsk. It also doesn't mention thatAskUserQuestionis lost ondontAsk, 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
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 checksf.Err(). I applied the round-1 mutation again: the first branch ofpermissionResult(claudeacp/permission.go:131-132) returnsclaudeagent.Allow{Classification: claudeagent.UserTemporary}. Both subtests now fail, on two counts: the prompt ends with "The Claude process exited unexpectedly", andexpect {..."behavior":"deny"...}: got {..."behavior":"allow"...}. Without the mutation they pass.outcome()hasoutFailed("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.AskUserQuestionline.dontAskWantpins both cases:1/AskUserQuestionis 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
main(4 files, +440) and the round-2 delta (+40/−9).mainhas no REVIEW.md, AGENTS.md or CLAUDE.md.d4a5f8a) is a fast-forward, clean.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.CLAUDEACP_E2E_CLAUDE=1, fake API, no model call): all 55dontAsk/*subtests pass, and the client is asked nothing exceptExitPlanModeafterEnterPlanMode. I also ranacceptEdits/0/*anddefault/0/*, which round 1 didn't rerun. They match the README table:acceptEditsrunsNotebookEditandEditand asks forWriteto.claude/,BashandWebFetch.defaultasks for all five. In every modeEnterPlanModeruns without a request, andAskUserQuestionis not offered to a client without forms.