feat: DO-backed webhook workflow - thread-safe, stateful, topic-separated#45
Draft
brendadeeznuts1111 wants to merge 1 commit intomainfrom
Draft
feat: DO-backed webhook workflow - thread-safe, stateful, topic-separated#45brendadeeznuts1111 wants to merge 1 commit intomainfrom
brendadeeznuts1111 wants to merge 1 commit intomainfrom
Conversation
Complete end-to-end workflow for deploying Durable Object-backed GitHub webhooks using ./tgk wrapper. Includes: - Prerequisites (topic IDs, GitHub webhook setup) - Three artefacts (DO class, worker entry, IaC patch) - Step-by-step workflow (7 phases from zero to prod) - Concurrency testing with thread-safety verification - Production promotion with zero downtime - Observability commands for monitoring - Rollback procedures for emergency reversion Key Benefits: - Thread-safe via DO single-threading guarantees - Stateful (persists pinned message IDs across requests) - Topic-separated (different DO instances per stream) - Zero downtime deployments via stage promotion - CLI-wrapped (no raw wrangler/cf commands needed) - Reuses existing stage/profile/scope mechanics Builds on existing infrastructure: - telegram-worker-clean branch (merged) - webhook template in templates/worker/github-webhook/ - tgk CLI enhancements - bootstrap-stream.sh automation References: - #42 (AlchemistOrgDoc v2.0 merged) - #43 (Profile enhancements) - #44 (Scope enhancements) - Related branches: telegram-worker-clean (merged), telegram (diverged)
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
brendadeeznuts1111
pushed a commit
that referenced
this pull request
Oct 27, 2025
Add formal RFC for implementing DO-backed webhooks with thread-safety guarantees. **Problem:** Two concurrent GitHub events can overwrite each other's pinned Telegram status cards in forum topics. **Solution:** - One Durable Object class per forum topic (DO id = gh_agent_<stream>) - DO state: pinnedMsgId (single key-value pair) - Worker forwards to DO stub with atomic single-threaded execution - Maintains existing tgk CLI, stage, profile, scope mechanics **Implementation:** - 40-line diff across 3 files - DO class (≤80 LOC) in src/do/github-agent.ts - Worker entry updates in workers/github-webhook/ - Alchemy IaC binding block in alchemy.run.ts **Benefits:** - Thread-safe: Single-threaded DO execution eliminates race conditions - Stateful: Persistent pinned message IDs across deployments - Topic-separated: Different streams use different DO instances - Back-compatible: Zero breaking changes to existing mechanics - Cost-effective: <50 bytes storage, billed only when active **Roll-out:** 1. Land DO class (≤80 LOC) 2. Add DO binding + Worker deploy 3. Insert DO forwarding in webhook worker 4. Confirm topic slugs match DO ids 5. Destroy old stateless worker Refs #45 (DO-backed webhook workflow PR)
5 tasks
brendadeeznuts1111
added a commit
that referenced
this pull request
Oct 27, 2025
* feat: implement DO-backed webhook workflow Complete end-to-end workflow for deploying Durable Object-backed GitHub webhooks using ./tgk wrapper. Includes: - Prerequisites (topic IDs, GitHub webhook setup) - Three artefacts (DO class, worker entry, IaC patch) - Step-by-step workflow (7 phases from zero to prod) - Concurrency testing with thread-safety verification - Production promotion with zero downtime - Observability commands for monitoring - Rollback procedures for emergency reversion Key Benefits: - Thread-safe via DO single-threading guarantees - Stateful (persists pinned message IDs across requests) - Topic-separated (different DO instances per stream) - Zero downtime deployments via stage promotion - CLI-wrapped (no raw wrangler/cf commands needed) - Reuses existing stage/profile/scope mechanics Builds on existing infrastructure: - telegram-worker-clean branch (merged) - webhook template in templates/worker/github-webhook/ - tgk CLI enhancements - bootstrap-stream.sh automation References: - #42 (AlchemistOrgDoc v2.0 merged) - #43 (Profile enhancements) - #44 (Scope enhancements) - Related branches: telegram-worker-clean (merged), telegram (diverged) * feat: add micro-rfc-005 - Thread-Safe Forum State with Durable Objects Add formal RFC for implementing DO-backed webhooks with thread-safety guarantees. **Problem:** Two concurrent GitHub events can overwrite each other's pinned Telegram status cards in forum topics. **Solution:** - One Durable Object class per forum topic (DO id = gh_agent_<stream>) - DO state: pinnedMsgId (single key-value pair) - Worker forwards to DO stub with atomic single-threaded execution - Maintains existing tgk CLI, stage, profile, scope mechanics **Implementation:** - 40-line diff across 3 files - DO class (≤80 LOC) in src/do/github-agent.ts - Worker entry updates in workers/github-webhook/ - Alchemy IaC binding block in alchemy.run.ts **Benefits:** - Thread-safe: Single-threaded DO execution eliminates race conditions - Stateful: Persistent pinned message IDs across deployments - Topic-separated: Different streams use different DO instances - Back-compatible: Zero breaking changes to existing mechanics - Cost-effective: <50 bytes storage, billed only when active **Roll-out:** 1. Land DO class (≤80 LOC) 2. Add DO binding + Worker deploy 3. Insert DO forwarding in webhook worker 4. Confirm topic slugs match DO ids 5. Destroy old stateless worker Refs #45 (DO-backed webhook workflow PR) --------- Co-authored-by: Brenda Willams <brenda.williams@example.com>
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.
🎯 Purpose
Implements complete DO-backed webhook workflow for thread-safe, stateful GitHub webhooks.
Problem:
Solution:
📋 Changes
🏗️ Implementation
DO Class (
src/do/github-agent.ts)Worker Entry (
workers/github-webhook/index.ts)Alchemy IaC (
alchemy.run.tspatch)🚀 Workflow
7-Step Terminal Session:
./tgk stage createfor feature branch./tgk deploy(atomic transaction)./tgk stage promoteto production./tgk logsfor observability🔧 CLI Enhancements
New tgk Commands:
./tgk stage create <name>- Create branch + stage./tgk deploy- Deploy with wrapper./tgk hook simulate <stream> --pr <num> --action <type>- Test concurrency./tgk stage promote <from> <to>- Zero downtime promotion./tgk logs worker <name> --stage <stage> --follow- Observability🧪 Testing
Concurrency Test:
Production Promotion:
pr-003→prod)✅ Pre-Submission Checklist
📚 Documentation
Added:
docs/do-webhook-workflow.md🔗 Related
Builds on:
References branches:
main(current production)telegram-worker-clean(merged to main)telegram(diverged, contains some related work)👥 Reviewers
Infrastructure Team: @brendadeeznuts1111
Department: Infrastructure
Type: Feature
Component: Worker, Webhook, DO
📊 Impact
Thread-Safety: Eliminates webhook race conditions
Statefulness: Persistent pinned messages across deployments
Topic Separation: Stream-specific DO instances
CLI Experience: Never leave ./tgk wrapper
Zero Downtime: Production deployments without interruption
Ready to review and merge! 🚀