Priority queue implementation - #415
Conversation
|
🤖 AI Code Review Here is an automated review of PR #415 ("Priority queue implementation"): 1. Regression Risks & Functional Bugs🚨 1. Missed Wiring:
|
b48262a to
690cf04
Compare
|
Thank you for your comments I have revised the issues and cleaned up the commits. I have also sorted out all issues with the new db versioning :) |
|
🤖 AI Code Review Here is a summary of the issues to address before merging PR #415: 🚨 Blocking Issues
|
Define PriorityRule and CompiledPriorityRule structs for regex-based patchset priority classification. Add a custom serde deserializer (deserialize_indexed_vec) to handle both TOML array and env-var indexed-map representations. Add the priority_rules field to ReviewSettings with serde(default) so existing configs are unaffected. Signed-off-by: Elkin Cruz <elkin@google.com>
Add a priority INTEGER DEFAULT 500 column to the patchsets table and a composite index idx_patchsets_status_priority_date on (status, priority DESC, date ASC) for efficient priority-ordered queries. The column defaults to 500 so existing patchsets are unaffected. Signed-off-by: Elkin Cruz <elkin@google.com>
Add migration to create priority columns and index. Introduce create_patchset_with_priority() which threads an explicit priority through all INSERT/UPDATE paths. Store base_priority as nullable so unclassified patchsets default to priority 500 in the queue while allowing subsequent deprioritization rules (priority < 500) to apply symmetrically regardless of part arrival order. Elevate base_priority with MAX(base_priority, ?) and apply priority_cap when present. Refactor create_patchset() to delegate with default None. Change get_pending_patchsets() ordering to priority DESC, date ASC. Add calculate_priority() for evaluating compiled regex rules against subjects (last match wins). Signed-off-by: Elkin Cruz <elkin@google.com>
Compile priority_rules from settings at startup and thread them through the DB worker into process_parsed_article(). Use calculate_priority() to compute priority from the patchset subject before calling create_patchset_with_priority(). API callers pass None for priority to create_fetching_patchset(). Signed-off-by: Elkin Cruz <elkin@google.com>
690cf04 to
eac198a
Compare
|
I've cleaned up the issues mentioned with third/party, including the asymmetric deprioritization note which was an excellent point for the agent to notice |
On top of #414
This basic priority queue (commits 1ecf827 to b48262a) allows us to set a priority to patchsets between 000 to 999. By default, a patchset is given the priority 500.
These changes only introduce a simple priority queue but not a mechanism to change priorities yet. That is reserved for future PRs (coming today too).
The queue has been written so that it is efficient (we have an index in the db for fast queries) and naive. It is naive in which we assume the review queue will be emptied eventually and all patches will be reviewed eventually. So we are assuming no patchset will every be locked forever. This matches what we see in our CI/CD environment, where sashiko has highs (chugging thousands of reviews at the time) and lows (when only one or two patches are being reviewed).