|
| 1 | +# BUILD_PR_LEVEL_09_05_SHARED_ASSET_HANDOFF_ENFORCEMENT |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Implement the smallest enforcement slice that makes the shared asset and shared palette handoff contract real across first-class tools after 09_04 asset structure simplification. |
| 5 | + |
| 6 | +This PR must tighten launch/consume behavior for shared asset flows without widening into engine refactors, sample work, or broad UI redesign. |
| 7 | + |
| 8 | +## Why This PR Exists |
| 9 | +09_04 established the asset usage contract, moved active template surfaces under `tools/templates/`, and proved normalized shared asset locations across Asteroids and the starter project baseline. However, the contract is still only partially effective until active tools consistently: |
| 10 | +- launch shared browse/import/manage flows through the common shell |
| 11 | +- publish normalized handoff payloads under the approved storage keys |
| 12 | +- consume shared handoff summaries without silently forking tool-private defaults |
| 13 | + |
| 14 | +This PR closes that enforcement gap. |
| 15 | + |
| 16 | +## Source Baseline |
| 17 | +Treat these as the architectural baseline for this PR: |
| 18 | +- `docs/specs/asset_usage_contract.md` |
| 19 | +- `tools/shared/vectorAssetSystem.js` |
| 20 | +- `tools/Asset Browser/main.js` |
| 21 | +- `tools/templates/starter-project-template/config/starter.project.json` |
| 22 | +- `tests/tools/VectorAssetSystem.test.mjs` |
| 23 | + |
| 24 | +## In Scope |
| 25 | +- first-class tool launch and consume enforcement for shared asset/palette handoff |
| 26 | +- shared shell action normalization where required for the in-scope tools |
| 27 | +- storage-key and payload-shape enforcement against the 09_04 contract |
| 28 | +- narrow validation/tests that prove the contract is being used consistently |
| 29 | +- starter template compatibility only where required to preserve the contract |
| 30 | + |
| 31 | +## Out of Scope |
| 32 | +- engine core API changes |
| 33 | +- game runtime behavior changes |
| 34 | +- sample curriculum work |
| 35 | +- broad tool UI cleanup or redesign |
| 36 | +- legacy tool reintegration |
| 37 | +- filesystem mutation/import-copy automation expansion |
| 38 | +- broad asset registry redesign |
| 39 | + |
| 40 | +## Required Contract Enforcement |
| 41 | + |
| 42 | +### 1. Shared action labels remain exact |
| 43 | +For active first-class tools in scope, shared actions must continue using these exact labels: |
| 44 | +- `Browse Assets` |
| 45 | +- `Import Assets` |
| 46 | +- `Browse Palettes` |
| 47 | +- `Manage Palettes` |
| 48 | + |
| 49 | +Do not introduce tool-specific label drift. |
| 50 | + |
| 51 | +### 2. Shared launch query contract must be real |
| 52 | +When an in-scope tool launches the shared Asset Browser or Palette Browser flow, it must use the normalized query-parameter contract defined in `docs/specs/asset_usage_contract.md`: |
| 53 | +- `view` |
| 54 | +- `sourceToolId` |
| 55 | + |
| 56 | +Examples: |
| 57 | +- `../Asset Browser/index.html?view=import&sourceToolId=tile-map-editor` |
| 58 | +- `../Palette Browser/index.html?view=browse&sourceToolId=sprite-editor` |
| 59 | + |
| 60 | +No alternate ad hoc query names may be introduced. |
| 61 | + |
| 62 | +### 3. Shared handoff storage keys must be canonical |
| 63 | +Asset handoff must use: |
| 64 | +- `toolboxaid.shared.assetHandoff` |
| 65 | + |
| 66 | +Palette handoff must use: |
| 67 | +- `toolboxaid.shared.paletteHandoff` |
| 68 | + |
| 69 | +Do not add duplicate parallel keys for the same responsibility. |
| 70 | + |
| 71 | +### 4. Handoff payload shape must be normalized |
| 72 | +For the tools touched in this PR, handoff payloads must preserve the stable top-level fields documented in the contract. |
| 73 | + |
| 74 | +Asset handoff must preserve at minimum: |
| 75 | +- `assetId` |
| 76 | +- `assetType` |
| 77 | +- `sourcePath` |
| 78 | +- `displayName` |
| 79 | +- `metadata` |
| 80 | +- `sourceToolId` |
| 81 | +- `selectedAt` |
| 82 | + |
| 83 | +Palette handoff must preserve at minimum: |
| 84 | +- `paletteId` |
| 85 | +- `displayName` |
| 86 | +- `colors` |
| 87 | +- `metadata` |
| 88 | +- `sourceToolId` |
| 89 | +- `selectedAt` |
| 90 | + |
| 91 | +Metadata may extend the shape but must not replace the stable top-level fields. |
| 92 | + |
| 93 | +### 5. Active tools must consume the shared handoff, not fork private defaults |
| 94 | +For each in-scope tool, consuming a handoff must prefer the shared contract payload over hidden tool-private default copies whenever the handoff payload is valid. |
| 95 | + |
| 96 | +Graceful degradation is required: |
| 97 | +- invalid or missing handoff payloads must not crash the tool |
| 98 | +- invalid or missing payloads may fall back safely |
| 99 | +- fallback must not overwrite the canonical handoff contract with malformed data |
| 100 | + |
| 101 | +## Required Implementation Shape |
| 102 | +Implement the smallest safe slice that proves the contract across the most important active tools. |
| 103 | + |
| 104 | +### Minimum in-scope tools |
| 105 | +At minimum, cover: |
| 106 | +- `Asset Browser / Import Hub` |
| 107 | +- `Sprite Editor` |
| 108 | +- `Vector Map Editor` |
| 109 | +- `Vector Asset Studio` |
| 110 | +- `Tile Map Editor` |
| 111 | +- `Parallax Editor` |
| 112 | + |
| 113 | +If some tools already comply, keep edits surgical and only normalize the drift that still exists. |
| 114 | + |
| 115 | +### Likely file targets |
| 116 | +Use only if needed; do not expand beyond proven necessity. |
| 117 | +- `tools/shared/...` shared launch/handoff helper(s) |
| 118 | +- active tool entry scripts for the in-scope tools |
| 119 | +- `tools/Asset Browser/main.js` |
| 120 | +- palette browser/manager entry script if present and required |
| 121 | +- focused tests under `tests/tools/` |
| 122 | +- starter template config only if compatibility needs a narrow update |
| 123 | + |
| 124 | +## Acceptance Criteria |
| 125 | +1. In-scope first-class tools launch shared browse/import/manage flows using the normalized query contract. |
| 126 | +2. Asset and palette handoffs use the canonical storage keys only. |
| 127 | +3. Published handoff payloads preserve the stable top-level contract fields. |
| 128 | +4. Consuming tools prefer valid shared handoff payloads over hidden tool-private defaults. |
| 129 | +5. Invalid or missing handoff payloads degrade safely without crashes. |
| 130 | +6. Legacy tools remain excluded. |
| 131 | +7. No engine core API files change. |
| 132 | +8. No unrelated tool-shell cleanup is bundled into this PR. |
| 133 | + |
| 134 | +## Validation Requirements |
| 135 | +Provide focused proof, not broad regression theater. |
| 136 | + |
| 137 | +### Required validation lanes |
| 138 | +- targeted unit/integration coverage for launch query generation and handoff payload normalization |
| 139 | +- targeted coverage for consumer-side safe fallback on invalid/missing payloads |
| 140 | +- targeted coverage that shared asset selection preserves canonical fields and source paths |
| 141 | +- targeted coverage that shared palette selection preserves canonical fields and colors |
| 142 | + |
| 143 | +### Manual validation checklist |
| 144 | +1. Launch each in-scope tool and confirm shared actions use normalized labels. |
| 145 | +2. Trigger `Browse Assets` or `Import Assets` from at least two tools and confirm the browser opens with `view` and `sourceToolId`. |
| 146 | +3. Select a shared asset and confirm `toolboxaid.shared.assetHandoff` stores the normalized payload. |
| 147 | +4. Select a shared palette and confirm `toolboxaid.shared.paletteHandoff` stores the normalized payload. |
| 148 | +5. Re-open a consuming tool and confirm it reads the shared handoff without creating a hidden private duplicate. |
| 149 | +6. Corrupt the stored handoff payload and confirm the tool degrades safely. |
| 150 | +7. Confirm starter project template still opens without contract breakage. |
| 151 | +8. Confirm no engine-core files changed. |
| 152 | + |
| 153 | +## Constraints |
| 154 | +- Docs-first, surgical PR only. |
| 155 | +- One purpose only: enforce shared handoff behavior. |
| 156 | +- Preserve 09_04 asset ownership and template relocation outcomes. |
| 157 | +- Do not move assets again in this PR. |
| 158 | +- Do not add new showcase/sample surfacing. |
| 159 | +- Do not change engine/game runtime contracts. |
| 160 | + |
| 161 | +## Approved Commit Comment |
| 162 | +build(assets): enforce shared tool asset and palette handoff contract |
| 163 | + |
| 164 | +## Next Command |
| 165 | +APPLY_PR_LEVEL_09_05_SHARED_ASSET_HANDOFF_ENFORCEMENT |
0 commit comments