fix(native): strip pre-release suffix in semverCompare#898
Conversation
`semverCompare('3.9.3-dev.6', '3.9.1')` returned -1 (less than) because
`Number('3-dev')` is NaN, which the `|| 0` fallback turned into 0,
making the comparison `0 < 1`. This caused `shouldSkipNativeOrchestrator`
to flag all pre-release builds as "buggy", disabling the native
orchestrator fast path introduced in #897.
Strip `-<prerelease>` before splitting on `.` so the numeric comparison
sees `3.9.3` vs `3.9.1` correctly.
|
Claude finished @carlos-alm's task —— View job PR Review Complete ✅Todo List
Phase 1: Root Cause Analysis ✅Problem Being Solved: Pre-release versions like Why This Approach: The fix strips pre-release suffixes with Impact Verification: Found that Phase 2: Configuration Change Detection ✅✅ No high-risk configuration changes detected
Phase 3: Test Integrity ✅✅ Strong test coverage and quality
Phase 4: Code Quality Review ✅✅ Implementation is sound and minimal
Phase 5: Backlog Compliance Assessment ✅Backlog Compliance
Critical ConcernsNone. This is a well-executed bug fix with proper testing and clear impact. Final Recommendation
|
Greptile SummaryFixes a bug in Confidence Score: 5/5Safe to merge — minimal, targeted fix with no regressions and adequate test coverage. The change is two lines in one function, the root cause is clearly explained, the fix is correct, and the new tests directly exercise the previously broken cases. No pre-existing behavior is altered for callers that don't pass pre-release strings, and checkForUpdates already short-circuits before reaching semverCompare for pre-release inputs. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/infrastructure/update-check.ts | Two-line fix strips pre-release suffix before splitting on ., eliminating the NaN-collapse bug; jsdoc updated to match. |
| tests/unit/update-check.test.ts | Adds a new it block with four assertions covering both one-sided and two-sided pre-release comparisons; existing suite unchanged. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["semverCompare(a, b)"] --> B["Strip pre-release suffix\na.replace(/-.*$/, '')"]
B --> C["Split on '.' and map to Number\n['3','9','3'] → [3, 9, 3]"]
C --> D{"Compare each segment\n(major → minor → patch)"}
D -- "na < nb" --> E["return -1"]
D -- "na > nb" --> F["return 1"]
D -- "all equal" --> G["return 0"]
H["Old behavior: '3.9.3-dev.6'"] --> I["split('.') → ['3', '9', '3-dev', '6']"]
I --> J["Number('3-dev') → NaN\nNaN || 0 → 0"]
J --> K["0 < 1 → returns -1 ❌"]
L["New behavior: '3.9.3-dev.6'"] --> M["replace(/-.*$/, '') → '3.9.3'"]
M --> N["split('.') → ['3','9','3']"]
N --> O["[3, 9, 3] — all valid numbers"]
O --> P["3 > 1 → returns 1 ✅"]
Reviews (1): Last reviewed commit: "fix(native): strip pre-release suffix in..." | Re-trigger Greptile
Codegraph Impact Analysis1 functions changed → 5 callers affected across 3 files
|
Summary
semverCompare('3.9.3-dev.6', '3.9.1')incorrectly returned-1becauseNumber('3-dev')isNaN, andNaN || 0collapsed to0, making the patch comparison0 < 1shouldSkipNativeOrchestratorto flag all pre-release builds as "buggy addon", disabling the native orchestrator fast path from perf(native): use single rusqlite connection for entire build pipeline #897-<prerelease>suffix before splitting on.so3.9.3-dev.6correctly compares as3.9.3Impact
Every dev build (e.g.
3.9.3-dev.6) was silently falling back to the JS pipeline instead of using the Rust orchestrator. Benchmarking confirmed the native orchestrator was skipped:Test plan
semverComparetests pass (equal, less-than, greater-than across major/minor/patch)3.9.3-dev.6 > 3.9.1,3.9.3-dev.6 == 3.9.3,2.0.0-beta.1 > 1.9.9-alpha.3)update-check.test.tspass