fix: Create and lookup rig agent beads with correct prefix

Per docs/architecture.md, Witness and Refinery are rig-level agents that
should use the rig's configured prefix (e.g., pi- for pixelforge) instead
of hardcoded "gt-".

This extends PR #183's creation fix to also fix all lookup paths:
- internal/rig/manager.go: Create agent beads in rig beads with rig prefix
- internal/daemon/daemon.go: Use rig prefix when looking up agent state
- internal/daemon/lifecycle.go: Use rig prefix for identity-to-bead mapping
- internal/cmd/sling.go: Pass townRoot for prefix lookup
- internal/cmd/unsling.go: Pass townRoot for prefix lookup
- internal/cmd/molecule_status.go: Use rig prefix for agent bead lookups
- internal/cmd/molecule_attach.go: Use rig prefix for agent bead lookups
- internal/config/loader.go: Add GetRigPrefix helper

Without this fix, the daemon would:
- Create pi-gastown-witness but look for gt-gastown-witness
- Report agents as missing/dead when they are running
- Fail to manage agent lifecycle correctly

Based on work by Johann Taberlet in PR #183.

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

Co-Authored-By: Johann Taberlet <johann.taberlet@gmail.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/jack
2026-01-05 19:39:42 -08:00
committed by Steve Yegge
parent fc0b506253
commit e8d27e7212
8 changed files with 100 additions and 55 deletions

View File

@@ -556,14 +556,15 @@ func (m *Manager) initBeads(rigPath, prefix string) error {
// Town-level agents (Mayor, Deacon) are created by gt install in town beads.
// Role beads are also created by gt install with hq- prefix.
//
// Format: <prefix>-<rig>-<role> (e.g., gt-gastown-witness)
// Rig-level agents (Witness, Refinery) are created here in rig beads with rig prefix.
// Format: <prefix>-<rig>-<role> (e.g., pi-pixelforge-witness)
//
// Agent beads track lifecycle state for ZFC compliance (gt-h3hak, gt-pinkq).
func (m *Manager) initAgentBeads(_, rigName, _ string) error { // rigPath and prefix unused until Phase 2
// TEMPORARY (gt-4r1ph): Currently all agent beads go in town beads.
// After Phase 2, only Mayor/Deacon will be here; Witness/Refinery go to rig beads.
townBeadsDir := filepath.Join(m.townRoot, ".beads")
bd := beads.NewWithBeadsDir(m.townRoot, townBeadsDir)
func (m *Manager) initAgentBeads(rigPath, rigName, prefix string) error {
// Rig-level agents go in rig beads with rig prefix (per docs/architecture.md).
// Town-level agents (Mayor, Deacon) are created by gt install in town beads.
rigBeadsDir := filepath.Join(rigPath, ".beads")
bd := beads.NewWithBeadsDir(rigPath, rigBeadsDir)
// Define rig-level agents to create
type agentDef struct {
@@ -573,17 +574,17 @@ func (m *Manager) initAgentBeads(_, rigName, _ string) error { // rigPath and pr
desc string
}
// Create rig-specific agents using gt prefix (agents stored in town beads).
// Format: gt-<rig>-<role> (e.g., gt-gastown-witness)
// Create rig-specific agents using rig prefix in rig beads.
// Format: <prefix>-<rig>-<role> (e.g., pi-pixelforge-witness)
agents := []agentDef{
{
id: beads.WitnessBeadID(rigName),
id: beads.WitnessBeadIDWithPrefix(prefix, rigName),
roleType: "witness",
rig: rigName,
desc: fmt.Sprintf("Witness for %s - monitors polecat health and progress.", rigName),
},
{
id: beads.RefineryBeadID(rigName),
id: beads.RefineryBeadIDWithPrefix(prefix, rigName),
roleType: "refinery",
rig: rigName,
desc: fmt.Sprintf("Refinery for %s - processes merge queue.", rigName),