AGENTS.md — Modern-Apps
Monorepo: ~100 Gradle modules + Rust workspace. Do scoped work only.
1. Scope first (law)
- Each module has its own
AGENTS.md(e.g.notes/AGENTS.md,games/voxels/AGENTS.md,library/ui/AGENTS.md) — auto-loaded on read. Read it instead of listing the dir. - State
Scope: <dir/> + <shared>before any scan. Stay inside those prefixes. - Expand only with one-line justification. Never root-recurse.
- Don't read
CONTRIBUTING.mdwhole (26KB). Pull a section only on demand. - Prefer 1 targeted read over 10 searches.
- Keep
AGENTS.mdcurrent (mandatory). If your change adds, removes, renames, or alters anything a module'sAGENTS.mddocuments — entry files, key files, architecture/data-flow, features, gotchas, verification commands, module purpose — update that module'sAGENTS.md(and this root file, when the change is repo-wide: conventions, shared-module ownership, app index) in the same change. Facts that stopped being true (removed deps, renamed files, dead behavior) must be corrected or deleted, not left standing. A change that makes anAGENTS.mdclaim false is incomplete. Conversely, don't churnAGENTS.mdprose for changes it doesn't document. AGENTS.mddescribes the current state only. No history: no changelogs, "previously/formerly/used to" narratives, migration stories, commit references, or dated change notes. Write present-tense descriptions of how the module works now; when you touch anAGENTS.md, strip historical content you find (keep any present-tense lesson, drop its narrative).
How to pick scope
| Task | Scope |
|---|---|
| UI bug in one app | that app + library/ui |
| DB / Room | that app + library/room |
| Network / TLS / certs | that app + library/network |
| Icons, scaffold, theme, messenger | that app + library/ui |
| Cross-app share / assistant tool | both apps + library (DTO in library.intents.<app>) |
| New app module | settings.gradle.kts + build-logic/ + reference app (backup/, else notes/) |
| Store listing / screenshots | that app + metadata_data/ |
| Rust / JNI / native | that app's src/main/rust/ + root Cargo.toml |
| Build convention change | build-logic/ only |
| Lint rule change | lint-rules/ only |
| Games hub achievement | game + sdk/games |
Shared modules (only pull when row above says so)
| Module | Path | What it owns |
|---|---|---|
| base | library/ | nav keys, AssistantIntent, IPC DTOs (library.intents.<app>), RoomRepository base |
| ui | library/ui/ | Icons.kt + generated wrappers from library/ui/icons.tsv (ONLY Icon()/painterResource() allowed there and in the generated source), AppScaffold family, DynamicTheme, messenger/AppMessages, motion helpers |
| network | library/network/ | NetworkClient, pinned CAs in assets/ca/, TrustBundle (FIRST_PARTY/STANDARD/EXTENDED/SYSTEM/ESIM), OfflineAware banner |
| room | library/room/ | Room 3 + SQLCipher (implementRoom(libs)) |
| map / ml / ocr | library/map/, library/ml/, library/ocr/ | vector maps (INTERNET itself) / inference / OCR |
| image/media | library/image/, library/media/ | image loading (offline-local; network apps opt into HTTP via Builder.remote() with a NetworkClient fetch fn) / AV playback |
| e2ee-p2p | library/e2ee-p2p/ | E2EE, p2p, Hkdf |
| widgets/work | library/widgets/, library/work/ | Glance widgets / WorkManager |
| biometric/ink | library/biometric/, library/ink/ | biometric / stylus ink |
| downloadservice | library/downloadservice/ | foreground downloads (INTERNET itself) |
| format | library/format/ | relative-age bucketing + "<amount>m ago" wording (opt-in; calendar dates stay in library/ui DateString) |
| locationprovider | library/locationprovider/ | location abstraction |
| aosp-stubs | library/aosp-stubs/ | compile-only hidden-API stubs |
| sdk:games/cast/openassistant | sdk/games/, sdk/cast/, sdk/openassistant/ | achievements / casting / assistant tools |
| build-logic | build-logic/ | common-conventions-app, common-conventions-library, launcherIcon, rustNativeLib |
| lint-rules | lint-rules/ | ToastUsage + DirectComposeAnimation + FileLength + DirectAndroidLog + DialogAsRoute + RouteScreenshotCoverage + FixtureDeterminism + NoDeadClick (fatal) + others |
Apps (Gradle key → dir)
Reference: backup/ satisfies every rule; notes/ second + intents/ demo. camera + games/voxels hand-commit screenshots. Full canonical index (Gradle key → dir + group + notes): .llms/repo-map.md. clock, notes, calendar, launcher, todo, maps, camera, findfamily, contacts, appstore, weather, communicate, music, email and securemail are single merged APKs for phone and watch (watch experience inside the phone app's module; the remaining *-wear modules are separate companion APKs with the phone app's applicationId/signing). appstore→appstore/ astronomy→astronomy/ auto→auto/,auto/protocol/ backup→backup/ calculator→calculator/ calendar→calendar/ camera→camera/ cast→cast/,cast/protocol/,cast/tv/ clock→clock/ code→code/ communicate→communicate/ contacts→contacts/ education→education/ email→email/ emergency→emergency/ euicc→euicc/ everysync→everysync/ files→files/ findfamily→findfamily/ findfamily-ios→apple/FindFamily/ (SwiftPM/xtool, not Gradle) flashcards→flashcards/ fooddelivery→fooddelivery/ health→health/ keyboard→keyboard/ launcher→launcher/ logviewer→logviewer/ maps→maps/ measure→measure/ music→music/ networklocation→networklocation/ news→news/ notes→notes/ office→office/ openassistant→openassistant/ passwords→passwords/ pdf→pdf/ photos→photos/ parentalcontrols→parentalcontrols/ screentime→screentime/ setupwizard→setupwizard/ share→share/ speech→speech/ taxi→taxi/ things→things/ todo→todo/ translate→translate/ travel→travel/ tuner→tuner/ updater→updater/ vpn→vpn/ weather→weather/ watch→watch/,watch-wear/ web→web/ youpipe→youpipe/,youpipe/extractor/ games-hub→games/hub/ games-kart→games/kart/ games-arrows→games/arrows/ games-chess→games/chess/ games-logicgate→games/logicgate/ games-minesweeper→games/minesweeper/ games-nonogram→games/nonogram/ games-pipes→games/pipes/ games-solitaire→games/solitaire/ games-sudoku→games/sudoku/ games-unblockjam→games/unblockjam/ games-voxels→games/voxels/ games-wordmaker→games/wordmaker/ Slash == colon for Gradle (games/voxels == games:voxels).
Never scan
target/, scripts/, build/, .gradle/, .kotlin/, */build/, */schemas/ (single file ok), metadata_data/photos/, third_party/, firmware/, *.onnx, *.log, personal/.
Backend server (outside this repo)
The backend (relay server for findfamily/everysync/office/voxels) lives outside this repo:
- Server checkout:
../location_share_server(sibling of this repo root). On this dev machine:C:\Users\Vayun\Documents\code\location_share_server. - Live server SSH:
ssh [email protected] - Server env template:
../location_share_server/.env.example(copy to../location_share_server/.env, never commit secrets). - The server's canonical API host is
api.maproj.org(same Cloudflare FIRST_PARTY pins). Legacyfindfamily.cc/api.findfamily.ccstill serve every API path identically so older app versions keep working. - Cloudflare R2: see
../location_share_server/src/handlers/os_admin.rsforR2::from_env(); required varsR2_ACCESS_KEY_ID,R2_SECRET_ACCESS_KEY, plusR2_ENDPOINTorR2_ACCOUNT_ID.
2. Conventions (check every time)
Toastbanned (fatal lint). UserememberMessenger().show()in composable,AppMessages.show()elsewhere.- Never
Icon()/painterResource()/androidx.compose.material.icons.*in app. Icons are generated fromlibrary/ui/icons.tsvbyGenerateIconsTask(build-logic) at build time: add an icon = one manifest line + rebuild; never hand-edit the generated file. A wrapper not in the manifest does not exist, so a missing icon is a compile error. - Never raw
Scaffold. UseAppScaffoldfamily. Refresh/loading indication goes through the scaffold's pull-to-refresh box (isRefreshing/onRefresh/refreshEnabledonAppScaffoldfamily; TV:TvAppFrame.isRefreshing/TvLoadingtop indicator), never a standaloneLoadingState/LoadingIndicator/CircularProgressIndicator/ContainedLoadingIndicatoror hand-rolled pull-to-refresh in app UI (fatalScaffoldLoadinglint). Truly local progress is a non-icon affordance (disabled state, progress text); real determinate progress is aLinearProgressIndicator(progress=...)bar. Exception marker only for library-internal helpers and genuinely non-screen contexts. Never rawandroidx.compose.animationat call site — uselibrary.uihelpers. NeverimePadding()/navigationBarsPadding()/systemBarsPadding()inlibrary.ui. - Screen-level search goes through the scaffold's
searchparameter (search = ScaffoldSearch(query, onQueryChange, placeholder)onAppScaffold/DetailScaffold/DetailLazyColumn/LazyListScaffold; the field renders AS the top app bar in its title slot, title replaced, above the refresh box), never a standaloneCommonSearchBar/SearchBar/SearchBarInputFieldor search-identifiedTextField/OutlinedTextFieldin app UI (fatalScaffoldSearchlint). TheAppScaffold(topBar=...)overload,SetupScaffold, andTabbedPagerScaffold(pages own their scaffolds) have no search slot by design; TV uses its own text field. Dialog/sheet/drawer-local filters and expandable overlay search with no scaffold host use the exception marker only. - Search hints say "Search" unless they convey valuable info such as the active search engine in web.
- Room 3 only. Literal
androidx.room.flagged even in comments. NeverbuildDatabase()at call site — subclasslibrary.room.RoomRepository. - Network only via
library.network.NetworkClient+TrustBundlenarrowest (FIRST_PARTY/STANDARD/EXTENDED/SYSTEM/ESIM). - Package roots closed set:
ui data domain platform network intents service provider widget notifications sync telephony. Noutil/. One public@Composableper file, named as file.domain/pure (no Android/Compose). - Package grammar is normative in
docs/package-structure.md: package segments name responsibilities/features, never generic buckets (util,common,helper,manager,api,viewmodel, …) or UI toolkits. Widget code is flat inwidget/— neverwidgets/,widget/glance/,glance/, or anywidget.<child>/. - Every app with networking has exactly one public
network.Networkingentry point. It ownsNetworkClient, the narrowestTrustBundle, URLs, endpoint paths, auth headers, retries, and status mapping. No package outsidenetwork/(andlibrary.network) may construct raw API requests. - Every native library has exactly one guarded wrapper in
platform/named<Feature>Native; it is the onlySystem.loadLibrarycaller for that library and exposes availability instead of letting initialization fail. JNI-frozen FQNs are the only package exceptions and must carry the verbatim JNI marker. - Every app has exactly one preferences owner in
data/named<App>Prefs; only it opens the app’s DataStore/SharedPreferences, and it recovers from corruption with documented defaults. Persisted/external decoding goes through non-throwing helpers indata/ordomain/; Room converters never throw. - Every exported entry point has one validated contract in
intents/; entry points consume validated values only. Regexes must be Android-ICU-valid (escape literal braces outside quantifiers/character classes). Widgets render from one immutable snapshot and use fallbacks for missing keys/items. One widget, one file: every file inwidget/declares aMaWidgetsubclass at top level together with its receiver; no helper-only files inwidget/(helpers nest inside the widget; non-Glance app helpers belong to their own root). - Escape hatches verbatim:
// PACKAGE STRUCTURE EXCEPTION (JNI),// RAW SCAFFOLD EXCEPTION: <reason>,// TOAST EXCEPTION: <reason>,// RAW ANIMATION EXCEPTION: <reason>,// SCAFFOLD LOADING EXCEPTION: <reason>,// SCAFFOLD SEARCH EXCEPTION: <reason>,// DIALOG LOCAL EXCEPTION: <reason>,// FIXTURE RELATIVE-TIME EXCEPTION: <reason>,// DEAD CLICK EXCEPTION: <reason>. - Test/screenshot fixtures are deterministic (fatal
FixtureDeterminismlint): noClock.System.now()/LocalDate.now()/LocalDateTime.now()/Instant.now()/System.currentTimeMillis()or unseededRandom()/UUID.randomUUID()insrc/test/src/screenshotTest— use named fixed constants or a seededRandom(seed); deadline-polling/elapsed/freshness-assert idioms in unit tests are not fixtures. Code that must seed relative to the SUT's real clock uses// FIXTURE RELATIVE-TIME EXCEPTION: <reason>. - No dead clicks (fatal
NoDeadClicklint): a Button/IconButton/FAB/MenuItem/ListItem-clickable insrc/mainwith an empty/comment-onlyonClickand noenabled = falseis an error — wire it, disable it honestly, or demote it to a non-button container. Display-only label chips are excluded by widget type; drag-handle grips use// DEAD CLICK EXCEPTION: <reason>. - detekt rules live in
detekt.yml(ui/domain/odf/service scoping rationale inline). Fix code, not config, to green a module.
3. Verify (slice touched, never whole repo)
./gradlew :<module>:compileDevKotlin
./gradlew :<module>:lint
./gradlew :<module>:checkMetadataGradle defaults to a small daemon heap (-Xmx8g) with wide task parallelism (org.gradle.workers.max=128 in gradle.properties; ./install all escalates the heap, not the worker count). New build logic must be configuration-cache compatible. New/changed UI previews: ./gradlew :<module>:metadata. Rust builds use the fast cargo profile for dev tasks and the release profile for release/ambiguous tasks, overridable with -Pmodernapps.rustProfile=release|fast. Variants: apps and libraries both define only dev and release build types (the AGP debug type's variants are disabled in both convention plugins; neither dev variant is debuggable, and both initialise from release). App dev consumes library dev by exact build-type match — the matchingFallbacks lists in the conventions exist only for external AARs, which ship just debug/release. Library unit tests run as :module:testDevUnitTest (testBuildType = "dev" in both conventions), so one library variant serves assembleDev and tests.
4. Tools — use these, not raw gradle/adb
Work in repo dir. Experiments/logs go in analysis/ (gitignored).
./install — build + session-install (handles .idsig/fs-verity + versionCodeOverride automatically; skips apps whose built APK is byte-identical to the installed one, INSTALL_SKIP_UNCHANGED=0 disables):
./install <device> <module> [...] # release by default; device (8|9|--device=watch) is required
./install [dev|release] <device> <module> [...]
./install voxels # shorthand → games:voxels; dooraccess → personal:dooraccess
./install dev games/voxels # slash == colon
./install 9 contacts calendar # multi-module, one gradlew invocation
./install 9 maps # device required: 8 = Pixel 8, 9 = Pixel 9, --device=watch = Pixel Watch
./install 9 all / ./install release 9 all # full repo (auto big-heap); release all caps R8 workers
./install --dry-run 9 contactsRules: release default (dev is almost never the right install), dev only when asked, debug blocked. Never uninstall / clear data (emulator-only exception, never touch physical device). Never give placeholder commands — output copy-pasteable.
./dhu — Desktop Head Unit loopback for auto/ (Pixel 8 default):
./dhu # adb forward tcp:5277 + live logcat → analysis/dhu-<ts>.log + DHU window
./dhu -NoLog # DHU only
./dhu -DeviceId <serial> # non-default device./search — scoped string search (bash only, rg when present, grep fallback). Pattern + optional -m (module) / -p (root package) filters, composable:
./search DB_NAME -m notes -p data # both: data/ package of notes/ only
./search RoomRepository -m notes # module only
./search TrustBundle -m web -p network # module + package combined
./search "foo" -m voxels # shorthand → games:voxels; slash == colon; -m all = everything
./search "bar" -m notes --files-only --max 20Never grep repo-wide when a filter will do. Always excluded: target/ build/ .gradle/ .kotlin/ .git/ .llms/ analysis/ *.log *.onnx metadata_data/photos/.
./check — static verification without building: :<module>:detekt (rules in detekt.yml) + :<module>:lint + :<module>:ktlintCheck + cargo check/clippy/fmt/doc --locked for Rust modules (workspace members via -p, standalone crates in-dir; cargo fmt --check is blocking — drift fails the script) + structure ratchets (tools/structure_check.py, manifests in docs/structure/ — Wear protocol-pair drift, generated-source guard, exception-marker inventory, line-count ratchet against line-budget.json; runs on every invocation):
./check <module> [...] # e.g. ./check notes backup; ./check voxels
./check all # every app + library module (pure-JVM modules excluded)
./check structure # only the structure ratchetsFindings fail the task. Only notes/, backup/, library/ui/, games/voxels/ are detekt-clean today; other modules carry incremental backlog — fixing a module means ./check <module> goes green, not config relaxation.
./format — auto-formatting (same module notation as ./check):
./format <module> [...] # ktlintFormat + cargo fmt (writes changes)
./format --check <module> # ktlintCheck + cargo fmt --check only
./format all # every app + library moduleFormatting (current state): Kotlin uses ktlint's standard rule set via the org.jlleitschuh.gradle.ktlint Gradle plugin (version pinned in gradle/libs.versions.toml; engine 1.5.0), applied by common-conventions-app/common-conventions-library so every app/library module has ktlintFormat/ktlintCheck. Style is the root .editorconfig (indent 4, max line 120, LF, final newline), which ktlint reads natively. Generated sources and *.kts build scripts are excluded (scope is src/**). ./check enforces formatting per module (:ktlintCheck beside detekt/lint; cargo fmt --check blocking for Rust — style in the root rustfmt.toml, maxwidth 100; the rustfmt component is required: rustup component add rustfmt). ./check all and ./format all additionally run the workspace-wide cargo fmt --all, covering workspace crates with no Gradle module (scripts/, `thirdparty/, library/tilecodec, library/jni-http, library/vision, communicate-dev/src/main/rust-mls), and check/format any standalone crate that is not a workspace member in its own dir. Rule exceptions: no ktlint rule is disabled. The one configured knob is ktlintfunctionnamingignorewhenannotatedwith = Composable in .editorconfig — composables are PascalCase by repo convention (one public @Composable per file, named as the file), so the rule must not demand camelCase for them. Roll out module by module: ./format <module> plus manual fixes for non-autocorrectable findings, then ./check <module>` green.
On-device file map (per-module AGENTS.md carries concrete names)
- Room (
RoomRepository,DB_NAMEindata/):/data/data/<pkg>/databases/<DB_NAME>(+-wal/-shmsidecars). SQLCipher-encrypted.getDatabasePath/deleteDatabase/LEGACY_*names are the same dir. - DataStore:
preferencesDataStore(name=X)→/data/data/<pkg>/files/datastore/X.preferences_pb; sharedDataStoreUtils→/data/data/<pkg>/files/datastore_default.preferences_pb. - Downloads (
InitialDownloadChecker/InitialModelDownloadChecker, file lists inplatform/ordata/): eachfileName→/storage/emulated/0/Android/data/<pkg>/files/<fileName>(+.partwhile downloading). - Assets (
src/main/assets/): APK-bundled, read viaAssetManager— no on-device path. Library assets (e.g.library/networkCAs) ship inside each dependent APK. - Library modules have no
applicationId: paths resolve under the hosting app's<pkg>.
5. Git / safety
- Other agents share the tree. Prohibited except reading state:
stash/revert/reset/checkout . /cleanetc. Onlyadd+commitallowed, and only paths you changed — checkgit statusfirst, neveradd -A/., never stage without committing instantly. - Commit message: line 1 is ≤80 chars, always in the format
appname: short description (#iss). Then a blank line and a full body: what changed and why, the context (bug/symptom, root cause, constraints, alternatives rejected), notable implementation details, user-visible effect, and how it was verified. Write in plain prose/bullets, wrapped at ~72 chars. The body feeds AI-written release notes, so make it complete; never stop at one line. - LF only; never commit line-ending churn.
FAIL_ON_PROJECT_REPOS— never add repos in modules. ReadSUPPLY_CHAIN_RISKS.mdbefore new third-party dep. - Lint gate (mandatory). No change merges into the local main branch without its modules' lint checks green: the agent verifies
./gradlew :<module>:lint :<module>:lintVitalRelease(plus unit tests) in its worktree before committing, and the parent re-runs release lint for every module a cherry-picked commit touches before merging. The.githooks/pre-commithook (enable once per clone withgit config core.hooksPath .githooks) enforces this at the actual merge point — it runs release lint for every staged module whenever a commit is made on main and rejects the commit on failure;.githooks/pre-pushis only a backstop for pushed ranges. Never bypass with--no-verify; fix the module instead.