Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Phase 1] Webhook Infrastructure & Delivery Guarantees</issue_title>
<issue_description>## Priority: P0 (Critical)
Phase: 1 - E-Commerce Core
Estimate: 3 days
Type: Story

Context

Provide outbound webhooks for key domain events (order.created, payment.completed, inventory.low, product.updated) with retry, idempotency, signature verification, and delivery metrics.

Scope

  • WebhookEndpoint (id, organizationId, url, secret, active, eventTypes[], failureCount, lastSuccessAt)
  • WebhookDelivery (id, endpointId, eventType, status, attempt, responseCode, nextAttemptAt, createdAt)
  • Event dispatcher utility invoked post-transaction commit
  • Retry policy: exponential backoff (1m, 5m, 30m, 2h, 24h) max 6 attempts
  • HMAC signature header X-StormCom-Signature (SHA-256 using secret + body)
  • Delivery filtering by subscribed event types

Acceptance Criteria

  • Endpoint can subscribe to subset of events
  • Failed delivery retried per schedule until success or max attempts
  • Idempotent: same event sent once per endpoint (no duplicates) unless retried
  • Signature verified by consumer example script (documented)
  • Metrics: delivery.success.count, delivery.failure.count, delivery.latency.p95
  • Admin can deactivate endpoint preventing future dispatch

Data Model (Draft)

model WebhookEndpoint {
  id             String    @id @default(cuid())
  organizationId String
  url            String
  secret         String
  eventTypes     String[] // Postgres text[] later
  active         Boolean   @default(true)
  failureCount   Int       @default(0)
  lastSuccessAt  DateTime?
  createdAt      DateTime  @default(now())
  updatedAt      DateTime  @updatedAt

  @@index([organizationId])
}

model WebhookDelivery {
  id           String   @id @default(cuid())
  endpointId   String
  eventType    String
  status       DeliveryStatus @default(PENDING)
  attempt      Int      @default(1)
  responseCode Int?
  nextAttemptAt DateTime?
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt

  @@index([endpointId])
  @@index([status])
}

enum DeliveryStatus {
  PENDING
  SUCCESS
  FAILED
  RETRYING
  ABANDONED
}

Dependencies

Metrics Targets

  • Successful first-attempt rate > 95%
  • Average delivery latency < 2s

Testing Checklist

  • Mock endpoint receives order.created with valid signature
  • Failure sequence triggers scheduled retries
  • Deactivated endpoint receives no events

Risk

External integration reliability & partner trust (score: 16). Foundation for ecosystem expansion.

References

  • docs/GITHUB_ISSUES_COMPARISON_ANALYSIS.md (webhook gap section)
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Nov 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
stormcomui Ready Ready Preview Comment Nov 25, 2025 2:41am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Phase 1] Webhook Infrastructure & Delivery Guarantees

2 participants