|
| 1 | +# PR_26171_GAMMA_021-sqlite-active-runtime-removal-plan |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +This report creates a focused removal plan for active SQLite references found on fresh `main` after PR #36 merged. |
| 6 | + |
| 7 | +Fresh-main baseline: |
| 8 | +- Branch: `team/GAMMA/admin` |
| 9 | +- Fresh main commit used for inventory: `1b27b0a9a3d67821fa586e34d5331567ec6f49b7` |
| 10 | +- Inventory command: `rg -i "sqlite|better-sqlite|sqlite3|\\.sqlite|sql\\.js"` |
| 11 | +- Raw inventory excluding generated diff noise: 130 files, 358 matching lines |
| 12 | + |
| 13 | +This PR does not remove code, change runtime behavior, touch archive reports, run Playwright, or run samples. |
| 14 | + |
| 15 | +## Active Classification |
| 16 | + |
| 17 | +### Active Runtime |
| 18 | + |
| 19 | +- `src/dev-runtime/messages/messages-sqlite-service.mjs` |
| 20 | + - Classification: active runtime |
| 21 | + - Current state: uses `node:sqlite`, `DatabaseSync`, `GAMEFOUNDRY_MESSAGES_SQLITE_PATH`, and `tmp/messages/messages.sqlite`. |
| 22 | + - Replacement path: replace with a Postgres-backed Messages database service using `GAMEFOUNDRY_DATABASE_URL` and the existing Local API message contracts. Prefer a vendor-neutral active service name such as `messages-database-service.mjs`; if a compatibility wrapper is needed, keep it temporary and log the deprecated name. |
| 23 | + |
| 24 | +- `src/dev-runtime/persistence/game-journey-completion-metrics-store.mjs` |
| 25 | + - Classification: active runtime |
| 26 | + - Current state: uses `node:sqlite`, `DatabaseSync`, `GAMEFOUNDRY_GAME_JOURNEY_METRICS_DB_PATH`, and `tmp/local-api/game-journey-completion-metrics.sqlite`. |
| 27 | + - Replacement path: move completion metrics reads/writes to the authoritative Postgres connection path using `GAMEFOUNDRY_DATABASE_URL`. Keep the current Local API response shape stable while replacing the storage implementation. |
| 28 | + |
| 29 | +- `src/dev-runtime/persistence/mock-db-store.js` |
| 30 | + - Classification: active runtime / allowed technical debt |
| 31 | + - Current state: shared dev-runtime schema and seed metadata; it does not import `node:sqlite`, but its active session adapter metadata still says `LocalDbAdapter backed by server SQLite storage`. |
| 32 | + - Replacement path: split shared schema/seed constants from persistence-provider labeling, then replace Local DB/SQLite-facing adapter copy with a Postgres-backed or neutral dev database adapter description. Preserve existing `MOCK_DB_KEYS` consumers until owner-assigned follow-up PRs migrate each tool surface. |
| 33 | + |
| 34 | +### Local API |
| 35 | + |
| 36 | +- `src/dev-runtime/server/local-api-router.mjs` |
| 37 | + - Classification: local API |
| 38 | + - Current state: imports `createMessagesSqliteService`, constructs the Messages SQLite service, and returns SQLite database engine metadata for remaining local routes. |
| 39 | + - Replacement path: inject the Postgres-backed Messages service and Game Journey metrics service through existing safe Local API contracts. Remove SQLite engine metadata only after the replacement services are available and targeted tests prove the same API response shapes. |
| 40 | + |
| 41 | +### Tests |
| 42 | + |
| 43 | +Direct SQLite tests: |
| 44 | +- `tests/playwright/tools/MessagesTool.spec.mjs` |
| 45 | +- `tests/playwright/tools/GameJourneyTool.spec.mjs` |
| 46 | +- `tests/dev-runtime/DbSeedIntegrity.test.mjs` |
| 47 | +- `tests/playwright/tools/LoginSessionMode.spec.mjs` |
| 48 | +- `tests/playwright/tools/BrowserApiUrlConfig.spec.mjs` |
| 49 | +- `tests/playwright/tools/AdminDbViewer.spec.mjs` |
| 50 | +- `tests/playwright/tools/AdminHealthOperationsPage.spec.mjs` |
| 51 | + |
| 52 | +Shared `mock-db-store.js` dependency tests that may need updates when the adapter label or constants split changes: |
| 53 | +- `tests/dev-runtime/AiCreditFoundation.test.mjs` |
| 54 | +- `tests/dev-runtime/LegalFoundation.test.mjs` |
| 55 | +- `tests/dev-runtime/MarketplaceCategories.test.mjs` |
| 56 | +- `tests/dev-runtime/MembershipDataModel.test.mjs` |
| 57 | +- `tests/dev-runtime/SupabaseDevAuthTestUserCleanup.test.mjs` |
| 58 | +- `tests/dev-runtime/TeamsFoundation.test.mjs` |
| 59 | +- `tests/playwright/account/AchievementsPage.spec.mjs` |
| 60 | +- `tests/playwright/tools/AdminNotesLocalViewer.spec.mjs` |
| 61 | +- `tests/playwright/tools/AdminPlatformToolsWireframes.spec.mjs` |
| 62 | +- `tests/playwright/tools/AssetToolMockRepository.spec.mjs` |
| 63 | +- `tests/playwright/tools/BuildPathProgressSimplification.spec.mjs` |
| 64 | +- `tests/playwright/tools/GameHubMockRepository.spec.mjs` |
| 65 | +- `tests/playwright/tools/IdeaBoardTableNotes.spec.mjs` |
| 66 | +- `tests/playwright/tools/InputMappingV2Tool.spec.mjs` |
| 67 | +- `tests/playwright/tools/PaletteToolMockRepository.spec.mjs` |
| 68 | +- `tests/playwright/tools/RootToolsFutureState.spec.mjs` |
| 69 | +- `tests/playwright/tools/TagsTool.spec.mjs` |
| 70 | +- `tests/playwright/tools/ToolboxAdminMetadataSsot.spec.mjs` |
| 71 | +- `tests/playwright/tools/ToolboxRoutePages.spec.mjs` |
| 72 | + |
| 73 | +### Docs |
| 74 | + |
| 75 | +- `docs_build/dev/PROJECT_INSTRUCTIONS.md` |
| 76 | + - Keep as authoritative deprecation governance. |
| 77 | +- `docs_build/database/dml/DML_INDEX.md` |
| 78 | +- `docs_build/database/dml/messages.sql` |
| 79 | +- `docs_build/database/seed/messages.json` |
| 80 | + - Update in the Messages Postgres cutover PR so seed/setup wording no longer references the server-side Messages SQLite service. |
| 81 | + |
| 82 | +### Archive/Reference |
| 83 | + |
| 84 | +Historical report and PR history under these paths is explicitly excluded from removal: |
| 85 | +- `docs_build/dev/reports/**` |
| 86 | +- `docs_build/pr/**` |
| 87 | + |
| 88 | +Archive/reference history may continue to mention SQLite for traceability. Do not rewrite old reports unless a future governance PR explicitly scopes archival cleanup. |
| 89 | + |
| 90 | +## Required Follow-Up PR Sequence |
| 91 | + |
| 92 | +1. Messages database cutover |
| 93 | + - Owner: Team Beta |
| 94 | + - Scope: replace `messages-sqlite-service.mjs` with a Postgres-backed Messages service, keep current Local API endpoints stable, migrate message seed/setup docs, and update `MessagesTool.spec.mjs`. |
| 95 | + - Validation: targeted Messages Local API and Messages Playwright coverage; no samples unless the changed API contract affects samples. |
| 96 | + |
| 97 | +2. Game Journey completion metrics database cutover |
| 98 | + - Owner: Team Alpha |
| 99 | + - Scope: replace `game-journey-completion-metrics-store.mjs` with a Postgres-backed metrics store and update Game Journey completion tests. |
| 100 | + - Validation: targeted Game Journey Local API and Game Journey Playwright coverage; no full suite unless shared runtime behavior expands. |
| 101 | + |
| 102 | +3. Shared dev database adapter label and schema split |
| 103 | + - Owner: Master Control assignment required because `mock-db-store.js` is shared across Alpha/Beta/Gamma surfaces. |
| 104 | + - Scope: split schema/key constants from persistence adapter labeling, remove Local DB/SQLite wording from active adapter metadata, and update affected tests by ownership lane. |
| 105 | + - Validation: targeted dev-runtime schema tests plus only the tool Playwright lanes whose fixtures import the changed contract. |
| 106 | + |
| 107 | +4. Local API SQLite metadata removal |
| 108 | + - Owner: Team Gamma for diagnostics/governance coordination, with Alpha/Beta implementation owners for affected routes. |
| 109 | + - Scope: remove SQLite imports, constructor wiring, and database engine metadata from `local-api-router.mjs` after replacement services have landed. |
| 110 | + - Validation: targeted Local API startup, Admin System Health diagnostics, Messages, and Game Journey lanes. |
| 111 | + |
| 112 | +5. Guard cleanup and final inventory |
| 113 | + - Owner: Team Gamma |
| 114 | + - Scope: update `scripts/validate-browser-env-agnostic.mjs` technical-debt notes, rerun the active SQLite inventory, and confirm only governance docs and archive/reference reports remain. |
| 115 | + - Validation: `git diff --check`, targeted script/static validation, final inventory report. |
| 116 | + |
| 117 | +## Manual Validation Notes |
| 118 | + |
| 119 | +- Confirmed the plan targets only active runtime, Local API, test, and active docs/data references. |
| 120 | +- Confirmed archive/reference report history is excluded. |
| 121 | +- Confirmed no code was removed. |
| 122 | +- Confirmed no runtime behavior was changed. |
| 123 | +- Confirmed Postgres remains the replacement direction. |
| 124 | + |
| 125 | +## Skipped Validation |
| 126 | + |
| 127 | +- Playwright skipped: docs/report-only planning PR. |
| 128 | +- Samples skipped: no sample files or sample runtime behavior changed. |
0 commit comments