Skip to content

fix: admit relay bulk frames once under backpressure - #26333

Merged
nwparker merged 4 commits into
mainfrom
nwparker/perf-relay-bulk-single-admission
Oct 8, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/perf-relay-bulk-single-admission

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

An SSH Git operation could receive the same chunk twice and fail with “Out-of-order chunk.” A filesystem stream waiting for capacity could also make the relay spin when its output connection failed. This change retires each chunk's retry after acceptance or settlement, while preserving completion through the original write callback.

What Changed

Bulk admission and retry-listener bookkeeping now use the existing publication transaction. Capacity notifications wait until the retry listener has been installed or removed. A completion flag prevents stale retries and prevents a synchronously rejected write from rearming its listener.

The production change is confined to one transport method, with 12 net added lines. Four test files exercise real Writable backpressure, retirement during admission, teardown, and defensive retry contracts.

Why

Removing a listener after enqueue was insufficient: retiring queued terminal output can synchronously notify capacity before enqueue returns. The existing transaction covers that interval without introducing another queue, timer, polling loop, or protocol change. The completion flag also covers the real closed-writer/client-still-open teardown interval.

Linked Issue

No separate issue; internal reliability fix.

Visual Proof

N/A — relay chunk ordering and callback settlement have no rendered UI change. Real-stream regressions and failing old-code controls provide the behavior evidence.

Testing

  • Final published commit: 8583700fffb5be4e4e8c383c0089a6b35f538946.

  • Independent exact-commit run: 2,231 relay tests passed, 7 skipped; 245 files passed, 2 skipped. Node typecheck passed.

  • 9 focused tests passed across three suites. They cover callback-owned completion, sink errors/disposal, real writer teardown, eight valid filesystem frames in order, and defensive stale-callback/failed-admission contracts.

  • The retirement regression sweeps 121 positions and asserts that a capacity wake actually occurs inside admission with a retry armed. A changed schedule therefore cannot silently make the regression vacuous.

  • The teardown test uses a real Writable with one held native write. It observes the writer closing before the client, synchronous error settlement, and rejected admission. The original transport fails a bounded negative control; the fixed version rejects cleanly with no retained retry or lease.

  • Independent exhaustive sweeps on the unchanged production code covered every retirement position across normal/filesystem lanes, two frame sizes, and three queue layouts, plus 22 lifecycle probes. The original transport duplicated a chunk at the critical position; the fix did not.

  • The final test-only watchdog counts consecutive rejected admissions and resets on acceptance. Substituting its earlier implementation fails the new eight-valid-frame test.

  • Changed-file code-quality checks and normal commit hooks passed. The existing terminal output-backpressure gate's 20 deterministic command groups passed on the primary audit worktree; its native/Docker rows were not run in this review.

  • Executed on macOS/Node with ORCA_BACKGROUND_LAUNCH=1; no visible app was launched. Physical Linux/Windows/ConPTY and live SSH latency were not exercised locally. Published-head CI covers the remaining automated checks.

  • Exercised the real-stream scenarios locally

  • Automated tests added/updated

Review

Independent normal review approves the exact final commit as low risk, with no remaining concrete correctness caveat or negative user-facing tradeoff identified.

Claude Opus 5.5 independently approved the unchanged production fix and the strengthened regression tests. Its final harness-only followup could not start after an Orca runtime restart; that correction received independent normal review, the full exact-commit relay run, and both negative controls above.

The final correction addresses Opus's remaining watchdog maintainability nit. Synthetic callback and failed-admission tests are defensive contract coverage, not claims that those injected paths occur naturally. The retirement test remains calibrated to the harness but explicitly verifies that it hits the relevant wake.

Agent skill upstream boundary

  • Not applicable; this change copies no upstream skill-installer material.

Notes

Reliability class: terminal-performance.output-backpressure-budget (existing experimental, partial gate). Invariant: a bulk frame is admitted once, completion belongs to its original sink callback, and failed admission retains its wake until settlement or closure. Failure source: duplicate SSH Git chunks and a real waiting-filesystem-stream teardown loop. Oracle: decoded frame order/count, completion timing, positive in-admission wake coverage, and zero retained retry/lease state after teardown. Diagnostics: focused test failures, full relay logs, and old-code negative controls identify the failing lifecycle boundary.

No new polling, queue limits, protocol fields, host-status rules, dependencies, or platform-specific behavior. Existing peers remain compatible. Relay/SSH consumers are covered through dispatcher contracts; folder workspaces and mobile use the same unchanged wire format.

Pre-existing teardown notification cost and exceptional throwing-admission cleanup are outside this change. Neither is a new user-facing tradeoff introduced here. The final pre-merge audit independently reran all nine focused tests and confirmed clean integration with current main. Recommendation: merge, low risk; no new user-facing tradeoff identified.

Checklist

  • This PR is small and focused
  • Explained the user-facing before/after, mechanism, and choice of approach
  • Visual proof marked N/A with behavior evidence
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, folder workspace, mobile, and compatibility impact considered
  • Full lint, all-project typecheck/tests, and build: remaining checks covered by published-head CI; local relay tests, Node typecheck, and changed-file quality checks pass

@coderabbitai

coderabbitai Bot commented Oct 7, 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: 27d7c276-ad74-4a60-9713-b1eb791a300a
📥 Commits

Reviewing files that changed from the base of the PR and between b4e1d9a and 8583700.

📒 Files selected for processing (2)
  • src/relay/dispatcher-bulk-admission.test.ts
  • src/relay/dispatcher-bulk-write-test-harness.ts

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


📝 Walkthrough

Walkthrough

publishBulkWhenAvailable now runs each retry in a publication transaction and marks it complete before removing its capacity listener. It stops completed retries and does not register a listener if publication finishes synchronously. New tests cover producer ordering, failed admissions, sink errors, disposal, and producer-write retirement.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 85837

The changed tests exercise failed-admission wakes and producer retirement, with no remaining concrete admission failure established. No specific merge blocker is indicated.

🚥 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 1 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ⚠️ Warning The required Linked Issue section does not contain an issue reference. It states only that no separate issue exists. Add the actual issue reference, or confirm that the author is a maintainer covered by the template exception for avoiding needless issues.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary fix: admitting relay bulk frames once under backpressure.
Description check ✅ Passed The description is detailed and covers the user impact, mechanism, rationale, testing, compatibility, and checklist requirements. It explains why no separate issue is linked for this internal reliabil…
Out of Scope Changes check ✅ Passed The changes match the stated objective. They modify bulk admission bookkeeping and add focused regression coverage without introducing unrelated production behavior.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@nwparker nwparker changed the title perf: stop retrying relay bulk frames after admission fix: admit relay bulk frames once under backpressure Oct 8, 2026
@nwparker
nwparker merged commit 6e39b8e into main Oct 8, 2026
55 checks passed
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