unified webhook event envelope + after lifecycle hooks#245
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
What this does
Unifies every outbound webhook payload into one typed event envelope (#218 follow-up) and adds the missing after-* lifecycle hook phases (#216 follow-up).
BREAKING: unified webhook event envelope
Every dispatcher delivery now serializes to:
{ "id": "evt_<uuid>", "type": "alert.triggered", "version": 1, "occurredAt": "<ISO8601>", "organizationId": "<uuid>", "projectId": "<uuid or null>", "data": { } }alert.triggered(anomalies distinguished bydata.baseline_metadata),incident.created,error.detected,monitor.status_changed,channel.notification(generic channel deliveries),channel.test.datakeeps the previous snake_case fields minusevent_type/timestamp(nowtype/occurredAton the envelope).@logtide/shared(webhookEnvelopeSchema,parseWebhookEvent); producers are schema-locked in tests.X-Logtide-Event-Version: 1header; HMAC signing unchanged, covering the serialized envelope;beforeWebhookDispatchstill mutates pre-serialization so hook changes are signed.after-* lifecycle hook phases
afterIngest(batch counts + rejection reasons, no log content; fires on every completed batch including all-rejected and hook-filtered paths),afterAlertTriggered(post-persist trigger facts, threshold and rate-of-change),afterWebhookDispatch(per delivery attempt result, queued and sync paths, fired insidedeliverOnce).Semantics: fire-and-forget (handler errors logged, never block), frozen read-only contexts,
hasHandlersguards keep the no-handler hot path at zero overhead, registration viaHOOKS_MODULESidentical to before-* phases.run()is now type-restricted to before-phases; after-phases go throughrunAfter().Docs
docs/webhooks.mdgains the envelope reference and event catalog;docs/lifecycle-hooks.mddocuments the three new phases.Tests
59 shared schema tests (round-trips and rejections for all types), envelope/dispatcher/producer assertions schema-locked via
parseWebhookEvent, 14 new after-hook tests plus call-site integration tests. Full backend suite green.