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

@@ -3,6 +3,8 @@ package daemon
import (
"io"
"log"
"os"
"path/filepath"
"testing"
)
@@ -14,6 +16,33 @@ func testDaemon() *Daemon {
}
}
// testDaemonWithTown creates a Daemon with a proper town setup for testing.
// Returns the daemon and a cleanup function.
func testDaemonWithTown(t *testing.T, townName string) (*Daemon, func()) {
t.Helper()
townRoot := t.TempDir()
// Create mayor directory and town.json
mayorDir := filepath.Join(townRoot, "mayor")
if err := os.MkdirAll(mayorDir, 0755); err != nil {
t.Fatalf("failed to create mayor dir: %v", err)
}
townJSON := filepath.Join(mayorDir, "town.json")
content := `{"name": "` + townName + `"}`
if err := os.WriteFile(townJSON, []byte(content), 0644); err != nil {
t.Fatalf("failed to write town.json: %v", err)
}
d := &Daemon{
config: &Config{TownRoot: townRoot},
logger: log.New(io.Discard, "", 0),
}
return d, func() {
// Cleanup handled by t.TempDir()
}
}
func TestParseLifecycleRequest_Cycle(t *testing.T) {
d := testDaemon()
@@ -152,11 +181,12 @@ func TestParseLifecycleRequest_AlwaysUsesFromField(t *testing.T) {
}
func TestIdentityToSession_Mayor(t *testing.T) {
d := testDaemon()
d, cleanup := testDaemonWithTown(t, "ai")
defer cleanup()
result := d.identityToSession("mayor")
if result != "gt-mayor" {
t.Errorf("identityToSession('mayor') = %q, expected 'gt-mayor'", result)
if result != "gt-ai-mayor" {
t.Errorf("identityToSession('mayor') = %q, expected 'gt-ai-mayor'", result)
}
}