Revert to simple gt-mayor/gt-deacon session names

Reverts the session naming changes from PR #70. Multi-town support
on a single machine is not a real use case - rigs provide project
isolation, and true isolation should use containers/VMs.

Changes:
- MayorSessionName() and DeaconSessionName() no longer take townName parameter
- ParseSessionName() handles simple gt-mayor and gt-deacon formats
- Removed Town field from AgentIdentity and AgentSession structs
- Updated all callers and tests

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
joe
2026-01-03 14:33:24 -08:00
committed by Steve Yegge
parent d3e47221ac
commit 4bcf50bf1c
23 changed files with 117 additions and 267 deletions

View File

@@ -35,7 +35,6 @@ type AgentSession struct {
Type AgentType
Rig string // For rig-specific agents
AgentName string // e.g., crew name, polecat name
Town string // For mayor/deacon only (town name from session)
}
// AgentTypeColors maps agent types to tmux color codes.
@@ -136,16 +135,13 @@ func categorizeSession(name string) *AgentSession {
session := &AgentSession{Name: name}
suffix := strings.TrimPrefix(name, "gt-")
// Town-level agents: gt-{town}-mayor, gt-{town}-deacon
// Check if suffix ends with -mayor or -deacon (new format)
if strings.HasSuffix(suffix, "-mayor") {
// Town-level agents: gt-mayor, gt-deacon (simple format, one per machine)
if suffix == "mayor" {
session.Type = AgentMayor
session.Town = strings.TrimSuffix(suffix, "-mayor")
return session
}
if strings.HasSuffix(suffix, "-deacon") {
if suffix == "deacon" {
session.Type = AgentDeacon
session.Town = strings.TrimSuffix(suffix, "-deacon")
return session
}

View File

@@ -21,18 +21,9 @@ import (
"github.com/steveyegge/gastown/internal/workspace"
)
// getDeaconSessionName returns the Deacon session name for the current workspace.
// The session name includes the town name to avoid collisions between multiple HQs.
// getDeaconSessionName returns the Deacon session name.
func getDeaconSessionName() (string, error) {
townRoot, err := workspace.FindFromCwdOrError()
if err != nil {
return "", fmt.Errorf("not in a Gas Town workspace: %w", err)
}
townName, err := workspace.GetTownName(townRoot)
if err != nil {
return "", err
}
return session.DeaconSessionName(townName), nil
return session.DeaconSessionName(), nil
}
var deaconCmd = &cobra.Command{
@@ -673,14 +664,8 @@ func runDeaconHealthCheck(cmd *cobra.Command, args []string) error {
return nil
}
// Get town name for session name generation
townName, err := workspace.GetTownName(townRoot)
if err != nil {
return fmt.Errorf("getting town name: %w", err)
}
// Get agent bead info before ping (for baseline)
beadID, sessionName, err := agentAddressToIDs(agent, townName)
beadID, sessionName, err := agentAddressToIDs(agent)
if err != nil {
return fmt.Errorf("invalid agent address: %w", err)
}
@@ -787,14 +772,8 @@ func runDeaconForceKill(cmd *cobra.Command, args []string) error {
agent, remaining.Round(time.Second))
}
// Get town name for session name generation
townName, err := workspace.GetTownName(townRoot)
if err != nil {
return fmt.Errorf("getting town name: %w", err)
}
// Get session name
_, sessionName, err := agentAddressToIDs(agent, townName)
_, sessionName, err := agentAddressToIDs(agent)
if err != nil {
return fmt.Errorf("invalid agent address: %w", err)
}
@@ -1154,14 +1133,13 @@ func notifyMayorOfWitnessFailure(townRoot string, zombies []zombieInfo) {
// agentAddressToIDs converts an agent address to bead ID and session name.
// Supports formats: "gastown/polecats/max", "gastown/witness", "deacon", "mayor"
// The townName parameter is required for mayor/deacon to generate correct session names.
func agentAddressToIDs(address, townName string) (beadID, sessionName string, err error) {
func agentAddressToIDs(address string) (beadID, sessionName string, err error) {
switch address {
case "deacon":
sessName := session.DeaconSessionName(townName)
sessName := session.DeaconSessionName()
return sessName, sessName, nil
case "mayor":
sessName := session.MayorSessionName(townName)
sessName := session.MayorSessionName()
return sessName, sessName, nil
}
@@ -1227,11 +1205,7 @@ func sendMail(townRoot, to, subject, body string) {
// updateAgentBeadState updates an agent bead's state.
func updateAgentBeadState(townRoot, agent, state, reason string) {
townName, err := workspace.GetTownName(townRoot)
if err != nil {
return
}
beadID, _, err := agentAddressToIDs(agent, townName)
beadID, _, err := agentAddressToIDs(agent)
if err != nil {
return
}

View File

@@ -5,13 +5,13 @@ import (
)
func TestAddressToAgentBeadID(t *testing.T) {
townName := "ai"
tests := []struct {
address string
expected string
}{
{"mayor", "gt-ai-mayor"},
{"deacon", "gt-ai-deacon"},
// Mayor and deacon use simple session names (no town qualifier)
{"mayor", "gt-mayor"},
{"deacon", "gt-deacon"},
{"gastown/witness", "gt-gastown-witness"},
{"gastown/refinery", "gt-gastown-refinery"},
{"gastown/alpha", "gt-gastown-polecat-alpha"},
@@ -25,9 +25,9 @@ func TestAddressToAgentBeadID(t *testing.T) {
for _, tt := range tests {
t.Run(tt.address, func(t *testing.T) {
got := addressToAgentBeadID(tt.address, townName)
got := addressToAgentBeadID(tt.address)
if got != tt.expected {
t.Errorf("addressToAgentBeadID(%q, %q) = %q, want %q", tt.address, townName, got, tt.expected)
t.Errorf("addressToAgentBeadID(%q) = %q, want %q", tt.address, got, tt.expected)
}
})
}

View File

@@ -261,8 +261,8 @@ func createMayorCLAUDEmd(hqRoot, townRoot string) error {
TownRoot: townRoot,
TownName: townName,
WorkDir: hqRoot,
MayorSession: session.MayorSessionName(townName),
DeaconSession: session.DeaconSessionName(townName),
MayorSession: session.MayorSessionName(),
DeaconSession: session.DeaconSessionName(),
}
content, err := tmpl.RenderRole("mayor", data)

View File

@@ -14,18 +14,9 @@ import (
"github.com/steveyegge/gastown/internal/workspace"
)
// getMayorSessionName returns the Mayor session name for the current workspace.
// The session name includes the town name to avoid collisions between multiple HQs.
// getMayorSessionName returns the Mayor session name.
func getMayorSessionName() (string, error) {
townRoot, err := workspace.FindFromCwdOrError()
if err != nil {
return "", fmt.Errorf("not in a Gas Town workspace: %w", err)
}
townName, err := workspace.GetTownName(townRoot)
if err != nil {
return "", err
}
return session.MayorSessionName(townName), nil
return session.MayorSessionName(), nil
}
var mayorCmd = &cobra.Command{

View File

@@ -120,17 +120,11 @@ func runNudge(cmd *cobra.Command, args []string) error {
t := tmux.NewTmux()
// Get session names for this town
townName := ""
if townRoot != "" {
townName, _ = workspace.GetTownName(townRoot)
}
// Expand role shortcuts to session names
// These shortcuts let users type "mayor" instead of "gt-{town}-mayor"
// These shortcuts let users type "mayor" instead of "gt-mayor"
switch target {
case "mayor":
target = session.MayorSessionName(townName)
target = session.MayorSessionName()
case "witness", "refinery":
// These need the current rig
roleInfo, err := GetRole()
@@ -149,7 +143,7 @@ func runNudge(cmd *cobra.Command, args []string) error {
// Special case: "deacon" target maps to the Deacon session
if target == "deacon" {
deaconSession := session.DeaconSessionName(townName)
deaconSession := session.DeaconSessionName()
// Check if Deacon session exists
exists, err := t.HasSession(deaconSession)
if err != nil {
@@ -286,9 +280,6 @@ func runNudgeChannel(channelName, message string) error {
// Prefix message with sender
prefixedMessage := fmt.Sprintf("[from %s] %s", sender, message)
// Get town name for session names
townName, _ := workspace.GetTownName(townRoot)
// Get all running sessions for pattern matching
agents, err := getAgentSessions(true)
if err != nil {
@@ -300,7 +291,7 @@ func runNudgeChannel(channelName, message string) error {
seenTargets := make(map[string]bool)
for _, pattern := range patterns {
resolved := resolveNudgePattern(pattern, agents, townName)
resolved := resolveNudgePattern(pattern, agents)
for _, sessionName := range resolved {
if !seenTargets[sessionName] {
seenTargets[sessionName] = true
@@ -362,15 +353,15 @@ func runNudgeChannel(channelName, message string) error {
// - Role: "*/witness" → all witness sessions
// - Special: "mayor", "deacon" → gt-{town}-mayor, gt-{town}-deacon
// townName is used to generate the correct session names for mayor/deacon.
func resolveNudgePattern(pattern string, agents []*AgentSession, townName string) []string {
func resolveNudgePattern(pattern string, agents []*AgentSession) []string {
var results []string
// Handle special cases
switch pattern {
case "mayor":
return []string{session.MayorSessionName(townName)}
return []string{session.MayorSessionName()}
case "deacon":
return []string{session.DeaconSessionName(townName)}
return []string{session.DeaconSessionName()}
}
// Parse pattern
@@ -438,11 +429,8 @@ func shouldNudgeTarget(townRoot, targetAddress string, force bool) (bool, string
return true, "", nil
}
// Get town name for session name generation
townName, _ := workspace.GetTownName(townRoot)
// Try to determine agent bead ID from address
agentBeadID := addressToAgentBeadID(targetAddress, townName)
agentBeadID := addressToAgentBeadID(targetAddress)
if agentBeadID == "" {
// Can't determine agent bead, allow the nudge
return true, "", nil
@@ -467,13 +455,13 @@ func shouldNudgeTarget(townRoot, targetAddress string, force bool) (bool, string
// - "gastown/alpha" -> "gt-gastown-polecat-alpha"
//
// Returns empty string if the address cannot be converted.
func addressToAgentBeadID(address, townName string) string {
func addressToAgentBeadID(address string) string {
// Handle special cases
switch address {
case "mayor":
return session.MayorSessionName(townName)
return session.MayorSessionName()
case "deacon":
return session.DeaconSessionName(townName)
return session.DeaconSessionName()
}
// Parse rig/role format

View File

@@ -5,10 +5,10 @@ import (
)
func TestResolveNudgePattern(t *testing.T) {
// Create test agent sessions
// Create test agent sessions (no Town field for mayor/deacon anymore)
agents := []*AgentSession{
{Name: "gt-ai-mayor", Type: AgentMayor, Town: "ai"},
{Name: "gt-ai-deacon", Type: AgentDeacon, Town: "ai"},
{Name: "gt-mayor", Type: AgentMayor},
{Name: "gt-deacon", Type: AgentDeacon},
{Name: "gt-gastown-witness", Type: AgentWitness, Rig: "gastown"},
{Name: "gt-gastown-refinery", Type: AgentRefinery, Rig: "gastown"},
{Name: "gt-gastown-crew-max", Type: AgentCrew, Rig: "gastown", AgentName: "max"},
@@ -27,12 +27,12 @@ func TestResolveNudgePattern(t *testing.T) {
{
name: "mayor special case",
pattern: "mayor",
expected: []string{"gt-ai-mayor"},
expected: []string{"gt-mayor"},
},
{
name: "deacon special case",
pattern: "deacon",
expected: []string{"gt-ai-deacon"},
expected: []string{"gt-deacon"},
},
{
name: "specific witness",
@@ -86,10 +86,9 @@ func TestResolveNudgePattern(t *testing.T) {
},
}
townName := "ai"
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := resolveNudgePattern(tt.pattern, agents, townName)
got := resolveNudgePattern(tt.pattern, agents)
if len(got) != len(tt.expected) {
t.Errorf("resolveNudgePattern(%q) returned %d results, want %d: got %v, want %v",

View File

@@ -315,8 +315,8 @@ func outputPrimeContext(ctx RoleContext) error {
TownName: townName,
WorkDir: ctx.WorkDir,
Polecat: ctx.Polecat,
MayorSession: session.MayorSessionName(townName),
DeaconSession: session.DeaconSessionName(townName),
MayorSession: session.MayorSessionName(),
DeaconSession: session.DeaconSessionName(),
}
// Render and output

View File

@@ -31,8 +31,8 @@ func TestCategorizeSessionRig(t *testing.T) {
{"gt-a-b", "a"}, // minimum valid
// Town-level agents (no rig)
{"gt-ai-mayor", ""},
{"gt-ai-deacon", ""},
{"gt-mayor", ""},
{"gt-deacon", ""},
}
for _, tt := range tests {
@@ -68,8 +68,8 @@ func TestCategorizeSessionType(t *testing.T) {
{"gt-myrig-crew-user", AgentCrew},
// Town-level agents
{"gt-ai-mayor", AgentMayor},
{"gt-ai-deacon", AgentDeacon},
{"gt-mayor", AgentMayor},
{"gt-deacon", AgentDeacon},
}
for _, tt := range tests {

View File

@@ -117,15 +117,9 @@ func runThemeApply(cmd *cobra.Command, args []string) error {
// Determine current rig
rigName := detectCurrentRig()
// Get town name for session name comparison
var mayorSession, deaconSession string
townRoot, err := workspace.FindFromCwd()
if err == nil && townRoot != "" {
if townName, err := workspace.GetTownName(townRoot); err == nil {
mayorSession = session.MayorSessionName(townName)
deaconSession = session.DeaconSessionName(townName)
}
}
// Get session names for comparison
mayorSession := session.MayorSessionName()
deaconSession := session.DeaconSessionName()
// Apply to matching sessions
applied := 0