Resolve unique provenance sources
Implement source_leaves(graph, claim). The graph maps every artifact ID to a list of input artifact IDs; a leaf has an empty list. Return a sorted list of unique leaf IDs reachable from the claim. Reject a missing claim, unknown referenced artifacts in the reachable subgraph, and reachable cycles. Unrelated components are not traversed. Repeated paths to one observation do not create independent evidence.
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
Inputgraph={"report":["forecast","obs"],"forecast":["obs","schedule"],"obs":[],"schedule":[]}; claim="report"
Output["obs","schedule"]
Inputgraph={"a":["b"],"b":["a"]}; claim="a"
OutputValueError
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor