Skip to content

feat(cli): add the outbound webhook sender - #927

Merged
ajianaz merged 1 commit into
developfrom
feat/webhook-sender
Nov 18, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/webhook-sender

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 4b of #911: webhook_out::send::drain_pass, one drain pass over the outbox. Nothing calls it yet; the tick wiring and the tole serve sender thread follow in separate PRs.

Why

This is the piece that signs and sends. It reads a file other processes of the same account can write, so what it may sign is bounded by the loaded config, not by the file. It is split from the store (#926, merged) and from the wiring to keep each PR small for review.

Changes

  • drain_pass: leases at most one due event per destination under try_lock (a second drainer does nothing), sends with no lock held, appends the result under a short lock.
  • Before every send the line is re-validated and the destination is taken from the loaded map. The key comes from the key source that destination names, read again per attempt, and is not read at all for a line that fails validation.
  • A result line and its terminal line are one write, so no other drainer sees the event unleased and due in between. A send must end inside its lease.
  • Retry on connect/TLS/DNS/timeout, 5xx, 408 and 429: 2 s, 10 s, 30 s, 2 min, then 5 min steps with +/- 20 % jitter (a hash of the id, no random source) until the 6 h deadline. Retry-After on 429/503 raises the wait, capped at 10 min. No retry on another 4xx, a redirect or a refused address.
  • Result codes are a closed set (http_<status>, timeout, dns, refused_address, redirect_refused, bad_destination, expired, bad_line). Nothing a receiver says is stored or printed; Debug of a reply and of a leased event hides it.
  • The network (Poster), the key source (Keys) and the clock are injected; NetPoster is tole_core::web::vetted_post.
  • The design note lists the extra result codes and the forged-enqueue residual. CHANGELOG entry.

Testing

  • 22 new tests: a signed 2xx send checked against the native v2 signature, 500 then 200 (same id and body, new timestamp and signature), 4xx and policy refusals are final, transient errors retry, a missing key sends nothing, one event per destination per pass, a leased event is not sent by a second drainer, including a poster that plays the second drainer during the send, lock contention, expiry, forged lines (other destination, unlisted event type, wrong id, from the future, not JSON, oversized) never signed, the key resolver never called for a forged line, a forged attempt count of u32::MAX, adjacency of the result and terminal lines, a send that could outlive its lease is not started, no secret or URL in the outbox or a settled row, and the retry and classification tables.
  • Full cargo test -p tole-cli passes, clippy clean, layering test passes.
  • Independent read-only review of the combined store and sender: two major findings (a double-send window and an unbounded read; the second was fixed in feat(cli): add the outbound webhook outbox store #926) and minor ones, all applied.

Part 4b of #911. webhook_out::send::drain_pass leases one due event per
destination through the store, sends with no lock held, and appends the
result under a short lock.

Before every send the line is re-validated against the destination of the
loaded config and signed with the key that destination names, so a
forged line cannot choose a destination, an event type or a key, and the
key is not read for a line that fails validation. A result line and its
terminal line are one write, and a send must end inside its lease.

Retry and no-retry follow the design; result codes are a closed set and
no receiver text is stored or printed. The network, the key source and
the clock are injected.

Nothing calls it yet.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 1072eb6 into develop Nov 18, 2026
23 checks passed
@ajianaz
ajianaz deleted the feat/webhook-sender branch November 20, 2026 08:38
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