- The work-buffer poll resolved each item's project, workflow and capture
labels by reading the full run document (up to 6MB) every 3s. Cache the
resolved labels per item for 2 minutes.
- Slots whose item the active scan already counted keep their slot without
rereading the item and its claim receipt (same outcome as before).
- Draft, review-draft, review-session and work-buffer saves no longer flush
the dashboard response cache; they change nothing a dashboard counts.
Local perf DB with a 6MB run: poll total p50 141ms -> 7ms (enrich 131 -> 0),
byte-identical response. Admin dashboard stays cached across draft and
session saves and is still recomputed after other writes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The trace deployed in round5 located the cost: batches_ms carried 80% of
every work-buffer poll (1400-3900ms of 1600-4100ms total). The poller's
enablement check called ListHumanBatches for the project, which — because
the legacy migration created one batch per task — materialized 12,009 full
batch documents on every 3s poll, walking an organizationId-only index over
17,334 docs.
- HasRawHumanAnnotationBatch (Memory + Mongo): projects only the stages
field and stops at the first three-role raw_human match (105ms on the
production dataset, was 2000ms+).
- New humanBatches index organizationId_projectId_pluginId backs both the
enablement query and ListHumanBatches' project-scoped reads.
- store.Store interface gains the method; both store implementations keep
identical semantics (mid-test profile flips stay visible).
The new indexes cut the work-buffer poll from 3-5s to 2-3s, but the remaining
cost is unlocated. This trace records where the time goes per poll so the
next fix targets evidence, not guesses.