fix(update): apply staged Windows replacement#21
Open
NianJiuZst wants to merge 3 commits into
Open
Conversation
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.
What Problem This Solves
On Windows,
bsk updatecould report a successful update even though the installed executable was never replaced. The updater wrote a staged executable and a.cmdreplacement script next to the running binary, then returnedInstallAction::Staged, but nothing launched that script. The old executable therefore remained installed indefinitely.This also created a daemon availability problem. The update flow stops a running daemon before replacing the binary. Because the staged replacement never ran—and because the Windows path did not preserve the previous daemon state—the command could leave users on the old version with their daemon stopped while still printing an update-style success message.
How This Fix Works
cmd.exeprocess before the updater exits.bsk.exereleases its file lock, then atomically replace the target from the staged executable.stagedstatus and wording that accurately describes when the replacement will occur.User Impact
Windows users can now run
bsk updateand have the staged version applied automatically after the command exits. A daemon that was running before the update comes back on the new binary, while an intentionally stopped daemon remains stopped. Failed helper launches are visible as failures rather than false-positive update reports.Validation
cargo fmt --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --lockedThe full local Rust workspace suite passed. A local GNU Windows cross-check was also attempted, but this macOS environment does not provide the
x86_64-w64-mingw32-gcctoolchain required by the transitiveaws-lc-sysbuild; GitHub CI remains the authoritative clean-environment build check for the PR.CI Baseline Compatibility
This branch also carries the one-line Biome 2.4 formatter output for
apps/extension/vitest.config.ts. The same formatting mismatch currently fails the Frontend job onupstream/main; this minimal compatibility commit is intentionally separate from the functional fix and lets this PR run the repository CI suite to completion.CI Reliability Follow-up
GitHub Actions exposed a pre-existing test-only port allocation race: integration helpers probed an ephemeral port, released it, and then asked the daemon to bind the same number, allowing another process to claim it in between. The resulting
Address already in usefailure was unrelated to the functional changes. The PR now lets each daemon bind port0directly and reads the assigned address from its handle, removing the TOCTOU window across all affected integration helpers.