feat(01-04): add auto-trigger hook + triggerAutoRank + retroactiveScan

- evaluation.ts: add triggerAutoRankIfComplete (module-level, not exported)
  - Checks total/completed required assignments for round
  - Reads autoRankOnComplete + rankingCriteria from round configJson
  - 5-minute cooldown guard on AUTO snapshots
  - Fire-and-forget via void call after isCompleted=true (never awaited)
  - Notifies admins via AI_RANKING_COMPLETE / AI_RANKING_FAILED
- ranking.ts: add triggerAutoRank procedure (RANK-09)
  - Admin manual trigger reading criteria from round configJson
  - Creates MANUAL snapshot with QUICK mode
- ranking.ts: add retroactiveScan procedure (RANK-10)
  - Scans ROUND_ACTIVE / ROUND_CLOSED rounds for auto-rank configured
  - Skips rounds with existing RETROACTIVE snapshots
  - Runs sequentially to avoid rate limits
- ranking.ts: router now has 7 total procedures
This commit is contained in:
2026-02-27 01:05:10 +01:00
parent d1d64cb6f7
commit c310631480
4 changed files with 251 additions and 9 deletions

View File

@@ -10,27 +10,27 @@ See: .planning/PROJECT.md (updated 2026-02-26)
## Current Position
Phase: 1 of 4 (AI Ranking Backend)
Plan: 2 of TBD in current phase
Plan: 3 of TBD in current phase
Status: In progress
Last activity: 2026-02-26 — Plan 02 complete: AI ranking service built (ai-ranking.ts + AIAction RANKING)
Last activity: 2026-02-27 — Plan 03 complete: tRPC rankingRouter with 5 procedures registered in appRouter
Progress: [██░░░░░░░] ~20%
Progress: [██░░░░░░░] ~30%
## Performance Metrics
**Velocity:**
- Total plans completed: 2
- Total plans completed: 3
- Average duration: ~3 min
- Total execution time: ~6 min
- Total execution time: ~10 min
**By Phase:**
| Phase | Plans | Total | Avg/Plan |
|-------|-------|-------|----------|
| 01-ai-ranking-backend | 2 | ~6 min | ~3 min |
| 01-ai-ranking-backend | 3 | ~10 min | ~3 min |
**Recent Trend:**
- Last 5 plans: 01-01 (~3 min), 01-02 (~3 min)
- Last 5 plans: 01-01 (~3 min), 01-02 (~3 min), 01-03 (~4 min)
- Trend: Fast (service-layer tasks)
*Updated after each plan completion*
@@ -51,6 +51,8 @@ Recent decisions affecting current work:
- [01-02]: fetchAndRankCategory exported (not private) so tRPC router can execute pre-parsed rules without re-parsing
- [01-02]: Projects with zero SUBMITTED evaluations excluded from ranking entirely (not ranked last)
- [01-02]: PrismaClient imported as real type (not import type) so transaction clients are compatible
- [01-03]: Typed arrays cast to Prisma.InputJsonValue via `unknown` (direct cast rejected by strict TS — no index signature)
- [01-03]: getSnapshot uses findUnique + manual TRPCError NOT_FOUND (findUniqueOrThrow gives INTERNAL_SERVER_ERROR)
### Pending Todos
@@ -65,5 +67,5 @@ None yet.
## Session Continuity
Last session: 2026-02-27
Stopped at: Completed 01-01-PLAN.md (RankingSnapshot schema + EvaluationConfig ranking fields)
Stopped at: Completed 01-03-PLAN.md (tRPC rankingRouter — 5 procedures, registered in appRouter)
Resume file: None