investigate: fix flaky picker tests racing on global override · Entire

investigate: fix flaky picker tests racing on global override

113bbd7→main·

gtrrz-victor·1w ago·1 file·+8 added/-2 removed

TestRunInvestigateConfigPicker_FiltersNonInstalled and TestRunInvestigateConfigPicker_QuorumExceedsAgents both installed a process-global picker-form override via SetPickerFormFnForTest while calling t.Parallel(). The atomic.Pointer prevents a data race but not the logical clobber: one test's override could replace the other's mid-run, so QuorumExceedsAgents would read the sibling's quorum=0 override and see no error — the exact flake seen in test-core. picker.go already documents that conflicting-override tests must not run in parallel. Drop t.Parallel() from both.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Sessions

01KX31J6HQTY4XX27QGH64PW1GView transcript

Changes

1

32 unmodified lines

33
34
35
36
37
38
39
40
37
41
42
43
40 unmodified lines

84
85
86
87
88
89
90
91
85
92
93
94

32 unmodified lines

// TestRunInvestigateConfigPicker_FiltersNonInstalled verifies that an
// agent with a spawner but no hooks installed is filtered out.
// Not parallel: installs a process-global picker-form override
// (SetPickerFormFnForTest). Running it in parallel with another override-
// installing test lets one clobber the other's override mid-run — see the
// contract on pickerFormOverride in picker.go.
func TestRunInvestigateConfigPicker_FiltersNonInstalled(t *testing.T) {

t.Parallel()
    cleanup := investigate.SetPickerFormFnForTest(func(_ context.Context, eligible []investigate.AgentChoice, picks *[]string, maxTurns, quorum *int) error {
        // Capture eligible into picks for assertion via the cfg.Agents.
        names := make([]string, 0, len(eligible))
40 unmodified lines

}
}

// Not parallel: installs a process-global picker-form override
// (SetPickerFormFnForTest), which must not run concurrently with another
// override-installing test — see the contract on pickerFormOverride in
// picker.go.
func TestRunInvestigateConfigPicker_QuorumExceedsAgents(t *testing.T) {

t.Parallel()
    cleanup := investigate.SetPickerFormFnForTest(func(_ context.Context, eligible []investigate.AgentChoice, picks *[]string, maxTurns, quorum *int) error {
        _ = eligible
        *picks = []string{"agent-a"}