fix: Make Mayor/Deacon session names include town name
Session names `gt-mayor` and `gt-deacon` were hardcoded, causing tmux
session name collisions when running multiple towns simultaneously.
Changed to `gt-{town}-mayor` and `gt-{town}-deacon` format (e.g.,
`gt-ai-mayor`) to allow concurrent multi-town operation.
Key changes:
- session.MayorSessionName() and DeaconSessionName() now take townName param
- Added workspace.GetTownName() helper to load town name from config
- Updated all callers in cmd/, daemon/, doctor/, mail/, rig/, templates/
- Updated tests with new session name format
- Bead IDs remain unchanged (already scoped by .beads/ directory)
Fixes #60
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,15 +21,16 @@ const (
|
||||
// AgentIdentity represents a parsed Gas Town agent identity.
|
||||
type AgentIdentity struct {
|
||||
Role Role // mayor, deacon, witness, refinery, crew, polecat
|
||||
Rig string // empty for mayor/deacon
|
||||
Town string // town name (for mayor/deacon only)
|
||||
Rig string // rig name (empty for mayor/deacon)
|
||||
Name string // crew/polecat name (empty for mayor/deacon/witness/refinery)
|
||||
}
|
||||
|
||||
// ParseSessionName parses a tmux session name into an AgentIdentity.
|
||||
//
|
||||
// Session name formats:
|
||||
// - gt-mayor → Role: mayor
|
||||
// - gt-deacon → Role: deacon
|
||||
// - gt-<town>-mayor → Role: mayor, Town: <town>
|
||||
// - gt-<town>-deacon → Role: deacon, Town: <town>
|
||||
// - gt-<rig>-witness → Role: witness, Rig: <rig>
|
||||
// - gt-<rig>-refinery → Role: refinery, Rig: <rig>
|
||||
// - gt-<rig>-crew-<name> → Role: crew, Rig: <rig>, Name: <name>
|
||||
@@ -48,18 +49,20 @@ func ParseSessionName(session string) (*AgentIdentity, error) {
|
||||
return nil, fmt.Errorf("invalid session name %q: empty after prefix", session)
|
||||
}
|
||||
|
||||
// Check for global roles first (no rig)
|
||||
switch suffix {
|
||||
case "mayor":
|
||||
return &AgentIdentity{Role: RoleMayor}, nil
|
||||
case "deacon":
|
||||
return &AgentIdentity{Role: RoleDeacon}, nil
|
||||
}
|
||||
|
||||
// Parse rig-based roles
|
||||
// Parse into parts
|
||||
parts := strings.Split(suffix, "-")
|
||||
if len(parts) < 2 {
|
||||
return nil, fmt.Errorf("invalid session name %q: expected rig-role format", session)
|
||||
return nil, fmt.Errorf("invalid session name %q: expected town-role or rig-role format", session)
|
||||
}
|
||||
|
||||
// Check for mayor/deacon (town-level roles with suffix marker)
|
||||
if parts[len(parts)-1] == "mayor" {
|
||||
town := strings.Join(parts[:len(parts)-1], "-")
|
||||
return &AgentIdentity{Role: RoleMayor, Town: town}, nil
|
||||
}
|
||||
if parts[len(parts)-1] == "deacon" {
|
||||
town := strings.Join(parts[:len(parts)-1], "-")
|
||||
return &AgentIdentity{Role: RoleDeacon, Town: town}, nil
|
||||
}
|
||||
|
||||
// Check for witness/refinery (suffix markers)
|
||||
@@ -94,9 +97,9 @@ func ParseSessionName(session string) (*AgentIdentity, error) {
|
||||
func (a *AgentIdentity) SessionName() string {
|
||||
switch a.Role {
|
||||
case RoleMayor:
|
||||
return MayorSessionName()
|
||||
return MayorSessionName(a.Town)
|
||||
case RoleDeacon:
|
||||
return DeaconSessionName()
|
||||
return DeaconSessionName(a.Town)
|
||||
case RoleWitness:
|
||||
return WitnessSessionName(a.Rig)
|
||||
case RoleRefinery:
|
||||
|
||||
Reference in New Issue
Block a user