feat: DGR-002 - Adopt the versioned gRPC Shard protocol

This commit is contained in:
Dobromir Popov
2026-07-13 16:00:49 +03:00
parent efec84efef
commit 30dcf953fe
22 changed files with 3615 additions and 17 deletions

View File

@@ -0,0 +1,63 @@
"""The native Shard protocol: Protobuf over gRPC/HTTP2 (ADR-0020).
`packages/node/native/proto/shard_runtime.proto` is the contract. This package
is how Python speaks it: the generated stubs plus the validation, framing and
chunking rules that the stubs cannot express.
Import the message types from here rather than reaching into `.generated`, so
the location of build output stays an implementation detail::
from meshnet_node.native_protocol import pb, encode_tensor, decode_bundle
"""
from __future__ import annotations
from .generated import shard_runtime_pb2 as pb
from .codec import (
BUNDLE_VERSION,
DEFAULT_MAX_CHUNK_BYTES,
DEFAULT_MAX_FRAGMENT_BYTES,
DEFAULT_MAX_INFLIGHT_CHUNKS,
DEFAULT_MAX_PREFILL_CHUNK_TOKENS,
HIDDEN_STATES,
SCHEMA_VERSION,
PayloadCorrupt,
PrefillChunk,
ProtocolError,
checksum_of,
crc32c,
decode_bundle,
decode_tensor,
default_flow_control,
encode_bundle,
encode_tensor,
expected_bytes,
itemsize,
negotiate_flow_control,
plan_prefill_chunks,
)
__all__ = [
"BUNDLE_VERSION",
"DEFAULT_MAX_CHUNK_BYTES",
"DEFAULT_MAX_FRAGMENT_BYTES",
"DEFAULT_MAX_INFLIGHT_CHUNKS",
"DEFAULT_MAX_PREFILL_CHUNK_TOKENS",
"HIDDEN_STATES",
"SCHEMA_VERSION",
"PayloadCorrupt",
"PrefillChunk",
"ProtocolError",
"checksum_of",
"crc32c",
"decode_bundle",
"decode_tensor",
"default_flow_control",
"encode_bundle",
"encode_tensor",
"expected_bytes",
"itemsize",
"negotiate_flow_control",
"pb",
"plan_prefill_chunks",
]