Collect an opaque-cursor tool catalog
Implement collect_catalog(pages, start). This is an offline application fixture, not an MCP transport implementation. pages maps opaque string cursors to objects with tools (list of unique nonempty tool-name strings) and next (another cursor or None). Follow from start, preserving discovery order. Reject missing pages, repeated cursors, malformed pages, and duplicate tool names across pages with ValueError. An empty page with a new next cursor must be followed.
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
Inputcollect_catalog({"root":{"tools":["a"],"next":"x"},"x":{"tools":["b"],"next":null}},"root")
Output["a", "b"]
Inputcollect_catalog({"root":{"tools":[],"next":null}},"root")
Output[]
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor