You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(managed-server): let a forced update or rollback cross mixed daemon generations - #34664
A long-running SSH host can end up with terminals spread across two terminal daemons: an older one kept alive through a past update, and the current one. Orca's update check asked the host which daemon protocol its terminals use. When the host had two, it answered "unknown", and Orca then refused even a forced update. A busy host could never be updated without closing every terminal. The host now names every protocol in use, and Orca allows the forced update when the new build can reach all of them.
What Changed
The terminal census (orcad.terminalCensus) gets an optional daemonProtocolVersions list naming every daemon generation that owns live sessions. The existing single daemonProtocolVersion field keeps its old meaning for older desktops.
assessOrcadLiveDaemonCrossing checks every listed protocol. A crossing counts as attachable only if the incoming build (for update) or the target build (for rollback) can attach each one. It strands terminals if any one can't be attached, and is unverifiable only if no protocol is known. Refusal messages name the protocols that can't be attached.
Before: forced update and rollback on a host with mixed daemon generations always failed with *_daemon_protocol_unverifiable. After: they proceed when every generation is reachable. They are still refused when any generation would be stranded.
Why
The census had been collapsing a set of protocols to a single number. That lost the very information the safety check needs. Reporting the set fixes the cause, rather than adding a way to override the check, and keeps the guarantee that a forced update never strands terminals. This is the same set model getLocalBuildCompatibilityError already uses for local builds.
Mixed versions:
New desktop with an old host: the list is absent, so the desktop falls back to the scalar (same behaviour as today).
Old desktop with a new host: the desktop strips the unknown key, so behaviour is unchanged.
Hosts still on an older orcad keep reporting only the scalar, so their first update across this change needs a follow-up that has the incoming build's own preflight report the live daemon generations. That will be a separate PR.
Linked Issue
No GitHub issue; reported directly by the maintainer (managed host "omarchy": 80 live terminals, orcad_update_daemon_protocol_unverifiable even with --force).
Visual Proof
N/A: planner and wire-format change with no UI change. The existing refusal and proceed paths render as before.
Testing
Automated tests added/updated
New: mixed generations {2,3} proceed when forced and {3,4} strand (update); {1,3} roll back cleanly and {2,4} strand (rollback); an empty set with live sessions stays unverifiable; the host census names every generation. These fail on main and pass here.
Ran every unit test file that imports a changed module (15 files), the static lint/format/type-aware/changed-code/ratchet gates, typecheck:ci, and check-daemon-protocol-crossing.
smoke:orcad-terminal could not complete locally because the machine is heavily loaded (file watcher readiness timeout in the profile preflight, which this diff does not touch). CI covers it.
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Security: none. Cross-platform: platform-neutral planner code. SSH/WSL: both use the same census and planner. Mobile: not affected. Performance: one extra small array per census.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
…on generations
The terminal census collapsed sessions spread over more than one daemon
generation to a null protocol, so a host that kept a legacy daemon alive
across an earlier update refused every forced update and rollback while any
terminal ran. The census now reports every live protocol, and the crossing
check requires the incoming build to attach each one. The single-protocol
field stays for older desktops.
The terminal census now reports sorted, unique daemon protocol versions and sets the legacy scalar only when one version is present. Crossing assessment checks compatibility with every reported version and returns structured outcomes. Update and rollback planning use those outcomes and include incompatible versions in their messages. Tests cover single and mixed generations, empty protocol data, update deferrals, and rollback results.
Priority: Normal
Merge Risk: Moderate · up to b0158
Managed rollback still refuses live terminals even when their daemon generations are compatible. The promised rollback support needs integration before merge.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title names the main change: a forced update or rollback can now cross mixed daemon generations. It matches the changeset, which adds a daemon protocol list to the census and checks every reported…
Description check
The description follows the template. It has an ELI5 section, a What Changed section with the before and after behavior, a Why section that explains the chosen approach and the alternatives, a Testing…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a forced update or rollback can now cross mixed daemon generations. It matches the changeset, which adds a daemon protocol list to the census and checks every reported protocol in the crossing assessment. The title uses a conventional prefix and stays within one sentence. It is 83 characters, which is long but acceptable.
Full details: Description check
Explanation
The description follows the template. It has an ELI5 section, a What Changed section with the before and after behavior, a Why section that explains the chosen approach and the alternatives, a Testing section with specific tests and a note on the failed smoke test, and the AI disclosure and upstream boundary sections. The Linked Issue section has no issue number. It says the report came from a maintainer and gives no GitHub issue, so the template's linked-issue requirement is not met. The Visual Proof section is marked N/A with a reason. The final lint/typecheck/test/build checklist item is unchecked, though the Testing section says CI will cover it.
Resolution
Add a linked issue number in the Linked Issue section, or confirm that a maintainer-reported change does not need one. Check the final checklist item once the lint, typecheck, test, and build commands pass, or state which of them CI will cover.
Full details: Docstring Coverage
Explanation
Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 6 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: c03eef1d-c3f7-4594-a747-b53f57a75a99
Commits
Reviewing files that changed from the base of the PR and between 4f9b331 and b01586f.
Files selected for processing: 6
src/main/orcad/orcad-terminal-census.test.ts
src/main/orcad/orcad-terminal-census.ts
src/main/ssh/orcad-daemon-protocol-crossing.ts
src/main/ssh/orcad-update-plan.test.ts
src/main/ssh/orcad-update-plan.ts
src/shared/orcad-terminal-census.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
The managed rollback refuses every live session, so mixed-generation rollback cannot run.
Two gates block the rollback before the crossing check can decide. The managed entrypoint refuses any nonzero live count, and the fenced recount refuses the same way. Replacing only one gate does not unblock the workflow.
rollbackManagedOrcadEnvironment returns orcad_rollback_terminals_running when census.liveSessions !== 0. This happens before rollbackOrcad is called.
If that gate passes, runFencedStop recounts the census and calls refuse: rollbackRecountRefusal. Any nonzero count returns orcad_rollback_terminals_running.
The assessOrcadRollback crossing check never evaluates a mixed-generation census on this path. The PR describes rollback as proceeding when the target can attach to every live daemon protocol. The managed rollback does not do this.
The remedy must do more than move the refusal. Keep these points in any change:
Keep an explicit refusal for liveSessions === null in both gates. assessOrcadRollback does not refuse a null count directly. It refuses only a null startedSinceActivation. A null count with known protocols can pass the crossing check as attachable.
assessOrcadRollback already refuses in-process sessions, which set startedSinceActivation to null. It refuses sessions started after activation, where startedSinceActivation > 0. Keep both refusals.
The recount callback receives only the census. The record, snapshot presence, target protocol facts, and state-write check must come from the enclosing rollbackOrcadLocked closure.
Do not relax either gate yet. The managed entrypoint passes targetDaemonProtocol: CURRENT_ORCAD_DAEMON_PROTOCOL. That is the running client build's protocol. The rollback target is record.previous, an earlier build. The crossing check uses the passed value to decide attachability. An older target can then be judged able to attach to daemon protocols it does not list. The rollback would strand running terminals. Pass the target build's own protocol facts before the mixed-generation path is enabled.
The comment above the entrypoint check ("Require idle because this client cannot prove the older build's daemon protocol attaches") describes the gap that this PR closes for census reporting. It does not describe the target-build gap, which remains.
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
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.
ELI5
A long-running SSH host can end up with terminals spread across two terminal daemons: an older one kept alive through a past update, and the current one. Orca's update check asked the host which daemon protocol its terminals use. When the host had two, it answered "unknown", and Orca then refused even a forced update. A busy host could never be updated without closing every terminal. The host now names every protocol in use, and Orca allows the forced update when the new build can reach all of them.
What Changed
orcad.terminalCensus) gets an optionaldaemonProtocolVersionslist naming every daemon generation that owns live sessions. The existing singledaemonProtocolVersionfield keeps its old meaning for older desktops.assessOrcadLiveDaemonCrossingchecks every listed protocol. A crossing counts as attachable only if the incoming build (for update) or the target build (for rollback) can attach each one. It strands terminals if any one can't be attached, and is unverifiable only if no protocol is known. Refusal messages name the protocols that can't be attached.*_daemon_protocol_unverifiable. After: they proceed when every generation is reachable. They are still refused when any generation would be stranded.Why
The census had been collapsing a set of protocols to a single number. That lost the very information the safety check needs. Reporting the set fixes the cause, rather than adding a way to override the check, and keeps the guarantee that a forced update never strands terminals. This is the same set model
getLocalBuildCompatibilityErroralready uses for local builds.Mixed versions:
Hosts still on an older orcad keep reporting only the scalar, so their first update across this change needs a follow-up that has the incoming build's own preflight report the live daemon generations. That will be a separate PR.
Linked Issue
No GitHub issue; reported directly by the maintainer (managed host "omarchy": 80 live terminals,
orcad_update_daemon_protocol_unverifiableeven with--force).Visual Proof
N/A: planner and wire-format change with no UI change. The existing refusal and proceed paths render as before.
Testing
typecheck:ci, andcheck-daemon-protocol-crossing.smoke:orcad-terminalcould not complete locally because the machine is heavily loaded (file watcher readiness timeout in the profile preflight, which this diff does not touch). CI covers it.Review
Agent skill upstream boundary
Notes
Security: none. Cross-platform: platform-neutral planner code. SSH/WSL: both use the same census and planner. Mobile: not affected. Performance: one extra small array per census.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)