aw-sync publishes aw-server-rust's private sqlite schema as the wire format (unreadable by aw-server-python, unversioned, WAL-mutable)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Domain
- databases, distributed-systems
Research direction
Start with aw-sync, aw-datastore/src/worker.rs, sync.rs, and aw-core/aw_datastore/storages/sqlite.py to trace how staging databases are written and consumed. Review the constraints and related issues #689, #684, and ActivityWatch/activitywatch#1445; done requires a design decision for a versioned, self-describing, externally safe format readable by both server implementations and third-party tools.
Written by the indexing model from the issue text.
Description
The files aw-sync publishes into the shared folder are sqlite databases in aw-server-rust's internal datastore schema. That schema is undocumented, unversioned as an interchange format, migration-mutable, and — the part that surprised me — not readable by ActivityWatch's own Python server.
The two schemas are structurally incompatible
aw-server-rust/aw-datastore (what lands in the sync folder, read from a real staging db):
CREATE TABLE buckets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE NOT NULL, type TEXT NOT NULL, client TEXT NOT NULL,
hostname TEXT NOT NULL, created TEXT NOT NULL
, data_deprecated TEXT DEFAULT '{}', data TEXT NOT NULL DEFAULT '{}');
CREATE TABLE events (
id INTEGER PRIMARY KEY AUTOINCREMENT, bucketrow INTEGER NOT NULL,
starttime INTEGER NOT NULL, endtime INTEGER NOT NULL,
data TEXT NOT NULL,
FOREIGN KEY (bucketrow) REFERENCES buckets(id));
aw-core/aw_datastore/storages/sqlite.py:
CREATE TABLE IF NOT EXISTS buckets (
rowid INTEGER PRIMARY KEY AUTOINCREMENT,
id TEXT UNIQUE NOT NULL, name TEXT, type TEXT NOT NULL, client TEXT NOT NULL,
hostname TEXT NOT NULL, created TEXT NOT NULL, datastr TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS events (
id INTEGER PRIMARY KEY AUTOINCREMENT, bucketrow INTEGER NOT NULL,
starttime INTEGER NOT NULL, endtime INTEGER NOT NULL,
datastr TEXT NOT NULL,
FOREIGN KEY (bucketrow) REFERENCES buckets(rowid));
Differences that matter:
- The bucket's string key is
buckets.namein Rust andbuckets.idin Python.nameexists in both and means opposite things — the key in one, a nullable display name in the other. - The bucket's integer PK is
idin Rust,rowidin Python, soevents.bucketrowpoints at a differently-named column. - The JSON payload column is
datain Rust anddatastrin Python, on both tables.
These are not subtle: a query written against one raises "no such column" against the other.
Consequences
- A user running aw-server-python cannot read their own sync folder with their own server's storage layer. The bundle still ships aw-server-python as an option, so this is a live split.
- The wire format is one implementation's private schema. It changes under migrations —
user_versionis already at 5 — and the published files carry the evidence: every staging database in my sync folder contains a column literally nameddata_deprecated, internal migration residue being shipped as the interchange format. - Third-party tooling has to reverse-engineer it. There is no spec, no version marker in the sync folder, and no compatibility statement.
sync.rseven carries// TODO: Check for compatible remote db version before opening— so a peer db from a future schema is opened blind. - Related: the filename. Every database in the folder is called
test.db(see #689 item 4). A user opening the folder finds N identical filenames in a format nothing outside aw-server-rust can read.
Also: WAL
Measured on a live sync folder — two of three staging databases report journal_mode = wal, and aw-datastore/src/worker.rs enables it deliberately. aw-sync closes the datastore at the end of a pass, so sqlite checkpoints and removes the -wal sidecar; in the steady state the published file is self-contained, which is why no -wal files are currently visible in the folder.
The exposure is the write window. A push into a 273 MB staging database is not instant, and the file syncer is watching the directory: it can begin transferring test.db while a -wal exists and the main file is mid-checkpoint. There is already evidence of the syncer observing concurrent modification here — erb-main3/5a5df0f8-…/test.sync-conflict-20241125-052022-GRUSU5T.db and a second conflict file from the same day.
Publishing a mutable, in-place-updated sqlite file into a directory whose whole purpose is that an external process copies it whenever it changes is a structural mismatch, independent of the schema question.
What this is really asking
Whether the sync folder should contain sqlite at all, versus an explicit, versioned, documented interchange format that is written once and never mutated. That question is under active design review; this issue exists to record the concrete constraints any answer has to satisfy:
- readable by both server implementations, and by third-party tools, without reimplementing a private schema
- explicitly versioned in the folder, so a peer can refuse or adapt rather than opening blind
- safe to publish into a directory an external syncer copies at arbitrary moments
- self-describing filenames
Related: #689 (test.db naming, orphaned dbs), #684 (observability), ActivityWatch/activitywatch#1445.
cc @TimeToBuildBob — filing this as a constraints record rather than a proposal; the format decision should wait for the design review.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ActivityWatch/aw-server-rust
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ActivityWatch/aw-server-rust#798 · 1 comment ·
Maintainers usually reply within 1 day
-
Allow configuring sync dir in the `aw-sync/config.toml` filePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
ActivityWatch/aw-server-rust#853 · 1 comment ·
Maintainers usually reply within 1 day
-
Correctness bugs: heartbeat cache, query cache invalidation, commit rollback statePossibly taken A pull request linked to this issue is open or already merged. Openenhancement
Difficulty 4/5 3-5 days Newbie friendliness 25/100
ActivityWatch/aw-server-rust#825 · 2 comments ·
Maintainers usually reply within 1 day
-
aw-sync: rowid upgrade bootstrap does not recover backfills lost under the old timestamp cursorOpen
Difficulty 5/5 Over a week Newbie friendliness 25/100
ActivityWatch/aw-server-rust#793 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
ActivityWatch/aw-server-rust#790 ·
Maintainers usually reply within 1 day
All issues in ActivityWatch/aw-server-rust
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
symposium-dev/symposium#530 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
topgrade-rs/topgrade#2540 ·
Maintainers usually reply within 1 day
-
Invalid JSON options for ngram and edge_ngram silently use defaultsPossibly taken @Tilendlesa claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
noemaforge/vimanam#153 ·
Maintainers usually reply within 1 day