|
| 1 | +Toolbox Aid |
| 2 | +David Quesenberry |
| 3 | +04/03/2026 |
| 4 | +PLAN_PR_SPRITE_EDITOR_PROJECT_INTEGRATION.md |
| 5 | + |
| 6 | +# PLAN_PR_SPRITE_EDITOR_PROJECT_INTEGRATION |
| 7 | + |
| 8 | +## 1. Goals |
| 9 | +- Integrate isolated Sprite Editor with engine-authoritative palette flow. |
| 10 | +- Make engine palette list the single source of truth. |
| 11 | +- Enforce palette-gated editing and palette lock semantics for project/session consistency. |
| 12 | +- Define persistence contract for palette identity without duplicating palette authority. |
| 13 | +- Keep implementation small, boundary-safe, and compatible with future tool pipeline alignment. |
| 14 | + |
| 15 | +## 2. In Scope / Out of Scope |
| 16 | +In scope: |
| 17 | +- Sprite Editor integration planning for engine palette contract consumption. |
| 18 | +- Disabled-until-palette-selected UX and locked-palette UX contracts. |
| 19 | +- Save/load project palette identity contract. |
| 20 | +- Error behavior contract when engine palette source is unavailable. |
| 21 | +- Docs/reports bundle for PLAN stage. |
| 22 | + |
| 23 | +Out of scope: |
| 24 | +- Engine rewrites or new engine palette systems. |
| 25 | +- Changes to pre-existing sprite editor implementations outside `tools/Sprite Editor/`. |
| 26 | +- Unrelated tools or gameplay/runtime systems. |
| 27 | +- Any destructive or migration-heavy repo changes. |
| 28 | + |
| 29 | +## 3. Exact Files Likely To Change (for BUILD_PR) |
| 30 | +Primary likely implementation files: |
| 31 | +- `tools/Sprite Editor/index.html` |
| 32 | +- `tools/Sprite Editor/modules/spriteEditorApp.js` |
| 33 | +- `tools/Sprite Editor/modules/projectModel.js` |
| 34 | +- `tools/Sprite Editor/modules/constants.js` |
| 35 | +- `tools/Sprite Editor/README.md` |
| 36 | + |
| 37 | +Optional tiny integration point: |
| 38 | +- `tools/Sprite Editor/main.js` (only if bootstrap wiring required) |
| 39 | + |
| 40 | +Required BUILD docs/report files: |
| 41 | +- `docs/pr/BUILD_PR_SPRITE_EDITOR_PROJECT_INTEGRATION.md` |
| 42 | +- `CODEX_COMMANDS.md` |
| 43 | +- `docs/dev/reports/change_summary.txt` |
| 44 | +- `docs/dev/reports/validation_checklist.txt` |
| 45 | +- `docs/dev/reports/file_tree.txt` |
| 46 | + |
| 47 | +## 4. Engine Integration Contract For paletteList |
| 48 | +Authoritative source: |
| 49 | +- Engine-owned `engine/paletteList.js` exposes `globalThis.palettesList` / `window.palettesList`. |
| 50 | + |
| 51 | +Tool integration rule: |
| 52 | +- Sprite Editor reads palette sets from that engine contract only. |
| 53 | +- Sprite Editor does not define a hardcoded tool-only authoritative palette catalog. |
| 54 | + |
| 55 | +Boundary rule: |
| 56 | +- Sprite Editor uses read-only consumption of engine palette data. |
| 57 | +- No writes/mutations to `globalThis.palettesList`. |
| 58 | +- No duplicated authority copy in tool modules. |
| 59 | + |
| 60 | +Loading rule: |
| 61 | +- If `globalThis.palettesList` is available and valid, build palette selector options from it. |
| 62 | +- If unavailable/invalid, editor enters blocked mode (non-destructive, no editing) and presents actionable recovery message. |
| 63 | + |
| 64 | +Expected contract shape consumed by Sprite Editor: |
| 65 | +- paletteId -> array of entries |
| 66 | +- each entry expected to expose at minimum a usable `hex` color value |
| 67 | +- optional metadata (name/symbol) may be displayed but is not required for editing correctness |
| 68 | + |
| 69 | +## 5. Disabled-Until-Palette-Selected Behavior Contract |
| 70 | +Initial load state: |
| 71 | +- Palette selector enabled. |
| 72 | +- Editing actions disabled until palette selected. |
| 73 | + |
| 74 | +Disabled actions before selection: |
| 75 | +- draw/erase/fill interactions |
| 76 | +- frame editing actions |
| 77 | +- import PNG into frame |
| 78 | +- resize/new-canvas actions that mutate document pixels |
| 79 | +- export actions that rely on active edit context |
| 80 | + |
| 81 | +Allowed actions before selection: |
| 82 | +- palette selection |
| 83 | +- load existing JSON project (to restore/resolve palette identity) |
| 84 | +- read-only UI browsing and status/help interactions |
| 85 | + |
| 86 | +UX messaging requirement: |
| 87 | +- Status/readout must clearly state: "Select palette from engine list to enable editing." |
| 88 | +- Disabled controls should appear visibly disabled, not silently ignored. |
| 89 | + |
| 90 | +## 6. Locked-Palette Behavior Contract |
| 91 | +Lock trigger: |
| 92 | +- First successful palette selection on new session/project, or |
| 93 | +- successful project load that resolves a saved palette identity to engine palette list. |
| 94 | + |
| 95 | +Lock semantics: |
| 96 | +- After lock, palette selector is read-only for that active project/session. |
| 97 | +- User cannot switch to a different palette through normal interaction. |
| 98 | + |
| 99 | +Explicit unlock flows (allowed): |
| 100 | +- New Project flow (creates fresh project and clears prior lock) |
| 101 | +- Approved reset/new-project action explicitly documented in UI |
| 102 | + |
| 103 | +Operation-specific lock behavior: |
| 104 | +- New Project: clears existing lock and requires new palette selection before edits. |
| 105 | +- Load Existing JSON Project: |
| 106 | + - if saved paletteId resolves in engine list -> auto-lock to that palette. |
| 107 | + - if saved paletteId missing/unresolvable -> project loads into blocked palette-selection state; user must choose one palette, then it locks. |
| 108 | +- PNG Import: uses current locked palette context; does not unlock or change palette. |
| 109 | +- Resize Canvas: preserves current lock; no palette switching. |
| 110 | +- Duplicate Frame: preserves current lock. |
| 111 | +- Save/Load Flow: save records palette identity; load attempts restore and lock as above. |
| 112 | + |
| 113 | +## 7. Save/Load Project Palette Contract |
| 114 | +Saved JSON contract addition: |
| 115 | +- Store palette reference block, not authoritative palette catalog copy. |
| 116 | + |
| 117 | +Planned shape: |
| 118 | +- `paletteRef.source = "engine/paletteList"` |
| 119 | +- `paletteRef.id = <paletteId>` |
| 120 | +- `paletteRef.locked = true` |
| 121 | +- optional non-authoritative verification metadata (example: color count/signature) for diagnostics only |
| 122 | + |
| 123 | +Load contract: |
| 124 | +- Resolve `paletteRef.id` against engine palette list. |
| 125 | +- On success: restore lock and enable editing. |
| 126 | +- On failure: keep editing blocked until user selects palette; then write new lock in memory. |
| 127 | + |
| 128 | +No-authority-duplication rule: |
| 129 | +- Serialized project must not become an alternative palette authority source. |
| 130 | +- Tool may store convenience metadata but engine palette list remains source of truth. |
| 131 | + |
| 132 | +## 8. Manual Validation Checklist (for BUILD/APPLY) |
| 133 | +- Confirm Sprite Editor loads engine palette list from engine contract path. |
| 134 | +- Confirm no tool-local hardcoded authoritative palette list is used. |
| 135 | +- Confirm editing is blocked on first load until palette selected. |
| 136 | +- Confirm selecting palette enables editing and locks selector. |
| 137 | +- Confirm palette cannot be changed during active project/session via normal controls. |
| 138 | +- Confirm New Project clears lock and requires new selection. |
| 139 | +- Confirm Load JSON with resolvable paletteRef auto-locks correctly. |
| 140 | +- Confirm Load JSON with missing paletteRef enters blocked selection state. |
| 141 | +- Confirm PNG import/resize/duplicate frame preserve lock. |
| 142 | +- Confirm save JSON includes paletteRef identity fields. |
| 143 | +- Confirm load/save messaging explains lock/resolution outcomes. |
| 144 | +- Confirm no engine or unrelated tool files were changed beyond approved integration touchpoints. |
| 145 | + |
| 146 | +## 9. BUILD_PR Command |
| 147 | +`Create BUILD_PR_SPRITE_EDITOR_PROJECT_INTEGRATION.` |
| 148 | + |
| 149 | +Required BUILD constraints: |
| 150 | +- Implement only this approved plan. |
| 151 | +- Keep PR small and surgical. |
| 152 | +- Use engine palette contract as single authority. |
| 153 | +- Do not modify pre-existing sprite editor implementations outside `tools/Sprite Editor/`. |
| 154 | +- Do not introduce engine rewrites. |
| 155 | +- Produce delta zip: `tmp/BUILD_PR_SPRITE_EDITOR_PROJECT_INTEGRATION_delta.zip`. |
| 156 | + |
| 157 | +## 10. Commit Comment |
| 158 | +`BUILD_PR_SPRITE_EDITOR_PROJECT_INTEGRATION: integrate isolated Sprite Editor with engine-authoritative palette contract and locked palette flow` |
| 159 | + |
| 160 | +## 11. Next Command |
| 161 | +`APPLY_PR_SPRITE_EDITOR_PROJECT_INTEGRATION` |
0 commit comments