Fix agent bead ID prefix - always use gt- not rig prefix

Agent beads must use gt- prefix (required by beads validation).
Only issue beads use rig-specific prefixes (ga-, bd-, etc.).

Fixed in:
- crew_add.go: Use CrewBeadID() not CrewBeadIDWithPrefix()
- prime.go: Use non-prefix variants for all agent types
- sling.go: Use non-prefix variants for all agent types

This fixes 'invalid agent ID' error when creating crew in rigs
with non-gt prefix (e.g., gastown with ga- prefix).

🤖 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 19:12:28 -08:00
parent bf390dee86
commit 8c80ad0aff
3 changed files with 18 additions and 33 deletions

View File

@@ -81,12 +81,9 @@ func runCrewAdd(cmd *cobra.Command, args []string) error {
// Create agent bead for the crew worker // Create agent bead for the crew worker
rigBeadsPath := filepath.Join(r.Path, "mayor", "rig") rigBeadsPath := filepath.Join(r.Path, "mayor", "rig")
bd := beads.New(rigBeadsPath) bd := beads.New(rigBeadsPath)
// Use the rig's configured prefix, defaulting to "gt" for backward compatibility // Agent beads always use "gt-" prefix (required by beads validation)
prefix := "gt" // Only issue beads use rig-specific prefixes
if r.Config != nil && r.Config.Prefix != "" { crewID := beads.CrewBeadID(rigName, name)
prefix = r.Config.Prefix
}
crewID := beads.CrewBeadIDWithPrefix(prefix, rigName, name)
if _, err := bd.Show(crewID); err != nil { if _, err := bd.Show(crewID); err != nil {
// Agent bead doesn't exist, create it // Agent bead doesn't exist, create it
fields := &beads.AgentFields{ fields := &beads.AgentFields{

View File

@@ -1170,18 +1170,11 @@ func getAgentFields(ctx RoleContext, state string) *beads.AgentFields {
} }
// getAgentBeadID returns the agent bead ID for the current role. // getAgentBeadID returns the agent bead ID for the current role.
// Uses canonical naming: prefix-rig-role-name // Uses canonical naming: gt-rig-role-name
// The prefix is looked up from routes.jsonl to support rigs with custom prefixes. // Agent beads always use "gt-" prefix (required by beads validation).
// Only issue beads use rig-specific prefixes.
// Returns empty string for unknown roles. // Returns empty string for unknown roles.
func getAgentBeadID(ctx RoleContext) string { func getAgentBeadID(ctx RoleContext) string {
// Helper to get prefix for rig-level agents
getPrefix := func() string {
if ctx.TownRoot != "" && ctx.Rig != "" {
return beads.GetPrefixForRig(ctx.TownRoot, ctx.Rig)
}
return "gt" // Default prefix
}
switch ctx.Role { switch ctx.Role {
case RoleMayor: case RoleMayor:
return beads.MayorBeadID() return beads.MayorBeadID()
@@ -1189,22 +1182,22 @@ func getAgentBeadID(ctx RoleContext) string {
return beads.DeaconBeadID() return beads.DeaconBeadID()
case RoleWitness: case RoleWitness:
if ctx.Rig != "" { if ctx.Rig != "" {
return beads.WitnessBeadIDWithPrefix(getPrefix(), ctx.Rig) return beads.WitnessBeadID(ctx.Rig)
} }
return "" return ""
case RoleRefinery: case RoleRefinery:
if ctx.Rig != "" { if ctx.Rig != "" {
return beads.RefineryBeadIDWithPrefix(getPrefix(), ctx.Rig) return beads.RefineryBeadID(ctx.Rig)
} }
return "" return ""
case RolePolecat: case RolePolecat:
if ctx.Rig != "" && ctx.Polecat != "" { if ctx.Rig != "" && ctx.Polecat != "" {
return beads.PolecatBeadIDWithPrefix(getPrefix(), ctx.Rig, ctx.Polecat) return beads.PolecatBeadID(ctx.Rig, ctx.Polecat)
} }
return "" return ""
case RoleCrew: case RoleCrew:
if ctx.Rig != "" && ctx.Polecat != "" { if ctx.Rig != "" && ctx.Polecat != "" {
return beads.CrewBeadIDWithPrefix(getPrefix(), ctx.Rig, ctx.Polecat) return beads.CrewBeadID(ctx.Rig, ctx.Polecat)
} }
return "" return ""
default: default:

View File

@@ -842,10 +842,11 @@ func detectActor() string {
} }
// agentIDToBeadID converts an agent ID to its corresponding agent bead ID. // agentIDToBeadID converts an agent ID to its corresponding agent bead ID.
// Uses canonical naming: prefix-rig-role-name // Uses canonical naming: gt-rig-role-name
// The prefix is looked up from routes.jsonl based on the rig name. // Agent beads always use "gt-" prefix (required by beads validation).
// Only issue beads use rig-specific prefixes.
func agentIDToBeadID(agentID string) string { func agentIDToBeadID(agentID string) string {
// Handle simple cases (town-level agents always use gt- prefix) // Handle simple cases (town-level agents)
if agentID == "mayor" { if agentID == "mayor" {
return beads.MayorBeadID() return beads.MayorBeadID()
} }
@@ -861,21 +862,15 @@ func agentIDToBeadID(agentID string) string {
rig := parts[0] rig := parts[0]
// Look up the prefix for this rig from routes.jsonl
prefix := "gt" // default
if townRoot, err := workspace.FindFromCwd(); err == nil && townRoot != "" {
prefix = beads.GetPrefixForRig(townRoot, rig)
}
switch { switch {
case len(parts) == 2 && parts[1] == "witness": case len(parts) == 2 && parts[1] == "witness":
return beads.WitnessBeadIDWithPrefix(prefix, rig) return beads.WitnessBeadID(rig)
case len(parts) == 2 && parts[1] == "refinery": case len(parts) == 2 && parts[1] == "refinery":
return beads.RefineryBeadIDWithPrefix(prefix, rig) return beads.RefineryBeadID(rig)
case len(parts) == 3 && parts[1] == "crew": case len(parts) == 3 && parts[1] == "crew":
return beads.CrewBeadIDWithPrefix(prefix, rig, parts[2]) return beads.CrewBeadID(rig, parts[2])
case len(parts) == 3 && parts[1] == "polecats": case len(parts) == 3 && parts[1] == "polecats":
return beads.PolecatBeadIDWithPrefix(prefix, rig, parts[2]) return beads.PolecatBeadID(rig, parts[2])
default: default:
return "" return ""
} }