fix: prefer witness agent override
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user