* feat(ssh): track connection-manager drains, test probes and provider continuations (#16741 T2 P3+P8a)
The SSH connection manager now registers each connection it allocates against
the connection's transport-closure notice, and tracks every connect,
disconnect, reconnect and teardown per target, so later slices can tell when a
target's local work and transports are really gone. Ordinary connect,
disconnect and quit behavior is unchanged apart from cleanup.
Manager (ssh-connection-manager.ts):
- registerConnection counts every connection a target allocated, retired pool
entries included, until its transport-closure notice arrives.
- connect/disconnect/reconnect/disconnectConnection/disconnectAll run through
trackTargetOperation; a failed teardown is remembered as unconfirmed.
- A failed startup is now disconnected, not just dropped from the pool.
- disconnectAndDrain(targetId, signal) and disconnectConnection(..., drain),
bounded by a 10s timeout.
- disconnectAll(shouldDisconnect) only tears down targets the filter allows.
IPC:
- ssh-connect-attempt-registry: runSshTestConnectionProbe publishes a probe per
target before it starts and clears testingTargets / credential flags only
when the target's last probe settles. ssh:testConnection uses it, so quit
still joins an in-flight probe within the shutdown budget.
- ssh-target-lifecycle-queue: runTargetLifecycle returns the operation's value.
- ssh-shutdown-drain: a mayDetach predicate (default: every target) is plumbed
through detach, invalidation and disconnectAll.
- ssh-renderer-broadcast: targets owned by a runtime are hidden by owner too,
not only by id prefix.
- ssh-target-registry: direct-authority resolver, installed by
ssh-active-relay-sessions.
- Provider dispatch: unregister*IfCurrent for git and filesystem providers.
P8a, SSH provider continuations: ssh-provider-continuations tracks local
settlement of SSH filesystem writes/deletes, imports, detected-worktree
listings and worktree/folder removals per target. It records only local
settlement, never remote execution or exit.
Porting note (source: #16741 head a68b6f3531, merge-base 277c289bd4):
- Left for later slices: connectExclusive and assertTargetTransportsClosed
(T8), hasTargetActivity (T3), assertProfileLifetimeAdmission (P8b, stubbed
out of the manager and continuations), the reset admission checks in
ssh-connection-handlers and the reset predicate in the shutdown drain (T3),
the network-tunnel resolver (T4), and the managed-orcad provisioning test
hunks in ssh-target-registry.test.ts (T6).
- Tests read the manager's bookkeeping through
ssh-connection-manager-test-probes until T3/T8 expose readers. Two of the
four deferred disconnect-drain cases are restored; the two that need
connectExclusive, two closure cases that need it and three profile-admission
cases stay deferred.
- The removal and detected-worktree call sites were rebased onto main's
background removal and execution-host routing. filesystem-import-ssh moved
its remote-existence helpers out to stay under 300 lines.
* test(ssh): name the filesystem continuation handler payload type
---------
Co-authored-by: m4air <m4air@m4airs-Air.localdomain>
* feat(ssh): connect in plain SSH mode when no Orca runtime can run on the host
Runtime ladder rung D (design D6): instead of failing the connect, register an
ssh2 shell-channel PTY provider and an SFTP-only filesystem provider and publish
the classified reason on the SSH connection state.
* fix(ssh): harden plain SSH mode against stale reconnects, host sleep and tilde cwd
- Only the current connect or reconnect attempt may enter plain SSH mode; a superseded
reconnect whose ladder ends at rung D no longer registers a second provider set.
- Host-sleep resume probes a plain session over SFTP instead of always reconnecting,
which ended every open plain shell.
- A home-relative cwd keeps its tilde outside the quotes so the shell expands it.
- The SFTP provider implements folder download, which the connect state advertises.
* docs(ssh): rung D now means plain SSH mode, not a failed connect
---------
Co-authored-by: m4air <m4air@m4airs-Air.localdomain>
Co-authored-by: m4air <m4air@Mac.localdomain>
* perf(worktrees): bound repeated runtime discovery scans (#8882)
* fix(worktrees): invalidate scans on SSH state changes (#8882)
* fix(worktrees): key scan reuse by execution runtime (#8882)
* test(worktrees): prove cached lineage variants (#8882)
* test(worktrees): exercise lineage through the shared scan cache (#8882)
* fix(worktrees): prevent stale runtime scans from repopulating cache (#8882)
* test(worktrees): prove stale generations stay out of cache (#8882)
* fix(worktrees): invalidate hidden SSH scans on relay state (#8882)
* fix(worktrees): scope SSH scan invalidation to provider changes (#8882)
* fix(worktrees): preserve enriched hidden SSH state notifications (#8882)
* test(worktrees): pin SSH provider generation monotonicity (#8882)
* test(worktrees): drain cached scan mock responses (#8882)
* fix(worktrees): scope resolved SSH invalidation to affected repos (#8882)
* fix(worktrees): separate SSH scan invalidation from client events (#8882)
* perf(worktrees): preserve raw scan reuse across metadata updates
# Conflicts:
# src/main/runtime/orca-runtime.ts
* perf(worktrees): scope repo-local scan invalidation
# Conflicts:
# src/main/runtime/orca-runtime.ts
* perf(worktrees): scope all repository scan invalidations
* fix(worktrees): drop scan cache on orphan-cleanup removal (#8882)
The orphan-cleanup fallback in removeManagedWorktree (git worktree remove
fails with 'not a working tree', Orca deletes the directory and prunes)
invalidated only the resolved cache, so the removed worktree kept being
served from the bounded raw scan cache for up to its 30s TTL.
Co-authored-by: Orca <help@stably.ai>
* Simplify SSH deploy-success handling to use broadcastSshState
Route the post-deploy "connected" notification through the shared
broadcastSshState helper instead of manually reimplementing window
broadcast and runtime cache invalidation inline, keeping SSH state
propagation consistent with other call sites.
* perf(worktrees): defer SSH enrichment, consolidate cache invalidation
- Skip enriching ephemeral-VM SSH state since it's not broadcast to the
renderer, avoiding unnecessary withSshRemotePlatform() calls.
- Move invalidateResolvedWorktreeCache() outside the conditional branch
to eliminate redundant calls (previously called in both if and else).
---------
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
Co-authored-by: Orca <help@stably.ai>