SIGN IN SIGN UP

fix: one canonical key grammar closes the spelling class for good

Closes #42. Four generations of findings across PR #22 and PR #41 —
duplicate keys, quoted and spaced spellings, the same one level up,
then escaped keys — shared one root cause: the scanner enumerated bad
key spellings while its threat model was "whatever a real YAML parser
would resolve", and that enumeration cannot terminate. An escaped
"version" matches no enumerated spelling yet resolves to version
in Psych and PyYAML alike.

The inversion: at the two scanned levels, every non-blank, non-comment
line must carry a plain-scalar key, a bare [A-Za-z0-9._-]+ followed
immediately by ':' and whitespace or end of line (PLAIN_KEY_RE). One
rule, one message, replacing ALT_VERSION_KEY_RE and
ALT_METADATA_KEY_RE and deliberately reversing the earlier allowance
of quoted "other" keys: a quoted other key is textually
indistinguishable from a disguised version or metadata, so no safe
allowance smaller than the full ban exists — the two tests protecting
that allowance flip accordingly. Escapes live only inside quoted keys,
so the class closes without decoding anything; within the accepted
grammar the line scanner and any YAML parser read identical keys,
which is the property every prior finding exploited the absence of.

Also added on the same last-wins reasoning: duplicate exact-spelling
metadata blocks are now invalid even when only one declares a version,
since a parser keeps the last block entirely while the scanner would
read the stale first.

Suite grows to 41: escaped keys at both levels, anchored keys, quoted
other keys at both levels, duplicate metadata blocks with and without
two versions. Mutation-checked against the canonical SKILL.md for
every prior class (flow, whitespace, comments, unquoted scalars,
delimiters) plus the new ones; all fail loud, restored tree green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SwGKATJ6u4rgWyLsbg4Grj
N
Nanako Tsai committed
833ce90b9abb1fd0105d83bfa1e8b99e700d1962
Parent: a4293c7