Repository navigation
fix(parser): green compound-cost conversion retries unparsable numbers like red - #1714
Merged
Merged
Conversation
…s like red fuzz_green_eq_red found (#1713) an input where the green-wired parse and parse_red_only disagree on a compound cost: red produced Compound { per_unit: 2, .. } while green produced per_unit: 0. Root cause: #1704 gave red TWO number semantics — cost_compound_numbers retries past unparsable NUMBER tokens on each side of the hash (is_none() guards re-arm when the parse fails), while the plain path latches the first NUMBER token via cs.number() — but green kept a single latched tracker, satisfying only the plain path. On garbage like `{<unparsable> 2 # ...}` red retried to 2; green latched None -> 0. Green now carries both: a retried pre-hash tracker for the compound path plus the existing latched first-token tracker for the plain path (and the post-hash side switches from latch to retry, matching red). - Regression test pins the 418-byte fuzzer input (fuzz_regressions/diverge_compound_cost_unparsable_number.bin). - CACHE_VERSION 13 -> 14 (+ changelog): parse output changes for inputs with garbage around compound costs; stale caches would resurrect the divergence. Tripwire fixture versions advance (layouts unchanged). - Fuzz-validated: 5.34M executions / 9 min on the fixed converter, zero artifacts. Closes #1713 Co-Authored-By: Claude Opus 4.8 <[email protected]>
The v0.20.1 release bump did not regenerate these, so every cargo invocation re-pins rustledger-plugin-types 0.20.0 -> 0.20.1 and dirties the tree — which breaks prek pre-push stash handling. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a green/red converter parity bug in rustledger-parser for compound cost specs when NUMBER tokens are present but unparsable, ensuring green’s recovery behavior matches red’s and preventing directive divergences found by fuzzing (#1713).
Changes:
- Updated green CST cost-spec conversion to carry both “latched first NUMBER token” semantics (plain path) and “retry until parse succeeds” semantics (compound
{a # b}path), matching red. - Added a pinned regression test fixture asserting
parse(green-wired) exactly matchesparse_red_onlyfor the reported divergence input. - Bumped loader cache version (13→14) and advanced cache tripwire fixture versions to prevent stale caches from resurrecting the old behavior; refreshed sample stub lockfiles.
Reviewed changes
Copilot reviewed 3 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/rustledger-plugin/tests/fixtures/sample_stub/Cargo.lock | Fixture lockfile bump for rustledger-plugin-types 0.20.1. |
| crates/rustledger-parser/tests/fuzz_regressions.rs | Adds a regression test asserting green/red directive equality for the #1713 input. |
| crates/rustledger-parser/src/cst/green.rs | Fixes green compound-cost number tracking to match red retry/latch semantics. |
| crates/rustledger-loader/src/cache.rs | Bumps CACHE_VERSION to 14 and updates related fixture-version tripwires and changelog notes. |
| crates/rustledger-importer/tests/fixtures/sample_stub/Cargo.lock | Fixture lockfile bump for rustledger-plugin-types 0.20.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs main branch (2026-07-03)
What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
The function was replaced by cost_compound_numbers in #1704; the module doc and a parity-corpus comment still narrated the old latch semantics. The corpus entry still passes because BOTH parsers now retry past the unparsable post-hash number and agree on Compound{7, 0} — the comment now says so. (Copilot review catch on #1714.) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Member
Author
Merged
robcohen
added a commit
that referenced
this pull request
Jul 4, 2026
* chore: release v0.20.2 - fix(query): typed scalar functions propagate NULL, beanquery parity (#1711) - fix(parser): green compound-cost conversion retries unparsable numbers (#1714) Fixture sample_stub lockfiles regenerated with the version bump this time (v0.20.1 missed them, which broke prek pre-push stash handling). Co-Authored-By: Claude Opus 4.8 <[email protected]> * chore: drop generated changelog block (curated doc, per v0.20.1 precedent) Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
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 #1713 (the
fuzz_green_eq_reddivergence found on #1711's fuzz run).Root cause — an asymmetry introduced in #1704: red got two number semantics (
cost_compound_numbersretries past unparsable NUMBER tokens on each side of the#; the plain path latches the first token viacs.number()), but green kept a single latched tracker satisfying only the plain path. On garbage like{<unparsable> 2 # ...}, red retried toper_unit: 2while green latchedNone → 0.Fix: green carries both — a retried pre-hash tracker for the compound path alongside the latched first-token tracker for the plain path; the post-hash side switches from latch to retry, matching red.
Verification
CACHE_VERSION13→14 + changelog (parse output changes for garbage-adjacent compound costs; stale caches would resurrect the divergence). Tripwire fixture versions advance; rkyv layouts unchanged.-D warnings, fmt, doc, parser + loader suites all clean.Drive-bys: pre-existing typos in cache.rs comments (hook-enforced); sample_stub fixture lockfiles regenerated for 0.20.1 (missed by the release bump; their staleness broke prek pre-push stash handling).
🤖 Generated with Claude Code