From a7efd1ebafb728b8c53fbbc346874f56c9a68713 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 16 Jun 2026 04:11:24 +0100 Subject: [PATCH] Route Python local server through transport port --- docs/cultnet-transport-parity.md | 12 ++++++------ docs/runtime-parity-scope.md | 6 +++--- packages/cultcache-py/PARITY.md | 6 ++++-- .../cultcache-py/src/cultmesh_py/server.py | 18 +++++++++++++----- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/docs/cultnet-transport-parity.md b/docs/cultnet-transport-parity.md index 038bfb17..06ce00dd 100644 --- a/docs/cultnet-transport-parity.md +++ b/docs/cultnet-transport-parity.md @@ -153,8 +153,9 @@ Current progress: path or the transport connection path. - Python now has the same `tcp_framed` transport profile helper plus a synchronous `TcpFramedTransportConnection` with `send`, `receive`, `close`, - and stats. `CultNetRawClient` and database subscriptions send/read through - that port instead of owning frame I/O directly. + and stats. `CultNetRawClient`, database subscriptions, and the local + CultMesh server connection loop send/read through that port instead of owning + frame I/O directly. - Rust now has the same `tcp_framed` transport profile helper plus a `TcpFramedTransportConnection` with schema-channel `send`, `receive`, and transfer stats. The Rust interop peer advertises and uses that shared port @@ -243,10 +244,9 @@ Current progress: lease catalogs, stream catalogs, and RUDP client/server construction. The facade delegates to the same owners as the top-level helpers instead of creating a second authority path. -- The remaining parity work is to deepen Python's server-side use of its port - and move each runtime's existing TCP/LiteNetLib/WebSocket bodies behind those - ports, then broaden RUDP interop into automatic reconnect orchestration and - the wider schema-message matrix. +- The remaining parity work is to move the remaining TCP/LiteNetLib/WebSocket + service bodies behind their shared transport ports, then broaden RUDP interop + into automatic reconnect orchestration and the wider schema-message matrix. ## RUDP Packet Contract V0 diff --git a/docs/runtime-parity-scope.md b/docs/runtime-parity-scope.md index 0ed6f393..3ed5ffcc 100644 --- a/docs/runtime-parity-scope.md +++ b/docs/runtime-parity-scope.md @@ -56,9 +56,9 @@ CultMesh. ## Remaining Work Before A Full Completion Claim -- Broaden service adoption so local servers and daemon paths use the shared - transport port consistently instead of keeping raw TCP/LiteNetLib/WebSocket - ownership in individual bodies. +- Broaden service adoption so remaining daemon and production paths use the + shared transport port consistently instead of keeping raw + TCP/LiteNetLib/WebSocket ownership in individual bodies. - Extend RUDP interop evidence through automatic reconnect orchestration and the wider schema-message matrix. RUDP profiles now advertise the portable reconnect policy across the targeted runtimes; service adoption of that diff --git a/packages/cultcache-py/PARITY.md b/packages/cultcache-py/PARITY.md index b824d48d..11fa864b 100644 --- a/packages/cultcache-py/PARITY.md +++ b/packages/cultcache-py/PARITY.md @@ -164,8 +164,10 @@ CultCache, CultNet, and CultMesh. It is evidence, not confetti. - Python CultMesh local server: Serves a `CultMeshNode` plus Verse and peer catalogs over the same framed MessagePack request/response lane used by `CultNetRawClient` and - `CultMeshDiscoveryClient`. It also supports live raw database subscriptions - for snapshot, put, and delete notifications on a connected client stream. + `CultMeshDiscoveryClient`. Accepted connections now read and write through + the shared `TcpFramedTransportConnection` port rather than owning raw frame + I/O in the server loop. It also supports live raw database subscriptions for + snapshot, put, and delete notifications on a connected client stream. When given a `CultNetSimulationObservationHub`, it accepts `cultnet.simulation_observation.v0` messages and replies with current `cultnet.simulation_consensus_candidate.v0` messages through the same framed diff --git a/packages/cultcache-py/src/cultmesh_py/server.py b/packages/cultcache-py/src/cultmesh_py/server.py index a98f4376..73182224 100644 --- a/packages/cultcache-py/src/cultmesh_py/server.py +++ b/packages/cultcache-py/src/cultmesh_py/server.py @@ -9,10 +9,9 @@ import msgpack from cultnet_py import ( CultNetSimulationObservationHub, + TcpFramedTransportConnection, create_tcp_framed_transport_profile, - read_frame, wire_message_schema_descriptors, - write_frame, ) from .node import CultMeshNode @@ -142,18 +141,27 @@ class CultMeshLocalServer: def _handle_connection(self, client: socket.socket) -> None: with client: stream = client.makefile("rwb") + transport = TcpFramedTransportConnection( + stream, + profile=create_tcp_framed_transport_profile( + self.node.runtime_id, + transport_id="cultmesh-local-tcp", + host=self.host, + port=self.port, + ), + ) subscriptions: dict[str, _DatabaseSubscription] = {} while not self._stop.is_set(): try: - message = msgpack.unpackb(read_frame(stream), raw=False) + frame = transport.receive() + message = msgpack.unpackb(frame.payload, raw=False) except EOFError: return if not isinstance(message, dict): continue responses = self._handle_connection_message(message, subscriptions) for response in responses: - write_frame(stream, msgpack.packb(response, use_bin_type=True)) - stream.flush() + transport.send("schema", msgpack.packb(response, use_bin_type=True)) def _handle_connection_message( self,