Agent web jobs now stop after Brain consolidation and enter needs_review with a persisted review queue (blocking: high-severity, low-confidence, sensitive-category findings; audit sample of clean clusters). Humans decide confirm/reject/unsure/needs_clarification via new review API and frontend queue; a finalizer applies decisions (rejections suppressed with reason codes), performs bounded targeted reruns for clarifications, drafts RFIs only for kept issues, and only then marks the job done and sends the final email. Two-phase email (review-required, then final report), per-decision feedback labels with redacted aggregate metrics, restart recovery from job artifacts, and CLI --no-review bypass. Classic pipeline unchanged. 65 non-LLM tests.
26 lines
891 B
Python
26 lines
891 B
Python
"""Aggregate metrics over feedback labels.
|
|
|
|
Default aggregates exclude source_text, images, raw sheet content, and
|
|
reviewer free-text comments; include_text=True is the only path that embeds
|
|
the raw labels.
|
|
"""
|
|
|
|
from collections import Counter
|
|
from typing import Dict, List
|
|
|
|
|
|
def aggregate_labels(labels: List[dict], include_text: bool = False) -> Dict:
|
|
decisions = Counter(label.get("decision") or "unknown" for label in labels)
|
|
reasons = Counter(label.get("reason_code") or "none" for label in labels if label.get("decision") == "reject")
|
|
summary = {
|
|
"total": len(labels),
|
|
"decisions": dict(decisions),
|
|
"reject_reasons": dict(reasons),
|
|
}
|
|
for label in labels:
|
|
decision = label.get("decision") or "unknown"
|
|
summary[decision] = summary.get(decision, 0) + 1
|
|
if include_text:
|
|
summary["labels"] = labels
|
|
return summary
|