mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 17:45:53 +01:00
reserveBodyRead answered 503 bridge_busy for two different conditions: the bound is transiently full (a retry can succeed) and the read's own charge is larger than the whole bound (no retry ever succeeds). The second case invites the same endless-retry defect the earlier 502-on-oversize-body fix closed. Split the two. reserveBodyRead now returns a RESERVE_NEVER_FITS marker when reserveBytes alone exceeds maxInflightBodyBytes, and both gateways answer a non-retryable 413 request_too_large for that marker, before they take any reserve. They keep the existing 503 bridge_busy for the transient case. In-spec traffic at the production defaults does not reach the never-fits branch (the file gateway's worst-case charge is about 42 MiB against a 64 MiB bound); this is a backstop, so a future factor change that breaks that property fails loudly with a clean 413 instead of turning legal traffic into a retry loop. Also add explicit coverage for the three real no-declared-length request shapes: a DELETE with no body sends no Content-Length header; a POST with a streamed body sends chunked transfer encoding and no Content-Length; a POST with an explicit empty body sends Content-Length: 0. All three now reach the host worker at the production inflight default, not a 503. Verified: 45 tests in sandbox-callback-bridge.test.ts (2 new), 19 in duplex-bridge-local-e2e.test.ts, 136 in execution-target-sandbox.test.ts, and 2 in execution-target-ssh-buffer.test.ts pass. npx tsc --noEmit on packages/adapter-utils is clean. Co-authored-by: Paperclip <noreply@paperclip.ing>