Skip to article
Daedalus Development Group
← More from this project

George Sarris (0xcircuitbreaker) · · 4 min read

From Webhook to Auditable Queue: The Icarus/Hermes Relay

A code-level look at DDG's inbound relay: source authentication, durable queueing, explicit acknowledgement, and the hardening work still open.

In this article

The problem is the boundary, not the webhook

Icarus can receive work from a storefront, source repository, payment provider, messaging channel, or another DDG service. Hermes can then run a workflow against that work. The awkward boundary is between those two moments: an inbound request may arrive while the runtime is offline, a provider may retry it, and a consumer may fail after doing the work but before acknowledging the event.

DDG's current relay is a small, inspectable bridge for that boundary. It is implemented in two Netlify Functions. The ingress function authenticates a supported source and writes an event to Netlify Blobs. A private dequeue function lets the Hermes-side worker list, fetch, and explicitly delete queued records.

That description is intentionally narrower than calling it a production message bus. The code has useful durability and audit properties, but it does not yet implement leases, automatic retries, a dead-letter queue, or exactly-once processing.

Authentication follows the source

The ingress endpoint reads the final path segment as a source. Its current allowlist includes internal, Stripe, GitHub, Shopify, email, Telegram, audit, and generic events.

Authentication is selected by that source:

  • internal, generic, email, and audit requests use a shared bearer token;
  • Stripe requests verify a v1 signature against the raw request body;
  • GitHub requests verify the SHA-256 webhook signature;
  • Shopify requests verify its base64 HMAC;
  • Telegram requests compare the secret-token header configured for the bot webhook.

The raw body matters. Re-serializing parsed JSON before HMAC verification can change bytes and invalidate an otherwise correct signature, so verification occurs against the text received by the function. Comparisons use constant-time helpers where secrets are involved.

Successful requests receive a 202 response only after the Blob write completes. Failed authentication returns 401 without enqueueing the event. Those are code-path properties, not a claim that every upstream provider is configured correctly; provider-side webhook configuration still has to be tested separately.

What the queue record contains

The event record contains its source, a millisecond receive timestamp, selected headers, the raw body, and an optional provider delivery identifier. Its key combines the timestamp, source, and random suffix. The Blob store is opened with strong consistency.

The dequeue endpoint uses the same bearer boundary as the internal ingress path. A GET lists keys, sorts them, takes at most 50, and fetches their records. Because the timestamp leads the key, that yields an oldest-first batch for the current key format. A separate DELETE acknowledges one key.

Separating fetch from delete is useful during development: an operator can see exactly which record remains pending. It also defines the failure mode. If a worker performs an external action and crashes before DELETE, the same queue record can appear again. The consumer must therefore treat delivery as at least once and make side effects idempotent, normally by retaining the provider delivery ID or another business-level deduplication key.

The random key suffix also means ingress itself does not collapse duplicate provider deliveries. A repeated webhook can become a second Blob even when both records carry the same delivery ID.

What is auditable today

For a queued item, the current system preserves the source, receipt time, selected transport metadata, and original body until acknowledgement. Operators can inspect the pending record and correlate provider delivery identifiers when the provider supplies one. Explicit deletion creates a clear handoff point between pending and acknowledged work.

This is operational traceability, not a complete compliance audit log. The queue does not by itself prove which downstream tool ran, what external system changed, who approved the action, or whether a deletion happened after a successful side effect. Those facts belong in the Icarus broker and workflow-result records.

The hardening gates

Several limits should remain visible in any production review:

  1. Redact verification material. The code comment says authentication values should not be persisted, but the current selected-header list still includes the Stripe signature and Telegram secret-token header. Those fields should be removed or transformed before this boundary carries sensitive production traffic.
  2. Define retention. Raw webhook bodies can contain customer or operational data. The implementation needs a written retention window and a cleanup path for abandoned records.
  3. Add retry and quarantine policy. Repeated failures need attempt counts, backoff, and a dead-letter or review state instead of an endlessly pending item.
  4. Use idempotency deliberately. Provider delivery IDs should feed a tested deduplication rule at the consumer and, where appropriate, at ingress.
  5. Record the downstream result. Queue acknowledgement should correlate with the workflow run, approval state, external receipts, and final disposition.
  6. Exercise failure cases. Tests should cover malformed signatures, duplicate deliveries, crashes before and after side effects, poison messages, and concurrent dequeue workers.

Why keep it small

The relay is valuable because its behavior is visible in a pair of functions and a Blob store. That makes it easier to test the boundary and replace it later if throughput or delivery guarantees require a dedicated queue.

The current evidence supports a precise claim: DDG has implemented an authenticated, durable, oldest-first queue bridge with explicit acknowledgement. It does not support claims of exactly-once delivery, complete auditability, or a production reliability target. Those stronger claims should wait for the hardening gates and failure tests above.