Skip to content

Refactor Slack notifications: severity-aware, human-centered format#9

Merged
justinemach merged 1 commit into
mainfrom
devin/1771897638-slack-message-refactor
Feb 24, 2026
Merged

Refactor Slack notifications: severity-aware, human-centered format#9
justinemach merged 1 commit into
mainfrom
devin/1771897638-slack-message-refactor

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Refactor Slack notifications: severity-aware, human-centered format

Summary

Replaces the flat title + bullet list + context Slack message format with a structured, severity-aware layout. Drift notifications now have 4 clearly labeled sections (Change Summary, Impact, Docs Status, Action) and a severity-colored header (🟢 Non-Breaking, 🟡 Potentially Breaking, 🔴 Breaking).

slack_notify.py was rewritten:

  • send_slack_notification() removed; replaced by send_drift_notification(DriftMessage) and send_audit_notification(title, summary, context)
  • New build_drift_message() constructs a DriftMessage dataclass from the drift report's endpoint/schema lists
  • Severity is inferred from the drift data for formatting purposes only (no detection/classification logic changed)
  • Shared _post_or_print() handles webhook posting or stdout fallback

guard.py callers updated:

  • cmd_check now passes structured report data through build_drift_message()send_drift_notification()
  • cmd_audit now uses send_audit_notification() with a calmer title (no 🚨)

Review & Testing Checklist for Human

  • Severity inference is string-match-based and fragile: infer_severity() checks for "lost field" and "gained field" substrings in schema_changes entries. These strings are generated by drift_detect.py:DriftReport.as_bullet_list(). If the wording there ever changes, severity silently falls through to POTENTIALLY_BREAKING instead of the correct level. Verify you're comfortable with this coupling, or whether severity should be a first-class property of DriftReport instead.
  • send_slack_notification() was deleted: This is a breaking API change. Confirm nothing else imports it — check CI workflow, pre-commit hook scripts, and any test files that might reference the old function name.
  • tier3_drafted is accepted but never passed as True: build_drift_message() has a tier3_drafted param but guard.py never sets it. The "Migration guidance draft added" line is unreachable. Decide whether to remove it or wire it up.
  • Audit notification tone changed: Title went from "🚨 API Call Guard: Runtime mismatches detected" to "Runtime Audit | API call mismatches detected" and the :warning: Slack emoji was dropped from context. Verify this is the tone you want for audit alerts.

Test Plan

  1. Start server: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
  2. Save baseline: python -m drift_guard.guard baseline
  3. Simulate non-breaking drift (add optional field): modify baseline to remove role field, run check, verify Slack payload shows 🟢 Non-Breaking with "No action required"
  4. Simulate breaking drift (remove endpoint): modify baseline to add fake endpoint, run check, verify Slack payload shows 🔴 Breaking with "Review required before merge"
  5. Test audit: make bad API calls, run python -m drift_guard.guard audit, verify Slack payload uses the new audit format
  6. Verify CI still passes (no import errors from removed send_slack_notification)

Notes


Open with Devin

- Replace flat title+bullets layout with structured 4-section messages:
  1) Change Summary (impacted endpoints and schema changes)
  2) Impact (what it means for clients)
  3) Docs Status (what was regenerated)
  4) Action (what the reader needs to do)
- Severity inferred from drift data: green/yellow/red circle emoji
- Header format: '{emoji} Docs Drift Guard | {Severity Label}'
- No more bell emoji, no alarmist tone for non-breaking changes
- Dedicated build_drift_message() function for deterministic output
- Separate send_drift_notification() and send_audit_notification()
- Existing webhook integration preserved

Co-Authored-By: unknown <>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@justinemach justinemach merged commit 5b53ca6 into main Feb 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant