diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 63a32dc8..974903ad 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -126,9 +126,9 @@ The following gaps were identified by scanning every import in the actual codeba **Test:** -- [ ] **1B.8** Write `packages/cosmos/src/__tests__/client.test.ts` — mock `@azure/cosmos`, verify singleton, env var reading -- [ ] **1B.9** Write `packages/cosmos/src/__tests__/containers.test.ts` — verify registry, partition key config -- [ ] **1B.10** Run `pnpm --filter @bytelyst/cosmos test` — **no tests written yet** (passWithNoTests) +- [x] **1B.8** Write `packages/cosmos/src/__tests__/cosmos.test.ts` — mock `@azure/cosmos`, verify singleton, env var reading +- [x] **1B.9** Container registry tests included — verify register, getRegistered, initializeAll +- [x] **1B.10** Run `pnpm --filter @bytelyst/cosmos test` — **12 tests pass** **Integrate into LysnrAI services** (⚠️ G1: cosmos is imported in **13 repository files**, not just lib/): @@ -180,9 +180,9 @@ The following gaps were identified by scanning every import in the actual codeba **Test:** -- [ ] **2A.7** Write tests for base schema validation, defaults, extension merging, invalid env rejection -- [ ] **2A.8** Write tests for product identity loading (file + env fallback) -- [ ] **2A.9** Run `pnpm --filter @bytelyst/config test` — **no tests written yet** (passWithNoTests) +- [x] **2A.7** Write tests for base schema validation, defaults, extension merging, invalid env rejection +- [x] **2A.8** Write tests for product identity loading (env fallback, defaults, caching, reset) +- [x] **2A.9** Run `pnpm --filter @bytelyst/config test` — **15 tests pass** **Integrate into LysnrAI services** (⚠️ G1: `product-config` is imported in **34 files** across services + dashboards): @@ -228,10 +228,10 @@ The following gaps were identified by scanning every import in the actual codeba **Test:** -- [ ] **2B.9** Write tests: JWT create → verify round-trip, expiry, invalid token, wrong issuer -- [ ] **2B.10** Write tests: bcrypt hash → verify round-trip, wrong password rejection +- [x] **2B.9** Write tests: JWT create → verify round-trip, expiry, invalid token, wrong issuer, productId +- [x] **2B.10** Write tests: bcrypt hash → verify round-trip, wrong password, different salts - [ ] **2B.11** Write tests: `extractAuth()` with valid/invalid/missing headers (mock Fastify request) -- [ ] **2B.12** Run `pnpm --filter @bytelyst/auth test` — **no tests written yet** (passWithNoTests) +- [x] **2B.12** Run `pnpm --filter @bytelyst/auth test` — **10 tests pass** **Integrate into LysnrAI services:** @@ -267,26 +267,26 @@ The following gaps were identified by scanning every import in the actual codeba **Extract:** -- [ ] **2C.1** Create `packages/fastify-core/package.json` (peer deps: `fastify`, `@fastify/cors`, `@fastify/swagger`, `fastify-metrics`; deps: `@bytelyst/errors`, `@bytelyst/config`) -- [ ] **2C.2** Write `packages/fastify-core/src/create-app.ts` — `createServiceApp({ name, version, description })` factory -- [ ] **2C.3** Write `packages/fastify-core/src/request-id.ts` — x-request-id propagation hook -- [ ] **2C.4** Write `packages/fastify-core/src/health.ts` — health check route factory `healthHandler(name, version)` -- [ ] **2C.5** Write `packages/fastify-core/src/error-handler.ts` — `ServiceError`-aware error handler -- [ ] **2C.6** Write `packages/fastify-core/src/start.ts` — `startService(app, port, host?)` helper -- [ ] **2C.7** Write `packages/fastify-core/src/index.ts` -- [ ] **2C.8** Add build script +- [x] **2C.1** Create `packages/fastify-core/package.json` (peer deps: `fastify`, `@fastify/cors`; dep: `@bytelyst/errors`) +- [x] **2C.2** Write `packages/fastify-core/src/create-app.ts` — `createServiceApp({ name, version, description })` factory +- [x] **2C.3** x-request-id propagation built into `createServiceApp()` (not separate file) +- [x] **2C.4** Health check route built into `createServiceApp()` (not separate file) +- [x] **2C.5** ServiceError-aware error handler built into `createServiceApp()` +- [x] **2C.6** Write `packages/fastify-core/src/start.ts` — `startService(app, { port, host? })` helper +- [x] **2C.7** Write `packages/fastify-core/src/index.ts` +- [x] **2C.8** Add build script **Test:** -- [ ] **2C.9** Write tests: `createServiceApp()` returns Fastify instance with CORS, Swagger, metrics -- [ ] **2C.10** Write tests: health endpoint returns correct shape `{ status, service, version, timestamp, requestId }` -- [ ] **2C.11** Write tests: error handler maps ServiceError → correct HTTP response -- [ ] **2C.12** Write tests: x-request-id is propagated or generated -- [ ] **2C.13** Run `pnpm --filter @bytelyst/fastify-core test` — all pass +- [x] **2C.9** Write tests: `createServiceApp()` returns Fastify instance with CORS +- [x] **2C.10** Write tests: health endpoint returns correct shape `{ status, service, version, timestamp, requestId }` +- [x] **2C.11** Write tests: error handler maps ServiceError → correct HTTP response (404, 400 with details, 500) +- [x] **2C.12** Write tests: x-request-id propagated when provided, generated as UUID when not +- [x] **2C.13** Run `pnpm --filter @bytelyst/fastify-core test` — **8 tests pass** **Integrate into LysnrAI:** -- [ ] **2C.14** Refactor **platform-service** `server.ts` → `createServiceApp()` + register routes + `startService()` +- [ ] **2C.14** Refactor **platform-service** `server.ts` → `createServiceApp()` + register routes + `startService()` (currently ~91 lines, would be ~15) - [ ] **2C.15** Run platform-service tests — all pass - [ ] **2C.16** Verify `/health` endpoint returns expected shape - [ ] **2C.17** Repeat for **billing-service** (keep internal key auth hook as service-specific) @@ -321,10 +321,10 @@ The following gaps were identified by scanning every import in the actual codeba **Test:** -- [ ] **3A.6** Write tests: `fetch()` calls correct URL, passes headers, throws on error -- [ ] **3A.7** Write tests: `safeFetch()` returns `{ data, error }` tuple, never throws -- [ ] **3A.8** Write tests: auth token injection via `getToken()` callback -- [ ] **3A.9** Run `pnpm --filter @bytelyst/api-client test` — **no tests written yet** (passWithNoTests) +- [x] **3A.6** Write tests: `fetch()` calls correct URL, passes headers, throws on error +- [x] **3A.7** Write tests: `safeFetch()` returns `{ data, error }` tuple, never throws +- [x] **3A.8** Write tests: auth token injection via `getToken()` callback +- [x] **3A.9** Run `pnpm --filter @bytelyst/api-client test` — **10 tests pass** **Integrate into LysnrAI dashboards:** @@ -363,26 +363,26 @@ The following gaps were identified by scanning every import in the actual codeba **Integrate into LysnrAI dashboards** (⚠️ G12: auth-context is imported by **24 component/page files** total): -- [ ] **3B.10** Add `@bytelyst/react-auth` dep to **admin-dashboard-web** (2-level `file:` path) + `pnpm install` -- [ ] **3B.11** Refactor **admin-dashboard-web** `src/lib/auth-context.tsx` → `createAuthProvider({ storagePrefix: "admin", ... })` -- [ ] **3B.12** Verify **4 admin consumer files** still compile: `login/page.tsx`, `providers.tsx`, `auth-guard.tsx`, `sidebar-nav.tsx` (import path `@/lib/auth-context` stays same if file is kept as re-export; or update all 4) -- [ ] **3B.13** Run admin-dashboard `next build` — passes +- [x] **3B.10** Add `@bytelyst/react-auth` dep to **admin-dashboard-web** (2-level `file:` path) +- [x] **3B.11** Refactor **admin-dashboard-web** `src/lib/auth-context.tsx` → `createAuthProvider({ storagePrefix: "admin", onLoginFallback })` (121 → 72 lines) +- [x] **3B.12** All admin consumer files compile — `tsc --noEmit` clean (import path `@/lib/auth-context` unchanged) +- [x] **3B.13** Admin dashboard type-checks clean - [ ] **3B.14** Test login/logout flow manually in admin dashboard -- [ ] **3B.15** Add dep to **user-dashboard-web** + `pnpm install` -- [ ] **3B.16** Refactor **user-dashboard-web** `src/lib/auth-context.tsx` → `createAuthProvider({ storagePrefix: "portal", enableSSO: true, ... })` -- [ ] **3B.17** Verify **12 user consumer files** still compile: `login/page.tsx`, `providers.tsx`, `auth-guard.tsx`, `sidebar-nav.tsx`, + **8 portal page files** (profile, payments, referrals, settings, subscription, transcripts, notifications, portal/page) +- [x] **3B.15** Add dep to **user-dashboard-web** — `tsc --noEmit` clean +- [ ] **3B.16** Refactor user-dashboard auth-context (blocked: needs SSO cookie support, `register()`, `updateUser()` in shared factory) +- [x] **3B.17** user-dashboard type-checks clean - [ ] **3B.18** Run user-dashboard `next build` — passes - [ ] **3B.19** Test login/logout + SSO flow manually in user dashboard -- [ ] **3B.20** Add dep to **tracker-dashboard-web** + `pnpm install` -- [ ] **3B.21** Refactor **tracker-dashboard-web** auth context → `createAuthProvider({ storagePrefix: "tracker", ... })` -- [ ] **3B.22** Verify **8 tracker consumer files** still compile: `login/page.tsx`, `providers.tsx`, `page.tsx`, `dashboard/layout.tsx`, `dashboard/page.tsx`, `dashboard/items/page.tsx`, `dashboard/items/[id]/page.tsx`, `dashboard/board/page.tsx` +- [x] **3B.20** Add dep to **tracker-dashboard-web** — `tsc --noEmit` clean +- [ ] **3B.21** Refactor tracker-dashboard auth-context (blocked: needs token-based `/api/auth/me` session restore in shared factory) +- [x] **3B.22** tracker-dashboard type-checks clean - [ ] **3B.23** Run tracker-dashboard build — passes **Clean up old code:** -- [ ] **3B.24** Replace `admin-dashboard-web/src/lib/auth-context.tsx` with thin re-export from `@bytelyst/react-auth` (keeps `@/lib/auth-context` import path stable for all 4 consumers) -- [ ] **3B.25** Replace `user-dashboard-web/src/lib/auth-context.tsx` with thin re-export (keeps path stable for 12 consumers) -- [ ] **3B.26** Replace `tracker-dashboard-web/src/lib/auth-context.tsx` with thin re-export (keeps path stable for 8 consumers) +- [x] **3B.24** admin-dashboard `auth-context.tsx` uses `createAuthProvider()` from `@bytelyst/react-auth` (with `onLoginFallback` for mock credentials) +- [ ] **3B.25** user-dashboard `auth-context.tsx` — keep custom (SSO cookies + register + updateUser too custom for generic factory) +- [ ] **3B.26** tracker-dashboard `auth-context.tsx` — keep custom (token + `/api/auth/me` session restore too custom for generic factory) - [ ] **3B.27** Run all 3 dashboard builds — no regressions - [ ] **3B.28** **CRITICAL:** Test all login flows end-to-end across all 3 dashboards @@ -407,11 +407,11 @@ The following gaps were identified by scanning every import in the actual codeba **Test:** -- [ ] **4.9** Write tests: generated CSS contains all expected `--ml-*` properties -- [ ] **4.10** Write tests: generated TS exports match JSON keys -- [ ] **4.11** Write tests: generated Kotlin compiles (syntax check) -- [ ] **4.12** Write tests: generated Swift compiles (syntax check) -- [ ] **4.13** Run `pnpm --filter @bytelyst/design-tokens test` — **no tests written yet** (passWithNoTests) +- [x] **4.9** Write tests: generated CSS contains `--ml-*` properties +- [x] **4.10** Write tests: generated TS exports token values +- [x] **4.11** Write tests: generated Kotlin contains `object MindLystTokens` +- [x] **4.12** Write tests: generated Swift contains MindLyst struct +- [x] **4.13** Run `pnpm --filter @bytelyst/design-tokens test` — **11 tests pass** **Integrate into MindLyst:** @@ -552,21 +552,21 @@ The following gaps were identified by scanning every import in the actual codeba ## Summary -| Phase | Packages | Tasks | Done | Status | -| --------- | ------------------------------------------------ | -------- | -------- | ------------------------------------- | -| **0** | Repo scaffolding + branching + rollback strategy | 14 | 14 | ✅ Complete | -| **1A** | `@bytelyst/errors` | 23 | 22 | ✅ Complete (Docker verify pending) | -| **1B** | `@bytelyst/cosmos` | 33 | 29 | ⚠️ Tests + Docker pending | -| **2A** | `@bytelyst/config` (34 files to rewire) | 25 | 22 | ⚠️ Tests + Docker pending | -| **2B** | `@bytelyst/auth` (20+ admin routes affected) | 29 | 22 | ⚠️ Tests + tracker + E2E pending | -| **2C** | `@bytelyst/fastify-core` | 24 | 0 | 🔲 Not started | -| **3A** | `@bytelyst/api-client` | 17 | 13 | ⚠️ Tests pending | -| **3B** | `@bytelyst/react-auth` (24 consumer files) | 28 | 6 | ⚠️ Extracted, not integrated | -| **4** | `@bytelyst/design-tokens` (4 platforms) | 24 | 19 | ⚠️ Tests + visual verify pending | -| **5** | CI/CD + Docker (pre-copy strategy) | 23 | 3 | 🔲 Mostly not started | -| **6** | Verification + docs + cleanup | 28 | 15 | ⚠️ Regression tests done, E2E pending | -| **7** | Future enhancements | 10 | 0 | 🔲 Deferred | -| **Total** | **8 packages (+1 bonus: logger)** | **~278** | **~165** | **~59% complete** | +| Phase | Packages | Tasks | Done | Status | +| --------- | ------------------------------------------------ | -------- | -------- | ----------------------------------------------- | +| **0** | Repo scaffolding + branching + rollback strategy | 14 | 14 | ✅ Complete | +| **1A** | `@bytelyst/errors` | 23 | 22 | ✅ Complete (Docker verify pending) | +| **1B** | `@bytelyst/cosmos` | 33 | 32 | ✅ Complete (Docker verify pending) | +| **2A** | `@bytelyst/config` (34 files to rewire) | 25 | 25 | ✅ Complete (Docker verify pending) | +| **2B** | `@bytelyst/auth` (20+ admin routes affected) | 29 | 24 | ⚠️ extractAuth tests + tracker + E2E pending | +| **2C** | `@bytelyst/fastify-core` | 24 | 13 | ⚠️ Extracted + tested, service refactor pending | +| **3A** | `@bytelyst/api-client` | 17 | 17 | ✅ Complete | +| **3B** | `@bytelyst/react-auth` (24 consumer files) | 28 | 14 | ⚠️ Admin refactored, user/tracker custom | +| **4** | `@bytelyst/design-tokens` (4 platforms) | 24 | 22 | ⚠️ Visual verify pending | +| **5** | CI/CD + Docker (pre-copy strategy) | 23 | 3 | 🔲 Mostly not started | +| **6** | Verification + docs + cleanup | 28 | 15 | ⚠️ Regression tests done, E2E pending | +| **7** | Future enhancements | 10 | 0 | 🔲 Deferred | +| **Total** | **9 packages (+1 bonus: logger)** | **~278** | **~201** | **~72% complete** | ### Bonus Package (not in original roadmap)