Skip to content

fix(managed-server): let a forced update or rollback cross mixed daemon generations - #34664

Merged
nwparker merged 1 commit into
mainfrom
fix/orcad-census-protocol-set
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/orcad-census-protocol-set

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22

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

  • 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.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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.

Comment on lines 213 to +228
@@ -218,13 +219,13 @@ export function assessOrcadRollback(input: {
`${target} would reach the terminals still running. Retry when the daemon answers.`
}
}
if (crossing === 'strands-live-terminals') {
if (crossing.state === 'strands-live-terminals') {
return {
safety: 'unsafe',
code: 'orcad_rollback_strands_live_terminals',
reason:
`The live terminal daemon speaks protocol ${String(input.census.daemonProtocolVersion)}, ` +
`which ${target} does not list. Rolling back now would leave every running terminal ` +
`A live terminal daemon speaks ${describeDaemonProtocols(crossing.unattachable)}, ` +
`which ${target} does not list. Rolling back now would leave its running terminals ` +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Heavy lift

Supported by static analysis

Script executed:

rg -n 'runFencedStop|rollbackRecountRefusal|rollbackOrcadLocked|assessOrcadRollback|targetDaemonProtocolVersion' src/main
sed -n '1,240p' src/main/managed-server/lifecycle/orcad-rollback-transition.ts
sed -n '1,160p' src/main/managed-server/lifecycle/orcad-rollback-admission.ts

Repository: stablyai/orca

Length of output: 14241


Script executed:

# Read the fenced stop ordering, the rollback assessment, and the managed entrypoint with its callers.
sed -n '1,140p' src/main/ssh/orcad-fenced-stop.ts
echo '--- orcad-update-plan.ts assessOrcadRollback ---'
sed -n '140,260p' src/main/ssh/orcad-update-plan.ts
echo '--- orcad-runtime-maintenance.ts ---'
sed -n '195,245p' src/main/ssh/orcad-runtime-maintenance.ts
echo '--- rollbackOrcad / rollbackManagedOrcadEnvironment callers ---'
rg -n -F -e 'rollbackManagedOrcadEnvironment' -e 'rollbackOrcad(' -e 'orcad_rollback_terminals_running' -- src/main || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 15085


Script executed:

rg -n -F -e 'CURRENT_ORCAD_DAEMON_PROTOCOL' -e 'OrcadDaemonProtocolFacts' -e 'targetDaemonProtocol' -- src/main src/shared || test "$?" -eq 1
echo '--- orcad-daemon-protocol-crossing.ts ---'
sed -n '1,90p' src/main/ssh/orcad-daemon-protocol-crossing.ts
echo '--- orcad-remote-rollback.ts rollbackOrcad ---'
sed -n '40,90p' src/main/managed-server/install/orcad-remote-rollback.ts

Repository: stablyai/orca

Length of output: 7365


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.

@nwparker
nwparker merged commit bd4702f into main Oct 28, 2026
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant