Link MR bead to agent bead for traceability (gt-84ery)
Add bidirectional cross-references between MR beads and agent beads: 1. MRFields.AgentBead - tracks which agent created the MR 2. AgentFields.ActiveMR - tracks agent's current MR In gt done: - Include agent_bead in MR description when creating - Update agent bead with active_mr pointing to the new MR In refinery merge handling: - Clear agent bead's active_mr after successful merge Benefits: - Given MR, find which polecat created it - Given polecat, find their active MR - Orphan detection: MR without agent = stale 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
b241a353f3
commit
4a22e621a9
@@ -108,6 +108,19 @@ func runDone(cmd *cobra.Command, args []string) error {
|
||||
polecatName = parts[len(parts)-1]
|
||||
}
|
||||
|
||||
// Get agent bead ID for cross-referencing
|
||||
var agentBeadID string
|
||||
if roleInfo, err := GetRoleWithContext(cwd, townRoot); err == nil {
|
||||
ctx := RoleContext{
|
||||
Role: roleInfo.Role,
|
||||
Rig: roleInfo.Rig,
|
||||
Polecat: roleInfo.Polecat,
|
||||
TownRoot: townRoot,
|
||||
WorkDir: cwd,
|
||||
}
|
||||
agentBeadID = getAgentBeadID(ctx)
|
||||
}
|
||||
|
||||
// For COMPLETED, we need an issue ID and branch must not be main
|
||||
var mrID string
|
||||
if exitType == ExitCompleted {
|
||||
@@ -173,6 +186,9 @@ func runDone(cmd *cobra.Command, args []string) error {
|
||||
if worker != "" {
|
||||
description += fmt.Sprintf("\nworker: %s", worker)
|
||||
}
|
||||
if agentBeadID != "" {
|
||||
description += fmt.Sprintf("\nagent_bead: %s", agentBeadID)
|
||||
}
|
||||
|
||||
// Create MR bead (ephemeral wisp - will be cleaned up after merge)
|
||||
mrIssue, err := bd.Create(beads.CreateOptions{
|
||||
@@ -186,6 +202,13 @@ func runDone(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
mrID = mrIssue.ID
|
||||
|
||||
// Update agent bead with active_mr reference (for traceability)
|
||||
if agentBeadID != "" {
|
||||
if err := bd.UpdateAgentActiveMR(agentBeadID, mrID); err != nil {
|
||||
style.PrintWarning("could not update agent bead with active_mr: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Success output
|
||||
fmt.Printf("%s Work submitted to merge queue\n", style.Bold.Render("✓"))
|
||||
fmt.Printf(" MR ID: %s\n", style.Bold.Render(mrID))
|
||||
|
||||
Reference in New Issue
Block a user