Service-Failure Forensics
You have a list of services, dependency pairs [a, b] meaning a depends on b, and log lines [time, service, status] where status is "ok" or "fail". Consider each service's first failure. It is explained when some service it depends on — directly or transitively — failed at or before that time. Return the services whose first failure is not explained, ordered by that failure time and then by name.
rootCauses(["api", "db", "cache"], [["api", "db"], ["api", "cache"]],
[[1, "db", "fail"], [2, "api", "fail"], [3, "cache", "ok"]]) -> ["db"]Hints
Hint 1
First pass over the logs: the earliest failure time per service. Services that never failed are not suspects.
Hint 2
For each failed service, walk its dependency closure (DFS over the dependency edges); if any dependency's first failure is at or before its own, it is explained.