Skip to content

test(daemon): make real-socket backpressure assertion deterministic - #31520

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/sta-11548-socket-backpressure-test
Oct 21, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/sta-11548-socket-backpressure-test

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 21, 2026 •

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

ELI5

The real-socket backpressure test could fail on Linux CI even when the daemon behaved correctly. Sending 8 MiB in total did not guarantee that 4 MiB was still pending: each event-loop yield let socket write callbacks release the daemon's accounting. There is no user-facing change; this improves CI reliability.

What Changed

The bounded flood now runs synchronously until the producer pauses or the existing 8 MiB ceiling is reached. Pending write callbacks cannot run before the pause assertion, so the visible producer's pause follows from the daemon's outstanding accounting rather than kernel socket capacity. The real Unix socket / Windows named-pipe fixture and subsequent asynchronous drain, byte conservation, background shedding, typing delivery, and producer resume checks remain in place. Production code and fake-socket contracts are unchanged.

Why

A paused JavaScript reader does not determine how much data the operating system can accept. Keeping write callbacks pending establishes the condition the daemon actually guarantees without increasing the flood budget, extending timeouts, mocking the socket, or changing production behavior.

Linked Issue

Tracked in STA-11548.

Visual Proof

N/A — test-only CI reliability change with no visual or interaction changes.

Testing

  • Ran ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/daemon/daemon-stream-backpressure-socket.test.ts three times on macOS through the normal test runner and tc-gate: all four cases passed each time.
  • Updated the existing real-socket regression test; no new test files.
  • Linux CI covers the platform where the original failure occurred. Full lint and typecheck are left to CI.

Review

Self-reviewed the test against daemon pending-write accounting and verified the only changed file is the real-socket test.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Author: @BrennanKB5. No production, SSH, mobile, saved-data, or protocol changes. Existing platform-specific socket fixture is preserved.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Review path and plan

Full review path because the same pause-assertion symptom was addressed in #31256 within the last 30 days. Runtime QA is skipped (qa=none) because only a test changes.

  • Small: satisfied; zero production lines and one test file (+2/-6).
  • Outside risky areas: no shipped lifecycle, persistence, concurrency, protocol, process, account, orchestration, build or default code changes. Scheduling changes are confined to the test fixture.
  • Not a repeat: not satisfied; test(daemon): run the stalled-reader backpressure test over a Unix socket, not TCP loopback #31256 changed this same test on October 20 to address Linux pause-assertion failures.
  • Local effect: satisfied; test-only change with no app behavior change.

Plan: keep the existing real-socket fixture and flood ceiling, assert producer pressure while write callbacks are still pending, then retain the asynchronous drain and delivery checks. The full review verified the regression contract with producer pause forwarding disabled in a temporary test mutation: both visible cases failed at the unchanged pause assertion under Node and Bun, then the exact original test bytes were restored. Normal runs passed all four cases under each runtime. Production and fake-socket contracts were unchanged. Final-head CI passed after merging current main.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 21, 2026 12:17
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1582260a-84d0-43f5-a189-a981bbeaa4a1
📥 Commits

Reviewing files that changed from the base of the PR and between 5dd5294 and b99cdaf.

📒 Files selected for processing: 1
  • src/main/daemon/daemon-stream-backpressure-socket.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The socket backpressure test no longer imports or calls nextTurn(). Its production loop continues enqueueing and flushing data, up to the existing 8 MiB limit, while write callbacks remain pending until the pause assertion. The test also replaces a kernel buffer explanation with a comment about the pending callbacks.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to b99cd

No actionable merge-blocking risk remains in this test-only change.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: making the real-socket backpressure assertion deterministic.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Description check Passed The pull request description is complete and follows the repository template. It explains the problem, change, rationale, linked issue, testing, review scope, visual proof status, platform considerati…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

Full details: Description check

Explanation

The pull request description is complete and follows the repository template. It explains the problem, change, rationale, linked issue, testing, review scope, visual proof status, platform considerations, and checklist status.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

The real-socket test could report a missing producer pause even when daemon backpressure worked. Its per-MiB yields let completed writes release outstanding accounting, so 8 MiB of cumulative writes did not guarantee 4 MiB pending at the assertion. #31256 changed the transport but still yielded, so callbacks could release accounting; this change removes the yields and asserts pause before callbacks can run.

This test-only change establishes the pending-callback condition synchronously, then keeps the real socket drain, bounded buffering, byte conservation, background shedding, typing delivery and producer resume checks. There is no app behavior change. Production code and fake-socket contracts were not changed.

Review completed with a fresh correctness reviewer and independent architecture challenger. Both found no issues; no review fixes or deferred findings remain. Full path was required because #31256 addressed the same symptom within 30 days. Readiness checks, including the proportional performance, compatibility and platform passes, found no issues.

Verified:

  • All four normal cases passed under Node and Bun on macOS.
  • One temporary fixture mutation removed producer pause forwarding without changing assertions. Both visible cases failed at the pause assertion under each runtime; both hidden cases passed. Exact original bytes were restored and the worktree was clean.
  • Real-socket probes under both runtimes observed zero write callbacks during synchronous writes, including writes already accepted by the kernel.
  • The final main sync left the test and its invoked production mechanisms byte-identical to the reviewed versions. Full PR Checks passed on final head 9c26fbc, including Linux unit coverage and static analysis/typecheck.

Runtime QA is skipped (qa=none) because only a test changes. No Electron flow or Windows named-pipe run was performed by this review. The evidence verifies daemon-owned accounting pressure and real transport delivery; it does not assert a particular kernel buffer capacity or exercise a real PTY.

For Brennan's review: screenshots are not applicable to this test-only change. The judgment point is the bounded synchronous flood and unchanged pause assertion; the later asynchronous delivery/resume assertions remain in place.

@brennanb2025
brennanb2025 merged commit 3086fe2 into main Oct 21, 2026
33 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/sta-11548-socket-backpressure-test branch October 21, 2026 17:16
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