docs: AGENTS.md refresh — verified counts (346/16), release traps (publish-release.py, versionCode before tag, CHANGELOG embed), R8/Gson lessons, emulator recipe, privacy constraints
This commit is contained in:
parent
2e7d610440
commit
1b5637f6ea
123
AGENTS.md
123
AGENTS.md
@ -1,52 +1,91 @@
|
|||||||
# AGENTS.md
|
# 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
|
## Build & Test
|
||||||
- `./gradlew assembleDebug` – build debug APK
|
- `./gradlew assembleDebug` — debug APK
|
||||||
- `./gradlew assembleRelease` – build optimized release APK (uses debug keystore if none else)
|
- `./gradlew testDebugUnitTest` — 346 JVM tests (292 without local data)
|
||||||
- `./gradlew testDebugUnitTest` – run 326 unit tests (282 without local data)
|
- `./gradlew connectedDebugAndroidTest` — 16 Compose UI tests (emulator/device required)
|
||||||
- `./gradlew connectedDebugAndroidTest` – run 14 UI tests (requires emulator/device)
|
- `./gradlew lint` — must be green before any release
|
||||||
- `./gradlew lint` – lint check must pass green before 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
|
## Command order (release)
|
||||||
1. Commit and tag version (e.g., `v1.4.0`).
|
`lint` → `testDebugUnitTest` → `connectedDebugAndroidTest` → `assembleRelease` →
|
||||||
2. Build release APK: `./gradlew assembleRelease`.
|
emulator validation of the RELEASE APK (§16.ter) → tag → publish.
|
||||||
3. Sign with keystore (`scripts/make-release-keystore.sh` generates if missing).
|
Release-APK validation before tagging is OBLIGATORY (checklist step 3.bis).
|
||||||
4. Publish two APKs per tag on Gitea releases (`*-release.apk`, `*-debug.apk`).
|
|
||||||
5. Sync web version if applicable (v1.9.8+).
|
|
||||||
|
|
||||||
## Testing
|
## Toolchain — pinned; bump only after reading docs/DEVELOPPEMENT.md §3
|
||||||
- Unit tests in `app/src/test/java/com/hormonetrack/pk/` and `data/`.
|
- 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.
|
||||||
- UI tests in `app/src/androidTest/java/com/hormonetrack/uitest/`.
|
- No version catalog, no ktlint/detekt. `app/lint.xml` downgrades two Compose checks to warnings;
|
||||||
- Data-driven tests use `local-test-data/` (gitignoré, not in repo).
|
`StringFormatMatches` stays a blocking error (it caught bugs #47/#48).
|
||||||
- Regression tests numbered (e.g., #64 found LogDoseRequestTest crash).
|
- 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
|
## Release
|
||||||
- Core logic: `app/src/main/java/com/hormonetrack/pk/` (models, calibration, curves).
|
- Every release adds a `## [X.Y.Z]` section to `docs/CHANGELOG.md` (no "v" prefix) — the
|
||||||
- Room database: `app/src/main/java/com/hormonetrack/data/`.
|
`copyChangelog` task embeds it in the APK ("Nouveautés" dialog); missing section = empty dialog.
|
||||||
- UI: Jetpack Compose in `app/src/main/java/com/hormonetrack/ui/`.
|
- Annotated tag `vX.Y.Z`, pushed to BOTH remotes: `origin` (gitea.cloudyfy.fr) and `farewell`
|
||||||
- PK models: Estrannaise, Transfem Science, WHSAH in `pk_profiles.json` (analytique v1.9.0+).
|
(gitea.farewell.dev, SSH; push-to-create disabled).
|
||||||
- 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.
|
- 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
|
## R8 / Gson traps (release-only bugs)
|
||||||
- Manual export/import JSON: `Settings → Sauvegarde JSON` (v1.4.2+).
|
- `proguard-rules.pro` carries explicit `-keep` rules for Gson-reflected models
|
||||||
- Auto-backup quotidien (v1.7.0, opt-in): selects folder via SAF, stores `hormonetrack-auto-YYYYMMDD-HHmm.json`, keeps last 7 copies.
|
(`data.model.**`, `BackupData`, `TConfig`) and WorkManager classes.
|
||||||
- Backup excludes logs, exports, foreign files.
|
- Two crashes happened ONLY in release (#64 class removed by R8, #72 `cycleEntries` null under
|
||||||
- Restore via import JSON.
|
R8) — JVM tests never exercise R8; smoke-test backup export/import + charts on a release build.
|
||||||
|
|
||||||
## Watch GT 3 Gadgetbridge
|
## Emulator recipe (docs/DEVELOPPEMENT.md §16.ter)
|
||||||
- Notifications mirrored to Huawei Watch GT 3 via Gadgetbridge (FOSS) or Huawei Health.
|
- `scripts/seed-emulator.py <db> <backup.json>` injects real data (from `local-test-data/`) into
|
||||||
- Gadgetbridge can install watchfaces `.hwt` but not apps `.hap`.
|
the debug app DB; extract the DB together with its `-wal` file after `force-stop` (WAL trap).
|
||||||
- See `docs/MONTRE-GADGETBRIDGE.md` for details.
|
- ⚠️ `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
|
## Tests
|
||||||
- `docs/DEVELOPPEMENT.md` – architecture, math, bugs, tests.
|
- Unit: `app/src/test/java/com/hormonetrack/` (pk, data, ui, util, reminder, settings);
|
||||||
- `docs/GUIDE_INSTALLATION.md` – user installation steps.
|
UI: `app/src/androidTest/java/com/hormonetrack/`.
|
||||||
- `scripts/` – release keystore, publish release, seed emulator.
|
- Data-driven regressions load real exports from `local-test-data/` (gitignored) and SKIP when
|
||||||
- Check `opencode.json` for any defined tasks (use `opencode` skill if needed).
|
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
|
## Architecture
|
||||||
1. `./gradlew lint`
|
- Packages in `app/src/main/java/com/hormonetrack/`: `pk/` pure PK engine (no Android deps,
|
||||||
2. `./gradlew testDebugUnitTest`
|
time zones parameterized for deterministic tests), `data/` Room (hand-written migrations
|
||||||
3. `./gradlew connectedDebugAndroidTest`
|
v1→v4, `exportSchema=false`), `reminder/` (exact alarms, notification actions, boot),
|
||||||
4. `./gradlew assembleRelease`
|
`settings/` (DataStore), `ui/` (Compose; `screens/settings/` = cards).
|
||||||
5. Tag and publish release.
|
- 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).
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user