Repository navigation
fix(guild-automation): post-merge stabilization for execution and locking - #179
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for regal-bunny-0c8efe ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughThis change introduces a shared execution pipeline for guild automation's apply/reconcile flows, replacing in-memory locks with Redis token-based distributed locks, adding ID-first role/channel matching with deterministic fallback, and introducing specialized error handling for infrastructure failures. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Route as Routes/guildAutomation
participant Service as GuildAutomationExecutionService
participant Discord as Discord API
participant DB as Database
participant Redis as Redis
Client->>Route: PUT /plan or /apply or /reconcile
Note over Route: Validate request
alt actualState in body
Route->>Route: Use provided actualState
else actualState missing
Route->>Service: captureGuildAutomationState(guildId)
Service->>Discord: Fetch roles, channels, onboarding, etc.
Service->>DB: Query moderation, messages, reaction roles
Service->>Service: Transform to GuildAutomationManifestDocument
Service-->>Route: Return captured state
end
Route->>Redis: acquireLock(guildId)
alt Lock acquired
Redis-->>Route: Return token
Route->>Service: executeApplyPlan(plan, desired, actual, allowProtected)
Service->>Service: Apply onboarding module
Service->>Service: Apply roles module (ID-first matching)
Service->>Discord: Create/update/delete roles
Service->>Service: Apply channels module
Service->>Discord: Create/update/delete channels
Service->>Service: Apply moderation, messages, reaction roles
Service->>DB: Persist remapped manifest IDs
Service-->>Route: Return { diagnostics, remappedManifest }
Route->>DB: Update run with results
Route->>Redis: releaseLock(token)
else Lock unavailable
Route-->>Client: 503 Service Unavailable
end
Route-->>Client: Return run with status (completed/blocked/failed)
sequenceDiagram
participant Redis as Redis Lock
participant Service as Shared Service
Note over Redis,Service: Lock Acquisition Flow
Service->>Redis: setNxPx(key: lockKey, value: token, ttl: 30s)
alt Lock set successfully
Redis-->>Service: true
Service->>Service: Proceed with operation
else Key already exists
Redis-->>Service: false
Service-->>Service: Throw GuildAutomationLockUnavailableError
end
Note over Redis,Service: Lock Release Flow
Service->>Redis: delIfValueMatches(key: lockKey, expectedValue: token)
alt Value matches token
Redis-->>Service: true (key deleted)
else Value doesn't match or key missing
Redis-->>Service: false
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan for PR comments
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 |
|
|
…king (#179) * fix(shared): harden guild automation locks and domain errors * fix(backend): execute automation apply and reconcile mutations * refactor(bot): reduce automation apply complexity and update docs


Summary
Validation
Summary by CodeRabbit
New Features
Bug Fixes