fix(engine): match negative-range int params so they round-trip - #3
Conversation
_buildTemplateMatcher built the regex for non-enum int params unconditionally as
(\d+), which cannot match a leading '-'. The first commands in the library to use a
negative int range — uppity.rotary.spin (:PR{speed}, min -100) and uppity.rotary.rel
(:PD{degrees}, min -180) — therefore failed to re-parse their own documented negative
examples (:PR-80, :PD-90): match() returned null and parseWCBValue fell back to a raw
step instead of a structured, editable one. encode() was unaffected (string interp).
Fix: use (-?\d+) for int-param groups. Adds a regression test asserting match(':PR-80')
=> uppity.rotary.spin/speed='-80' and match(':PD-90') => uppity.rotary.rel/degrees='-90'.
Bumps engine version 2.1.0 -> 2.1.1 (catalog libraryVersion unchanged; no board data).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review — PR #3 (fix(engine): match negative-range int params so they round-trip)Scope: engine-only change. No 1. Checks — all green
2. The fix itself
Nice catch on why this was invisible before: 3. One design concern worth a follow-up (non-blocking)The new Suggestion: gate the 4. Versioning
Overall: solid, well-tested bug fix. Recommend considering the range-gated regex (#3 above) before or shortly after merge, but nothing here blocks it. |
Found by the automated review of PR #1 (the R2 Uppity Spinner ALT board).
Bug:
_buildTemplateMatcherbuilt the regex for non-enum int params unconditionally as(\d+), which can't match a leading-. The first library commands with a negative int range —uppity.rotary.spin(:PR{speed}, min -100) anduppity.rotary.rel(:PD{degrees}, min -180) — failed to re-parse their own documented negative examples (:PR-80,:PD-90):match()returned null andparseWCBValuefell back to a raw step instead of a structured, editable one.encode()was unaffected.Fix:
(-?\d+)for int-param groups. Adds a regression test (match(':PR-80')→uppity.rotary.spin/speed-80;:PD-90→uppity.rotary.rel/degrees-90). Engine version 2.1.0 → 2.1.1; cataloglibraryVersionunchanged.Full suite: 137 passing; validator green.