Files
Rosea/.agents/features/android-release-apk.md
T

104 lines
8.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# The Android APK in a release, tested on the Wave 10 through Fabrica's phone queue
Branch `feature/android-release-apk`, 2026-11-21. Follows [`fabrica-release.md`](fabrica-release.md) (F1–F11), which
made Rosea a Fabrica app with no release yet.
## 1. Why and what, in the player's terms
Mark asked for every Domi app to ship its APK, tested at least once on a real phone first: *install, open, the first
screen shows, one real action*. For Rosea the real action is to water her, and the check that matters is that she is
still watered after the app is closed and opened again. A rose that forgets her care on a phone is the cruellest bug
this product could have (CLAUDE.md §8).
A player gets the APK from Rosea's Aula page once a release is published. Nothing about the game changes. This
branch changes how the APK is built, tested and released.
## 2. Technical architecture
```mermaid
flowchart LR
subgraph repo["Rosea (this repository)"]
game["apps/rosea → dist-tauri/"] --> shell["apps/rosea-tauri: tauri android build"]
shell --> debug["debug APK (WebView drivable)"]
shell --> unsigned["release APK, unsigned<br/>android.ts verify: no permission, no backup"]
spec["e2e/android/garden.android.ts"]
end
subgraph fabrica["Fabrica (Mark's PC and the hub)"]
e2e["e2e pipeline, runner windows-e2e<br/>step phone: device Wave 10"] --> lease["hub: phone queue lease"]
lease --> run["fabrica tests run --target phone<br/>reset uninstall, install, launch"]
rel["release pipeline: android → approve → apk"]
end
debug --> e2e
spec --> run
run --> phone(("Wave 10"))
unsigned --> rel
rel --> custos["Custos: custos-sign apk, key rosea-android"]
custos --> mini["minisign (domi-release), SHA256SUMS"]
```
- **A1. Two APKs, one game.** The phone test drives the **debug** APK. Only a debug build's WebView can be reached
over DevTools (Fabrica docs/22 part 5), and Tauri's `devtools` feature would make the *release* WebView drivable for
anyone with a cable, so the shipped APK never gets it. The two APKs carry the same `dist-tauri/` game, the same
manifest patch (no `INTERNET`, no backup) and the same `MainActivity`. They differ in the Rust profile and the
signing key. What the phone test cannot prove about the release APK is listed in §5.
- **A2. The phone only through the queue.** The `phone` step of `.fabrica/artifex/e2e.yaml` says `device: Wave 10`.
The hub queues the run for the phone, the runner sets `ANDROID_SERIAL` and `FABRICA_PHONE_LEASED`, and the nested
`fabrica tests run --target phone` uses that phone without a lease of its own (docs/35 part 4). The spec skips
unless Fabrica's environment is there, so it never reaches for a phone by itself.
- **A3. `reset: uninstall`, not the default `clear`.** The target installs the debug APK. A release build of Rosea
on the phone has another key and would refuse the install. `clear` would wipe its data and then fail anyway;
`uninstall` wipes the same data and installs fresh. The Wave 10 is the dedicated test phone (docs/35 part 5), and
no player's rose lives on it.
- **A4. `maxMinutes: 20`.** One test of about two minutes, plus install and launch. Twenty minutes frees the phone
for the next app if the run hangs, well under the 60-minute default.
- **A5. Caches off C:.** Both pipelines name `GRADLE_USER_HOME` on `D:\build\rosea\gradle` and the NDK
(`NDK_HOME`, which the Tauri CLI needs and this PC does not set). A local build also puts Cargo's target folder,
`TEMP` and `ANDROID_USER_HOME` under `D:\build\rosea`. The pipelines keep Cargo's target in the checkout, because
the installer's artifact glob is there.
- **A6. Signing: `rosea-android` does not exist, and Custos will not make it.** Custos creates an Android key on an
app's first release only for the apps in its `ANDROID_APPS` table (`apps/desktop/src-tauri/src/signing.rs`). In
0.24.0 that table holds Postea, Culina and Liber, and Mark's PC runs 0.22.0, which holds Postea only. Rosea's `apk`
step would stop at `no_key`, as Culina's and Liber's did on 2026-11-20. Two fixes exist, and both belong to
Custos and Mark, not to this repository: a Custos change that adds `rosea-android` (`CN=Rosea Domi`, only
`mnovak/Rosea`, pipeline `release`) and its install on this PC, or Mark's *Create Android key* by hand.
`fabrica-release.md` said "Custos makes the key on the first release". It was wrong, and is corrected here.
- **A7. The certificate is forever.** Once a player installs an APK signed with `rosea-android`, every update must
carry the same certificate (CLAUDE.md §8). The CN names the product, *Rosea Domi*, and the name is still provisional.
The key outlives a rename: a renamed app keeps the old CN, and no player sees it.
## 3. Risk analysis
| Risk | Where | Answer |
| :-- | :-- | :-- |
| A player's rose lost on the test phone | `reset: uninstall` | The Wave 10 is Fabrica's dedicated test phone (docs/35 part 5). The memory rule stands: Fabrica stops the app after the run, and the spec force-stops it in `finally` as well. |
| The release APK phones home | the APK | `android.ts verify` reads the built APK with `aapt2` and refuses any permission or backup flag. It runs in the release pipeline's `android` step and in every local build. |
| Someone made reachable | none | No network feature. The APK asks for no `INTERNET` permission, so the kernel refuses every socket. |
| A tester's place on the phone | the spec | The spec chooses *Not now*, so no town is ever chosen on the phone. |
| A release signed with a stand-in key | signing | The `apk` step names `rosea-android` only, through Custos, and refuses `CUSTOS_PIPE` (sign-apk.ts). There is no fallback to a debug or local keystore. A missing key stops the release. |
| An untested APK published | the release | The phone test is a pipeline of its own: phones are leased per run, and the release must not hold the phone for two hours. Until the e2e pipeline's `phone` step has passed on a commit, that commit is not tagged (process, §5). |
## 4. Gap analysis and the designed solution
| Gap | Solution here | Left open |
| :-- | :-- | :-- |
| The phone target did not say `reset` or `maxMinutes` (the old CLI refused them) | The installed CLI reads both now: a planted `reset: wipe-everything` is refused by `fabrica artifex check`. Written: `reset: uninstall`, `maxMinutes: 20`. | none |
| No pipeline put the phone run in the queue | `e2e.yaml` gains `apk` (`pnpm tauri:android`) and `phone` (`device: Wave 10`). | It has not run: the Wave 10 is not paired in Fabrica (below). |
| The release pipeline's Android step lacked the NDK and put Gradle on C: | `NDK_HOME` and `GRADLE_USER_HOME` in `release.yaml`'s env. | none |
| The release APK was never built | Built here with caches on D:, then checked by `android.ts verify` (§5). | Not signed (A6). |
| `rosea-android` | Named as Custos's change (A6). | **Custos's and Mark's.** |
| The Wave 10 is not paired in Fabrica | `fabrica devices list` shows `WAVE 10C connected (not paired in Fabrica)`. `pass::resolve` then finds no phone named *Wave 10*, and the step fails before it runs. | **The Fabrica session's** (Pipelines → Workshop → Devices → Pair a phone). |
| Publication | G6.1: the repository is public, so a release is public, and a legal check of the look comes first. | **Mark's** (`fabrica-release.md` F1). |
## 5. Verification matrix
| Case | Kind | How | Status |
| :-- | :-- | :-- | :-- |
| The release APK builds with every cache off C: | build | `pnpm tauri:android-release` | done 2026-11-21: 27 min from cold (Gradle 9.6.1 downloaded to D:), 5.60 MiB, arm64-v8a, versionCode 1000, sha256 4d52e9eca4cd2e56… (unsigned) |
| The release APK asks for no permission and allows no backup | build check | `android.ts verify <unsigned apk>` (aapt2) | done: verified; `aapt2 dump badging` shows no `debuggable` and only androidx's own `DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION` (the app's own signature permission, not a capability) |
| `reset` and `maxMinutes` are read, and a wrong `reset` is refused | config | `fabrica artifex check` with a planted value | done: refused with `targets[1].reset: clear, uninstall or keep` |
| The pipelines are valid | config | `fabrica artifex check` | done: 0 problems |
| Install, open, first screen, water, close, reopen, still watered | e2e, real phone | the e2e pipeline's `phone` step | **not run**: the phone is not paired in Fabrica |
| The spec never reaches for a phone outside the queue | e2e | `test.skip` without `FABRICA_TESTS_PACKAGE` and `ANDROID_SERIAL` | by construction |
| The signed APK verifies with `rosea-android`'s certificate | release | the `apk` step (custos-sign verifies with apksig) | **not run**: no key |
| What the debug test cannot prove about the release APK | manual | install the signed release APK on the Wave 10 once, water, close, reopen | after the key exists |