Skip to content

fix(relay): preserve PTY streaming and shutdown test invariants - #17737

Closed
brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/r2-build
Closed

brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/r2-build

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178
Prod 35 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1159 $\color{#cf222e}{\Huge{\mathbf{−}}}$​165 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​994

Summary

  • Scope the live identity-evidence backstop to clients that have reported visible PTYs, and to an active PTY pool. This removes an always-running interval from relay instances that have no visible identity consumers while preserving stale-visible reconciliation.
  • Add a stale replay-isolation regression test proving replay bytes never feed the live identity boundary scanner.

Tests

  • pnpm vitest run --config config/vitest.config.ts src/relay/ src/main/ssh/ — 277 files passed, 3,327 passed, 18 skipped.
  • pnpm typecheck — passed (silent success).
  • pnpm run check:code-quality:changed — passed (0 new native/type-aware/React Doctor findings).
  • git diff --check and oxfmt --check — passed.
  • Red/green proof (backstop): reverse patch restored the unconditional setInterval in wireAndStore; pty-handler-dispose-lifecycle.test.ts -t "takes ownership when dispose overlaps" failed (timerCount 2 vs expected 1). Restored the scoped timer; focused lifecycle/shutdown/output tests passed.
  • Red/green proof (replay isolation): temporary reverse patch fed replay into the live scanner; pty-handler-attach-replay.test.ts -t "keeps stale replay bytes" failed (2 process-table reads vs expected 1). Restored path separation; the stale replay test passed.
  • Live Electron smoke: launched this worktree on CDP 9333, verified window.api.app.getIdentity() reported branch brennanb2025/r2-build and root /Users/brennanbenson/orca/workspaces/orca/r2-build, registered the disposable remote demo repo, connected to the throwaway Linux SSH target, spawned a remote PTY, and observed R2_LIVE, /work/demo-project, and clean remote git status output.
  • Live SSH/relay smoke: throwaway Ubuntu 22.04 Docker target (not localhost SSH) with Node 20, OpenSSH, and a local demo-project bundle; relay deployed and remote PTY output/OSC boundaries were delivered. Remote proof: /work/demo-project remained ## main...origin/main with one worktree and no test artifacts.
  • pnpm run lint — known baseline failure: existing warnings (including import-cycle/duplicate-import findings) are denied; additionally src/main/runtime/rpc/dispatcher.ts reports eslint max-lines 302/300 on origin/main itself. Static-analysis/verify red status is unrelated to this fix; no max-lines disable was added.

Reliability notes

  • Invariant: live PTY output and identity evidence remain provider-owned, and replay bytes cannot create live identity evidence (terminal-session.provider-ownership / replay isolation).
  • Oracle: focused output/lifecycle tests, the stale replay scanner-count test, full relay+SSH suites, and the live remote PTY smoke above.
  • The scheduler-path test is intentionally stale before attach; its result proves the structural path separation under freshness-dedup conditions. Backstop polling is active only after visibility has been reported for an active PTY, and is cleared when the last visible client detaches or the PTY pool empties.
  • Local/daemon/SSH Linux paths were covered by tests and the live smoke. WSL, Windows/ConPTY, macOS remote targets, mobile relay, and packaged production artifacts were not exercised here and remain accepted gaps for this test-only change.

Readiness follow-up (2026-09-01)

  • Fix pushed in f691dfae7f: held identity rows are reseeded in epoch-consistent batches; boundary-triggered reads snapshot pending IDs; process-table reads require an active client with the negotiated identityEvidence capability; V1 identity capability negotiation now intersects client and host offers. Duplicate imports were consolidated and the SSH notification routing helpers were split (267 lines; no max-lines change).
  • Tests: pnpm tc; changed-code quality; full relay/SSH suites (280 files, 3,358 passed, 18 skipped); focused replay/capability tests (49 passed). Reverse red proofs were recorded: reverting epoch/read fixes makes the mixed-held-epoch test fail (one publication instead of two), and reverting capability intersection makes the no-V1 test fail (an identity grant is emitted).
  • Remaining security/readiness blocker: this PR has no pane/PTY nonce protocol for OSC 133/777. createPtyIdentityBoundaryScanner accepts forged or absent-nonce marker-shaped bytes, and the required forged-marker test cannot be satisfied without introducing a new wire/shell contract. Real Linux SSH Electron smoke also produced no pty.identityEvidence notification after a visible PTY and live OSC 133 input, so the end-to-end push path remains unproven.

Platform matrix

Surface Evidence / result
macOS local Exact target worktree launched via Electron CDP; renderer identity and branch/root verified; local typecheck/build/tests pass.
Linux local-or-SSH Relay built locally and on the real Linux SSH host (ssh:ssh-1785104650217-eduhep, neil-ubuntu, bash); remote PTY and OSC bytes observed.
Windows native (PowerShell and Git Bash) Not applicable to this PR's SSH relay path; no Windows host changes, and no native Windows session was used for the SSH evidence producer.
WSL Not applicable to this PR's SSH-only relay producer; no WSL source path changed.
SSH remote pane Real host/repo/worktree created and connected; live PTY output and OSC 133 bytes observed, but no pty.identityEvidence IPC event was observed.
daemon-backed pane No daemon code path changed; covered by existing relay/daemon tests only.
reattach/reconnect Replay isolation test proves replay bytes do not trigger a second process-table read; mixed held-epoch reseed test passes. Physical reconnect push remains unproven due missing live event.
mixed old-client/new-host Capability tests cover old/no-V1 offers and symmetric V1 intersection; no physical old-client binary was available.

Readiness: DO NOT LAND until the nonce/trust contract and real SSH identity-evidence push are fixed and demonstrated.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR adds provider-owned SSH PTY identity-evidence propagation while separating replay from live boundary scanning and scoping reconciliation polling to visible PTYs.

  • Adds negotiated identity-evidence capabilities and relay-to-renderer routing.
  • Tracks visible PTYs and performs bounded, backoff-aware process reconciliation.
  • Adds lifecycle and replay-isolation coverage.

Confidence Score: 4/5

The PR is not yet safe to merge because retained identity evidence can still be emitted as an internally inconsistent batch that the receiving provider discards.

Retained rows survive across observation epochs, but the relay publishes them under one maximum epoch while the main-side parser requires every row to match that envelope, so visibility or attach seeding can be dropped until a later live scan.

Files Needing Attention: src/relay/pty-handler.ts, src/main/providers/ssh-pty-identity-notification.ts

Important Files Changed

Filename Overview
src/relay/pty-handler.ts Adds live identity scanning, retained evidence, visibility-scoped reconciliation, and shutdown cleanup.
src/main/providers/ssh-pty-identity-notification.ts Adds strict validation and application-ID mapping for relay identity-evidence notifications.
src/main/providers/ssh-pty-notification-routing.ts Routes validated identity notifications while enforcing authority-generation and epoch monotonicity.
src/main/providers/ssh-pty-identity-visibility.ts Adds debounced, connection-filtered publication of the renderer-visible PTY set.
src/shared/pty-identity-evidence.ts Defines shared identity-evidence validation and live PTY boundary-scanning behavior.

Sequence Diagram

sequenceDiagram
  participant PTY as Remote PTY
  participant Relay as Relay handler
  participant Main as SSH provider
  participant Renderer as Terminal renderer
  PTY->>Relay: Live output bytes
  Relay->>Relay: Scan live identity boundaries
  Relay->>Relay: Read process table and retain evidence
  Relay-->>Main: pty.identityEvidence
  Main->>Main: Validate generation and observation epoch
  Main-->>Renderer: Validated identity evidence
  Note over PTY,Renderer: Replay follows a separate path and never feeds the live scanner
Loading

Reviews (2): Last reviewed commit: "fix(renderer): avoid replay SSH resume o..." | Re-trigger Greptile

Comment thread src/relay/pty-handler.ts Outdated
Comment on lines +2515 to +2519
const epoch = Math.max(...rows.map((row) => row.foregroundProcessEvidence.observationEpoch))
this.dispatcher.publishProducerNotification(clientId, 'pty.identityEvidence', {
authorityGeneration: this.ptyIdMintEpoch,
observationEpoch: epoch,
rows

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 Held batches mix observation epochs

When separate identity reads leave rows from different observations in the retained map, this code publishes them under the maximum epoch. The main-process parser requires every row to match the envelope epoch and therefore rejects the entire batch, leaving affected panes without the intended identity seed until another live scan succeeds.

Knowledge Base Used: Relay protocol and transport

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

Important

Two issues in the identity-evidence reseed and read-gating paths should be addressed before merge — one that silently drops reconnect seeds, one that undercuts the scoping this PR aims to achieve.

Reviewed changes

  • Relay identity-evidence producer — PtyHandler gains a live OSC 133/777 boundary scanner, a bounded held-evidence cache, per-client visibility tracking, and pty.identityEvidence publication fed by ps -axo process-table reads, gated behind a new identityEvidence v1 capability on the consumer-session hello/grant.
  • Main-process provider threading — SshPtyProvider/SshPtyProviderOutputState parse and re-route pty.identityEvidence notifications, and ssh-relay-session.ts flips the SSH gate to negotiate the capability and forward evidence over pty:identityEvidence IPC.
  • Renderer consumption — a new evidence store (pty-identity-evidence-store.ts) plus pane-ssh-identity-evidence.ts apply live evidence to setPaneForegroundAgent, with generation/epoch fencing against reconnect and stale rows.
  • Visibility-scoped backstop — resize-visibility.ts pushes the visible pane set to the relay via a debounced pty.identityEvidence.setVisibility request; the 30s reconcile interval now only runs for clients that reported visible PTYs in a non-empty pool.
  • Replay isolation test — a regression test proves retained replay bytes (replayed on attach) never feed the live boundary scanner.

ℹ️ Nitpicks

  • Held rows are re-published with capturedAgeMs: 0, so the renderer rebases receivedAtMs = now() and treats up-to-30s-old evidence as freshly received for the full freshnessMs window. Rebasing capturedAgeMs to include the time the row has been held would make the documented age rebasing honest.
  • identityEvidenceBackoffByPty is only deleted on a live verdict or in dispose() — never on PTY exit — so a long-lived relay accumulates one entry per exited PTY that ever received a non-live verdict.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog

pullfrog Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Two findings from the review, tied to specific lines (the [!IMPORTANT] callout above references these; GitHub anchored-comment delivery was unavailable for this run, so the details are inline here):

⚠️ Held reseed publishes inconsistent epochs and gets dropped wholesale

PtyHandler.publishHeldIdentityEvidenceToClient (src/relay/pty-handler.ts:2515) stamps the notification with observationEpoch = Math.max(...rows.map(r => r.foregroundProcessEvidence.observationEpoch)), but each row keeps the epoch from the individual read that captured it. Boundary-triggered reads only refresh the PTY that emitted the marker (scheduleIdentityEvidenceRead(managed.id) → the requestedIds filter in publishIdentityEvidence), so held rows for multiple visible PTYs routinely carry different epochs.

parseSshIdentityEvidenceNotification (src/main/providers/ssh-pty-identity-notification.ts:44) then rejects the entire batch when any row's evidence.observationEpoch !== observationEpoch. Consequence: in the common multi-pane case, the reconnect seed is silently dropped on the client, and the renderer never receives the held rows it was meant to seed from. The live path is unaffected (each live read produces internally consistent rows), but a reconnecting pane then falls through to the 30s backstop rather than being seeded immediately.

The minimum fix is to make the batch internally consistent before publishing — e.g. re-stamp each row's foregroundProcessEvidence.observationEpoch to the notification epoch — or relax the parser to validate authorityGeneration + notification-level monotonicity without requiring per-row epoch equality.

⚠️ Identity reads are gated on connection, not visibility/capability

PtyHandler.publishIdentityEvidence gates only on hasConnectedClients() (src/relay/pty-handler.ts:2593), not on any client having negotiated identityEvidence or reported visible PTYs. Combined with wireAndStore scheduling a read on every spawn (:878) and the boundary scanner scheduling one on every live prompt, a relay serving only legacy (non-negotiating) clients — or a client whose panes are all hidden — still forks ps -axo per prompt boundary, doing work the admission gate then discards for everyone.

This is the same per-connection cost the backstop scoping was intended to remove, just relocated to a different trigger. Suggest gating the read on identityEvidenceVisibleByClient.size > 0 (or on any active client holding the identityEvidence grant) before invoking getStrictProcessTableSnapshot().

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: ff50559e-446e-4549-aeee-fac38ba30084

📥 Commits

Reviewing files that changed from the base of the PR and between 5d09764 and f691dfa.

📒 Files selected for processing (7)
  • src/main/providers/ssh-pty-notification-rejection.ts
  • src/main/providers/ssh-pty-notification-routing.ts
  • src/relay/dispatcher-notification-publication.ts
  • src/relay/pty-handler-attach-replay.test.ts
  • src/relay/pty-handler.ts
  • src/shared/pty-consumer-session-capabilities.ts
  • src/shared/pty-consumer-session.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/relay/dispatcher-notification-publication.ts

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


📝 Walkthrough

Walkthrough

The change adds versioned SSH PTY identity-evidence negotiation and recovery. The relay scans PTY output, resolves foreground-process evidence, retains bounded results, and publishes them according to client visibility and admission. Main-process providers parse and route notifications through IPC. The renderer tracks PTY incarnations, filters evidence by generation and epoch, stores evidence, and updates pane identity state. Eager PTY buffering moves into a dedicated renderer module.

Merge Risk: 🟡 Moderate · up to f691d

This change adds live PTY identity evidence, but marker-shaped terminal output is not authenticated, visibility can broaden before a client reports its scope, stale evidence can race with terminal shutdown, and the real SSH smoke did not receive the expected identity notification. The PR is not merge-ready until the nonce/trust contract and live delivery path are fixed and demonstrated.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.12% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 42 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides detailed scope, testing, platform coverage, and readiness information. However, it omits required template sections, including a linked issue, visual proof or an explicit N/A … Add the required template sections and provide a real linked issue. Add visual proof or state N/A with a reason if no visual or interaction change exists. Complete the testing and checklist sections. Resolve and demonstrate the stated nonce…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title describes real changes related to PTY streaming and shutdown invariants, but it does not identify the primary identity-evidence backstop and replay-isolation work. It is still sufficiently r…
Full details: Title check

Explanation

The title describes real changes related to PTY streaming and shutdown invariants, but it does not identify the primary identity-evidence backstop and replay-isolation work. It is still sufficiently related to pass as a partial summary.

Full details: Description check

Explanation

The description provides detailed scope, testing, platform coverage, and readiness information. However, it omits required template sections, including a linked issue, visual proof or an explicit N/A statement, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the checklist. It also states that the PR must not land because nonce/trust and end-to-end SSH push issues remain unresolved.

Resolution

Add the required template sections and provide a real linked issue. Add visual proof or state N/A with a reason if no visual or interaction change exists. Complete the testing and checklist sections. Resolve and demonstrate the stated nonce/trust and real SSH identity-evidence push blockers before requesting merge.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch brennanb2025/r2-build

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: 8

🧹 Nitpick comments (2)
src/shared/pty-consumer-session-capabilities.ts (1)

48-48: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Also intersect the client's offered identity-evidence versions.

The output-flow-control branch requires offer.versions.includes(1). The identity branch checks only the server support set. A hello that offers identityEvidence: { versions: [2] } therefore receives a version: 1 grant it never offered. Client-side validateGrant rejects only an unoffered capability, not a mis-versioned one, so the mismatch would survive to the client.

Both peers ship version [1] today, so no current failure exists. Make the intersection symmetric so a future version 2 cannot be silently downgraded.

♻️ Proposed fix
-  const identitySupported = Boolean(identityOffer && identitySupport?.versions.includes(1))
+  const identitySupported = Boolean(
+    identityOffer && identityOffer.versions.includes(1) && identitySupport?.versions.includes(1)
+  )
src/renderer/src/components/terminal-pane/pty-eager-dispatch.ts (1)

9-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

New import cycle between the dispatcher and the extracted eager-buffer module. pty-eager-dispatch.ts imports ensurePtyDispatcher from pty-dispatcher.ts, and pty-dispatcher.ts imports the eager-buffer functions back. Both sides cross the cycle only through hoisted function declarations, so module evaluation still succeeds, but static analysis reports import(no-cycle) on both edges and the coupling blocks further extraction.

Break the cycle by moving ensurePtyDispatcher (or the attach state it guards) into a separate module that both files import.

  • src/renderer/src/components/terminal-pane/pty-eager-dispatch.ts#L9-L9: import ensurePtyDispatcher from the new shared module instead of ./pty-dispatcher.
  • src/renderer/src/components/terminal-pane/pty-dispatcher.ts#L36-L36: keep the eager-buffer import and re-export ensurePtyDispatcher from the new shared module for existing callers.

Source: Linters/SAST tools


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: cdafa82d-0e0c-4cff-96a5-ca89b4020a50

📥 Commits

Reviewing files that changed from the base of the PR and between 02a7742 and c819af2.

📒 Files selected for processing (40)
  • src/main/ipc/pty/ipc/resize-visibility.ts
  • src/main/providers/pty-provider-contract.ts
  • src/main/providers/ssh-pty-identity-notification.ts
  • src/main/providers/ssh-pty-identity-visibility.ts
  • src/main/providers/ssh-pty-notification-routing.identity.test.ts
  • src/main/providers/ssh-pty-notification-routing.ts
  • src/main/providers/ssh-pty-provider-contract.ts
  • src/main/providers/ssh-pty-provider-output-state.ts
  • src/main/providers/ssh-pty-provider.ts
  • src/main/ssh/ssh-pty-consumer-recovery.ts
  • src/main/ssh/ssh-pty-consumer-session.test.ts
  • src/main/ssh/ssh-pty-consumer-session.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/preload/api/pty-api.ts
  • src/preload/index.ts
  • src/relay/dispatcher-capacity-signals.ts
  • src/relay/dispatcher-contract.ts
  • src/relay/dispatcher-notification-publication.ts
  • src/relay/dispatcher.ts
  • src/relay/pty-handler-attach-replay.test.ts
  • src/relay/pty-handler.ts
  • src/relay/ssh-pty-consumer-session-adapter.ts
  • src/renderer/src/components/terminal-pane/ipc-pty-connect.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-ssh-identity-evidence.ts
  • src/renderer/src/components/terminal-pane/pty-connection/transport-output-callbacks.ts
  • src/renderer/src/components/terminal-pane/pty-dispatcher.ts
  • src/renderer/src/components/terminal-pane/pty-eager-dispatch.ts
  • src/renderer/src/components/terminal-pane/pty-identity-evidence-dispatch.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/lib/pty-identity-evidence-store.test.ts
  • src/renderer/src/lib/pty-identity-evidence-store.ts
  • src/shared/pty-consumer-session-capabilities.ts
  • src/shared/pty-consumer-session-contract.ts
  • src/shared/pty-consumer-session-hello.ts
  • src/shared/pty-consumer-session.ts
  • src/shared/pty-identity-evidence.test.ts
  • src/shared/pty-identity-evidence.ts
  • src/shared/ssh-types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

Comment on lines +101 to +104
const grantedIdentity = grant.capabilities?.identityEvidence
if (!options.identityEvidence && grantedIdentity) {
throw new Error('Remote relay granted an unoffered PTY identity-evidence capability')
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- repository knowledge scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort
printf '%s\n' '--- knowledge headers ---'
head -5 /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md 2>/dev/null || true
printf '%s\n' '--- target file outline ---'
ast-grep outline src/main/ssh/ssh-pty-consumer-session.ts
printf '%s\n' '--- target implementation ---'
cat -n src/main/ssh/ssh-pty-consumer-session.ts | sed -n '1,190p'
printf '%s\n' '--- related symbols ---'
rg -n -S 'identityEvidence|openSshPtyConsumerSession|pty\.openClient|validateGrant' src/main src/test test tests 2>/dev/null | head -240

Repository: stablyai/orca

Length of output: 28248


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- SSH learning ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-main-ssh.md
printf '%s\n' '--- shared session definitions ---'
fd -i 'pty-consumer-session' src
for f in $(fd -i 'pty-consumer-session' src); do
  printf '\n--- %s ---\n' "$f"
  ast-grep outline "$f"
  cat -n "$f" | sed -n '1,240p'
done
printf '%s\n' '--- consumer session tests ---'
cat -n src/main/ssh/ssh-pty-consumer-session.test.ts | sed -n '1,240p'
printf '%s\n' '--- grant producers ---'
rg -n -S -C 12 'identityEvidence.*version|identityEvidence:|capabilities:' src/main src/relay src/shared | head -320

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- forwarding branch ---'
cat -n src/main/ssh/ssh-relay-session.ts | sed -n '1140,1210p;1755,1800p'
printf '%s\n' '--- recovery state flow ---'
cat -n src/main/ssh/ssh-pty-consumer-recovery.ts | sed -n '1,115p'
printf '%s\n' '--- identity capability references in main SSH ---'
rg -n -C 6 'identityEvidence' src/main/ssh --glob '*.ts'

Repository: stablyai/orca

Length of output: 22137


Validate the granted identity-evidence version.

When identityEvidence is present, reject it unless grantedIdentity.version === 1. The current code copies a version-2 object into owner state and treats it as enabled because downstream checks only truthiness. Add a test for a version-2 grant.

Comment thread src/relay/pty-handler.ts
Comment on lines +967 to +968
this.identityEvidenceScanners.delete(managed.id)
this.evictIdentityEvidence(managed.id, managed.incarnationId)

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Mirror this cleanup in reapExitedPty.

onExit deletes the scanner and evicts held evidence. reapExitedPty is the second retirement route (attach probe, listing probe, post-shutdown sweep) and it does not run either step. Its own comment states it exists for a shell that exits without a node-pty onExit, so that route is reachable.

identityEvidenceHeld is bounded by TTL and row/byte caps, but identityEvidenceScanners and identityEvidenceBackoffByPty have no bound. PTY ids increment monotonically, so both maps grow for the life of the relay daemon once PTYs are retired through the reap path.

🔒️ Proposed fix in `reapExitedPty`
   private reapExitedPty(managed: ManagedPty): void {
     managed.physicalExit?.markExited()
     this.releaseRelayIngress(managed)
     this.flushPtyOutput(managed.id)
+    this.identityEvidenceScanners.delete(managed.id)
+    this.identityEvidenceBackoffByPty.delete(managed.id)
+    this.evictIdentityEvidence(managed.id, managed.incarnationId)
     this.notifyExitListener(managed)

onExit also leaves identityEvidenceBackoffByPty populated; add the same delete there.

Comment thread src/relay/pty-handler.ts
Comment on lines +2484 to +2489
const row = this.identityEvidenceHeld.get(oldest)
this.identityEvidenceHeld.delete(oldest)
if (row) {
this.identityEvidenceHeldBytes -= this.identityEvidenceRowBytes(row)
}
}

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Delete the identityEvidenceHeldAt entry in the bounded-eviction branch.

The TTL branch above deletes from identityEvidenceHeld and identityEvidenceHeldAt. This cap-eviction branch deletes only from identityEvidenceHeld. Every row evicted by the row or byte cap leaves its timestamp in identityEvidenceHeldAt until dispose.

The map is keyed by id\0incarnationId, so a re-store overwrites the stale entry and reads stay correct. The effect is unbounded map growth on a relay that repeatedly reaches the cap.

🔒️ Proposed fix
       const row = this.identityEvidenceHeld.get(oldest)
       this.identityEvidenceHeld.delete(oldest)
+      this.identityEvidenceHeldAt.delete(oldest)
       if (row) {
         this.identityEvidenceHeldBytes -= this.identityEvidenceRowBytes(row)
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const row = this.identityEvidenceHeld.get(oldest)
this.identityEvidenceHeld.delete(oldest)
if (row) {
this.identityEvidenceHeldBytes -= this.identityEvidenceRowBytes(row)
}
}
const row = this.identityEvidenceHeld.get(oldest)
this.identityEvidenceHeld.delete(oldest)
this.identityEvidenceHeldAt.delete(oldest)
if (row) {
this.identityEvidenceHeldBytes -= this.identityEvidenceRowBytes(row)
}
}

Comment thread src/relay/pty-handler.ts Resolved
Comment thread src/relay/pty-handler.ts
Comment on lines +2709 to +2716
if (hasCompleteHeldEvidence) {
evidenceResults = heldEvidence.map((row) => {
const evidence = row!.foregroundProcessEvidence
return evidence.verdict === 'live'
? { available: true, processName: evidence.processName }
: { available: false, processName: null, reason: evidence.reason }
})
} else if (process.platform !== 'win32' && managedEntries.length > 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.

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Description: Confirm every reader of `evidenceRows` in listProcesses, so the fast-path assignment is safe.
set -euo pipefail
rg -n -C4 '\bevidenceRows\b' src/relay/pty-handler.ts

Repository: stablyai/orca

Length of output: 1965


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- applicable repository guidance ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print

printf '%s\n' '--- listProcesses fast path and title selection ---'
sed -n '2678,2750p' src/relay/pty-handler.ts

printf '%s\n' '--- complete evidenceRows references ---'
rg -n -C3 '\bevidenceRows\b' src/relay/pty-handler.ts

Repository: stablyai/orca

Length of output: 8107


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- relay learnings ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-relay.md

printf '%s\n' '--- held evidence writers and listProcesses continuation ---'
rg -n -C5 'identityEvidenceHeld|hasCompleteHeldEvidence|foregroundProcessEvidence' src/relay/pty-handler.ts
sed -n '2734,2785p' src/relay/pty-handler.ts

Repository: stablyai/orca

Length of output: 13180


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '2518,2662p' src/relay/pty-handler.ts

Repository: stablyai/orca

Length of output: 4976


Use held evidence for title on the complete-evidence POSIX path.

When hasCompleteHeldEvidence is true, evidenceRows remains null, so listProcesses calls getForegroundProcessName for each PTY. This restores sequential per-PTY probes and can make title disagree with the held foregroundProcessEvidence. Use a truthy sentinel only on POSIX, or select evidenceResults directly while preserving the Windows fallback.

Comment on lines +137 to +138
if (isDirectSshPtyId(id)) {
session.bindIdentityEvidence?.(id)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Description: Trace identity-evidence binding call sites and incarnation-id consumers.
set -euo pipefail

rg -nP -C4 '\bbindIdentityEvidence\b' --type=ts
rg -nP -C3 '\bgetPtyIncarnationId\b' --type=ts
rg -nP -C4 '\bisTrackablePtyId\b' --type=ts

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- repository knowledge scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort

printf '%s\n' '--- target file outline ---'
ast-grep outline src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts

printf '%s\n' '--- target file relevant sections ---'
rg -n -C8 'bindIdentityEvidence|isForegroundTrackingAllowed|isTrackablePtyId|setPaneForegroundAgent|incarnationId|bindPaneSshIdentityEvidence|getPtyIncarnationId' src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts

printf '%s\n' '--- direct symbol definitions and uses ---'
rg -n -C5 'bindPaneSshIdentityEvidence|bindIdentityEvidence|getPtyIncarnationId|isTrackablePtyId' src/renderer/src --glob '*.ts' --glob '*.tsx'

Repository: stablyai/orca

Length of output: 276


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- repository knowledge scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print 2>/dev/null | sort

printf '%s\n' '--- applicable convention and architecture headers ---'
for f in $(find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' 2>/dev/null | sort); do
  printf '\n--- %s ---\n' "$f"
  head -5 "$f"
done

printf '%s\n' '--- target file outline ---'
ast-grep outline src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts 2>&1

printf '%s\n' '--- target file relevant sections ---'
rg -n -C8 'bindIdentityEvidence|isForegroundTrackingAllowed|isTrackablePtyId|setPaneForegroundAgent|incarnationId|bindPaneSshIdentityEvidence|getPtyIncarnationId' src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts 2>&1

printf '%s\n' '--- direct symbol definitions and uses ---'
rg -n -C5 'bindPaneSshIdentityEvidence|bindIdentityEvidence|getPtyIncarnationId|isTrackablePtyId' src/renderer/src --glob '*.ts' --glob '*.tsx' 2>&1

Repository: stablyai/orca

Length of output: 36718


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- applicable terminal-pane learning ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-renderer-src-components-terminal-pane.md

printf '%s\n' '--- SSH identity evidence implementation ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/pane-ssh-identity-evidence.ts | sed -n '1,240p'

printf '%s\n' '--- foreground tracker implementation ---'
cat -n src/renderer/src/components/terminal-pane/pane-foreground-agent-tracker.ts | sed -n '1,280p'

printf '%s\n' '--- session contract around identity and transport ---'
rg -n -C12 'bindIdentityEvidence|disposeIdentityEvidence|isForegroundTrackingAllowed|transport:' src/renderer/src/components/terminal-pane/pty-connection/connect-pane-pty-session.ts src/renderer/src/components/terminal-pane/pty-transport-types.ts

Repository: stablyai/orca

Length of output: 19092


Pass the PTY incarnation ID when rebinding identity evidence. The tracker invokes session.isForegroundTrackingAllowed during visible-pane and command-start checks. This callback rebinds identity evidence without an incarnation ID, bypassing the relay incarnation fence and allowing evidence from a recycled PTY ID to update the pane. Pass session.transport.getPtyIncarnationId?.() ?? undefined.

Comment on lines +42 to +45
session.bindIdentityEvidence?.(
ptyId,
session.transport.getPtyIncarnationId?.() ?? undefined
)

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 4 'bindIdentityEvidence|bindPaneSshIdentityEvidence|registerPtyIdentityEvidenceHandler|disposed' \
  src/renderer/src/components/terminal-pane

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print

printf '%s\n' '--- callback and binder ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/transport-output-callbacks.ts | sed -n '1,75p'
cat -n src/renderer/src/components/terminal-pane/pty-connection/pane-ssh-identity-evidence.ts | sed -n '1,150p'

printf '%s\n' '--- session contract and disposal ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/connect-pane-pty-session.ts | sed -n '1,220p'
cat -n src/renderer/src/components/terminal-pane/pty-connection/session-reconcile-dispose.ts | sed -n '165,320p'

Repository: stablyai/orca

Length of output: 19205


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- relevant repository conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/repo-wide.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-renderer-src-components-terminal-pane.md

printf '%s\n' '--- binding assignment and all disposer references ---'
rg -n -C 5 'bindPaneSshIdentityEvidence|bindIdentityEvidence|registerPtyIdentityEvidenceHandler|unregisterPtyIdentityEvidence|ptyIdentityEvidence' \
  src/renderer/src/components/terminal-pane/pty-connection \
  src/renderer/src/components/terminal-pane/pty-dispatcher.ts

printf '%s\n' '--- dispatcher implementation ---'
cat -n src/renderer/src/components/terminal-pane/pty-dispatcher.ts | sed -n '1,240p'

Repository: stablyai/orca

Length of output: 27833


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- pane identity installer ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.ts | sed -n '18,48p'

printf '%s\n' '--- identity dispatcher ---'
cat -n src/renderer/src/components/terminal-pane/pty-identity-evidence-dispatch.ts | sed -n '1,220p'

printf '%s\n' '--- identity disposer usage across the repository ---'
rg -n -C 3 'disposeIdentityEvidence' src

Repository: stablyai/orca

Length of output: 4884


Dispose the identity-evidence handler when the session is disposed.

session.bindIdentityEvidence stores the disposer in session.disposeIdentityEvidence, but session.dispose() does not call it. If the PTY remains alive after pane teardown, the retained callback can update stale pane state through setPaneForegroundAgent. Call and clear the disposer during disposal.

Comment on lines +42 to +46
if (!restore && row.observationEpoch <= currentEpoch) {
return false
}
generationByHost.set(row.hostId, row.authorityGeneration)
epochByHost.set(row.hostId, Math.max(currentEpoch, row.observationEpoch))

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Description: Find consumers of the identity-evidence store and all applyPush/activateGeneration call sites.
set -euo pipefail

rg -nP -C4 '\bptyIdentityEvidenceStore\b' --type=ts
rg -nP -C6 '\b(applyPush|applySeed|activateGeneration)\s*\(' --type=ts
# Confirm notifications are host-wide with multiple rows per epoch.
fd -t f 'pty-identity-evidence.ts' | xargs -r rg -nP -C6 '(observationEpoch|rows\s*:)'

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- repository conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print \
  | sort \
  | head -40

printf '%s\n' '--- target file ---'
fd -t f -i 'pty-identity-evidence-store.ts' . | while IFS= read -r f; do
  cat -n "$f"
done

printf '%s\n' '--- related definitions and call sites ---'
rg -n -C5 'ptyIdentityEvidenceStore|applyPush|applySeed|activateGeneration|identity.?evidence' \
  src/renderer/src --glob '*.ts' --glob '*.tsx' || true

Repository: stablyai/orca

Length of output: 28183


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- renderer conventions and relevant learnings ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/repo-wide.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-renderer-src.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-renderer-src-components-terminal-pane.md

printf '%s\n' '--- pane handler and dispatcher ---'
cat -n src/renderer/src/components/terminal-pane/pty-connection/pane-ssh-identity-evidence.ts
cat -n src/renderer/src/components/terminal-pane/pty-identity-evidence-dispatch.ts

printf '%s\n' '--- shared notification contract and producer references ---'
rg -n -C8 'PtyIdentityEvidenceNotification|pty-identity-evidence|identityEvidence|observationEpoch' \
  shared src/main src/relay src/renderer/src --glob '*.ts' --glob '*.tsx' || true

printf '%s\n' '--- store tests ---'
cat -n src/renderer/src/lib/pty-identity-evidence-store.test.ts

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- notification contract ---'
cat -n src/shared/pty-identity-evidence.ts | sed -n '1,180p'

printf '%s\n' '--- relay publication paths ---'
sed -n '2490,2522p' src/relay/pty-handler.ts
sed -n '2588,2660p' src/relay/pty-handler.ts

printf '%s\n' '--- store read-side consumers ---'
rg -n -C8 'ptyIdentityEvidenceStore\.(get|snapshot|size|evict|markHostUnverifiable)' \
  src --glob '*.ts' --glob '*.tsx' || true

printf '%s\n' '--- generation-reset tests and all store test assertions ---'
sed -n '1,180p' src/renderer/src/lib/pty-identity-evidence-store.test.ts

Repository: stablyai/orca

Length of output: 8496


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- notification dispatch and provider-generation injection ---'
rg -n -C12 'dispatchPtyIdentityEvidence|providerGeneration|identityEvidence' \
  src/renderer/src/components/terminal-pane src/renderer/src --glob '*.ts' --glob '*.tsx' \
  | grep -E 'dispatchPtyIdentityEvidence|providerGeneration|identityEvidence|pty\.identityEvidence' -C5 || true

printf '%s\n' '--- all imports and direct store interactions ---'
rg -n -C4 'pty-identity-evidence-store|ptyIdentityEvidenceStore' \
  src/renderer/src --glob '*.ts' --glob '*.tsx' || true

printf '%s\n' '--- SSH generation ownership ---'
rg -n -C10 'providerGeneration|generation' \
  src/renderer/src/components/terminal-pane/pty-connection src/renderer/src/components/terminal-pane/pty-dispatcher.ts \
  --glob '*.ts' || true

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- onIdentityEvidence bindings ---'
rg -n -C12 'onIdentityEvidence' . --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.mjs' \
  | head -240

printf '%s\n' '--- providerGeneration assignments ---'
rg -n -C8 'providerGeneration\s*:' . --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.mjs' \
  | head -240

printf '%s\n' '--- exact store API consumers outside tests ---'
rg -n 'ptyIdentityEvidenceStore|\.snapshot\(\)|\.get\([^)]*incarnationId' \
  src --glob '*.ts' --glob '*.tsx' \
  | grep -v 'pty-identity-evidence-store.test.ts' || true

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- provider notification transformation ---'
sed -n '1,130p' src/main/providers/ssh-pty-provider-output-state.ts
sed -n '1,120p' src/main/providers/ssh-pty-provider.ts
sed -n '1740,1800p' src/main/ssh/ssh-relay-session.ts

printf '%s\n' '--- identity routing tests with multi-row cases ---'
rg -n -C12 'rows:|multiple|providerGeneration|identityEvidence' \
  src/main/providers/*identity*.test.ts src/main/providers/*notification*.test.ts \
  src/main/ssh --glob '*.test.ts' 2>/dev/null | head -320

Repository: stablyai/orca

Length of output: 40489


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- relay batch publication ---'
sed -n '2634,2690p' src/relay/pty-handler.ts

printf '%s\n' '--- provider-side identity notification routing ---'
rg -n -C18 "pty\.identityEvidence|identityEvidenceListeners" \
  src/main/providers/ssh-pty-notification-routing.ts \
  src/main/providers/ssh-pty-provider-output-state.ts \
  src/main/providers/ssh-pty-provider-contract.ts

Repository: stablyai/orca

Length of output: 20282


Track observation epochs per PTY row and make generation activation idempotent. A relay batch can contain multiple rows with one observationEpoch. After one row advances epochByHost, lines 42–43 reject the remaining rows, so snapshot() retains only one row. On the first provider generation, each pane handler also calls activateGeneration, which clears rows from earlier handlers. Track epochs by row key and activate each host generation only once.

Source: Linters/SAST tools

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

ℹ️ This renderer delta is clean — no new issues in the adoption fix itself. The two IMPORTANT relay findings from the prior review (reseed epoch mismatch and reads gated on connection rather than capability) are in pty-handler.ts, untouched by this commit, and remain open.

Reviewed changes

  • Extended the "not locally trackable" gate to remote runtime PTYs — isForegroundTrackingAllowed now returns false for any isRemoteExecutionHostPtyId(id) (paired remote: runtime PTYs, not just direct SSH), and readForegroundProcess/confirmForegroundProcess short-circuit to null for those ids, so adopting a remote-runtime pane no longer drives a local getForegroundProcess read that triggers replay/SSH resume.
  • Guarded SSH identity-evidence binding on older preload bridges — bindPaneSshIdentityEvidence bails before registerPtyIdentityEvidenceHandler when window.api.pty.onIdentityEvidence is absent, keeping legacy clients from initializing the PTY dispatcher for a handler that can never fire.

ℹ️ Nitpicks

  • The remote: adoption fix ships with no regression test — remote-execution-host-pty.test.ts covers the shared predicate, but nothing asserts that isForegroundTrackingAllowed returns false (or that getForegroundProcess is never called) for a remote: id, which is the exact behavior this commit changes.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Readiness review — DO NOT LAND

Reviewed exact head f691dfae7f on brennanb2025/r2-build and pushed the proven fixes in that commit.

What passed:

  • pnpm tc, changed-code quality, and oxlint pass.
  • Full relay/SSH suites: 280 files passed, 3,358 tests passed, 18 skipped.
  • Focused replay/capability tests: 49 passed.
  • Real Linux SSH host (ssh:ssh-1785104650217-eduhep, neil-ubuntu, bash): relay build passed; real remote PTY emitted live OSC bytes.
  • Reverse proofs: reverting epoch/read changes fails the mixed-held-epoch test (one publication instead of two); reverting symmetric capability intersection fails the no-V1 test (identity capability incorrectly granted).

Blocking findings:

  1. src/shared/pty-identity-evidence.ts has no nonce/trust gate. OSC 133/777 marker-shaped bytes from a hostile remote (wrong or absent nonce) are accepted and trigger process-table reads. The required forged-marker test (“reject as untrusted and rank with title”) cannot pass without adding a pane/PTY nonce contract and matching shell marker emission; this PR currently has neither.
  2. Real SSH Electron smoke connected a visible remote PTY and sent live OSC 133 input, but no pty.identityEvidence IPC notification arrived. Capability admission/visibility and the end-to-end push remain unproven.
  3. Held identity rows could be published under a maximum epoch while containing mixed row epochs; fixed by grouping rows per epoch. Boundary pending IDs were aliased then cleared (causing full-pool scans); fixed by snapshotting the set. Identity capability negotiation now intersects both offer and support versions.

Platform matrix

Surface Evidence / applicability
macOS local Exact target worktree launched with Electron CDP; identity branch/root verified; local build/typecheck/tests pass.
Linux local-or-SSH Relay built locally and on real Linux SSH host; remote PTY exercised.
Windows native (PowerShell + Git Bash) Not applicable: this PR changes SSH relay producer only; no Windows native path changed or required for the producer.
WSL Not applicable: no WSL source path changed.
SSH remote pane Real host/repo/worktree connected; live PTY/OSC observed, but identity push event missing.
daemon-backed pane No daemon path changed; existing relay/daemon suites pass.
reattach/reconnect Replay bytes are isolated from live scanner; mixed held-epoch reseed test passes. Physical reconnect push remains unproven.
mixed old-client/new-host No-V1/old-client capability omission and V1 intersection covered by tests; no old binary available for physical run.

Verdict: DO NOT LAND until the marker nonce/trust contract and real SSH pty.identityEvidence push are fixed and demonstrated. No Docker result was used as real-host evidence.

@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 new issues in this delta — it resolves both prior IMPORTANT findings. I'm holding approval only because the PR's own readiness gate (no OSC 133/777 nonce/trust contract, and the live SSH Electron smoke produced no pty.identityEvidence push) remains and is unchanged by these commits, consistent with the author's "DO NOT LAND" note.

Reviewed changes

  • Epoch-consistent held-evidence reseed — publishHeldIdentityEvidenceToClient now groups held rows by observationEpoch and emits one internally consistent pty.identityEvidence notification per epoch, so the main-process parser no longer rejects mixed-epoch reconnect seeds.
  • Capability-gated process-table reads — publishIdentityEvidence consults hasIdentityEvidenceConsumer() (an active client with the negotiated identityEvidence v1 admission) instead of hasConnectedClients(), and snapshots identityEvidencePendingIds into a new Set before clearing, so a boundary-triggered read no longer degenerates into a full-pool scan.
  • Symmetric capability intersection — intersectPtyConsumerCapabilities now requires the client's offer to include version 1, matching the outputFlowControl branch.
  • Refactor + regression tests — extracted rejectedRecoveryPriority/rejectedSourceIdentity into ssh-pty-notification-rejection.ts and consolidated duplicate imports; added epoch-consistency, no-read-without-capability, and omitted-V1 grant tests.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@OrcaWin

OrcaWin commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this. The SSH relay this PR hardened has been removed (#27214 deleted the client relay path, #27215 deleted src/relay); SSH terminals now run on Orca's managed server, so these relay invariants no longer apply. Closing.

@OrcaWin OrcaWin closed this Oct 11, 2026
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.

2 participants