From 55db13fc068a282c66571d18486bd50713aaded1 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 11 Jun 2026 15:48:00 +0100 Subject: [PATCH] Fix CI test drift and SSE idle race Refs Build and Test failures on pulse/v6-release. --- internal/api/ai_handlers.go | 7 ++++--- internal/monitoring/mock_metrics_history_test.go | 4 ++-- scripts/tests/test-hot-dev-bg.sh | 10 ++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go index 78010e2cf..041b1510a 100644 --- a/internal/api/ai_handlers.go +++ b/internal/api/ai_handlers.go @@ -3477,12 +3477,13 @@ func (s *legacyAssistantSSEWriter) startHeartbeat(ctx context.Context) { } func (s *legacyAssistantSSEWriter) startIdleProgress(ctx context.Context) { - if chatStreamIdleProgressInterval <= 0 { + interval := chatStreamIdleProgressInterval + if interval <= 0 { return } go func() { - ticker := time.NewTicker(chatStreamIdleProgressInterval) + ticker := time.NewTicker(interval) defer ticker.Stop() for { select { @@ -3500,7 +3501,7 @@ func (s *legacyAssistantSSEWriter) startIdleProgress(ctx context.Context) { return } lastEventAt := time.UnixMilli(s.lastClientEventUnixMS.Load()) - if time.Since(lastEventAt) < chatStreamIdleProgressInterval { + if time.Since(lastEventAt) < interval { continue } progressEvent := ai.StreamEvent{ diff --git a/internal/monitoring/mock_metrics_history_test.go b/internal/monitoring/mock_metrics_history_test.go index c191ea566..14f005414 100644 --- a/internal/monitoring/mock_metrics_history_test.go +++ b/internal/monitoring/mock_metrics_history_test.go @@ -764,9 +764,9 @@ func TestSeedMockMetricsHistory_UsesCanonicalMockFixtureGraphForLegacyAndProvide sampleInterval := time.Minute historyRetention := boundedMockHistoryProofWindow if raceEnabled { - seedDuration = 5 * time.Minute + seedDuration = 3 * time.Hour sampleInterval = time.Minute - historyRetention = 10 * time.Minute + historyRetention = 3 * time.Hour } cfg := metrics.DefaultConfig(t.TempDir()) diff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.sh index 247aa3f91..18fa5c0fc 100755 --- a/scripts/tests/test-hot-dev-bg.sh +++ b/scripts/tests/test-hot-dev-bg.sh @@ -707,7 +707,13 @@ test_makefile_routes_managed_runtime_through_npm() { test_hot_dev_script_advertises_foreground_escape_hatch() { local output - output="$(sed -n '1,40p' "${HOT_DEV}")" + output="$( + awk ' + NR == 1 { print; next } + /^#/ || /^$/ { print; next } + { exit } + ' "${HOT_DEV}" + )" assert_contains "hot-dev header identifies foreground escape hatch" "${output}" "hot-dev.sh - Foreground Pulse dev runtime escape hatch" assert_contains "hot-dev usage points to managed runtime first" "${output}" "npm run dev # Canonical managed dev runtime" @@ -821,7 +827,7 @@ test_hot_dev_health_monitor_probes_api_health() { local output output="$(cat "${HOT_DEV}")" - assert_contains "hot-dev health monitor declares a configurable unhealthy streak threshold" "${output}" 'UNHEALTHY_THRESHOLD="${HOT_DEV_BACKEND_UNHEALTHY_THRESHOLD:-2}"' + assert_contains "hot-dev health monitor declares a configurable unhealthy streak threshold" "${output}" 'UNHEALTHY_THRESHOLD="${HOT_DEV_BACKEND_UNHEALTHY_THRESHOLD:-4}"' assert_contains "hot-dev health monitor declares backend startup grace" "${output}" 'BACKEND_HEALTH_STARTUP_GRACE_SECONDS="${HOT_DEV_BACKEND_HEALTH_STARTUP_GRACE_SECONDS:-180}"' assert_contains "hot-dev health monitor declares missing-process grace" "${output}" 'BACKEND_PROCESS_MISSING_GRACE_SECONDS="${HOT_DEV_BACKEND_PROCESS_MISSING_GRACE_SECONDS:-10}"' assert_contains "hot-dev health monitor tracks backend restart time through a shared marker" "${output}" 'BACKEND_STARTED_AT_FILE="${HOT_DEV_BACKEND_STARTED_AT_FILE:-${ROOT_DIR}/tmp/hot-dev.backend.started-at}"'