Fix AI assignment workload imbalance: enforce caps and rebalance
All checks were successful
Build and Push Docker Image / build (push) Successful in 8m22s

Root cause: batches of 15 projects were processed independently -
GPT didn't see assignments from previous batches, so expert jurors
got assigned 18-22 projects while others got 4-5.

Fixes:
- Track cumulative assignments across batches (feed to each batch)
- Calculate ideal target per juror and communicate to GPT
- Add post-processing rebalancer that enforces hard caps and
  redistributes excess assignments to least-loaded jurors
- Calculate sensible default max cap when not configured
- Reweight prompt: workload balance 50%, expertise 35%, diversity 15%

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-18 16:16:55 +01:00
parent 8bbdc31d17
commit 6abf962fa0
2 changed files with 178 additions and 20 deletions

View File

@@ -134,7 +134,13 @@ export const roundAssignmentRouter = router({
// Build constraints
const configJson = round.configJson as Record<string, unknown> | null
const maxPerJuror = (configJson?.maxAssignmentsPerJuror as number) ?? undefined
const configuredMax = (configJson?.maxAssignmentsPerJuror as number) ?? undefined
// If no explicit cap, calculate a balanced one: ceil(total_needed / juror_count) + 2 buffer
const totalNeeded = projectStates.length * input.requiredReviews
const jurorCount = round.juryGroup.members.length
const calculatedMax = Math.ceil(totalNeeded / jurorCount) + 2
const maxPerJuror = configuredMax ?? calculatedMax
const constraints = {
requiredReviewsPerProject: input.requiredReviews,