fix(simulation): address PR #143 review (#1006)

- Add D-230 skeleton: DistrictSkeleton field to DistrictWorldState;
  cascade Default to DistrictSkeleton + contained enums/structs. Box the
  GenCompletion::SkeletonGenerated state to avoid large_enum_variant.
- Derive PartialEq on FloorExtent/FloorHeightProfile/DistrictWorldState/
  CityGenerationContext (+ minimal cascade) for downstream assert_eq tests.
- Add 4 unit tests for floor_at_voxel_z / voxel_range_for_floor (uniform,
  basement, variable heights, boundary) — the Q-104 deliverable.
- Drop unused smallvec direct dep (stays transitive via bevy_ecs).
- Key districts insert by skeleton.district_id, sharpen TODO(#957).

clippy --all-targets -D warnings clean; 1263 lib tests pass; fmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 22:06:57 +02:00
co-authored by Claude Opus 4.8
parent 899f447eed
commit 99da796cde
5 changed files with 161 additions and 42 deletions
+4 -3
View File
@@ -103,8 +103,9 @@ pub enum GenCompletion {
/// The body this skeleton belongs to — used to route state into
/// `BodyWorldState.districts` (D-230).
body_id: String,
/// District-level world state (block tags) produced by the plan phase (D-230).
state: DistrictWorldState,
/// District-level world state (skeleton + block tags) produced by the plan phase (D-230).
/// Boxed to keep `GenCompletion` variant sizes balanced (D-230 skeleton is ~2.7 KB).
state: Box<DistrictWorldState>,
},
ChunkFilled {
district_id: u64,
@@ -344,7 +345,7 @@ fn run_work_item(item: &GenWorkItem) -> GenCompletion {
GenCompletion::SkeletonGenerated {
city_id: *city_id,
body_id: String::new(),
state: DistrictWorldState::default(),
state: Box::new(DistrictWorldState::default()),
}
}
GenWorkItem::FillChunk {
+10 -3
View File
@@ -88,9 +88,16 @@ fn drain_generation_completions(
} => {
if !body_id.is_empty() {
if let Some(body_state) = cache.peek_mut(&body_id) {
// TODO(#957): keying by city_id is a stub — a city has multiple districts;
// use DistrictSkeleton.district_id as the DistrictId key when real skeleton gen lands.
body_state.districts.insert(city_id, state);
// Key by state.skeleton.district_id (D-194/D-230): a city has many
// districts, each with its own DistrictId. `city_id` is only the
// dispatch key used in the work item — the canonical insert key is
// the district's own stable id. TODO(#957): the stub GenerateSkeleton
// returns a default skeleton with district_id=0; real gen (#957) will
// populate it from CityGenerationContext.
let _ = city_id; // used as dispatch key only; district_id is the map key
body_state
.districts
.insert(state.skeleton.district_id, *state);
} else {
tracing::warn!(
city_id,