Skip to content

Commit 6f2108f

Browse files
committed
Add server-backed Local DB adapter path without browser DB access - PR_26158_025-local-db-server-adapter
1 parent 52c3644 commit 6f2108f

9 files changed

Lines changed: 255 additions & 155 deletions

File tree

admin/db-viewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function loadLocalDbViewer() {
3535
return;
3636
}
3737
if (!localModeSelected()) {
38-
showGatewayStatus("Local Mem DB is available only in Local Mem mode until Local DB adapter is configured.");
38+
showGatewayStatus("Local Mem DB Viewer is available only in Local Mem mode.");
3939
return;
4040
}
4141
const module = await import("../src/engine/api/mock-db-viewer-ui.js");
Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
1-
# PR_26158_024 Browser Mock Remaining Audit
1+
# PR_26158_025 Browser Mock Remaining Audit
22

33
## Scope
44

5-
Focused audit for browser-visible files and adjacent server/API cleanup touched in PR_26158_024:
5+
Focused audit for the Local DB server adapter step:
66

7-
- `admin/db-viewer.html`
87
- `admin/db-viewer.js`
9-
- `src/engine/api/mock-db-api-client.js`
10-
- `src/engine/api/mock-db-viewer-ui.js`
118
- `src/dev-runtime/server/mock-api-router.mjs`
129
- `src/dev-runtime/persistence/mock-db-store.js`
13-
- `tests/playwright/tools/AdminDbViewer.spec.mjs`
1410
- `tests/playwright/tools/LoginSessionMode.spec.mjs`
1511

1612
## Static Import Boundary
1713

1814
| Check | Status | Evidence |
1915
| --- | --- | --- |
20-
| Browser files import `src/dev-runtime` directly. | PASS | `rg -n '^import .*src/dev-runtime|import\\(.*src/dev-runtime' assets admin toolbox src -g '*.js' -g '!src/dev-runtime/**' ...` returned no matches. |
21-
| Browser files import static `toolRegistry.js` directly. | PASS | `rg -n '^import .*toolRegistry\\.js|import\\(.*toolRegistry\\.js' ...` returned no matches. |
22-
| Browser files import mock repositories directly. | PASS | Refined `rg` excluding repository implementation files returned no matches. |
16+
| Browser files import `src/dev-runtime` directly. | PASS | `rg -n 'src/dev-runtime' admin assets toolbox src -g '*.js' -g '*.mjs' -g '!src/dev-runtime/**' -g '!**/*-mock-repository.js' -g '!toolbox/colors/palette-workspace-repository.js' ...` returned no matches. |
17+
| Browser files import mock repositories directly. | PASS | `rg -n 'mock-.*repository' ...` excluding repository implementation files returned no matches. |
18+
| Browser files import static `toolRegistry.js` directly. | PASS | `rg -n 'import .*toolRegistry\\.js|from .*toolRegistry\\.js|import\\(.*toolRegistry\\.js' ...` returned no matches. |
2319

24-
## Local Mode Cleanup
20+
## Local DB Boundary
2521

2622
| Check | Status | Evidence |
2723
| --- | --- | --- |
28-
| Local login shows only Local Mem and Local DB. | PASS | Login Playwright lane asserts exact labels. |
29-
| DEV/UAT/Prod are not local login buttons. | PASS | Login Playwright lane asserts no DEV, UAT, or Prod buttons. |
30-
| Server rejects legacy `modeId: "local"`. | PASS | API contract probe returned 500 with `Unknown local login environment: local`. |
31-
| Local DB does not fall back to Local Mem. | PASS | API contract probe verified Local DB snapshot fails with `Local DB adapter not configured`. |
32-
| DB Viewer user-facing wording says Local Mem DB. | PASS | Admin DB Viewer Playwright asserts Local Mem DB headings, status text, clear/seed controls, and dialogs. |
24+
| Browser flow remains Browser -> API client -> server API -> data source. | PASS | Local DB implementation lives in `src/dev-runtime/server/mock-api-router.mjs`; login and DB Viewer continue to use `/api/session/*` and `/api/mock-db/*`. |
25+
| Browser code does not import Local DB implementation modules. | PASS | No browser import-boundary matches were found. |
26+
| Local Mem behavior remains available. | PASS | LoginSessionMode and AdminDbViewer Playwright lanes passed against Local Mem. |
27+
| Local DB is configured behind the existing server API boundary. | PASS | API contract probe selected `local-db`, resolved users/roles, read snapshots, and verified persisted clear across server restart. |
28+
| Local DB failure is visible and actionable. | PASS | API contract probe with `GAMEFOUNDRY_LOCAL_DB_DISABLE=1` returned a 500 diagnostic naming `Local DB adapter not configured` and the disabled storage cause. |
29+
| UAT/Prod are not local login choices. | PASS | LoginSessionMode Playwright and API contract probe assert only Local Mem and Local DB selector modes. |
3330

3431
## Remaining Internal Matches
3532

3633
- `toolbox/*/*-mock-repository.js` and `toolbox/colors/palette-workspace-repository.js` remain server/data-source implementation modules, not active browser entry imports.
3734
- `/api/mock-db/*` route names and `mock-db-*` module filenames remain stable internal API contracts.
38-
- Internal exception text `Invalid mock DB audit user key` remains in non-user-facing audit validation.

docs_build/dev/reports/coverage_changed_js_guardrail.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,20 @@ Source: Playwright/Chromium built-in V8 coverage from the active Playwright run.
88
Changed runtime JS files considered:
99
(0%) src/dev-runtime/persistence/mock-db-store.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
1010
(0%) src/dev-runtime/server/mock-api-router.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
11-
(0%) src/engine/api/session-api-client.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
1211
(0%) src/shared/toolbox/assetUsageIntegration.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
1312
(0%) src/shared/toolbox/platformShell.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
1413
(0%) src/shared/toolbox/projectSystem.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
1514
(0%) src/shared/toolbox/toolHostManifest.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
1615
(0%) src/shared/toolbox/toolLaunchSSoTData.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
17-
(0%) toolbox/assets/assets-api-client.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
18-
(0%) toolbox/assets/assets-mock-repository.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
19-
(0%) toolbox/colors/palette-api-client.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
20-
(0%) toolbox/colors/palette-workspace-repository.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
21-
(0%) toolbox/game-configuration/game-configuration-api-client.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
22-
(0%) toolbox/game-design/game-design-api-client.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
23-
(0%) toolbox/project-journey/project-journey-mock-repository.js - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
2416
(56%) src/engine/api/server-api-client.js - executed lines 154/154; executed functions 10/18
2517
(60%) src/engine/api/mock-db-api-client.js - executed lines 19/19; executed functions 3/5
26-
(74%) toolbox/tools-page-accordions.js - executed lines 774/774; executed functions 53/72
2718
(86%) src/engine/api/mock-db-viewer-ui.js - executed lines 478/478; executed functions 78/91
28-
(89%) toolbox/tool-registry-api-client.js - executed lines 148/148; executed functions 24/27
29-
(97%) toolbox/project-journey/project-journey.js - executed lines 1003/1003; executed functions 104/107
30-
(100%) toolbox/project-journey/project-journey-api-client.js - executed lines 12/12; executed functions 2/2
31-
(100%) toolbox/project-workspace/project-workspace-api-client.js - executed lines 12/12; executed functions 2/2
3219

3320
Guardrail warnings:
3421
(0%) src/dev-runtime/persistence/mock-db-store.js - WARNING: changed runtime JS file missing from coverage; advisory only
3522
(0%) src/dev-runtime/server/mock-api-router.mjs - WARNING: changed runtime JS file missing from coverage; advisory only
36-
(0%) src/engine/api/session-api-client.js - WARNING: changed runtime JS file missing from coverage; advisory only
3723
(0%) src/shared/toolbox/assetUsageIntegration.js - WARNING: changed runtime JS file missing from coverage; advisory only
3824
(0%) src/shared/toolbox/platformShell.js - WARNING: changed runtime JS file missing from coverage; advisory only
3925
(0%) src/shared/toolbox/projectSystem.js - WARNING: changed runtime JS file missing from coverage; advisory only
4026
(0%) src/shared/toolbox/toolHostManifest.js - WARNING: changed runtime JS file missing from coverage; advisory only
4127
(0%) src/shared/toolbox/toolLaunchSSoTData.js - WARNING: changed runtime JS file missing from coverage; advisory only
42-
(0%) toolbox/assets/assets-api-client.js - WARNING: changed runtime JS file missing from coverage; advisory only
43-
(0%) toolbox/assets/assets-mock-repository.js - WARNING: changed runtime JS file missing from coverage; advisory only
44-
(0%) toolbox/colors/palette-api-client.js - WARNING: changed runtime JS file missing from coverage; advisory only
45-
(0%) toolbox/colors/palette-workspace-repository.js - WARNING: changed runtime JS file missing from coverage; advisory only
46-
(0%) toolbox/game-configuration/game-configuration-api-client.js - WARNING: changed runtime JS file missing from coverage; advisory only
47-
(0%) toolbox/game-design/game-design-api-client.js - WARNING: changed runtime JS file missing from coverage; advisory only
48-
(0%) toolbox/project-journey/project-journey-mock-repository.js - WARNING: changed runtime JS file missing from coverage; advisory only
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# PR_26158_025 Local DB Server Adapter Report
2+
3+
## Executive Summary
4+
5+
Implemented the next smallest Local DB server adapter step behind the existing server API boundary. Local Mem remains unchanged, Local DB now uses a server-side JSON-backed `LocalDbAdapter`, and browser code continues to interact through the existing API routes.
6+
7+
## Requirement Checklist
8+
9+
| Requirement | Status | Evidence |
10+
| --- | --- | --- |
11+
| Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` first. | PASS | Instructions were read before implementation. |
12+
| Implement/configure Local DB behind existing server API boundary. | PASS | `src/dev-runtime/server/mock-api-router.mjs` adds `LocalDbAdapter`, dynamic local DB storage path resolution, read/write state, and adapter persistence. |
13+
| Keep Browser -> API client -> server API -> Local DB data source. | PASS | Browser-facing behavior still uses `/api/session/*`, `/api/mock-db/*`, and server API routes; static import audit found no browser direct Local DB imports. |
14+
| Do not let browser code import dev-runtime, DB repositories, or DB implementation modules directly. | PASS | Static import boundary checks returned no browser import matches. |
15+
| Preserve Local Mem behavior. | PASS | LoginSessionMode, AdminDbViewer, and ProjectJourneyTool Playwright lanes passed with existing Local Mem flows. |
16+
| Local DB fails visibly with actionable diagnostics when storage cannot initialize. | PASS | API probe with `GAMEFOUNDRY_LOCAL_DB_DISABLE=1` returned `Local DB adapter not configured` plus the disabled storage cause. |
17+
| Do not expose UAT or Prod as local login choices. | PASS | Login UI and API probe assert local login choices are exactly `Local Mem` and `Local DB`. |
18+
| Do not modify `start_of_day` folders. | PASS | No `start_of_day` files changed. |
19+
20+
## Implementation Notes
21+
22+
| Area | Evidence |
23+
| --- | --- |
24+
| Local DB adapter | `src/dev-runtime/server/mock-api-router.mjs` adds `LocalDbAdapter` with JSON read/write storage, `GAMEFOUNDRY_LOCAL_DB_PATH` override, default `tmp/local-db/local-db-state.json`, and disabled-storage diagnostic support. |
25+
| Adapter contract | `src/dev-runtime/server/mock-api-router.mjs` reports Local DB as `configured`; `src/dev-runtime/persistence/mock-db-store.js` marks Local DB as configured, persistent, and users-enabled. |
26+
| State persistence | `LocalDevMockDataSource` now snapshots, applies, and persists state on mode switches, clear/seed/testing-state replacement, and repository method writes. |
27+
| Login validation | `tests/playwright/tools/LoginSessionMode.spec.mjs` verifies Local DB selector users, Admin session resolution, snapshot access, and isolated Local DB test storage. |
28+
| DB Viewer scope | `admin/db-viewer.js` keeps DB Viewer Local Mem only with a clear Local Mem-only gateway diagnostic. |
29+
30+
## Validation Evidence
31+
32+
| Validation | Result |
33+
| --- | --- |
34+
| Changed-file syntax checks | PASS |
35+
| Local DB/API contract validation | PASS |
36+
| LoginSessionMode Playwright | PASS, 5/5 |
37+
| AdminDbViewer Playwright | PASS, 5/5 |
38+
| ProjectJourneyTool Playwright | PASS, 13/13 |
39+
| Static import boundary audit | PASS |
40+
| `git diff --check` | PASS, Git line-ending warnings only |
41+
42+
## Remaining Migration Notes
43+
44+
- Local DB is a server-side local JSON adapter for this PR slice, not a physical SQL/SQLite implementation.
45+
- DB Viewer remains Local Mem only until a later PR explicitly enables Local DB viewer behavior.
46+
- Playwright V8 coverage remains advisory for server-side modules that Chromium cannot collect directly.

0 commit comments

Comments
 (0)