fix(simulation): PR #194 review round — rung-floor dependency direction, golden body coverage, doc honesty

Tyre's I1 (his ruling: the cutoff's job is Nyquist, a property of the
RUNG): MIN_WL_BANDS_M's District band now derives from 2*DISTRICT_M
directly, decoupled from OCTAVE_WAVELENGTHS_M[3] — a detail_scatter
retune can no longer silently redefine the Atlas rung floor. Direction-
agnostic const assert pins the coincidence so drift on either side
breaks the build for a deliberate human decision; golden_cutoffs_match_
the_scale_ladder now pins the District coupling too. I2: D-226
paraphrase replaced with cites to the T-1150 wire-contract note +
T-1162 refinement resolution (2), plus a self-found stale 2048m claim
fixed in the same comments. I4: golden extended with airless/dry
(ceiling_q==0 short-circuit) and volcanic-coast (ridged warp) body
rows via body_sweep_samples() — fixture regen verified 510 insertions,
0 deletions (existing rows byte-identical, purely appended). Q2 nit:
vegetation_invention module doc now states majority-preservation as
the coherence guarantee, not per-cell class stability (a boundary
cell's flip IS the clearing mechanism). Forward-contract for T-1156:
0x5EED_C0DE promoted to named WINDOW_RELIEF_SALT const. 158 focused
tests green; cargo check --tests clean.

Tickets: T-1162, T-1161

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 23:31:14 +02:00
co-authored by Claude Fable 5
parent a5b9c28e74
commit 3368891976
6 changed files with 751 additions and 76 deletions
@@ -253,5 +253,515 @@
"temperature_dc": -64,
"moisture_q": 43,
"vegetation": 1
},
{
"label": "airless_dry/coastal_a",
"rung": "district",
"wx_m": 2000000,
"wy_m": 1500000,
"min_wl_m": 4096,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 2,
"elev_q": 44,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_a",
"rung": "quarter",
"wx_m": 2000000,
"wy_m": 1500000,
"min_wl_m": 1024,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 2,
"elev_q": 48,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_a",
"rung": "region",
"wx_m": 2000000,
"wy_m": 1500000,
"min_wl_m": 0,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 0,
"elev_q": 41,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_b",
"rung": "district",
"wx_m": 2050000,
"wy_m": 1500000,
"min_wl_m": 4096,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 1,
"elev_q": 42,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_b",
"rung": "quarter",
"wx_m": 2050000,
"wy_m": 1500000,
"min_wl_m": 1024,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 2,
"elev_q": 39,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_b",
"rung": "region",
"wx_m": 2050000,
"wy_m": 1500000,
"min_wl_m": 0,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 0,
"elev_q": 41,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_c",
"rung": "district",
"wx_m": 2100000,
"wy_m": 1560000,
"min_wl_m": 4096,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 2,
"elev_q": 44,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_c",
"rung": "quarter",
"wx_m": 2100000,
"wy_m": 1560000,
"min_wl_m": 1024,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 2,
"elev_q": 45,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/coastal_c",
"rung": "region",
"wx_m": 2100000,
"wy_m": 1560000,
"min_wl_m": 0,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 0,
"elev_q": 41,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/inland",
"rung": "district",
"wx_m": 500000,
"wy_m": 3000000,
"min_wl_m": 4096,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 3,
"elev_q": 44,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/inland",
"rung": "quarter",
"wx_m": 500000,
"wy_m": 3000000,
"min_wl_m": 1024,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 4,
"elev_q": 39,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/inland",
"rung": "region",
"wx_m": 500000,
"wy_m": 3000000,
"min_wl_m": 0,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 0,
"elev_q": 42,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/high_lat",
"rung": "district",
"wx_m": 1200000,
"wy_m": 8500000,
"min_wl_m": 4096,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 2,
"elev_q": 76,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/high_lat",
"rung": "quarter",
"wx_m": 1200000,
"wy_m": 8500000,
"min_wl_m": 1024,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 3,
"elev_q": 79,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "airless_dry/high_lat",
"rung": "region",
"wx_m": 1200000,
"wy_m": 8500000,
"min_wl_m": 0,
"morphology": 8,
"tectonic": 0,
"glaciation": 0,
"precipitation": 0,
"slope_q": 0,
"elev_q": 77,
"ocean_fraction_q": 0,
"temperature_dc": -2147483648,
"moisture_q": 0,
"vegetation": 0
},
{
"label": "volcanic_coast/coastal_a",
"rung": "district",
"wx_m": 2000000,
"wy_m": 1500000,
"min_wl_m": 4096,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 3,
"elev_q": 25,
"ocean_fraction_q": 0,
"temperature_dc": 497,
"moisture_q": 60,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_a",
"rung": "quarter",
"wx_m": 2000000,
"wy_m": 1500000,
"min_wl_m": 1024,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 6,
"elev_q": 13,
"ocean_fraction_q": 0,
"temperature_dc": 560,
"moisture_q": 62,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_a",
"rung": "region",
"wx_m": 2000000,
"wy_m": 1500000,
"min_wl_m": 0,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 0,
"elev_q": 28,
"ocean_fraction_q": 0,
"temperature_dc": 482,
"moisture_q": 59,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_b",
"rung": "district",
"wx_m": 2050000,
"wy_m": 1500000,
"min_wl_m": 4096,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 4,
"elev_q": 34,
"ocean_fraction_q": 0,
"temperature_dc": 456,
"moisture_q": 58,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_b",
"rung": "quarter",
"wx_m": 2050000,
"wy_m": 1500000,
"min_wl_m": 1024,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 6,
"elev_q": 24,
"ocean_fraction_q": 0,
"temperature_dc": 508,
"moisture_q": 60,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_b",
"rung": "region",
"wx_m": 2050000,
"wy_m": 1500000,
"min_wl_m": 0,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 0,
"elev_q": 28,
"ocean_fraction_q": 0,
"temperature_dc": 487,
"moisture_q": 59,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_c",
"rung": "district",
"wx_m": 2100000,
"wy_m": 1560000,
"min_wl_m": 4096,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 2,
"elev_q": 28,
"ocean_fraction_q": 0,
"temperature_dc": 486,
"moisture_q": 59,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_c",
"rung": "quarter",
"wx_m": 2100000,
"wy_m": 1560000,
"min_wl_m": 1024,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 4,
"elev_q": 33,
"ocean_fraction_q": 0,
"temperature_dc": 460,
"moisture_q": 59,
"vegetation": 3
},
{
"label": "volcanic_coast/coastal_c",
"rung": "region",
"wx_m": 2100000,
"wy_m": 1560000,
"min_wl_m": 0,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 3,
"slope_q": 0,
"elev_q": 29,
"ocean_fraction_q": 0,
"temperature_dc": 481,
"moisture_q": 59,
"vegetation": 3
},
{
"label": "volcanic_coast/inland",
"rung": "district",
"wx_m": 500000,
"wy_m": 3000000,
"min_wl_m": 4096,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 2,
"slope_q": 3,
"elev_q": 24,
"ocean_fraction_q": 0,
"temperature_dc": 565,
"moisture_q": 49,
"vegetation": 3
},
{
"label": "volcanic_coast/inland",
"rung": "quarter",
"wx_m": 500000,
"wy_m": 3000000,
"min_wl_m": 1024,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 2,
"slope_q": 4,
"elev_q": 21,
"ocean_fraction_q": 0,
"temperature_dc": 581,
"moisture_q": 49,
"vegetation": 3
},
{
"label": "volcanic_coast/inland",
"rung": "region",
"wx_m": 500000,
"wy_m": 3000000,
"min_wl_m": 0,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 2,
"slope_q": 0,
"elev_q": 23,
"ocean_fraction_q": 0,
"temperature_dc": 571,
"moisture_q": 49,
"vegetation": 3
},
{
"label": "volcanic_coast/high_lat",
"rung": "district",
"wx_m": 1200000,
"wy_m": 8500000,
"min_wl_m": 4096,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 2,
"slope_q": 3,
"elev_q": 68,
"ocean_fraction_q": 0,
"temperature_dc": 545,
"moisture_q": 29,
"vegetation": 2
},
{
"label": "volcanic_coast/high_lat",
"rung": "quarter",
"wx_m": 1200000,
"wy_m": 8500000,
"min_wl_m": 1024,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 2,
"slope_q": 4,
"elev_q": 65,
"ocean_fraction_q": 0,
"temperature_dc": 561,
"moisture_q": 30,
"vegetation": 2
},
{
"label": "volcanic_coast/high_lat",
"rung": "region",
"wx_m": 1200000,
"wy_m": 8500000,
"min_wl_m": 0,
"morphology": 15,
"tectonic": 2,
"glaciation": 0,
"precipitation": 2,
"slope_q": 0,
"elev_q": 66,
"ocean_fraction_q": 0,
"temperature_dc": 555,
"moisture_q": 30,
"vegetation": 2
}
]
+138 -25
View File
@@ -18,6 +18,16 @@
//! quantization will change this golden's values — regenerate deliberately
//! (per the asset-pipeline discipline: source changes, not hand-edits).
//!
//! **Body coverage (Tyre, PR #194 review I4):** the sweep runs against THREE
//! bodies, not one — the original temperate/ocean/breathable body (unchanged
//! from the initial T-1162 landing), plus an airless/dry body (exercises
//! `vegetation_invention::VegetationEnvelope`'s `ceiling_q == 0` short
//! circuit at the full derivation-stack level) and a volcanic/high-tectonic
//! coastal body (exercises the ridged-warp/wide-`scatter_floor` branch of
//! `coast_invention`). The two new bodies' rows are APPENDED after the
//! original body's rows (never interleaved), so the original rows stay
//! byte-identical across the I4 regen — see `body_sweep_samples`'s doc.
//!
//! Run: `cargo test --test window_derivation_golden`
//! Regenerate: `UPDATE_GOLDEN=1 cargo test --test window_derivation_golden`
@@ -36,6 +46,14 @@ const GOLDEN_FILE: &str = "tests/golden/window_derivation_golden.json";
/// Compact representation of a `DistrictProfile` sample for golden pinning.
/// Integer-discriminant fields only (D-010) — no float equality flakiness.
///
/// **No `body` field (Tyre, PR #194 I4 constraint):** the two new body rows
/// (I4) distinguish themselves via the `label` field's prefix instead of a
/// new struct field — adding a field here would change the JSON shape of
/// EVERY existing row (not just the new ones), which fails I4's explicit
/// "existing rows must stay byte-identical" requirement. `label` was always
/// a free-form string, so `"golden_body/coastal_a"` vs `"airless_dry/coastal_a"`
/// costs nothing structurally and keeps the diff a pure append.
#[derive(Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone)]
struct GoldenSample {
label: String,
@@ -97,6 +115,43 @@ fn sample_params() -> BodyParams {
}
}
/// I4 (Tyre, PR #194 review): airless/dry body params — exercises
/// `vegetation_invention::VegetationEnvelope`'s `ceiling_q == 0` short
/// circuit (no water, no atmosphere → zero patchiness swing, per
/// `envelope_airless_or_dry_body_has_zero_ceiling`'s unit-level proof) at
/// the FULL derivation-stack level, which the unit test alone doesn't pin.
/// Also airless (`atmosphere: "none"`) so `temperature_c`/`vegetation_class`
/// take the `None`/`Absent` branches — a body-envelope regression that
/// invented forest on a bone-dry world would show up here as a NEW
/// non-Barren/non-Absent vegetation discriminant in the golden diff.
fn airless_dry_params() -> BodyParams {
BodyParams {
hydrosphere: Some("none".into()),
atmosphere: Some("none".into()),
planet_class: Some("arid".into()),
body_radius_km: Some(3_390.0), // Mars-scale, deliberately distinct from the wet body
..Default::default()
}
}
/// I4 (Tyre, PR #194 review): volcanic/high-tectonic coastal body params —
/// exercises `coast_invention`'s ridged-warp + wide-`scatter_floor` branch
/// (`TectonicClass::Volcanic` → `tectonic_energy` near its ceiling in
/// `body_coast_envelope`, driving up `roughness`/`warp_amplitude_px`/
/// `scatter_floor` per that function's doc) — the coast-crinkle branch most
/// likely to visibly differ from the temperate body's gentler warp, and thus
/// the branch most likely to silently regress without dedicated coverage.
fn volcanic_coast_params() -> BodyParams {
BodyParams {
hydrosphere: Some("ocean".into()),
atmosphere: Some("breathable".into()),
planet_class: Some("volcanic".into()),
tectonic_activity: Some("volcanic".into()),
body_radius_km: Some(6_000.0),
..Default::default()
}
}
/// Fixed sweep positions (world metres from origin) — a handful of points
/// spanning a coastal stretch (per the heightmap's ripple) plus a couple of
/// clearly inland/high-latitude points, so the golden exercises coast warp,
@@ -165,53 +220,105 @@ const DISTRICT_MIN_WL_M: f64 = 4_096.0;
/// new T-1162 entry — Quarter's own Nyquist floor, `2 * QUARTER_M`).
const QUARTER_MIN_WL_M: f64 = 1_024.0;
/// Build the full fixed sweep: every position × the three rung cutoffs
/// (District / Quarter use their REAL production `MIN_WL_BANDS_M` values /
/// Region via `derive_orbital_at_metres`, which takes no cutoff parameter —
/// see its own doc on why).
fn golden_samples() -> Vec<GoldenSample> {
let hm = sample_hm();
let ta = sample_ta(&hm);
let params = sample_params();
let climate = ClimateConstants::default();
let seed = SeedChain::root(0xC0FFEE_u64).derive(SeedDomain::Body, 7);
let body_id = "golden_body";
/// Run the fixed sweep (every position × the three rung cutoffs — District /
/// Quarter use their REAL production `MIN_WL_BANDS_M` values / Region via
/// `derive_orbital_at_metres`, which takes no cutoff parameter — see its own
/// doc on why) for ONE body. Extracted (Tyre, PR #194 I4) so multiple bodies
/// can share the same sweep logic; `label_prefix` (empty for the original
/// body, non-empty for the I4 additions) is prepended to each row's `label`
/// so multi-body output stays distinguishable without a new struct field
/// (see [`GoldenSample`]'s doc on why no `body` field was added).
#[allow(clippy::too_many_arguments)]
fn body_sweep_samples(
label_prefix: &str,
seed: SeedChain,
body_id: &str,
params: &BodyParams,
ta: &TerrainAnalysis,
climate: &ClimateConstants,
) -> Vec<GoldenSample> {
let mut out = Vec::new();
for (label, wx, wy) in sweep_positions() {
let label = format!("{label_prefix}{label}");
out.push(derive_golden_sample(
label,
&label,
"district",
seed,
body_id,
&params,
&ta,
&climate,
params,
ta,
climate,
wx,
wy,
DISTRICT_MIN_WL_M,
false,
));
out.push(derive_golden_sample(
label,
&label,
"quarter",
seed,
body_id,
&params,
&ta,
&climate,
params,
ta,
climate,
wx,
wy,
QUARTER_MIN_WL_M,
false,
));
out.push(derive_golden_sample(
label, "region", seed, body_id, &params, &ta, &climate, wx, wy, 0.0, true,
&label, "region", seed, body_id, params, ta, climate, wx, wy, 0.0, true,
));
}
out
}
/// Build the full golden sample set: the ORIGINAL temperate/ocean/breathable
/// body's sweep first (byte-identical inputs to the pre-I4 `golden_samples`
/// — same seed, same `body_id`, same unprefixed labels, so its rows are
/// byte-identical in the regenerated fixture), THEN the two I4 body rows
/// appended after (never interleaved) so the diff against the pre-I4 golden
/// is a pure append, not a reshuffle.
fn golden_samples() -> Vec<GoldenSample> {
let hm = sample_hm();
let ta = sample_ta(&hm);
let climate = ClimateConstants::default();
let mut out = Vec::new();
// Original body — UNCHANGED inputs from pre-I4 (T-1162 initial landing).
out.extend(body_sweep_samples(
"",
SeedChain::root(0xC0FFEE_u64).derive(SeedDomain::Body, 7),
"golden_body",
&sample_params(),
&ta,
&climate,
));
// I4 addition 1: airless/dry — ceiling_q == 0 vegetation short-circuit.
out.extend(body_sweep_samples(
"airless_dry/",
SeedChain::root(0xC0FFEE_u64).derive(SeedDomain::Body, 8),
"golden_body_airless_dry",
&airless_dry_params(),
&ta,
&climate,
));
// I4 addition 2: volcanic/high-tectonic coast — ridged warp, wide scatter_floor.
out.extend(body_sweep_samples(
"volcanic_coast/",
SeedChain::root(0xC0FFEE_u64).derive(SeedDomain::Body, 9),
"golden_body_volcanic_coast",
&volcanic_coast_params(),
&ta,
&climate,
));
out
}
#[test]
fn window_derivation_golden_regression() {
let manifest = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@@ -294,12 +401,18 @@ fn quarter_and_district_rungs_diverge_at_the_same_position() {
);
}
/// `scale::DISTRICT_M` / `scale::QUARTER_M` sanity — documents WHY 2,048/1,024
/// are the cutoffs used above (District's own spacing; Quarter's own Nyquist
/// floor, `2 × QUARTER_M`), so a future scale-ladder change surfaces here.
/// `scale::DISTRICT_M` / `scale::QUARTER_M` sanity — documents WHY
/// `DISTRICT_MIN_WL_M`/`QUARTER_MIN_WL_M` are the cutoffs used above (each
/// rung's own Nyquist floor, `2 × <rung's spacing>`), so a future
/// scale-ladder change surfaces here. Pins BOTH rungs' coupling (Tyre, PR
/// #194 I1 — District's coupling was previously unpinned; only Quarter's
/// `2 × QUARTER_M` was checked) — this mirrors
/// `layer_proxy::MIN_WL_BANDS_M`'s own direct `2 × DISTRICT_M` / `2 ×
/// QUARTER_M` derivation, not `detail_scatter::OCTAVE_WAVELENGTHS_M`.
#[test]
fn golden_cutoffs_match_the_scale_ladder() {
assert_eq!(scale::DISTRICT_M, 2_048);
assert_eq!(scale::QUARTER_M, 512);
assert_eq!(2 * scale::QUARTER_M, 1_024);
assert_eq!(2 * scale::DISTRICT_M, DISTRICT_MIN_WL_M as i32);
assert_eq!(2 * scale::QUARTER_M, QUARTER_MIN_WL_M as i32);
}