test(kernel/notification): pin push_notification routing for health_check_failed#3222
Merged
Merged
Conversation
…heck_failed Follow-up for #3218 — locks the global-fallback match arm so a future refactor cannot silently disable heartbeat alerts. Adds four pure routing tests against LibreFangKernel::push_notification: - health_check_failed falls back to alert_channels when no agent_rule matches - a matching agent_rule overrides alert_channels - no configured targets produce zero sends (silent, not panicking) - unknown event_type yields zero sends (typo guard — never page on unrecognized event_type) Reuses the RecordingChannelAdapter pattern already used by test_notify_escalated_approval_prefers_request_route_to. No production code changes.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #3218 (review feedback): adds regression tests pinning the global-fallback match arm in
LibreFangKernel::push_notificationso a future refactor cannot silently disable heartbeat alerts. No production code changes.Per CLAUDE.md "always write integration tests at the injection site" — the parent PR wired
health_check_failedintonotification.alert_channelsvia a one-line match arm extension; this PR locks the contract.What's covered
Four tests, all calling
LibreFangKernel::push_notificationdirectly with aRecordingChannelAdapter(pattern lifted fromtest_notify_escalated_approval_prefers_request_route_to):health_check_failedfalls back toalert_channelswhen noagent_rulematches — the core wiring from feat(kernel/heartbeat): deliver HealthCheckFailed to notification.alert_channels #3218.agent_ruleoverridesalert_channels— pins routing precedence so per-agent overrides can't be regressed by future global-fallback edits.[notification.alert_channels]at all.event_typeyields zero targets — a typo inevent_typemust never accidentally page operators via the global fallback.Why this shape
push_notificationis a private async method, but the resolver logic (agent_rulesmatch → fallback to event-type-keyed global channels) is a pure routing decision over(NotificationConfig, agent_id, event_type). Driving the real method end-to-end through a recording adapter gives us the same lock without extracting a free function — and matches howtest_notify_escalated_approval_prefers_request_route_toalready pins approval routing.Out of scope (separate follow-ups)
docs/configuration/core/page.mdx[notification]section uses old field names (kind/target/agent/targets) vs the actual schema (channel_type/recipient/agent_pattern/channels/events), andhealth_check_failedisn't enumerated as a valideventsentry. Worth a separate docs-only PR.Test plan
cargo test -p librefang-kernel --lib kernel::tests::test_push_notification— 4 passed.cargo clippy -p librefang-kernel --lib --tests -- -D warnings— clean.