Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / library / network / AGENTS.md

AGENTS.md3.0 KiBRenderedCodeRaw
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<!-- last-reviewed: 2026-10-16 -->
6- Gradle: :library:network / dir: library/network/
7- Package roots present: network (+ `util` for the connectivity monitor/banner)
8- Entry files: NetworkClient.kt + TrustBundle.kt (no MainActivity/Route — library)
9- Deps: (none — no project dependencies by design, #884)
10- Remote images: network apps build their own `Fetcher` from `NetworkClient`
11 and hand it to `ImageLoader.Builder.remote()` in `:library:image`; the HTTP
12 transport lives in the app, never in a library-to-library edge
13- Metadata: metadata_data/library-network.md (absent — libraries have none by design)
14- Rust: no / screenshotTest: no
15
16### Relay server (backend, outside this repo)
17Relay 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)".
18
19## Overview
20**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).
21**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`).
22**Entry points:** `NetworkClient.kt` → `TrustBundle.kt` → `HttpUrlEngine.kt` → `Urls.kt`.
23**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.
24
25## Key files
26- com/vayunmathur/library/network/NetworkClient.kt — init + narrowest-bundle rule
27- com/vayunmathur/library/network/TrustBundle.kt
28- com/vayunmathur/library/network/BundledTrust.kt
29- com/vayunmathur/library/network/HttpUrlEngine.kt
30- com/vayunmathur/library/network/PooledHttpEngine.kt
31- com/vayunmathur/library/network/NativeHttpBridge.kt — Rust bridge
32- com/vayunmathur/library/network/Urls.kt
33- com/vayunmathur/library/network/WebSocketClient.kt
34- com/vayunmathur/library/util/ConnectivityMonitor.kt
35- com/vayunmathur/library/util/ConnectivityCompose.kt — `OfflineAware` banner (#884)
36
37## Verify (this module only)
38```
39./gradlew :library:network:compileDevKotlin
40./gradlew :library:network:lint
41```