# Azure Connection Audit — Full Workspace Report > **Date:** 2026-02-22 > **Scope:** `learning_ai_common_plat`, `learning_voice_ai_agent`, `learning_multimodal_memory_agents`, `learning_ai_clock`, `learning_ai_fastgap` > **Auditor:** Cascade (AI) --- ## Executive Summary | Category | Issues Found | Fixed (session 1) | Fixed (session 2) | Remaining | |----------|-------------|-------------------|-------------------|-----------| | `x-request-id` missing | 12 clients | 2 (MindLyst) | **9** (root cause + feature-flags) | 0 ✅ | | `x-product-id` missing | 6 clients | 0 | **6** (admin + user dashboards + Python) | 0 ✅ | | Cosmos PK mismatch | 1 container | 0 (flagged) | 0 | 1 (needs migration) | | `.env.example` gaps | 4 files | 1 (MindLyst) | **3** (ChronoMind, user-dash, admin-dash) | 0 ✅ | | Hardcoded productId | 2 instances | 0 | **2** (telemetry.ts, platform_client.py) | 0 ✅ | | Python client gaps | 1 file | 0 | **1** (headers + config) | 0 ✅ | --- ## 1. `x-request-id` Header — Root Cause ### Finding **`@bytelyst/api-client` does NOT auto-inject `x-request-id`.** The `createApiClient()` factory in `packages/api-client/src/client.ts` only sets `Content-Type`, auth token (via `getToken`), and caller-supplied `defaultHeaders`. No `x-request-id` is generated. This means **every consumer** that relies on `@bytelyst/api-client` without explicitly adding the header is missing request tracing. ### Root Cause Fix Add `x-request-id: crypto.randomUUID()` to `buildHeaders()` in `packages/api-client/src/client.ts`. This single change propagates to all consumers automatically. ### Affected Clients (missing `x-request-id`) | Repo | File | Client Pattern | |------|------|---------------| | `common_plat` | `dashboards/admin-web/src/lib/billing-client.ts` | `createApiClient` — no `x-request-id` | | `common_plat` | `dashboards/admin-web/src/lib/growth-client.ts` | `createApiClient` — no `x-request-id` | | `common_plat` | `dashboards/admin-web/src/lib/platform-client.ts` | `createApiClient` — no `x-request-id` | | `common_plat` | `dashboards/tracker-web/src/lib/tracker-client.ts` | `createApiClient` — no `x-request-id` | | `common_plat` | `packages/extraction/src/client.ts` | `createApiClient` — no `x-request-id` | | `voice_ai_agent` | `user-dashboard-web/src/lib/billing-client.ts` | `createApiClient` — no `x-request-id` | | `voice_ai_agent` | `user-dashboard-web/src/lib/growth-client.ts` | `createApiClient` — no `x-request-id` | | `voice_ai_agent` | `user-dashboard-web/src/lib/platform-client.ts` | `createApiClient` — no `x-request-id` | | `voice_ai_agent` | `user-dashboard-web/src/lib/feature-flags.ts` | Custom `fetch` — no `x-request-id` | | `voice_ai_agent` | `backend/src/clients/platform_client.py` | `httpx` — no `x-request-id` | ### Already Fixed (previous session) | Repo | File | Status | |------|------|--------| | `multimodal_memory` | `web/src/lib/billing-client.ts` | ✅ Added via `defaultHeaders` | | `multimodal_memory` | `web/src/lib/feature-flags.ts` | ✅ Added manually | ### Already Correct | Repo | File | Status | |------|------|--------| | `ai_fastgap` (NomGap) | `src/api/client.ts` | ✅ Custom client with `crypto.randomUUID()` | | `ai_clock` (ChronoMind) | `web/src/lib/platform-sync.ts` | ✅ Custom client with `crypto.randomUUID()` | | `voice_ai_agent` | `backend/src/main.py` | ✅ Middleware propagates/generates | | `voice_ai_agent` | `backend/src/clients/extraction_client.py` | ✅ Passes `request_id` param | --- ## 2. `x-product-id` Header Gaps ### Clients Missing `x-product-id` | Repo | File | Impact | |------|------|--------| | `common_plat` | `admin-web/src/lib/billing-client.ts` | Server can't filter by product | | `common_plat` | `admin-web/src/lib/growth-client.ts` | Server can't filter by product | | `voice_ai_agent` | `user-dashboard-web/src/lib/billing-client.ts` | Server can't filter by product | | `voice_ai_agent` | `user-dashboard-web/src/lib/growth-client.ts` | Server can't filter by product | | `voice_ai_agent` | `user-dashboard-web/src/lib/platform-client.ts` | Passes in body, not header | | `voice_ai_agent` | `backend/src/clients/platform_client.py` | Passes in body/params, not header | ### Already Correct | Repo | File | |------|------| | `ai_fastgap` (NomGap) | `src/api/client.ts` — `x-product-id: API_CONFIG.productId` | | `ai_clock` (ChronoMind) | `web/src/lib/platform-sync.ts` — `x-product-id` header | | `multimodal_memory` (MindLyst) | `web/src/lib/billing-client.ts` — via `defaultHeaders` | | `multimodal_memory` (MindLyst) | `web/src/lib/feature-flags.ts` — explicit header | | `common_plat` | `tracker-web/src/lib/tracker-client.ts` — from `localStorage` | --- ## 3. Cosmos DB Partition Key Mismatch ### `referrals` Container — 3-way Mismatch | Location | Partition Key | |----------|--------------| | `platform-service/src/lib/cosmos-init.ts` | `/id` | | MindLyst `web/src/lib/cosmos.ts` | `/userId` | | Admin dashboard `admin-web/src/lib/cosmos.ts` | `/referrerId` | | User dashboard `user-dashboard-web/src/lib/cosmos.ts` | `/referrerId` | **Status:** Flagged in previous session. Cannot be fixed without data migration. Comment added to `cosmos-init.ts`. **Risk:** Cross-partition queries will silently succeed but may return incomplete results or fail on point reads if the wrong partition key is specified. --- ## 4. Missing Environment Variables in `.env.example` Files ### ChronoMind `web/.env.example` Currently only has: ``` NEXT_PUBLIC_PLATFORM_SERVICE_URL=http://localhost:4003/api ``` **Missing:** - `NEXT_PUBLIC_PRODUCT_ID=chronomind` — used implicitly by `platform-sync.ts` (hardcoded there, but should be env-driven for consistency) ### LysnrAI `user-dashboard-web/.env.example` **Missing:** - `NEXT_PUBLIC_PRODUCT_ID=lysnrai` — referenced by `feature-flags.ts` line 10 - `NEXT_PUBLIC_PLATFORM_SERVICE_URL=http://localhost:4003` — referenced by `feature-flags.ts` line 11 Has `PLATFORM_SERVICE_URL` (server-side) but not the `NEXT_PUBLIC_` variant (client-side). ### LysnrAI root `.env.example` **Missing:** - `NEXT_PUBLIC_PRODUCT_ID` — not needed at root level (desktop app), so this is informational only. ### Admin dashboard `.env.example` **Missing:** - `AZURE_KEYVAULT_URL` — referenced by `instrumentation.ts` but not in `.env.example` --- ## 5. Hardcoded `productId` Values | Repo | File | Line | Value | Should Use | |------|------|------|-------|-----------| | `multimodal_memory` | `web/src/lib/telemetry.ts` | 19 | `productId: 'mindlyst'` | `process.env.NEXT_PUBLIC_PRODUCT_ID` | | `voice_ai_agent` | `backend/src/clients/platform_client.py` | 86, 101 | `product_id: str = "lysnrai"` | `settings.PRODUCT_ID` or config | --- ## 6. Python Backend Client Gaps (`platform_client.py`) The `PlatformClient` class in `backend/src/clients/platform_client.py` has several issues: 1. **No `x-request-id` header** on any request 2. **No `x-product-id` header** on any request 3. **Creates new `httpx.AsyncClient` per request** — no connection pooling 4. **Hardcoded `product_id="lysnrai"` defaults** — should use config --- ## 7. Previously Fixed (Session 1) | Fix | Repo | File | |-----|------|------| | Added `x-request-id` to billing client | `multimodal_memory` | `web/src/lib/billing-client.ts` | | Added `x-request-id` to feature flags | `multimodal_memory` | `web/src/lib/feature-flags.ts` | | Added 13 MindLyst containers to cosmos-init | `common_plat` | `services/platform-service/src/lib/cosmos-init.ts` | | Added Blob Storage creds to Python config | `voice_ai_agent` | `backend/src/config.py` | | Added missing env vars to MindLyst | `multimodal_memory` | `web/.env.example` | --- ## 8. Recommended Fix Order 1. **P0 — Root cause:** Add `x-request-id` auto-generation to `@bytelyst/api-client` `buildHeaders()` → fixes 9 TS clients at once 2. **P0 — LysnrAI feature-flags:** Add `x-request-id` to the custom `fetch` call in `user-dashboard-web/src/lib/feature-flags.ts` 3. **P1 — Python backend:** Add `x-request-id` and `x-product-id` headers to `platform_client.py` 4. **P1 — Env vars:** Add missing `NEXT_PUBLIC_*` vars to ChronoMind, LysnrAI user-dashboard, admin-dashboard `.env.example` files 5. **P2 — `x-product-id`:** Add to admin/user dashboard clients via `defaultHeaders` in `createApiClient` config 6. **P2 — Hardcoded productId:** Replace in `telemetry.ts` and `platform_client.py` 7. **P3 — Referrals PK mismatch:** Requires data migration strategy (separate task)