fix: read the YAML layouts a model actually writes, and name the line and construct on a parse error - #293
Merged
Merged
Conversation
… and construct on a parse error Four layouts that are valid YAML — checked against a spec-compliant parser — were rejected or mangled by core/yaml.ts, each with "Invalid YAML indentation near: …" or worse: - A block sequence at the same column as its key (`items:` / `- a`) read as `items: null`, and at the top level every line after it was dropped without a word. Nested, the same layout threw. - A plain scalar wrapped onto more-indented lines (self-audit probe D), which is what a model writing a long closeout_summary produces, threw. So did a scalar starting on the line after its key, a wrapped sequence item, and a wrapped value on an item's first key. They fold now, blank lines to newlines, like a `>` block. - A sequence of sequences threw. - A tab in the indentation was counted as two columns and sliced as one character, so `\tkey: v` parsed as the key "". Every parse error now reads `YAML line N: <what was expected> — "<the line>"`. The audit's probes C and C2 (a sibling key deeper than the first key) are not valid YAML and still fail, but the message says so instead of blaming whitespace. Content left after the top-level block ends is an error rather than silently unread. The Duplicate YAML key wording is kept inside the new format. docs/library-format.md's dialect section was still saying folded scalars are not read; it now lists what is. Closes #246. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 12, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #246 (D-M10; mech 1.7, probes C/C2/D).
What the audit's probes actually show
Probes C and C2 (a sibling key indented deeper than the item's first key) are not valid YAML — PyYAML rejects both with "mapping values are not allowed here" — so the issue's "(valid YAML)" premise is wrong for those two. The layout the earlier
itemIndentfix handles (- id: xwith siblings aligned underid) already parsed. I probed a wider set of layouts against PyYAML and found four that are valid and were rejected or mangled:items:/- a)items: null, and at the top level every later line silently dropped; nested, the indentation errorcloseout_summary)>(blank line → newline)- - a)\tb: 1→ key""(garbage)Every expectation in the tests was checked against PyYAML before being pinned. Continuation stops at a mapping entry (
key:— colon-space, so a wrappedhttps://…is not a key), a sequence item, or a comment; quoted scalars never continue.Error messages
All parse errors are now
YAML line N: <what was expected> — "<the line>":Duplicate YAML key: dupwording is kept inside the new format —framework-handoff.test.mjspins it), non-entry linesThe emitter is untouched; #225 (scalar-looking strings emitted bare) is a separate open high.
Docs
docs/library-format.md§YAML dialect still said>folded scalars are not read (stale since 0.19.3; L4). It now lists what is read and that errors name the line.Tests
11 new (suite 732/732): 10 in
tests/yaml.test.mjscovering each layout and each message, plustests/handoff-layouts.test.mjscompleting a real handoff written with a wrappedcloseout_summary, a next-linedescription, and same-column lists throughcodecarto_complete. All 11 fail on the pre-fix parser.🤖 Generated with Claude Code