Repository navigation
fix(runtime-host): surface refused Host handoff attempts instead of looping - #5758
Merged
jackwener merged 1 commit intoSep 27, 2026
Merged
Conversation
…ooping
When Desktop upgrades while a supervised Runtime Host from an older
release is running, the handoff starts an automatic safe replacement.
The managed update CLI cannot speak the old Host's retirement protocol,
so without interruption consent it reports active_tasks even though the
Host's handshake shows zero connections and operations. It rolls back
the staged package and leaves the launchd/systemd unit on the old
version.
The handoff projected that refusal for non-explicit replacements as
retry_required ("the service changed; retrying is safe"). Retrying runs
the same refused attempt again, so the dialog stayed open indefinitely
and the one action that works, Stop and continue, looked secondary.
A refusal is now projected as busy for every replacement kind, and an
idle busy view uses the existing "refused safe retirement" copy.
The local adapter also reported a target_mismatch refusal from the
update, repair, or restart command as a successful replacement or an
unavailable result. Pre-mutation refusals such as a downgrade then lost
their diagnostic and re-entered the same loop. They now fail like any
other refusal. Recovery is keyed to the observed blocker identity, so
a Host that really changed is still observed again and handled
automatically.
Refs apache#5476
Generated-by: Devin
Astro-Han
marked this pull request as ready for review
September 27, 2026 12:15
jackwener
approved these changes
Sep 27, 2026
jackwener
left a comment
Member
There was a problem hiding this comment.
Approving at dbb602d63d30c62c72fa90ca3e19cc3d9f519be9. No P0–P2 findings, and CI test is green.
- Loop fix:
projectBlockernow maps any refused safe attempt (activeWorkRefused) tobusy, whatever the replacement kind, before the explicit-selection and idle-activity branches. An idle supervised Host that refuses retirement therefore offerscancel / retry / interruptwith the existing "refused safe retirement" copy (formatHostHandofftreats idle activity plusbusyas the manual-busy case) instead of theretry_requiredscreen that re-ran the same refused staging. The renamed test pins the reason, the actions and the copy. - Desktop adapter:
target_mismatchfromservice update/restartno longer collapses toreplaced/unavailable. Pre-mutation refusals such as the downgrade guard keep their CLI diagnostic and surface as a repair failure, and the new assertions cover both the repair and the conflict-replacement paths. canInterrupt: false: this only occurs without a registration. There,busywithcancel / retryis accurate, and the copy points the user to closing other clients.- P3, accepted trade-off: a genuine concurrent replacement between observation and
service updateused to be absorbed asreplaced. It now surfaces as an error once, and the next attempt re-observes the new registration. That fits the PR's "recovery is keyed to the observed blocker identity" reasoning; I'm noting it only so the behavior change is visible. - Not verified: a real old-release supervised Host upgrade on macOS or Linux.
Automated review by an AI agent, approving at a maintainer's request. This is not an independent human review.
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.
Summary
When Desktop upgrades while a supervised Runtime Host from an older release is running, the handoff dialog can stay open indefinitely (#5476). The part of the report that still holds on
mainis the dialog getting stuck. The idea that staging never ends does not: the update process already stops after 10 minutes.maka runtime-host service updatefrom the new package. That CLI cannot speak the old Host's retirement protocol:connectExistingRuntimeHostreturnsincompatible. Without interruption consent,retireRuntimeHostLifecycleOwnertherefore returnsactive_tasksfor a supervised Host, even when its handshake reports 0 connections and 0 operations. The CLI then rolls back the staged package, so the launchd/systemd unit keeps pointing at the old version. This matches the "plist never rewritten, KeepAlive keeps the old daemon" observation in the issue comments.runHostHandoffcounted that refusal asbusyonly for explicit-selection replacements. For the supervised path it showedretry_required("the service changed; a safe retry won't interrupt work") plus "Maka keeps checking". Retry runs the same refused attempt (download, stage, rollback), so the loop never ends. The only action that works, Stop and continue, looked secondary. This is exactly the screen in the report:retry_requiredwith 0 connections, 0 operations and 0 background activities.Changes:
projectBlockernow shows any refused safe attempt asbusy, whatever the replacement kind. An idlebusyview uses the existing "The old service refused safe retirement… close other clients and try again, or explicitly interrupt work and continue" copy. No new strings.target_mismatchrefusal fromservice update/restartasreplaced/unavailable. Pre-mutation refusals such as "This update would downgrade the shared Runtime Host. Update the Client instead." used to lose their diagnostic and land in the same loop. They now becomerepair_requiredwith the CLI's message. Recovery is keyed to the observed blocker identity. A Host that really changed has a new registration, so it is still observed again and handled automatically.Refs #5476
Out of scope
target_mismatchtochanged. That path requires explicit selection with a manual recheck and has its own test, so it is left alone.isVersionNewercomparison mentioned in the issue thread is a separate app-update issue.Verification
main: the extendedhost-handofftest gotretry_requiredinstead ofbusy, and both extendedruntime-host-local-remote-accesscases resolved instead of rejecting.retireRuntimeHostLifecycleOwnerwith an idleincompatiblesupervised Host,refuse_active_work→{ kind: 'active_tasks' }and the supervisor is not retired.@maka/runtime-hostdist/**/*.test.js: 2144 passed, 2 failed. The 2 failures are sandbox Bash tests inexecution-model-composition, and they fail the same way on the rootmaincheckout.@maka/desktopdist/main/**/*.test.js: all pass.maka-agenthandoff tests (runtime-host-handoff-surface,local-handoff,managed-source-handoff): all pass.npm run lintandnpm run format:checkare clean.AI use
Tool(s) and scope: Devin handled the diagnosis, the code and test changes, and this description.
Checklist
Does this PR entail a change in behavior?