Title: Design: read it bounded — one response-read contract for mcpx's outbound calls · Issue #4375 · developing-today/code · GitHub
Open Graph Title: Design: read it bounded — one response-read contract for mcpx's outbound calls · Issue #4375 · developing-today/code
X Title: Design: read it bounded — one response-read contract for mcpx's outbound calls · Issue #4375 · developing-today/code
Description: Design doc: files/designs/code-mcpx-bounded-response-reads.md in the keep-the-four-repos-healthy goal workspace. Audit at origin/main f93e6dc5b — every defect below re-verified present at the cited lines this pass (2026-11-02). Summary m...
Open Graph Description: Design doc: files/designs/code-mcpx-bounded-response-reads.md in the keep-the-four-repos-healthy goal workspace. Audit at origin/main f93e6dc5b — every defect below re-verified present at the cited...
X Description: Design doc: files/designs/code-mcpx-bounded-response-reads.md in the keep-the-four-repos-healthy goal workspace. Audit at origin/main f93e6dc5b — every defect below re-verified present at the cited...
Opengraph URL: https://github.com/developing-today/code/issues/4375
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design: read it bounded — one response-read contract for mcpx's outbound calls","articleBody":"Design doc: `files/designs/code-mcpx-bounded-response-reads.md` in the keep-the-four-repos-healthy goal workspace. Audit at origin/main `f93e6dc5b` — every defect below re-verified present at the cited lines this pass (2026-11-02).\n\n## Summary\n\nmcpx reads responses from endpoints it does not control — third-party MCP servers, configured model providers, remote embeddings services — with no byte bound in four places. A client timeout bounds *duration*, never *bytes*: a fast endpoint can deliver gigabytes inside the timeout. Each filing re-derived the same missing rule in a different package:\n\n- **Daemon chat-completions proxy** — `proxyToUpstream` (`internal/daemon/routes_proxy.go:244`) uses `http.DefaultClient` (no deadline at all) and streams the response through a `TeeReader` into an unbounded `bytes.Buffer` kept as the feedback record (#2114; implementation PR #3380 in flight).\n- **MCP client non-JSON fallback** — `HTTPTransport.Send` (`internal/mcpclient/http.go:218`) does `io.ReadAll(resp.Body)` uncapped and pushes the result as one \"message\", while the non-2xx path in the same function caps at 4 KB (#4282).\n- **Both OpenAI-compatible providers** — `internal/model/openai.go:123` and `internal/scripting/provider.go:121` buffer whole; on non-2xx the entire body is embedded in the error (#4354; probe: a 32 MiB error body produced a 33.5 MB error string). The `baseURL` is configuration (OpenAI, a company gateway, LiteLLM, Ollama, LM Studio).\n- **A fifth instance is unfiled** — the remote embeddings client's error path (`internal/catalog/embeddings.go:101`) reads the body whole into its error. Phase 4 dispositions it.\n\nThe conforming embodiments already agree: error bodies are read via `io.LimitReader(resp.Body, defaults.HTTPErrorBodyLimit)` (4 KB, `upstream.errorBodyLimit`) in `mcpclient/http.go:167` and `sse.go:76,225,228`; the SSE reader has a max line size; every daemon *inbound* body is bounded by `http.MaxBytesReader` / named `defaults` limits. The inbound side has a contract; the outbound side has exceptions.\n\n## The contract\n\n> **Every byte mcpx reads from a peer it does not operate is bounded, and the bound's shape depends on what the bytes are for: an error body is an excerpt, a buffered success body is refused past its cap, a retained copy is truncated while the delivered stream is not, and every call carries a deadline as well as a byte bound — a timeout bounds duration, never bytes.**\n\nRecorded decisions (full reasoning, alternatives and risks in the design doc):\n\n1. **Error bodies are excerpts, everywhere, at the existing limit** — any non-2xx body embedded in an error/record/log is read at most `defaults.HTTPErrorBodyLimit` (4 KB). No new limit, no exceptions.\n2. **A success body mcpx buffers whole is refused past its cap, never silently truncated** — read cap+1; over → error naming the surface and the cap (truncated JSON fails parsing with a misleading error). Caps are named `defaults.json` entries: model + scripting providers **16 MiB**; the mcpclient non-JSON fallback **1 MiB** (aligned with `http.bodyLimit`), pinning #4282's open choice to **refuse** — over the cap, `Send` errors and pushes nothing (a truncated non-JSON body would manufacture a partial \"message\" out of a body that is definitionally not a protocol message). Under the cap, hand-on-whole behaviour is unchanged.\n3. **A retained copy is truncated; the delivered stream never is** — the proxy's feedback record is capped with the truncation visible in the record; the client receives the full response. PR #3380 (for #2114) already implements this shape and is adopted as the embodiment.\n4. **Deadline and byte bound are both required** — providers, embeddings and mcpclient already carry client deadlines; the proxy's `proxy.timeout` (PR #3380) closes the exception. A future outbound site is conforming only when both are present.\n\n## Phased breakdown\n\nPhases adopt the three filed origins as sub-issues (no parallels); Phase 4 is a new closing-audit issue, gated on Phases 1–3.\n\n- **Phase 1 — providers: success cap + error excerpt** (adopted: #4354). Lands the two provider implementations under decisions 1–2.\n- **Phase 2 — mcpclient fallback: bounded, refuse past cap** (adopted: #4282). Independent of Phase 1.\n- **Phase 3 — daemon proxy: deadline + retained-copy cap** (adopted: #2114). In flight as PR #3380; the phase completes when it merges or a superseding conforming change lands.\n- **Phase 4 — closing inventory + contract statement** (new issue, gated on Phases 1–3): every `resp.Body` read / buffered copy in `pkgs/mcpx` dispositioned; required dispositions — the embeddings error read (`catalog/embeddings.go:101`, fix in audit if it stays one line), the `internal/cli/*` own-daemon reads (local-trust; name any whose endpoint is configurable beyond the local daemon), decoder-streamed success paths, and stdin/file reads (out of scope — not peer bytes). Contract statement lands in `internal/defaults/defaults.go` beside `HTTPErrorBodyLimit`.\n\n## Open questions (in the design doc, not filed)\n\nA per-message byte bound for the mcpclient JSON decoder path; the 16 MiB provider cap revisited on Phase 1's real completion sizes; a decoded-value (max-dimension) bound for embeddings — a schema contract, not a byte contract.\n\n## Related\n\nDesign doc (full problem/evidence/alternatives/risks): `files/designs/code-mcpx-bounded-response-reads.md` (goal workspace). Origins: #2114, #4282, #4354. Neighbours, not this design: #2082 (closed — daemon *request* bodies), openchamber #1127 (the same contract stated for that repo's codebase), #3068 (parsed-shape validation — what a value's shape may be, not how many bytes may be read).\n\n\u003c!-- agent-note:v1 -->\nFiled by the design architect (pass 38, 2026-11-02): design issue for the mcpx bounded response-read contract. The three origin issues are adopted as its phases — triage of each origin should record the phase structure and the decisions above rather than re-filing or re-scoping. Phase 4's closing audit is filed separately and gated on Phases 1–3.\n\n## Acceptance criteria\n- One bounded response-read contract for mcpx outbound calls is stated in the design and adopted: every byte read from a peer mcpx does not operate is bounded, with the bound's shape matched to the bytes' purpose.\n- Each of the four named unbounded sites (daemon proxy `routes_proxy.go:244`, MCP client fallback `http.go:218`, both OpenAI-compatible providers, and the embeddings error path at `embeddings.go:101`) is dispositioned by a phase of this design — fixed under the contract or explicitly excepted with reasoning.\n- The conforming embodiments (4 KB `HTTPErrorBodyLimit` error reads, SSE max line size, bounded inbound bodies) are named as the contract's reference implementations.\n- Child/phase issues (including #4376 Phase 4) carry the implementation work; this design issue closes when the contract is adopted and all phases are filed/landed or excepted.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-02T13:35:07Z","url":"https://github.com/developing-today/code/issues/4375"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fc44aa80-ffe3-cc1a-7fdf-fe97e6ab4391 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D872:D0B9B:A082EA:D72591:6B063F96 |
| html-safe-nonce | 5d98fcd58d2f2130597b130d720154f3668738bcbae238d55cc542bc4a852e13 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODcyOkQwQjlCOkEwODJFQTpENzI1OTE6NkIwNjNGOTYiLCJ2aXNpdG9yX2lkIjoiODc3MDg2MDc5NDQ5NDQ4MzQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 069638532f2bcd6967234e4c3beefa5dacec0ac07e8ca72f97a9acb3e6e9c3f6 |
| hovercard-subject-tag | issue:6163617215 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/4375/issue_layout |
| twitter:image | https://opengraph.githubassets.com/32fa47209e397c3f2868fcd9e2d855e4b0e778528803413900ff50931ef5037a/developing-today/code/issues/4375 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/32fa47209e397c3f2868fcd9e2d855e4b0e778528803413900ff50931ef5037a/developing-today/code/issues/4375 |
| og:image:alt | Design doc: files/designs/code-mcpx-bounded-response-reads.md in the keep-the-four-repos-healthy goal workspace. Audit at origin/main f93e6dc5b — every defect below re-verified present at the cited... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ac613d3698d3d8565651455086e1f74da07bf277 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width