fix: make isMilestoneReadyNotification metadata-authoritative

When metadata is present, skip the text fallback entirely — the emitter
declared the event kind explicitly and the regex should not override it.
Add regression test file covering all acceptance criteria: metadata-first
classification, legacy fallback, dedupe_key dedup, and the key invariant
that automated notices cannot produce terminal/blocked signals.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-01 23:08:55 +02:00
parent a055b3adf2
commit 10936277a5

View file

@ -174,10 +174,13 @@ export function isMilestoneReadyNotification(
): boolean {
if (event.type !== "extension_ui_request" || event.method !== "notify")
return false;
// Structured: approval_request+blocking is the milestone-ready signal.
const meta = getEventMetadata(event);
if (meta?.kind === "approval_request" && meta.blocking === true) return true;
// Fallback: legacy text heuristics.
if (meta !== undefined) {
// Metadata present: it is the authoritative source. Do not fall back to
// text matching — the emitter declared the event kind explicitly.
return meta.kind === "approval_request" && meta.blocking === true;
}
// No metadata — fall back to legacy text heuristics.
return isMilestoneReadyText(String(event.message ?? ""));
}