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

@@ -618,12 +618,13 @@ func runCostsRecord(cmd *cobra.Command, args []string) error {
// - Polecats: gt-{rig}-{polecat} (e.g., gt-gastown-toast)
// - Crew: gt-{rig}-crew-{crew} (e.g., gt-gastown-crew-max)
// - Witness/Refinery: gt-{rig}-{role} (e.g., gt-gastown-witness)
// - Mayor/Deacon: gt-{role} (e.g., gt-mayor)
// - Mayor/Deacon: gt-{town}-{role} (e.g., gt-ai-mayor)
func deriveSessionName() string {
role := os.Getenv("GT_ROLE")
rig := os.Getenv("GT_RIG")
polecat := os.Getenv("GT_POLECAT")
crew := os.Getenv("GT_CREW")
town := os.Getenv("GT_TOWN")
// Polecat: gt-{rig}-{polecat}
if polecat != "" && rig != "" {
@@ -635,9 +636,9 @@ func deriveSessionName() string {
return fmt.Sprintf("gt-%s-crew-%s", rig, crew)
}
// Global roles without rig: gt-{role}
if role != "" && rig == "" {
return fmt.Sprintf("gt-%s", role)
// Town-level roles (mayor, deacon): gt-{town}-{role}
if (role == "mayor" || role == "deacon") && town != "" {
return fmt.Sprintf("gt-%s-%s", town, role)
}
// Rig-based roles (witness, refinery): gt-{rig}-{role}