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:
markov-kernel
2026-01-03 21:21:00 +01:00
parent 7f9795f630
commit e7145cfd77
46 changed files with 4772 additions and 1615 deletions

View File

@@ -230,10 +230,18 @@ func resolveRoleToSession(role string) (string, error) {
switch strings.ToLower(role) {
case "mayor", "may":
return "gt-mayor", nil
mayorSession, err := getMayorSessionName()
if err != nil {
return "", fmt.Errorf("cannot determine mayor session name: %w", err)
}
return mayorSession, nil
case "deacon", "dea":
return "gt-deacon", nil
deaconSession, err := getDeaconSessionName()
if err != nil {
return "", fmt.Errorf("cannot determine deacon session name: %w", err)
}
return deaconSession, nil
case "crew":
// Try to get rig and crew name from environment or cwd
@@ -360,11 +368,15 @@ func buildRestartCommand(sessionName string) (string, error) {
// sessionWorkDir returns the correct working directory for a session.
// This is the canonical home for each role type.
func sessionWorkDir(sessionName, townRoot string) (string, error) {
// Get session names for comparison
mayorSession, _ := getMayorSessionName()
deaconSession, _ := getDeaconSessionName()
switch {
case sessionName == "gt-mayor":
case sessionName == mayorSession:
return townRoot, nil
case sessionName == "gt-deacon":
case sessionName == deaconSession:
return townRoot + "/deacon", nil
case strings.Contains(sessionName, "-crew-"):