aw-sync: rowid cursor misses heartbeat extensions to trailing open event

Open
#790 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Start by reading the rowid fast-path around get_events_since_rowid and how reconcile_updated_events uses resume_sync_at. Then trace where the highest-rowid trailing event can be re-synced; done means heartbeat extensions to that event are included in the destination without losing the rowid cursor's handling of late-arriving events.

Written by the indexing model from the issue text.

Description

Problem

The rowid-cursor sync introduced in #789 doesn't re-fetch events whose endtime was extended by a heartbeat after the event's rowid was synced.

Scenario:

  1. Event A (rowid 100, T1–T2) is synced → cursor saved at 100
  2. A heartbeat extends event A's endtime to T2+30 (rowid still 100)
  3. Next sync: get_events_since_rowid(100) returns only rowid > 100 → misses the T2→T2+30 extension
  4. reconcile_updated_events handles the lookback window up to resume_sync_at but not extensions beyond that boundary

Impact

Bounded: only the trailing open event at sync time loses the heartbeat extension in the destination. The impact resolves on the next natural event transition (when a new event starts and the old one closes).

Tradeoff

This is a known tradeoff vs. the old timestamp-scan path:

  • Rowid cursor: correct for late-arriving events (the core #696 fix), but misses endtime-only updates
  • Timestamp scan: re-fetches events in the time window, catching heartbeat extensions, but permanently loses late-arriving events (#696)

Proposed fix

After the rowid fast-path, re-sync the highest-rowid event from source (the "trailing event") to capture any heartbeat extension since the previous cursor save. This is a small fixed-cost read per bucket per sync pass.

Related

  • Fixes #696 (rowid cursor) — #789
  • Greptile P1 finding "Continued activity stops growing" on #789
Dominant language
Rust
Stars
322
Forks
105
Avg merge
3d 10h
Merged PRs (30d)
22

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ActivityWatch/aw-server-rust

All issues in ActivityWatch/aw-server-rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.