1# whiskers-store
2
3Whiskers' storage on SQLite: one database file per device and one for the service, with the pictures as blobs in
4it. Every table, and how each merges, is in [`SCHEMA.md`](SCHEMA.md); the SQL is in `migrations/`.
5
6It implements the core's ports over one [`Store`]: `SqliteMemory` (`Memory`), `SqliteChat` (`ChatStore`),
7`SqliteLog` (`Log`, and the copy of the other devices' lines), `SqliteHousehold` (`HouseholdStore`, which
8`TimeKeeper` keeps its document in) and `SqlitePictures` for a device; and for the service the three hubs
9(`SqliteMemoryHub`, `SqliteHouseholdHub`, `SqliteChatHub`), `SqliteJournal`, `SqlitePictureShelf` and
10`SqliteAllowance`, which pass the laws of `whiskers-conformance` unchanged (`tests/conformance.rs`).
11
12The merge rules are not here. They are pure functions in `whiskers-core`, run on a document read from the rows,
13and the difference is written back in one transaction. What is here, in the schema, are the rules about what must
14not exist: a forgotten memory leaves only a tombstone of its id, when and by whom, and the identities of the turns it was told in, which empty
15what was said in them; `tests/forgetting.rs` and `tests/forgetting_turns.rs` search the bytes of the database file and of its write-ahead log to show it.
16The parents' log is read a day at a time through an index (`SqliteLog::read_range`, `days`) and can be cleared by age (`expire_before`), and what
17waits for the memory to think about it is kept (`SqliteReflections`) so a stop loses none of it.
18
19| File | What |
20|---|---|
21| `migrations/` | The numbered SQL migrations. `PRAGMA user_version` says where a database is. |
22| `src/lib.rs` | `Store`: opening, pragmas, migrations, `scrub` (empty the write-ahead log) and `backup_to` (a consistent copy). |
23| `src/memory.rs` | `SqliteMemory`: the memory as a `MemoryDoc`, written as the difference between two of them. |
24| `src/chat.rs`, `src/household.rs`, `src/log.rs`, `src/pictures.rs` | A device's chat, grown-ups' choices and minutes, parents' log (and the copy of the others', read by range and by day, cleared by age), and pictures. |
25| `src/reflections.rs` | The exchanges waiting for the memory to think about them. |
26| `src/hubs.rs`, `src/journal.rs`, `src/spend.rs` | The service's hubs, journal and spending. |
27| `tests/` | The conformance suite on these adapters, the device's own behaviour, and forgetting. |
28
29Builds for Linux and for Android (`aarch64-linux-android` through `cargo-ndk`) with SQLite compiled in; it is left
30out of the wasm check like the other native-only crates.