Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / library / network / AGENTS.md
| 1 | # AGENTS.md — library/network/ (':library:network') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `library/network/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | - Gradle: :library:network / dir: library/network/ |
| 6 | - Package roots present: network (+ `util` for the connectivity monitor/banner) |
| 7 | - Entry files: NetworkClient.kt + TrustBundle.kt (no MainActivity/Route — library) |
| 8 | - Deps: (none — no project dependencies by design) |
| 9 | - Remote images: network apps build their own `Fetcher` from `NetworkClient` |
| 10 | and hand it to `ImageLoader.Builder.remote()` in `:library:image`; the HTTP |
| 11 | transport lives in the app, never in a library-to-library edge |
| 12 | - Metadata: metadata_data/library-network.md (absent — libraries have none by design) |
| 13 | - Rust: no / screenshotTest: no |
| 14 | |
| 15 | ### Relay server (backend, outside this repo) |
| 16 | Relay host: `api.maproj.org`, covered by the `FIRST_PARTY` bundle pins (Cloudflare). Server checkout: `../location_share_server` (sibling of this repo root, `C:\Users\Vayun\Documents\code\location_share_server`). Live SSH: `ssh [email protected]`. Full details: root `AGENTS.md` → "Backend server (outside this repo)". |
| 17 | |
| 18 | ## Overview |
| 19 | **Purpose:** The ONLY network path in the repo — pinned-TLS HTTP engines + WebSocket + connectivity monitoring. Apps call `NetworkClient.init(context, TrustBundle.*)` first, then go through the engines; never raw OkHttp, never `TrustAll` (that lives in apps' dev-only code, never here). |
| 20 | **How to use:** `NetworkClient.init()` in `MainActivity.onCreateBeforeContent` with the narrowest bundle (`FIRST_PARTY` own relay / `STANDARD` public APIs / `EXTENDED` + `ESIM` special hosts / `SYSTEM` user-entered hosts like web browser). Requests via `HttpUrlEngine`/`PooledHttpEngine` (Rust `NativeHttpBridge`); pins in `BundledTrust` + `assets/ca/`; offline UI via `util/ConnectivityMonitor` (+ `ConnectivityCompose` banner in `:library:ui`). |
| 21 | **Entry points:** `NetworkClient.kt` → `TrustBundle.kt` → `HttpUrlEngine.kt` → `Urls.kt`. |
| 22 | **Gotchas:** `PooledHttpEngine`/`HttpUrlEngine`/`NativeHttpBridge` all exist — check which one your call site already uses before adding a new path. INTERNET permission is declared by consuming apps (or by `library/map`/`downloadservice` themselves), not here. |
| 23 | |
| 24 | ## Key files |
| 25 | - com/vayunmathur/library/network/NetworkClient.kt — init + narrowest-bundle rule |
| 26 | - com/vayunmathur/library/network/TrustBundle.kt |
| 27 | - com/vayunmathur/library/network/BundledTrust.kt |
| 28 | - com/vayunmathur/library/network/HttpUrlEngine.kt |
| 29 | - com/vayunmathur/library/network/PooledHttpEngine.kt |
| 30 | - com/vayunmathur/library/network/NativeHttpBridge.kt — Rust bridge |
| 31 | - com/vayunmathur/library/network/Urls.kt |
| 32 | - com/vayunmathur/library/network/WebSocketClient.kt |
| 33 | - com/vayunmathur/library/util/ConnectivityMonitor.kt |
| 34 | - com/vayunmathur/library/util/ConnectivityCompose.kt — `OfflineAware` banner |
| 35 | |
| 36 | ## Verify (this module only) |
| 37 | ``` |
| 38 | ./gradlew :library:network:compileDevKotlin |
| 39 | ./gradlew :library:network:lint |
| 40 | ``` |