Skip to content

fix(link): decode the hold check's body copy only after the request is accepted, under the resolved inbound limit - #8613

Merged
lidge-jun merged 1 commit into
devfrom
fix/link-hold-decode-bounds
Nov 13, 2026
Merged

lidge-jun merged 1 commit into
devfrom
fix/link-hold-decode-bounds

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

When a Remote Link has a releasable link WebSocket activity hold, the Home reads a copy of each relayed POST /v1/responses body to see whether it returns the pending tool results. That copy was handled with looser bounds than the request itself (#8608):

  • It was decoded with decodeRequestBody's 256 MiB default instead of the resolved inbound limit the handler uses (1 to 512 MiB, maxInboundBodyBytes).
  • It was read and decoded as soon as it was buffered, before the handler decided, and outside the inbound body budget. When the budget refused the request with 503, the copy was still read and decoded (up to 256 MiB from about 1.3 MiB of zstd), then thrown away.

The fix in src/server/index/link-listener.ts: the copy is read only after the handler answered below 400. A refusal (the budget's 503 included), an abort before headers, or a dispatch error cancels the copy unread; the cancel is not awaited, because a tee's cancel waits for the other half, which a refusal may leave unread. An accepted copy is decoded under the listener's resolved inbound limit (startContext.maxRequestBodySize, which src/server/index.ts sets from resolveInboundBodyLimitWithWarning(config), fixed at bind like the public listener). structure/remote-link.md describes the new order.

What stays unchanged by default: this code runs only while a link has a releasable hold, and holds come only from link WebSocket sockets. The link WebSocket release gate (linkWebsocketTransportReady) is still closed in this build and nothing here opens it, so no existing install reaches the changed path. Relayed requests on links without a hold take no copy, as before.

Closes #8608

Verification

Red first. Two tests in tests/server/link-websocket-holds.test.ts failed on origin/dev e85a975 for the stated reasons, and pass with the fix:

  • "a relayed POST that the inbound body budget refuses never decodes the copy": the handler admits through the real withRaisedInboundBodyAdmission with a budget another lease already fills, so the zstd body is refused with 503. On dev decodeRequestBody was called once (expected 0). The upload has fully arrived before the refusal, as it does while a request waits in the budget queue; the test reads a clone first to make that ordering deterministic.
  • "an accepted relayed POST whose copy decodes past the resolved inbound limit releases nothing": the listener's resolved limit is 1 MiB and the zstd body decodes to about 2 MiB (under the 8 MiB ratio floor, so only the limit refuses it). On dev the hold was released (inFlight 0, expected 1). The same accepted request under the limit still releases it.

The three existing HTTP release tests (plain, refused after reading, zstd #8594) stay green. The holds file passed ten consecutive runs.

Commands (Bun 1.4.4, TMPDIR=/tmp):

  • bun run typecheck: exit 0
  • bun run privacy:scan: exit 0
  • bun run structure:check: exit 0
  • bun scripts/test.ts --parallel=2 tests/server/link-*.test.ts tests/server/inbound-body-admission.test.ts tests/server/inbound-encoded-body-budget.test.ts tests/server/inbound-body-budget.test.ts tests/lab/core-link-boundary.test.ts tests/lab/core-lab-boundary.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/clients/link-boundary.test.ts: exit 0, 622 pass, 0 fail, 35 files

NOT RUN: the full bun run test suite (the lane's VM is limited to focused files with parallelism 2; the change is confined to the link listener's hold observer, which the focused link and inbound-body files exercise). Cross-platform CI is left to the batched dev run.

Review

A fresh reviewer (gpt-6.1-terra, xhigh, read only) reviewed commit ff5bdb6 on the brief "deferred tee read, every decision path, the resolved limit, the red-first tests, behaviour with the gate closed, the structure sentence": no P0-P2 findings. It noted that a relayed request can still be observed while the release gate is closed if a hold was persisted earlier; holds are created only by link WebSocket sockets, which this build never admits, so no install has one. It did not rerun the new tests against origin/dev (the red runs above are the author's). An earlier reviewer on another model was stopped before it reported, after the owner changed the reviewer model.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (structure/remote-link.md).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (no credential or auth path changes; the bound is tightened).

Implemented by Claude Opus 5.5 (anthropic/claude-opus-5-5) in GOAT through the Codex harness; in-lane review by GPT-6.1 Terra (xhigh). Received as a git bundle from the VM that built it and pushed by the coordinator.

@lidge-jun lidge-jun added the bug Something isn't working label Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 01:28
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 01:28
@lidge-jun
lidge-jun merged commit 2c0a9ef into dev Nov 13, 2026
31 of 32 checks passed
@lidge-jun
lidge-jun deleted the fix/link-hold-decode-bounds branch November 13, 2026 01:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-13T01:31:06.723597Z ff5bdb6 Draft marked ready
ℹ️ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Link WebSocket holds: the HTTP hold check decodes its body copy outside the inbound budget (fix before the gate opens)

1 participant