Skip to content

Commit 2042151

Browse files
committed
feat(form-documents): improve delivery mode and conditional page guidance
Delivery mode: removed overly conservative "default to static" and replaced with content-complexity-based criteria (narrative fields, sensitive topics, eligibility logic → conversational). Conditional pages: added explicit instructions for deriving page-level conditions from field-level conditions, with a worked example in the schema. Modest improvement (+6.3pp) but the inference remains hard for a prompt-only approach. Results: overall 77.1% (+19.8pp vs baseline). Delivery mode regression eliminated. Conditional use improved from 37.5% to 43.8%.
1 parent c44a9b7 commit 2042151

2 files changed

Lines changed: 70 additions & 60 deletions

File tree

catalog/experiments/layout-quality/sonnet-hybrid-layout-v1.json

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,97 +3,97 @@
33
"implementation": "sonnet-hybrid-layout-v1",
44
"specVersion": "2026-05-06",
55
"status": "current",
6-
"timestamp": "2026-05-06T07:49:47.601Z",
6+
"timestamp": "2026-05-06T08:10:01.163Z",
77
"model": "Claude Sonnet 4 (hybrid + layout)",
88
"summary": {
9-
"pageSizing": 0.8125,
9+
"pageSizing": 0.6875,
1010
"topicCohesion": 0.875,
11-
"logicalProgression": 0.875,
12-
"conditionalUse": 0.375,
13-
"titleClarity": 1,
14-
"deliveryModeChoice": 0.5625,
15-
"overall": 0.75
11+
"logicalProgression": 0.9375,
12+
"conditionalUse": 0.4375,
13+
"titleClarity": 0.9375,
14+
"deliveryModeChoice": 0.75,
15+
"overall": 0.7708333333333333
1616
},
1717
"cases": [
1818
{
1919
"fixture": "pardon-application",
2020
"metrics": {
2121
"pageSizing": 0.5,
2222
"topicCohesion": 0.75,
23-
"logicalProgression": 0.75,
24-
"conditionalUse": 0.25,
23+
"logicalProgression": 1,
24+
"conditionalUse": 0.5,
2525
"titleClarity": 1,
26-
"deliveryModeChoice": 0.5,
27-
"overall": 0.625
26+
"deliveryModeChoice": 0.75,
27+
"overall": 0.75
2828
},
2929
"details": {
3030
"rawScores": {
3131
"pageSizing": {
3232
"score": 3,
33-
"rationale": "Page 1 has 32 fields which is quite large for a single page, while pages like page 4 and page 7 have only 1-5 fields; the distribution is uneven though splitting page 1 further could be warranted."
33+
"rationale": "Page 1 has 32 fields which is quite large and could overwhelm users, while pages like 4, 7, and 9 have only 1-2 fields; splitting the background information into identity, address/contact, and demographics would improve usability."
3434
},
3535
"topicCohesion": {
3636
"score": 4,
37-
"rationale": "Most pages group related topics well, though page 5 combines sobriety/substance use with financial information which are somewhat distinct sensitive topics, and page 2 combines residence history with job history."
37+
"rationale": "Most pages group related topics well (military, case background, certifications), though page 5 combines substance use and financial matters which are somewhat distinct sensitive topics, and page 3 mixes housing and employment."
3838
},
3939
"logicalProgression": {
40-
"score": 4,
41-
"rationale": "The flow from personal info → living/work history → education/military → community → health/finances → criminal history → reasons → references → certification is logical, though placing reasons for pardon after criminal history rather than before is slightly unusual."
40+
"score": 5,
41+
"rationale": "The flow moves naturally from identity to background history, then personal growth, sensitive matters, the actual conviction details, reasons for pardon, and finally legal certifications and references."
4242
},
4343
"conditionalUse": {
44-
"score": 2,
45-
"rationale": "The DataCollectionSpec has clear conditional fields (military service details conditional on serving, substance use details conditional on having struggled, previous application dates conditional on having applied before) but no page-level conditions are used anywhere."
44+
"score": 3,
45+
"rationale": "Military service and previous application details have conditional relevance but the form doesn't use page-level conditions to skip them for non-applicable users, and substance use history could also be conditionally shown."
4646
},
4747
"titleClarity": {
4848
"score": 5,
49-
"rationale": "All page titles are plain-language, conversational, and clearly communicate what the user will be asked (e.g., 'Tell us about yourself', 'Why you're seeking a pardon', 'Sign and submit your application')."
49+
"rationale": "All page titles are plain-language, user-friendly, and clearly communicate what the user will be asked about without jargon or bureaucratic numbering."
5050
},
5151
"deliveryModeChoice": {
52-
"score": 3,
53-
"rationale": "Page 5 (substance use and finances) appropriately uses conversational mode for sensitive topics, and page 3 uses hybrid for conditional military content, but page 6 (criminal history with complex narrative fields about conduct and responsibility) being static is suboptimal, and the reasons-for-pardon page could also benefit from conversational delivery."
52+
"score": 4,
53+
"rationale": "Conversational mode is well-chosen for sensitive topics like substance use, conviction details, and reasons for pardon; however, the certification/signatures page might be better as static since it requires precise legal acknowledgments rather than dialogue."
5454
}
5555
},
5656
"pageCount": 9,
57-
"fieldCount": 128,
57+
"fieldCount": 76,
5858
"groupCount": 13
5959
}
6060
},
6161
{
6262
"fixture": "i-9",
6363
"metrics": {
64-
"pageSizing": 0.75,
64+
"pageSizing": 0.5,
6565
"topicCohesion": 1,
6666
"logicalProgression": 0.75,
6767
"conditionalUse": 0.25,
68-
"titleClarity": 1,
68+
"titleClarity": 0.75,
6969
"deliveryModeChoice": 0.5,
70-
"overall": 0.7083333333333334
70+
"overall": 0.625
7171
},
7272
"details": {
7373
"rawScores": {
7474
"pageSizing": {
75-
"score": 4,
76-
"rationale": "Page 1 has 20 fields and page 2 has 20 fields which is on the larger side but acceptable for a government form; pages 3 and 4 have 9-12 fields which is well-sized."
75+
"score": 3,
76+
"rationale": "Page 1 has 20 fields and page 2 has 20 fields, which are large but manageable given they map to logical form sections; however, page 1 could benefit from being split into personal info and immigration status sub-pages."
7777
},
7878
"topicCohesion": {
7979
"score": 5,
80-
"rationale": "Each page maps directly to one logical group from the I-9 form structure, maintaining perfect topic cohesion within each page."
80+
"rationale": "Each page maps directly to a single logical group from the I-9 form structure, maintaining perfect topic cohesion within each page."
8181
},
8282
"logicalProgression": {
8383
"score": 4,
84-
"rationale": "The flow follows the official I-9 section order logically, though placing the preparer/translator section after employer verification rather than after employee information slightly deviates from the actual form completion sequence."
84+
"rationale": "The flow from employee info to employer verification to preparer to reverification follows the official I-9 section order, though placing preparer certification after employer verification is slightly odd since it relates to Section 1."
8585
},
8686
"conditionalUse": {
8787
"score": 2,
88-
"rationale": "Pages 3 and 4 are clearly conditional (only needed if a preparer assisted or for reverification/rehire) but have no page-level conditions defined; additionally, immigration-related fields in page 1 could benefit from conditional logic based on citizenship status."
88+
"rationale": "The form has clearly conditional sections (preparer/translator only applies if someone assisted, reverification only for rehires, immigration fields conditional on citizenship status) but no page-level conditions are defined."
8989
},
9090
"titleClarity": {
91-
"score": 5,
92-
"rationale": "Titles like 'Tell us about yourself,' 'Employer document review,' and 'Preparer or translator assistance' are plain-language, descriptive, and help users immediately understand each page's purpose."
91+
"score": 4,
92+
"rationale": "Titles like 'Tell us about yourself,' 'Document verification,' and 'Preparer assistance' are plain-language and descriptive, though 'Tell us about yourself' slightly undersells the citizenship attestation component."
9393
},
9494
"deliveryModeChoice": {
9595
"score": 3,
96-
"rationale": "Page 1 appropriately uses hybrid mode given its mix of simple identity fields and complex citizenship/immigration attestation, but pages 3 and 4 could benefit from conversational mode since they involve conditional logic about whether they apply at all."
96+
"rationale": "Using conversational mode for the employee section makes sense given conditional immigration fields, but the employer verification section with complex document lists would benefit more from conversational/hybrid guidance, while the simple preparer fields being static is appropriate."
9797
}
9898
},
9999
"pageCount": 4,
@@ -104,44 +104,44 @@
104104
{
105105
"fixture": "w-9",
106106
"metrics": {
107-
"pageSizing": 1,
107+
"pageSizing": 0.75,
108108
"topicCohesion": 0.75,
109109
"logicalProgression": 1,
110110
"conditionalUse": 0.5,
111111
"titleClarity": 1,
112-
"deliveryModeChoice": 0.5,
112+
"deliveryModeChoice": 0.75,
113113
"overall": 0.7916666666666666
114114
},
115115
"details": {
116116
"rawScores": {
117117
"pageSizing": {
118-
"score": 5,
119-
"rationale": "19 fields across 4 pages yields an average of ~5 fields per page, which is well-balanced for this form's complexity."
118+
"score": 4,
119+
"rationale": "19 fields spread across 4 pages is reasonable; page 1 has 6 fields and page 4 has 6 fields which are appropriately sized, though page 3 with only 2 fields is slightly thin."
120120
},
121121
"topicCohesion": {
122122
"score": 4,
123-
"rationale": "Most pages have clear topical focus, though combining entity-information and exemptions on page 1 mixes two distinct groups—albeit related enough to work together."
123+
"rationale": "Most pages are cohesive, though page 1 mixes entity identification with address information (two distinct groups), and account numbers are oddly placed with address rather than with taxpayer identification."
124124
},
125125
"logicalProgression": {
126126
"score": 5,
127-
"rationale": "The flow from entity identification to address to TIN to certification/signature follows the natural W-9 order and moves from easier to more sensitive information."
127+
"rationale": "The flow from identity → tax classification → TIN certification/signature follows the natural W-9 order and moves from easy to sensitive information logically."
128128
},
129129
"conditionalUse": {
130130
"score": 3,
131-
"rationale": "The LLC tax classification field is conditional on selecting LLC, and the foreign partners indicator applies only to certain entity types, yet no page-level conditions are used to handle these cases."
131+
"rationale": "The LLC tax classification field is conditional on selecting LLC, and the foreign partners indicator is situational, but no page-level conditions are used to handle these cases."
132132
},
133133
"titleClarity": {
134134
"score": 5,
135-
"rationale": "All page titles are plain-language, action-oriented, and clearly communicate what information the user will provide on each page."
135+
"rationale": "Titles like 'Tell us about yourself,' 'Tax classification and exemptions,' 'Taxpayer identification,' and 'Certification and signature' are clear, plain-language, and descriptive."
136136
},
137137
"deliveryModeChoice": {
138-
"score": 3,
139-
"rationale": "Page 1 uses hybrid which is reasonable given the conditional LLC classification, but pages 3 and 4 could benefit from conversational mode since TIN entry requires choosing between SSN/EIN and certification involves understanding legal statements."
138+
"score": 4,
139+
"rationale": "Using conversational mode for the sensitive TIN page and certification is smart, and hybrid for the conditional tax classification section is appropriate, though the static mode for page 1 is also fitting for straightforward fields."
140140
}
141141
},
142142
"pageCount": 4,
143143
"fieldCount": 19,
144-
"groupCount": 5
144+
"groupCount": 6
145145
}
146146
},
147147
{
@@ -152,34 +152,34 @@
152152
"logicalProgression": 1,
153153
"conditionalUse": 0.5,
154154
"titleClarity": 1,
155-
"deliveryModeChoice": 0.75,
156-
"overall": 0.875
155+
"deliveryModeChoice": 1,
156+
"overall": 0.9166666666666666
157157
},
158158
"details": {
159159
"rawScores": {
160160
"pageSizing": {
161161
"score": 5,
162-
"rationale": "Each page has 6-9 fields, which is appropriate for a 43-field form spread across 6 pages—neither too dense nor over-paginated."
162+
"rationale": "Each page has 6-9 fields, which is well-balanced for a 43-field form spread across 6 pages, avoiding both overcrowding and over-pagination."
163163
},
164164
"topicCohesion": {
165165
"score": 5,
166-
"rationale": "Each page maps directly to one cohesive data group (personal info, household, income, assets, expenses, signature), maintaining clear topical focus."
166+
"rationale": "Each page maps directly to one cohesive data group with clearly related fields (personal info, household, income, assets, expenses, signature)."
167167
},
168168
"logicalProgression": {
169169
"score": 5,
170-
"rationale": "The flow moves naturally from identity → household → income → assets → expenses → certification/signature, following standard benefits application logic and building from simple to sensitive."
170+
"rationale": "The flow moves naturally from identity → household → income → assets → expenses → review/signature, following standard benefits application logic and progressing from easy to more complex/sensitive."
171171
},
172172
"conditionalUse": {
173173
"score": 3,
174-
"rationale": "The DataCollectionSpec has optional household members and conditional-like fields (e.g., self-employment, authorized representative) that could benefit from page-level conditions, but none are used."
174+
"rationale": "The household composition and self-employment fields could benefit from page-level conditions (e.g., only showing household members if applicable), but no conditional logic is used despite optional field groups."
175175
},
176176
"titleClarity": {
177177
"score": 5,
178-
"rationale": "All titles use plain, friendly language ('Tell us about yourself', 'Your monthly expenses') that clearly communicates what the user will be asked on each page."
178+
"rationale": "All titles are plain-language, user-friendly, and clearly describe what the user will be asked on each page (e.g., 'Your income sources', 'Your monthly expenses')."
179179
},
180180
"deliveryModeChoice": {
181-
"score": 4,
182-
"rationale": "Income and expenses are appropriately set to hybrid given their conditional complexity, and the signature page uses conversational mode for guidance, though assets could also benefit from hybrid mode given vehicle/property conditionality."
181+
"score": 5,
182+
"rationale": "Static mode is appropriate for straightforward factual fields (personal info, household), hybrid for moderately complex financial sections (income, assets, expenses), and conversational for the review/expedited screening questions that benefit from guided interaction."
183183
}
184184
},
185185
"pageCount": 6,

src/services/form-documents/layout-prompt.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ Apply these civic tech best practices when assigning groups to pages:
4747
2. **Front-load easy questions** — place simple, low-effort fields (name, contact info) on early pages to build momentum before complex sections.
4848
3. **Group for recognition** — related fields together reduce cognitive load. Users should recognize why fields appear on the same page.
4949
4. **Use plain-language titles** — page titles should describe what the user will do, not internal jargon (e.g., "Tell us about yourself" not "Personal Information Section A").
50-
5. **Conditional pages** — if a group has a condition, place it on its own page so it can be skipped entirely without confusing the user.
50+
5. **Conditional pages** — scan the DataCollectionSpec for groups where most or all requirements share the same condition (e.g., multiple fields with "condition": {"field": "hasServedInMilitary", "operator": "equals", "value": "Yes"}). When you find such a group, place it on its own page and add that same condition to the page. The "gate" question (the field referenced in the condition) must appear on a PRIOR page so the system knows whether to show or skip the conditional page. Example: if fields about military details all require hasServedInMilitary == "Yes", put those fields' group on a page with "condition": {"field": "hasServedInMilitary", "operator": "equals", "value": "Yes"}, and ensure the hasServedInMilitary field itself is on an earlier page.
5151
6. **Don't over-paginate** — avoid single-field pages unless justified by sensitivity or conditionality. Two closely related groups can share a page.
5252
5353
## deliveryMode assignment
5454
5555
Assign a deliveryMode to each page based on its content:
5656
57-
- **static** — straightforward fields with clear labels (name, date, address). Most pages should be static.
58-
- **conversational** — sections with many conditional fields, complex eligibility logic, or questions that benefit from guided explanation.
59-
- **hybrid** — moderately complex sections where some fields are straightforward but others may need clarification.
57+
- **static** — straightforward factual fields with clear labels where the user knows the answer immediately (name, date of birth, mailing address).
58+
- **conversational** — sections involving: narrative free-text fields, sensitive topics (criminal history, substance use, legal attestations), complex eligibility logic, or fields where users commonly need guidance to understand what's being asked.
59+
- **hybrid** — pages mixing simple factual fields with one or two that may need clarification (e.g., an address page that also asks about mailing preferences).
6060
61-
Default to "static" unless the page content clearly warrants conversational or hybrid treatment.
61+
Choose based on the content's complexity, not just field count. A page with 3 narrative fields about criminal conduct is more complex than a page with 8 address fields.
6262
6363
## FormSpec JSON schema
6464
@@ -70,11 +70,19 @@ Return ONLY valid JSON (no markdown fences, no explanation) matching this schema
7070
"title": "string — a user-friendly form title",
7171
"pages": [
7272
{
73-
"id": "page-<n>",
73+
"id": "page-1",
7474
"title": "string — plain-language page title",
7575
"description": "string (optional) — brief guidance for the user",
76-
"groups": ["group-id-1", "group-id-2"],
77-
"deliveryMode": "static | conversational | hybrid"
76+
"groups": ["group-id-1"],
77+
"deliveryMode": "static"
78+
},
79+
{
80+
"id": "page-2",
81+
"title": "Your military service",
82+
"description": "Tell us about your time in the armed forces.",
83+
"groups": ["military-service-details"],
84+
"condition": { "field": "hasServedInMilitary", "operator": "equals", "value": "Yes" },
85+
"deliveryMode": "hybrid"
7886
}
7987
],
8088
"createdAt": "${new Date().toISOString()}",
@@ -83,6 +91,8 @@ Return ONLY valid JSON (no markdown fences, no explanation) matching this schema
8391
8492
Each page's "groups" array references group IDs from the DataCollectionSpec. Every group must appear in exactly one page.
8593
94+
The "condition" property is OPTIONAL — use it when a page's content only applies to users who answered a specific way on a previous page. The "field" must reference a fieldName from the DataCollectionSpec. When a condition is present, the page is skipped if the condition is not met.
95+
8696
## DataCollectionSpec
8797
8898
${JSON.stringify(spec, null, 2)}

0 commit comments

Comments
 (0)