Repository navigation
test(scheduler): kick the stale refresh with an unrestricted reader - #960
Conversation
#938 rewrote the stale-cache tests around staleListRecommendations, which reads through a plain context.Background(). #932 (a86c6d7) made ListRecommendations kick a cold-start or stale-cache collection only when ctx carries WithBackgroundCollection (scheduler.go mayCollect), so the two merged without a textual conflict but the positive test never saw a refresh and timed out on main. Mark the helper's ctx with WithBackgroundCollection, as the #932 tests do. This also keeps the TTL==0 sentinel test meaningful: with an unmarked ctx it could never refresh and would pass vacuously. Removing the TTL==0 guard now fails it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 1 billable file and costs up to $0.25.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 12 minutes for your next included review. View limit details
Comment |
Independent review verdict: CLEAN at d9e192fReviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. The PR body was treated as a claim. Coordinator: claude-cc-reviewer. Findings: none, blocking or non-blocking. What was attacked and how (local macOS, unit tests with mocks):
Gate: labels are set directly (no linked issue, as the body says). CodeRabbit is green. Merge waits on CI being green at this SHA. |
|
Independent review of d9e192f: CLEAN The fix is correct, test-only and in the right place. Two pre-existing vacuous Lambda tests (same family, not caused by this PR) are filed as non-blocking follow-ups. Findings
What I attacked
|
|
Gate record for d9e192f:
This is ready for a human merge. Merging it turns main green again, and it is test-only, so there is no deploy. |
mainis red.TestScheduler_ListRecommendations_StaleCacheKicksBackgroundRefreshfails in the Unit and Integration jobs on main (CI run 38887365202 at 18ee477, and every later PR run). The failure:Root cause
Two PRs merged with no textual conflict but broke each other:
ListRecommendationskick a cold-start or stale-cache collection only when the context carriesWithBackgroundCollection. The check ismayCollect := BackgroundCollectionAllowed(ctx)ininternal/scheduler/scheduler.go; the helpers are inbackground_collection.go.staleListRecommendationsreads through a plaincontext.Background(), so no refresh can start.Effects:
TestScheduler_ListRecommendations_StaleHoursZeroDisablesBackgroundRefresh, passes vacuously. An unmarked context never refreshes, whatever the TTL.Fix
Test-only. The helper now reads through
WithBackgroundCollection(context.Background()), the same way #932's own tests do. Production code is unchanged. #932's guard is intended: only unrestricted readers may kick a collection.Verification (macOS)
go test ./internal/scheduler -run 'TestScheduler_ListRecommendations_Stale' -count=2 -vfails on both runs with the message above.-count=20passes.scheduler.go, reverted):if false): the sentinel test now FAILS, so it is no longer vacuous.mayCollect := true: fix(api): only unrestricted readers may kick a recommendations collection #932'sTestListRecommendations_UnmarkedColdStart_NeverMarksOrCollectsandTestListRecommendations_UnmarkedStaleCache_NeverRefreshesstill fail as before.go test ./internal/scheduler ./internal/api/... -count=1passes, andmake lint(go1.26.9 toolchain) reports 0 issues.The
Lint Codefailure on main's run is unrelated: golangci-lint timed out fetching its JSON schema over the network.No issue was filed for this breakage, so the labels are set directly: bug, high severity because it blocks every PR's CI, urgent.
🤖 Generated with Claude Code