fix(dispatcher): advance mint counter past caller-supplied IDs (#3126)

Closed
EL
2mo ago
+104-2

Summary

When a caller supplies an integer request ID, the dispatcher's internal _next_id counter can mint the same value for a later request. The spec says IDs MUST NOT be reused within a session, so this is a correctness bug.

The fix eagerly advances _next_id to max(_next_id, supplied_id) in both JsonRpcDispatcher and DirectDispatcher. Two lines per dispatcher, no behavioral change for callers using string-only IDs.

Test plan

  • 4 new regression tests (2 per dispatcher via pair_factory parametrization)
  • All 894 tests pass
  • Covers both in-flight and completed caller-supplied ID scenarios

Fixes #3126