feat(self-update): wait for delegated daemon update to complete#699
Merged
Conversation
When the alert daemon owns the binary swap, `bestool self-update` handed off the update and exited immediately, leaving the operator with no visibility on whether it succeeded. Poll the daemon after delegating: watch `/status` for a restart (a fresh `started_at`) to confirm the new binary is running, and add a `/tasks/self-update/status` endpoint so a failed install is surfaced instead of timing out silently. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
passcod
enabled auto-merge
July 20, 2026 09:47
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, when the alert daemon is running,
bestool self-updatehands the binary swap off to the daemon and then exits immediately:The daemon does the download / verify / install / restart in a background task, so the command returns before any of that happens. The operator has no visibility on whether the update actually completed.
Change
The CLI now waits for the delegated update to run to completion instead of exiting the moment the daemon accepts it.
crates/bestool/src/actions/self_update.rs— before kicking off the update, record the daemon'sstarted_at; after delegating, poll until one of:/statusreports a freshstarted_at(the daemon restarted onto the new binary) → log the running version and return success, warning if it isn't the version that was requested;bestool alertd status.Connection errors during polling are treated as "daemon mid-restart" and don't abort the wait.
crates/bestool/src/actions/self_update/task.rs— add a/tasks/self-update/statusendpoint exposing the lastfailed_version, so a failed background install is surfaced instead of only timing out.Tests
Added unit tests for the restart-detection logic (
restart_completed).Verification
Non-test builds pass on both the unix default target and
x86_64-pc-windows-gnu(the delegation path is Windows-only);cargo fmt --checkand clippy are clean for the changed code. Note:cargo test/clippy --testsfor the crate currently fails to compile due to a pre-existing, unrelated issue incanopy_contract.rs(identical on the base commit), so the new tests compile-check under the non-test Windows build but weren't executed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01J7Hgzqa2sEfCUnqj8sNdoK
Generated by Claude Code