Fewer round trips

Closed
SA
1mo ago
+4211-1154

Summary by cubic

Removes an entire turn from session startup and batches awaited host calls so asyncio.gather(f(), g()) costs one round trip, not three.

The first feed or load now carries the session's Configure, so a session configures and runs its first snippet in one turn; checkout() sends nothing, a refused session (unknown profile, drain, disconnect) surfaces as that first call's error instead of rejecting checkout(), and sessionId is known only after it completes. A host call the sandbox awaits as it is made no longer suspends on its own: the worker answers it with a future, runs on until every task blocks, and hands the host every call made since the last wait in a single ResolveFutures. Answering with a plain value raises the TypeError CPython raises for awaiting a non-awaitable (the gather variant when the call feeds a gather). The stepping APIs (feed_start/feedStart) opt back into per-call suspensions via suspend_awaited_calls and surface each awaited call as its own snapshot.

Protocol and pool

  • ParentRequest.open_session carries the configuration on the opening feed/load; an opening feed that raises still reports its clock, and an unusable bare Configure is kept for the next request; ResolveFutures.calls/os_calls carry announced calls; ExtFunctionResult.plain answers one with a value.
  • Dump::load re-announces unresolved awaited calls to the restoring host.
  • Each announced call is charged as one suspension, timed and traced under its own span closed by the result naming it, with tracing capped at max_suspensions; an unhandled awaited OS call raises the sandbox's own error.