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

@@ -21,7 +21,6 @@ const (
// AgentIdentity represents a parsed Gas Town agent identity.
type AgentIdentity struct {
Role Role // mayor, deacon, witness, refinery, crew, polecat
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)
}
@@ -29,8 +28,8 @@ type AgentIdentity struct {
// ParseSessionName parses a tmux session name into an AgentIdentity.
//
// Session name formats:
// - gt-<town>-mayor → Role: mayor, Town: <town>
// - gt-<town>-deacon → Role: deacon, Town: <town>
// - gt-mayor → Role: mayor (one per machine)
// - gt-deacon → Role: deacon (one per machine)
// - gt-<rig>-witness → Role: witness, Rig: <rig>
// - gt-<rig>-refinery → Role: refinery, Rig: <rig>
// - gt-<rig>-crew-<name> → Role: crew, Rig: <rig>, Name: <name>
@@ -49,20 +48,18 @@ func ParseSessionName(session string) (*AgentIdentity, error) {
return nil, fmt.Errorf("invalid session name %q: empty after prefix", session)
}
// Parse into parts
parts := strings.Split(suffix, "-")
if len(parts) < 2 {
return nil, fmt.Errorf("invalid session name %q: expected town-role or rig-role format", session)
// Check for simple town-level roles (no rig qualifier)
if suffix == "mayor" {
return &AgentIdentity{Role: RoleMayor}, nil
}
if suffix == "deacon" {
return &AgentIdentity{Role: RoleDeacon}, nil
}
// 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
// Parse into parts for rig-level roles
parts := strings.Split(suffix, "-")
if len(parts) < 2 {
return nil, fmt.Errorf("invalid session name %q: expected rig-role format", session)
}
// Check for witness/refinery (suffix markers)
@@ -97,9 +94,9 @@ func ParseSessionName(session string) (*AgentIdentity, error) {
func (a *AgentIdentity) SessionName() string {
switch a.Role {
case RoleMayor:
return MayorSessionName(a.Town)
return MayorSessionName()
case RoleDeacon:
return DeaconSessionName(a.Town)
return DeaconSessionName()
case RoleWitness:
return WitnessSessionName(a.Rig)
case RoleRefinery:

View File

@@ -6,38 +6,23 @@ import (
func TestParseSessionName(t *testing.T) {
tests := []struct {
name string
session string
wantRole Role
wantTown string
wantRig string
wantName string
wantErr bool
name string
session string
wantRole Role
wantRig string
wantName string
wantErr bool
}{
// Town-level roles (mayor/deacon with town name)
// Town-level roles (simple gt-mayor, gt-deacon)
{
name: "mayor simple town",
session: "gt-ai-mayor",
name: "mayor",
session: "gt-mayor",
wantRole: RoleMayor,
wantTown: "ai",
},
{
name: "mayor hyphenated town",
session: "gt-my-town-mayor",
wantRole: RoleMayor,
wantTown: "my-town",
},
{
name: "deacon simple town",
session: "gt-alpha-deacon",
name: "deacon",
session: "gt-deacon",
wantRole: RoleDeacon,
wantTown: "alpha",
},
{
name: "deacon hyphenated town",
session: "gt-my-town-deacon",
wantRole: RoleDeacon,
wantTown: "my-town",
},
// Witness (simple rig)
@@ -138,9 +123,6 @@ func TestParseSessionName(t *testing.T) {
if got.Role != tt.wantRole {
t.Errorf("ParseSessionName(%q).Role = %v, want %v", tt.session, got.Role, tt.wantRole)
}
if got.Town != tt.wantTown {
t.Errorf("ParseSessionName(%q).Town = %v, want %v", tt.session, got.Town, tt.wantTown)
}
if got.Rig != tt.wantRig {
t.Errorf("ParseSessionName(%q).Rig = %v, want %v", tt.session, got.Rig, tt.wantRig)
}
@@ -158,19 +140,14 @@ func TestAgentIdentity_SessionName(t *testing.T) {
want string
}{
{
name: "mayor with town",
identity: AgentIdentity{Role: RoleMayor, Town: "ai"},
want: "gt-ai-mayor",
name: "mayor",
identity: AgentIdentity{Role: RoleMayor},
want: "gt-mayor",
},
{
name: "mayor hyphenated town",
identity: AgentIdentity{Role: RoleMayor, Town: "my-town"},
want: "gt-my-town-mayor",
},
{
name: "deacon with town",
identity: AgentIdentity{Role: RoleDeacon, Town: "alpha"},
want: "gt-alpha-deacon",
name: "deacon",
identity: AgentIdentity{Role: RoleDeacon},
want: "gt-deacon",
},
{
name: "witness",
@@ -253,8 +230,8 @@ func TestAgentIdentity_Address(t *testing.T) {
func TestParseSessionName_RoundTrip(t *testing.T) {
// Test that parsing then reconstructing gives the same result
sessions := []string{
"gt-ai-mayor",
"gt-alpha-deacon",
"gt-mayor",
"gt-deacon",
"gt-gastown-witness",
"gt-foo-bar-refinery",
"gt-gastown-crew-max",

View File

@@ -12,17 +12,15 @@ import (
const Prefix = "gt-"
// MayorSessionName returns the session name for the Mayor agent.
// The townName parameter allows multiple towns to run concurrently
// without tmux session name collisions.
func MayorSessionName(townName string) string {
return fmt.Sprintf("%s%s-mayor", Prefix, townName)
// One mayor per machine - multi-town requires containers/VMs for isolation.
func MayorSessionName() string {
return Prefix + "mayor"
}
// DeaconSessionName returns the session name for the Deacon agent.
// The townName parameter allows multiple towns to run concurrently
// without tmux session name collisions.
func DeaconSessionName(townName string) string {
return fmt.Sprintf("%s%s-deacon", Prefix, townName)
// One deacon per machine - multi-town requires containers/VMs for isolation.
func DeaconSessionName() string {
return Prefix + "deacon"
}
// WitnessSessionName returns the session name for a rig's Witness agent.

View File

@@ -8,42 +8,20 @@ import (
)
func TestMayorSessionName(t *testing.T) {
tests := []struct {
townName string
want string
}{
{"ai", "gt-ai-mayor"},
{"alpha", "gt-alpha-mayor"},
{"gastown", "gt-gastown-mayor"},
{"", "gt--mayor"}, // empty town name
}
for _, tt := range tests {
t.Run(tt.townName, func(t *testing.T) {
got := MayorSessionName(tt.townName)
if got != tt.want {
t.Errorf("MayorSessionName(%q) = %q, want %q", tt.townName, got, tt.want)
}
})
// Mayor session name is now fixed (one per machine)
want := "gt-mayor"
got := MayorSessionName()
if got != want {
t.Errorf("MayorSessionName() = %q, want %q", got, want)
}
}
func TestDeaconSessionName(t *testing.T) {
tests := []struct {
townName string
want string
}{
{"ai", "gt-ai-deacon"},
{"alpha", "gt-alpha-deacon"},
{"gastown", "gt-gastown-deacon"},
{"", "gt--deacon"}, // empty town name
}
for _, tt := range tests {
t.Run(tt.townName, func(t *testing.T) {
got := DeaconSessionName(tt.townName)
if got != tt.want {
t.Errorf("DeaconSessionName(%q) = %q, want %q", tt.townName, got, tt.want)
}
})
// Deacon session name is now fixed (one per machine)
want := "gt-deacon"
got := DeaconSessionName()
if got != want {
t.Errorf("DeaconSessionName() = %q, want %q", got, want)
}
}