Send the first request behind `Configure` without waiting for its reply

Merged
SA
25d ago
+1696-486

The pool no longer configures a session in a turn of its own: Checkout::create keeps the Configure and the first request writes it out ahead of itself, reading the Configure reply (bounded by request_timeout) before its own. The child answers in order, so a session opens and runs its first Feed or Load in one round trip. A refused Configure is that request's error and ends the session; an oversize first request still opens it; a checkout finished without a request never configures its worker. Redial and turn_raw take the same path, and the wasm transport pipelines the same way.

session_id is None until the first turn; a Load reply replaces it and a refused Load keeps it. The telemetry recorders track the unanswered Configure apart from the turn pipelined behind it.

Claude-Session: https://claude.ai/code/session_018zfZ5xdFiagSnfMeWL7Nb6


Summary by cubic

The session's Configure now carries its first Feed or Load (Configure.first), so a session opens and runs its first request in one round trip: the pool sends the Configure and the request as one frame, and a refused Configure is the reply, a SessionRefused event, so that request never runs and ends the session.

Protocol and pool

  • The pool encodes the borrowed Configure and first request together (OpeningRequest) without cloning either, and the child arms the session's memory ceiling before running the request — except the subprocess shell, which sets its allocator baseline on the pristine worker before any request, so a first request decoded before its ceiling is armed still counts toward max_memory. Each session is charged its own stored Configure, shifting the exact usage figures in the subprocess tests.
  • Redial, raw turns, and the wasm transport take the same path; a checkout finished without a request never configures its worker, and a write that breaks the pipe keeps reading so a refused Configure reports the child's own reason.
  • The protocol version bumps to 8, since a version 7 child would drop a request carried inside Configure; version 7 parents still send Configure alone, which this child serves, so MIN_SUPPORTED_PROTOCOL_VERSION stays at 7.

Session ID and errors

  • session_id is unset until the first request is answered, so it is read through the new awaitable get_session_id() / getSessionId(), which sends a lone Configure when no request has gone out yet; the session_id property is deprecated. A Load reply replaces the ID, and a refused Load keeps it along with the clock and limits of the Configure reply reported. A refused Configure raises MontyConfigurationError from Python and JS, including the wasm worker.
  • Telemetry tracks the unanswered Configure apart from the request behind it. Only the first turn-ending reply acknowledges a Configure carrying a request — a later abort reply no longer re-adopts the server's clock, which would switch a remote CPU session to wall-clock supervision. FatalError and Shutdown replies report no clock and are classified as themselves, and a refused Configure records no run. A remote session's first request relies on a finite request_timeout in place of the wall-time backstop, since the server's clock arrives with its reply.