feat: use hq- prefix for Mayor and Deacon session names

Town-level services (Mayor, Deacon) now use hq- prefix instead of gt-:
- hq-mayor (was gt-mayor)
- hq-deacon (was gt-deacon)

This distinguishes town-level sessions from rig-level sessions which
continue to use gt- prefix (gt-gastown-witness, gt-gastown-crew-max, etc).

Changes:
- session.MayorSessionName() returns "hq-mayor"
- session.DeaconSessionName() returns "hq-deacon"
- ParseSessionName() handles both hq- and gt- prefixes
- categorizeSession() handles both prefixes
- categorizeSessions() accepts both prefixes
- Updated all tests and documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/jack
2026-01-05 00:42:10 -08:00
committed by Steve Yegge
parent a459cd9fd6
commit 6b8c897e37
16 changed files with 92 additions and 74 deletions

View File

@@ -127,24 +127,29 @@ func init() {
// categorizeSession determines the agent type from a session name.
func categorizeSession(name string) *AgentSession {
// Must start with gt- prefix
session := &AgentSession{Name: name}
// Town-level agents use hq- prefix: hq-mayor, hq-deacon
if strings.HasPrefix(name, "hq-") {
suffix := strings.TrimPrefix(name, "hq-")
if suffix == "mayor" {
session.Type = AgentMayor
return session
}
if suffix == "deacon" {
session.Type = AgentDeacon
return session
}
return nil // Unknown hq- session
}
// Rig-level agents use gt- prefix
if !strings.HasPrefix(name, "gt-") {
return nil
}
session := &AgentSession{Name: name}
suffix := strings.TrimPrefix(name, "gt-")
// Town-level agents: gt-mayor, gt-deacon (simple format, one per machine)
if suffix == "mayor" {
session.Type = AgentMayor
return session
}
if suffix == "deacon" {
session.Type = AgentDeacon
return session
}
// Witness sessions: legacy format gt-witness-<rig> (fallback)
if strings.HasPrefix(suffix, "witness-") {
session.Type = AgentWitness

View File

@@ -9,9 +9,9 @@ func TestAddressToAgentBeadID(t *testing.T) {
address string
expected string
}{
// Mayor and deacon use simple session names (no town qualifier)
{"mayor", "gt-mayor"},
{"deacon", "gt-deacon"},
// Mayor and deacon use hq- prefix (town-level)
{"mayor", "hq-mayor"},
{"deacon", "hq-deacon"},
{"gastown/witness", "gt-gastown-witness"},
{"gastown/refinery", "gt-gastown-refinery"},
{"gastown/alpha", "gt-gastown-polecat-alpha"},

View File

@@ -5,10 +5,10 @@ import (
)
func TestResolveNudgePattern(t *testing.T) {
// Create test agent sessions (no Town field for mayor/deacon anymore)
// Create test agent sessions (mayor/deacon use hq- prefix)
agents := []*AgentSession{
{Name: "gt-mayor", Type: AgentMayor},
{Name: "gt-deacon", Type: AgentDeacon},
{Name: "hq-mayor", Type: AgentMayor},
{Name: "hq-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-mayor"},
expected: []string{"hq-mayor"},
},
{
name: "deacon special case",
pattern: "deacon",
expected: []string{"gt-deacon"},
expected: []string{"hq-deacon"},
},
{
name: "specific witness",

View File

@@ -430,7 +430,8 @@ func runShutdown(cmd *cobra.Command, args []string) error {
// mayorSession and deaconSession are the dynamic session names for the current town.
func categorizeSessions(sessions []string, mayorSession, deaconSession string) (toStop, preserved []string) {
for _, sess := range sessions {
if !strings.HasPrefix(sess, "gt-") {
// Gas Town sessions use gt- (rig-level) or hq- (town-level) prefix
if !strings.HasPrefix(sess, "gt-") && !strings.HasPrefix(sess, "hq-") {
continue // Not a Gas Town session
}

View File

@@ -30,9 +30,9 @@ func TestCategorizeSessionRig(t *testing.T) {
// Edge cases
{"gt-a-b", "a"}, // minimum valid
// Town-level agents (no rig)
{"gt-mayor", ""},
{"gt-deacon", ""},
// Town-level agents (no rig, use hq- prefix)
{"hq-mayor", ""},
{"hq-deacon", ""},
}
for _, tt := range tests {
@@ -67,9 +67,9 @@ func TestCategorizeSessionType(t *testing.T) {
{"gt-gastown-crew-max", AgentCrew},
{"gt-myrig-crew-user", AgentCrew},
// Town-level agents
{"gt-mayor", AgentMayor},
{"gt-deacon", AgentDeacon},
// Town-level agents (hq- prefix)
{"hq-mayor", AgentMayor},
{"hq-deacon", AgentDeacon},
}
for _, tt := range tests {