Skip to content

Commit 8ad34e6

Browse files
mayorPunit Rathore
authored andcommitted
Auto-heal witness beads redirects
Executed-By: mayor
1 parent db74d75 commit 8ad34e6

5 files changed

Lines changed: 39 additions & 4 deletions

File tree

.beads/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Dolt database (managed by Dolt, not git)
22
dolt/
3+
embeddeddolt/
34

45
# Runtime files
56
bd.sock

.beads/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ types.custom: "agent,role,rig,convoy,slot,queue,event,message,molecule,gate,merg
4545
prefix:
4646
issue-prefix:
4747
dolt.idle-timeout: "0"
48+
49+
sync.remote: "git+https://github.com/steveyegge/gastown.git"

internal/cmd/prime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ func getAgentBeadID(ctx RoleContext) string {
11301130
// Uses the shared SetupRedirect helper which handles both tracked and local beads.
11311131
func ensureBeadsRedirect(ctx RoleContext) {
11321132
// Only applies to worktree-based roles that use shared beads
1133-
if ctx.Role != RoleCrew && ctx.Role != RolePolecat && ctx.Role != RoleRefinery {
1133+
if ctx.Role != RoleCrew && ctx.Role != RolePolecat && ctx.Role != RoleRefinery && ctx.Role != RoleWitness {
11341134
return
11351135
}
11361136

internal/cmd/prime_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,36 @@ func TestCompactResumeReminder_NonPolecatNoGtDone(t *testing.T) {
948948
}
949949
}
950950

951+
func TestEnsureBeadsRedirect_WitnessCreatesRedirect(t *testing.T) {
952+
townRoot := t.TempDir()
953+
rigRoot := filepath.Join(townRoot, "testrig")
954+
witnessDir := filepath.Join(rigRoot, "witness")
955+
mayorBeadsDir := filepath.Join(rigRoot, "mayor", "rig", ".beads")
956+
if err := os.MkdirAll(witnessDir, 0755); err != nil {
957+
t.Fatalf("mkdir witness dir: %v", err)
958+
}
959+
if err := os.MkdirAll(mayorBeadsDir, 0755); err != nil {
960+
t.Fatalf("mkdir mayor beads dir: %v", err)
961+
}
962+
963+
ctx := RoleContext{
964+
Role: RoleWitness,
965+
WorkDir: witnessDir,
966+
TownRoot: townRoot,
967+
}
968+
969+
ensureBeadsRedirect(ctx)
970+
971+
redirectPath := filepath.Join(witnessDir, ".beads", "redirect")
972+
content, err := os.ReadFile(redirectPath)
973+
if err != nil {
974+
t.Fatalf("read redirect: %v", err)
975+
}
976+
if got, want := string(content), "../mayor/rig/.beads\n"; got != want {
977+
t.Fatalf("redirect content = %q, want %q", got, want)
978+
}
979+
}
980+
951981
// TestOutputRalphLoopDirective_NoSlashCommand verifies that ralph mode emits
952982
// inline iterative work instructions instead of referencing a nonexistent
953983
// /ralph-loop slash command. This is the regression test for the ralph-loop

internal/witness/manager.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,17 @@ func (m *Manager) Start(foreground bool, agentOverride string, envOverrides []st
149149

150150
// Note: No PID check per ZFC - tmux session is the source of truth
151151

152-
// Working directory
153-
witnessDir := m.witnessDir()
154-
155152
// Ensure runtime settings exist in the shared witness parent directory.
156153
// Settings are passed to Claude Code via --settings flag.
157154
// ResolveRoleAgentConfig is internally serialized (resolveConfigMu in
158155
// package config) to prevent concurrent rig starts from corrupting the
159156
// global agent registry.
157+
// Working directory
158+
witnessDir := m.witnessDir()
160159
townRoot := m.townRoot()
160+
if err := beads.SetupRedirect(townRoot, witnessDir); err != nil {
161+
return fmt.Errorf("ensuring witness beads redirect: %w", err)
162+
}
161163

162164
// Resolve CLAUDE_CONFIG_DIR from accounts.json so witness sessions
163165
// use the correct account. Mirrors the daemon restart path (lifecycle.go).

0 commit comments

Comments
 (0)