feat: Add --claim flag to bd update for work queue semantics (gt-il2p7)

Adds atomic claim operation for work queue messages:

- New --claim flag on bd update command
- Sets assignee to claimer and status to in_progress
- Fails with clear error if already claimed by someone else
- Works in both daemon and direct modes
- Includes comprehensive tests for claim functionality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-30 10:41:51 -08:00
parent cf4aff1cb4
commit 9cc385debc
4 changed files with 253 additions and 2 deletions

View File

@@ -468,9 +468,32 @@ func (s *Server) handleUpdate(req *Request) Response {
}
}
updates := updatesFromArgs(updateArgs)
actor := s.reqActor(req)
// Handle claim operation atomically
if updateArgs.Claim {
// Check if already claimed (has non-empty assignee)
if issue.Assignee != "" {
return Response{
Success: false,
Error: fmt.Sprintf("already claimed by %s", issue.Assignee),
}
}
// Atomically set assignee and status
claimUpdates := map[string]interface{}{
"assignee": actor,
"status": "in_progress",
}
if err := store.UpdateIssue(ctx, updateArgs.ID, claimUpdates, actor); err != nil {
return Response{
Success: false,
Error: fmt.Sprintf("failed to claim issue: %v", err),
}
}
}
updates := updatesFromArgs(updateArgs)
// Apply regular field updates if any
if len(updates) > 0 {
if err := store.UpdateIssue(ctx, updateArgs.ID, updates, actor); err != nil {