hand the windows update off to a detached installer - #3302
Closed
kevinjosethomas wants to merge 1 commit into
Closed
kevinjosethomas wants to merge 1 commit into
kevinjosethomas wants to merge 1 commit into
Conversation
Windows keeps a running executable's directory un-renameable, and the running CLI is the payload binary the installer replaces (the .cmd and sh launchers exec <prefix>/share/prime-agent/prime-agent.exe), so the spawn-and-wait channel funnel could never let the installer's publish (the rename of that directory) happen. When the caller IS the install's payload binary (cfg(windows) + the marked-tree gate), the funnel now spawns the installer detached without waiting and reports a Handoff outcome; the CLI and the TUI /update print the handoff line and exit, so the unlocked directory lets the publish land. Unix keeps the deterministic spawn-and-wait (and its e2e tests unchanged).
Contributor
[written by prime-agent, reviewed by snimu] |
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.
On Windows,
prime-agent updatecan never publish: the running CLI is the payload binary under<prefix>\share\prime-agent, and Windows will not let the installer rename that directory while a process that lives in it is still running — so the funnel's spawn-and-wait wedges the installer mid-publish forever. The funnel now hands off on Windows when the caller IS that payload binary: it spawns the installer detached without waiting, prints one handoff line, and exits so the publish can land; the TUI's/updatedoes the same and hands the terminal back before it exits. Unix keeps its deterministic spawn-and-wait (and its e2e tests unchanged).update::installer:RunOutcome::Handoff— the gate iscfg(windows)plus "this exe is<prefix>/share/prime-agent/prime-agent.exein a marked tree" (canonicalized path compare + the install marker as the ownership proof); the installer spawns with the product's detached-spawn contract and is never waited on. The gate sits inexecute_script, so fix update rollback and archive on installer installs #3278's bundled-installer paths inherit it on rebase (its Macroscope thread on installer.rs:251).Parity-diff evidence: no TS counterpart exists — the TypeScript product never shipped a Windows build, so this surface has nothing to diff; the unix funnel is unchanged and its e2e (
installer_update_e2e) reran green on this branch.Ownership: pa-core owns the funnel (the handoff is one more outcome of its exec step); the two pa-cli surfaces own printing and exiting; pa-tui exposes its existing one process-exit restore to the composition root; dependency direction unchanged.
Testing (Prime sandbox, rust pinned to 1.98.1, python 3.12 first on PATH):
cargo fmt --all --checkandcargo clippy -p pa-cli -p pa-core -p pa-tui --all-targets -- -D warningsgreen.cargo test -p pa-core --lib update::(36),-p pa-cli --lib -- update installer(27),-p pa-tui --lib -- update_command exit_restore,--test installer_update_e2e(3),--test installer_platform_map(3),--test release_workflow(6, no skips),--test windows_update_handoff_e2e(compiles, 0 tests on unix).cargo check --target x86_64-pc-windows-gnu -p pa-cli --all-targetsgreen; pa-core lib green on that target (pa-core'skernel_startup_jointest red on windows-gnu is pre-existing — identical on main).crates/pa-cli/tests/windows_update_handoff_e2e.rsrides the windows battery (windows-runtime-triage): the payload-binary CLI exits while the installer is still running, and the detached installer survives the exit and lands its payload.Note
Hand off Windows update to a detached installer instead of waiting
execute_scriptin installer.rs now spawns the installer detached with a null stdin and its own process group, then returns without waiting. This lets the caller exit before the installer renames the payload directory, which would otherwise fail while the payload is running.RunOutcomeenum with separateInstalledandHandoffvariants, so callers can distinguish a completed update from a detached handoff.caller_is_payload_binary/is_payload_binary_of) only triggers when the current executable canonically matches the marked payload executable under the install prefix. A Windows unit test covers marker and path matching.run_updatein client_update.rs) and the CLI (runin installer_update.rs) — restore the terminal, print a shared handoff message, and exit successfully. Only a completed install persists the explicit channel.restore_terminalin exit_restore.rs is now public for the CLI to call.RunOutcomeenum; a handoff result is treated as unexpected on Unix. Windows handoff runs skip the launcher version probe and do not persist the requested channel.Macroscope summarized d07134f.