FEATURE: Add the Cloudflare Queues worker boundary - #33
bmdavis419 wants to merge 3 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (14)
Included review availability: This review used your included allowance. 6 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour. 📝 WalkthroughWalkthroughThis change adds typed background jobs, queue producer and consumer services, an authenticated endpoint for queue batches, and Cloudflare queue configuration. The consumer validates job bodies and returns per-message acknowledgment or retry decisions. Queue setup and operation are documented. ChangesBackground Job Queue
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The queue foundation does not currently redirect application work into the unfinished job handlers. No actionable merge-blocking issue remains after normal checks. 🚥 Pre-merge checks | ✅ 5❌ Failed checks (1 inconclusive)
✅ Passed checks (5 passed)
Comment |
31c4541 to
7efff9d
Compare
| const queueProducers = (block) => bindingNames(block.queues?.producers); | ||
| if (!sameJson(queueProducers(config), queueProducers(prod))) { | ||
| drift.push( | ||
| `queues.producers bindings: local=${JSON.stringify(queueProducers(config))} production=${JSON.stringify(queueProducers(prod))}` | ||
| ); | ||
| } |
There was a problem hiding this comment.
Check queue configuration drift
This check reduces producers to binding names and does not compare producer destinations or any consumer configuration. A production queue can therefore use a different destination, retry limit, or consumer queue while this release check reports no drift. This is non-blocking, but it removes the intended deployment safeguard and can leave jobs routed or retried differently in production.
Knowledge Base Used:
Artifacts
- The authored Node script clones the current Wrangler configuration into temporary directories, applies one queue-only mutation per run, and invokes the real drift checker; it reproduces the unchecked queue values.
- The real checker was executed against an unmodified temporary copy of the current Wrangler configuration and exited successfully with no drift.
- The real checker was executed against three temporary copies differing only in a producer destination, consumer retry setting, or consumer destination, and it passed all three; queue configuration drift is not detected.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/check-wrangler-drift.mjs
Line: 184-189
Comment:
**Check queue configuration drift**
This check reduces producers to binding names and does not compare producer destinations or any consumer configuration. A production queue can therefore use a different destination, retry limit, or consumer queue while this release check reports no drift. This is non-blocking, but it removes the intended deployment safeguard and can leave jobs routed or retried differently in production.
**Knowledge Base Used:**
- [Runtime configuration and schema](https://app.greptile.com/davis7dotsh/-/custom-context/knowledge-base/davis7dotsh/adrive/-/docs/runtime-configuration-and-schema.md)
- [Release, backup, and safety automation](https://app.greptile.com/davis7dotsh/-/custom-context/knowledge-base/davis7dotsh/adrive/-/docs/release-backup-and-safety-automation.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.7efff9d to
d460dfd
Compare
Declares the adrive-jobs queue (producer JOBS plus consumer with a dead-letter queue) at the top level and in env.production, keeps the producer bindings covered by the drift check, and regenerates the Worker types. Adds the shared Job discriminated union and JobSchema, a JobQueue service (with a null layer) in the request layer, and a consumer that decodes each message, acks invalid bodies, and retries failed jobs. The Worker facade forwards queue batches to /api/internal/jobs in-process under an HMAC signed over the batch body, then acks or retries per message from the endpoint's decisions. No behaviour moves onto the queue yet; runJob only logs until D2/D3. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
d460dfd to
83a750a
Compare
| ); | ||
| } | ||
| } | ||
| const queueProducers = (block) => bindingNames(block.queues?.producers); |
There was a problem hiding this comment.
🟡 Medium scripts/check-wrangler-drift.mjs:184
The drift check reports no difference when a producer keeps the same binding but points to a different queue, so production jobs can be routed to the wrong queue without failing validation. queueProducers currently discards each entry's queue; include both fields when comparing producers.
| const queueProducers = (block) => bindingNames(block.queues?.producers); | |
| const queueProducers = (block) => | |
| (block.queues?.producers ?? []) | |
| .map((entry) => [entry.binding, entry.queue]) | |
| .sort(); |
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @scripts/check-wrangler-drift.mjs around line 184:
The drift check reports no difference when a producer keeps the same `binding` but points to a different `queue`, so production jobs can be routed to the wrong queue without failing validation. `queueProducers` currently discards each entry's `queue`; include both fields when comparing producers.
Add the typed Cloudflare Queues boundary: the generated Worker signs each batch, forwards it into the SvelteKit bundle, and applies per-message acknowledgment or retry decisions. Missing decisions retry; invalid jobs are acknowledged and logged. Operation handlers are connected in #36.
The internal endpoint limits streamed UTF-8 bytes before verifying the signature over the unchanged request text. Behavioral tests execute the generated facade and cover signatures, mixed decisions, missing decisions, and failed consumers.
Important files:
apps/web/scripts/cloudflare-adapter.mjs: queue entrypoint and signed forwarding.apps/web/src/lib/server/jobs/consumer.ts: typed dispatch and per-message decisions.apps/web/src/routes/api/internal/jobs/+server.ts: authenticated, bounded batch ingestion.apps/web/src/lib/server/services/jobs.tsandapps/web/wrangler.jsonc: producer service and environment bindings.Validation: TypeScript/Effect/Svelte checks; formatting; Worker build; final independent Codex review clean. Cloudflare delivery remains a deployment-time check.
Stack layer 5/12: depends on #32; followed by #34.
Note
Add Cloudflare Queues worker boundary for job delivery
JobSchemaunion (index, purge, scan, site-cleanup) and aJobQueueservice that publishes JSON jobs through theJOBSbinding (index.ts, jobs.ts).runJoblogs and acks all four job kinds without performing indexing, scanning, purging, or site-cleanup work.📊 Macroscope summarized 83a750a. 13 files reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues
The outstanding configuration-drift concern is non-blocking.
Fix with agent prompt
Summary
This PR adds a Cloudflare Queues boundary: the Worker forwards job batches to an authenticated internal endpoint and receives per-message acknowledgment or retry decisions. The existing queue-configuration drift gap remains outstanding.
Reviews (3) · Last reviewed commit: "BUGFIX: Bound queue requests before sign..."