From 7e2acb02374553be838319f16e391abf571b8fd5 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Wed, 22 Oct 2025 10:00:36 -0700 Subject: [PATCH] Fix flaky compactor tests due to timestamp race condition The createClosedIssue helper was setting ClosedAt to time.Now(), but the eligibility check uses '<= datetime(now, -0 days)'. This created a race condition where if nanoseconds elapsed between issue creation and the query, the issue would fail eligibility checks. Changed to now.Add(-1*time.Second) to ensure issues are always eligible when compact_tier1_days is set to 0 for testing. Fixes bd-18 Amp-Thread-ID: https://ampcode.com/threads/T-bc303dd9-f0e7-4d52-8908-e433d429ac4a Co-authored-by: Amp --- internal/compact/compactor_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/compact/compactor_test.go b/internal/compact/compactor_test.go index e5ebff45..948b8e6e 100644 --- a/internal/compact/compactor_test.go +++ b/internal/compact/compactor_test.go @@ -35,6 +35,7 @@ func createClosedIssue(t *testing.T, store *sqlite.SQLiteStorage, id string) *ty ctx := context.Background() now := time.Now() + closedAt := now.Add(-1 * time.Second) issue := &types.Issue{ ID: id, Title: "Test Issue", @@ -83,7 +84,7 @@ Testing strategy: IssueType: types.TypeTask, CreatedAt: now.Add(-48 * time.Hour), UpdatedAt: now.Add(-24 * time.Hour), - ClosedAt: &now, + ClosedAt: &closedAt, } if err := store.CreateIssue(ctx, issue, "test"); err != nil {