Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 944e0b6afd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if isinstance(element, Sequence): | ||
| return all(element_matches_empty(child, memo) | ||
| for child in element.children) |
There was a problem hiding this comment.
Handle unbounded Repetition in element_matches_empty
element_matches_empty() currently falls through to the generic Sequence branch for Repetition, which makes Repetition(..., min=0, unbounded=True) look non-empty whenever its child is non-empty. That lets nested grammars like Repetition(Repetition(Literal("a"), min=0, unbounded=True), min=0, unbounded=True) bypass the constructor guard, even though the inner repetition can match zero words; at runtime this can create non-terminating decode loops because the outer unbounded repetition can keep accepting zero-length child matches.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| if isinstance(element, Sequence): | ||
| return all(element_matches_empty(child, memo) | ||
| for child in element.children) | ||
| return False |
There was a problem hiding this comment.
Empty-check misses zero-min Repetition
High Severity
element_matches_empty treats Repetition as a plain Sequence, so unbounded repetitions with min=0 are considered non-empty. This bypasses the constructor guard and allows unbounded repetition children that can accept empty, causing non-consuming repetition loops.


Summary
Testing
Note
Medium Risk
Touches core parsing and repetition decoding plus multiple engine compilers, so regressions could affect recognition matching/greediness or engine-specific grammar generation; changes are well-covered by new targeted tests.
Overview
Adds inline repetition syntax to compound specs via brace ranges (e.g.
"<item>{1,}","{0,}","{2,4}"), with parser updates to distinguish repetition quantifiers from existing{weight=...}-style specifiers and to avoid mutating shared extras when applying specials.Extends
Repetitionwith anunboundedmode (validated against empty-matchable children), updates its runtimedecode()/get_repetitions()behavior, and propagates repeated extras as lists throughCompoundvalue functions and throughCompoundRule/MappingRulevia new sharedextract_compound_extras()logic (including default/omission handling and per-branch shape inference).Updates Kaldi/Natlink/SAPI5/Sphinx compilers to emit correct grammar structures for unbounded repetition (preserving
minand optional skip behavior) and adds substantial unit/doctest coverage for the new parsing, repetition, and compiler semantics.Written by Cursor Bugbot for commit 944e0b6. This will update automatically on new commits. Configure here.