feat(halacha): review-queue triage — defer + batch group actions + quality-flag badges (#84)

Make the chair's pending-halacha review faster and less exhausting.

Backend:
- New 'deferred' review_status (snooze): stays out of the active library AND
  out of the default pending queue, without the finality of 'rejected'.
  update_halacha stamps reviewer+reviewed_at on defer; HALACHA_REVIEW_STATUSES
  is the single source of valid statuses (PATCH validation now uses it).
- db.update_halachot_batch(ids, status, reviewer) — one atomic UPDATE for a
  whole group; invalid status / empty ids are a no-op.
- POST /api/halachot/batch (HalachaBatchReviewRequest) wraps it.
- update_halacha now RETURNs quality_flags too (parity with list_halachot).

Frontend (halacha-review-panel):
- Quality-flag badges (#81: non_decision / truncated_quote / thin_restatement /
  quote_unverified) so the chair sees WHY an item was held back.
- Defer action — button + keyboard 'D' — to snooze without rejecting (fixes the
  'leave in pending forever' anti-pattern; reject stays the junk verb).
- Per-precedent batch bar: 'אשר הכל' / 'דחה הכל' via useBatchReviewHalachot
  (one request, one refetch) with confirm guards.
- Halacha/HalachaPatch types gain quality_flags + 'deferred'.

Verified: mcp-server suite 156 passed; web build green; end-to-end integration
against dev DB (batch approve/reject, defer sets status+timestamp, pending
excludes approved+deferred, deferred queryable, invalid status no-op).

Note: api:types regen deferred until deploy (the batch hook is hand-typed, not
dependent on generated types).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-03 13:42:21 +00:00
parent 7ebddcce6d
commit eeb70a5758
4 changed files with 173 additions and 14 deletions

View File

@@ -72,7 +72,10 @@ export type Halacha = {
cites: string[];
confidence: number;
quote_verified: boolean;
review_status: "pending_review" | "approved" | "rejected" | "published";
/* #81 strict-rubric quality flags — non_decision | truncated_quote |
* thin_restatement | quote_unverified. Any flag blocked auto-approval. */
quality_flags?: string[];
review_status: "pending_review" | "approved" | "rejected" | "published" | "deferred";
reviewer: string;
reviewed_at: string | null;
created_at: string;
@@ -574,7 +577,7 @@ export function useHalachotPending(limit = 200) {
}
export type HalachaPatch = Partial<{
review_status: "pending_review" | "approved" | "rejected" | "published";
review_status: "pending_review" | "approved" | "rejected" | "published" | "deferred";
reviewer: string;
rule_statement: string;
reasoning_summary: string;
@@ -595,3 +598,23 @@ export function useUpdateHalacha() {
},
});
}
export type BatchReviewStatus =
| "approved" | "rejected" | "deferred" | "pending_review" | "published";
/** #84 — apply one review status to many halachot in a single request. */
export function useBatchReviewHalachot() {
const qc = useQueryClient();
return useMutation({
mutationFn: ({ ids, status, reviewer }: {
ids: string[]; status: BatchReviewStatus; reviewer?: string;
}) =>
apiRequest<{ updated: number }>(
`/api/halachot/batch`,
{ method: "POST", body: { halacha_ids: ids, review_status: status, reviewer } },
),
onSuccess: () => {
qc.invalidateQueries({ queryKey: libraryKeys.all });
},
});
}