한 schema, 여러 consumer
Output schema가 consume되는 곳: 프롬프트 (JSON Schema export), validator (Pydantic / Zod), downstream code (TypeScript / Python type), test suite (sample fixture), docs (API 묘사). 한 source of truth, 여러 derived artifact.
어떻게 wire
- Pydantic (Python)이나 Zod (TypeScript)에서 author.
model_json_schema()나zodToJsonSchema로 JSON Schema 생성.- JSON Schema를 structured-output spec로 프롬프트에 inject.
- 같은 Pydantic / Zod 모델로 response validate.
- 같은 type으로 consumer type.
win
Schema 바꾸면 모든 dependent layer가 compile time에 break. 뭐 바꿔야 할지 보임. Single source of truth 없으면 schema 변경이 silently desync — 프롬프트가 옛 shape 요청, 코드가 새 shape 기대, runtime crash.