[docs] TauriPlatforms: Four versions from one codebase on Tauri 2: CLAUDE.md, the roadmap's platform track, the analysis

This commit is contained in:
2026-11-17 18:45:36 +01:00
parent 22f55dc9fa
commit 3f95a1b37d
3 changed files with 256 additions and 16 deletions
+103 -12
View File
@@ -20,14 +20,19 @@ For the engineering picture read [`.agents/GAP_ANALYSIS.md`](.agents/GAP_ANALYSI
> always **Rosea Domi** in public, and *Domi* never appears alone. In source the name lives in exactly
> three places — `packages/schema/src/constants.ts`, `apps/rosea/index.html` and the web manifest —
> plus the `@rosea/*` package scope and the IndexedDB database name, which change together with them.
> Renaming must stay a one-commit operation until the name is confirmed.
> The app shell adds a fourth: `apps/rosea-tauri/src-tauri/tauri.conf.json` (`productName`, window
> title), which the shell's test holds equal to the constants (§2, *Four versions*).
> Renaming must stay a one-commit operation until the name is confirmed. The bundle identifier is
> the exception: once an APK or installer reaches a player it cannot change without making a
> second, separate app, so it is chosen once, before the first release (§8).
---
## 1. What this project is
**Rosea Domi** is a small web game, installable as a PWA, about a living rose, a fox, and the time we
give to people. It belongs to the Domi ecosystem and is linked from the parent mode of Panda Domi; the
**Rosea Domi** is a small game about a living rose, a fox, and the time we give to people. It ships
as **four versions from one Svelte codebase** — a PWA, an Android app, an iOS app and a desktop app
(§2, *Four versions*). It belongs to the Domi ecosystem and is linked from the parent mode of Panda Domi; the
fox is a quiet nod to Ulfík the red panda (they look alike — an Easter egg, never an explanation).
It is made **for lonely people**, and the word *loneliness* never appears anywhere in the product.
@@ -141,7 +146,13 @@ packages/
ui/ # Svelte components + tokens + copy/. No business logic.
apps/
rosea/ # the PWA (Svelte 5 + Vite + workbox) -> @rosea/app
rosea/ # the game (Svelte 5 + Vite + workbox) -> @rosea/app. Built twice:
# dist/ the PWA, under /Rosea/, with its service worker
# dist-tauri/ for the shell: base /, no service worker, no manifest
rosea-tauri/ # the Tauri 2 shell -> @rosea/tauri. Wraps apps/rosea/dist-tauri/; imports no package
src-tauri/ # Rust (a window and nothing else), tauri.conf.json, capabilities/
android/ # what must survive `tauri android init` (gen/ is never committed)
scripts/ # icons from apps/rosea/public/icon.svg; the Android privacy patch
services/
lucerna/ # OPTIONAL discovery service (Phase 4), Rust (Axum) + SQLite.
@@ -179,6 +190,7 @@ apps/rosea ──► packages/ui ──► packages/engine ──► packages/sc
└───────► packages/identity ──► packages/schema
services/lucerna ──► packages/schema (trace shape only, via generated JSON Schema)
tools/art-prep ──► art/manifest.json, packages/content, packages/schema (never imported by the app)
apps/rosea-tauri ──► apps/rosea's BUILT output (dist-tauri/) only — no package, no source file
```
- `packages/engine` is pure. Time and randomness are parameters. This is what makes growth, taming and
@@ -186,6 +198,10 @@ tools/art-prep ──► art/manifest.json, packages/content, packages/schema
- `apps/rosea` contains zero growth, taming or sky logic. It renders what the engine returns.
- `services/lucerna` must be deletable. If removing it breaks the rose, the planets, the fox, friends
or the sunset, the shared sky has stopped being optional and that is a **blocker**.
- `apps/rosea-tauri` must be deletable too: removing it leaves the PWA whole. The game never asks
which shell it is in except through one build-time constant, `__ROSEA_SHELL__` (`'web'` or
`'tauri'`), read in `apps/rosea/src/App.svelte` only, for wiring (no service worker; the app counts
as installed). No package ever reads it.
### Why Svelte, and where Rust earns its place
@@ -194,12 +210,41 @@ Web first is the decision: the game must run from a link, on any phone, with no
- **`services/lucerna`** — a small, long-running, internet-facing service. Rust (Axum) gives memory
safety and a tiny footprint on a home server. Its contract is the JSON Schema in `packages/schema`.
- **A Tauri 2 shell, later (Phase 6)** — same Svelte code, packaged for Android and iOS, matching the
ecosystem's move to Tauri. Its main gift is **local notifications without a server** (see the
notification trap in §8).
- **A Tauri 2 shell, now (the platform track)** — same Svelte code, packaged for Android, iOS and the
desktop, matching the ecosystem's move to Tauri. Its later gift (Phase 6) is **local notifications
without a server** (see the notification trap in §8).
- **Not** a Rust UI framework (Leptos, Dioxus, Yew) and **not** Rust→WASM for the sunset or star
maths: both are small and fast in TypeScript. WASM enters only with a measurement that says it must.
### Four versions, one garden — decided by the author, 2026-11-17
| Version | Made from | Runs in | Where it can be built |
|:--|:--|:--|:--|
| **PWA** | `apps/rosea` → `dist/` | any browser; GitHub Pages under `/Rosea/` | any machine |
| **Android** (APK) | `apps/rosea-tauri` → `pnpm tauri:android` | Android System WebView | Windows, macOS or Linux with the Android SDK, NDK 27, JDK 17 and the Rust Android targets |
| **Desktop** | `apps/rosea-tauri` → `pnpm tauri:build` | WebView2 (Windows), WKWebView (macOS), WebKitGTK (Linux) | each on its own OS: an NSIS installer on Windows; `.app`/`.dmg` on macOS; `.deb`/AppImage on Linux |
| **iOS** | `apps/rosea-tauri` → `pnpm tauri:ios` | WKWebView | **macOS with Xcode only**, and an Apple developer account to put it on a phone |
- **One codebase.** The same Svelte 5 app, the same packages, the same IndexedDB code in all four.
The shell adds a window around the built game and nothing else: no Tauri command, no plugin, no
`@tauri-apps/api` in the game. Each plugin that arrives later (notifications in Phase 6) is reviewed
for network access before it is added, as in Amicitia.
- **Layout: `apps/rosea-tauri/src-tauri/`.** The Tauri 2 CLI looks for `src-tauri/tauri.conf.json`
below the folder it runs in, so this is the layout it expects, one level down. Not Tauri's default
`apps/rosea/src-tauri/`: that would put Rust and the Tauri CLI into the PWA's package. Here the shell
is deletable, and its only input is a built folder — the same seam the e2e suites test
(`tauri-platforms.md` D1).
- **The shell's build of the game** (`vite build --mode tauri`, into `apps/rosea/dist-tauri/`): base `/`,
because Tauri serves the files at the root of its own origin; **no service worker and no web
manifest**, because the files are already on the device and a store or installer brings updates;
the content-security policy delivered by Tauri (`app.security.csp`), the same string as the PWA's
`<meta>` policy, held equal by a test (§8).
- **The non-negotiable properties hold in all four.** Local-first, anonymous, no free text, never
counting people, nothing written outside IndexedDB, no analytics — in any SDK either: the shell
links no analytics, crash-reporting or ads library, and the webviews' own reporting is switched off
where the platform allows it (§8, *the webview phones home*). The Android app asks for **no
`INTERNET` permission** while Rosea has no network feature, so the kernel refuses it any socket.
---
## 3. Commands
@@ -226,12 +271,26 @@ pnpm art:board # prompts + stand-ins -> tools/art-prep
pnpm art:accept <id> <file> # an accepted picture -> art/final/*.webp, sheets cut
tsx scripts/build-places.ts <folder> # rebuilds the town list from downloaded Natural Earth + tzdb (by hand)
# The Tauri 2 shell (apps/rosea-tauri) — each builds the game for the shell first (dist-tauri/):
pnpm tauri:dev # desktop window on the Vite dev server, 127.0.0.1:5173
pnpm tauri:build # desktop release: on Windows an NSIS installer and the .exe
# needs Rust (MSVC), WebView2, VS Build Tools; macOS/Linux on their own OS
pnpm tauri:android # Android debug APK (universal); needs ANDROID_HOME, NDK 27, JDK 17,
# the four Rust Android targets. Install: adb install -r <apk>
pnpm tauri:ios # macOS + Xcode only — refuses elsewhere with the reason (§8)
pnpm --filter @rosea/tauri test # the shell's tests: config (CSP, name, origin), privacy patch, shell build
tsx e2e/apps/check-garden.ts desktop # the built .exe: water her, close, reopen, still watered (temp data folder)
tsx e2e/apps/check-garden.ts android # the installed APK on the device over adb; `pm clear`s the TEST app first
# Not yet — they arrive with their first feature:
cargo test --manifest-path services/lucerna/Cargo.toml # Phase 4 onward
```
The build's base path is `/Rosea/` (GitHub Pages' project sub-path); `ROSEA_BASE=/x/` overrides it
for the build and for both Playwright suites together.
for the build and for both Playwright suites together. `pnpm --filter @rosea/app build:shell` builds
the shell's copy instead (`--mode tauri`: base `/`, into `dist-tauri/`); the `tauri:*` commands run it.
`pnpm tauri:android` ends by reading the built APK with `aapt2` and fails if it asks for any
permission or allows backup (`tauri-platforms.md` D6).
> **The `pnpm test` trap, imported from Aeterna.** Exit code 0 says the command succeeded, not that
> tests ran. A filter that matched nothing and a green run look identical. **Quote the counts per
@@ -261,7 +320,22 @@ replaying `events` through the engine. A number that cannot be derived from the
`derived`.
**Nothing else is written anywhere.** No cookies, no `localStorage`, no analytics of any kind, no
third-party origin, no fonts or images from a CDN.
third-party origin, no fonts or images from a CDN. This holds in the shell too: `localStorage` and
`sessionStorage` stay forbidden there, and the Rust side writes no file of its own.
**Where IndexedDB lives in each version** (the webview owns the folder; Rosea writes only its
database there — the webview keeps its own caches beside it):
| Version | Where the `rosea` database is |
|:--|:--|
| PWA | the browser profile, per origin; evictable (§8) |
| Windows | WebView2's user data folder: `%LOCALAPPDATA%\<identifier>\EBWebView\` |
| Android | the app's private data: `/data/data/<identifier>/app_webview/` — no Auto Backup, no device transfer (`tauri-platforms.md` D6) |
| macOS / iOS | WKWebView's website data in the app's container (`Library/WebKit/`) *(predicted)* |
| Linux | WebKitGTK's data dir under `~/.local/share/<identifier>/` *(predicted)* |
A rose made in the PWA and the same player's Android app are **two roses** until the player carries
one across with *Keep her safe* (save to a file, bring her back). Nothing syncs them.
**On `services/lucerna`, only when the player has opted in to the shared sky (Phase 4):** an anonymous
trace id, a coarse geocell (~1 km), a day bucket (never a timestamp finer than a day), and the gesture
@@ -314,6 +388,8 @@ Format : [<Package>] <FeatureName>: <one-line description>
Example: [engine] RoseGrowth: Grow from total days of care, never from consecutive days
Remote : GitHub (primary) — branch main; mirrored to gitea.marek-novak.cz, as in Panda Domi
Deploy : GitHub Actions builds apps/rosea and publishes it to GitHub Pages on every merge to main
Apps : the APK and the desktop installer are built by hand on this machine until CI can (G0.22);
never committed. Release signing keys never enter the repository (§5.3's token rule)
```
PRs are opened and merged on GitHub. The Gitea mirror is a backup and must stay in sync — after every
@@ -361,7 +437,10 @@ repository, a review document or command output.
### 5.4 The deployed bundle is the only thing the player sees
The player opens an installed PWA served from a precached shell. Source changes are invisible until
the app is rebuilt, the service worker's bytes change, and the client picks up the new worker. When
the app is rebuilt, the service worker's bytes change, and the client picks up the new worker. In the
Android, iOS and desktop apps the game is inside the package: a change reaches a player only with a
new APK or installer, which must carry a higher version (`apps/rosea/package.json`, read by
`tauri.conf.json`) or Android refuses it as a downgrade. When
reporting a fix, **say whether the bundle was rebuilt and redeployed**. If a change is deliberately
invisible (a refactor, a library update), say so explicitly — a fresh build that looks identical is
otherwise indistinguishable from a stale one. *(Imported from NoAlgoTube and Aeterna, where it
@@ -413,7 +492,10 @@ happened twice.)*
### 5.7 A test run leaves the machine as it found it
Nothing binds to anything but `127.0.0.1`. Every browser a test starts is closed in `finally`. Do not
Nothing binds to anything but `127.0.0.1` — the shell's dev server and a webview's debugging port
included; a phone reaches the dev server through `adb reverse`, never through `--host`. Every browser
a test starts is closed in `finally`, and so is every app a test launches (the desktop `.exe`, the
app on the tablet: `am force-stop`). Do not
start a full run above ~80% CPU. *(Imported from Ludus and Aeterna.)* **Enforced, not trusted:**
`pnpm test`, `test:e2e` and `test:offline` first run `pnpm guard:cpu`, which waits up to three minutes
for the machine to calm and then refuses (`tools/cpu-guard`, lessons/process.md). A dedicated machine
@@ -494,7 +576,7 @@ No timestamp finer than a day, no precise location, no free text, no link to the
| Trap | Why it bites |
|:--|:--|
| **A PWA cannot schedule a local notification** *(predicted — verify first)* | The sunset invitation is time-based. A web app generally cannot fire a notification at a set time while closed without a **push server** sending it, and a push server that knows when someone's sunset is knows roughly where they are. On iOS, web push works only for a site added to the home screen. **Decided in Phase 0 (2026-11-01):** in-app sunset only for the web build — no push server — and local notifications through the Tauri shell later (Phase 6). |
| **A PWA cannot schedule a local notification** *(predicted — verify first)* | The sunset invitation is time-based. A web app generally cannot fire a notification at a set time while closed without a **push server** sending it, and a push server that knows when someone's sunset is knows roughly where they are. On iOS, web push works only for a site added to the home screen. **Decided in Phase 0 (2026-11-01):** in-app sunset only for the web build — no push server — and local notifications through the Tauri shell later (Phase 6). The shell exists since 2026-11-17; its notification plugin is still Phase 6. |
| **Polar day and polar night** *(measured 2026-11-01)* | Above the Arctic Circle the sun does not set in summer or rise in winter. "Every day at sunset" has no answer there. Measured: the almanac has no rise or set in Tromsø on 21 June and no events at all on 21 December. `engine/sun` returns `polar-day` or `polar-night` and a gentle moment for each (the lowest light; noon twilight) — `.agents/features/sun.md` D4. |
| **DST and the local day** *(measured 2026-11-01)* | Sunset jumps an hour twice a year under a player who did nothing: Prague's is 18:28 on 28 March and 19:29 on the 29th, while the sun moved one minute. A day boundary computed in UTC records Monday-evening care as Tuesday's. One module computes the day; the sun works in instants. |
| **Comfort becomes wallpaper** | The same words every day stop meaning anything. Comfort words are occasional; the real trace of a real person is constant. Track repetition in tests. |
@@ -515,6 +597,14 @@ No timestamp finer than a day, no precise location, no free text, no link to the
| **Pages hosts files, not services** | `services/lucerna` cannot live on Pages. It runs on Mark's own server (Phase 4), and the app must work fully without it. |
| **`pnpm test` exits 0 having run nothing** | Quote counts per package. |
| **Playwright against the dev server** | It never registers the service worker and has never reproduced a caching bug. |
| **Base path in the shell** *(predicted)* | The PWA lives under `/Rosea/`; Tauri serves the game at the root of its own origin (`https://tauri.localhost/` on Windows and Android with `useHttpsScheme`, `tauri://localhost/` on macOS and iOS). A shell build with base `/Rosea/` opens a blank window. The shell's copy is built with base `/` into its own folder, so the two can never be mixed up. |
| **A service worker inside a webview** *(predicted)* | Inside Tauri the files are already on the device; a worker would cache a second copy, could serve a stale game after an app update, and *A new version of the garden is ready* would offer a refresh that fetches nothing. The shell's build has no worker and no manifest: `vite-plugin-pwa` is disabled there and `registerSW` is its no-op. |
| **Two content-security policies** *(predicted)* | The PWA carries its policy in a `<meta>` tag (Pages sends no headers). Tauri can deliver its own policy and adds hashes for the scripts it injects; a page with **both** obeys both, and the `<meta>` would block what Tauri adds. So the shell's build has no `<meta>` policy and Tauri delivers the same string, held equal by `apps/rosea-tauri` test. |
| **IndexedDB eviction in a webview** *(predicted)* | WebView2 and Android WebView are Chromium: best-effort storage can be cleared under disk pressure, and an app's data is wiped on uninstall (the Windows uninstaller offers to delete app data). WKWebView on iOS may purge website data of an app that is not used. `persist()` is asked in the shell as in an installed PWA; *Keep her safe* stays the real defence — and on Android and iOS saving a file through `<a download>` does nothing (measure; `tauri-platforms.md` G-T4). |
| **The webview phones home** *(measured in Amicitia, 2026-11-08; predicted here)* | A webview talks to its maker on its own: WebView2 to Microsoft and DNS-over-HTTPS providers, Android WebView to Google's metrics and an Autofill server as soon as a field takes focus. Desktop: `additionalBrowserArgs` switches these off (undocumented feature names a runtime update can break). Android: no `INTERNET` permission at all while Rosea has no network feature, plus metrics and Safe Browsing off in the manifest, applied by a committed patch because `gen/` is regenerated. Measure on every release build. |
| **Auto Backup sends the garden to a cloud** *(predicted)* | A stock Tauri Android manifest lets Android copy the app's data — the care log, the keys, the chosen town — to the player's cloud backup, without the player choosing it. The patch sets `allowBackup="false"` and excludes every domain from cloud backup and device transfer; *Keep her safe* is how a rose moves. |
| **iOS cannot be built on Windows** *(known)* | `tauri ios init` and every iOS build need macOS and Xcode; installing on a phone needs an Apple developer account (free for one's own device, paid for TestFlight and the App Store). `pnpm tauri:ios` refuses on Windows with this reason. |
| **The bundle identifier and the origin are forever** | An Android `applicationId` or iOS bundle id cannot change after a release without becoming a different app: the old one keeps the player's rose, the new one starts empty. Chosen once (`cz.mareknovak.domi.rosea`), before the first release, even though the product name may still change. The same holds for `useHttpsScheme` (`true`): flipping it changes the webview's origin, and IndexedDB is per origin, so the rose is left behind. The shell's test pins both. |
---
@@ -531,4 +621,5 @@ No timestamp finer than a day, no precise location, no free text, no link to the
| Add or edit hope sentences | Agents propose in `content/candidates/`; the author verifies with `pnpm library:verify`. Then `pnpm validate:library` |
| Change what friends can send each other | `packages/schema` §6.1 — and re-read §5.6 rule 1 |
| Change the shared sky | `services/lucerna/` — and re-read §4 and §5.6 rules 6–7 |
| Build the Android, iOS or desktop app | `apps/rosea-tauri/`, then `.agents/features/tauri-platforms.md` and the shell traps in §8 |
| Understand a past decision | `.agents/features/*.md`, `git log`, `.agents/reviews/*.md` |