ADR 0005: M2 parcel resolution
- 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/0004-m2-review-actions.md,openspec/changes/m2-parcel-resolution/design.md
Context
Section titled “Context”Intake stores captures with no confident parcel match as needs_match and parcel_id = NULL. Review
actions can return or reject them, but accept requires a matched parcel, so the office cannot finish
the capture entirely in the browser. Parcel search and the parcel identity constraints already exist.
Decisions
Section titled “Decisions”One resolution endpoint with one parcel source
Section titled “One resolution endpoint with one parcel source”POST /v1/captures/:id/resolve-parcel accepts exactly one of:
{ "parcelId": "uuid" }{ "parcel": { "mapLot": "014-022-003", "address": "12 Elm Street", "ownerName": "Synthetic Owner" }, "expectedStatus": "needs_match"}Both or neither source is a 422 validation_failed. Existing parcels must belong to the capture’s
tenant and town; a mismatch is 422 parcel_not_found rather than a leak. New map/lot and address are
required; owner is optional.
Alternative considered: separate match and create endpoints. Rejected because the operation and audit event are the same.
Resolution is limited to needs_match
Section titled “Resolution is limited to needs_match”The endpoint does not rematch in_review or terminal captures. A stale expectedStatus returns
409 capture_status_conflict; any other status returns 409 invalid_transition. Rematching would
need its own decision about replacing an existing audit-backed match and is deferred.
Parcel creation and matching are one atomic batch
Section titled “Parcel creation and matching are one atomic batch”CaptureRepository.assignParcel runs one D1 batch:
- When creating, insert the parcel only if the capture is still
needs_match. - Update the capture: set
parcel_id, set statusin_review, guarded byneeds_match. - Insert the event only if the update changed a row (
changes() = 1).
A stale status makes steps 1 and 2 no-ops, so no parcel or event remains. A duplicate map/lot raises
the parcel unique constraint; the adapter translates it to DuplicateParcelError and the core returns
409 parcel_exists. The batch is transactional, so a failed duplicate insert rolls back the whole
operation.
Alternative considered: create the parcel first, then update the capture. Rejected because a failed match would leave an orphan parcel.
Resolution is a reviewer action
Section titled “Resolution is a reviewer action”The route uses requireSession and requireSameOrigin; active reviewer and admin roles may
resolve. API keys cannot resolve parcels. The event is capture.parcel_matched with actorType user,
the reviewer id and name, needs_match as the previous status, and in_review as the result.
The detail page owns parcel resolution
Section titled “The detail page owns parcel resolution”A panel renders only for needs_match captures. Existing-parcel mode searches by map/lot, address, or
owner within the capture’s town. Create mode prefills map/lot and address from the submitted payload
and accepts an optional owner. Success replaces the cached detail, invalidates capture lists, removes
the panel, and shows the parcel event; accept becomes available because the capture is now
in_review.
Consequences
Section titled “Consequences”- No schema or migration change.
- A reviewer can complete the M2 path: login → resolve parcel → accept or return → audit trail.
- Parcel creation currently exists only through resolution. Admin create/edit/import remains future work and should reuse the core creation rules.
- Rematching, parcel deletion, and parcel merge are not supported.
- Parcel search is bounded at 50 results until parcel/admin paging work.
- SameSite=Lax plus the same-origin check protect the cookie-authenticated write; CSRF tokens remain a hardening item.