Skip to content

feat(cli): auto-update — nudge + tracebloc upgrade (F1) - #390

Merged
shujaatTracebloc merged 4 commits into
developfrom
feat/cli-auto-update
Jul 23, 2026
Merged

feat(cli): auto-update — nudge + tracebloc upgrade (F1)#390
shujaatTracebloc merged 4 commits into
developfrom
feat/cli-auto-update

Conversation

@LukasWodka

@LukasWodkaLukasWodka commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Fixes the stale-CLI problem (backlog F1): install once → never updated.

  • Update-check nudge — after any command, a quiet once/day line when a newer release exists (cache in ~/.tracebloc, 2s network cap, best-effort). Silent on dev builds, off a terminal, in CI, or via TRACEBLOC_NO_UPDATE_CHECK.
  • tracebloc upgrade — re-runs the verified installer (reuses cosign; upgrades CLI + environment together, no skew).
  • 426 "too old" now points at tracebloc upgrade.

Not a silent auto-replace (surprise/latency/security/skew) — nudge + one-command apply, the gh/kubectl pattern. Tests: semver compare, cache, fetch (httptest), fresh/stale, skip gates. Catalog: 11-upgrade.golden.

🤖 Generated with Claude Code


Note

Medium Risk
upgrade shells out to curl|bash on Unix (trusted installer path, but still elevated user impact); update checks add outbound GitHub traffic on interactive release builds only.

Overview
Adds F1 stale-CLI handling: a best-effort update nudge after commands plus an explicit tracebloc upgrade path, without silent auto-replace.

main switches to ExecuteContextC so it knows which command ran, then calls MaybeNotifyUpdate on stderr (skipped after upgrade). The nudge checks GitHub’s latest release at most once per day (cached under ~/.tracebloc), with a 2s timeout; it stays quiet on dev builds, non-TTY, CI, or TRACEBLOC_NO_UPDATE_CHECK.

tracebloc upgrade on Linux/macOS re-runs the signed official installer via bash -o pipefail (CLI + secure environment stay aligned); on Windows it only prints the PowerShell install command because the running binary can’t replace itself.

HTTP 426 upgrade-required copy now points at tracebloc upgrade instead of generic release URLs. Copy catalog gains 11-upgrade.golden and home help lists upgrade.

Reviewed by Cursor Bugbot for commit ab10dc7. Bugbot is set up for automated code reviews on this repo. Configure here.

Customers run the installer once and then never again, so they silently sit on
an old CLI. Three layers, all safe (no silent binary swap):
- Update-check nudge: after any command, a quiet one-liner if a newer release
exists. Throttled to once/day via a cache in ~/.tracebloc, network capped at
2s, best-effort. Silent on dev builds, off a terminal, in CI, or with
TRACEBLOC_NO_UPDATE_CHECK. Nudges from cache; refreshes when stale.
- `tracebloc upgrade`: the apply step. Re-runs the official installer
(curl … | bash) so it reuses the existing cosign verification and upgrades
the CLI + the secure environment together (no version skew) — no new download/
verify surface in the CLI.
- The existing 426 "CLI too old" error now points at `tracebloc upgrade`.
Tests cover the semver compare (incl. v-prefix + pre-release), cache round-trip,
the GitHub fetch (httptest), fresh-vs-stale cache behavior, and the skip gates.
Catalog: adds 11-upgrade.golden.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodkaLukasWodka self-assigned this Jul 22, 2026
@LukasWodka

Copy link
Copy Markdown
ContributorAuthor

bugbot run

Comment threadinternal/cli/update_check.go
Comment threadcmd/tracebloc/main.go Outdated
Comment threadinternal/cli/upgrade.go
shujaat hasanand others added 2 commits July 23, 2026 15:40
Three medium-severity issues from Cursor Bugbot:
1. Offline throttle broken (update_check.go): on a failed fetch,
latestReleaseVersion fell back to the stale cache but never re-stamped
CheckedAt, so the cache stayed expired and every command re-hit the
network and ate the 2s timeout while offline. Now re-stamps CheckedAt so
the once-per-interval throttle actually holds.
2. Nudge fired after a successful `tracebloc upgrade` (main.go): the nudge
used the running process's compile-time version, which is stale by design
once upgrade swaps the binary — so it claimed a newer release existed
right after the user installed it. main now captures the executed command
via ExecuteContextC and skips the nudge for `upgrade`.
3. `upgrade` broken on Windows (upgrade.go): it hardcoded `bash i.sh`, but
Windows is a shipped platform (install.ps1, windows/* build matrix) with
no bash — while the new 426 message tells users to run `upgrade`. Now
branches on GOOS to run install.ps1 via PowerShell on Windows.
Adds regression tests: offline-fetch throttle refresh, per-OS upgrade
command, and the upgrade nudge-skip detector.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shujaatTracebloc

Copy link
Copy Markdown
Contributor

Pushed fixes for the 3 Bugbot findings (commit 63d43d4), plus merged latest develop:

  1. Offline throttle broken — on a failed fetch, latestReleaseVersion fell back to the stale cache but never re-stamped CheckedAt, so every command re-hit the network and ate the 2s timeout while offline. Now re-stamps CheckedAt so the once-per-interval throttle holds.
  2. Nudge after successful upgrade — the nudge used the running process's compile-time version (stale by design once upgrade swaps the binary). main now captures the executed command via ExecuteContextC and skips the nudge for upgrade.
  3. upgrade broken on Windows — hardcoded bash i.sh, but Windows is a shipped platform (install.ps1, windows/* matrix) with no bash. Now branches on GOOS to run install.ps1 via PowerShell, matching the README's documented Windows install.

Added regression tests: offline-fetch throttle refresh, per-OS upgrade command, upgrade nudge-skip detector. Full internal/cli suite + go vet green locally.

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 63d43d4. Configure here.

Comment threadinternal/cli/upgrade.go Outdated
Comment threadinternal/cli/upgrade.go Outdated
Comment threadinternal/cli/upgrade.go
Round-2 Bugbot review of the auto-update work surfaced 3 real HIGH issues,
all verified against scripts/install.ps1:
1. Upgrade hid curl failures: `curl … | bash` ran under `bash -c` without
pipefail, so a failed curl left the trailing `bash` exiting 0 on empty
stdin and `upgrade` reported success having installed nothing. Now runs
with `bash -o pipefail -c`.
2/3. Windows self-upgrade can't work: install.ps1 is CLI-only (no environment
upgrade) and Move-Items the binary into place, which Windows blocks for a
running .exe. Proper Windows self-update is a separate feature, so instead
of pretending, `upgrade` on Windows now prints the documented manual
command to run in a fresh shell (no tracebloc process holding the binary).
Help/home/copy no longer promise CLI+environment parity on Windows.
Refactors the per-OS branch into upgradePlanFor(goos) (exec on Unix, guide on
Windows) so it's testable on any host. Regenerates copy-catalog goldens.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shujaatTracebloc

Copy link
Copy Markdown
Contributor

Round-2 fixes pushed (commit ab10dc7) — all 3 HIGH findings verified against scripts/install.ps1 and resolved:

  1. Upgrade hid curl failures — Unix now runs bash -o pipefail -c …, so a failed curl fails the whole pipeline instead of the trailing bash exiting 0 on empty stdin.
    2 & 3. Windows self-upgrade can't work — confirmed install.ps1 is CLI-only and does Move-Item -Force onto the binary (Windows locks a running .exe). Proper Windows self-update is a separate feature, so rather than pretend, upgrade on Windows now prints the documented manual command to run in a fresh shell. Help/home/copy no longer promise CLI+environment parity on Windows.

Refactored the per-OS branch into upgradePlanFor(goos) (exec on Unix, guide on Windows) — testable on any host. Regenerated copy-catalog goldens. Full go test ./... + go vet + gofmt green locally.

Windows automatic self-upgrade (running-exe swap + Windows environment story) is worth its own ticket — happy to file it.

@shujaatTracebloc
shujaatTracebloc merged commit dfee738 into developJul 23, 2026
20 checks passed
@shujaatTracebloc
shujaatTracebloc deleted the feat/cli-auto-update branch July 23, 2026 13:59
shujaatTracebloc pushed a commit that referenced this pull request Jul 23, 2026
Resolves the develop conflict (branched before the upgrade #390 and
prepare-host #394 commands merged): copy_catalog_test.go auto-merged to keep
all three commands' catalog entries; regenerated goldens (zz-all-strings +
00-home + 08-client) so the harvested strings and command lists include upgrade,
prepare-host, and the seal-check screens together. No code conflicts; the seal
logic is unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@LukasWodka@shujaatTracebloc