소스 검색

docs(hook-protocol): matcher's invalid-regex handling is SILENT, not bridge-logged

Review noted the module docs promised an invalid regex is "logged by the bridge",
but matchesMatcher only returns `false` — callers cannot distinguish a genuine
non-match from a compile failure, so a typo'd pattern silently disables that
matcher with no warning. Both bridges call matchesMatcher directly, so no log
happens anywhere. Correct the docs to state the silence explicitly; surfacing bad
config would need a diagnostic-returning variant or parse-time validation, marked
TODO(matcher-diagnostics). No behavior change.
Tianyi Cui 2 달 전
부모
커밋
8f2ef9dc9b
1개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 8 3
      packages/hooks/hook-protocol/src/matcher.ts

+ 8 - 3
packages/hooks/hook-protocol/src/matcher.ts

@@ -9,8 +9,11 @@
  * - `codex`: every pattern is an unanchored regex (no literal fast path).
  * - `codex`: every pattern is an unanchored regex (no literal fast path).
  *
  *
  * Both treat an absent / empty / `'*'` pattern as match-all, and both treat an
  * Both treat an absent / empty / `'*'` pattern as match-all, and both treat an
- * invalid regex as a non-match (the bridge logs it; a broken matcher must not
- * throw into the loop).
+ * invalid regex as a non-match: a broken matcher selects nothing rather than
+ * throwing into the loop. This is SILENT — the boolean return cannot distinguish
+ * "did not match" from "failed to compile", so a typo'd pattern (e.g. `[`)
+ * quietly disables that matcher with no warning. Surfacing bad config would need
+ * a diagnostic-returning variant or parse-time validation (`TODO(matcher-diagnostics)`).
  *
  *
  * @module @deepseek-ai/dsh-hook-protocol/matcher
  * @module @deepseek-ai/dsh-hook-protocol/matcher
  */
  */
@@ -43,7 +46,9 @@ export function matchesMatcher(matcher: string | undefined, query: string, mode:
     return new RegExp(pattern).test(query)
     return new RegExp(pattern).test(query)
   } catch {
   } catch {
     // Invalid regex: a broken matcher selects nothing rather than throwing into
     // Invalid regex: a broken matcher selects nothing rather than throwing into
-    // the agent loop. The bridge is responsible for surfacing the bad config.
+    // the agent loop. This is silent — callers get `false`, indistinguishable
+    // from a genuine non-match, so a typo'd pattern quietly disables the matcher.
+    // Surfacing it needs a diagnostic-returning variant (TODO(matcher-diagnostics)).
     return false
     return false
   }
   }
 }
 }