ADR 0004: M2 review actions
- Status: Accepted
- Date: 2026-11-24
- Deciders: AP Dev Solutions, LLC
- Related: the project overview §8, §9, §11, §14 (M2),
docs/adr/0002-m1-capture-api.md,docs/adr/0003-m2-reviewer-sessions.md,openspec/changes/m2-review-actions/design.md
Context
Section titled “Context”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.
Decisions
Section titled “Decisions”One core transition matrix
Section titled “One core transition matrix”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.
Request information reuses returned
Section titled “Request information reuses returned”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.
Review is session-only and same-origin
Section titled “Review is session-only and same-origin”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.
Status updates are conditional and atomic
Section titled “Status updates are conditional and atomic”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.
The detail page owns the action flow
Section titled “The detail page owns the action flow”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.
Consequences
Section titled “Consequences”- No schema or migration change;
capture_eventsalready supports reviewer actors. - Captures reach
accepted,returned, orrejectedentirely 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_matchcaptures. - Review actions currently live only on capture detail; bulk review and assignments are future work.