Skip to content

fix(ssh): orcad GC honors the activation journal; readiness requires proven daemon coverage (#16741 T6) - #24451

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/node-rt-p3-t6-gaps
Oct 1, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/node-rt-p3-t6-gaps

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​148 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​141
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​100 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​93

ELI5

These are two safety fixes for managing the remote orcad server.

  • Cleanup no longer removes a version an update still needs. Orca deletes old server versions on a remote machine to save space. That cleanup now first checks whether an update, rollback or decommission is still in progress, and never removes a version that work still depends on. If Orca can't tell what's in progress, it skips cleanup entirely.
  • A server must prove its terminals actually work. When Orca checks whether a server is healthy, it now requires proof that the server's terminal helper (the daemon that runs terminals) really opened a test terminal, not only that it answered a ping.

Nothing calls this code in production yet, so users see no change.

What Changed

1. Cleanup reads the activation journal

New file: orcad-gc-transaction-pins.ts. gcOldOrcadVersions now does two things before removing anything:

  • Pins every version a pending transaction names. If T6-2's activation journal records an update, rollback or decommission in progress, cleanup keeps every version that journal names: the candidate, the incumbent, the target, and the active and previous versions on both sides.
  • Keeps everything when it can't tell. It skips the whole pass, including the node-runtime pass, when any of these is true:
    • the journal can't be read;
    • the read gets no answer;
    • the transaction lock is held but there's no journal yet.
  • Lost channel still fails the pass. A connection whose termination isn't confirmed throws, as it already did.
  • Snapshots are untouched. Pre-activation snapshots and rollback rescue copies live under orcad-state-snapshots/. Cleanup only ever lists orcad-<version> slot directories, so it never touches them; a test now covers this.

2. Readiness requires proven terminal coverage

orcad side. runTerminalDaemonSelfTest now calls checkDaemonHealthWithCoverage (#24409). So selfTest.coverage reports what the daemon says its probe actually did, instead of a guess based on the platform.

Client side. probeActiveOrcadReadiness and launchOrcadSlotAndAwaitReadiness (orcad-active-readiness.ts) now accept a slot only when one of these holds:

  • coverage is pty-spawn, meaning a real test terminal was created;
  • coverage is handshake and the host is win32, where the daemon never spawns a test terminal;
  • the build doesn't report coverage at all.

Builds that don't report coverage keep today's check (build hash plus version), so older slots aren't stranded. A handshake-only result on a POSIX host is rejected with the verdict rejected.

Why

  • Cleanup: a pending transaction may still restart or settle any slot its journal names. Deleting one of those slots would turn a recoverable interruption into a broken host. A journal that can't be read is treated as unknown, never as empty (docs/reference/ssh-execution-boundary.md).
  • Coverage: a daemon that only completes the connection handshake hasn't shown that a terminal can be created. Accepting it would mark a slot healthy when it can't run a single command.

Linked Issue

Part of the Node runtime plan (Phase 3), T6 exit-gate track (#16741). These close the T6-2 GC gap and the T6-1 readiness follow-up. Independent of #24449.

Visual Proof

N/A. There's no UI change and no production caller.

Testing

  • orcad-remote-gc.test.ts:

    • a pending activation journal pins its candidate and previous versions;
    • cleanup removes nothing (and never lists candidates) behind an unreadable journal, an unanswered read, or a lock held without a journal;
    • the snapshot directory is never a candidate.
  • orcad-remote-primitives.test.ts:

    • accepts pty-spawn, handshake on win32, and a build without the coverage field;
    • rejects handshake on Linux, for both probing an existing slot and launching a new one.
  • orcad-health.test.ts: the self-test reports the coverage the daemon returns.

  • Regression: every src/main/orcad and src/main/ssh test plus the import-boundary test.

    • 280 files: 269 passed, 11 skipped.
    • 3,574 tests passed, 54 skipped.
  • Static checks: node config/scripts/check-changed-code-quality.mjs origin/main passes. A tsc --noEmit run limited to the changed files is clean (the full typecheck was not run). oxlint is clean and pnpm-lock.yaml is unchanged.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

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

…proven daemon coverage (#16741 T6 follow-up)

GC pins every slot an in-flight activation journal names and skips the pass entirely when a journal is unreadable or a fence is held without one. orcad's self-test now reports the coverage the daemon says its probe achieved, and remote readiness probes accept a slot only on pty-spawn coverage, or handshake on win32; builds without the field keep the identity gate.
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Changes garbage collection and readiness checks for terminal daemon slots.

The GC concurrency gap should be resolved before this change is relied on for safe activation cleanup.

Findings

  1. P1 GC can delete a new candidate ▶

Summary

The PR pins versions named by an activation journal during Orcad GC and uses the daemon’s reported probe coverage when evaluating remote-slot readiness.

  • Unreadable transaction state now skips collection, including node-runtime cleanup.
  • POSIX readiness rejects a reported handshake-only terminal probe while retaining compatibility with builds that omit coverage.
  • The journal check remains vulnerable to a concurrent deployment starting after GC reads it.

Reviews (1) · Last reviewed commit: "fix(ssh): orcad GC honors the activation..."

}

export async function gcOldOrcadVersions(options: OrcadGcOptions): Promise<void> {
const transaction = await readOrcadGcTransactionPins(options)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 GC can delete a new candidate

If a deployment finishes installing a candidate after GC reads the journal but before the deployment writes its activation journal, GC will not pin that candidate. The completed install no longer holds its per-version lock, so GC can remove the idle-looking slot. The deployment then cannot launch the version it just installed. The journal read needs to remain coordinated with activation through deletion.

Knowledge Base Used: Remote connectivity and execution

@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 scope question inline, plus a stale doc reference.

Reviewed changes

  • orcad GC honors the activation journal — gcOldOrcadVersions now reads the activation journal and fence before the version pass; readOrcadGcTransactionPins pins every version an in-flight activate/rollback names, and returns keep-all (skipping the pass, including the node-runtime store pass) when the journal is unreadable, unanswered, or absent behind a held fence. Unconfirmed SSH termination still rethrows.
  • Readiness requires proven daemon coverage — runTerminalDaemonSelfTest now reports the daemon's own coverage via checkDaemonHealthWithCoverage, and gatedReadiness rejects a handshake-only result on a non-win32 host through the new orcadDaemonCoverageRefusal.
  • Tests — new GC transaction-pin cases, coverage accept/reject cases for probe and launch, and a daemon-reported coverage case. Verified locally: all 43 tests in the three changed test files pass.
Technical details
# Coverage gate is applied on the probe/launch path but not the activation-commit path

## Affected sites
- `src/main/ssh/orcad-active-readiness.ts:62` — `orcadDaemonCoverageRefusal`, applied in `gatedReadiness` (used by `probeActiveOrcadReadiness` / `launchOrcadSlotAndAwaitReadiness`).
- `src/main/ssh/orcad-installed-activation.ts:226` — calls `evaluateOrcadActivation` directly; no coverage refusal.
- `src/main/ssh/orcad-rollback-transition.ts:205` — same.
- `src/main/ssh/orcad-activation-gate.ts:140` — still only warns on `selfTest.coverage === 'handshake'`.

## Required outcome
- Same verdict for the same payload on both surfaces, or an explicit statement that the split is intentional.

## Open questions for the human
- On POSIX, a daemon that reports `handshake` is rejected by recovery but would still be activated by the install path. Is that split intentional (activation is owned by another task), or should `evaluateOrcadActivation` consult `orcadDaemonCoverageRefusal` too?

ℹ️ Stale function name in orcad-operations docs

docs/reference/orcad-operations.md:255 says the self-test "runs checkDaemonHealth against the daemon's socket". This PR switches runTerminalDaemonSelfTest to checkDaemonHealthWithCoverage, so the named function no longer matches. Worth updating while the coverage semantics are in hand.

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

Comment on lines +62 to +75
export function orcadDaemonCoverageRefusal(readiness: ServeReadiness): string | null {
const health = readiness.health
const coverage = health?.terminalDaemon?.selfTest?.coverage
if (!health || coverage === undefined || coverage === 'pty-spawn') {
return null
}
if (coverage === 'handshake' && health.platform === 'win32') {
return null
}
return (
`reported terminal-daemon coverage '${String(coverage)}', which does not prove a PTY can ` +
`be created on ${health.platform}.`
)
}

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.

This platform-aware refusal only runs on the probe/launch path. The gate that commits an activation, evaluateOrcadActivation (called from orcad-installed-activation.ts:226 and orcad-rollback-transition.ts:205), still treats selfTest.coverage === 'handshake' as a warning (orcad-activation-gate.ts:140), so a POSIX host reporting handshake is rejected by recovery but would still be activated on install.

Technical details
# Coverage gate not applied to the activation-commit path

## Affected sites
- src/main/ssh/orcad-active-readiness.ts:62 — new refusal, wired into `gatedReadiness` only
- src/main/ssh/orcad-activation-gate.ts:140 — handshake still warning-only
- src/main/ssh/orcad-installed-activation.ts:226, src/main/ssh/orcad-rollback-transition.ts:205 — call the gate directly

## Open questions for the human
- Is this split intentional (activation owned by another task), or should `evaluateOrcadActivation` consult `orcadDaemonCoverageRefusal` so both surfaces agree?

@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: d1887065-0e79-4d1d-ab01-c785b511fc1e

📥 Commits

Reviewing files that changed from the base of the PR and between 477e699 and 3d025ed.

📒 Files selected for processing (7)
  • src/main/orcad/orcad-health.test.ts
  • src/main/orcad/orcad-health.ts
  • src/main/ssh/orcad-active-readiness.ts
  • src/main/ssh/orcad-gc-transaction-pins.ts
  • src/main/ssh/orcad-remote-gc.test.ts
  • src/main/ssh/orcad-remote-gc.ts
  • src/main/ssh/orcad-remote-primitives.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The terminal daemon self-test now reports daemon-supplied health coverage, and readiness validation checks that coverage against the platform. Remote version GC now reads activation-transaction pins, combines them with existing pins, and skips the pass when transaction state cannot be resolved. Tests cover coverage handling, pending transactions, journal and fence states, and GC removal candidates.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 3d025

The changes strengthen daemon readiness checks and protect in-flight versions during cleanup. No concrete merge-blocking issue is established; mergeability remains subject to normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 3d025

The changes strengthen cleanup protection and readiness checks without a demonstrated new attacker-accessible boundary. However, activation and recovery apply different readiness policies, which could leave an interrupted operation requiring manual recovery. Actual deployment exposure remains unconfirmed.

Retained concerns

  • Medium · reliability · inferred: Initial activation and rollback can accept otherwise healthy POSIX handshake-only readiness through evaluateOrcadActivation, but recovery now rejects the same payload through the stricter readiness wrapper. If interruption occurs after a candidate-ready or target-ready journal is persisted, recovery can finish the record commit and then refuse readiness, retaining the fence for operator recovery. Windows handshake and missing-coverage compatibility are accepted, so the mismatch is conditional rather than universal. Runtime reachability of this case is not established.
Security review details

Security Blast Radius

  • observed — The examined sensitive outcomes are readiness acceptance and removal of version trees on the supplied SSH target. Deletion candidates remain constrained by install-model ownership, version-directory matching, pins, liveness checks, and an owned deletion claim. The reviewed change does not add authority to delete arbitrary journal-named paths.

Trust Boundaries and Controls

  • observed — Daemon coverage is consumed through the existing local control connection using the daemon token. The health client requests the PTY-health RPC and combines its success verdict with parsed coverage. This change reuses that boundary rather than introducing a new unauthenticated source of readiness authority.

Resilience and Maintainability Implications

  • observed — An absent journal with a held fence causes GC to preserve everything. Fence release removes the journal before the lock, so interrupted release leaves a conservative state. Recovery exceptions retain the fence instead of declaring unresolved ownership safe.

Hardening Proposals

  • proposed — Use one platform-aware readiness policy before initial activation or rollback commit and during recovery, preserving intentional legacy compatibility. This would prevent a state from being accepted for commit but rejected solely by a different recovery policy.
  • proposed — Before enabling concurrent cleanup and activation scheduling, establish shared coordination covering transaction start through destructive deletion. A second journal read alone would not eliminate the start-after-read race.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes both primary changes: activation-journal-aware orcad garbage collection and daemon-coverage-based readiness.
Description check ✅ Passed The description is detailed and covers the required purpose, changes, rationale, linked issue context, visual proof, testing, compatibility, and checklist items. It omits the template's separate Revie…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@OrcaWin
OrcaWin merged commit d3f8c50 into main Oct 1, 2026
59 checks passed
OrcaWin added a commit that referenced this pull request Oct 2, 2026
* Revert "feat(orcad): source-side dormant export of a relay-hosted SSH target (#16741 T6-8) (#24519)"

This reverts commit 783101b.

* Revert "feat(ssh): update, roll back, recover and stop a managed orcad server (#16741 T6-5 follow-up) (#24463)"

This reverts commit 38c2d1d.

* Revert "feat(ssh): deploy and pair an empty managed orcad server over SSH (#16741 T6-5) (#24453)"

This reverts commit 8b76683.

* Revert "fix(ssh): orcad GC honors the activation journal; readiness requires proven daemon coverage (#16741 T6 follow-up) (#24451)"

This reverts commit d3f8c50.

* Revert "feat(ssh): remote orcad stop by request file and journaled decommission (#16741 T6-4) (#24449)"

This reverts commit 43d9b43.

* Revert "feat(orcad): supervisable server: stop requests, managed stop receipts and a lifetime that keeps its lock on failed teardown (#16741 T6-3) (#24433)"

This reverts commit b093d3a.

* Revert "feat(ssh): crash-safe orcad activation, rollback and recovery (#16741 T6-2) (#24423)"

This reverts commit 1a9ac0e.

* Revert "feat(runtime): SSH access links for paired servers in a downgrade-safe sidecar (#16741 T5-1+T5-2) (#24420)"

This reverts commit 99db2bf.

* Revert "feat(relay): capability-gated owner reset with a durable preparation journal (#16741 T3 R1) (#24418)"

This reverts commit 34a582b.

* Revert "feat(ssh): track connection-manager drains, test probes and provider continuations (#16741 T2 P3+P8a) (#24407)"

This reverts commit d53063d.

* Revert "feat(daemon): idle retirement, session census and recovery-only provider (#16741 T2 P4b) (#24409)"

This reverts commit ff212db.

* Revert "feat(ssh): add pty.resumeClient and split SSH PTY process listing (#16741 T2 P5+P6) (#24414)"

This reverts commit 92cb717.

* Revert "feat(relay): await owned watcher and agent children on shutdown (#16741 T2 P1) (#24400)"

This reverts commit 6b36e4f.

* Revert "feat(session): retry failed renderer session writes and verify local folder PTYs (#16741 T2 P9) (#24406)"

This reverts commit d23ecef.

* Revert "feat(ssh): remote orcad primitives on the pinned Node runtime (#16741 T6-1) (#24419)"

This reverts commit dd87ae5.

* Revert "fix(runtime): fence runtime-environment subscriptions and status probes by identity (#16741 T5-3) (#24421)"

This reverts commit ece9e4d.

* Revert "feat(orcad): migration manifest and dormant-state contracts (#16741 T6-7) (#24422)"

This reverts commit 3fbdaba.

* Revert "feat(ssh): wire SshConnection through the work and transport close ledgers (#16741 T2 P2) (#24401)"

This reverts commit 4e8edc8.

* Revert "feat(profiles): carry markdown frontmatter visibility in project transfers (#16741 T2 P7) (#24405)"

This reverts commit 60c9326.

* Revert "fix(runtime): project the PTY incarnation onto mobile session tabs (#24413)"

This reverts commit 99e0303.

* Revert "feat(daemon): tag daemon stream data with the PTY incarnation id (#16741 T2 P4a) (#24402)"

This reverts commit 817af76.

* Revert "feat(ssh): port the SSH connection work ledger and transport close ledger (#16741 T2) (#24210)"

This reverts commit c991893.

* Revert "feat(relay): fence and drain file and git response streams on shutdown (#24185)"

This reverts commit dc08ffe.

* Revert "refactor(runtime-rpc): extract the Node WebSocket lifecycle; opt-in pinned port (#24186)"

This reverts commit a789233.

* Revert "feat(relay): route relay handlers through work admission; producer publication drain (#24181)"

This reverts commit 0b812bd.

* Revert "feat(relay): land the #16741 T1 seam (work drain, publication drain, release gate) (#24156)"

This reverts commit 3aa2d3a.

---------

Co-authored-by: m4air <[email protected]>
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