Expand description
Parse the model’s raw reply into a structured Emission.
Three shapes (matching the failure-mode taxonomy in
~/workspaces/knowledge/board/drake/2026-05-29_newt-coder-failure-mode-taxonomy.md):
Emission::WholeFiles— one or moreFILE: <path>\n…\nEND-FILEblocks. The S5 directive’s preferred shape.Emission::UnifiedDiff— a unified diff (fenced or not). Legacy path; useful when a model ignores the directive but still lands a valid hunk.Emission::Prose— nothing structured was found. The model emitted text only. Failure mode T0a in the taxonomy.
The parser is permissive. Real Ollama replies often arrive
wrapped in stray ``` fences or with a leading “Here’s the
updated file:” preamble — strip_outer_fences peels a single
enclosing fence and try_parse_whole_files is tolerant of
interleaved blank lines. We’d rather extract a valid emission
from a slightly-malformed reply than crash on it.
Enums§
Functions§
- normalize_
emission - Parse
rawinto anEmission. Permissive: peels a single enclosing```fence before deciding, then tries each shape in preference order (whole-files > unified-diff > prose).