Skip to content

fix(link): a combo-routed Remote Link turn reads its upstream only as its client drains - #8837

Merged
lidge-jun merged 1 commit into
devfrom
fix/link-turn-combo-pacing
Nov 16, 2026
Merged

lidge-jun merged 1 commit into
devfrom
fix/link-turn-combo-pacing

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

A Remote Link turn routed through a combo still let the Home read up to 32 MiB ahead of a stalled Child. #8785 paced every relayed link turn, but the pacing check (linkTurnPacesReads) looks up the link-turn observer by log context, and a combo runs each target on a fresh child log context that was never bound to it. A Child that stopped reading a combo-routed turn therefore held about 37 upstream chunks on the Home instead of one.

The combo now binds each child's log context to the parent's link-turn observer for pacing only (bindLinkTurnChild in src/server/link-turn.ts, called where core-combo.ts builds the child log). The binding lives in a separate map that notifyLinkTurnFinal never reads, so the observer's terminal notice still fires once, from the combo's own final log.

Docs: structure/remote-link.md no longer claims that every link turn is paced without qualification. It now names the passthrough relay as the paced path, describes combo children and the stream preflight's first chunk, and points to the regression test. The investigation history and recorded RSS runs moved out of that structure doc into devlog/_plan/261113_link_websocket_gate_opening/010_memory_investigation.md. structure/transports/byte-accounting.md names combo targets. No en/es docs-site page describes link read pacing, so none changed.

Addresses CodeRabbit review threads PRRT_kwDOS-0Gi863w6KX and PRRT_kwDOS-0Gi863w6Ke on #8785.

Verification

Regression tests in tests/responses/stalled-reader-memory.test.ts:

  • "a relayed link turn routed through a combo reads paced, and its terminal notice fires once". origin/dev behaviour (fix call site removed): fails with Expected: <= 2, Received: 37 upstream chunks before the client's first read. With the fix: passes. After the first read the reader stays one chunk ahead; before it, the combo stream preflight also holds the chunk it read to commit the target.
  • "a combo child's context paces for the parent's link turn without taking its terminal notice". On origin/dev: fails, because bindLinkTurnChild does not exist (SyntaxError on import). With the fix: passes. A child's final log fires nothing, and the parent's fires exactly once.

Commands, each focused file run under /usr/bin/lockf -k /tmp/ocx-test.lock because the host is under heavy load:

  • bun test tests/responses/stalled-reader-memory.test.ts: 13 pass, 0 fail
  • bun test tests/server/link-request-log-fields.test.ts: 16 pass, 0 fail
  • bun test tests/server/link-websocket-upgrade.test.ts: 21 pass, 0 fail
  • bun test tests/server/link-websocket-holds.test.ts: 19 pass, 0 fail
  • bun run typecheck, bun run structure:check, bun run privacy:scan: all pass

NOT RUN: full bun run test and bun run test:changed (the host is under heavy load and the task limited local runs to focused files; ci:full covers the rest), and the opt-in RSS acceptance tests/e2e-style/link-websocket-rss.test.ts.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Bug Fixes
    • Combo-routed requests now pace upstream reads while preserving the complete response stream. Child requests share read pacing without triggering duplicate terminal notifications.
  • Tests
    • Added coverage for combo request pacing, stream delivery, and parent-only terminal notifications.
  • Documentation
    • Clarified pacing behavior for dispatched targets and updated WebSocket acceptance-test guidance.

… its client drains

A combo runs each target on a fresh child log context, so linkTurnPacesReads
never saw the parent's link-turn observer and the child kept the 32 MiB
inspection read-ahead. The combo now binds each child context to that
observer for pacing only; the terminal notice still fires once, from the
parent's final log.

The structure doc's pacing claim is corrected, and its investigation
history moves to the link WebSocket gate-opening devlog unit.

Addresses PRRT_kwDOS-0Gi863w6KX and PRRT_kwDOS-0Gi863w6Ke on #8785.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 16, 2026 13:31
@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 16, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T13:33:13.507043Z 767c125 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Combo-routed link turns now propagate the parent’s pacing observer to dispatched child contexts. Tests cover paced reads, complete stream delivery, and parent-only terminal notifications. Documentation and an investigation note describe the pacing contract and memory measurements.

Changes: Combo Link-Turn Pacing

Layer / File(s) Summary
Propagate pacing to combo children
src/server/link-turn.ts, src/server/responses/core-combo.ts, tests/responses/stalled-reader-memory.test.ts, structure/remote-link.md, structure/transports/byte-accounting.md, tests/e2e-style/link-websocket-rss.test.ts, devlog/_plan/261113_link_websocket_gate_opening/010_memory_investigation.md
Combo child log contexts inherit the parent’s pacing observer without inheriting its terminal-notification binding. Tests verify paced reads, full stream delivery, and parent-only terminal notices. Documentation clarifies combo-target pacing and acceptance-test details; the investigation note records memory-path history and settled RSS runs.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant executeComboResponses
  participant bindLinkTurnChild
  participant ChildLogContext
  participant linkTurnPacesReads
  executeComboResponses->>bindLinkTurnChild: pass parent and child log contexts
  bindLinkTurnChild->>ChildLogContext: associate inherited pacing observer
  ChildLogContext->>linkTurnPacesReads: check observer for paced reads
Loading

Possibly related PRs

  • lidge-jun/opencodex#8785: Applies paced upstream reads to relayed Responses turns; this change extends the pacing behavior to combo-routed child contexts.

Suggested reviewers: luvs01

Merge Risk: Minimal · up to 767c1

Combo-routed link turns now pace upstream reads per target, which limits memory held by a stalled client. No concrete merge-blocking risk was found, and the change is small and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: a combo-routed Remote Link turn now paces its upstream reads to the client's drain rate. The changeset binds combo child log contexts to the parent's link-turn observe…
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: Title check

Explanation

The title names the main change: a combo-routed Remote Link turn now paces its upstream reads to the client's drain rate. The changeset binds combo child log contexts to the parent's link-turn observer (bindLinkTurnChild, pacingByLog, core-combo.ts) so each combo target is paced, which matches the title. The title is specific and uses the conventional fix(scope) form. The title is a single sentence of 87 characters, which fits the length guidance.

Finishing Touches

Generate unit tests (beta)

  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3ef14ad and 767c125.

Files selected for processing: 7

  • devlog/_plan/261113_link_websocket_gate_opening/010_memory_investigation.md
  • src/server/link-turn.ts
  • src/server/responses/core-combo.ts
  • structure/remote-link.md
  • structure/transports/byte-accounting.md
  • tests/e2e-style/link-websocket-rss.test.ts
  • tests/responses/stalled-reader-memory.test.ts

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration of #8837 at 767c125. It fixes CodeRabbit threads PRRT_kwDOS-0Gi863w6KX and w6Ke, left on #8785.

  • What it fixes: combo targets ran on a fresh child log context that never reached the parent's link-turn observer, so combo-routed Remote Link turns were unpaced. bindLinkTurnChild binds a child for pacing only, and the terminal notice still fires once, from the parent.
  • Regression test: on dev, the combo-routed relayed turn read 37 chunks ahead against a limit of 2. Here it holds about one chunk after the first read; before that first read the preflight's selection chunk adds one more.
  • Docs: structure/remote-link.md no longer claims every link turn is paced, and its history moved to devlog.
  • Review gate: Codex completed on this exact head with no unresolved findings, CodeRabbit reviewed this head, and no review thread is open. CI on this exact head: green, including enforce-target. assert-mergeable-review: OK. Simulated merge onto the dev of this moment: clean, and no file over its size cap. Dev state: batch lane=all 43890997984 (147b59f) failed only windows 11/14 (active-turn-disconnect timeout cascade). The same product code passed that shard and case in 43874258334 (3ef14ad to 147b59f changes only test(claude-cli): hold the reader until the pre-fix child exits so the frame is always cut #8840's test files), so it is an intermittent hosted-Windows failure, recorded on Windows hosted CI quarantine for 2.98.0 (overflow matrix, client-link-stop, CLI plan) #8262.

@lidge-jun
lidge-jun merged commit 25a9b99 into dev Nov 16, 2026
37 of 41 checks passed
@lidge-jun
lidge-jun deleted the fix/link-turn-combo-pacing branch November 16, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ci:full Run the four full Ubuntu test shards on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant