fix(simulation): address PR #87 review — name collision, validation, and polish

- Fix critical name collision: shuffle+pop for unique NPC names (#3)
- Validate population_density >= 1 in generator and validator (#4)
- Guard against empty given_names/roles with validator warnings (#5)
- Extract filler word cap to MAX_FILLER_WORDS constant (#6)
- Fix cultural behavior gate checking wrong field (#7)
- Document intentional one-directional relationships (#8)
- Validate min_npcs <= max_npcs in validator (#9)
- Fix validate-ron script realpath error handling (#10)
- Add TODO comments for spike-specific code duplication (#11, #12, #13)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 21:50:33 +01:00
co-authored by Claude Opus 4.6
parent 0f83c64e8f
commit a54b9d24e0
3 changed files with 135 additions and 31 deletions
+29
View File
@@ -49,6 +49,27 @@ fn main() {
Ok(spec) => {
println!("Valid ZoneSpec: {} ({})", spec.label, spec.zone_type);
println!(" {} roles, {} social sites", spec.roles.len(), spec.social_sites.len());
let mut warnings = 0;
if spec.roles.is_empty() {
eprintln!(" WARNING: no roles defined — generator will reject this");
warnings += 1;
}
if spec.population_density < 1 {
eprintln!(" WARNING: population_density is 0 — generator requires >= 1");
warnings += 1;
}
for site in &spec.social_sites {
if site.min_npcs > site.max_npcs {
eprintln!(
" WARNING: social site '{}' has min_npcs ({}) > max_npcs ({})",
site.site_type, site.min_npcs, site.max_npcs
);
warnings += 1;
}
}
if warnings > 0 {
process::exit(1);
}
}
Err(e) => {
eprintln!("Invalid ZoneSpec in {}:", args.file);
@@ -69,6 +90,14 @@ fn main() {
profile.speech.filler_words.len(),
profile.values.favored_traits.len()
);
let mut warnings = 0;
if profile.naming.given_names.is_empty() {
eprintln!(" WARNING: no given_names — generator will reject this");
warnings += 1;
}
if warnings > 0 {
process::exit(1);
}
}
Err(e) => {
eprintln!("Invalid CultureProfile in {}:", args.file);