refactor(M03): extract M2 mesh resource cache state

Work-Package: M03-RND-M2-MESH-RESOURCE-CACHE-001
Agent: sindo-main-codex
Tests: 35 headless renderer/coordinate contracts pass; checkpoint dry-run 7/7; documentation and coordination gates pass
Fidelity: preserves exact Mesh references, replacement semantics and final-shutdown lifetime; no visual parity claim
This commit is contained in:
2026-07-17 12:10:37 +04:00
parent e2bb501695
commit e990a6503d
13 changed files with 478 additions and 19 deletions
+8 -5
View File
@@ -19,7 +19,7 @@ loader retains every I/O and engine-resource operation.
## Non-goals
- Call ResourceLoader or select cache paths/formats.
- Own M2 Mesh, scene, missing or material-refresh caches.
- Own M2 scene, missing or material-refresh caches, or prepared Mesh references.
- Extract Meshes from PackedScene/GLB Resources.
- Consume finalize permits or rebuild/adopt runtime Meshes.
- Merge static and animated M2 pipelines.
@@ -38,7 +38,7 @@ flowchart LR
State --> FIFO[Finalize FIFO]
FIFO --> Loader
Loader --> Budget[M2_MESH_FINALIZE permit]
Loader --> Cache[Mesh or missing cache]
Loader --> Cache[M2 Mesh resource cache or shared missing cache]
```
Allowed dependencies are value containers, Strings and opaque integer statuses.
@@ -135,7 +135,7 @@ flowchart TB
Loader[StreamingWorldLoader] --> State[M2MeshLoadPipelineState]
Loader --> Resource[ResourceLoader]
Loader --> Budget[RenderBudgetScheduler]
Loader --> MeshCache[M2 Mesh/missing caches]
Loader --> MeshCache[M2 Mesh resource cache and shared missing cache]
Loader --> Classifier[M2RuntimeMeshRebuildClassifier]
State -. no dependency .-> Resource
State -. no dependency .-> Budget
@@ -147,7 +147,8 @@ flowchart TB
- Main thread serializes all state mutation and snapshots.
- State owns only request/finalize Dictionaries containing Strings and status integers.
- Loader owns ResourceLoader request lifetime and drains active paths before shutdown clear.
- Loader owns Mesh/missing caches, material refresh, M2Builder and engine resources.
- `M2MeshResourceCacheState` owns prepared static Mesh references; the loader
owns shared missing state, material refresh, M2Builder and other engine resources.
- Snapshot and diagnostic records are detached; caller mutation cannot affect state.
## Errors, cancellation and recovery
@@ -202,7 +203,8 @@ rebuild policy are unchanged; no migration or rebake is required.
|---|---|---|---|
| Static M2 request/finalize state | Implemented extraction | Contract/source/timing verifier | Asset-backed long traversal pending |
| ResourceLoader I/O | Existing loader-owned | Shutdown/material regressions | I/O adapter extraction optional |
| Mesh cache/materialization | Existing loader-owned | Renderer/material tests | Separate state/finalizer extraction pending |
| Mesh cache | Implemented extraction | Mesh resource cache state verifier | Asset-backed memory/leak run pending |
| Mesh materialization | Existing loader-owned | Renderer/material tests | Separate finalizer extraction pending |
## Known gaps and risks
@@ -216,6 +218,7 @@ rebuild policy are unchanged; no migration or rebake is required.
| Path | Responsibility |
|---|---|
| `src/render/m2/m2_mesh_load_pipeline_state.gd` | Pending records, terminal FIFO and metrics |
| `src/render/m2/m2_mesh_resource_cache_state.gd` | Prepared static Mesh references and final clear |
| `src/scenes/streaming/streaming_world_loader.gd` | Cache path choice, I/O polling, permits and Mesh/missing adoption |
| `src/render/m2/m2_runtime_mesh_rebuild_classifier.gd` | Downstream stale Mesh rebuild decision |
| `src/tools/verify_m2_mesh_load_pipeline_state.gd` | Lifecycle/boundary/timing regression |