Skip to main content

Module protocol

Module protocol 

Source
Expand description

The wire format core and helpers agree on.

Everything here is data: no process is spawned and no compiler is linked. A helper binary depends on this module to speak the protocol and on nothing else of codehelion, which is what keeps a toolchain dependency from reaching the analysis crates.

§Framing

Messages travel over the helper’s standard input and output as length-prefixed frames: a four-byte big-endian payload length, a one-byte encoding tag, then the payload. The tag exists so that compiler IR too large to be worth serializing as text can travel as bytes later without changing how a frame is found in the stream — only Encoding gains a variant.

A frame carries its own length so a reader never has to guess where a message ends, and never has to trust the sender’s promise about total volume: MAX_FRAME_BYTES bounds what one frame may ask a reader to allocate, so a helper that has gone wrong cannot exhaust memory before it is noticed.

Structs§

Analyze
One unit to analyze, and what is wanted from it.
BuildDescription
The conditions a tree’s code is analyzed under.
ClientIdentity
Who is connecting, and which revisions it can speak.
CompileCommandSelector
One stable, exact selector for an entry in compile_commands.json.
DescribeBuild
The tree whose build is being asked about.
Failure
Why a request could not be answered.
HelperIdentity
What a helper says about itself.
Request
A message from core to a helper.
Response
A message from a helper to core.

Enums§

Absence
What a run does when a helper cannot supply a capability.
Capability
Something a helper can be asked for.
Encoding
How a frame’s payload is encoded.
Execution
Something a helper may be permitted to run out of the project it is analyzing.
FrameError
Something that went wrong reading or writing a frame.
RequestBody
The askable things.
ResponseBody
The answers.

Constants§

MAX_FRAME_BYTES
Largest payload a single frame may declare.
PROTOCOL_VERSION
The only protocol revision this build speaks.

Functions§

read_frame
Read one frame and parse it.
write_frame
Write value as one JSON frame.