Skip to content

🤖 perf: shard OpenSSH exec paths and simplify SSH project sync#3125

Merged
ammario merged 16 commits intomainfrom
perf-ssh-runtime-scaling
Apr 6, 2026
Merged

🤖 perf: shard OpenSSH exec paths and simplify SSH project sync#3125
ammario merged 16 commits intomainfrom
perf-ssh-runtime-scaling

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

@ammar-agent ammar-agent commented Apr 5, 2026

Summary

This keeps the SSH scaling wins that matter in practice — sharded OpenSSH exec paths, serialized same-project sync/import work, hashed remote project layout, and persisted SSH workspace roots where they still match a known checkout shape — while deleting the explicit master-pool/coordinator machinery and replacing most mock-heavy runtime unit suites with higher-level SSH integration coverage.

Background

The original branch tackled real SSH bottlenecks: one implicit control socket per host, duplicate same-project bundle imports, and basename-derived remote roots that could collide. But the first implementation grew into an app-managed OpenSSH master scheduler with a large amount of lifecycle, compatibility, and mock-test surface area. This revision deliberately simplifies the design so the branch still improves SSH scalability without carrying most of that maintenance burden.

Implementation

  • shard short-lived OpenSSH exec/file traffic across a small deterministic set of ControlPaths via ControlMaster=auto, keep sshConnectionPool as the single bootstrap/backoff layer, re-check requested shard readiness after waiting on another inflight probe, and cap any follow-up shard probe to the remaining acquire budget
  • simplify SSHRuntime to one hashed remote project layout, one serialized per-project sync path, one current-snapshot marker, and ref-manifest validation before snapshot reuse
  • keep bundle imports in refs/mux-bundle/* and UUID bundle temp paths, but remove the explicit openSshMasterPool, projectSyncCoordinator, remote branch-metadata persistence, and hot-path legacy layout auto-detection layers
  • preserve persisted SSH workspace roots only when config still points at a known canonical or legacy checkout shape, including sibling multi-project path hints for repo operations and resolving an upgraded worktree's actual common git dir before rename/delete worktree commands
  • replace the runtime-internal unit suites with focused Docker-backed SSH integration coverage for concurrent exec bursts, rename/delete lifecycle, snapshot recovery, and checked-out branch collision cases, plus targeted sshConnectionPool and legacy-worktree regressions

Validation

  • make typecheck
  • make static-check
  • bun test ./src/node/runtime/runtimeHelpers.test.ts
  • bun test ./src/node/runtime/sshConnectionPool.test.ts
  • bun test src/node/services/workspaceProjectRepos.test.ts src/node/services/workspaceService.test.ts src/node/services/workspaceService.multiProject.test.ts
  • TEST_INTEGRATION=1 bun x jest tests/runtime/runtime.test.ts --runInBand --testNamePattern='SSHRuntime'
  • TEST_INTEGRATION=1 bun x jest tests/runtime/runtime.test.ts --runInBand --testNamePattern='legacy base repo for upgraded SSH worktrees'

Risks

Moderate. The simplified transport no longer has the same theoretical ceiling as the previous explicit master-pool design, but it still improves on the original baseline by removing the single implicit host-wide control path from short-lived SSH execs. The main compatibility edge is that SSH workspaces rooted outside the known canonical or legacy checkout shapes now fall back to the canonical hashed layout and may need re-init instead of transparent path inference.

Pains

The original explicit-pool direction accumulated a lot of policy and mock-test code. The cleanup work here was mostly about deleting that surface area without giving back the core scaling fixes, which in turn meant shifting confidence into the real Docker-backed SSH integration harness.


Generated with mux • Model: openai:gpt-5.4 • Thinking: xhigh • Cost: $269.00

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 01c559b to b2cc683 Compare April 5, 2026 16:43
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01c559b110

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from b2cc683 to 4c51e09 Compare April 5, 2026 17:01
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 4c51e09 to 09b6354 Compare April 5, 2026 17:04
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 09b6354 to 5000faf Compare April 5, 2026 17:06
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5000faf832

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 5000faf to f42ea83 Compare April 5, 2026 17:22
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from f42ea83 to 6850d04 Compare April 5, 2026 17:26
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6850d04db6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 6850d04 to 7107b20 Compare April 5, 2026 17:40
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 7107b20 to f3db47b Compare April 5, 2026 17:46
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3db47b065

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from f3db47b to e2b8aa6 Compare April 5, 2026 18:08
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from e2b8aa6 to 0d5eb46 Compare April 5, 2026 18:18
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d5eb4674e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 0d5eb46 to a1a00b0 Compare April 5, 2026 18:39
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1a00b0b3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from a1a00b0 to 6253e8f Compare April 5, 2026 18:56
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the latest transport/path feedback:

  • shard execs now warm the same ControlPath they later run on by probing that exact path through sshConnectionPool
  • PTY sessions no longer force BatchMode=yes
  • SSH primary path hints are gated consistently so non-repo container roots do not get reused as project checkouts

Revalidated locally:

  • bun test ./src/node/runtime/sshConnectionPool.test.ts ./src/node/services/workspaceProjectRepos.test.ts ./src/node/services/workspaceService.multiProject.test.ts ./src/node/services/workspaceService.test.ts ./src/node/services/aiService.test.ts
  • TEST_INTEGRATION=1 bun x jest tests/runtime/runtime.test.ts --runInBand --testNamePattern='SSHRuntime'
  • make static-check

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from f84fffe to 37666f6 Compare April 6, 2026 17:31
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37666f614e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

I updated the affected service tests to match the now-gated SSH primary-path behavior and force-pushed the refreshed commit.

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 37666f6 to a7767a8 Compare April 6, 2026 17:43
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the latest review:

  • PTY sessions no longer apply the headless-fallback host-key policy override
  • syncProjectToRemote() now recomputes the snapshot digest after entering the serialized sync section before writing current-snapshot

Revalidated locally:

  • TEST_INTEGRATION=1 bun x jest tests/runtime/runtime.test.ts --runInBand --testNamePattern='SSHRuntime'
  • make static-check

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from a7767a8 to dde79ef Compare April 6, 2026 17:48
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dde79ef854

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the remaining legacy-root issue by seeding the fork source runtime from the persisted workspace path before branch detection/fork orchestration.

Revalidated locally:

  • bun test ./src/node/services/workspaceService.test.ts ./src/node/services/workspaceService.multiProject.test.ts ./src/node/services/aiService.test.ts ./src/node/services/workspaceProjectRepos.test.ts
  • make static-check

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from dde79ef to 00a933c Compare April 6, 2026 18:03
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00a933c0f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the latest review:

  • project-sync queue wait now races the prior tail against the caller abort signal
  • shard readiness is cached per host/control-path, so healthy execs no longer pay an extra ssh -O check on every command

Revalidated locally:

  • bun test ./src/node/runtime/sshConnectionPool.test.ts
  • TEST_INTEGRATION=1 bun x jest tests/runtime/runtime.test.ts --runInBand --testNamePattern='SSHRuntime'
  • make static-check

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from 00a933c to b683814 Compare April 6, 2026 18:19
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b683814c94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Collapse the SSH scaling redesign around a simpler sharded OpenSSH transport,
hashed project layout, and higher-level integration coverage.

Delete the explicit OpenSSH master pool and project sync coordinator, remove
remote branch-metadata persistence and legacy layout inference, and keep a
serialized per-project sync path with current-snapshot reuse validation.

---

_Generated with `mux` • Model: `openai:gpt-5.4` • Thinking: `xhigh` • Cost: `$219.50`_

<!-- mux-attribution: model=openai:gpt-5.4 thinking=xhigh costs=219.50 -->
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the remaining queue-tail issue by keeping the project sync tail registered until the prior sync actually settles, even if an intermediate waiter aborts.

Revalidated locally:

  • TEST_INTEGRATION=1 bun x jest tests/runtime/runtime.test.ts --runInBand --testNamePattern='SSHRuntime'
  • make static-check

@ammar-agent ammar-agent force-pushed the perf-ssh-runtime-scaling branch from b683814 to e812fc9 Compare April 6, 2026 18:30
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e812fc96d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Loop after waiting on another host probe so callers re-validate the requested
sharded ControlPath before returning, and cover the regression with a targeted
singleflight test.

---

_Generated with `mux` • Model: `openai:gpt-5.4` • Thinking: `xhigh` • Cost: `$269.00`_

<!-- mux-attribution: model=openai:gpt-5.4 thinking=xhigh costs=269.00 -->
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the remaining inflight shard readiness issue by looping after an existing probe completes so each caller re-validates its requested ControlPath, and added a targeted regression test in sshConnectionPool.test.ts.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed8fe808e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Fail fast when SSH runtime helpers are asked to reconstruct an execution root
without a persisted workspace path, while preserving the runtime-path fallback
for non-SSH unit-test scenarios.

---

_Generated with `mux` • Model: `openai:gpt-5.4` • Thinking: `xhigh` • Cost: `$269.00`_

<!-- mux-attribution: model=openai:gpt-5.4 thinking=xhigh costs=269.00 -->
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the SSH workspace-path regression by requiring a persisted workspace path before resolveWorkspaceExecutionPath() will serve an SSH runtime, while keeping the old runtime-derived fallback only for non-SSH scenarios.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58a9293d0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Use each existing SSH worktree's reported common git dir for rename/delete
operations so upgraded legacy layouts keep working, and bound follow-up shard
probes to the remaining acquire budget after waiting on an inflight probe.

---

_Generated with `mux` • Model: `openai:gpt-5.4` • Thinking: `xhigh` • Cost: `$269.00`_

<!-- mux-attribution: model=openai:gpt-5.4 thinking=xhigh costs=269.00 -->
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the follow-up SSH issues by resolving the actual worktree common git dir before rename/delete commands on upgraded legacy layouts, and by bounding post-singleflight shard probes to the remaining acquire budget with a regression test.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammario ammario merged commit 60a2570 into main Apr 6, 2026
24 checks passed
@ammario ammario deleted the perf-ssh-runtime-scaling branch April 6, 2026 21:20
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