voxel-chunk-lifecycle
Models the lifecycle of streamed voxel chunks and their ownership. Use when adding chunk loading, generation, meshing, GPU upload, eviction, or cancellation.
SKILL.mdcurated-skill-sources/engine-runtime/voxel-chunk-lifecycle/SKILL.md
GitHubVoxel Chunk Lifecycle
Use when
Chunks appear twice, disappear during reload, keep stale meshes, or finish asynchronous work after they have been unloaded.
Workflow
- Define explicit states such as absent, requested, generating, generated, meshing, ready-to-upload, resident, and evicting.
- Assign each request a chunk key plus generation/version token so stale async completions can be rejected.
- Specify ownership for voxel data, mesh data, GPU resources, and neighbor dependencies; define cancellation and eviction rules.
- Test every transition, including unload/reload during generation, neighbor edits, world shutdown, and repeated requests.
Required output
A state-transition table, ownership diagram, cancellation contract, and lifecycle regression cases.
Validation
- Every async result checks that its token still matches the current chunk generation.
- Resources are freed exactly once and stale meshes cannot replace newer ones.
- Boundary and shutdown transitions are covered.
Guardrails
Do not rely on timing delays or arbitrary sleeps to hide lifecycle races; expose state and make transitions testable.