Repository navigation
fix(hooks): gate 'ask' verdict emits a real Claude ask prompt, not a hard deny (#111) - #117
Merged
Merged
Conversation
…hard deny (#111) The #106 gate wiring put the Tirith defence-in-depth gate on the live `hook claude` path. When a gate returned `GateDecision::Ask` for a command with no contextcrawler rewrite (e.g. a credential-bearing `curl` loop), the no-rewrite branch fell through to a hard `PayloadAction::Deny` — an "ask" the user could never answer. Real users hit this in REST-verification workflows. The Claude Code PreToolUse protocol supports `permissionDecision` values of `allow`, `deny`, and `ask` (the existing `handle_vscode` path already emits `ask`). This change routes a gate `Ask` + non-rewritable command to a real `ask` decision so the user gets an approve/deny prompt. - Add `PayloadAction::Ask { reason, audit_tag, cmd }` mirroring `Deny`. - Add `emit_claude_ask` alongside `emit_claude_deny`; same JSON schema, `permissionDecision: "ask"`. - `run_claude` gains an `Ask` arm; `run_claude_inner` mirrors it. - The `gate_no_rewrite` branch now returns `Ask` (audit tag `ask:gate_no_rewrite`) instead of `Deny`; stderr line reworded. - A supply-chain hard `Block` (`GateDecision::Deny`) still routes through `Deny` — a real hard-block stays a deny. - Gate decision is now injectable via `process_claude_payload_with_gate` so the no-rewrite Ask path is deterministically testable. Tests: gate `Ask` + non-rewritable command yields the `Ask` action / `ask` JSON; gate `Ask` + rewritable command still rewrites; supply-chain `Block` still denies. cargo test --workspace and clippy --workspace --release pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Closed
8 tasks done
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
Fixes a real user-reported regression. The #106 gate-wiring turned a gate Ask verdict into a hard Deny for any command with no contextcrawler rewrite (
gate_no_rewrite) — an "ask" the user could never answer. It silently blocked credential-bearingcurlloops in a REST-verification workflow.Fix
A gate
Askverdict now emits a real Claude Codeaskpermission decision so the user gets an approve/deny prompt — instead of a hard deny.hookSpecificOutput.permissionDecisionacceptsallow/deny/ask(thehandle_vscodepath already emitsask).PayloadAction::Ask { reason, audit_tag, cmd }+emit_claude_ask(reason)— byte-identical JSON toemit_claude_deny, only the decision value differs.gate_no_rewritearm now returnsPayloadAction::Ask(audit tagask:gate_no_rewrite) instead ofDeny; the stderr helper reworded from "denying" to "prompting the user".Block→Deny, permission-rule deny, malformed-payload deny — a genuine hard block still hard-denies.Test plan
cargo test --workspace— 13 suites, 0 fail; newtest_gate_ask_no_rewrite_is_ask_action,test_gate_ask_emits_ask_json,test_gate_ask_with_rewrite_still_rewrites,test_gate_deny_still_deniescargo clippy --workspace --releasecleanaskcan't become auto-allow; hard denies untouched)Part of the #111 audit.
🤖 Generated with Claude Code