feat(classify): optional priority field for category rules - #663
Conversation
Greptile SummaryThis PR adds optional integer priorities, including the
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Query category-rule list] --> B[Parse category, rule, and optional priority]
B --> C{Category path empty?}
C -->|Yes| D[Skip rule]
C -->|No| E{Rule matches event?}
E -->|No| F[Check next rule]
E -->|Yes| G[Rank by explicit priority or depth times 10]
G --> H{Rank at least current rank?}
H -->|Yes| I[Replace selected category]
H -->|No| F
D --> F
F --> J[Write selected category or Uncategorized]
Reviews (3): Last reviewed commit: "fix(classify): default ranking to depth ..." | Re-trigger Greptile |
|
@greptileai review |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #663 +/- ##
==========================================
+ Coverage 70.81% 79.45% +8.63%
==========================================
Files 51 67 +16
Lines 2916 5835 +2919
==========================================
+ Hits 2065 4636 +2571
- Misses 851 1199 +348 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
|
@TimeToBuildBob Strictly integer? If so I think default should be |
|
@TimeToBuildBob Also need support in aw-core/aw-server-python |
When multiple rules match, ranking uses an optional `priority` (alias `weight`) on the rule dict. If omitted, depth-based ranking is unchanged. This lets a shallow rule beat a deeper organizational match without changing default behavior for existing configs.
An empty match must not replace Uncategorized. The old depth comparison rejected len 0 against the fallback's len 1; keep that when ranking starts from i64::MIN so negative priorities can still categorize.
Integer-only priority. Unset rules rank as depth * 10 so explicit values can slot between nesting levels (depth 1 → 10, depth 2 → 20). Relative order of unprioritized rules is unchanged.
676c090 to
1003817
Compare
|
@greptileai review |
|
Integer-only, with default
Python ranking is ActivityWatch/aw-core#153 ( |
* feat(classify): optional priority field for category rules Match ActivityWatch/aw-server-rust#663: integer `priority`/`weight` on rules, default rank is depth * 10 so values can slot between nesting levels. Existing configs keep their current ordering. * fix(classify): pick category without i64 fallback sentinel Replace the signed-64-bit Uncategorized rank with Optional[int] so a valid unbounded Python priority below -(2**63) still beats Uncategorized. Git-Session-Id: bob-monitor-aw-core-153
* feat(classify): optional priority field for category rules Match ActivityWatch/aw-server-rust#663: integer `priority`/`weight` on rules, default rank is depth * 10 so values can slot between nesting levels. Existing configs keep their current ordering. * fix(classify): pick category without i64 fallback sentinel Replace the signed-64-bit Uncategorized rank with Optional[int] so a valid unbounded Python priority below -(2**63) still beats Uncategorized. Git-Session-Id: bob-monitor-aw-core-153
Brings in category-rule priority support (ActivityWatch#663) and the aw-webui bump (ActivityWatch#668). The aw-webui submodule pointer is unchanged: beta had already moved it to a2ca625, which upstream master now also points at.
Optional integer
priority(aliasweight) on categorize rules, as discussed in #597.depth * 10(depth 1 → 10, depth 2 → 20), so values can slot between nesting levels{ "type": "regex", "regex": "vim", "priority": 25 }In the reported tree (A matches at depth 1, B→B1 matches at depth 2) A wins if its priority is higher than B1's default of 20.
Does not change default configs. Python ranking is ActivityWatch/aw-core#153. WebUI editor field is still a follow-up — not closing #597 here.