Correlate and classify invocation results
Implement correlate_results(pending, responses) for an offline fixture. Pending is a list of unique nonempty string IDs. Each response has exactly id plus either error, or result. An error value yields kind protocol_error. A result must contain exact boolean isError and a value; classify it as tool_error or success. Return normalized records in pending order. Every pending ID must have exactly one response; reject unknown, duplicate, missing or malformed responses. This simplified envelope is not a complete current MCP result model.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
Inputcorrelate_results(["a","b"], [{"id":"b","error":"bad_method"},{"id":"a","result":{"isError":false,"value":3}}])
Output[{"id":"a","kind":"success","value":3},{"id":"b","kind":"protocol_error","value":"bad_method"}]
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor