12#ifndef PROVSQL_KCMCP_PROTOCOL_H
13#define PROVSQL_KCMCP_PROTOCOL_H
115 void send(
Type type, uint32_t request_id,
const std::string &payload);
116 void send(
Type type, uint32_t request_id) {
send(type, request_id, std::string()); }
131 const std::string &result);
bool recv(Message &out)
Read one logical message (concatenating MORE frames).
void send(Type type, uint32_t request_id, const std::string &payload)
Send a message, splitting payload across MORE-flagged frames no larger than the peer's limit.
void send(Type type, uint32_t request_id)
Connection(int fd, uint32_t recv_max, uint32_t send_max)
std::string build_result(OutputFormat fmt, const std::string &meta_json, const std::string &result)
Build a RESULT payload (result_format byte + meta JSON + result bytes).
Flag
Frame flags (header byte 1).
@ FLAG_MORE
payload continues in the next frame
@ FLAG_COMPRESSED
payload is zstd-compressed (unused here)
InputFormat
Input-format registry (REQUEST byte 1).
Type
Frame type (header byte 0).
const char * input_format_name(InputFormat fmt)
const char * output_format_name(OutputFormat fmt)
Operation
Operation registry (REQUEST byte 0 / HELLO operations names).
@ UNSUPPORTED_VERSION
client requires a KCMCP major this server lacks
@ COMPRESSION_UNSUPPORTED
COMPRESSED frame flag set, but unsupported.
@ UNSUPPORTED_OPERATION
unsupported operation or unknown frame type
const char * operation_name(Operation op)
OutputFormat
Output-format registry (REQUEST byte 2 / RESULT byte 0; one shared space).
std::string build_error(ErrorCode code, const std::string &message)
Build an ERROR payload (u16 code + UTF-8 message).
bool parse_request(const std::string &payload, Request &out)
Decode a REQUEST payload; returns false if structurally malformed.
A fully reassembled inbound message (MORE frames concatenated).
ProtocolError(ErrorCode c, const std::string &what, bool fatal_=true)
std::string problem
the formula bytes
std::string options
UTF-8 JSON (may be empty == {}).
OutputFormat output_format