Role beads (hq-*-role) are templates that define role characteristics. They are created during gt install but creation may fail silently. Without role beads, agents fall back to defaults. Changes: - Add beads.AllRoleBeadDefs() as single source of truth for role bead definitions - Update gt install to use shared definitions - Add doctor check that detects missing role beads (warning, not error) - Doctor --fix creates missing role beads Fixes #371 Co-authored-by: julianknutsen <julianknutsen@users.noreply.github> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package doctor
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/steveyegge/gastown/internal/beads"
|
|
)
|
|
|
|
func TestRoleBeadsCheck_Run(t *testing.T) {
|
|
t.Run("no town beads returns warning", func(t *testing.T) {
|
|
tmpDir := t.TempDir()
|
|
// Create minimal town structure without .beads
|
|
if err := os.MkdirAll(filepath.Join(tmpDir, "mayor"), 0755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
check := NewRoleBeadsCheck()
|
|
ctx := &CheckContext{TownRoot: tmpDir}
|
|
result := check.Run(ctx)
|
|
|
|
// Without .beads directory, all role beads are "missing"
|
|
expectedCount := len(beads.AllRoleBeadDefs())
|
|
if result.Status != StatusWarning {
|
|
t.Errorf("expected StatusWarning, got %v: %s", result.Status, result.Message)
|
|
}
|
|
if len(result.Details) != expectedCount {
|
|
t.Errorf("expected %d missing role beads, got %d: %v", expectedCount, len(result.Details), result.Details)
|
|
}
|
|
})
|
|
|
|
t.Run("check is fixable", func(t *testing.T) {
|
|
check := NewRoleBeadsCheck()
|
|
if !check.CanFix() {
|
|
t.Error("RoleBeadsCheck should be fixable")
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestRoleBeadsCheck_usesSharedDefs(t *testing.T) {
|
|
// Verify the check uses beads.AllRoleBeadDefs()
|
|
roleDefs := beads.AllRoleBeadDefs()
|
|
|
|
if len(roleDefs) < 7 {
|
|
t.Errorf("expected at least 7 role beads, got %d", len(roleDefs))
|
|
}
|
|
|
|
// Verify key roles are present
|
|
expectedIDs := map[string]bool{
|
|
"hq-mayor-role": false,
|
|
"hq-deacon-role": false,
|
|
"hq-witness-role": false,
|
|
"hq-refinery-role": false,
|
|
}
|
|
|
|
for _, role := range roleDefs {
|
|
if _, exists := expectedIDs[role.ID]; exists {
|
|
expectedIDs[role.ID] = true
|
|
}
|
|
}
|
|
|
|
for id, found := range expectedIDs {
|
|
if !found {
|
|
t.Errorf("expected role %s not found in AllRoleBeadDefs()", id)
|
|
}
|
|
}
|
|
}
|