Add the structural resolver: case selection plus positional routing - #578
Merged
Conversation
Smaug123
force-pushed
the
argparser-candidate-scan
branch
from
July 25, 2026 10:26
704d73d to
bd4c15b
Compare
Smaug123
force-pushed
the
argparser-resolver
branch
from
July 25, 2026 10:26
e6f154f to
9bdb4ab
Compare
Smaug123
force-pushed
the
argparser-candidate-scan
branch
from
July 25, 2026 10:33
bd4c15b to
723c144
Compare
Smaug123
force-pushed
the
argparser-resolver
branch
from
July 25, 2026 10:33
9bdb4ab to
7695eba
Compare
`resolve` chooses a case for every Sum and routes the positional stream, before any conversion: it intersects the events' candidate sets and runs the compositional selector once per candidate sink, the sink treated as one additional observed leaf. A unique fully-accepting hypothesis wins; several (including a single sink whose interpretation is ambiguous through untouched empty-satisfiable cases) report ambiguity; a hypothesis unique up to missing required arguments is still selected so the missing arguments surface through the ordinary channel; and when no sink fits, the named-only diagnosis is preferred, with the routing contradiction reported when the events share no candidate at all. Two new selection errors carry the routing failures (UnroutablePositional, AmbiguousPositionalRouting). Not yet wired into runParse — that is the next stage — so generated parsers are unchanged. The oracle: a property pinning `resolve` equivalent to the exhaustive reference semantics over generated trees and inputs (it caught one real bug during development: a sink whose interpretations were ambiguous was silently discarded, letting another sink win uniquely). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Smaug123
force-pushed
the
argparser-resolver
branch
from
July 25, 2026 10:52
7695eba to
36f624b
Compare
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.
Stage 5a of the positional-args-with-unions stack (5/8). Stacked on #577.
Adds the pure structural resolver:
resolve (schema) (observed) (positionalEvents) : Selection, which performs case selection and positional routing together, before any value conversion. Conversion failures can therefore never influence which case wins or where a token goes.Algorithm: intersect the events' candidate sets; for each candidate sink, form the hypothesis "this sink is active" by re-running selection with the sink as an extra observed leaf (
selectWith); classify hypotheses as clean, fully valid, or internally ambiguous (the sink is routable but multiple interpretations through it accept); aggregate. NewSelectionErrors:UnroutablePositional(no sink can take a token — including when the candidate intersection is empty, which is now always reported alongside the named-only diagnosis) andAmbiguousPositionalRouting.The centrepiece test is an equivalence property against the Stage 2 exhaustive reference semantics (3000 generated cases per run, with distribution counters to confirm the generator exercises ambiguous/unroutable regions). This property caught a real bug during development: hypotheses whose only errors were empty-case ambiguities were being discarded as incoherent, letting a different sink win "uniquely" where the definitional semantics says the parse is ambiguous. The
innerAmbiguousclassification is the fix; 120k cases pass after it.🤖 Generated with Claude Code