Summarize validated run records
Implement summarize_runs(records). Each record must have exactly ok (bool) and milliseconds (nonnegative exact int). Return count, successes, success_rate, and mean_ms over all records. Empty input has zero counts and None for both averages. Reject malformed records with ValueError and do not mutate inputs. This small report exercises a real distinction between no observations and a measured zero success rate.
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
Input[{"ok": true, "milliseconds": 10}, {"ok": false, "milliseconds": 30}]
Output{"count": 2, "successes": 1, "success_rate": 0.5, "mean_ms": 20.0}
Input[]
Output{"count": 0, "successes": 0, "success_rate": null, "mean_ms": null}
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor