Repository navigation
Conversation
[Medium impact] The reviewed changes appear safe to merge. SummaryThis PR caches the event returned by
The previous and current heads have different merge bases with the target commit, so this review covered the full PR diff. Reviews (6) · Last reviewed commit: "test(api): use UTC in backward-clock hea..." · Reviewed by Greptile |
|
CI note, not caused by this diff: both Ubuntu jobs fail during Set up Python with |
|
Fixed the runner mismatch in 065e9be: both Python 3.9 jobs now use Validated the workflow matrices and confirmed an Ubuntu 22.04 x64 Python 3.9 build exists in the setup-python manifest. The full local |
|
CI-green and mergeable — waiting only on a maintainer click. Updated 2026-11-12: all eight checks pass on The AI-review panel reports 5/5 with no findings on this head. Greptile's 5/5 covers the older |
🤖 AI code reviewIn aw_server/api.py, ServerAPI.heartbeat() now captures the return value of insert() and caches it, falling back to the original heartbeat when insert() returns None. In tests/test_server.py, a new test sends heartbeats across a backward clock step and checks the timestamps and durations of the two remaining events. Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings. The diff looks correct to me on this pass. Files changed (2) — the diff as I read it
Previous review passes
Reviewed Maintainer commands
|
8edeab9 to
cfb7399
Compare
|
@greptileai review |
|
Rebased onto current master There is now no |
|
The remaining failure is inherited from master: #218 upgraded Ruff to 0.17.3, whose expanded default rule selection reports 150 violations on unmodified master. This PR's Linux/macOS/Windows tests, typecheck and format checks all pass. Opened #224 to make the prior lint selection explicit while retaining the upgraded action. Both Ruff versions pass with that configuration, its effective enabled codes exactly match the previous 58-rule baseline, and an undefined-name control still fails. This heartbeat branch also passes Ruff 0.17.3 using the repair configuration. No heartbeat code changes or reruns of the deterministically failing check. The CI repair needs a maintainer merge first; then this PR needs a refreshed lint run against the repaired base. |
|
Updated the PR description to replace the initial sandbox-only test note with the recorded full-suite results and an explicit lint is still failing merge gate. The summary-only P1 was triggered by that old wording; its preflight now returns no finding, while a control with the old wording still reproduces it. Refreshed the existing AI-review comment on unchanged head No code push, CI rerun or merge. #224 remains the lint repair to land first, followed by refreshing this branch and obtaining passing exact-head checks. This review refresh does not clear that CI blocker. |
cfb7399 to
7984736
Compare
|
@greptileai review |
|
Resolved the merge conflict and force-with-lease pushed Verification on the rebased head: full GitHub now reports mergeable, but not CI-green: current-head lint fails, format passes, and the remaining checks are running. Local Ruff 0.17.3 still reports the expanded-rule baseline failures, so #224 remains the separate lint repair. Requested a fresh Greptile review for this exact head; the previous head's 5/5 is not current-head evidence. No merge performed. |
7984736 to
cfb7399
Compare
The merge path already replaces the event it merged into by id when that id is known (aw-watcher-afk#61). The insert path discarded insert()'s return value, so the cached heartbeat had no id and every merge fell back to replace_last(). That fallback targets whichever event sorts last by timestamp, so after an out-of-order heartbeat (a backward NTP or manual clock step) it overwrote and destroyed a newer stored event, leaving two rows at the same timestamp. Cache the event as stored and add a regression test that steps the clock back 3600 s: it fails before this change and passes after. Git-Session-Id: 2459c02a-4b33-51b6-89e9-623b6e0f4df1
Git-Session-Id: 348b38df-3329-54e6-891f-357385c887c9
cfb7399 to
d60ee8b
Compare
Problem
ServerAPI.heartbeat()caches the last heartbeat so the next one can merge into it. Master already replaces the merged event by id, falling back toreplace_last()when the id is unknown (ActivityWatch/aw-watcher-afk#61).The insert path discards the return value of
self.db[bucket_id].insert(heartbeat), so the cached event lacks its assigned id. Subsequent merges take the fallback, which resolves "last" by maximum timestamp.After a backward wall-clock step,
heartbeat_merge()refuses to merge into the past and inserts an older heartbeat. The next merge then overwrites the newest stored event instead of the older event, destroying the pre-step activity and leaving two rows at the older timestamp. The existing FIXME inaw_server/api.pydescribes this failure.Fix
Cache the event returned by
insert()(including its id), falling back to the original heartbeat only when insert returns None. Later merges replace the row actually merged into, matching the by-id approach inaw-server-rust.Test
test_backward_clock_step_does_not_overwrite_newer_eventsendst+0,t+5,t−3600,t−3590withpulsetime=10, using an explicitly UTC baseline.t−3600; thetevent is gone.t−3600with duration 10 andtwith duration 5.End-to-end client/server probe:
ErikBjare/bob,knowledge/research/2026-11-05-aw-clock-step-recording-probe.md.Local verification recorded on 2026-11-06 for head
cfb7399151b0:tests/test_server.py21 passed; full existingmake test145 passed (Python 3.13). The initial sandbox'stests/test_client.pyConnectionError occurred without a live server; it is not the current hosted check result.CI status / merge gate (2026-11-12)
All eight current-head checks pass on
d60ee8b441848027d8f13fe5ae82d43a6e36558b: Linux, macOS and Windows tests, typecheck, lint, format, CodeQL and Analyze (python). GitHub reports the PR is mergeable.#224 merged as
90fc21dc8c3c5b0e0a3c649e47d779f6b0f6c88c. This branch has been refreshed against that repaired base; the prior expanded-Ruff-default lint blocker is cleared. The latest master Lint run also passes: https://github.com/ActivityWatch/aw-server/actions/runs/43274449099. Current-head lint/format run: https://github.com/ActivityWatch/aw-server/actions/runs/43306280967.The AI-review panel reports 5/5 with no findings on
d60ee8b44184(2026-11-12). Greptile's 5/5 is historical, for79847368fcc8, not the current head. No merge has been performed; a maintainer owns the merge decision.