Repository navigation
fix(relay): preserve PTY streaming and shutdown test invariants - #17737
brennanb2025 wants to merge 4 commits into
Conversation
Greptile SummaryThe PR adds provider-owned SSH PTY identity-evidence propagation while separating replay from live boundary scanning and scoping reconciliation polling to visible PTYs.
Confidence Score: 4/5The 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
|
| 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
Reviews (2): Last reviewed commit: "fix(renderer): avoid replay SSH resume o..." | Re-trigger Greptile
| const epoch = Math.max(...rows.map((row) => row.foregroundProcessEvidence.observationEpoch)) | ||
| this.dispatcher.publishProducerNotification(clientId, 'pty.identityEvidence', { | ||
| authorityGeneration: this.ptyIdMintEpoch, | ||
| observationEpoch: epoch, | ||
| rows |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 —
PtyHandlergains a live OSC 133/777 boundary scanner, a bounded held-evidence cache, per-client visibility tracking, andpty.identityEvidencepublication fed byps -axoprocess-table reads, gated behind a newidentityEvidencev1 capability on the consumer-session hello/grant. - Main-process provider threading —
SshPtyProvider/SshPtyProviderOutputStateparse and re-routepty.identityEvidencenotifications, andssh-relay-session.tsflips the SSH gate to negotiate the capability and forward evidence overpty:identityEvidenceIPC. - Renderer consumption — a new evidence store (
pty-identity-evidence-store.ts) pluspane-ssh-identity-evidence.tsapply live evidence tosetPaneForegroundAgent, with generation/epoch fencing against reconnect and stale rows. - Visibility-scoped backstop —
resize-visibility.tspushes the visible pane set to the relay via a debouncedpty.identityEvidence.setVisibilityrequest; 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 rebasesreceivedAtMs = now()and treats up-to-30s-old evidence as freshly received for the fullfreshnessMswindow. RebasingcapturedAgeMsto include the time the row has been held would make the documented age rebasing honest. identityEvidenceBackoffByPtyis only deleted on a live verdict or indispose()— never on PTY exit — so a long-lived relay accumulates one entry per exited PTY that ever received a non-live verdict.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Two findings from the review, tied to specific lines (the
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (3 passed)
Full details: Title checkExplanation 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 checkExplanation 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.
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (2)
src/shared/pty-consumer-session-capabilities.ts (1)
48-48: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAlso 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 offersidentityEvidence: { versions: [2] }therefore receives aversion: 1grant it never offered. Client-sidevalidateGrantrejects 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 tradeoffNew import cycle between the dispatcher and the extracted eager-buffer module.
pty-eager-dispatch.tsimportsensurePtyDispatcherfrompty-dispatcher.ts, andpty-dispatcher.tsimports the eager-buffer functions back. Both sides cross the cycle only through hoisted function declarations, so module evaluation still succeeds, but static analysis reportsimport(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: importensurePtyDispatcherfrom 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-exportensurePtyDispatcherfrom 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
📒 Files selected for processing (40)
src/main/ipc/pty/ipc/resize-visibility.tssrc/main/providers/pty-provider-contract.tssrc/main/providers/ssh-pty-identity-notification.tssrc/main/providers/ssh-pty-identity-visibility.tssrc/main/providers/ssh-pty-notification-routing.identity.test.tssrc/main/providers/ssh-pty-notification-routing.tssrc/main/providers/ssh-pty-provider-contract.tssrc/main/providers/ssh-pty-provider-output-state.tssrc/main/providers/ssh-pty-provider.tssrc/main/ssh/ssh-pty-consumer-recovery.tssrc/main/ssh/ssh-pty-consumer-session.test.tssrc/main/ssh/ssh-pty-consumer-session.tssrc/main/ssh/ssh-relay-session.tssrc/preload/api/pty-api.tssrc/preload/index.tssrc/relay/dispatcher-capacity-signals.tssrc/relay/dispatcher-contract.tssrc/relay/dispatcher-notification-publication.tssrc/relay/dispatcher.tssrc/relay/pty-handler-attach-replay.test.tssrc/relay/pty-handler.tssrc/relay/ssh-pty-consumer-session-adapter.tssrc/renderer/src/components/terminal-pane/ipc-pty-connect.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-ssh-identity-evidence.tssrc/renderer/src/components/terminal-pane/pty-connection/transport-output-callbacks.tssrc/renderer/src/components/terminal-pane/pty-dispatcher.tssrc/renderer/src/components/terminal-pane/pty-eager-dispatch.tssrc/renderer/src/components/terminal-pane/pty-identity-evidence-dispatch.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/lib/pty-identity-evidence-store.test.tssrc/renderer/src/lib/pty-identity-evidence-store.tssrc/shared/pty-consumer-session-capabilities.tssrc/shared/pty-consumer-session-contract.tssrc/shared/pty-consumer-session-hello.tssrc/shared/pty-consumer-session.tssrc/shared/pty-identity-evidence.test.tssrc/shared/pty-identity-evidence.tssrc/shared/ssh-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| const grantedIdentity = grant.capabilities?.identityEvidence | ||
| if (!options.identityEvidence && grantedIdentity) { | ||
| throw new Error('Remote relay granted an unoffered PTY identity-evidence capability') | ||
| } |
There was a problem hiding this comment.
🎯 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 -240Repository: 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 -320Repository: 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.
| this.identityEvidenceScanners.delete(managed.id) | ||
| this.evictIdentityEvidence(managed.id, managed.incarnationId) |
There was a problem hiding this comment.
🩺 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.
| const row = this.identityEvidenceHeld.get(oldest) | ||
| this.identityEvidenceHeld.delete(oldest) | ||
| if (row) { | ||
| this.identityEvidenceHeldBytes -= this.identityEvidenceRowBytes(row) | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 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.
| 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) | |
| } | |
| } |
| 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) { |
There was a problem hiding this comment.
🚀 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.tsRepository: 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.tsRepository: 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.tsRepository: stablyai/orca
Length of output: 13180
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '2518,2662p' src/relay/pty-handler.tsRepository: 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.
| if (isDirectSshPtyId(id)) { | ||
| session.bindIdentityEvidence?.(id) |
There was a problem hiding this comment.
🎯 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=tsRepository: 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>&1Repository: 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.tsRepository: 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.
| session.bindIdentityEvidence?.( | ||
| ptyId, | ||
| session.transport.getPtyIncarnationId?.() ?? undefined | ||
| ) |
There was a problem hiding this comment.
🩺 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-paneRepository: 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' srcRepository: 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.
| if (!restore && row.observationEpoch <= currentEpoch) { | ||
| return false | ||
| } | ||
| generationByHost.set(row.hostId, row.authorityGeneration) | ||
| epochByHost.set(row.hostId, Math.max(currentEpoch, row.observationEpoch)) |
There was a problem hiding this comment.
🗄️ 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' || trueRepository: 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.tsRepository: 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.tsRepository: 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' || trueRepository: 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' || trueRepository: 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 -320Repository: 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.tsRepository: 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
There was a problem hiding this comment.
ℹ️ This renderer delta is clean — no new issues in the adoption fix itself. The two
IMPORTANTrelay findings from the prior review (reseed epoch mismatch and reads gated on connection rather than capability) are inpty-handler.ts, untouched by this commit, and remain open.
Reviewed changes
- Extended the "not locally trackable" gate to remote runtime PTYs —
isForegroundTrackingAllowednow returnsfalsefor anyisRemoteExecutionHostPtyId(id)(pairedremote:runtime PTYs, not just direct SSH), andreadForegroundProcess/confirmForegroundProcessshort-circuit tonullfor those ids, so adopting a remote-runtime pane no longer drives a localgetForegroundProcessread that triggers replay/SSH resume. - Guarded SSH identity-evidence binding on older preload bridges —
bindPaneSshIdentityEvidencebails beforeregisterPtyIdentityEvidenceHandlerwhenwindow.api.pty.onIdentityEvidenceis 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.tscovers the shared predicate, but nothing asserts thatisForegroundTrackingAllowedreturnsfalse(or thatgetForegroundProcessis never called) for aremote:id, which is the exact behavior this commit changes.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Readiness review — DO NOT LANDReviewed exact head What passed:
Blocking findings:
Platform matrix
Verdict: DO NOT LAND until the marker nonce/trust contract and real SSH |
There was a problem hiding this comment.
ℹ️ No new issues in this delta — it resolves both prior
IMPORTANTfindings. 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 nopty.identityEvidencepush) remains and is unchanged by these commits, consistent with the author's "DO NOT LAND" note.
Reviewed changes
- Epoch-consistent held-evidence reseed —
publishHeldIdentityEvidenceToClientnow groups held rows byobservationEpochand emits one internally consistentpty.identityEvidencenotification per epoch, so the main-process parser no longer rejects mixed-epoch reconnect seeds. - Capability-gated process-table reads —
publishIdentityEvidenceconsultshasIdentityEvidenceConsumer()(an active client with the negotiatedidentityEvidencev1 admission) instead ofhasConnectedClients(), and snapshotsidentityEvidencePendingIdsinto a newSetbefore clearing, so a boundary-triggered read no longer degenerates into a full-pool scan. - Symmetric capability intersection —
intersectPtyConsumerCapabilitiesnow requires the client's offer to include version 1, matching theoutputFlowControlbranch. - Refactor + regression tests — extracted
rejectedRecoveryPriority/rejectedSourceIdentityintossh-pty-notification-rejection.tsand consolidated duplicate imports; added epoch-consistency, no-read-without-capability, and omitted-V1 grant tests.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Summary
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 --checkandoxfmt --check— passed.setIntervalinwireAndStore;pty-handler-dispose-lifecycle.test.ts -t "takes ownership when dispose overlaps"failed (timerCount2 vs expected 1). Restored the scoped timer; focused lifecycle/shutdown/output tests passed.replayinto 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.window.api.app.getIdentity()reported branchbrennanb2025/r2-buildand 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 observedR2_LIVE,/work/demo-project, and clean remotegit statusoutput.demo-projectbundle; relay deployed and remote PTY output/OSC boundaries were delivered. Remote proof:/work/demo-projectremained## main...origin/mainwith one worktree and no test artifacts.pnpm run lint— known baseline failure: existing warnings (including import-cycle/duplicate-import findings) are denied; additionallysrc/main/runtime/rpc/dispatcher.tsreports eslintmax-lines302/300 onorigin/mainitself. Static-analysis/verify red status is unrelated to this fix; no max-lines disable was added.Reliability notes
terminal-session.provider-ownership/ replay isolation).Readiness follow-up (2026-09-01)
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 negotiatedidentityEvidencecapability; 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).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).createPtyIdentityBoundaryScanneraccepts 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 nopty.identityEvidencenotification after a visible PTY and live OSC 133 input, so the end-to-end push path remains unproven.Platform matrix
ssh:ssh-1785104650217-eduhep,neil-ubuntu, bash); remote PTY and OSC bytes observed.pty.identityEvidenceIPC event was observed.Readiness: DO NOT LAND until the nonce/trust contract and real SSH identity-evidence push are fixed and demonstrated.