diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-16 15:28:53 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-16 15:28:53 +0200 |
| commit | fd770dc6293be67298f582de5800f2ca6fe24a8b (patch) | |
| tree | df8a393741ccf391b5bb4fa490980c632695cbdd /packages/meshbay-common/src/meshbay_common | |
| parent | 0bd3f805ffbd04b40b5150474336a5e5d200e72b (diff) | |
| download | meshbay-fd770dc6293be67298f582de5800f2ca6fe24a8b.tar.gz | |
feat(common): MNP 0.2 — liveness, and chat history read the way it is written
`get_messages` pages forward from the oldest message. That is the right shape
for "what happened since I last looked" and the wrong one for opening a
conversation, and the browser asked it for `since=0, limit=200` — so a group
with more than two hundred messages showed its first two hundred and the
exchange anyone came for was unreachable. Demonstrated on 300 messages: the
newest was simply absent from the answer.
`get_recent` and `get_before` page backwards, cursored on the row id rather than
the timestamp. Nothing makes a `time.time()` float unique, and a cursor on a
value two rows can share eventually skips a message or repeats it.
PING/PONG covers liveness on an already-open channel: a DataChannel whose peer
vanished without closing still reads as connected, and nothing noticed until a
real request hung. It is not a discovery mechanism — opening a connection to
ping costs a full ICE/DTLS handshake, measured at 0.6-7 s across two ISPs — so
presence in the group list comes from the hub's registry instead.
Both additions are backward compatible: an 0.1 peer sends no `before` and is
answered with the newest page, which is what it wanted.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-common/src/meshbay_common')
| -rw-r--r-- | packages/meshbay-common/src/meshbay_common/__init__.py | 7 | ||||
| -rw-r--r-- | packages/meshbay-common/src/meshbay_common/protocol.py | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/packages/meshbay-common/src/meshbay_common/__init__.py b/packages/meshbay-common/src/meshbay_common/__init__.py index ef0f1f6..60a9dc7 100644 --- a/packages/meshbay-common/src/meshbay_common/__init__.py +++ b/packages/meshbay-common/src/meshbay_common/__init__.py @@ -1,5 +1,8 @@ """MeshBay common — shared crypto primitives and protocol types.""" -__version__ = "0.4.0" -MNP_VERSION = "0.1" +__version__ = "0.5.0" +# 0.2: added PING/PONG, and `before`/`has_more` on chat history. Both are +# additive — an 0.1 peer sends no `before` and gets the newest page, which is +# what it wanted — so this is a MINOR bump, not a MAJOR one. +MNP_VERSION = "0.2" MHP_VERSION = "0.1" diff --git a/packages/meshbay-common/src/meshbay_common/protocol.py b/packages/meshbay-common/src/meshbay_common/protocol.py index b5a54ff..1aadafe 100644 --- a/packages/meshbay-common/src/meshbay_common/protocol.py +++ b/packages/meshbay-common/src/meshbay_common/protocol.py @@ -27,8 +27,16 @@ class MNP: STREAM_SEGMENT = "stream_seg" # HLS/DASH segment CHAT_MESSAGE = "chat_msg" # Double Ratchet message CHAT_ATTACHMENT = "chat_attach" # attachment metadata - CHAT_HISTORY = "chat_hist" # request message history + CHAT_HISTORY = "chat_hist" # request message history (newest, or before a cursor) CHAT_HISTORY_RESPONSE = "chat_hist_resp" # history response with messages + # Liveness on an *already open* channel. A peer that goes away without + # closing leaves a DataChannel that still reads as connected until the next + # real request hangs, and there was no way to ask. This is not a discovery + # mechanism: opening a connection in order to ping costs a full ICE/DTLS + # handshake (measured at 0.6-7 s across two ISPs), so presence in the group + # list comes from the hub's socket registry instead. + PING = "ping" + PONG = "pong" # GEK_REQUEST / GEK_RESPONSE were removed (NS3, and finding L1): the node must # never serve the GEK in plaintext. Members obtain it by unwrapping their own # ECIES bundle. The constants lingered after the handlers were deleted, leaving |