Skip to content

API Reference parrot_formdesigner.services.sandbox.protocol

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.services.sandbox.protocol

View source

Length-prefixed JSON wire protocol for sandbox workers (FEAT-459 / M8).

SandboxContext goes IN to a worker; SandboxOutcome, AbortSignal, or a BrokerRequest come OUT. Both worker pools (TASK-3169 subprocess, TASK-3170 gVisor) use this exact framing over their child process's stdio. Frames exceeding MAX_FRAME_BYTES are REJECTED, never truncated.

Alias AbortSignal

Re-exported from parrot_formdesigner.core.snippets.AbortSignal.

Class BrokerRequest

One host-mediated I/O request from a tier 3/4 worker (spec §2 HostBroker).

Fields:

Field Type Default Description
kind str Which allowlist category this request falls under — matches BrokerAllowlist's field names (TASK-3161).
target str The specific host/table/channel/toolkit being requested, checked against the manifest's corresponding allowlist tuple.
args dict[str, Any] Request-specific payload (e.g. HTTP method/body for "http_hosts", a bound query for "query_tables").

Class BrokerResponse

The host broker's answer to a BrokerRequest.

Fields:

Field Type Default Description
result dict[str, Any]
denied bool False
denial_reason str | None None

Class FrameTooLargeError

Raised when a frame's declared or actual size exceeds MAX_FRAME_BYTES.

Attribute MAX_FRAME_BYTES

Alias SandboxContext

Re-exported from parrot_formdesigner.core.snippets.SandboxContext.

Alias SandboxOutcome

Re-exported from parrot_formdesigner.core.snippets.SandboxOutcome.

Function decode_frame

Read and deserialise exactly one frame from reader.

decode_frame(reader: asyncio.StreamReader) -> BaseModel

Parameter Type Default Description
reader asyncio.StreamReader An open asyncio.StreamReader (worker stdout/socket).

Returns: BaseModel — A reconstructed instance of whichever _FRAME_MODELS type was encoded.

Raises:

  • FrameTooLargeError — the frame's DECLARED length exceeds MAX_FRAME_BYTES — the body is never read in this case (fail before allocating).
  • asyncio.IncompleteReadError — the stream closed mid-frame (caller's job to interpret as "worker died", not this function's).
  • ValueError — the decoded type tag is not recognised.

Function encode_frame

Serialise message into one length-prefixed frame.

encode_frame(message: BaseModel) -> bytes

Parameter Type Default Description
message BaseModel An instance of one of the types in _FRAME_MODELS.

Returns: bytes — <4-byte big-endian length><JSON body> ready to write to a stream.

Raises:

  • FrameTooLargeError — the serialised body exceeds MAX_FRAME_BYTES.
  • ValueError — message's type is not a recognised frame type.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally