Module 03 Activity
Scenario
The next step after your model call is code, not a person. Everything here is about making the boundary safe.
What you build
A parser with format instructions, a validating schema, a feedback-driven retry with a give-up path, and a schema-change plan.
Steps
- Replace prose output with a parser, binding the format instructions with
.partial()so they cannot be forgotten. - Run four candidate outputs through the parser, including JSON wrapped in prose and truncated JSON. Note which succeed.
- Add a validating schema constraining types, allowed values and at least one format pattern.
- Build a retry that feeds the specific error back, caps attempts, and has an explicit give-up path.
- Count parse failures separately from validation failures and alert on each rate.
- Write the schema-change plan: which changes are backward compatible and what your rolling-deploy order is.
Evidence to hand in
- The parser with bound format instructions.
- Four candidates with their outcomes, including the two surprises.
- The schema with types, allowed values and a pattern.
- The retry with its feedback, cap and give-up path.
- The schema-change plan with deploy ordering.
Review checklist
- Format instructions are bound once, not passed per call.
- The schema rejects a plausible label outside the allowed set.
- The retry feeds back the specific error, not 'try again'.
- There is an explicit give-up path.
- The deploy plan says readers before writers for a widened enum.
