Repository navigation
Conversation
query_bucket returns events newest-first, but the merge walks both lists in ascending order. Unsorted input emitted overlapping events: a 40-minute span with full coverage in both lists summed to 70 minutes. period_union and filter_period_intersect already sort their inputs. Git-Session-Id: f67bd883-b10a-49dd-99de-2938d082f464
[Medium impact] This PR appears safe to merge. Summary
Reviews (1) · Last reviewed commit: "fix(transform): sort union_no_overlap in..." · Reviewed by Greptile |
🤖 AI code reviewIn Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No thread-worthy findings. Advisory notes follow; they are retained without opening review threads. 1 advisory finding (summary-only, not scored)These P2 guard, heuristic, trade-off, or documentation claims are retained for judgment without opening review threads.
This is a How this was verified: static preflight: fix-commit + touched-files scan (rule 7) Files changed (1) — the diff as I read it
Previous review passes
Reviewed Maintainer commands
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #838 +/- ##
===========================================
+ Coverage 70.81% 85.42% +14.61%
===========================================
Files 51 88 +37
Lines 2916 12613 +9697
===========================================
+ Hits 2065 10775 +8710
- Misses 851 1838 +987 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The missing-test advisory is a false positive: this diff adds the inline Rust regression test |
|
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. |
query_bucket returns events newest-first, but the merge walks both lists in ascending order. Unsorted input emitted overlapping events: a 40-minute span with full coverage in both lists summed to 70 minutes. period_union and filter_period_intersect already sort their inputs. Counterpart of ActivityWatch/aw-server-rust#838. Git-Session-Id: f67bd883-b10a-49dd-99de-2938d082f464
union_no_overlapwalks both lists in ascending timestamp order, butquery_bucketreturns events newest-first, and the query function passes its arguments through unsorted. The result then contains overlapping events and durations are double-counted.Repro against a v0.14.1
--testingserver: window and AFK buckets that each fully cover the same 40 minutes.union_no_overlap(query_bucket("w"), query_bucket("afk")) -> sum_durations 4200.0 union_no_overlap(sort_by_timestamp(query_bucket("w")), sort_by_timestamp(query_bucket("afk"))) -> sum_durations 2400.0aw-webui hits this path with raw bucket output:
canonicalEvents:stopwatch_events = query_bucket(...)thenunion_no_overlap(stopwatch_events, events)activityQuery:not_afk_curr = filter_keyvals(query_bucket(...), ...)thenunion_no_overlap(not_afk, not_afk_curr), once per AFK bucket. With two or more devices the total is inflated.The fix sorts both inputs inside the transform, as
period_unionandfilter_period_intersectalready do. Inputs that are already sorted produce the same output as before.Test:
newest_first_inputs_are_sorted_before_mergingfeeds reversed lists. It fails without the sort (six overlapping spans) and passes with it.cargo test -p aw-transform -p aw-querypasses andcargo fmt --checkis clean.aw-core's Python
union_no_overlapdocuments sorted input as a precondition and has the same exposure, so it needs a matching change.