refactor: migrate callers from deprecated MayorBeadID/DeaconBeadID to Town variants (gt-gbw0a)
Update all callers of deprecated MayorBeadID()/DeaconBeadID() to use MayorBeadIDTown()/DeaconBeadIDTown() which return hq- prefix IDs for town-level beads storage. Changes: - internal/daemon/lifecycle.go: identityToAgentBeadID and checkStaleAgents - internal/cmd/prime.go: getAgentBeadID - internal/cmd/molecule_status.go: buildAgentBeadID - internal/cmd/prime_test.go: update expected values to hq-* - Comments updated to reflect hq- prefix for town-level agents The deprecated functions remain for backward compatibility and are used by the migration tool (migrate_agents.go). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
a5907685cd
commit
60ecf1ff76
@@ -54,7 +54,7 @@ func runMoleculeAttach(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// detectAgentBeadID detects the current agent's bead ID from the working directory.
|
// detectAgentBeadID detects the current agent's bead ID from the working directory.
|
||||||
// Returns the agent bead ID (e.g., "gt-mayor", "gt-gastown-polecat-nux") or empty string if not detectable.
|
// Returns the agent bead ID (e.g., "hq-mayor", "gt-gastown-polecat-nux") or empty string if not detectable.
|
||||||
func detectAgentBeadID() (string, error) {
|
func detectAgentBeadID() (string, error) {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ import (
|
|||||||
|
|
||||||
// buildAgentBeadID constructs the agent bead ID from an agent identity.
|
// buildAgentBeadID constructs the agent bead ID from an agent identity.
|
||||||
// Uses canonical naming: prefix-rig-role-name
|
// Uses canonical naming: prefix-rig-role-name
|
||||||
|
// Town-level agents use hq- prefix; rig-level agents use rig's prefix.
|
||||||
// Examples:
|
// Examples:
|
||||||
// - "mayor" -> "gt-mayor"
|
// - "mayor" -> "hq-mayor"
|
||||||
// - "deacon" -> "gt-deacon"
|
// - "deacon" -> "hq-deacon"
|
||||||
// - "gastown/witness" -> "gt-gastown-witness"
|
// - "gastown/witness" -> "gt-gastown-witness"
|
||||||
// - "gastown/refinery" -> "gt-gastown-refinery"
|
// - "gastown/refinery" -> "gt-gastown-refinery"
|
||||||
// - "gastown/nux" (polecat) -> "gt-gastown-polecat-nux"
|
// - "gastown/nux" (polecat) -> "gt-gastown-polecat-nux"
|
||||||
@@ -34,9 +35,9 @@ func buildAgentBeadID(identity string, role Role) string {
|
|||||||
if role == RoleUnknown || role == Role("") {
|
if role == RoleUnknown || role == Role("") {
|
||||||
switch {
|
switch {
|
||||||
case identity == "mayor":
|
case identity == "mayor":
|
||||||
return beads.MayorBeadID()
|
return beads.MayorBeadIDTown()
|
||||||
case identity == "deacon":
|
case identity == "deacon":
|
||||||
return beads.DeaconBeadID()
|
return beads.DeaconBeadIDTown()
|
||||||
case len(parts) == 2 && parts[1] == "witness":
|
case len(parts) == 2 && parts[1] == "witness":
|
||||||
return beads.WitnessBeadID(parts[0])
|
return beads.WitnessBeadID(parts[0])
|
||||||
case len(parts) == 2 && parts[1] == "refinery":
|
case len(parts) == 2 && parts[1] == "refinery":
|
||||||
@@ -57,9 +58,9 @@ func buildAgentBeadID(identity string, role Role) string {
|
|||||||
|
|
||||||
switch role {
|
switch role {
|
||||||
case RoleMayor:
|
case RoleMayor:
|
||||||
return beads.MayorBeadID()
|
return beads.MayorBeadIDTown()
|
||||||
case RoleDeacon:
|
case RoleDeacon:
|
||||||
return beads.DeaconBeadID()
|
return beads.DeaconBeadIDTown()
|
||||||
case RoleWitness:
|
case RoleWitness:
|
||||||
if len(parts) >= 1 {
|
if len(parts) >= 1 {
|
||||||
return beads.WitnessBeadID(parts[0])
|
return beads.WitnessBeadID(parts[0])
|
||||||
|
|||||||
@@ -1245,14 +1245,14 @@ func getAgentFields(ctx RoleContext, state string) *beads.AgentFields {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getAgentBeadID returns the agent bead ID for the current role.
|
// getAgentBeadID returns the agent bead ID for the current role.
|
||||||
// Rig-scoped agents use the rig's configured prefix; town agents remain gt-.
|
// Town-level agents (mayor, deacon) use hq- prefix; rig-scoped agents use the rig's prefix.
|
||||||
// Returns empty string for unknown roles.
|
// Returns empty string for unknown roles.
|
||||||
func getAgentBeadID(ctx RoleContext) string {
|
func getAgentBeadID(ctx RoleContext) string {
|
||||||
switch ctx.Role {
|
switch ctx.Role {
|
||||||
case RoleMayor:
|
case RoleMayor:
|
||||||
return beads.MayorBeadID()
|
return beads.MayorBeadIDTown()
|
||||||
case RoleDeacon:
|
case RoleDeacon:
|
||||||
return beads.DeaconBeadID()
|
return beads.DeaconBeadIDTown()
|
||||||
case RoleWitness:
|
case RoleWitness:
|
||||||
if ctx.Rig != "" {
|
if ctx.Rig != "" {
|
||||||
prefix := beads.GetPrefixForRig(ctx.TownRoot, ctx.Rig)
|
prefix := beads.GetPrefixForRig(ctx.TownRoot, ctx.Rig)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func TestGetAgentBeadID_UsesRigPrefix(t *testing.T) {
|
|||||||
Role: RoleMayor,
|
Role: RoleMayor,
|
||||||
TownRoot: townRoot,
|
TownRoot: townRoot,
|
||||||
},
|
},
|
||||||
want: "gt-mayor",
|
want: "hq-mayor",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "deacon",
|
name: "deacon",
|
||||||
@@ -44,7 +44,7 @@ func TestGetAgentBeadID_UsesRigPrefix(t *testing.T) {
|
|||||||
Role: RoleDeacon,
|
Role: RoleDeacon,
|
||||||
TownRoot: townRoot,
|
TownRoot: townRoot,
|
||||||
},
|
},
|
||||||
want: "gt-deacon",
|
want: "hq-deacon",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "witness",
|
name: "witness",
|
||||||
|
|||||||
@@ -715,9 +715,9 @@ func (d *Daemon) identityToAgentBeadID(identity string) string {
|
|||||||
|
|
||||||
switch parsed.RoleType {
|
switch parsed.RoleType {
|
||||||
case "deacon":
|
case "deacon":
|
||||||
return beads.DeaconBeadID()
|
return beads.DeaconBeadIDTown()
|
||||||
case "mayor":
|
case "mayor":
|
||||||
return beads.MayorBeadID()
|
return beads.MayorBeadIDTown()
|
||||||
case "witness":
|
case "witness":
|
||||||
return beads.WitnessBeadID(parsed.RigName)
|
return beads.WitnessBeadID(parsed.RigName)
|
||||||
case "refinery":
|
case "refinery":
|
||||||
@@ -741,8 +741,8 @@ const DeadAgentTimeout = 15 * time.Minute
|
|||||||
func (d *Daemon) checkStaleAgents() {
|
func (d *Daemon) checkStaleAgents() {
|
||||||
// Known agent bead IDs to check
|
// Known agent bead IDs to check
|
||||||
agentBeadIDs := []string{
|
agentBeadIDs := []string{
|
||||||
beads.DeaconBeadID(),
|
beads.DeaconBeadIDTown(),
|
||||||
beads.MayorBeadID(),
|
beads.MayorBeadIDTown(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dynamically discover rigs from the rigs config
|
// Dynamically discover rigs from the rigs config
|
||||||
|
|||||||
Reference in New Issue
Block a user