Code monitors: simplify last searched
Created by: camdencheek
This PR removes the concept of an "args hash" from repo-aware code monitors. Previously, we would use the args hash (a hash of all the arguments to the code monitor) to identify subqueries in complex code monitor queries so that we could independently run each job and still update the last searched commits appropriately.
For example, in the search type:commit ((repo:a b) or (repo:c d))
, we would have two subqueries: repo:a b
and repo:c d
. These would each be hashed to identify them, and we would track the commits searched by each independently since they will search over different sets of commits (each searches its own set of repos).
However, it turns out this is extremely fragile because if we ever change how the arguments are hashed, or if we ever add an argument, all the hashes change and we can no longer associate a subquery with its last searched commits.
As a fix, this PR restricts the types of queries that can be run by code monitors to queries that generate a single commit search job. This way, we only need to know which commits were last searched by the code monitor.
Currently, any time we have an and
or an or
in a query, we will generate multiple commit search jobs. This means this PR makes and/or
queries invalid when repo-aware monitors are enabled. However, with the recent optimizations Rijnard has been working on, we should be able to generate a single commit search job that works for any and/or
patterns. That will happen in followup PRs.
Note that all the changes here are hidden behind the cc-repo-aware-monitors
flag.
Test plan
Added test for error condition, manually tested that monitors still work as expected.