fix(simulation): PR #179 review round — F1-F4
F1: T-1112 amendment touch-point list gains the ZoningType PartialOrd/Ord derive (mirroring DistrictType's T-994 precedent) so the dominant_zoning declaration-order tie-break is computable. F2: stale terminal-layer doc on AtlasLayerRequest.up_to corrected to Region. F3: believability cascade_for_body bumped to Region — harness mirrors production depth, invariant documented. F4: end-to-end dispatch coverage — populated-regions test asserts regions + second handle_atlas_request returns region_grid; no-params sibling asserts regions empty. Suites: layer_proxy 10, believability 4, gen_queue 8, cascade 10. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -497,7 +497,14 @@ pub fn seed_to_u64(seed: &str) -> u64 {
|
||||
}
|
||||
|
||||
/// Resolve the committed inputs for `body_id` and run the real deterministic cascade
|
||||
/// (through the road graph), returning the per-body world state to [`analyze`].
|
||||
/// (through the full production depth, `CascadeLayer::Region`), returning the
|
||||
/// per-body world state to [`analyze`].
|
||||
///
|
||||
/// The terminal layer here MIRRORS production (`gen_queue.rs::run_work_item`) by
|
||||
/// ruling (PR #179 F3): a shallower harness run would silently hand future
|
||||
/// believability conditions (D-245's climate-appropriateness is the natural
|
||||
/// consumer of `state.regions`) an empty layer that production populates.
|
||||
/// When production's terminal advances, advance this one with it.
|
||||
///
|
||||
/// `Err` if `systems.db` or the body's `heightmap.png` cannot be found, or the body
|
||||
/// has no params — callers (the regression harness) may *skip* on that rather than
|
||||
@@ -529,7 +536,7 @@ pub fn cascade_for_body(world_seed: u64, body_id: &str) -> Result<BodyWorldState
|
||||
&cities,
|
||||
None,
|
||||
Some(¶ms),
|
||||
CascadeLayer::RoadGraph,
|
||||
CascadeLayer::Region,
|
||||
);
|
||||
Ok(snapshot.into_body_world_state())
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ const DEFAULT_SEA_LEVEL: f32 = 0.3;
|
||||
/// A client request for a body's generation layers (D-225).
|
||||
///
|
||||
/// `up_to` is a forward-compat seam that is **not yet honored**: `run_work_item`
|
||||
/// (`gen_queue.rs`) currently runs the cascade through `CascadeLayer::RoadGraph`
|
||||
/// (the terminal layer, T-1038) unconditionally on every request, ignoring this
|
||||
/// (`gen_queue.rs`) currently runs the cascade through `CascadeLayer::Region`
|
||||
/// (the terminal layer, T-1113) unconditionally on every request, ignoring this
|
||||
/// field. Wiring per-request depth (and the partial caching it implies) is
|
||||
/// deferred to #1021.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -1104,7 +1104,11 @@ mod tests {
|
||||
}
|
||||
|
||||
/// With body_params_reader wired, a cache miss enqueues an AnalyzeBody that
|
||||
/// completes with populated `districts` (DistrictProfile layer ran).
|
||||
/// completes with populated `districts` (DistrictProfile layer ran) AND
|
||||
/// populated `regions` (Region layer ran — the production terminal,
|
||||
/// T-1113). Then the completed state served back through
|
||||
/// `handle_atlas_request` carries a `region_grid` — closing the full
|
||||
/// dispatch → Ready → region_grid loop (PR #179 F4).
|
||||
#[test]
|
||||
fn body_params_reader_wired_produces_populated_regions() {
|
||||
let mut cache = BodyWorldStateCache::new(CACHE_CAPACITY);
|
||||
@@ -1142,6 +1146,29 @@ mod tests {
|
||||
!body_state.districts.is_empty(),
|
||||
"districts must be populated when body_params_reader is wired (T-1032 dispatch path)"
|
||||
);
|
||||
assert!(
|
||||
!body_state.regions.is_empty(),
|
||||
"regions must be populated when body_params_reader is wired (T-1113 dispatch path)"
|
||||
);
|
||||
|
||||
// Serve the completed state back through the proxy: the cache-hit
|
||||
// branch must build and include the region grid.
|
||||
cache.insert(body_state);
|
||||
let ready = handle_atlas_request(
|
||||
&req("GJ1c"),
|
||||
&mut cache,
|
||||
&queue,
|
||||
&resolver,
|
||||
None,
|
||||
Some(¶ms_reader),
|
||||
42,
|
||||
2,
|
||||
);
|
||||
assert_eq!(ready.status, AtlasLayerStatus::Ready);
|
||||
assert!(
|
||||
ready.region_grid.is_some(),
|
||||
"a Ready response for a Region-populated body must carry region_grid"
|
||||
);
|
||||
}
|
||||
|
||||
/// Without body_params_reader (None), districts is empty — pre-T-1032 behaviour.
|
||||
@@ -1181,5 +1208,10 @@ mod tests {
|
||||
body_state.districts.is_empty(),
|
||||
"districts must remain empty when no body_params_reader is wired"
|
||||
);
|
||||
assert!(
|
||||
body_state.regions.is_empty(),
|
||||
"regions must remain empty when no body_params_reader is wired \
|
||||
(the Region layer gates on body_params, T-1113)"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user