Skip to content

[FOUND-113] (2/5) Add buffered socket read helpers#36

Open
mattwd7 wants to merge 9 commits intoFOUND-113-pr1-protocol-basefrom
FOUND-113-pr2-socket-buffer
Open

[FOUND-113] (2/5) Add buffered socket read helpers#36
mattwd7 wants to merge 9 commits intoFOUND-113-pr1-protocol-basefrom
FOUND-113-pr2-socket-buffer

Conversation

@mattwd7
Copy link

@mattwd7 mattwd7 commented Feb 27, 2026

Summary

  • Add buffered text-read helpers to socket instance methods (read_line, read_from_buffer, clear_read_buffer).
  • Preserve over-read bytes for mixed line/body parsing workflows.
  • Keep change additive without modifying existing binary call paths.

Test plan

  • Meta/unit and integration tests pass in stacked head branch
  • No behavioral change expected for existing binary protocol path

@mattwd7 mattwd7 force-pushed the FOUND-113-pr1-protocol-base branch 3 times, most recently from 32d5b15 to 6237cb0 Compare February 27, 2026 20:44
Introduce `read_line` and `read_from_buffer` so text protocol parsing can safely mix line and body reads without losing over-read bytes.
@mattwd7 mattwd7 force-pushed the FOUND-113-pr2-socket-buffer branch from 0ee7537 to 5e9593e Compare February 27, 2026 20:52
@mattwd7 mattwd7 changed the title FOUND-113 Part 2: Add buffered socket read helpers [FOUND-113][2/5] Add buffered socket read helpers Feb 27, 2026
@mattwd7 mattwd7 changed the title [FOUND-113][2/5] Add buffered socket read helpers [FOUND-113] (2/5) Add buffered socket read helpers Feb 27, 2026
Test read_line, read_from_buffer, and clear_read_buffer behavior including buffering, retry, timeout, and connection reset paths.

Made-with: Cursor
@mattwd7
Copy link
Author

mattwd7 commented Mar 2, 2026

read_line and the @read_buffer are needed by the meta protocol specifically.

Binary protocol responses are length-framed:

  • fixed 24-byte header
  • header tells you exact body size
  • client then reads exactly that many bytes

Because binary always does fixed-size reads in sequence, it doesn’t need a cross-call spill buffer.
Meta protocol responses are mixed:

  • first read a line (e.g. VA 5 f0 ...\r\n)
  • then read a known number of body bytes (5)
  • then consume trailing \r\n

A single socket read can pull more than just the line, so leftover bytes must be kept for the next body read. That’s what @read_buffer is for.

Copy link
Author

@mattwd7 mattwd7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-reviewed ✅

@mattwd7 mattwd7 marked this pull request as ready for review March 3, 2026 00:12
@mattwd7 mattwd7 requested a review from a team as a code owner March 3, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants