Repository navigation
fix: answer PING with a responsive PING, not an undecodable pong - #15
Conversation
The client defined MSG_PONG = 13, mapped 13 to "pong", and replied to
every PING with that frame. Wire code 13 is unassigned in the reference
_INT2TYPE and there is no PONG in HiveMessageType, so a reference decoder
raises on it:
ValueError: not a HiveMind message: {'msg_type': 'pong', ...}
The client therefore never produced a usable PING reply, and the
originator never saw it in the hive map.
HIVEMIND-MSG-1 4 and HIVEMIND-NODE-1 4: discovery is PING-only, and a
node answers with its own PING carrying the originator's flood_id,
PROPAGATE-wrapped. That is what lets the originator match the answer to
the flood it started. Verified against the reference implementation: the
new envelope parses as propagate -> ping with the flood_id intact.
Answers are deduplicated per flood, bounded at 64 ids. Without that, a
flood reaching this node over two paths is answered twice and the
originator records one node as two - and an unbounded set is not
something a microcontroller can carry.
The existing test asserted the broken behaviour, so it is replaced rather
than adapted: it now pins the responsive PING and the flood_id, asserts
no pong is emitted at all, and a second test covers the dedup. Verified
by mutation - restoring the pong reply fails the first test.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe client now answers encrypted PING messages with encrypted, propagated PING messages. Responses preserve the flood ID and include current node metadata. The client ignores empty or duplicate flood IDs and limits remembered IDs to 64 entries. ChangesResponsive PING flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant IncomingPeer
participant Client
participant Propagate
IncomingPeer->>Client: Encrypted PING with flood_id
Client->>Client: Check and record flood_id
Client->>Propagate: Encrypted propagate envelope with responsive PING
Propagate-->>IncomingPeer: Responsive PING with matching flood_id
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
The client defined
MSG_PONG = 13, mapped13: "pong", and answered every PING with that frame. Wire code 13 is unassigned in the reference_INT2TYPE, and there is noPONGinHiveMessageType, so a reference decoder rejects it:So this client never produced a usable PING reply and never appeared in the originator's hive map.
HIVEMIND-MSG-1 §4 and HIVEMIND-NODE-1 §4: discovery is PING-only, and a node answers with its own PING carrying the originator's
flood_id, PROPAGATE-wrapped. Verified against the reference implementation — the new envelope parses aspropagate→ innerpingwith the flood_id intact, while the old one raises theValueErrorabove.Answers are deduplicated per flood and bounded at 64 ids: a flood arriving over two paths would otherwise be answered twice and the originator would map one node as two, and an unbounded set is not something a microcontroller can carry.
The existing test asserted the broken behaviour (
test_ping_is_answered_with_pong), so it is replaced rather than adapted. Mutation-verified: restoring the pong reply fails the new test and nothing else. 78 tests pass.Found during the ecosystem documentation audit — the docs described a
pongthat the protocol has never had.Summary by CodeRabbit