Wave-40 C11: user-initiated update check - #328
Conversation
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (12)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a user-initiated release update check command (sl-daemon check-update) that compares the installed version against the latest GitHub Release tag. The feedback highlights several critical improvements: enhancing the SemVer comparison to properly handle pre-release suffixes, supporting uppercase 'V' prefixes in release tags, and avoiding hardcoded repository URLs in the status output when a custom repository is queried. Additionally, the reviewer recommends configuring a network timeout on the HTTP client to prevent CLI hangs and adding support for GitHub authentication tokens to mitigate API rate-limiting issues.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| pub fn version_cmp(a: &str, b: &str) -> Ordering { | ||
| parse_semver(a).cmp(&parse_semver(b)) | ||
| } |
There was a problem hiding this comment.
The current version_cmp implementation completely ignores pre-release suffixes (e.g., -beta.1) by splitting on - and only comparing the numeric core. This causes stable releases and pre-releases of the same version core to be treated as equal (e.g., 0.1.0-beta.1 is treated as equal to 0.1.0). As a result, users on pre-releases will not be notified of stable updates, and pre-releases won't be ordered correctly. We should implement a robust comparison that handles pre-release tags according to SemVer rules.
pub fn version_cmp(a: &str, b: &str) -> Ordering {
let a_semver = parse_semver(a);
let b_semver = parse_semver(b);
match a_semver.cmp(&b_semver) {
Ordering::Equal => {
let a_pre = normalize_tag(a).split_once('-').map(|(_, pre)| pre);
let b_pre = normalize_tag(b).split_once('-').map(|(_, pre)| pre);
match (a_pre, b_pre) {
(None, None) => Ordering::Equal,
(None, Some(_)) => Ordering::Greater,
(Some(_), None) => Ordering::Less,
(Some(ap), Some(bp)) => compare_prerelease(ap, bp),
}
}
ord => ord,
}
}
fn compare_prerelease(ap: &str, bp: &str) -> Ordering {
let mut ap_parts = ap.split('.');
let mut bp_parts = bp.split('.');
loop {
match (ap_parts.next(), bp_parts.next()) {
(None, None) => return Ordering::Equal,
(None, Some(_)) => return Ordering::Less,
(Some(_), None) => return Ordering::Greater,
(Some(a_seg), Some(b_seg)) => {
let ord = match (a_seg.parse::<u64>(), b_seg.parse::<u64>()) {
(Ok(an), Ok(bn)) => an.cmp(&bn),
_ => a_seg.cmp(b_seg),
};
if ord != Ordering::Equal {
return ord;
}
}
}
}
}| pub fn format_status(status: &UpdateStatus) -> String { | ||
| match status { | ||
| UpdateStatus::UpToDate { installed, latest } => { | ||
| format!("sl-daemon {installed} is up to date (latest release: {latest})") | ||
| } | ||
| UpdateStatus::UpdateAvailable { installed, latest } => { | ||
| format!( | ||
| "update available: sl-daemon {installed} → {latest}\n\ | ||
| Download from https://github.com/{DEFAULT_REPO}/releases/tag/{latest}\n\ | ||
| Verify SHA256SUMS (and Sigstore bundle when present) before replacing binaries." | ||
| ) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The format_status function hardcodes DEFAULT_REPO in the printed download URL. If a user specifies a custom repository using the --repo flag, the printed update message will still point to the default repository. We should pass the queried repo to format_status to ensure the correct URL is displayed.
| pub fn format_status(status: &UpdateStatus) -> String { | |
| match status { | |
| UpdateStatus::UpToDate { installed, latest } => { | |
| format!("sl-daemon {installed} is up to date (latest release: {latest})") | |
| } | |
| UpdateStatus::UpdateAvailable { installed, latest } => { | |
| format!( | |
| "update available: sl-daemon {installed} → {latest}\n\ | |
| Download from https://github.com/{DEFAULT_REPO}/releases/tag/{latest}\n\ | |
| Verify SHA256SUMS (and Sigstore bundle when present) before replacing binaries." | |
| ) | |
| } | |
| } | |
| } | |
| pub fn format_status(status: &UpdateStatus, repo: &str) -> String { | |
| match status { | |
| UpdateStatus::UpToDate { installed, latest } => { | |
| format!("sl-daemon {installed} is up to date (latest release: {latest})") | |
| } | |
| UpdateStatus::UpdateAvailable { installed, latest } => { | |
| format!( | |
| "update available: sl-daemon {installed} → {latest}\n\ | |
| Download from https://github.com/{repo}/releases/tag/{latest}\n\ | |
| Verify SHA256SUMS (and Sigstore bundle when present) before replacing binaries." | |
| ) | |
| } | |
| } | |
| } |
| let payload = serde_json::to_string_pretty(&status).unwrap_or_default(); | ||
| println!("{payload}"); | ||
| } else { | ||
| println!("{}", update_check::format_status(&status)); |
| let latest_tag = match latest_override { | ||
| Some(tag) => tag, | ||
| None => { | ||
| let client = reqwest::Client::new(); |
There was a problem hiding this comment.
The reqwest::Client is constructed without a timeout. If the network is slow or GitHub is unresponsive, the CLI command will hang indefinitely. Configuring a reasonable timeout (e.g., 10 seconds) is a crucial best practice for CLI tools.
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(10))
.build()
.unwrap_or_default();| pub fn normalize_tag(tag: &str) -> &str { | ||
| tag.trim().strip_prefix('v').unwrap_or(tag.trim()) | ||
| } |
There was a problem hiding this comment.
The normalize_tag function only strips lowercase 'v'. If a release tag starts with uppercase 'V', it won't be stripped, leading to parsing failures. We should support both cases.
pub fn normalize_tag(tag: &str) -> &str {
let trimmed = tag.trim();
trimmed
.strip_prefix('v')
.or_else(|| trimmed.strip_prefix('V'))
.unwrap_or(trimmed)
}| let resp = client | ||
| .get(&url) | ||
| .header("Accept", "application/vnd.github+json") | ||
| .header("X-GitHub-Api-Version", "2022-11-28") | ||
| .header("User-Agent", "sl-daemon-check-update") | ||
| .send() | ||
| .await?; |
There was a problem hiding this comment.
Unauthenticated GitHub API requests are heavily rate-limited (60 requests per hour per IP). If users or CI workflows run check-update frequently, they will easily hit this limit. We should check for GITHUB_TOKEN or GH_TOKEN environment variables and attach them as a Bearer token if present to increase the rate limit to 5000 requests per hour.
let mut req = client
.get(&url)
.header("Accept", "application/vnd.github+json")
.header("X-GitHub-Api-Version", "2022-11-28")
.header("User-Agent", "sl-daemon-check-update");
if let Some(token) = std::env::var("GITHUB_TOKEN").ok().or_else(|| std::env::var("GH_TOKEN").ok()) {
if !token.trim().is_empty() {
req = req.header("Authorization", format!("Bearer {}", token.trim()));
}
}
let resp = req.send().await?;| std::env::var("SL_CHECK_UPDATE_LATEST").ok().filter(|value| !value.trim().is_empty()) | ||
| }); | ||
| let latest_tag = match latest_override { | ||
| Some(tag) => tag, |
There was a problem hiding this comment.
SUGGESTION: --latest "" (empty override) is not filtered, unlike the SL_CHECK_UPDATE_LATEST env-var branch at line 815.
When --latest is an empty/whitespace string, Some(tag) is used verbatim, so compare_versions(installed, "") parses latest as (0,0,0) and always reports UpToDate — silently hiding a real update. Filter the override for emptiness/whitespace the same way the env var does, e.g. chain .filter(|v| !v.trim().is_empty()) on the map so an empty --latest falls through to the API (or errors explicitly).
| Some(tag) => tag, | |
| Some(tag) => tag, |
| client: &reqwest::Client, | ||
| repo: &str, | ||
| ) -> Result<String, UpdateCheckError> { | ||
| let url = format!("{GITHUB_API_BASE}/repos/{repo}/releases/latest"); |
There was a problem hiding this comment.
SUGGESTION: The repo argument is interpolated into the request URL with no format validation.
If --repo is missing the owner/name slash (e.g. SessionLedger) or contains spaces/control characters, this builds a malformed path (/repos/SessionLedger/releases/latest) that returns HTTP 404 and a generic Parse error, which is confusing for operators. Validating that repo matches ^[^/]+/[^/]+$ (and trimming) before formatting the URL would surface a clear usage error. This is user-local, so severity is low, but it improves CLI robustness.
| let url = format!("{GITHUB_API_BASE}/repos/{repo}/releases/latest"); | |
| let url = format!("{GITHUB_API_BASE}/repos/{repo}/releases/latest"); |
Code Review SummaryStatus: 8 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (13 files)
Fix these issues in Kilo Cloud Previous Review Summary (commit 55bd403)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 55bd403)Status: 8 Issues Found (6 pre-existing from prior review + 2 new) | Recommendation: Address before merge Overview
The PR adds a clean, hermetic, well-tested Issue Details (click to expand)SUGGESTION (prior review — still open, active comments)
SUGGESTION (new this review)
Files Reviewed (12 files)
Reviewed by step-3.7-flash · Input: 103.1K · Output: 17.9K · Cached: 472.1K |
Add sl-daemon check-update to compare installed version against GitHub latest release without downloading or installing. Document ADR 0001 manual-update posture with SelfCheck anchors and soft/blocking CI smoke.
Co-authored-by: Cursor <cursoragent@cursor.com>
55bd403 to
91b517d
Compare


Summary
sl-daemon check-updateto compare the installed version against the latest GitHub Release tag (check-only; no download or install per ADR 0001).docs/ops/update-check.mdwith ADR/distribution cross-links.scripts/update-check-check.ps1,tests/update_check.rs) plus soft (update-check-soft.yml) and blocking (update-check-hard.yml) CI smoke.Test plan
pwsh ./scripts/update-check-check.ps1 -SelfCheckcargo test update_checkincrates/sl-daemoncargo test --test check_updateincrates/sl-daemoncargo test --test update_checkat repo rootupdate check hardworkflow on PR