fix(simulation): address PR #142 review round 2

gen_queue: add in_flight_count tracking for all work item types (not
just AnalyzeBody). Rewrite saturation test with AnalyzeBody items.
Fix priority_ordering test thread count to match new gate.

rng: collapse to single AtlasRng::new(seed) constructor — callers
own their seed transform.

import_province_boundaries: fix "savepoint" comment to "transaction".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-03 15:51:10 +02:00
co-authored by Claude Opus 4.6
parent 332b9404be
commit 0d09d905e4
5 changed files with 63 additions and 70 deletions
+6 -23
View File
@@ -3,10 +3,7 @@
//! Shared by all atlas generation modules that need seeded randomness.
//! Uses Knuth's LCG parameters — integer-only arithmetic, no f32, D-010 compliant.
//!
//! Two construction options:
//! - [`AtlasRng::new`] — adds 1 to seed (district_mix convention).
//! - [`AtlasRng::new_mixed`] — mixes seed with a Fibonacci hash constant to
//! avoid degenerate state at 0 (skeleton_gen convention).
//! Callers are responsible for any seed pre-mixing before calling `AtlasRng::new`.
/// Seeded linear congruential generator (D-010).
pub struct AtlasRng {
@@ -14,18 +11,12 @@ pub struct AtlasRng {
}
impl AtlasRng {
/// Seed by adding 1 — matches the district_mix convention.
/// Create a new RNG from a pre-mixed seed.
///
/// Callers must ensure the seed is non-degenerate (avoid passing 0 directly
/// if the seed could realistically be 0 — add a constant before calling).
pub fn new(seed: u64) -> Self {
Self {
state: seed.wrapping_add(1),
}
}
/// Seed with Fibonacci hash mix — avoids degenerate state at seed=0.
pub fn new_mixed(seed: u64) -> Self {
Self {
state: seed.wrapping_add(0x9e37_79b9_7f4a_7c15),
}
Self { state: seed }
}
fn next_u64(&mut self) -> u64 {
@@ -63,12 +54,4 @@ mod tests {
let vals_b: Vec<u32> = (0..10).map(|_| b.next_u32()).collect();
assert_ne!(vals_a, vals_b);
}
#[test]
fn mixed_seed_avoids_zero_state() {
let mut r = AtlasRng::new_mixed(0);
// Should not produce a constant zero sequence.
let vals: Vec<u32> = (0..5).map(|_| r.next_u32()).collect();
assert!(vals.iter().any(|&v| v != 0));
}
}