Compare commits
No commits in common. "main" and "v1.14.3" have entirely different histories.
123
AGENTS.md
123
AGENTS.md
@ -1,91 +1,52 @@
|
||||
# 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` — 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+.
|
||||
- `./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
|
||||
|
||||
## 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).
|
||||
## 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+).
|
||||
|
||||
## 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).
|
||||
## 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).
|
||||
|
||||
## 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`.
|
||||
## 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.
|
||||
|
||||
## 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.
|
||||
## 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.
|
||||
|
||||
## Emulator recipe (docs/DEVELOPPEMENT.md §16.ter)
|
||||
- `scripts/seed-emulator.py <db> <backup.json>` 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).
|
||||
## 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.
|
||||
|
||||
## 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).
|
||||
## 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).
|
||||
|
||||
## 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).
|
||||
## Critical Command Order
|
||||
1. `./gradlew lint`
|
||||
2. `./gradlew testDebugUnitTest`
|
||||
3. `./gradlew connectedDebugAndroidTest`
|
||||
4. `./gradlew assembleRelease`
|
||||
5. Tag and publish release.
|
||||
@ -2446,14 +2446,6 @@ de signature est requise — elle est désormais câblée :
|
||||
8. **Smoke-test R8 sur téléphone** (le release APK n'est pas vérifiable en
|
||||
tests JVM) : installation par-dessus l'existant, graphiques, export ET
|
||||
import d'un backup JSON, rappel. Le debug APK est le repli (même signature).
|
||||
**v1.14.3 — piège « release invisible » (epoch 0)** : l'instance Gitea
|
||||
dérive `created_at` de la date de l'OBJET TAG (taggerdate) et ignore
|
||||
`created_at` du POST/PATCH API — si la release est créée à une date
|
||||
d'epoch (release triée TOUT EN BAS, invisible) : DELETE release + tag
|
||||
distant, POST sans tag existant (Gitea le crée, date correcte), puis
|
||||
`git push -f origin <tag>` (le tag annoté local resynchronise la date).
|
||||
Vérifier TOUJOURS en fin de publication que la release apparaît en tête
|
||||
de `GET /releases?limit=2`.
|
||||
9. **Mettre à jour §2/§8/§19/§21 si besoin** puis pusher la doc.
|
||||
|
||||
Notes :
|
||||
|
||||
@ -26,27 +26,6 @@ import sys
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
def git_tag_timestamp(tag: str) -> int:
|
||||
"""Timestamp UNIX de la création du tag annoté [tag] (référence de
|
||||
created_at pour la release Gitea — cf leçon epoch 0, v1.14.3)."""
|
||||
out = subprocess.run(
|
||||
["git", "for-each-ref", f"refs/tags/{tag}", "--format=%(taggerdate:unix)"],
|
||||
capture_output=True, text=True, check=True
|
||||
).stdout.strip()
|
||||
# Tag léger (non annoté) → committerdate de secours
|
||||
if not out or out == "0":
|
||||
out = subprocess.run(
|
||||
["git", "rev-list", "-n", "1", tag],
|
||||
capture_output=True, text=True, check=True
|
||||
).stdout.strip()
|
||||
out = subprocess.run(
|
||||
["git", "show", "-s", "--format=%ct", out],
|
||||
capture_output=True, text=True, check=True
|
||||
).stdout.strip()
|
||||
return int(out)
|
||||
|
||||
# Instances connues : clé = nom court
|
||||
INSTANCES = {
|
||||
@ -197,20 +176,7 @@ def main():
|
||||
if e.code != 404:
|
||||
raise
|
||||
release = request(f"{base}/releases", "POST", token=token, data={
|
||||
"tag_name": tag, "name": tag, "body": body, "draft": False, "prerelease": False,
|
||||
# ⚠️ LEÇON v1.14.3 (epoch 0) : cette instance dérive created_at de
|
||||
# la date de l'OBJET TAG (taggerdate — vérifié : v1.14.2/1.14.1
|
||||
# collent exactement) et IGNORAIT created_at du POST/PATCH à cette
|
||||
# occasion → release créée à epoch 0 (1970), triée TOUT EN BAS de
|
||||
# la liste, invisible côté UI. FIX IN SITU : supprimer release +
|
||||
# tag distant, recréer la release SANS tag existant (Gitea crée le
|
||||
# tag, date correcte), puis re-forcer le tag ANNOTÉ local
|
||||
# (`git push -f origin <tag>` — Gitea resynchronise alors la date
|
||||
# de la release avec le tag objet). Ce champ created_at reste
|
||||
# ici à titre documentaire : les instances à jour l'honorent.
|
||||
"created_at": datetime.fromtimestamp(
|
||||
git_tag_timestamp(tag), tz=timezone.utc
|
||||
).isoformat().replace("+00:00", "Z")})
|
||||
"tag_name": tag, "name": tag, "body": body, "draft": False, "prerelease": False})
|
||||
release_id = release["id"]
|
||||
print(f"[{instance}] release {tag} créée (id {release_id})")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user