|
| 1 | +# PR_26158_037 DB Seed Integrity Report |
| 2 | + |
| 3 | +## Executive Summary |
| 4 | + |
| 5 | +Local DB and Local Mem seed creation now use runtime-generated timestamps for createdAt and updatedAt instead of hardcoded 2026 seed anchors. |
| 6 | + |
| 7 | +The server seed snapshot now includes a standalone `tool_state_samples` table. Guest rows are generated from the active toolbox registry so every available tool has a loadable starter toolState/sample row. User rows provide unique user-owned project/toolState seed records for User 1, User 2, User 3, and Admin without storing Guest as a DB user. |
| 8 | + |
| 9 | +## Implementation |
| 10 | + |
| 11 | +| Area | Change | Evidence | |
| 12 | +| --- | --- | --- | |
| 13 | +| Shared mock DB schema | Added `tool_state_samples` schema and standalone ownership. | `src/dev-runtime/persistence/mock-db-store.js` | |
| 14 | +| Runtime timestamps | Replaced fixed 2026 seed timestamp helpers with runtime timestamp generation in shared DB, Palette, Asset, and Project Journey seed helpers. | `src/dev-runtime/persistence/mock-db-store.js`; `toolbox/colors/palette-workspace-repository.js`; `toolbox/assets/assets-mock-repository.js`; `toolbox/project-journey/project-journey-mock-repository.js` | |
| 15 | +| Server seed table | Added server-side `tool_state_samples` rows for guest active-tool starters and unique human-user seed rows. | `src/dev-runtime/server/mock-api-router.mjs` | |
| 16 | +| DB Viewer visibility | Added a standalone `Tool State Samples` filter label and userKey relationship diagnostics. | `src/engine/api/mock-db-viewer-ui.js` | |
| 17 | +| Validation | Added targeted Node seed integrity test and extended Admin DB Viewer Playwright. | `tests/dev-runtime/DbSeedIntegrity.test.mjs`; `tests/playwright/tools/AdminDbViewer.spec.mjs` | |
| 18 | + |
| 19 | +## Requirement Checklist |
| 20 | + |
| 21 | +| Requirement | Evidence | Status | |
| 22 | +| --- | --- | --- | |
| 23 | +| Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` first. | Read before implementation and validation. | PASS | |
| 24 | +| When creating/initializing the Local DB, use real runtime timestamps for `createdAt` and `updatedAt`. | Shared DB, server seed, Palette, Asset, and Project Journey seed helpers use `Date.now()` / `new Date()` runtime timestamps. Node and Playwright validate runtime parseable timestamps. | PASS | |
| 25 | +| Remove hardcoded seed timestamps from DB creation paths. | Targeted `rg` search found no active hardcoded `Date.UTC(2026)`, fixed `const now = "2026..."`, or old hardcoded seed timestamp in touched seed paths. | PASS | |
| 26 | +| Verify guest seed data includes at least one loadable sample/toolState for every available tool. | `tool_state_samples` guest rows are built from `getActiveToolRegistry()` and validated against `/api/toolbox/registry/snapshot`. | PASS | |
| 27 | +| Verify each seeded user has unique projects, tool states, manifests, or sample data where user-owned data exists. | User 1, User 2, User 3, and Admin have unique `projectKey`, `toolStateKey`, `manifestPath`, and `sampleLabel` rows. | PASS | |
| 28 | +| Do not share mutable seeded records across users. | Validation verifies separate user-owned seed rows with unique project/toolState keys. | PASS | |
| 29 | +| Preserve audit fields: `key`, `createdAt`, `updatedAt`, `createdBy`, `updatedBy`. | Table schemas include audit fields; AdminDbViewer audit diagnostics and Node test validate fields and user references. | PASS | |
| 30 | +| Preserve SQLite-backed Local DB behind API boundary. | Local DB mode is selected through `/api/session/mode`; AdminDbViewer reads through `/api/mock-db/snapshot`; no browser DB imports were added. | PASS | |
| 31 | +| Do not add UAT/Prod behavior. | No UAT/Prod adapter or login behavior changed. | PASS | |
| 32 | +| Run changed-file syntax checks. | All changed JS/MJS/spec files passed `node --check`. | PASS | |
| 33 | +| Run targeted DB seed integrity validation. | `node --test tests/dev-runtime/DbSeedIntegrity.test.mjs` passed 1/1. | PASS | |
| 34 | +| Run AdminDbViewer Playwright to verify timestamps, guest samples, and user-unique records are visible. | `npx playwright test tests/playwright/tools/AdminDbViewer.spec.mjs` passed 7/7 with new visible `tool_state_samples` checks. | PASS | |
| 35 | +| Run LoginSessionMode Playwright if login/session seed behavior is touched. | `npx playwright test tests/playwright/tools/LoginSessionMode.spec.mjs` passed 5/5. | PASS | |
| 36 | +| Do not run full samples smoke unless directly impacted. | Full samples smoke skipped because sample runtime/loader files were not changed. | PASS | |
| 37 | +| Required reports and review artifacts generated. | This report, `testing_lane_execution_report.md`, V8 coverage, review diff, changed files, and ZIP artifact generated. | PASS | |
| 38 | + |
| 39 | +## Validation Commands |
| 40 | + |
| 41 | +| Command | Result | |
| 42 | +| --- | --- | |
| 43 | +| `node --check src/dev-runtime/persistence/mock-db-store.js` | PASS | |
| 44 | +| `node --check src/dev-runtime/server/mock-api-router.mjs` | PASS | |
| 45 | +| `node --check src/engine/api/mock-db-viewer-ui.js` | PASS | |
| 46 | +| `node --check toolbox/colors/palette-workspace-repository.js` | PASS | |
| 47 | +| `node --check toolbox/assets/assets-mock-repository.js` | PASS | |
| 48 | +| `node --check toolbox/project-journey/project-journey-mock-repository.js` | PASS | |
| 49 | +| `node --check tests/playwright/tools/AdminDbViewer.spec.mjs` | PASS | |
| 50 | +| `node --check tests/dev-runtime/DbSeedIntegrity.test.mjs` | PASS | |
| 51 | +| `rg -n 'Date\.UTC\(2026\|const now = "2026\|2026-06-06T09:00:00\.000Z' src/dev-runtime toolbox tests/dev-runtime tests/playwright/tools/AdminDbViewer.spec.mjs` | PASS, no matches | |
| 52 | +| `node --test tests/dev-runtime/DbSeedIntegrity.test.mjs` | PASS, 1/1 | |
| 53 | +| `npx playwright test tests/playwright/tools/AdminDbViewer.spec.mjs` | PASS, 7/7 | |
| 54 | +| `npx playwright test tests/playwright/tools/LoginSessionMode.spec.mjs` | PASS, 5/5 | |
| 55 | +| `git diff --check` | PASS, with Git line-ending warnings only | |
| 56 | + |
| 57 | +## Skipped Lanes |
| 58 | + |
| 59 | +| Lane | Decision | Reason | |
| 60 | +| --- | --- | --- | |
| 61 | +| Full samples smoke | SKIP | No sample loader/framework or sample runtime files changed. | |
| 62 | +| Full Playwright suite | SKIP | Targeted AdminDbViewer, LoginSessionMode, and Node seed integrity validations cover the changed DB seed paths. | |
| 63 | +| ToolboxRoutePages Playwright | SKIP | Tool page routing was not changed. | |
| 64 | +| ProjectJourneyTool Playwright | SKIP | Project Journey UI behavior was not changed; seed timestamp behavior is validated through DB seed/API and Admin DB Viewer. | |
| 65 | + |
| 66 | +## Notes |
| 67 | + |
| 68 | +- No CSS was added. |
| 69 | +- Guest remains unauthenticated and is not stored in the `users` table. |
| 70 | +- Existing SQLite experimental warnings and seed-only audit fallback diagnostics appeared during validation; they are existing runtime diagnostics and did not affect the PR requirement results. |
| 71 | +- V8 coverage warnings for dev-runtime/server and repository files are advisory only; the affected server seed behavior is covered by Node and API-backed Playwright validation. |
0 commit comments