feat(store): durable webhook deliveries with X-GitHub-Delivery idempotency (#2 phase 1)#44
Merged
Merged
Conversation
…tency (#2 phase 1) New crates/store crate: embedded SQLite (rusqlite, WAL, user_version migrations) holding webhook_deliveries, tasks, and task_attempts per docs/durable-task-store.md. The webhook route now records every delivery — and its routing outcome — atomically BEFORE GitHub hears success: - X-GitHub-Delivery is required (400 without it); it is the idempotency key - redelivered ids answer 200 {duplicate:true} and never dispatch twice - routed tasks get a durable queued row (with superseded tombstones for older queued reviews of the same PR); ping/unroutable deliveries are recorded as ignored:<reason> - a store failure answers 500 so GitHub retries instead of losing work [storage] config with doctor checks; compose gains a data volume; the demo gains an Act 1b proving redelivery dedup end to end (21 assertions); the smoke script covers the missing-delivery-id 400. Worker dispatch still rides the in-process channel in this phase; durable claims, restart recovery, and retirement of the in-memory task store land in phase 2. Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Implements phase 1 of issue #2’s durable-task-store design by introducing a new SQLite-backed store and wiring webhook handling to persist + deduplicate deliveries by X-GitHub-Delivery before responding success.
Changes:
- Add
crates/store(rusqlite + WAL + migrations viaPRAGMA user_version) to persist webhook deliveries and routed tasks. - Update webhook route to require
X-GitHub-Delivery, record routing outcomes durably, and short-circuit redeliveries as duplicates. - Add
[storage] pathconfig surface + doctor diagnostics, and update demo/compose/smoke scripts + docs to reflect the new durable store.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| scripts/smoke-webhook.sh | Extends smoke script to assert 400 on missing X-GitHub-Delivery. |
| README.md | Updates feature matrix to mark durable queue/store as Partial with phase-1 semantics. |
| examples/demo/run-demo.sh | Adds durable store config and demonstrates webhook redelivery dedup in the demo loop. |
| docs/durable-task-store.md | Marks the design as accepted and notes phase 1 implemented. |
| docs/demo.md | Documents the new demo “Act 1b” redelivery assertion. |
| crates/worker/src/lib.rs | Updates test config builders to include default storage config. |
| crates/webhook/src/routes.rs | Requires X-GitHub-Delivery; persists deliveries/tasks; adds idempotency tests. |
| crates/webhook/Cargo.toml | Adds dependency on coven-github-store. |
| crates/store/src/lib.rs | New durable SQLite store implementation + migrations + store unit tests. |
| crates/store/Cargo.toml | New crate manifest for the store. |
| crates/server/src/main.rs | Opens the durable store at startup and injects it into webhook state. |
| crates/server/Cargo.toml | Adds dependency on coven-github-store. |
| crates/config/src/lib.rs | Adds [storage] config + default path + doctor diagnostics. |
| config/example.toml | Documents the new [storage] configuration section. |
| compose.yaml | Adds a named volume for durable /data storage. |
| Cargo.toml | Adds the new crate to the workspace and adds workspace rusqlite dependency. |
| Cargo.lock | Locks new transitive dependencies for rusqlite/store crate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+181
to
+185
| if state.task_tx.try_send(task).is_err() { | ||
| warn!(task_id, "task queue full — dropping task"); | ||
| } else { | ||
| info!(task_id, "task enqueued"); | ||
| } |
This was referenced Jul 7, 2026
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.
Phase 1 of the durable task store (design, merged in #43) — refs #2.
What lands
New
crates/store— embedded SQLite viarusqlite(bundled, WAL,busy_timeout, foreign keys, forward-only migrations tracked byPRAGMA user_version). One writer connection behind a mutex; every async entry point hops throughspawn_blocking. Schema:webhook_deliveries,tasks,task_attemptsexactly as designed.Persist-then-ack webhook handling:
X-GitHub-Deliveryis now required — 400 without it (it's the idempotency key; a caller without one is not GitHub)200 {"ok":true,"duplicate":true}, nothing dispatched, original routing standsqueuedreviews of the same PR (supersede_key) in the same transactionignored:<reason>Operational surface:
[storage] pathconfig (+ doctor checks: error if the path is a directory, warning pointing at the volume that must persist), composecoven-datavolume, example config section.Phase discipline
Worker dispatch still rides the in-process channel in this PR, exactly as the design's phase 1 prescribes. Durable claims, restart recovery, and retiring the in-memory
TaskStoreare phase 2.Verification
cargo check/clippy -D warnings/test --all/ python gates greenX-GitHub-Deliveryid redelivered after the full loop → zero additional GitHub API calls, no second Check Run/session/PR — 21/21 assertions green through the real binaryscripts/smoke-webhook.shgains the missing-delivery-id 400 check