Skip to content

[Feature] Add JsonRpcResponseIndex utility for batch response correlation #23

Description

@limehee

Problem statement

Batch response handling requires repeated custom code for id correlation, missing response detection, and success/error partitioning. This creates inconsistent behavior between integrations and increases maintenance cost.

Proposed solution

Add JsonRpcResponseIndex in jsonrpc-core to provide structured access to parsed batch responses:

  • index by id for fast lookup
  • findById(...), requireById(...)
  • successes(), errors() views
  • missing-id / duplicate-id diagnostics
  • configurable duplicate-id policy (for example: reject, keep-first, keep-last)

Alternatives considered

  • Keep exposing only raw List<JsonRpcIncomingResponse>
  • Encourage each project to write local helper functions

These alternatives preserve flexibility but continue the same duplication and behavior drift.

JSON-RPC behavior impact

No protocol behavior change. This is a consumer-side utility for parsed responses.

Additional context

  • Works with existing parser/validator output (JsonRpcIncomingResponseEnvelope).
  • Include deterministic behavior docs for duplicate response IDs.
  • Add focused tests for empty batch, mixed success/error, and duplicate-id paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: waiting-for-feedbackWaiting for additional information from reporter or stakeholders.type: featureNew feature specification and implementation.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions