# Hook dispatch and extension protocol semantics Status: accepted ## Context Lens, MCP and extensions all plug into the event bus, and extensions are untrusted external processes. ## Decision - Hooks run in registration order; the first `Block` wins; a `Mutate` is visible to later hooks. - Bus clones share the hook list, so the permission bridge can emit on the agent's bus. - Extensions speak newline-delimited JSON-RPC 2.0 over stdio: `initialize {protocolVersion, cwd}` returns subscribed event types and tools; `event {event}` returns `{action: continue|block|mutate|inject, ...}`; `tool/call {name, args}` returns `{content, is_error}`. - A dead or slow extension never blocks the agent: errors and timeouts count as `continue`. ## Consequences Ordering matters for hook authors; failing extensions degrade silently to no-ops. Code: crates/hx-core/src/hook.rs (`Bus`, dispatch), crates/hx-core/src/ext.rs (module)