RFC-009: Fetch boundary in Atlas UI
Problem
Section titled “Problem”Ad-hoc fetch scattered across views makes auth scope, telemetry, and error handling inconsistent.
Policy
Section titled “Policy”- Transport layer —
src/api/http.tsownsrequestJSON,requestZod,AtlasApiError, and the single rawfetchused for JSON Atlas routes. - Domain modules —
src/lib/atlasApi.ts,src/lib/caseApi.ts, andsrc/lib/projectApi.tscallrequestJSONfromhttp.ts(they do not callfetchdirectly). - React callers — use
useScopedQuery,useScopedMutation, orscopedFetchfrom@alexbayerl/djed-query-clientso tenant/workspace/context headers and auth gates stay consistent. - Auth bootstrap —
src/components/AuthProvider.tsxmay usefetchfor/auth/config, BFF session, and logout before scope context exists. - Telemetry —
src/lib/atlasTelemetry.tsmay usefetchwithkeepalivefor fire-and-forgetPOST /api/telemetry.
Enforcement
Section titled “Enforcement”ESLint no-restricted-globals on fetch for all src/**/*.{ts,tsx} except the allowlisted files above.
Non-goals
Section titled “Non-goals”Removing fetch from the transport layer — one central caller is the intended design, not zero fetch in the bundle.