#23730: fix(update): correctly compare versions with -N build suffix
size: S
Cluster:
Update Handling Fixes
## Summary
Fixes #23647
`openclaw update status` was incorrectly flagging versions like `2026.2.21-2` as older than `2026.2.21`, causing false "update available" warnings and potential downgrades.
## Root Cause
The `compareSemverStrings()` function used `parseSemver()` which only extracted `major.minor.patch` and ignored the `-N` build suffix entirely. This meant `2026.2.21` and `2026.2.21-2` were treated as identical versions.
## Solution
1. **Added `parseVersionWithBuild()`**: Extracts both the semver components AND the build suffix number from version strings
2. **Updated `compareSemverStrings()`**: Now compares build suffixes numerically after the semver comparison
3. **Build suffix semantics**: Higher build number = newer version (e.g., `2026.2.21-2` > `2026.2.21-0`)
## Changes
- `src/infra/update-check.ts`: Added build-aware version parsing and comparison
- `src/infra/update-check.test.ts`: Added 7 new test cases covering build suffix scenarios
## Test Coverage
```typescript
// Build suffix comparison (the fix)
expect(compareSemverStrings("2026.2.21-2", "2026.2.21")).toBe(1); // -2 is newer
expect(compareSemverStrings("2026.2.21", "2026.2.21-2")).toBe(-1); // base is older
// Numeric build comparison (not string)
expect(compareSemverStrings("1.0.0-10", "1.0.0-2")).toBe(1); // 10 > 2
```
All 7 new tests pass.
## Verification
```bash
# Before fix:
$ openclaw update status
# Reports: 2026.2.21-2 is behind 2026.2.21 ❌
# After fix:
$ openclaw update status
# Reports: npm latest 2026.2.21 (local newer) ✅
```
## Alternative Considered
Issue #23647 suggested changing the version naming convention from `YYYY.M.D-N` to `YYYY.M.D.N` (dot-separated). While that would work, this fix is less disruptive and handles the existing version format correctly.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds build suffix support to version comparison logic to correctly handle versions like `2026.2.21-2`. The implementation introduces `parseVersionWithBuild()` which extracts both semver components and numeric build suffixes, treating higher build numbers as newer versions. This fixes false "update available" warnings when running `openclaw update status` with build-suffixed versions.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is well-tested with 7 comprehensive test cases covering edge cases like numeric build comparison (10 > 2), equality checks, and various build suffix formats. The regex pattern `/-(\d+)(?:[+.]|$)/` correctly handles build suffixes while avoiding false matches with pre-release versions (since it requires digits immediately after the hyphen). The change is focused, backward-compatible, and directly addresses the reported issue.
- No files require special attention
<sub>Last reviewed commit: 7fdf416</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23660: fix(update): compare numeric -N suffix as build revision
by rylena · 2026-02-22
86.3%
#17237: fix(update): guard post-install imports after npm global update
by tdjackey · 2026-02-15
80.4%
#22406: Fix update detection for Companion App npm-prefix installs
by graysurf · 2026-02-21
75.9%
#16016: fix: update systemd unit version on gateway restart
by jbold · 2026-02-14
75.9%
#23113: fix: show actual runtime version after update/restart when service ...
by BryanTegomoh · 2026-02-22
74.9%
#18961: fix: detect pnpm package manager in openclaw update
by norci · 2026-02-17
73.8%
#17912: fix: configure git to use HTTPS instead of SSH for GitHub URLs
by MisterGuy420 · 2026-02-16
73.7%
#23597: fix(mac): stop Sparkle updater from offering downgrades as updates
by cyberdrk305 · 2026-02-22
73.5%
#13168: perf: short-circuit --version to skip process respawn and full modu...
by RamiNoodle733 · 2026-02-10
73.3%
#11415: Update package.json metadata for npm discoverability
by PythonUser42 · 2026-02-07
73.2%