fix: prefer witness agent override

This commit is contained in:
joshuavial
2026-01-09 22:24:09 +13:00
committed by Steve Yegge
parent 271bd7ea0a
commit bfd3096b49
2 changed files with 20 additions and 0 deletions

View File

@@ -277,6 +277,9 @@ func roleConfigEnvVars(roleConfig *beads.RoleConfig, townRoot, rigName string) m
}
func buildWitnessStartCommand(rigPath, rigName, townRoot, agentOverride string, roleConfig *beads.RoleConfig) (string, error) {
if agentOverride != "" {
roleConfig = nil
}
if roleConfig != nil && roleConfig.StartCommand != "" {
return beads.ExpandRolePattern(roleConfig.StartCommand, townRoot, rigName, "", "witness"), nil
}

View File

@@ -36,3 +36,20 @@ func TestBuildWitnessStartCommand_DefaultsToRuntime(t *testing.T) {
t.Errorf("expected BD_ACTOR=gastown/witness in command, got %q", got)
}
}
func TestBuildWitnessStartCommand_AgentOverrideWins(t *testing.T) {
roleConfig := &beads.RoleConfig{
StartCommand: "exec run --role {role}",
}
got, err := buildWitnessStartCommand("/town/rig", "gastown", "/town", "codex", roleConfig)
if err != nil {
t.Fatalf("buildWitnessStartCommand: %v", err)
}
if strings.Contains(got, "exec run") {
t.Fatalf("expected agent override to bypass role start_command, got %q", got)
}
if !strings.Contains(got, "GT_ROLE=witness") {
t.Errorf("expected GT_ROLE=witness in command, got %q", got)
}
}