From 6a5d7cb3ec6fbf543c735a9ed49f372f86166cbf Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sun, 28 Dec 2025 16:12:13 -0800 Subject: [PATCH] Add session name helper functions (gt-atqr8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create helper functions in internal/session/names.go for consistent session name construction across Gas Town agents: - MayorSessionName() - DeaconSessionName() - WitnessSessionName(rig) - RefinerySessionName(rig) - CrewSessionName(rig, name) - PolecatSessionName(rig, name) Includes comprehensive unit tests in names_test.go. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/session/names.go | 37 ++++++++++++ internal/session/names_test.go | 104 +++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 internal/session/names.go create mode 100644 internal/session/names_test.go diff --git a/internal/session/names.go b/internal/session/names.go new file mode 100644 index 00000000..303bdbaa --- /dev/null +++ b/internal/session/names.go @@ -0,0 +1,37 @@ +// Package session provides polecat session lifecycle management. +package session + +import "fmt" + +// Prefix is the common prefix for all Gas Town tmux session names. +const Prefix = "gt-" + +// MayorSessionName returns the session name for the Mayor agent. +func MayorSessionName() string { + return Prefix + "mayor" +} + +// DeaconSessionName returns the session name for the Deacon agent. +func DeaconSessionName() string { + return Prefix + "deacon" +} + +// WitnessSessionName returns the session name for a rig's Witness agent. +func WitnessSessionName(rig string) string { + return fmt.Sprintf("%s%s-witness", Prefix, rig) +} + +// RefinerySessionName returns the session name for a rig's Refinery agent. +func RefinerySessionName(rig string) string { + return fmt.Sprintf("%s%s-refinery", Prefix, rig) +} + +// CrewSessionName returns the session name for a crew worker in a rig. +func CrewSessionName(rig, name string) string { + return fmt.Sprintf("%s%s-crew-%s", Prefix, rig, name) +} + +// PolecatSessionName returns the session name for a polecat in a rig. +func PolecatSessionName(rig, name string) string { + return fmt.Sprintf("%s%s-%s", Prefix, rig, name) +} diff --git a/internal/session/names_test.go b/internal/session/names_test.go new file mode 100644 index 00000000..d8137406 --- /dev/null +++ b/internal/session/names_test.go @@ -0,0 +1,104 @@ +package session + +import "testing" + +func TestMayorSessionName(t *testing.T) { + want := "gt-mayor" + got := MayorSessionName() + if got != want { + t.Errorf("MayorSessionName() = %q, want %q", got, want) + } +} + +func TestDeaconSessionName(t *testing.T) { + want := "gt-deacon" + got := DeaconSessionName() + if got != want { + t.Errorf("DeaconSessionName() = %q, want %q", got, want) + } +} + +func TestWitnessSessionName(t *testing.T) { + tests := []struct { + rig string + want string + }{ + {"gastown", "gt-gastown-witness"}, + {"beads", "gt-beads-witness"}, + {"foo", "gt-foo-witness"}, + } + for _, tt := range tests { + t.Run(tt.rig, func(t *testing.T) { + got := WitnessSessionName(tt.rig) + if got != tt.want { + t.Errorf("WitnessSessionName(%q) = %q, want %q", tt.rig, got, tt.want) + } + }) + } +} + +func TestRefinerySessionName(t *testing.T) { + tests := []struct { + rig string + want string + }{ + {"gastown", "gt-gastown-refinery"}, + {"beads", "gt-beads-refinery"}, + {"foo", "gt-foo-refinery"}, + } + for _, tt := range tests { + t.Run(tt.rig, func(t *testing.T) { + got := RefinerySessionName(tt.rig) + if got != tt.want { + t.Errorf("RefinerySessionName(%q) = %q, want %q", tt.rig, got, tt.want) + } + }) + } +} + +func TestCrewSessionName(t *testing.T) { + tests := []struct { + rig string + name string + want string + }{ + {"gastown", "max", "gt-gastown-crew-max"}, + {"beads", "alice", "gt-beads-crew-alice"}, + {"foo", "bar", "gt-foo-crew-bar"}, + } + for _, tt := range tests { + t.Run(tt.rig+"/"+tt.name, func(t *testing.T) { + got := CrewSessionName(tt.rig, tt.name) + if got != tt.want { + t.Errorf("CrewSessionName(%q, %q) = %q, want %q", tt.rig, tt.name, got, tt.want) + } + }) + } +} + +func TestPolecatSessionName(t *testing.T) { + tests := []struct { + rig string + name string + want string + }{ + {"gastown", "Toast", "gt-gastown-Toast"}, + {"gastown", "Furiosa", "gt-gastown-Furiosa"}, + {"beads", "worker1", "gt-beads-worker1"}, + } + for _, tt := range tests { + t.Run(tt.rig+"/"+tt.name, func(t *testing.T) { + got := PolecatSessionName(tt.rig, tt.name) + if got != tt.want { + t.Errorf("PolecatSessionName(%q, %q) = %q, want %q", tt.rig, tt.name, got, tt.want) + } + }) + } +} + +func TestPrefix(t *testing.T) { + want := "gt-" + if Prefix != want { + t.Errorf("Prefix = %q, want %q", Prefix, want) + } +}