diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index b57f227..8bc17dd 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -56,6 +56,9 @@ the resulting roles. ## 2. P2: Remove the restore test's incidental startup deadline +Status: Complete. Cancellation is synchronized after discovery with the session +lock held. Ten focused race repetitions and the full repository race suite pass. + Stage: 12; the fragile timing assumption predates this migration. Location: `internal/app/restore_execution_test.go:383–387`, diff --git a/internal/app/restore_execution_test.go b/internal/app/restore_execution_test.go index cd381de..634d0b6 100644 --- a/internal/app/restore_execution_test.go +++ b/internal/app/restore_execution_test.go @@ -380,8 +380,19 @@ func TestExecuteRestoreLockConflictFailsAndWritesNothing(t *testing.T) { deps := restoreCommandDependencies(fake) - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) + ctx, cancel := context.WithCancel(context.Background()) defer cancel() + discover := deps.discoverRemoteCurrentState + if discover == nil { + discover = discoverRemoteCurrentState + } + deps.discoverRemoteCurrentState = func(ctx context.Context, cfg *config.Config, store storage.ObjectStore) (*RemoteCurrentState, error) { + current, err := discover(ctx, cfg, store) + // Cancel after discovery so configuration and storage startup have no + // incidental deadline. The held lock must prevent installation. + cancel() + return current, err + } err = restoreWithDependencies(ctx, []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &bytes.Buffer{}, deps) if err == nil || !strings.Contains(err.Error(), "acquire session lock") { t.Fatalf("Restore() error = %v, want lock failure", err)