Schema · validation · rejection · provenance
Charles Trinh — Structured Output Pipelines

Turning model output into data a system can trust: schemas, validation, rejection paths and the reason free text does not survive a clinical workflow.
What this is
Free text is a decision to push the reading cost downstream. In a clinical workflow that cost lands on a clinician, and it is paid on every record, forever.
A schema turns the same task into something a system can validate, store and test. It also makes failure visible at the boundary instead of three steps later in a report.
This page covers the pipeline that gets there: schema first, validation in layers, rejection rather than repair, and a record of where each field came from.
Why schema first
A schema is a contract; it makes the output testable and the failure visible rather than plausible.
Write the schema from what the downstream system needs, not from what the model produces easily. The second direction quietly exports the model's limitations into your data.
Validation layers
Validate shape, then types, then domain rules; each layer catches a different class of error.
A shape check catches a missing field, a type check catches a number as string, and a domain rule catches a plausible but impossible value. All three are cheap; skipping one moves the error downstream.
Rejection, not repair
Reject invalid output and re-run, rather than repairing it; repair hides the defect that produced it.
Repair code accumulates and eventually becomes the thing that is wrong. A rejection with a reason is a telemetry signal; a repair is a silent guess.
Determinism where possible
Temperature zero where the task is extraction; creativity is a liability in a data path.
Extraction should be repeatable: same input, same output, every time. Save the variability for the drafting steps where a person still reads the result.
Golden sets
Keep a labelled sample and run it after every change; otherwise every improvement is an opinion.
A hundred real examples with correct outputs is enough to catch regressions and small enough to maintain. Grow it from production failures, not from synthetic edge cases.
Provenance
Record which model, which prompt version and which source produced each field.
Provenance is what lets you answer a content question without reprocessing the corpus. It also shows which prompt versions are responsible for which classes of error.
Human review where it counts
Review the exceptions, not everything; a review queue that never clears is a queue nobody uses.
Route by confidence and by consequence: high-confidence, low-consequence fields pass; anything else goes to a person with the source beside it.
Cost of being wrong
Ask what happens downstream when a field is wrong; that answer sets the validation bar.
A wrong billing code is rework; a wrong allergy is an incident. The bar should differ accordingly, and the pipeline should say which fields carry which bar.
How I do it
I write the schema from the downstream system's requirements first, then build the extraction against it. That order keeps the model's habits out of the data model, which is the difference between a pipeline and a transcript.
Validation goes in layers, with a named rejection reason per failure class, and a golden set of real examples runs on every change. Repair logic is deliberately absent: a rejection is a signal, and a repair is a guess that hides one.
Provenance and routing come last but not optionally: per-field model and prompt version, and a review queue that sends exceptions to a person with the source beside them. Without those, the pipeline cannot answer a question about its own output.
Artifacts you keep
- A schema per task derived from downstream requirements
- Layered validation with a rejection reason per failure class
- A golden set of labelled examples run on every change
- Per-field provenance: model, prompt version and source
- A confidence-routed review queue with the source shown
Schema first, prompt second
The output schema is the contract, and it should be written before the prompt. A pipeline designed from the schema validates what it receives and fails loudly, rather than parsing whatever the model produced and hoping.
Pin the schema, version it, and treat a schema change as a release. Consumers of structured output are as sensitive to a field rename as any API client.
Validation and repair
Validate on receipt, and on failure re-ask with the validation error rather than silently discarding. A repair loop that is bounded and logged is a control; an unbounded one is a cost incident.
Log the validation failures by field. The pattern shows which instruction is ambiguous, which is usually a schema problem rather than a model problem.
Provenance for each field
For regulated data, record which source each field was derived from and with what model version. That provenance is what lets a reviewer ask why a value is what it is and receive an answer.
Without it, structured output is an assertion, and assertions are what an audit exists to test.
Failure handling downstream
A pipeline that produces records must decide what happens when a field is missing or invalid: reject, quarantine or accept with a flag. Each is defensible and the choice must be written down, because the default is that the record is written with nulls and nobody notices.
Quarantine with an owner is usually the right answer, and it is the one that requires the most discipline to sustain.
C
ost of a repair loop
A
repair loop doubles the cost of a failed call and a bounded loop is a small premium. An unbounded one is a runaway, and the difference is a retry ceiling and a metric.
A
lert on repair rate per schema, because it is the earliest signal that an instruction has become ambiguous.
Keep a fixture set of inputs with expected outputs, and re-run it on every schema or model change. The fixtures are what turn a pipeline from something that works today into something that still works after the next upgrade, and they cost an afternoon to create the first time.
Where an input cannot be represented in the schema, say so and route it rather than forcing it into an approximate field. An approximate field is a data quality defect with a long life.
The schema review
A schema is a contract with downstream consumers, so changes need review by someone who represents them. The most common defect is a silently widened field that accepts values the consumer cannot handle.
Version the schema and keep the previous version valid for a stated period, exactly as an API would.
Test the pipeline with deliberately malformed inputs, because the production failures arrive as truncation, refusal and partial JSON rather than as clean schema violations. A fixture for each of those three is worth more than a hundred valid examples.
Keep the raw model response for a short window alongside the validated output. When a field is wrong, the raw response answers whether the model was wrong or the validator was, and that distinction changes the fix.
Keep a sample of validated outputs reviewed by a human each month, because the validator proves the shape and not the meaning, and meaning is what a downstream consumer relies on.
Proof
- ONC (g)(10) self-test PASS, 317 of 317 subtests, April 2026 — public suite URL
- 67 public hostnames, 51 serving, one AWS account
- 104 clearinghouse enrolments across 53 jurisdictions
- USCDI v7 proposal — Patient Digital Identity Credential — listed at isp.healthit.gov
- SAM.gov UEI MVKQW9DKKGB8 · CAGE 20KM5 · NPI 1194645564
- AWS Business Associate Addendum active since 18 August 2026
Where this work is delivered
Engagements run from Las Vegas and reach across the valley: clients in Las Vegas, NV; Las Vegas, Nevada; Henderson; Clark County, Nevada; and North Las Vegas, Nevada, plus remote delivery nationwide.
How an engagement runs
1. Trace one real case
Follow a single patient or claim end to end with a timestamp at every hop, before any document is written.
2. Written findings
A findings list naming the defect, the system, the owner and the date.
3. Monthly review
Review the list monthly and check whether the dates held.
Frequently asked
What is this service?
This page describes charles trinh — structured output pipelines — the scope, the failure modes it prevents and how the work is measured. It sits in the AI and Automation category at trinh.io.
Where is the work delivered?
Engagements run from Las Vegas, Nevada across the valley — Las Vegas, Henderson, North Las Vegas, Spring Valley, Paradise, Winchester, Sunrise Manor, Enterprise, Summerlin, Clark County — and remotely anywhere in the United States. On-site work in the Las Vegas valley, remote delivery elsewhere.
What does it cost?
Standard rate $195 per hour, committed $165 per hour at twenty hours or more per week for three months or more; $1,600 standard day, $1,350 committed day. Scoped in writing before work starts, fixed fee where the deliverable is defined.
Who is Charles Trinh?
A technology architect in Las Vegas, Nevada, working in healthcare identity, consent and interoperability. Not a physician, not a medical practice, and not affiliated with any other Charles Trinh.
How does an engagement start?
With one trace of a real case and a written findings list naming the defect, the system, the owner and the date. The first call is twenty minutes and free: 702-559-3489.
Engagement
Scoped in writing before work starts; fixed fee where the deliverable is defined. First call is 20 minutes and free. 702-559-3489 · charles@trinh.io
Talk to Charles
- Phone: 702-559-3489
- Email: charles@trinh.io
- Based in Las Vegas, Nevada · working remotely across the United States