Fix decide-after-finish refusal and run size loop data race

A run stays in r.active after finishRunState persists its terminal status
until its goroutine finishes notifying, so a decision in that window was
refused as "already active". decide now refuses only runs whose terminal
state is not yet durable; a finished run gets ResolveDecision's
already-decided / not-waiting answer, and an executing run is still refused.

Tests overwrote runner.artifactsRoot after Handler/newRunner had started
background goroutines (sizeLoop, session export jobs) that read it. The
root is now fixed at construction through newRunnerAt, which
HandlerWithOptions uses for Options.ArtifactsRoot, and tests configure it
there instead of mutating the field afterwards.
This commit is contained in:
2026-11-01 18:58:14 +00:00
parent c41f5caa4f
commit 3bfb3d6b44
10 changed files with 89 additions and 22 deletions
+1 -2
View File
@@ -95,9 +95,8 @@ func sessionExportRunner(t *testing.T, backend string, seam func(stage.SessionEx
if err != nil {
t.Fatal(err)
}
handler := Handler(ctx, store).(*runHandler)
handler := HandlerWithOptions(ctx, Options{ArtifactsRoot: t.TempDir()}, store).(*runHandler)
t.Cleanup(func() { cancel(); WaitRuns(handler) })
handler.runner.artifactsRoot = t.TempDir()
if seam != nil {
handler.runner.exportSession = func(_ context.Context, request stage.SessionExportRequest) (stage.SessionExportResult, error) {
return seam(request)