# Shared client policy across web and mobile

Error translation, mutation toasts, query retries, user-agent parsing and platform-admin role checks now live once in client-safe leaf modules, and a test prevents new platform duplicates.

- **Typed error translation without casts.** `translateError(t)` in `@fofo/errors` binds any typed i18next `t` covering `ErrorMessageKey | AuthErrorMessageKey` into `(error: unknown) => string`. Fourteen inline `(key, params) => t(key as never, params ?? {})` adapters across web and mobile are replaced.
- **One retry policy; mobile stops retrying 4xx.** `retryQuery` moved to the leaf `@fofo/errors/query-retry` and is used by both apps. Mobile stops retrying 4xx responses and keeps its single retry for 5xx and network failures (`maxRetries: 1`; web retries twice). A Better Auth client error with a 4xx status counts as a 4xx on both, so web no longer retries it. Web passes `{ isServer: typeof document === "undefined" }` so SSR never blocks on backoff.
- **One mutation-toast rule, user-agent parser and admin role check.** `shouldToastMutationError` lives in `@fofo/errors/mutation-toast`, `parseUserAgent` in `@fofo/auth/user-agent` (bringing native iOS/Android and iPadOS desktop-mode recognition to web session and activity views as well), and `sessionHasAdminRole` in `@fofo/api/admin/roles` using the stricter `ADMIN_ROLES` fail-closed check on both server and client.
- **A test prevents future drift.** `scripts/duplicate-platform-exports.test.mjs` fails when the same exported function name exists in both `apps/web/src/platform` and `apps/mobile/src/platform`, with a hook allowlist that fails when stale. See [Conventions](/docs/development/conventions#shared-client-policy-lives-in-a-leaf) and [Enforcement](/docs/development/enforcement).
