Rework form generation around incidents and templates instead of extractions
Background
Form generation still pointed at extract_id and a closed form_type enum, both left over from before templates were user-registered and before extraction fed into a stored incident. It also had two separate endpoints for generating one form versus all forms, which no longer makes sense once generation is just a lookup against the incident's contract document.
What needs to change
- Merge
generate/all and generate/{form_type} into one POST /forms/generate that takes an incident_id and a list of template_ids. Omitting template_ids generates everything the readiness matrix reports as ready.
- Point generation at
incident_id instead of extract_id, since the contract document now lives on the incident row, not the extraction.
- Since generation is pure lookup and draw (schema fields read the contract path, static fields stamp saved text, manual and open fields read
custom_fields), no LLM runs here at all, so a whole batch should complete in seconds even for many templates.
- Templates that are not ready get skipped with a reason instead of failing the whole batch, unless
force_partial is set.
- Unify the response shapes so a single form and a batch form both return the same
FormRecord, with template_id, form_type, and batch_id all present.
- Add
GET /forms/batch/{batch_id}/download so a batch of generated forms can be pulled as one archive instead of fetching each form's PDF individually.
Rework form generation around incidents and templates instead of extractions
Background
Form generation still pointed at
extract_idand a closedform_typeenum, both left over from before templates were user-registered and before extraction fed into a stored incident. It also had two separate endpoints for generating one form versus all forms, which no longer makes sense once generation is just a lookup against the incident's contract document.What needs to change
generate/allandgenerate/{form_type}into onePOST /forms/generatethat takes anincident_idand a list oftemplate_ids. Omittingtemplate_idsgenerates everything the readiness matrix reports as ready.incident_idinstead ofextract_id, since the contract document now lives on the incident row, not the extraction.custom_fields), no LLM runs here at all, so a whole batch should complete in seconds even for many templates.force_partialis set.FormRecord, withtemplate_id,form_type, andbatch_idall present.GET /forms/batch/{batch_id}/downloadso a batch of generated forms can be pulled as one archive instead of fetching each form's PDF individually.