feat(moderation): two-tier batch+individual fallback pipeline

- After a batch LLM call, any result flagged analysis_incomplete is
  immediately fanned out to an individual per-message fallback queue
- Batch hard-fail (result.ok=false) and unhandled exceptions now also
  route all affected messages to the individual queue instead of waiting
  behind the conversation error cooldown
- Individual queue runs fully parallel (fire-and-forget per message),
  de-duplicated by a Set<messageId> so no double-processing
- processIndividualFallback runs in the main process (no worker pool IPC
  overhead for a single-item call), with retryWithBackoff 2x/2-15s
- AnalysisQueueStatus gains activeIndividualRequests +
  individualInFlightCount fields for dashboard observability
This commit is contained in:
MythEclipse
2026-05-27 23:25:37 +07:00
parent 2156c52c35
commit 5925c11c54
2 changed files with 193 additions and 0 deletions
+4
View File
@@ -137,5 +137,9 @@ export type ModerationWsEvent =
export interface AnalysisQueueStatus {
queuedConversations: number;
activeRequests: number;
/** Number of single-message fallback calls currently awaiting the LLM. */
activeIndividualRequests: number;
/** Number of message IDs sitting in the dedup set (in-flight or about to start). */
individualInFlightCount: number;
lastError: string | null;
}