Repository navigation
Validate the params of an optional Hash scope without the iterator - #3075
Merged
Merged
Conversation
ericproulx
force-pushed
the
perf/direct-optional-hash-scopes
branch
2 times, most recently
from
November 10, 2026 10:52
5ac65e1 to
8aa2778
Compare
A validator reads its scope's params directly, and skips the attributes iterator, when its scope is always validated: the root scope and the required Hash scopes under it. A Hash scope that is optional, or that sits under an optional one, went through the iterator instead, although it has nothing to add there either: #validate only goes on once the scope's params are there and not blank, so the iterator hands that one Hash back, has no empty value to pass over and no dependency to meet. The direct path now covers every scope with no Array scope and no `given` on its chain. It no longer tries a required Hash scope inside an Array scope, whose params resolve to an Array and were resolved a second time by the iterator. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ericproulx
force-pushed
the
perf/direct-optional-hash-scopes
branch
from
November 11, 2026 10:16
8aa2778 to
9ebb2d5
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.
A validator reads its scope's params directly, without the attributes iterator, when its scope is always validated: the root scope and the required Hash scopes under it (#2936). A Hash scope that is optional, or that sits under an optional one, still went through the iterator, although the iterator has nothing to add there either.
#validateonly goes on once the scope's params are there and not blank, so the iterator hands that one Hash back, with no empty value to pass over and no dependency to meet.The direct path now covers every scope with no Array scope and no
givenon its chain:It also stops trying a required Hash scope inside an Array scope. The params of such a scope resolve to an Array, so the direct path never applied to them, and the iterator then resolved them a second time.
A scope under a
givenstays on the iterator, so its dependency is asked as often as it is on master.Numbers
Interleaved A/B from one checkout, median of per-round pairs over 6 rounds. In parentheses, the rounds the branch won.
POST, 9 params in three optional Hashes, one inside anotherPOST, an Array of five Hashes, each requiring a HashPUTby id, 9 params, one an optional HashPOST, 23 params declared with three optional Hashes and an Array, 4 of the 15 top-level ones sentPOST, 10 params with an optional Hash and an Array of three HashesGET, four query params, root scope only (control)Checked against master
About 88,000 requests over random declarations (Hash and Array scopes, nested, required and optional, under
given, with defaults andvalues) and random payloads, a quarter of them valid: the same status and the same error messages. Taking the direct path for every scope makes 267 of one seed's 10,140 requests answer differently, so the comparison does tell a wrong path apart.No contract change, so no UPGRADING entry.
🤖 Generated with Claude Code