Skip to content

ADR 0004: M2 review actions

The read-only inbox proved reviewer login and session-based reads, but every disposition still required an API key. The office needs to accept, return, reject, or request information from capture detail while preserving reviewer attribution and an append-only audit trail.

reviewCapture owns the matrix:

Current status accept return reject request information
in_review accepted returned rejected returned
needs_match rejected returned rejected returned
accepted, returned, rejected rejected rejected rejected rejected

Accept requires a matched parcel. The API returns 409 invalid_transition for an unsupported transition or terminal status, and 409 parcel_required for a corrupt in_review capture with no parcel. The UI mirrors the matrix but the core remains authoritative.

The capture contract has six statuses and no waiting_on_submitter. Request information moves the capture to returned and records capture.information_requested with the reviewer’s note. The distinct event preserves intent. A dedicated waiting status needs a resubmission workflow and is deferred.

Reasons are required where the office needs an explanation

Section titled “Reasons are required where the office needs an explanation”

Return, reject, and request information require a trimmed reason of 1–2000 characters (HTTP 422 review_reason_required when missing). Accept may include an optional note. The reason is stored as the audit event note and rendered in the timeline.

POST /v1/captures/:id/review uses requireSession and the existing origin check. Bearer API keys cannot review. Only active users with role reviewer or admin may review; a submitter receives HTTP 403. A future admin slice can decide whether login should filter roles earlier.

SameSite=Lax plus the origin check protect the cookie-authenticated write. A per-form CSRF token remains a hardening item alongside review-adjacent admin writes.

The core reads the capture, validates the transition, and asks the repository to apply the new status only when it still equals the status that was read. The D1 adapter performs a guarded update and an event insert in one batch; a zero-row update returns a conflict and inserts no event. The web client sends the displayed status as expectedStatus so a stale view produces 409 capture_status_conflict instead of silently overwriting another reviewer’s decision.

Capture detail shows four action buttons for in_review and needs_match. Selecting an action opens a reason form; accept is disabled without a matched parcel. Success replaces the cached detail with the API response and invalidates capture lists. Terminal captures show the disposition and no controls. Errors keep the previous status visible and offer a reload.

  • No schema or migration change; capture_events already supports reviewer actors.
  • Captures reach accepted, returned, or rejected entirely from the browser without an API key.
  • Returned and information-requested captures share a status; reports must use the event action to distinguish them.
  • Reopening is not supported. A corrected submission is a new capture, preserving append-only history.
  • Parcel matching remains the blocker for accepting needs_match captures.
  • Review actions currently live only on capture detail; bulk review and assignments are future work.