feat: notify dispatcher when polecat work completes

When a crew or other agent dispatches work to a polecat using `gt sling`,
the polecat now tracks who dispatched the work and sends them a completion
notification when running `gt done`.

Changes:
- Add DispatchedBy field to AttachmentFields in beads/fields.go
- Store dispatcher agent ID in bead when slinging (both direct and formula)
- Check for dispatcher in done.go and send WORK_DONE notification to them

This fixes the orchestration issue where crews were left waiting because
polecats only notified the Witness on completion, not the dispatcher.

Fixes: id-c17

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nux
2026-01-02 22:24:48 -05:00
committed by cvsloane
parent 386dbf85fb
commit b8eca6c04a
3 changed files with 106 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ type AttachmentFields struct {
AttachedMolecule string // Root issue ID of the attached molecule
AttachedAt string // ISO 8601 timestamp when attached
AttachedArgs string // Natural language args passed via gt sling --args (no-tmux mode)
DispatchedBy string // Agent ID that dispatched this work (for completion notification)
}
// ParseAttachmentFields extracts attachment fields from an issue's description.
@@ -61,6 +62,9 @@ func ParseAttachmentFields(issue *Issue) *AttachmentFields {
case "attached_args", "attached-args", "attachedargs":
fields.AttachedArgs = value
hasFields = true
case "dispatched_by", "dispatched-by", "dispatchedby":
fields.DispatchedBy = value
hasFields = true
}
}
@@ -88,6 +92,9 @@ func FormatAttachmentFields(fields *AttachmentFields) string {
if fields.AttachedArgs != "" {
lines = append(lines, "attached_args: "+fields.AttachedArgs)
}
if fields.DispatchedBy != "" {
lines = append(lines, "dispatched_by: "+fields.DispatchedBy)
}
return strings.Join(lines, "\n")
}
@@ -107,6 +114,9 @@ func SetAttachmentFields(issue *Issue, fields *AttachmentFields) string {
"attached_args": true,
"attached-args": true,
"attachedargs": true,
"dispatched_by": true,
"dispatched-by": true,
"dispatchedby": true,
}
// Collect non-attachment lines from existing description