From 1b5637f6eadc523ed72e176eeb069a6c0296d430 Mon Sep 17 00:00:00 2001 From: Siphonight Date: Wed, 18 Nov 2026 22:47:24 +0100 Subject: [PATCH] =?UTF-8?q?docs:=20AGENTS.md=20refresh=20=E2=80=94=20verif?= =?UTF-8?q?ied=20counts=20(346/16),=20release=20traps=20(publish-release.p?= =?UTF-8?q?y,=20versionCode=20before=20tag,=20CHANGELOG=20embed),=20R8/Gso?= =?UTF-8?q?n=20lessons,=20emulator=20recipe,=20privacy=20constraints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 123 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 42 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 922ca66..81a0d41 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,52 +1,91 @@ # AGENTS.md +Android app (Kotlin + Jetpack Compose, single module `:app`), 100 % local HRT tracking. +Docs, comments and CHANGELOG are French-first; `README.md` (FR) ↔ `README.en.md` must stay in sync. + ## Build & Test -- `./gradlew assembleDebug` – build debug APK -- `./gradlew assembleRelease` – build optimized release APK (uses debug keystore if none else) -- `./gradlew testDebugUnitTest` – run 326 unit tests (282 without local data) -- `./gradlew connectedDebugAndroidTest` – run 14 UI tests (requires emulator/device) -- `./gradlew lint` – lint check must pass green before release +- `./gradlew assembleDebug` — debug APK +- `./gradlew testDebugUnitTest` — 346 JVM tests (292 without local data) +- `./gradlew connectedDebugAndroidTest` — 16 Compose UI tests (emulator/device required) +- `./gradlew lint` — must be green before any release +- No CI: these gates run locally; every release commit needs `testDebugUnitTest` green. +- Needs `local.properties` (`sdk.dir=…`) or `ANDROID_HOME`; platform 37 auto-downloaded; JDK 17+. -## Release Process -1. Commit and tag version (e.g., `v1.4.0`). -2. Build release APK: `./gradlew assembleRelease`. -3. Sign with keystore (`scripts/make-release-keystore.sh` generates if missing). -4. Publish two APKs per tag on Gitea releases (`*-release.apk`, `*-debug.apk`). -5. Sync web version if applicable (v1.9.8+). +## Command order (release) +`lint` → `testDebugUnitTest` → `connectedDebugAndroidTest` → `assembleRelease` → +emulator validation of the RELEASE APK (§16.ter) → tag → publish. +Release-APK validation before tagging is OBLIGATORY (checklist step 3.bis). -## Testing -- Unit tests in `app/src/test/java/com/hormonetrack/pk/` and `data/`. -- UI tests in `app/src/androidTest/java/com/hormonetrack/uitest/`. -- Data-driven tests use `local-test-data/` (gitignoré, not in repo). -- Regression tests numbered (e.g., #64 found LogDoseRequestTest crash). +## Toolchain — pinned; bump only after reading docs/DEVELOPPEMENT.md §3 +- AGP 9.4.0 / Kotlin compose plugin 2.3.21 / KSP 2.3.11 / Gradle 9.7.1 / Compose BOM 2026.08.00 — tested together. +- No version catalog, no ktlint/detekt. `app/lint.xml` downgrades two Compose checks to warnings; + `StringFormatMatches` stays a blocking error (it caught bugs #47/#48). +- Bump `versionCode` + `versionName` in `app/build.gradle.kts` BEFORE the release commit/tag + (v1.3.0–v1.3.2 shipped with a stale VERSION_NAME). -## Architecture Highlights -- Core logic: `app/src/main/java/com/hormonetrack/pk/` (models, calibration, curves). -- Room database: `app/src/main/java/com/hormonetrack/data/`. -- UI: Jetpack Compose in `app/src/main/java/com/hormonetrack/ui/`. -- PK models: Estrannaise, Transfem Science, WHSAH in `pk_profiles.json` (analytique v1.9.0+). -- Calibration per ester and period (v1.4.8); Cycles (v1.14.0) — journal quotidien de 14 symptômes DRSP, carte Cycle en cours, récurrence des symptômes. +## Release +- Every release adds a `## [X.Y.Z]` section to `docs/CHANGELOG.md` (no "v" prefix) — the + `copyChangelog` task embeds it in the APK ("Nouveautés" dialog); missing section = empty dialog. +- Annotated tag `vX.Y.Z`, pushed to BOTH remotes: `origin` (gitea.cloudyfy.fr) and `farewell` + (gitea.farewell.dev, SSH; push-to-create disabled). +- Publish both APKs: `python3 scripts/publish-release.py cloudyfy|farewell vX.Y.Z` + (purge + upload + verify by download). Do NOT use `scripts/gitea-release.py` for APKs + (mono-APK; concurrent uploads overwrite each other — lesson #43). +- Gitea tokens come from the macOS keychain, scope `write:repository`. Never commit secrets; + `keystore.properties`/`*.keystore` are gitignored. Never compare tags as strings + (`v1.2.10` < `v1.2.5` lexicographically). +- Signing: `assembleRelease` uses the DEBUG key while `keystore.properties` is absent + (release installs over debug, no data loss). `scripts/make-release-keystore.sh` creates it — + signature then changes ⇒ on-device migration: export → uninstall → reinstall → import (§16.quater). +- Commits are layered with prefixes: `engine:` / `data:` / `reminders+ui:` / `scripts/docs:` / `release`. -## Backup & Data -- Manual export/import JSON: `Settings → Sauvegarde JSON` (v1.4.2+). -- Auto-backup quotidien (v1.7.0, opt-in): selects folder via SAF, stores `hormonetrack-auto-YYYYMMDD-HHmm.json`, keeps last 7 copies. -- Backup excludes logs, exports, foreign files. -- Restore via import JSON. +## R8 / Gson traps (release-only bugs) +- `proguard-rules.pro` carries explicit `-keep` rules for Gson-reflected models + (`data.model.**`, `BackupData`, `TConfig`) and WorkManager classes. +- Two crashes happened ONLY in release (#64 class removed by R8, #72 `cycleEntries` null under + R8) — JVM tests never exercise R8; smoke-test backup export/import + charts on a release build. -## Watch GT 3 Gadgetbridge -- Notifications mirrored to Huawei Watch GT 3 via Gadgetbridge (FOSS) or Huawei Health. -- Gadgetbridge can install watchfaces `.hwt` but not apps `.hap`. -- See `docs/MONTRE-GADGETBRIDGE.md` for details. +## Emulator recipe (docs/DEVELOPPEMENT.md §16.ter) +- `scripts/seed-emulator.py ` injects real data (from `local-test-data/`) into + the debug app DB; extract the DB together with its `-wal` file after `force-stop` (WAL trap). +- ⚠️ `connectedDebugAndroidTest` UNINSTALLS the app (DB + DataStore wiped) — seed AFTER the last + instrumented run. +- Pan/pinch on the chart is NOT testable via `adb input swipe` headless (no intermediate moves). -## Development Resources -- `docs/DEVELOPPEMENT.md` – architecture, math, bugs, tests. -- `docs/GUIDE_INSTALLATION.md` – user installation steps. -- `scripts/` – release keystore, publish release, seed emulator. -- Check `opencode.json` for any defined tasks (use `opencode` skill if needed). +## Tests +- Unit: `app/src/test/java/com/hormonetrack/` (pk, data, ui, util, reminder, settings); + UI: `app/src/androidTest/java/com/hormonetrack/`. +- Data-driven regressions load real exports from `local-test-data/` (gitignored) and SKIP when + absent — that's the 292 vs 346 delta. Regressions are numbered (e.g. #73 → `CycleEntrySliderTest`). +- `ui/ChartScreenSourceGuardTest.kt` reads `ChartScreen.kt` source and pins the gesture block + (+ its `rememberUpdatedState` alias) in that file — restructuring ChartScreen (~700 lines, + the #54–#70 hotspot) means rewriting this guard by design. +- No TODO/FIXME markers in code — remaining work lives in docs/DEVELOPPEMENT.md + §19 (limits), §20 (ideas), §21 (release manual checklist — NOT a TODO list). -## Critical Command Order -1. `./gradlew lint` -2. `./gradlew testDebugUnitTest` -3. `./gradlew connectedDebugAndroidTest` -4. `./gradlew assembleRelease` -5. Tag and publish release. \ No newline at end of file +## Architecture +- Packages in `app/src/main/java/com/hormonetrack/`: `pk/` pure PK engine (no Android deps, + time zones parameterized for deterministic tests), `data/` Room (hand-written migrations + v1→v4, `exportSchema=false`), `reminder/` (exact alarms, notification actions, boot), + `settings/` (DataStore), `ui/` (Compose; `screens/settings/` = cards). +- Assets: `mcmc_samples.json` (ESE MCMC cloud) in main; `pk_profiles.json` is test-only + (`src/test/assets/`) since v1.9.0 — Estrannaise is analytic at runtime. +- Backup JSON is versioned (`BackupData.version`); import rejects newer/unparsable backups + BEFORE wiping (transactional `db.withTransaction`); keep optional-field retrocompat when extending. + +## Hard privacy constraints +- The repo must NEVER contain health data: `local-test-data/` and `TODO.md` are gitignored; + history was scrubbed before the first push (§8.bis). +- No `android.util.Log`, no `GlobalScope` in `app/src/main` — health logging goes through + `AppLog` (private `filesDir` buffer). `allowBackup=false`. + +## Web port +- Separate repo `Siphonight/HormoneTrack-web` (same Gitea remotes), synced release-by-release; + Android-only features (Cycles, v1.14.0) are not ported yet. Engine/chart changes have JS + mirrors (`pk-engine.js`, `chart.js`) — flag sync needs in releases. + +## Docs map +- `docs/DEVELOPPEMENT.md` — full dev doc: §3 versions, §14 numbered bugs, §16 release checklist, + §16.ter emulator, §16.quater keystore, §19–§21. +- `docs/CHANGELOG.md` (embedded in app), `docs/GUIDE_INSTALLATION.md` (user guide), + `docs/MONTRE-GADGETBRIDGE.md` (watch).