Skip to content

fix(hooks): gate 'ask' verdict emits a real Claude ask prompt, not a hard deny (#111) - #117

Merged
thehoff merged 1 commit into
developfrom
fix/gate-ask-not-deny-111
May 20, 2026
Merged

thehoff merged 1 commit into
developfrom
fix/gate-ask-not-deny-111

Conversation

@thehoff

@thehoff thehoff commented May 20, 2026

Copy link
Copy Markdown
Owner

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-bearing curl loops in a REST-verification workflow.

Fix

A gate Ask verdict now emits a real Claude Code ask permission decision so the user gets an approve/deny prompt — instead of a hard deny.

  • Claude Code PreToolUse protocol: hookSpecificOutput.permissionDecision accepts allow/deny/ask (the handle_vscode path already emits ask).
  • New PayloadAction::Ask { reason, audit_tag, cmd } + emit_claude_ask(reason) — byte-identical JSON to emit_claude_deny, only the decision value differs.
  • The gate_no_rewrite arm now returns PayloadAction::Ask (audit tag ask:gate_no_rewrite) instead of Deny; the stderr helper reworded from "denying" to "prompting the user".
  • Unchanged: supply-chain hard Block → Deny, permission-rule deny, malformed-payload deny — a genuine hard block still hard-denies.

Test plan

  • cargo test --workspace — 13 suites, 0 fail; new test_gate_ask_no_rewrite_is_ask_action, test_gate_ask_emits_ask_json, test_gate_ask_with_rewrite_still_rewrites, test_gate_deny_still_denies
  • cargo clippy --workspace --release clean
  • Codex review — mergeable, all 6 adversarial points pass (ask JSON shape correct; no fail-open — ask can't become auto-allow; hard denies untouched)
  • Built + deployed locally ahead of merge to unblock the reporting workflow

Part of the #111 audit.

🤖 Generated with Claude Code

…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]>
@thehoff
thehoff merged commit 34093d5 into develop May 20, 2026
4 checks passed
@thehoff
thehoff deleted the fix/gate-ask-not-deny-111 branch May 20, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant