Fix the deploy matcher for a latency incident
Your task
At 02:14 UTC the p99 latency of your Go search service tripled. Nobody deployed by hand overnight, but several pull requests from an AI agent merged on their own after passing CI. The first step is to match the onset against the deploy log and find which deploy could have caused it.
An assistant wrote find_suspect_deploy(deploy_minutes, deploy_shas, onset_minute, window_minutes). It is in the editor. It has a bug. Find it and fix it.
Input and output:
deploy_minutesanddeploy_shas: each deploy's time in minutes since midnight UTC, and the commit SHA it shipped, at the same index. 02:14 is minute 134.onset_minute: the minute the latency spike began.window_minutes: how long before the onset a deploy can still explain it.- Return the suspect's SHA, or
none,ambiguousorinvalid.
Rules the tests check:
- Return
invalidif the two lists differ in length, ifwindow_minutesis negative, or if any SHA is empty. - A deploy is a suspect when its minute is from
onset_minute - window_minutestoonset_minute, both included. - No suspects:
none. More than one:ambiguous. Exactly one: its SHA.
Examples
find_suspect_deploy(deploy_minutes: list[int], deploy_shas: list[str], onset_minute: int, window_minutes: int) -> strExample 1
Input
find_suspect_deploy([60, 132, 200], ["a1", "b2", "c3"], 134, 30)Output
"b2"Example 2
Input
find_suspect_deploy([110, 132, 200], ["a1", "b2", "c3"], 134, 30)Output
"ambiguous"