Skip to content

test(wsl): drive hook-relay reattach bench through real PTY spawn - #13260

Merged
AmethystLiang merged 2 commits into
mainfrom
bench/wsl-hook-relay-reattach-via-pty
Aug 8, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
bench/wsl-hook-relay-reattach-via-pty

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #13139 / CodeRabbit feedback: harden bench:wsl-hook-relay-reattach so it fails if the production integration in src/main/ipc/pty.ts is removed or miswired.

  • stop calling ensureWslHookRelayForReattach directly from the benchmark
  • load main's real registerPtyHandlers path under plain Node via a minimal electron stub
  • spawn a surviving WSL floating PTY, dispose the pre-restart relay, then reattach the same session id through ptyController.spawn
  • assert: fresh spawn does not refresh the relay; reattach refreshes exactly once for the owned distro; endpoint rewrite + full sample delivery still hold

Why

The #13139 bench could pass with only the helper + manager working. That missed the failure mode the product fix actually needed: the reattach call site in the PTY spawn path.

Test plan

  • node --check on both benchmark scripts
  • lint-staged (oxlint + oxfmt) on commit
  • Real WSL bench on Windows host (--distro Ubuntu --samples 20):
    • stale median 1659.9 ms (≥ ~1s timeout path) ✅
    • reattach delivery 20/20 ✅
    • refreshed p95 269.4 ms (< 1s) ✅
    • warnings [] ✅
    • median speedup 8.8× (machine-dependent; thresholds above are the pass criteria)
    • stalledConnections: 21 then clean 20/20 after refresh

Run (Windows host only; guest Node ≥18 + python3):

pnpm run bench:wsl-hook-relay-reattach -- --distro <your-distro> --samples 20

Follow-up to #13139: stop calling ensureWslHookRelayForReattach from the
benchmark and instead reattach a surviving WSL PTY via main's
registerPtyHandlers path, so a missing or misplaced integration in pty.ts
fails the bench.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bd3c5e12-f821-4407-8cad-40910ba9cb68

📥 Commits

Reviewing files that changed from the base of the PR and between 3e2fa31 and fc707c3.

📒 Files selected for processing (1)
  • config/scripts/wsl-hook-relay-reattach-benchmark.mjs

📝 Walkthrough

Walkthrough

The benchmark now loads production PTY and relay modules through Jiti with disposable Electron and runtime stubs. It spawns a surviving WSL PTY through the production path, verifies PTY ID reuse, and checks for exactly one relay refresh. The JSON output includes the reattached PTY ID and refreshed distros. Cleanup kills all PTYs and removes temporary user data.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and testing, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, state No visual change, document AI cross-platform review, provide a security audit, and record platform-specific risks or follow-up work.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states that the benchmark now exercises WSL hook-relay reattachment through the real PTY spawn path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 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: 99d1e6cb-6876-4770-9f23-8914842138b2

📥 Commits

Reviewing files that changed from the base of the PR and between 04f7123 and 3e2fa31.

📒 Files selected for processing (2)
  • config/scripts/wsl-hook-relay-reattach-benchmark-electron-stub.mjs
  • config/scripts/wsl-hook-relay-reattach-benchmark.mjs

- Wrap benchmark in try-finally for reliable cleanup
- Add jiti module graph duplication detection to catch missing pty.ts integration
- Track relay refreshes only during reattach phase to avoid false positives from earlier phases
- Disable agent-status hooks during PTY spawn (reattach path doesn't gate on them)
- Improve error messages and make cleanup safe with optional chaining
@AmethystLiang
AmethystLiang merged commit 3e6b93f into main Aug 8, 2026
0 of 43 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ablyai#13260)

* test(wsl): drive hook-relay reattach bench through real PTY spawn

Follow-up to stablyai#13139: stop calling ensureWslHookRelayForReattach from the
benchmark and instead reattach a surviving WSL PTY via main's
registerPtyHandlers path, so a missing or misplaced integration in pty.ts
fails the bench.

* refactor(bench): isolate reattach relay refresh measurement and verify s

- Wrap benchmark in try-finally for reliable cleanup
- Add jiti module graph duplication detection to catch missing pty.ts integration
- Track relay refreshes only during reattach phase to avoid false positives from earlier phases
- Disable agent-status hooks during PTY spawn (reattach path doesn't gate on them)
- Improve error messages and make cleanup safe with optional chaining
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