|
| 1 | +Toolbox Aid |
| 2 | +David Quesenberry |
| 3 | +04/05/2026 |
| 4 | +BUILD_PR_RUNTIME_SCENE_LOADER_AND_HOT_RELOAD.md |
| 5 | + |
| 6 | +# BUILD_PR_RUNTIME_SCENE_LOADER_AND_HOT_RELOAD |
| 7 | + |
| 8 | +## Purpose |
| 9 | +Create a docs-only BUILD PR that defines the implementation contract for runtime scene loading and hot reload, using the already approved cross-tool render pipeline contract as the upstream dependency. |
| 10 | + |
| 11 | +Upstream dependency (already approved): |
| 12 | +- `toolbox.render.asset-document` |
| 13 | +- `toolbox.render.composition-document` |
| 14 | +- producer mappings for Tile Map Editor, Parallax Editor, Sprite Editor, Vector Asset Studio |
| 15 | + |
| 16 | +This BUILD PR adds no implementation code. |
| 17 | + |
| 18 | +## Scope |
| 19 | +In scope: |
| 20 | +- formal runtime scene loader responsibilities |
| 21 | +- hot reload lifecycle and deterministic reload order |
| 22 | +- watcher bridge boundaries |
| 23 | +- public engine mappings only |
| 24 | +- validation and structured error taxonomy |
| 25 | +- composition-driven reload rules |
| 26 | +- focused test plan and validation checklist |
| 27 | + |
| 28 | +Out of scope: |
| 29 | +- engine core API redesign |
| 30 | +- tool payload redesign |
| 31 | +- sample-specific runtime ownership |
| 32 | +- unrelated refactors |
| 33 | +- implementation code |
| 34 | + |
| 35 | +## Runtime Scene Loader Responsibilities |
| 36 | + |
| 37 | +### SceneCompositionLoader |
| 38 | +Responsibilities: |
| 39 | +- accept a composition document (`toolbox.render.composition-document`) |
| 40 | +- validate composition envelope, version, producer identity, and references |
| 41 | +- resolve referenced asset documents (`toolbox.render.asset-document`) |
| 42 | +- normalize scene package structure for runtime consumption |
| 43 | +- return structured errors on failure |
| 44 | + |
| 45 | +Non-responsibilities: |
| 46 | +- no schema migration |
| 47 | +- no silent mutation of invalid input |
| 48 | +- no direct rendering |
| 49 | + |
| 50 | +### RuntimeSceneLoader |
| 51 | +Responsibilities: |
| 52 | +- load normalized scene package into runtime through public engine entry points |
| 53 | +- initialize scene domains in deterministic stage order |
| 54 | +- track domain-level handles for targeted reload/dispose |
| 55 | +- preserve domain isolation (reload only affected domain unless full-recompose is required) |
| 56 | + |
| 57 | +Non-responsibilities: |
| 58 | +- no file watching |
| 59 | +- no editor/tool UI ownership |
| 60 | +- no sample-only private integration paths |
| 61 | + |
| 62 | +## Hot Reload Lifecycle |
| 63 | +Hot reload must be optional in development and use deterministic ordering that matches initial load. |
| 64 | + |
| 65 | +Lifecycle: |
| 66 | +1. WatcherBridge receives a file-change event. |
| 67 | +2. HotReloadCoordinator classifies changed artifact domain(s). |
| 68 | +3. Validate changed document(s) against locked contract schema. |
| 69 | +4. Resolve composition impact (targeted domain reload vs full recompose). |
| 70 | +5. Perform staged reload in deterministic order. |
| 71 | +6. Swap runtime handles atomically for affected domain(s). |
| 72 | +7. Dispose retired handles. |
| 73 | +8. Emit structured success/failure event. |
| 74 | +9. On failure, preserve last known-good runtime state. |
| 75 | + |
| 76 | +Deterministic reload order: |
| 77 | +1. composition metadata |
| 78 | +2. parallax domain |
| 79 | +3. tilemap domain |
| 80 | +4. sprite/entity domain |
| 81 | +5. vector/overlay domain |
| 82 | +6. ready signal |
| 83 | + |
| 84 | +## Watcher Bridge Boundaries |
| 85 | +Responsibilities: |
| 86 | +- normalize external file-change events into runtime-safe event payloads |
| 87 | +- provide only path + event-type + timestamp + optional hash metadata |
| 88 | +- remain optional and disabled outside development mode |
| 89 | + |
| 90 | +Boundaries: |
| 91 | +- no schema validation ownership |
| 92 | +- no composition assembly ownership |
| 93 | +- no direct runtime scene mutation |
| 94 | +- no engine core lifecycle ownership |
| 95 | + |
| 96 | +## Public Engine Mappings (Locked) |
| 97 | +Only public mappings are allowed: |
| 98 | +- composition doc -> `SceneCompositionLoader` |
| 99 | +- normalized scene package -> `RuntimeSceneLoader` |
| 100 | +- parallax contract payload -> approved parallax runtime entry path |
| 101 | +- tilemap contract payload -> approved tilemap runtime entry path |
| 102 | +- sprite contract payload -> approved sprite/entity runtime entry path |
| 103 | +- vector contract payload -> approved vector runtime entry path |
| 104 | +- lifecycle wiring -> scene init/update/render/dispose public flow |
| 105 | + |
| 106 | +No internal/private engine bypass is allowed in this PR. |
| 107 | + |
| 108 | +## Validation and Error Taxonomy |
| 109 | +Validation levels: |
| 110 | +- composition envelope validation |
| 111 | +- referenced asset-document validation |
| 112 | +- domain-specific payload validation |
| 113 | +- cross-reference validation (asset IDs, layer refs, domain refs) |
| 114 | + |
| 115 | +Structured error envelope: |
| 116 | +- `level`: `error` | `warning` |
| 117 | +- `stage`: `load` | `validate` | `resolve` | `compose` | `reload` | `dispose` |
| 118 | +- `code`: deterministic machine-readable code |
| 119 | +- `path`: document path or domain path |
| 120 | +- `message`: human-readable summary |
| 121 | +- `details`: stable object payload |
| 122 | + |
| 123 | +Required non-silent rejection behavior: |
| 124 | +- invalid version -> reject |
| 125 | +- invalid schema -> reject |
| 126 | +- missing required reference -> reject |
| 127 | +- unsupported producer mapping -> reject |
| 128 | +- reload validation failure -> reject reload, keep last known-good state |
| 129 | + |
| 130 | +## Composition-Driven Reload Rules |
| 131 | +Targeted reload rules: |
| 132 | +- parallax-only change -> reload parallax domain only |
| 133 | +- tilemap-only change -> reload tilemap + dependent collision domain only |
| 134 | +- sprite-only change -> reload sprite/entity domain only |
| 135 | +- vector-only change -> reload vector/overlay domain only |
| 136 | + |
| 137 | +Full recompose triggers: |
| 138 | +- composition manifest changed |
| 139 | +- layer/domain ordering changed |
| 140 | +- document-level metadata affecting scene assembly changed |
| 141 | + |
| 142 | +All reload decisions must be deterministic and recorded in structured events. |
| 143 | + |
| 144 | +## Test Plan |
| 145 | +Automated tests to implement in APPLY PR: |
| 146 | +- valid composition load succeeds |
| 147 | +- unsupported version fails fast |
| 148 | +- missing reference fails with structured error |
| 149 | +- deterministic stage ordering on initial load |
| 150 | +- deterministic stage ordering on reload |
| 151 | +- targeted parallax reload |
| 152 | +- targeted tilemap reload |
| 153 | +- targeted sprite reload |
| 154 | +- targeted vector reload |
| 155 | +- composition-change full recompose |
| 156 | +- failed reload preserves last known-good scene state |
| 157 | +- replaced handles are disposed |
| 158 | + |
| 159 | +Manual validation checklist (APPLY PR): |
| 160 | +- runtime scene loads from composition document with all 4 producers |
| 161 | +- development watcher can trigger reload workflow |
| 162 | +- invalid changed document is rejected without corrupting runtime state |
| 163 | +- deterministic order is consistent across repeated reload cycles |
| 164 | +- production mode disables watcher bridge cleanly |
| 165 | + |
| 166 | +## Deliverables For This BUILD PR (Docs-Only) |
| 167 | +- `docs/pr/BUILD_PR_RUNTIME_SCENE_LOADER_AND_HOT_RELOAD.md` |
| 168 | +- `docs/dev/codex_commands.md` |
| 169 | +- `docs/dev/commit_comment.txt` |
| 170 | +- `docs/dev/change_summary.txt` |
| 171 | +- `docs/dev/validation_checklist.txt` |
| 172 | +- `docs/dev/file_tree.txt` |
| 173 | +- `docs/dev/next_command.txt` |
| 174 | + |
| 175 | +## Packaging |
| 176 | +Output delta zip path: |
| 177 | +- `<project folder>/tmp/BUILD_PR_RUNTIME_SCENE_LOADER_AND_HOT_RELOAD_delta.zip` |
| 178 | + |
| 179 | +Zip content constraints: |
| 180 | +- repo-relative structure preserved |
| 181 | +- docs-only files for this PR purpose |
| 182 | +- no implementation files |
| 183 | + |
| 184 | +## Commit Comment |
| 185 | +`docs: build runtime scene loader and hot reload contract bundle` |
| 186 | + |
| 187 | +## Next Command |
| 188 | +`APPLY_PR_RUNTIME_SCENE_LOADER_AND_HOT_RELOAD` |
0 commit comments