Skip to content

fix: answer PING with a responsive PING, not an undecodable pong - #15

Merged
JarbasAl merged 1 commit into
devfrom
fix/ping-reply-not-pong
Aug 10, 2026
Merged

JarbasAl merged 1 commit into
devfrom
fix/ping-reply-not-pong

Conversation

@JarbasAl

@JarbasAl JarbasAl commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

🤖 Auto-generated by Claude Opus 5 (claude-opus-5) via Claude Code — NOT human-reviewed. Verify before acting.

The client defined MSG_PONG = 13, mapped 13: "pong", and answered 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 rejects it:

ValueError: not a HiveMind message: {'msg_type': 'pong', 'payload': {}}

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 as propagate → inner ping with the flood_id intact, while the old one raises the ValueError above.

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 pong that the protocol has never had.

Summary by CodeRabbit

  • New Features
    • PING requests now receive a responsive, propagated PING containing the original flood identifier and node information.
    • Repeated PING requests with the same flood identifier are answered only once.
  • Bug Fixes
    • Prevented responses to malformed or empty flood identifiers.
    • Replaced unsupported PONG responses with compatible PING responses.

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>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 72f39197-1bc2-47eb-803e-ef0bbec54b6d

📥 Commits

Reviewing files that changed from the base of the PR and between fdf3af3 and ea96175.

📒 Files selected for processing (2)
  • hivemind/client.py
  • test/test_integration.py

📝 Walkthrough

Walkthrough

The 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.

Changes

Responsive PING flow

Layer / File(s) Summary
PING protocol and response handler
hivemind/client.py
The client removes PONG handling, tracks answered flood IDs, and sends timestamped responsive PING messages through propagate.
Responsive PING integration coverage
test/test_integration.py
Integration tests verify the propagated PING payload, the absence of PONG frames, and duplicate-flood suppression.

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
Loading

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@JarbasAl
JarbasAl merged commit f3f5c4f into dev Aug 10, 2026
4 checks passed
@JarbasAl
JarbasAl deleted the fix/ping-reply-not-pong branch August 10, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant