Summary
Several read endpoints still join tokens even when the request does not filter by verified/claimed status and does not return token-derived fields. These are related to the D1 read disparity addressed for /api/submissions, but broadening the current PR would increase regression risk across leaderboard/model/provider response shapes.
Candidate endpoints
/api/model-submissions: best-row and list queries join tokens even when verified=false and no claimed data is returned.
/api/models, /api/providers, /api/providers/:provider/models: joins appear necessary only for verified=true.
/api/leaderboard: aggregate query and totalModels paths should be audited for token joins that are unrelated to verified filtering.
Acceptance criteria
- Add representative parity tests for each affected endpoint and query shape.
- Skip
tokens joins whenever no verified predicate or token-derived projection is required.
- Add SQL-shape regression tests to prevent unconditional joins from returning.
- Include lightweight row-read or query-plan assertions where practical.
Notes
The /api/submissions pagination COUNT hot path is intentionally handled separately in the current fix branch to keep the production change minimal and low risk.
Summary
Several read endpoints still join
tokenseven when the request does not filter by verified/claimed status and does not return token-derived fields. These are related to the D1 read disparity addressed for/api/submissions, but broadening the current PR would increase regression risk across leaderboard/model/provider response shapes.Candidate endpoints
/api/model-submissions: best-row and list queries jointokenseven whenverified=falseand no claimed data is returned./api/models,/api/providers,/api/providers/:provider/models: joins appear necessary only forverified=true./api/leaderboard: aggregate query andtotalModelspaths should be audited for token joins that are unrelated to verified filtering.Acceptance criteria
tokensjoins whenever no verified predicate or token-derived projection is required.Notes
The
/api/submissionspagination COUNT hot path is intentionally handled separately in the current fix branch to keep the production change minimal and low risk.