code wiki / (root) / nx_inter_layer_coherence.nx

nx_inter_layer_coherence.nx

buildroot/runtime/nx_inter_layer_coherence.nx

14469 B363 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_inter_layer_coherence.nx -- cross-layer constraint checker. Per honest audit 2026-05-16: per-layer graders can each be S-class while the OVERALL composition is nonsense -- river flowing uphill, forest in a desert biome, town built on a cliff edge, castle in a swamp. This primitive grades the INTER-LAYER CONSTRAINTS that must hold for a coherent world. Four constraints scored individually + composed: 1. RIVER_DRAINAGE: rivers should flow downhill. For each polyline segment, sample heightmap at both endpoints; score = fraction of segments where h_end < h_start. 2. FOREST_BIOME_MATCH: forests should sit in biomes that support forests (BOREAL_FOREST / TEMPERATE_FOREST / TROPICAL_RAINFOREST or GRASSLAND). Score = fraction of forest positions in valid biomes. 3. TOWN_FLATNESS: towns should be on relatively flat ground. Sample local heightmap stddev within town radius; score = inverse of normalised stddev. 4. CASTLE_DEFENSIVE: castles benefit from elevation advantage. Score = fraction of castles whose centre elevation exceeds the mean elevation in a surrounding band of 2x radius. Each function returns Q14 [0, Q]; nx_inter_layer_coherence_grade composes them into a LAYER_VERDICT (kind = NX_LAYER_KIND_READABILITY, refine = NX_LAYER_REFINE_FIX_COHERENCE). genealogy_id: world_design_coherence_canon + leopold_wolman_1957_drainage + medieval_settlement_geography_canon lineage_id: nx_inter_layer_coherence_4axis_v1

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_layer_verdict.nx nx_inter_layer_coherence.nx

imports: nx_syscalls.nxnx_tier.nxnx_layer_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nx_coherence_river_drainag _ilc_h_at nx_coherence_forest_in_bio _ilc_h_at ↻ nx_coherence_town_on_flatl _ilc_h_at ↻ nx_coherence_castle_on_hig _ilc_h_at ↻ nx_inter_layer_coherence_g nx_layer_verdict_init nx_layer_verdict_finalize nx_layer_grade_from_axes nx_lv_axis_verdict

structs

none

consts

47const NX_ILC_Q: nx_int = 16384
50const NX_ILC_AXIS_RIVER: nx_int = 0
51const NX_ILC_AXIS_FOREST_BIOME: nx_int = 1
52const NX_ILC_AXIS_TOWN_FLAT: nx_int = 2
53const NX_ILC_AXIS_CASTLE_HIGH: nx_int = 3
55const NX_ILC_AXIS_COUNT: nx_int = 4

functions

58func _ilc_h_at(
74func nx_coherence_river_drainage(
called by 1: main calls 1: _ilc_h_at
109func nx_coherence_forest_in_biome(
called by 1: main calls 1: _ilc_h_at
134func nx_coherence_town_on_flatland(
called by 1: main calls 1: _ilc_h_at
205func nx_coherence_castle_on_high(
called by 1: main calls 1: _ilc_h_at
252func nx_inter_layer_coherence_grade(
267func main() -> i64