mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 17:45:53 +01:00
Enforce the O(1) readiness-buffer cap on every pre-READY path. Before this change the gate checked the cap only on the no-newline branch. An over-cap blank prefix followed by a valid nonce-bound READY frame in one chunk reached READY acceptance without a cap check. The gate now rejects when the cursor passes the cap after it skips a line, and before it decodes a completed candidate line. The cap check has priority over READY acceptance on every path. A cap breach settles protocol contamination and falls back to the file bridge with bounded cleanup. Make the readiness gate tolerant of pre-READY noise. A PTY channel echoes the launch wrapper line before it sets raw mode, so the first line is often not the READY frame. The gate now skips each pre-READY line that does not decode as a READY frame, then accepts the first line that decodes as a READY frame with the matching nonce. A READY frame with a wrong nonce still fails the handshake. The skipped bytes stay in the capped buffer, so the cap and the timeout still bound the wait, and the newline scan stays linear in the bytes received. Fix the gateway launch command. A POSIX shell rejects an environment-assignment prefix on exec, so exec NAME=value command exits 127 and the gateway never starts. Use exec env NAME=value command, which keeps the exec-replaces-shell property and passes the assigned environment. Add fallback_reason to the channel-open span on the fallback path only. fallback_reason is an existing closed dimension key, so no new key reaches a sink. Co-authored-by: Paperclip <noreply@paperclip.ing>