Skip to content

test(e2e): make the cold-hydration spec check its own captured snapshot - #17031

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/e2e-harness2-r1
Aug 30, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/e2e-harness2-r1

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34
Prod 0 0 0 0

Fixes the ssh-cold-hydration-gap-tab-seeding spec so it checks its own precondition instead of failing downstream.

ELI5

This test captures a session snapshot, relaunches, replays the snapshot, and then checks that the tabs came back. If the capture happened to be empty, the test still sailed through the replay and only fell over much later, on afterHydration=0 — which reads exactly like the product losing your tabs. It wasn't. The test just never looked at what it had captured.

Now it asserts the captured snapshot before the relaunch that replays it, so an empty or unparseable capture fails right there and names itself.

Why the old failure was not a product bug

Traced through product code: an empty session places nothing, therefore reports nothing unplaced, therefore marks hydrated and replaces the worktree's tabs with none. That reproduces the observed baseline=3 duringStall=3 afterHydration=0 exactly — and it is correct behaviour for a genuinely empty host snapshot.

Before / after

Before After
Capture is empty Fails late on afterHydration=0, indistinguishable from a real tab-loss regression Fails at the capture, naming the empty snapshot
Capture is good Unchanged Unchanged

What this is NOT

  • No assertion was weakened. The afterHydration expectation is untouched.
  • No retry, no sleep, no timeout bump. The fix is an added precondition, not a relaxed one.

Context

This spec accounts for 1 of 29 failures on the e2e / ssh docker watcher isolation lane. The dominant failure on that lane (6 of 7) is a separate stale connectDockerRemote fork, fixed by #17017.

Not verified

Docker is dead on the authoring machine (docker ps returns EOF; docker desktop restart fails with context deadline exceeded), so nothing was run locally — this rests on CI logs and source reading. pnpm tc, lint, the quality gate, and the ratchets are green.

`adds no tab when the host workspace snapshot stalls across a relaunch` replays
the bytes it reads off the relay, but only ever waited for the snapshot FILE to
exist -- never for it to carry the tabs the test had just seeded. A capture that
missed the baseline produced a failure that reads as a product regression and is
not one: an empty `session.tabsByWorktreePath` places nothing, so it reports
nothing unplaced, so `remote-workspace-snapshot-apply.ts` marks the target
hydrated and `hydrateTabsSession` replaces the worktree's tabs with none. That is
exactly the observed `baseline=3 duringStall=3 afterHydration=0`, and it is
correct behaviour for a host snapshot that genuinely holds no tabs.

Assert the precondition where it belongs -- on the capture, before the relaunch
that consumes it -- so an empty or unparseable fixture names itself instead of
surfacing later as a tab count the product appears to have lost.

No assertion is weakened: `afterHydration` still has to equal the baseline, and
no retry, sleep, or timeout was added.
@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: 53f545b0-4614-46d8-b3ce-c8ddcb932270

📥 Commits

Reviewing files that changed from the base of the PR and between 94e7586 and 3d0282a.

📒 Files selected for processing (1)
  • tests/e2e/ssh-cold-hydration-gap-tab-seeding.spec.ts

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


📝 Walkthrough

Walkthrough

The test now parses the persisted SSH workspace snapshot before the relaunch scenario. It returns null when the snapshot contains invalid JSON. It asserts that the snapshot is valid and includes every seeded baseline tab ID before continuing with relaunch assertions.

Merge Risk: 🔵 Low · up to 3d028

The PR only adds earlier validation to an E2E snapshot, leaving production behavior unchanged. It is mergeable with explicit owner awareness that remote snapshots must continue using tabsByWorktreePath so the test validates the intended captured tabs.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, change, rationale, scope, and verification limitations. However, it omits several required template sections, including What Changed, Linked Issue with an issue n… Complete the required template sections. Add a valid linked issue after “Fixes #”, provide Visual Proof or write “N/A” with a reason, document testing and platform coverage, complete the required checkboxes, and address the remaining requir…
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: updating the end-to-end test to validate its captured snapshot.
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.
Full details: Description check

Explanation

The description explains the problem, change, rationale, scope, and verification limitations. However, it omits several required template sections, including What Changed, Linked Issue with an issue number, Visual Proof or an explicit N/A statement, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Complete the required template sections. Add a valid linked issue after “Fixes #”, provide Visual Proof or write “N/A” with a reason, document testing and platform coverage, complete the required checkboxes, and address the remaining required 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review — looks right, no changes requested

Test-only, so the bar is higher rather than lower. Verified against current main (94e7586665): pnpm tc clean, oxlint clean, git diff --check clean.

The precondition does what it claims

The e2e itself needs Docker, but the added logic is pure over the captured bytes, so I ran it directly across the cases that matter, with each gate ablated alone:

capture both gates null-check alone ablated baseline-check alone ablated both ablated (pre-fix)
good (3 tabs) GREEN GREEN GREEN GREEN
empty session {} RED RED GREEN GREEN
empty tab array RED RED GREEN GREEN
partial (2 of 3) RED RED GREEN GREEN
superset (3 + other worktree) GREEN GREEN GREEN GREEN
unparseable bytes RED RED RED GREEN
empty string RED RED RED GREEN
non-string ids RED RED GREEN GREEN

That is the proof asked for: an empty capture fails only with the fix (last column is green throughout), and a good capture never fires — including the legitimate superset case where the snapshot holds other worktrees' tabs.

One honest note on the two assertions

They are not two independent gates. Everything the .not.toBeNull() assertion catches, the missing-baseline assertion also catches (column 2 is red wherever column 1 is), because capturedTabIds ?? [] makes unparseable bytes look like zero tabs. So the null check is diagnostic-only — it changes the failure message, not the outcome. That is a reasonable thing to keep, since "not parseable JSON" and "parsed but empty" are genuinely different failures to debug, but it should not be read as two layers of protection. The baseline check is the one carrying the weight.

No changes requested.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review — verified, no defects found

Reviewed at head 3d0282acda (0 commits behind main). Docker is dead on this machine, so I did not run this spec locally — every runtime claim below is from CI, and everything else is source-level or a standalone harness.

The precondition was verified in both directions

I copied capturedSnapshotTabIds verbatim into a standalone harness and fed it twelve capture shapes (baseline ['t1','t2','t3']):

capture result verdict
all baseline tabs ["t1","t2","t3"] passes — does not fire on a good capture
zero tabs / empty tab array [] fails at assert #2
missing some baseline tabs ["t1"] fails at assert #2
"" / not json null fails at assert #1
"null" null fails at assert #1 — parsed.session throws TypeError, correctly caught
tabs lacking id / no session / [] / tabsByWorktreePath: null [] fails at assert #2
extra tabs beyond baseline passes correct — the gate is "no baseline tab missing", not set equality

That last row matters: the assertion cannot flake on extra tabs. Assert #1 throws before assert #2, so the capturedTabIds ?? [] fallback is defensive only, not a vacuity.

It cannot red a healthy run on id-space grounds

I checked the concern that the relay might re-key tab ids on persist. It does not: tabToRemote (src/shared/remote-workspace-session-projection.ts:34-39) spreads ...rest, stripping only worktreeId/pendingActivationSpawn, so tab.id survives verbatim into session.tabsByWorktreePath[path][].id. remote.tabIds and the captured ids are the same id space.

Sequencing is also safe: tabs are seeded → waitForUploadedRemoteSnapshot → flushSessionBeforeQuit → restart.close(app) → then blockRemoteWorkspaceGet runs cat.

No assertion was weakened

The diff is strictly additive (+34/−0): nothing deleted, reordered, or loosened, and no retry, sleep, waitFor, or timeout added. It also cannot turn a failing run green — it only adds an earlier, better-named failure. On an empty capture the old spec already failed, but with a message blaming the product; this re-attributes it to the harness.

Live evidence

e2e / changed e2e specs on this PR actually ran the spec with ORCA_E2E_SSH_DOCKER=1: 2 passed, 1 skipped, and the test's line moved 158 → 180, consistent with the +22 inserted lines. So the new precondition ran against a real capture and correctly did not fire.

Gates

pnpm run typecheck exit 0, oxlint exit 0 (zero findings), oxfmt --check clean, git diff --check clean. The node:child_process import on line 1 is pre-existing on main; this PR adds no imports, so the import ratchet is untouched.

The condition this guards against happened live today

While running the Docker-SSH lane on a separate branch that deliberately does not include this PR, the spec failed like this:

Error: tabs changed once the stalled snapshot landed: baseline=3 duringStall=3 afterHydration=0

afterHydration=0 is exactly the signature this PR's doc comment describes: an empty capture places nothing, hydrates cleanly, and replaces the worktree's tabs with none. Note what the failure says — it blames the product ("tabs changed once the stalled snapshot landed"), pointing at a regression in hydration. With this PR applied, that run would instead have stopped earlier and named the real problem: the captured snapshot is missing part of the baseline it seeded.

To be precise about what this shows: afterHydration=0 is consistent with an empty capture, and the log alone cannot confirm the capture was empty — which is exactly the ambiguity this precondition removes. That is the argument for it. This is not a hypothetical failure mode; it is on this lane now.

One caveat, not a blocker

waitForUploadedRemoteSnapshot only polls for the snapshot file to exist, and flushSessionBeforeQuit polls local window.api.session.get() — neither waits for the final remote snapshot revision. A late remote patch would now red the spec rather than be waited out. That is still a net improvement (a named harness failure beats a misattributed product failure), but polling the file's contents for the baseline ids before restart.close(app) would be strictly better. Worth a follow-up, not a change here.

No defects found. This is a sound spec-precondition fix.

@brennanb2025
brennanb2025 merged commit f7d8d7f into main Aug 30, 2026
39 of 68 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…hot (stablyai#17031)

`adds no tab when the host workspace snapshot stalls across a relaunch` replays
the bytes it reads off the relay, but only ever waited for the snapshot FILE to
exist -- never for it to carry the tabs the test had just seeded. A capture that
missed the baseline produced a failure that reads as a product regression and is
not one: an empty `session.tabsByWorktreePath` places nothing, so it reports
nothing unplaced, so `remote-workspace-snapshot-apply.ts` marks the target
hydrated and `hydrateTabsSession` replaces the worktree's tabs with none. That is
exactly the observed `baseline=3 duringStall=3 afterHydration=0`, and it is
correct behaviour for a host snapshot that genuinely holds no tabs.

Assert the precondition where it belongs -- on the capture, before the relaunch
that consumes it -- so an empty or unparseable fixture names itself instead of
surfacing later as a tab count the product appears to have lost.

No assertion is weakened: `afterHydration` still has to equal the baseline, and
no retry, sleep, or timeout was added.
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