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:
gastown/polecats/dementus
2025-12-30 22:28:33 -08:00
committed by Steve Yegge
parent b241a353f3
commit 4a22e621a9
5 changed files with 77 additions and 0 deletions
+10
View File
@@ -164,6 +164,7 @@ type MRFields struct {
Rig string // Which rig
MergeCommit string // SHA of merge commit (set on close)
CloseReason string // Reason for closing: merged, rejected, conflict, superseded
AgentBead string // Agent bead ID that created this MR (for traceability)
}
// ParseMRFields extracts structured merge-request fields from an issue's description.
@@ -218,6 +219,9 @@ func ParseMRFields(issue *Issue) *MRFields {
case "close_reason", "close-reason", "closereason":
fields.CloseReason = value
hasFields = true
case "agent_bead", "agent-bead", "agentbead":
fields.AgentBead = value
hasFields = true
}
}
@@ -257,6 +261,9 @@ func FormatMRFields(fields *MRFields) string {
if fields.CloseReason != "" {
lines = append(lines, "close_reason: "+fields.CloseReason)
}
if fields.AgentBead != "" {
lines = append(lines, "agent_bead: "+fields.AgentBead)
}
return strings.Join(lines, "\n")
}
@@ -284,6 +291,9 @@ func SetMRFields(issue *Issue, fields *MRFields) string {
"close_reason": true,
"close-reason": true,
"closereason": true,
"agent_bead": true,
"agent-bead": true,
"agentbead": true,
}
// Collect non-MR lines from existing description