Skip to content

fix(orcad): refuse an update that would end a degraded host's in-process terminals - #25598

Merged
OrcaWin merged 1 commit into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-in-process-census
Oct 5, 2026
Merged

OrcaWin merged 1 commit into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-in-process-census

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​64 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​57
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26

ELI5

When a managed Orca server's background terminal process is in a reduced ("degraded") mode, new terminals run inside the server process itself, so a restart ends them. Updating the server, even when forced, could restart it and end those terminals, while the update message said the terminals would survive. Now Orca refuses that update and says why.

What Changed

Before

  • fix(orcad): count a degraded daemon's in-process terminals in the terminal census #25545 added the in-process terminals to the live terminal count. But the update plan still saw the daemon's protocol as reachable, so it treated every live terminal as one that survives a restart.
  • Without force, the update deferred with "The restart would not kill them — the daemon is preserved".
  • With --force (CLI) or the force option in the UI, it proceeded with the note "They survive the restart on the existing daemon". The restart then ended every in-process terminal.

After

  • Census: it reports the in-process terminals separately, in a new optional inProcessSessions field. They are still included in liveSessions. An unreadable census reports the field as unknown, not zero.
  • Update plan: when that count is above zero, planOrcadUpdate defers with a new code, orcad_update_ends_in_process_terminals, before any force handling. The reason says the terminals run inside the orcad process because its daemon is degraded, that any restart ends them, and that forcing cannot keep them alive.
  • Not forceable: isForceableOrcadDeferral doesn't include the new code, so the UI offers no Force button and the CLI's --force gets the same refusal.
  • UI: the new code shows the existing localized "terminals on this server are still running. Close them and try again" line.
  • Auto-update: it treats the code as "wait and retry", like the other live-terminal deferrals.
  • Telemetry: the code is added to the managed-server failure list as update_ends_in_process_terminals, so it isn't recorded as other.

Why

  • Refuse instead of letting force proceed with a warning. The update plan's notes don't reach the CLI or the UI, so a forced update would still end those terminals without the user being told.
  • A separate count rather than reporting the daemon protocol as unknown (the other option the review suggested). That option would only refuse a forced update with a misleading "daemon protocol unverifiable" message. Counting in-process terminals separately states the real cause.

Linked Issue

Phase 3 round-6 review (medium, internal).

Visual Proof

N/A. No layout changes; the update action shows the existing "terminals still running" message for this case.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

New in orcad-update-plan.test.ts: a degraded host goes through the real census and the update plan. It has one daemon session on a protocol the new build can attach to, plus two in-process terminals. Both the unforced and the forced update defer with the new code, and the reason says the restart ends them. The existing census tests now expect inProcessSessions.

Ran locally: pnpm tc:node, the changed-code gate, the format check, and the census and update-plan tests.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Wire compatibility: inProcessSessions is a new optional field. An older host leaves it out and the plan treats that as no in-process terminals, which is exactly what that host knew before. An older client ignores it.
  • Out of scope: stop (decommission) also ends in-process terminals and isn't changed here.

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)

…ess terminals

The census now reports inProcessSessions separately. Those terminals run inside orcad and
end with any restart, so planOrcadUpdate defers with a non-forceable
orcad_update_ends_in_process_terminals instead of claiming they survive on the daemon.

@pullfrog pullfrog 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.

ℹ️ No critical issues — one order-of-checks issue inline, plus a wire-compat note.

Reviewed changes

  • Census field. OrcadTerminalCensusSchema gains an optional inProcessSessions; the orcad census computes it (and the host UNVERIFIABLE constant now carries null), so an unreadable census reports unknown rather than zero.
  • Update planner. planOrcadUpdate defers with the new orcad_update_ends_in_process_terminals when inProcessSessions ?? 0 > 0, ahead of the live-session/force branches.
  • Not forceable. isForceableOrcadDeferral is unchanged, so the new code offers no Force path, and auto-update treats it as a wait-and-retry code.
  • Surfaces. The renderer maps the code to the existing live-terminal copy; the telemetry failure enum gains update_ends_in_process_terminals via the orcad_ prefix strip.
  • Tests. Census expectations gain inProcessSessions; a new update-plan case drives the real census and pins the deferral for forced and unforced.

ℹ️ inProcessSessions absence also describes the #25545-only host

The body says an older host that omits the field "is exactly what that host knew before." That is true for a host predating #25545, but the base branch already contains #25545 (6cf918a0f3), which counts in-process terminals in liveSessions while (before this PR) omitting the field. If any build ships between #25545 and this PR, input.census.inProcessSessions ?? 0 treats that host's in-process terminals as none, and a forced update proceeds with the "They survive the restart" note — the exact loss this PR prevents. If the phase branch merges wholesale (as #24863 implies) there is no such build and this is moot; otherwise the ?? 0 default is the gap.

Technical details
# Wire-compat default for `inProcessSessions`

## Affected sites
- `src/main/ssh/orcad-update-plan.ts:115` — `const inProcess = input.census.inProcessSessions ?? 0`.
- `src/main/ssh/orcad-update-plan.ts:82-91` — force + `unverifiable` returns before the in-process guard.

## Required outcome
- Decide whether a build can exist between #25545 and this PR. If it can, an absent
  `inProcessSessions` on a host whose `liveSessions > 0` must not be read as zero when forcing.

## Suggested approach (only if a build can ship in that window)
- Treat absent-while-live as unverifiable and refuse force, or hold #25545 and this PR to the
  same release.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +115 to +117
const inProcess = input.census.inProcessSessions ?? 0
// Why force cannot override: these run inside orcad, so no daemon carries them across.
if (inProcess > 0) {

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.

On the canonical degraded host — an empty daemon plus in-process terminals, which the census test pins as { liveSessions: 1, daemonProtocolVersion: null, inProcessSessions: 1 } — the force && crossing === 'unverifiable' guard at lines 82-91 runs first. A forced update therefore returns orcad_update_daemon_protocol_unverifiable and its "Retry when the daemon answers" reason instead of this code, so the exact host this PR targets gets the wrong explanation (the unforced path is already correct). Move this block above that guard, and add a daemonProtocolVersion: null case to the new it.each.

Technical details
# Forced update names the wrong refusal for a degraded host

## Affected sites
- `src/main/ssh/orcad-update-plan.ts:115-117` — in-process guard sits after the force + `unverifiable` early return at `:82-91`.
- `src/main/ssh/orcad-update-plan.test.ts:89-118` — the new test only covers a daemon session on an `attachable` protocol, so it never exercises the forced/degraded branch.

## Evidence
- Verified with a throwaway test: `census: { liveSessions: 1, startedSinceActivation: null, daemonProtocolVersion: null, inProcessSessions: 1 }, force: true` returns `{ code: 'orcad_update_daemon_protocol_unverifiable', reason: 'The terminal daemon did not report its protocol … Retry when the daemon answers.' }`.

## Required outcome
- A forced update whose only live terminals run in-process returns `orcad_update_ends_in_process_terminals` with the restart-ends-them reason.

## Suggested approach
- Move the `inProcess > 0` block above the `if (input.force && crossing === 'unverifiable')` block (leaving the `strands-live-terminals` precedence unchanged).
- Add a force case using a census with `daemonProtocolVersion: null` and `inProcessSessions: 1`.

@OrcaWin
OrcaWin merged commit b8acb7f into OrcaWin/node-rt-phase3 Oct 5, 2026
63 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