fix: Make ParseAgentBeadID accept any valid prefix (gt-w0fqg)

Agent bead ID validation was hardcoded to only accept "gt-" prefix, which
caused errors when spawning beads polecats (which use "bd-" prefix):

  Error: invalid agent ID: agent ID must start with 'gt-' (got "bd-beads-polecat-pearl")

Changed ParseAgentBeadID to accept any 2-3 character prefix (gt-, bd-, hq-)
instead of hardcoding "gt-". Updated tests to cover other prefixes.

🤖 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/cheedo
2025-12-30 22:23:58 -08:00
committed by Steve Yegge
parent e539ea3cc8
commit 12543d1450
3 changed files with 31 additions and 12 deletions

View File

@@ -1019,8 +1019,14 @@ func TestParseAgentBeadID(t *testing.T) {
{"gt-gastown-polecat-my-agent", "gastown", "polecat", "my-agent", true},
// Parseable but not valid agent roles (IsAgentSessionBead will reject)
{"gt-abc123", "", "abc123", "", true}, // Parses as town-level but not valid role
// Other prefixes (bd-, hq-)
{"bd-mayor", "", "mayor", "", true}, // bd prefix town-level
{"bd-beads-witness", "beads", "witness", "", true}, // bd prefix rig-level singleton
{"bd-beads-polecat-pearl", "beads", "polecat", "pearl", true}, // bd prefix rig-level named
{"hq-mayor", "", "mayor", "", true}, // hq prefix town-level
// Truly invalid patterns
{"bd-gastown-crew-joe", "", "", "", false}, // Wrong prefix
{"x-mayor", "", "", "", false}, // Prefix too short (1 char)
{"abcd-mayor", "", "", "", false}, // Prefix too long (4 chars)
{"", "", "", "", false},
}
@@ -1049,19 +1055,26 @@ func TestIsAgentSessionBead(t *testing.T) {
beadID string
want bool
}{
// Agent session beads (should return true)
// Agent session beads with gt- prefix (should return true)
{"gt-mayor", true},
{"gt-deacon", true},
{"gt-gastown-witness", true},
{"gt-gastown-refinery", true},
{"gt-gastown-crew-joe", true},
{"gt-gastown-polecat-capable", true},
// Agent session beads with bd- prefix (should return true)
{"bd-mayor", true},
{"bd-deacon", true},
{"bd-beads-witness", true},
{"bd-beads-refinery", true},
{"bd-beads-crew-joe", true},
{"bd-beads-polecat-pearl", true},
// Regular work beads (should return false)
{"gt-abc123", false},
{"gt-sb6m4", false},
{"gt-u7dxq", false},
// Invalid beads
{"bd-abc123", false},
// Invalid beads
{"", false},
}