0048: Checked teaching programs
- Status: Accepted
- Date: 2026-10-30
- Plan: M7.3
Context
Teaching diagnostics need actual corrected programs and a small JSON surface. Existing JSON goldens and compiler phase messages must remain byte-identical.
Decision
Embed two TSV teaching tables alongside the diagnostics registry. Each active code has a wrong program and a complete corrected program. Tests check exact single-code failure and successful correction through the shared front end. The instance-limit example references the existing generated stress fixture; human explain expands it, so the displayed program is the tested one.
Human explain retains meaning and repair advice
and adds both programs. JSON explain contains code and complete
corrected source only. Ordinary diagnostics retain their existing
shape; their code is the lookup key for teaching content. Enforce
540-byte JSON lines (ceil(bytes / 3.6) <= 150) across all
diagnostic fixtures and explanation codes. No backend or execution
semantics change.
Alternatives considered
- Inline full programs in ordinary JSON: breaks goldens and exceeds the budget.
- Treat existing prose fragments as corrections: many lack declarations and cannot be compiler-checked in isolation.
- Include both complete programs in JSON explain: larger interface examples exceed 150 tokens; human explain provides the full context on demand.
Consequences
New diagnostic codes require a verified teaching pair. Resource-limit examples can reuse stress fixtures. TSV newline encoding is deliberately minimal; future examples needing literal backslash-n in source need an explicit encoding change.