fix(hooks): pass expectedEventName so a mismatched hookSpecificOutput block is discarded

Wire the bridges to the codec's new discriminator check (merged down from
dsh-hook-protocol): each bridge passes its firing `point` as `expectedEventName`
to runHook, so a hook whose `hookSpecificOutput.hookEventName` names a different
event has its event-scoped fields discarded. Bridge-level guard test: a
PreToolUse hook emitting a UserPromptSubmit-labeled deny no longer denies the
tool (proven red without the wiring, then reverted).
This commit is contained in:
Tianyi Cui
2026-07-01 10:56:34 +08:00
parent 5304d4ef29
commit 253eded47b
3 changed files with 21 additions and 0 deletions

View File

@@ -141,6 +141,9 @@ export function apply(ctx: Context, config: Config): void {
...opts.signal ? { signal: opts.signal } : {},
defaultTimeoutMs,
trailingNewline: true,
// Discard a `hookSpecificOutput` block whose `hookEventName` names a
// different event than the one firing (the schemas key it by event).
expectedEventName: point,
}, () => performance.now())
outputs.push(output)
if (output.updatedInput !== undefined) {