|
| 1 | +# PR_26160_074-palette-db-legacy-table-audit |
| 2 | + |
| 3 | +Generated: 2026-06-09 |
| 4 | + |
| 5 | +## Branch Validation |
| 6 | + |
| 7 | +| Check | Result | Evidence | |
| 8 | +| --- | --- | --- | |
| 9 | +| Current branch | PASS | `git branch --show-current` returned `main`. | |
| 10 | +| Expected branch | PASS | Required branch is `main`. | |
| 11 | +| Local branches found | PASS | `git branch --list` returned `main` only. | |
| 12 | + |
| 13 | +## Requirement Checklist |
| 14 | + |
| 15 | +| Requirement | Status | Evidence | |
| 16 | +| --- | --- | --- | |
| 17 | +| Audit `palette_source_swatches` reads | PASS | Reads are concentrated in `src/dev-runtime/persistence/tool-repositories/palette-workspace-repository.js`, `toolbox/colors/colors.js`, `toolbox/colors/palette-api-client.js`, `src/dev-runtime/server/mock-api-router.mjs`, `src/dev-runtime/persistence/mock-db-store.js`, and DB Viewer rendering through `src/engine/api/mock-db-viewer-ui.js`. | |
| 18 | +| Audit `palette_source_swatches` writes | PASS | Seed/write paths are `src/dev-runtime/guest-seeds/palette-source-mock-db.js`, `createPaletteToolMockDbTables()`, repository `getTables()`, and mock DB persistence/schema ownership in `src/dev-runtime/persistence/mock-db-store.js`. | |
| 19 | +| Determine Colors runtime effect | PASS | The table still affects source palette options, source swatch listing, source pin/unpin, harmony matching against current/all source swatches, table counts, diagnostics, and DB Viewer table visibility. | |
| 20 | +| Determine whether 838 records are legacy seed data | PASS | Probe confirmed `createPaletteSourceMockDbRows()` returns 838 rows and a fresh palette repository exposes 838 `palette_source_swatches` rows. They are seed-backed curated source rows, but not orphaned/unused legacy data. | |
| 21 | +| Decide remove/rename/archive/migrate | PASS | Do not remove or rename in this PR. Safe future migration would require first replacing source browser/harmony/source-row repository behavior with a new curated source catalog/service. | |
| 22 | +| Audit `palette_colors` | PASS | Active DB-owned Project Swatches table. Read/write via palette repository and visible in DB Viewer. | |
| 23 | +| Audit `palette_source_swatches` | PASS | Active DB-owned curated source/reference swatch table. Seeded by dev runtime and used by palette source/harmony paths. | |
| 24 | +| Audit `palette_swatch_usages` | PASS | Active DB-owned usage/dependency table. Used for swatch usage rows and DB Viewer relationship diagnostics to project swatches/assets. | |
| 25 | +| Audit `project_workspace_palette_globals` | PASS | Active DB-owned per-project palette settings/global table. Used for workspace palette records and palette table relationship diagnostics. | |
| 26 | +| Keep Colors grid behavior unchanged | PASS | Grid behavior was preserved. A narrow metadata repair in `toolbox/colors/colors.js` prevents generated swatches from storing the internal preview-layout sentinel `default` as user-facing sort metadata; the grid layout/order remains unchanged. | |
| 27 | +| Do not migrate unrelated Toolbox/Admin data | PASS | No Toolbox/Admin metadata migration was performed. | |
| 28 | +| No inline script/style/event handlers | PASS | No HTML/CSS changes were made. | |
| 29 | + |
| 30 | +## `palette_source_swatches` Usage Audit |
| 31 | + |
| 32 | +### Reads |
| 33 | + |
| 34 | +| File | Read behavior | |
| 35 | +| --- | --- | |
| 36 | +| `src/dev-runtime/persistence/tool-repositories/palette-workspace-repository.js` | Loads `loadedMockDbTables.palette_source_swatches`, normalizes rows with `normalizeSourcePaletteRows()`, exposes `sourcePaletteOptions()`, `listSourceSwatches()`, source counts, source row tables, and source-backed harmony matching. | |
| 37 | +| `toolbox/colors/palette-api-client.js` | Uses palette API repository constants/contracts that surface the palette repository snapshot and tables to the browser tool. | |
| 38 | +| `toolbox/colors/colors.js` | Reads `snapshot.sourcePaletteOptions`, `snapshot.sourcePaletteRecordCount`, `repository.listSourceSwatches()`, source diagnostics, and palette table counts. Source controls are currently hidden from the active UI, but the runtime code path remains present. | |
| 39 | +| `src/dev-runtime/server/mock-api-router.mjs` | Provides API-backed palette repository/test modes, including empty/invalid source table setup for palette route behavior. | |
| 40 | +| `src/dev-runtime/persistence/mock-db-store.js` | Declares `palette_source_swatches` schema and the Palette DB Viewer group. | |
| 41 | +| `src/engine/api/mock-db-viewer-ui.js` | Renders current adapter tables from the API snapshot; Palette filter shows `palette_source_swatches` with schema/records. | |
| 42 | +| `tests/playwright/tools/PaletteToolMockRepository.spec.mjs` | Asserts repository table ownership, source options, source swatch pin/unpin, hidden source controls in current UI, and symbol-free palette validation. | |
| 43 | +| `tests/playwright/tools/AdminDbViewer.spec.mjs` | Asserts Palette DB Viewer grouping includes `palette_source_swatches` and that raw Palette tables are DB-shaped. | |
| 44 | + |
| 45 | +### Writes / Ownership |
| 46 | + |
| 47 | +| File | Write/ownership behavior | |
| 48 | +| --- | --- | |
| 49 | +| `src/dev-runtime/guest-seeds/palette-source-mock-db.js` | `createPaletteSourceMockDbRows()` creates the curated source seed rows. | |
| 50 | +| `src/dev-runtime/persistence/tool-repositories/palette-workspace-repository.js` | `createPaletteToolMockDbTables()` seeds/clones source rows; `getTables()` returns normalized `palette_source_swatches` rows for persistence/snapshot output. | |
| 51 | +| `src/dev-runtime/persistence/mock-db-store.js` | Owns schema/table grouping and audit field normalization expectations for `palette_source_swatches`. | |
| 52 | + |
| 53 | +### Runtime Impact |
| 54 | + |
| 55 | +`palette_source_swatches` still affects active service behavior. The current Colors grid is the primary picker workflow, but the palette repository still uses source swatches for source palette options, source listing, source pinning, source-backed harmony suggestions, diagnostics, table counts, and DB Viewer visibility. Removing the table now would break those paths or force browser/server fallbacks, which would violate the current DB SSoT direction. |
| 56 | + |
| 57 | +### 838-Record Finding |
| 58 | + |
| 59 | +Targeted Node probe: |
| 60 | + |
| 61 | +```text |
| 62 | +seedRows: 838 |
| 63 | +tableRows: 838 |
| 64 | +sourceOptions: 11 |
| 65 | +sourcePaletteRecordCount: 838 |
| 66 | +tableCounts: palette_colors=0, palette_source_swatches=838, palette_swatch_usages=0, project_workspace_palette_globals=1 |
| 67 | +``` |
| 68 | + |
| 69 | +Conclusion: the 838 rows are dev/runtime seed-backed curated source swatches. They are legacy in the sense that they support the older source palette browser/harmony model, but they are not currently unused. |
| 70 | + |
| 71 | +## Palette Table Ownership Recommendation |
| 72 | + |
| 73 | +| Table | Current owner | Recommendation | |
| 74 | +| --- | --- | --- | |
| 75 | +| `palette_colors` | DB-backed Colors Project Swatches | Keep. It is the active project swatch table and is written/read by the Colors repository and DB Viewer. | |
| 76 | +| `palette_source_swatches` | DB-backed curated source/reference swatches | Keep for now. Do not delete until source browser/harmony matching is intentionally migrated to a new curated source catalog/service or retired. | |
| 77 | +| `palette_swatch_usages` | DB-backed swatch usage/dependency rows | Keep. It supports usage/dependency tracking and DB Viewer relationship diagnostics. | |
| 78 | +| `project_workspace_palette_globals` | DB-backed per-project palette settings/global records | Keep. It supports project palette settings and relationship checks for project swatches. | |
| 79 | + |
| 80 | +Future migration option: if the product direction is to remove source-browser behavior entirely, first remove or replace `sourcePaletteOptions()`, `listSourceSwatches()`, source pinning, and source-backed harmony matching. After that, migrate any still-useful curated swatches into a clearly named source catalog service/table or archive the seed file with a migration report. |
| 81 | + |
| 82 | +## Colors Metadata Repair |
| 83 | + |
| 84 | +During the requested Colors grid validation, the first run failed because generated picker swatches stored `sortField: "default"` when the preview grid was in default spatial order. That value is an internal layout sentinel, not a useful user-facing stored sort setting. `toolbox/colors/colors.js` now stores the active Project Swatches sort (`hue`, ascending by default) when the preview layout is `default`, while preserving the actual Picker Preview grid order and duplicate behavior. |
| 85 | + |
| 86 | +## Validation |
| 87 | + |
| 88 | +| Lane | Status | Command | Evidence | |
| 89 | +| --- | --- | --- | --- | |
| 90 | +| Branch guard | PASS | `git branch --show-current`; `git branch --list` | Current branch `main`; local branch list `main`. | |
| 91 | +| Palette DB audit probe | PASS | Inline Node import of palette seed and repository | Confirmed 838 seeded source rows, 838 repository table rows, 11 source options, and table counts. | |
| 92 | +| Changed JS syntax | PASS | `node --check toolbox/colors/colors.js` | Changed Colors JS parsed successfully. | |
| 93 | +| Colors grid/runtime Playwright | PASS | `npx playwright test tests/playwright/tools/PaletteToolMockRepository.spec.mjs --reporter=line` | 9 passed after metadata repair. Initial run exposed the `sortField: default` metadata drift. | |
| 94 | +| DB Viewer palette grouping Playwright | PASS | `npx playwright test tests/playwright/tools/AdminDbViewer.spec.mjs --reporter=line` | 7 passed. Covers Palette filter, `palette_source_swatches` visibility, raw DB-shaped Palette tables, Local Mem, and Local DB inspection. | |
| 95 | +| Static whitespace validation | PASS | `git diff --check` | No whitespace errors after report generation. | |
| 96 | + |
| 97 | +## Impacted Lane |
| 98 | + |
| 99 | +- Palette/Colors DB audit and runtime lane. |
| 100 | +- Admin DB Viewer Palette grouping lane. |
| 101 | + |
| 102 | +## Skipped Lanes |
| 103 | + |
| 104 | +| Lane | Status | Reason | |
| 105 | +| --- | --- | --- | |
| 106 | +| Full samples validation | SKIP | This PR does not touch sample loaders, game runtime, sample assets, or the shared sample framework. | |
| 107 | +| Broad Toolbox/Admin migration validation | SKIP | The request explicitly scoped this PR to Palette/Colors DB audit and DB Viewer palette grouping. | |
| 108 | +| Unrelated Toolbox/Admin data migration | SKIP | The request said not to migrate unrelated Toolbox/Admin data. | |
| 109 | + |
| 110 | +## Manual Test Notes |
| 111 | + |
| 112 | +No manual browser walkthrough was required beyond the targeted Playwright lanes. The audit found `palette_source_swatches` is still active and should not be deleted in this PR. |
0 commit comments