Sync V2: design review for syncing settings and category rules across devices

Open
#1,563 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
android, python, rust
Domain
backend, databases

Research direction

Read the sync V2 design in issue #1445 and compare the per-device folder model with a shared replicated settings document. The review should address the six listed questions, including category merge semantics and Rust/Python backend parity. Done means a short design doc recommends an alternative and breaks implementation into server export, reader, web UI, and Android slices.

Written by the indexing model from the issue text.

Description

Part of the sync V2 programme (#1445). This issue covers syncing settings, starting with category rules, alongside events. It is a design review, not an implementation ticket.

Problem

Category rules accumulate on each device independently. A phone, a desktop and a laptop each end up with their own rule set. Today the only ways to share rules are manual export/import or rebuilding them by hand on every device. Of all the settings, category rules are the ones users build up over time, so they gain the most from sync. Saved views and other settings follow after that.

Candidate design (Erik's starting point; alternatives wanted)

This keeps the ownership model V2 already uses for events (devices/{device_id}/):

  • Each device owns its folder. A device writes only its own shared settings. Every other device's folder is read-only to it, so writing to or pushing back into another device's files is a protocol violation.
  • Sharing is opt-in. The sync setup lets the user choose what a device shares, for example categories but not views.
  • Each device reads the others' shared rules and pulls them in explicitly. The UI offers:
    • Merge: fold another device's categories into this device's rule set, with conflicts shown and resolved instead of silently overwritten.
    • Copy: replace this device's rule set with another device's.
    • Inherit: make this device follow another device's rule set, so it tracks future changes from the device with the better rules.

Questions the review should answer

  1. Single-writer-per-device folders (above) versus a shared, replicated settings document (last-writer-wins, CRDT or versioned). The trade-off is between simplicity plus clear ownership, and a single source of truth that has no "which device is the master" step.
  2. Merge semantics for the category tree: matching by name path versus a stable ID, how to handle diverging regexes for the same category, and how to handle deletions.
  3. How "inherit" composes with local edits: does a local edit fork the device off, or is it refused?
  4. Scope and order: categories first, then views, then other settings. Some settings must never leave the device, such as server port and per-device watcher config.
  5. Format and versioning: reuse the segment/manifest format (v field, hash validation) or keep a separate small JSON document per device.
  6. Backend parity: Rust and Python servers both store categories in the settings store (classes), and Android runs aw-server-rust. The contract needs to cover both.

Done when

A short design doc compares at least two alternatives against the questions above, makes a recommendation, and splits the implementation into slices: server settings export, reader, webui merge/copy/inherit UI, and Android wiring.

Dominant language
Python
Stars
19.7k
Forks
1.1k
Avg merge
2d 19h
Merged PRs (30d)
14

Getting set up

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/activitywatch

All issues in ActivityWatch/activitywatch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.