Skip to content

fix(chat): register permission prompts before slow broker work - #84

Merged
vishr merged 1 commit into
mainfrom
fix/permission-hook-flake
Oct 30, 2026
Merged

vishr merged 1 commit into
mainfrom
fix/permission-hook-flake

Conversation

@vishr

@vishr vishr commented Oct 30, 2026

Copy link
Copy Markdown
Member

What changed

The Claude permission hook no longer drops a prompt when the Driga broker answers slowly. It now connects with chat.DialHook, which keeps the socket ownership checks and the client token but skips the separate /health round trip, and sends its authenticated request first. Other clients still use the health check.

Why

promptBroker gave chat.Dial 200 ms, and that included an authenticated /health round trip. On a loaded machine, or a slow Windows CI runner, the deadline expired before the hook ever registered. The hook then exited quietly and fell back to the terminal, so Driga never saw a real permission prompt. This made TestPermissionHookBuiltBinary fail on Windows in 2 of 3 runs after #80, including the v2026.10.23-alpha release check. The reporting Mac runs at load 50 to 100, where the same drop can happen to real prompts. Raising the timeout was rejected: the time went to a preflight that adds nothing a registered request does not already prove.

Risk and rollout

None beyond the hook's connect path. Fail-open is unchanged: with no broker, the hook still leaves the prompt to the terminal.

Contract changes

None

Verified

  • New TestHookRegistersWithSlowBroker serves the real broker handler on a private Unix socket on every platform, blocks /health, and delays /hook-prompt by 300 ms. It failed before the fix with hook did not register prompt: ... /health: context deadline exceeded, and now passes.
  • go test ./internal/chat (345 tests), also with TZ=UTC. All TestPermissionHookBuiltBinary subtests pass on macOS; the only failure is the pre-existing TempDir cleanup permission error on this Mac.
  • go vet for native, Linux and Windows.
  • I have accepted the CLA, or will when the bot asks on my first pull request.

https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4

Permission hooks used a 200 ms dial context for an authenticated health
round trip before registering their prompt. A slow response silently
returned the hook to the terminal without Driga ever seeing the request.

Prepare hook clients without that preflight and make registration the
first authenticated request. Keep socket validation, token checks,
bounded request lifetimes and fail-open behavior. General clients still
check broker health before use.

Add a deterministic cross-platform socket test that blocks health and
delays registration beyond the old preflight budget, then verifies prompt
visibility and an allow decision. The test fails with the original dial.

Claude-Session: https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4
@vishr
vishr merged commit 2249d3a into main Oct 30, 2026
7 checks passed
@vishr
vishr deleted the fix/permission-hook-flake branch October 30, 2026 19:35
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