Tree Identity Contract¶
Purpose¶
This note defines the new client/server contract for customer-scoped tree identity.
Operational rule¶
A job has two identifiers:
- job_number identifies the job
- tree_number identifies the tree for that customer
Multiple job numbers may refer to the same tree number.
Resolution rule¶
For a given customer:
if a valid
tree_numberis supplied, reuse or create that tree identityotherwise allocate the next available tree number
Database model¶
customerstreesjobs
Key constraints:
treesare unique by(customer_id, tree_number)jobsreferencetree_idand also storetree_numberfor operational convenience
Client contract impact¶
The client should treat tree_number as server-authoritative.
This means:
the client may begin without a final tree number for a phone-started job
after submit/review return, the client must accept and display the server value
later jobs for the same tree may have different
job_numbervalues but the sametree_number
Runtime API contract¶
The live server now exposes tree identity through the operational job endpoints.
POST /v1/jobsRequest accepts:
customer_name(optional but strongly preferred)tree_number(optional provisional customer-scoped tree number)
Response returns:
authoritative
job_numberauthoritative
tree_number
GET /v1/jobs/assignedEach assigned job row includes
tree_number.GET /v1/jobs/{job_id}Status payload includes
tree_number.POST /v1/jobs/{job_id}/rounds/{round_id}/submitThe server reads any provisional
client_tree_details.tree_numberin the submitted form, resolves the authoritative tree identity, writes that value back into the working form payload, and returns top-leveltree_numberin the submit response.GET /v1/jobs/{job_id}/rounds/{round_id}/reviewReview payload includes top-level
tree_numberand the canonicalclient_tree_details.tree_numberinside the returned form payload.POST /v1/jobs/{job_id}/rounds/{round_id}/reprocessReprocess response includes top-level
tree_number.POST /v1/jobs/{job_id}/finalFinal submission resolves the authoritative tree identity one last time from the submitted form payload, writes it back into the finalized form, and then generates final artifacts.
Implementation status¶
Current status:
schema support added
tree allocation helper added
importer seeds tree identities from legacy final form data where available
runtime job/create/status/review/submit/final paths now return or enforce the authoritative tree number