Skip to content

fix(e2e): drop the pi-title spec's stale private Docker-SSH connect fork - #17017

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/e2e-pi-title-unblock-r1
Aug 28, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/e2e-pi-title-unblock-r1

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​75 $\color{#cf222e}{\Huge{\mathbf{−}}}$​73
Prod 0 0 0 0

What this does

Deletes a stale private connectDockerRemote fork from
tests/e2e/ssh-pi-compatible-agent-title.spec.ts and calls the shared
connectDockerSshRelayTarget helper instead. One test file, +2/-75. No production code, no
helper change, no new assertion, and nothing weakened.

Scope change (2026-08-28): this PR previously also added a 60s retry loop to the shared
helper. That half has been removed — see Why the retry loop is gone.
Please do not re-add it here.

The defect

ssh-pi-compatible-agent-title.spec.ts (last touched 2026-07-11) kept a private copy of the connect
sequence:

await store.getState().fetchRepos()
await store.getState().fetchWorktrees(result.repo.id)          // no options
const worktree = (store.getState().worktreesByRepo[result.repo.id] ?? [])[0]
if (!worktree) {
  throw new Error(`No remote worktree found for ${result.repo.path}`)
}

a40183389b (#11003, 2026-07-28) gave fetchWorktrees a host-qualified authority gate. With no
directSshAuthority passed, it depends on getCurrentDirectSshAuthority resolving at that instant
(direct-ssh-authority.ts:21-43 returns null unless status === 'connected' with a complete
epoch/generation); when it returns null, fetch-worktrees.ts:70-77 short-circuits to false and
writes no authoritative rows. The listing is empty, [0] is undefined, and setup throws
No remote worktree found for /tmp/orca-docker-relay-perf-repo before the spec reaches a single
title assertion.

The same commit updated tests/e2e/helpers/docker-ssh-relay-connection.ts (+80) to pass
directSshAuthority explicitly — making that short-circuit structurally unreachable there — but
touched this spec zero times. The fork rotted silently, and
the Docker-SSH specs had no CI lane at all until #16746,
so nothing caught it for four weeks.

Differential that pins it

Across 5 lane runs (~130 SSH connects):

Source Guard errors
Shared helper (connectDockerSshRelayTarget), 26 connects/run 0
The private fork, 1 connect/run 3 × No remote worktree found

The fork's message has no : suffix, so it is distinguishable from the shared helper's. It accounts
for 6 of 7 failures on the e2e / ssh docker watcher isolation lane.

The fix is a faithful swap

Every helper default matches what the fork passed explicitly:

Fork Shared helper
relayGracePeriodSeconds: 1 options.relayGracePeriodSeconds ?? 1
remotePath: DOCKER_SSH_RELAY_REMOTE_REPO_PATH same default when viaProxyJump is false
seeds a tab when the worktree has none seedInitialTab ?? true
port: target.port viaProxyJump ? 22 : target.port
host: '127.0.0.1' (hardcoded) target.host — correct under ORCA_E2E_SSH_TARGET_HOST
worktreesByRepo[repoId][0] .find(c => c.hostId === executionHostId) — host-qualified

The three OMP/Pi title assertions are byte-identical; git diff -U0 shows exactly two added lines
(the import and the call).

Why the retry loop is gone

The removed half added a 60s waitForLiveAuthority retry loop to the shared helper, justified
by a "~0.5s post-deploy transport bounce". That premise was refuted
(review, point 1): the
[ssh] Reconnecting … failed handshakes 0/9 line is the spec's own finally calling
cleanupDockerSshRelayTarget → docker rm -f (docker-ssh-relay-target.ts:287), which deletes the
container the transport is connected to. In run
33175867485 the Playwright trace dates
the spec's throw ~0.1s earlier than the drop, and the gap is not fixed at 0.5s — across passing
runs it is 1.4s / 3.4s / 12s / 27s, tracking each spec's body length. failed handshakes 0/9 means
the transport was healthy until it was deleted. There is no product-side drop.

Three further reasons it should not ride along:

  1. It fixes nothing measurable. A fork-deletion-only branch (helper untouched) was run on the
    lane four times; the pi-title spec passed in all four.
  2. CI structurally cannot exercise it. selectPrE2eSpecs seeds only from
    /^tests\/e2e\/.*\.spec\.ts$/ and every route requires ^src/, so a tests/e2e/helpers/ edit
    routes zero specs and skips the Docker-SSH lane. The helper has 24 consumer files; a
    helper-only diff validates none of them.
  3. It can erase the error it exists to produce. tests/playwright.config.ts:22 sets a 120s
    default; ssh-startup-exec-readiness.spec.ts:32 sets test.setTimeout(150_000) with no
    test.slow(). A full 60s burn there replaces the named
    No remote worktree found for X: <reason> with an opaque test timeout, and
    tests/playwright.config.ts:34 sets retries: 0 deliberately so first-failure traces stay the
    only reliable artifact.

No retry, sleep, or timeout was added anywhere as compensation.

Validation

Docker is dead on the reviewing machine, so the lane was exercised only through
workflow_dispatch — the sole way to reach it (a PR diff of one Docker-gated spec routes to a
sharded lane that sets no ORCA_E2E_SSH_DOCKER and self-skips).

Fork-deletion-only branch, e2e / ssh docker watcher isolation:

Run Lane pi-title spec
33185192081 success ✓ 74:7 (24.1s) — 18 passed
33185197126 success ✓ 74:7 (24.5s) — 18 passed
33185202362 failure ✓ 74:7 (24.5s) — 17 passed, 1 failed
33185207547 success ✓ 74:7 (24.0s) — 18 passed

3 of 4 lanes green; the pi-title spec passed 4 of 4. The single red was
ssh-cold-hydration-gap-tab-seeding.spec.ts:158 (baseline=3 duringStall=3 afterHydration=0) — a
separate known issue that #17031 covers and that this branch deliberately does not include.

Baseline for comparison: the lane measured 22 pass / 7 fail (76%) across 29 decided runs since
#16746, with pi-title accounting for 6 of the 7 failures.

This PR's head e8a9988b6f, same lane, four more workflow_dispatch runs:

Run Lane pi-title spec Suite
33197732254 success ✓ 74:7 (24.8s) 2 + 5 + 18 passed, 0 failed
33197734527 success ✓ 74:7 (23.5s) 2 + 5 + 18 passed, 0 failed
33197737144 success ✓ 74:7 (24.8s) 2 + 5 + 18 passed, 0 failed
33197738900 success ✓ 74:7 (25.2s) 2 + 5 + 18 passed, 0 failed

4 of 4 green. Combined with the probe branch: 8 lane runs, 7 green, pi-title 8 of 8 — against
a 76% pre-fix baseline where pi-title alone was 6 of 7 failures. The one red across all eight was
the cold-hydration spec #17031 covers.

Gates

pnpm tc exit 0 · oxlint + type-aware + React Doctor changed-code gate: 0 new findings ·
oxfmt --check clean · git diff --check clean · typecheck:e2e error count 208 → 208
(red on main for unrelated reasons; this file contributes none — measured in both directions).
No suppressions, no max-lines disable or bump.

Known gap this PR does NOT fix

ssh_source_changed is false for a test-only diff, and the Docker-SSH lane's if names only
ssh-startup-exec-readiness.spec.ts and paired-startup-exec-readiness.spec.ts by hand. So
this PR's own e2e / ssh docker watcher isolation check will show as skipping — the lane it
fixes does not run on it. Fixing the gate means a new docker_ssh_spec_changed signal through
pr-e2e-source-routing.mjs → pr.yml → e2e.yml plus an update to pr-e2e-gate-contract.test.mjs:
a separate defect for a separate PR.

tests/e2e/ssh-localhost.spec.ts:213 has the identical pre-#11003 fork shape — same latent
defect, different lane. Also out of scope here.

Unblocks

#16336, #16901, #16915 and #16926 are each red on this lane and nothing else. Once this lands they
each need gh pr update-branch (or a new commit) — a gh run rerun stays pinned to the original
merge base and cannot pick this up.

@coderabbitai

coderabbitai Bot commented Aug 28, 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: Pro Plus

Run ID: cc158e23-c079-447a-ac8b-8890352ed1cd

📥 Commits

Reviewing files that changed from the base of the PR and between 75ef999 and 6223813.

📒 Files selected for processing (1)
  • tests/e2e/helpers/docker-ssh-relay-connection.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/helpers/docker-ssh-relay-connection.ts

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


📝 Walkthrough

Walkthrough

The Docker SSH relay helper now derives authority from current store state and waits for a connected authority when needed. Worktree hydration now retries authoritative fetches with live-authority validation and a 250 ms backoff for up to 60 seconds. The SSH-compatible agent title test now uses the shared connectDockerSshRelayTarget helper.

Merge Risk: 🔵 Low · up to 62238

The E2E helper now waits for a live SSH authority, but worktree data from an older authority may still be accepted if the connection rotates during hydration, potentially causing stale test setup. The PR is mergeable with explicit owner awareness and follow-up on this bounded correctness risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description gives detailed change, defect, scope, and validation information. However, it conflicts with the provided changeset summary and objectives about the shared helper retry loop, and it om… Align the description with the actual changeset and PR objectives. Restore the required template sections, provide a linked issue, add Visual Proof or state N/A with a reason, and complete the testing, review, notes, and checklist items.
✅ 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 accurately describes the removal of the stale private Docker-SSH connection helper, but it does not mention the shared-helper hydration and authority changes identified as the main PR object…
Full details: Title check

Explanation

The title accurately describes the removal of the stale private Docker-SSH connection helper, but it does not mention the shared-helper hydration and authority changes identified as the main PR objective. It remains clearly related to a real part of the changeset.

Full details: Description check

Explanation

The description gives detailed change, defect, scope, and validation information. However, it conflicts with the provided changeset summary and objectives about the shared helper retry loop, and it omits required template content such as the Linked Issue, Visual Proof or explicit N/A, Review, Notes, and Checklist sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c869497e-26be-4273-8576-ed78de0c00f0

📥 Commits

Reviewing files that changed from the base of the PR and between 65dd06a and b72b80eceb302808c79b93f4dad02be21353e9c0.

📒 Files selected for processing (2)
  • tests/e2e/helpers/docker-ssh-relay-connection.ts
  • tests/e2e/ssh-pi-compatible-agent-title.spec.ts

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

@brennanb2025
brennanb2025 force-pushed the brennanb2025/e2e-pi-title-unblock-r1 branch from 349b0dc to 50bb853 Compare August 28, 2026 12:44

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c6b1aa2f-901a-4357-bb26-66ebc0d46871

📥 Commits

Reviewing files that changed from the base of the PR and between b72b80eceb302808c79b93f4dad02be21353e9c0 and 50bb853.

📒 Files selected for processing (1)
  • tests/e2e/helpers/docker-ssh-relay-connection.ts

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop — round 1 (adversarial pass + rebase)

Reviewed at 349b0dc895, rebased onto current origin/main (94e7586665) and re-reviewed. One defect found and fixed, plus one hygiene change. Head is now 75ef999abb. Verdict: patch, not supersede.

Did it pass by weakening the spec? No.

The per-attempt acceptance check is byte-identical to the one it replaced — all seven conjuncts survive verbatim (status, repoId, authority.kind, executionHostId, targetId, providerEpoch, connectionGeneration). The only change is the failure action: throw became record reason; sleep 250ms; continue. The loop widens when setup gives up, never what it accepts.

One fixture property was deliberately dropped: the old code pinned hydration to the authority returned by ssh.connect() and threw if the store moved off it. The spec asserts on OSC-title classification and has no stake in which connection generation the listing was hydrated against — only that it was authoritative. Correct trade.

The deletion is also a strictness improvement: the deleted fork called fetchWorktrees(repoId) with no options and took worktreesByRepo[id][0]; the shared helper requires requireAuthoritative: true, an explicit authority, and finds by hostId === executionHostId.

Defect found and fixed

The load-bearing Why comment documented a mechanism that cannot execute on this code path. It described fetch-worktrees.ts:72-79 ("resolves no authority at all → writes nothing → empty list"), but that branch requires !directSshAuthority, and the shared helper always supplies one. That was the failure mode of the deleted fork, not of the helper.

The mechanism the loop actually handles is different: a caller authority that rotates mid-flight makes isCurrentDetectedWorktreeRefresh refuse the merge and return status: 'stale', which trips the !== 'complete' check. Comment corrected to the reachable mechanism, keeping "cause unknown".

Deletion safety — proven

grep -rn "connectDockerRemote" tests/ src/ returns hits only in ssh-codex-reconnect-replay-driver.ts — a different, exported function. The deleted one was file-private (confirmed: no export on main). Page and DockerSshRelayTarget are still imported and used; oxlint clean, no unused-import diagnostic.

Behavioural delta vs the deleted fork: relayGracePeriodSeconds identical — the helper applies ?? 1 in the outer argument object (:237), the same default that is already on origin/main, and this PR's diff touches the field zero times. seedInitialTab identical, host an improvement (the fork hardcoded 127.0.0.1 and ignored ORCA_E2E_SSH_TARGET_HOST), authority handling stricter. Label/display-name changes are cosmetic — the spec asserts only on terminal.agentStatus and terminal output, never on either.

Other findings

  • TDZ on unsubscribe: safe, but hoisted anyway (75ef999abb). A macrotask cannot run before the synchronous promise executor completes, including for the setTimeout(fn, 0) case, so there was no reachable ReferenceError. It was latent precisely because the timeout arm is the failure path, so the binding is now hoisted with an optional call. Recorded as hygiene, not a bug fix — and it trades a hypothetical ReferenceError for a hypothetical missed unsubscribe. Note waitForRepoOwner just above has the identical shape on main and was deliberately left alone as out-of-scope, so the file is now internally inconsistent on this pattern.
  • Subscription cleanup verified on every exit path, including the outer loop's continue: waitForLiveAuthority is awaited and both resolution paths tear down before resolving, so at most one subscription exists at a time. No leak.
  • typeof generation !== 'number' is dead as a runtime gate — Number.isSafeInteger subsumes it, so it can never be the sole reason for returning null. It survives legitimately as a TypeScript narrowing device. generation < 0 is not subsumed and is genuinely independent.
  • Scope of the shared-helper change — checked, and it is narrower than it looks. The helper has ~33-37 real invocations across ~24 specs (a raw grep overcounts: it catches imports and the differently-named reconnectDockerSshRelayTarget/disconnectDockerSshRelayTarget). More importantly the new loop is the fifth failure gate, after Store unavailable, SSH target did not connect, incomplete authority, addRemote error, and a 15s waitForRepoOwner. A systematically broken fixture still dies at gates 1-4 exactly as fast as before; the 60s is reachable only when SSH connected with a complete authority, addRemote succeeded and the owner hydrated, but the listing still will not go authoritative — i.e. precisely the targeted bounce. On the happy path the loop exits on iteration 1 with zero added latency.
  • Recommendation: keep the retry in the shared helper rather than making it opt-in. The bounce is a property of the fixture (relay deployment against a fresh container), which all consumers do identically; a second, independently-written 30s expect.poll for the same symptom already exists in ssh-codex-reconnect-replay-driver.ts, which is two independent encounters rather than conjecture; and an opt-in default would leave the shared helper with a known-broken default for every other consumer to rediscover — the fragmentation that produced three forks of this function to begin with.
  • A fast-fail taxonomy for "definitively failed" statuses was considered and rejected on evidence. ambiguous-owner looks terminal but is produced in the main process (host-qualified-worktree-listing.ts:62-64) while waitForRepoOwner only waits on the renderer store, so it can be transient across that gap. Production already made this call: direct-ssh-worktree-refresh-scheduler.ts:128-131 collapses authority-unknown and ambiguous-owner into non-authoritative and retries. The undifferentiated retry matches product policy.
  • Diagnosability — the one open recommendation. The spec's nested ceilings already sum to ~255s against a 360s test.slow() budget, so a full-deadline hydration will likely surface as an opaque Playwright timeout rather than the helper's constructed No remote worktree found ...: <reason> message. 60s is inside the file's existing vocabulary (15s, 30s, 45s, 60s all appear) but has no stated basis. Suggest measuring the real settle time and sizing to it — 30s matches the existing precedent for the same operation. Deliberately not changed here: guessing wrong introduces flake across every consumer, and that needs the lane run nobody could do.
  • A product gap this PR's premise is evidence for, which nobody has filed. An SSH repo added while the transport bounces gets one authoritative fetch (project-added-default-checkout.ts), and nothing re-lists worktrees on reconnect (direct-ssh-state-ipc-bridge.ts has zero worktree hits). So: add a remote SSH project during a bounce → no worktrees, and nothing recovers until restart. The no-write policy itself is correct per docs/reference/ssh-execution-boundary.md; the missing re-hydration is the gap. Recommend filing it so a real bug is not buried in a green test.
  • A third copy of this setup still lives in tests/e2e/ssh-codex-reconnect-replay-driver.ts, already papering over the same flake with a cruder expect.poll. Converging it is the greenfield answer but out of scope here.

Gates

pnpm tc clean · oxlint clean on both changed files · git diff --check clean · tsc -p config/tsconfig.e2e.json neutral (208 errors at head, 208 on origin/main, zero in either changed file) · formatted with npx oxfmt --write on changed paths only · no max-lines disable, no suppressions, no node:child_process import.

Not verified — stated plainly

The e2e was never executed. There is no runtime evidence for or against this PR. Docker's Linux VM backend is dead on this host (docker info → Server: ERROR: ... EOF; docker images/ps/buildx ls all EOF). A full pnpm build + build:native + Playwright setup got as far as globalSetup, which died on docker build ... : ERROR: failed to build: EOF. The engine was not restarted, because other agents hold containers in this session. So the spec was not observed failing at the parent commit or passing at the head, and every ablation row is a structural argument, not an observed red.

Also unverified: the cause of the transport bounce (unknown to the PR and to this review — not invented); whether 60s is the right deadline; the other 22 specs that share this helper.

Framing note

The Docker-SSH specs had no CI lane until #16746 — the commit immediately preceding this one on this file. A red here is very likely the first time the spec ever ran, not a regression. Nothing above should be read as describing one.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop follow-up — final head 62238138a3

Two further commits since the comment above, both after challenge:

  • 75ef999abb — hoists the waitForLiveAuthority unsubscribe binding. Hygiene, not a bug fix: the original had no reachable ReferenceError, since a macrotask cannot run before the synchronous promise executor completes. It was worth changing only because the affected arm is the failure path, so a future refactor would have broken it invisibly. Note it trades a hypothetical ReferenceError for a hypothetical missed unsubscribe, and that waitForRepoOwner just above has the identical shape on main and was deliberately left alone — the file is now internally inconsistent on this pattern.
  • 62238138a3 — labels the 60s deadline as what it actually is:
    // 60s is a conservative bound, not a measured settle time: nobody has timed the bounce.
    // Every consumer of this helper pays it on the failing path, so size it down once the
    // real settle time is known.
    
    It was deliberately not reduced to 30s. That would be a behavioural change to every consumer justified by nothing measurable, and being wrong in that direction converts a working retry into lane-wide flake — worse than the ergonomics cost it would fix.

On whether the retry should have been opt-in

I pushed on this and was talked out of it, on evidence. Leave it in the shared helper. The bounce is a property of the fixture — relay deployment against a fresh container — which every consumer does identically, so the only thing an opt-in would key on is which spec's author hit the flake first. The per-attempt acceptance criterion is byte-identical, so the retry cannot turn a real product failure green; it only changes how long setup waits before giving up on itself. And a third fork of this setup already wraps its listing in a 30s poll for the same symptom, written independently by a different author — per-spec opt-in is the policy that produced three forks of this function in the first place.

I also proposed a fast-fail taxonomy separating "definitively failed" from "transiently reconnecting" statuses, and that was correctly refuted: ambiguous-owner is produced in the main process while waitForRepoOwner only waits on the renderer store, so it can be transient across that gap — and production already collapses authority-unknown and ambiguous-owner into non-authoritative and retries. The undifferentiated retry matches product policy; a fixture-only taxonomy would diverge from it for no benefit.

Recommendations to the author, in priority order

  1. Time the bounce, size the deadline to it with headroom, and delete the "conservative bound" note once it reflects a measurement.
  2. Independently of that, either lower the deadline or raise this spec's budget so a full-deadline failure can actually surface lastHydrationFailure instead of an opaque Playwright timeout (~255s of nested ceilings against a 360s budget).
  3. File the product gap described above — no reconnect-driven re-listing, single-shot authoritative fetch in the add-project handoff. It should not stay recorded only as a comment in a test helper.
  4. Converge the third fork (ssh-codex-reconnect-replay-driver.ts) onto this helper in a separate PR.

Verdict unchanged: patch, not supersede. Still not merged, approved, or closed — that is Brennan's call.

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

♻️ Duplicate comments (2)
tests/e2e/helpers/docker-ssh-relay-connection.ts (2)

185-206: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Re-check the live authority after fetchWorktrees.

authority is captured before the await. Lines 190-197 compare the result only with that captured value. If the connection rotates before worktree selection, the old result can pass and a stale worktree can become active. Derive liveAuthority() after fetchWorktrees and require it to match the result before accepting the worktree.

Suggested check
           const worktreeResult = await store.getState().fetchWorktrees(result.repo.id, {
             executionHostId,
             directSshAuthority: authority,
             requireAuthoritative: true
           })
+          const currentAuthority = liveAuthority()
+          const authorityIsCurrent =
+            currentAuthority?.targetId === authority.targetId &&
+            currentAuthority?.providerEpoch === authority.providerEpoch &&
+            currentAuthority?.connectionGeneration === authority.connectionGeneration
           if (
             worktreeResult.status !== 'complete' ||
+            !authorityIsCurrent ||
             worktreeResult.repoId !== result.repo.id ||

176-200: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Keep the hydration request inside hydrationDeadline.

The loop checks the deadline only before fetchWorktrees. A request that starts near the deadline can remain pending after 60 seconds because this call has no visible remaining-time cancellation. The unconditional 250 ms backoff adds further overshoot. Pass the remaining timeout through the worktree-listing cancellation path and release its request lease when the deadline expires.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2da03e7f-001c-4e0d-8090-ec7268249487

📥 Commits

Reviewing files that changed from the base of the PR and between 50bb853 and 75ef999.

📒 Files selected for processing (1)
  • tests/e2e/helpers/docker-ssh-relay-connection.ts

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review — the fork deletion is right; the retry loop should be split out

Reviewed at head 62238138a3 (0 commits behind main). Docker is dead on this machine, so I did not run these specs locally — all runtime evidence below is CI logs and source.

The root cause holds up

Confirmed independently: a40183389b (#11003, 2026-07-28) modified tests/e2e/helpers/docker-ssh-relay-connection.ts (+80) alongside worktrees.ts and ssh-types.ts, and touched ssh-pi-compatible-agent-title.spec.ts zero times. The spec kept a private fork.

The mechanism is precise. The fork called fetchWorktrees(repoId) with no options, so it depended on getCurrentDirectSshAuthority resolving at that instant (direct-ssh-authority.ts:21-43 returns null unless status === 'connected' with a complete epoch/generation). When it returns null, fetch-worktrees.ts:70-77 calls fetchKnownSshWorktreesForRepo and returns false — and the fork then read [0], which is undefined. The fork had an await fetchRepos() immediately before, which is exactly the window for an IPC event to perturb sshConnectionStates.

The shared helper passes directSshAuthority explicitly, so directCallerAuthority is set and that short-circuit is structurally unreachable. That is why the shared helper's guard errored 0 times across ~130 connects while No remote worktree found hit only via the fork.

The four blocked PRs fail on exactly this

All of #16336, #16901, #16915, #16926 fail the lane on ssh-pi-compatible-agent-title.spec.ts with Error: No remote worktree found for /tmp/orca-docker-relay-perf-repo. That message has no : suffix, so it is the fork's string, not the shared helper's. (#16336 additionally fails the cold-hydration spec, which #17031 covers.)

The fork replacement is faithful: the helper defaults relayGracePeriodSeconds ?? 1 (matching the fork's explicit 1), remotePath defaults to DOCKER_SSH_RELAY_REMOTE_REPO_PATH, and seedInitialTab ?? true. Its .find(c => c.hostId === executionHostId) is strictly more correct than the fork's [0].

This half is correct and I recommend it lands.

Why I'd split the 60s retry loop out

To be clear about what is not wrong with it: the loop does not weaken the fence — every attempt still requires a full authority match on all five fields — and its shape is idiomatic here (deadline + while is already used in tests/e2e/helpers/docker-ssh-relay-target.ts at 90s and 60s, and expect.poll is unavailable inside page.evaluate). waitForLiveAuthority is properly event-driven via store.subscribe, and I found no leak: both arms unsubscribe and clear the timer.

The objections are evidentiary and blast-radius:

  1. Its stated justification is a hypothesis that was refuted. The in-code comment blames "something in setup bounces the SSH transport". That ~0.5s close is the spec's own finally calling docker rm -f; the Playwright trace dates the throw ~0.1s earlier than the drop. The comment also concedes "cause unknown" and "60s is a conservative bound, not a measured settle time".

  2. The fork deletion does not need it — proven, not argued. I built a fork-deletion-only branch (the spec change against main's helper, +2/-75, helper untouched), pushed it, and ran the Docker-SSH lane on it by workflow_dispatch. It typechecks and lints clean, its build e2e app succeeded, and the lane came back green, with the pi-title spec running at its fork-deleted line 74:7 and the suite reporting 18 passed / 1 skipped / 0 failed. The two halves are independent, and the half that fixes the lane is the fork deletion.

  3. CI cannot see the risky half. Running the PR's own changed paths through the router:

    #17017 paths  → ["tests/e2e/ssh-pi-compatible-agent-title.spec.ts"], ssh_source_changed=false
    helper-only   → []                                                 , ssh_source_changed=false
    

    selectPrE2eSpecs seeds only from /^tests\/e2e\/.*\.spec\.ts$/ and every route requires ^src/, so a tests/e2e/helpers/ edit routes zero specs and skips the Docker-SSH lane. The helper has 23 consumers; CI validated one, and only because that spec was independently edited.

  4. It can erase the error it is meant to produce. tests/playwright.config.ts:22 sets timeout: 120_000. Six consumer specs set no test.setTimeout and run on that budget — ssh-skill-installation, ssh-docker-reconnect-pane-restore, ssh-external-image-preview, ssh-docker-watcher-isolation (2 call sites), ssh-port-forward-lifecycle, ssh-reconnect-tab-destruction. After Electron cold start + Docker + SSH connect, a 60s helper loop can be truncated by the test timeout, replacing the named No remote worktree found for X: <reason> with an opaque Test timeout of 120000ms exceeded. tests/playwright.config.ts:34 also sets retries: 0 with a comment that this is deliberate so first-failure traces stay the only reliable artifact.

  5. No fast-fail arm. When the listing comes back complete and authoritative but simply carries no worktree for the host — not obviously transient — the loop re-fetches every 250ms for the full 60s, on the order of 100+ real listing round-trips against a live SSH host, where main failed immediately.

  6. It silently drops a diagnostic. main threw SSH authority rotated before worktree hydration when the authority changed between connect and hydration. The PR adopts the rotated authority instead. That guard never fired in ~130 connects, so removing it costs nothing today — but it is the one probe that would reveal rotation, on a lane being debugged for exactly this class of problem.

One minor defect in the loop, if it does stay

waitForLiveAuthority returns null on exactly one path — its own timer, armed to the overall hydrationDeadline — so the break arm only ever runs at the 60s mark, yet it overwrites lastHydrationFailure with 'SSH target never reported a connected authority'. On iteration 2 or later that is provably false (iteration 1 consumed a live authority), and it clobbers the specific repeated diagnostic from earlier attempts. Preserve or append the prior failure there.

For the record, I looked hard for worse and did not find it: no missed wakeup (the Promise executor is synchronous, and zustand's subscribe neither fires at registration nor replays), no subscription leak in either arm, no busy spin (every retry path awaits 250ms), no unsettled promise, and no TypeError on .authority.kind (status !== 'complete' short-circuits first).

Separately, and not introduced here: fetchWorktrees can return undefined when providerResult is absent on an admitted refresh (worktree-slice-types.ts:37 optional, detected-worktree-refresh.ts:174-181 returns admitted without it, fetch-worktrees.ts:115 non-null-asserts it). main's helper does the identical worktreeResult.status read, so this PR neither creates nor worsens it, and it needs an active runtime environment the Docker-SSH fixture never sets. Worth a separate follow-up.

Recommendation: land the fork deletion now; take the retry loop separately, and if it is still wanted, give it a fast-fail arm and derive its deadline from the remaining test budget rather than a flat 60s. Brennan owns the call.

Dispatch evidence

workflow_dispatch is the only way to exercise this lane. I ran it four times on the fork-deletion-only branch and twice more on this PR:

branch lane runs result
fork-deletion-only probe 4 3 green; the 1 red was not the pi-title spec
this PR (62238138a3) 2 (plus 2 earlier) 4 green

The pi-title spec passed in all four probe runs. The single probe red was ssh-cold-hydration-gap-tab-seeding.spec.ts — the spec #17031 covers, which that branch deliberately does not include — failing with tabs changed once the stalled snapshot landed: baseline=3 duringStall=3 afterHydration=0.

So the lane's two failure modes separate cleanly: the pi-title fork (this PR) and the cold-hydration capture (#17031). Neither result depends on the retry loop.

Gates

pnpm run typecheck exit 0, oxlint exit 0 (zero findings), oxfmt --check clean, git diff --check clean. No node:child_process import added. The type-only DirectSshAuthority import is well-precedented (116 e2e files import types from src/shared).

Note for whoever merges: this PR's own e2e / ssh docker watcher isolation check shows skipping — the lane it fixes does not run on it, per the routing above.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Correction to point 4 above, and a narrowing of point 3

Point 4 was wrong as I stated it. I claimed six consumer specs run the 60s loop inside a 120s budget. They do not. All six call test.slow() before the connect call — ssh-skill-installation:57, ssh-docker-reconnect-pane-restore:64, ssh-external-image-preview:113, ssh-docker-watcher-isolation:110, ssh-port-forward-lifecycle:56, ssh-reconnect-tab-destruction:65 — and playwright/lib/worker/timeoutManager.js:112 triples the slot (slot.timeout = slot.timeout * 3), giving them an effective 360s, not 120s.

One case does survive, and it is the tightest in the set: tests/e2e/ssh-startup-exec-readiness.spec.ts:32 sets test.setTimeout(150_000) with no test.slow(), and connects at :43. A full 60s burn there is a real risk of truncating the named error into an opaque timeout. So: one spec, not six.

Worth adding for fairness: the 60s is paid only on the failing path. waitForLiveAuthority returns immediately when the target is already connected, and the loop exits on the first authoritative listing, so there is no happy-path cost to the lane.

Point 3 also narrows. The routing blind spot is real and I re-proved it, but it is bounded rather than permanent: e2e.yml runs on schedule: '0 17,22 * * *', and the Docker-SSH lane's first clause is inputs.test_files == '', so all 23 consumers do run twice daily on main. Detection latency is ~12h, not "never". The weakness is attribution, not coverage — pr.yml records the e2e suite as already red on main every scheduled run, so a new helper-caused red there would be hard to pick out.

The recommendation is unchanged. It never rested on the timeout argument. It rests on: the fork-deletion-only branch clearing the lane on its own (pi-title green in all 4 runs), the retry loop's in-code justification being a refuted hypothesis, the absence of a fast-fail arm, and the fact that the loop's own PR CI cannot exercise the 23 consumers it changes. Points 3 and 4 were supporting, and both are weaker than I first wrote them.

`ssh-pi-compatible-agent-title.spec.ts` kept a private `connectDockerRemote`
that predates #11003. Commit a401833 gave `fetchWorktrees` a host-qualified
authority gate that short-circuits to `return false` for an SSH host with no
complete `directSshAuthority`, and updated the shared
`connectDockerSshRelayTarget` helper in the same commit -- but never touched
this spec. The fork still does `fetchRepos()` -> bare `fetchWorktrees(repoId)`
-> `worktreesByRepo[repoId][0]`, so the fetch short-circuits, the listing is
empty, `[0]` is undefined, and setup throws
`No remote worktree found for /tmp/orca-docker-relay-perf-repo` before the
spec reaches a single title assertion.

Differential across 5 lane runs (~130 SSH connects): the shared helper's guard
errors fired 0 times; `No remote worktree found` fired 3 times, always via the
fork. The fork accounts for 6 of 7 failures on `e2e / ssh docker watcher
isolation`.

The spec now calls the shared helper. Every helper default matches what the
fork passed (`relayGracePeriodSeconds: 1`, `remotePath`
DOCKER_SSH_RELAY_REMOTE_REPO_PATH, `seedInitialTab` true, port `target.port`);
the helper additionally uses `target.host` rather than a hardcoded
`127.0.0.1`, which is the correct value under `ORCA_E2E_SSH_TARGET_HOST`.

No assertion changed; no retry, sleep, or timeout was added anywhere.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/e2e-pi-title-unblock-r1 branch from 6223813 to e8a9988 Compare August 28, 2026 18:04
@brennanb2025 brennanb2025 changed the title fix(e2e): hydrate the Docker-SSH worktree list against a live authority fix(e2e): drop the pi-title spec's stale private Docker-SSH connect fork Aug 28, 2026
@brennanb2025

brennanb2025 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Split — the retry loop is out; the fork deletion stands alone

Head is now e8a9988b6f254e405f7038416adc3c0547133c5f, rebased onto origin/main
(ee1e002d00). Previous head was 62238138a399f27548cd36986fca74e8a6b1bbe9; force-pushed with
--force-with-lease pinned to that SHA, with git ls-remote re-checked immediately before and
after.

What changed

before (62238138a3) after (e8a9988b6f)
Files 2 1
Diffstat +102 / −110 +2 / −75
tests/e2e/helpers/docker-ssh-relay-connection.ts +128 / −? untouched — blob a17ad916e6, byte-identical to main
tests/e2e/ssh-pi-compatible-agent-title.spec.ts blob 5cea70a9bf blob 5cea70a9bf — unchanged from the previous head

The spec half is byte-identical to what was already reviewed here; only the shared-helper half was
dropped. git diff origin/main HEAD -U0 shows exactly two added lines:

+import { connectDockerSshRelayTarget } from './helpers/docker-ssh-relay-connection'
+      const remote = await connectDockerSshRelayTarget(orcaPage, target)

Zero occurrences of eslint-disable / oxlint-disable / max-lines / @ts-ignore /
@ts-expect-error / setTimeout / sleep / retry anywhere in the diff. No retry, sleep, or
timeout was added as compensation for removing the loop.

No assertion changed. Diffing the entire test.describe block against main yields exactly one
differing line — the connect call:

14c14
<       const remote = await connectDockerRemote(orcaPage, target)
---
>       const remote = await connectDockerSshRelayTarget(orcaPage, target)

All three expect.poll(...).toMatchObject({ isRunningAgent, status }) assertions (OMP working, OMP
ready, Pi working), their 10s poll timeouts and their failure messages are byte-identical.

Why the loop was removed

Its stated justification — a "~0.5s post-deploy transport bounce" — was refuted in
the review above, point 1.
That [ssh] Reconnecting … failed handshakes 0/9 line is the spec's own finally calling
cleanupDockerSshRelayTarget → docker rm -f
(tests/e2e/helpers/docker-ssh-relay-target.ts:287), which deletes the container the transport is
connected to. In run 33175867485 the
Playwright trace dates the spec's throw ~0.1s earlier than the drop, and the gap is not fixed at
0.5s — across passing runs it is 1.4s / 3.4s / 12s / 27s, tracking each spec's body length.
failed handshakes 0/9 means the transport was healthy right up to deletion. There is no
product-side drop, so the loop compensated for nothing.

Log adjacency alone could not have settled this: teardown noise sits next to every test's last real
event. It took a trace timestamp for the spec's own throw.

The 4-run experiment that decided it

Rather than argue the two halves apart, a fork-deletion-only branch was built
(brennanb2025/e2e-pi-title-forkonly-probe @ 2c5a8c8cd1, spec change against main's helper,
+2/−75, helper untouched) and the lane was run on it four times by workflow_dispatch — the
only way to reach it.

e2e / ssh docker watcher isolation, all four at 2c5a8c8cd1:

Run Job Lane pi-title spec Suite
33185192081 98897630158 success ✓ ssh-pi-compatible-agent-title.spec.ts:74:7 (24.1s) 18 passed
33185197126 98897777915 success ✓ 74:7 (24.5s) 18 passed
33185202362 98898004449 failure ✓ 74:7 (24.5s) 17 passed, 1 failed
33185207547 98898006317 success ✓ 74:7 (24.0s) 18 passed

Lane: 3 of 4 green. The pi-title spec: 4 of 4 green. Verified from the job logs directly, not
from the run-level conclusion — the run-level failure on all four is unrelated sharded e2e N-of-10
jobs that a full workflow_dispatch runs and a PR does not (browser-split-find-shortcut,
artificial-opencode-terminal-load, automation-prompt-disclosure, … — none reachable from a
test-only edit to one Docker-gated spec).

The single lane red was ssh-cold-hydration-gap-tab-seeding.spec.ts:158
(baseline=3 duringStall=3 afterHydration=0) — the spec #17031 covers, which this branch
deliberately does not include. Baseline for scale: the lane measured 22 pass / 7 fail (76%)
across 29 decided runs since #16746, with the pi-title fork accounting for 6 of the 7 failures.

So the fork deletion alone clears the lane, and the loop's contribution is not measurable.

Blast radius the loop carried, and this PR does not

  • selectPrE2eSpecs seeds only from /^tests\/e2e\/.*\.spec\.ts$/ and every route requires
    ^src/, so a tests/e2e/helpers/ edit routes zero specs and skips the Docker-SSH lane.
    The helper has 24 consumer files; a helper-only diff validates none of them. CI structurally
    could not have exercised the risky half.
  • tests/playwright.config.ts:22 sets a 120s default and :34 sets retries: 0 deliberately, so
    first-failure traces stay the only reliable artifact.
    tests/e2e/ssh-startup-exec-readiness.spec.ts:32 sets test.setTimeout(150_000) with no
    test.slow() and connects at :43 — a full 60s burn there would have replaced the named
    No remote worktree found for X: <reason> with an opaque test timeout.

Gates at e8a9988b6f

pnpm tc exit 0 · changed-code quality gate (oxlint + type-aware + React Doctor) 0 new findings
across 1 changed file
· oxfmt --check clean · git diff --check clean · typecheck:e2e
208 → 208 errors, measured in both directions by swapping the file back to main's version
(it is red on main for unrelated reasons; none of the 208 name this spec).

Four fresh workflow_dispatch E2E runs are in flight at e8a9988b6f; results to follow. Docker is
dead on this machine, so nothing was run locally.

Not touched: #17031, and #16336 / #16901 / #16915 / #16926.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Dispatch results at e8a9988b6f — 4 of 4 lanes green

e2e / ssh docker watcher isolation, four workflow_dispatch runs, all at head
e8a9988b6f254e405f7038416adc3c0547133c5f (head SHA confirmed per run, not assumed from the branch
name):

Run Job Lane pi-title spec Suite
33197732254 98939852826 success ✓ ssh-pi-compatible-agent-title.spec.ts:74:7 (24.8s) 2 + 5 + 18 passed, 0 failed
33197734527 98940128160 success ✓ 74:7 (23.5s) 2 + 5 + 18 passed, 0 failed
33197737144 98940141029 success ✓ 74:7 (24.8s) 2 + 5 + 18 passed, 0 failed
33197738900 98940331034 success ✓ 74:7 (25.2s) 2 + 5 + 18 passed, 0 failed

All three lane steps green in every run — including Run remaining Docker SSH E2E, the step that
contains this spec and the step that was red on #16901.

Combined evidence

Branch Lane runs Lane green pi-title green
fork-deletion-only probe (2c5a8c8cd1) 4 3 4 / 4
this PR (e8a9988b6f) 4 4 4 / 4
total 8 7 8 / 8

Against the pre-fix baseline of 22 pass / 7 fail (76%) across 29 decided runs since #16746 —
where the pi-title fork accounted for 6 of the 7 failures — 8/8 on the spec is not a lucky
green. The single red across all eight lane runs was ssh-cold-hydration-gap-tab-seeding.spec.ts:158
on the probe branch, which #17031 covers and which is untouched here.

Note the asymmetry that makes this meaningful: the retry loop was never the variable. The probe
branch had main's helper verbatim and still passed pi-title 4/4, so the loop's contribution
remains unmeasurable in either direction.

PR's own CI

Everything that runs is green — typecheck, static analysis, all 8 unit shards,
e2e / changed e2e specs, e2e / build e2e app, verify, test vs non-test LoC, both guards.

As documented in the body, e2e / ssh docker watcher isolation reports skipping on this PR:
ssh_source_changed is false for a test-only diff and the lane's if names only two specs by
hand, so the lane this fixes does not run on it. The eight dispatch runs above are the validation
of record. That gating gap is a separate defect and is not fixed here.

Nothing was papered over

Removing the 60s loop made nothing flaky: 0 failures across all four runs at this head, and 4/4 on
the spec across the probe runs that also lacked it. No retry, sleep, or timeout was added anywhere.

Head is e8a9988b6f254e405f7038416adc3c0547133c5f; git ls-remote re-confirmed it after the runs
settled, so nothing moved underneath this. Merging is Brennan's call.

@brennanb2025
brennanb2025 merged commit 774ce22 into main Aug 28, 2026
54 of 80 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
…ai#17017)

`ssh-pi-compatible-agent-title.spec.ts` kept a private `connectDockerRemote`
that predates stablyai#11003. Commit a401833 gave `fetchWorktrees` a host-qualified
authority gate that short-circuits to `return false` for an SSH host with no
complete `directSshAuthority`, and updated the shared
`connectDockerSshRelayTarget` helper in the same commit -- but never touched
this spec. The fork still does `fetchRepos()` -> bare `fetchWorktrees(repoId)`
-> `worktreesByRepo[repoId][0]`, so the fetch short-circuits, the listing is
empty, `[0]` is undefined, and setup throws
`No remote worktree found for /tmp/orca-docker-relay-perf-repo` before the
spec reaches a single title assertion.

Differential across 5 lane runs (~130 SSH connects): the shared helper's guard
errors fired 0 times; `No remote worktree found` fired 3 times, always via the
fork. The fork accounts for 6 of 7 failures on `e2e / ssh docker watcher
isolation`.

The spec now calls the shared helper. Every helper default matches what the
fork passed (`relayGracePeriodSeconds: 1`, `remotePath`
DOCKER_SSH_RELAY_REMOTE_REPO_PATH, `seedInitialTab` true, port `target.port`);
the helper additionally uses `target.host` rather than a hardcoded
`127.0.0.1`, which is the correct value under `ORCA_E2E_SSH_TARGET_HOST`.

No assertion changed; no retry, sleep, or timeout was added anywhere.

(cherry picked from commit 774ce22)
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ai#17017)

`ssh-pi-compatible-agent-title.spec.ts` kept a private `connectDockerRemote`
that predates stablyai#11003. Commit 57d3b79 gave `fetchWorktrees` a host-qualified
authority gate that short-circuits to `return false` for an SSH host with no
complete `directSshAuthority`, and updated the shared
`connectDockerSshRelayTarget` helper in the same commit -- but never touched
this spec. The fork still does `fetchRepos()` -> bare `fetchWorktrees(repoId)`
-> `worktreesByRepo[repoId][0]`, so the fetch short-circuits, the listing is
empty, `[0]` is undefined, and setup throws
`No remote worktree found for /tmp/orca-docker-relay-perf-repo` before the
spec reaches a single title assertion.

Differential across 5 lane runs (~130 SSH connects): the shared helper's guard
errors fired 0 times; `No remote worktree found` fired 3 times, always via the
fork. The fork accounts for 6 of 7 failures on `e2e / ssh docker watcher
isolation`.

The spec now calls the shared helper. Every helper default matches what the
fork passed (`relayGracePeriodSeconds: 1`, `remotePath`
DOCKER_SSH_RELAY_REMOTE_REPO_PATH, `seedInitialTab` true, port `target.port`);
the helper additionally uses `target.host` rather than a hardcoded
`127.0.0.1`, which is the correct value under `ORCA_E2E_SSH_TARGET_HOST`.

No assertion changed; no retry, sleep, or timeout was added anywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant