> Canonical guide: https://developers.foxlight.ai/build/sdk/wire/
> Contract snapshots: Skulk 2.0.0 (b0af39c79b6b7102b2478062904f1d7cc8619975); SDK 0.4.0 (31bb090b8f64689f87514e48385e22b6ad94a6c2). Check the installed runtime when versions differ.

# Local wire _framing_

The SDK supplies asynchronous framing for the owner–child connection. Use `read_message` and `write_message` instead of implementing a second serializer.

```python
from skulk_capability_sdk.wire import read_message, write_message

message = await read_message(reader)
await write_message(writer, response)
```

## Framing and backpressure

Each frame has a four-byte, network-order length followed by canonical JSON. The maximum message is 64 KiB. Reads reject lengths below two bytes or over the cap. Writes wait for the stream’s backpressure through `drain()`.

The surrounding lifecycle owns the deadline. A successful read does not start a new independent timeout budget; cancellation and the original invocation deadline still apply.

## Validation and failures

Incoming frames are validated against the discriminated wire contract in strict mode. Duplicate JSON keys, non-finite values, oversized frames, and excessive parser nesting are refused. `ProtocolError` reports framing violations; typed validation and incomplete stream reads can also fail. Handle them at the connection boundary with a useful diagnostic and controlled shutdown.

Streaming media uses the separate [streams channel](https://developers.foxlight.ai/build/sdk/streams/): a bounded header followed by raw bytes. Continue answering health on the primary control channel while executing a stream. Large immutable results use the host's declared result transport and its bounds.

[Wire API reference](https://developers.foxlight.ai/build/sdk/reference/wire/)
