nx_water_erosion_gate.nx
buildroot/runtime/nx_water_erosion_gate.nx
about
nx_water_erosion_gate.nx -- GATE for the Mei 2007 hydraulic erosion pipeline (PG18, procgen.plan, 2026-08-24).
WHY THIS GATE EXISTS: nx_water_erosion.nx implements all seven Mei 2007 stages and its own header names
`bug-tape-flow-direction-mass-imbalance` as the hazard -- yet its self-test never once summed the water.
Its T9 comment read "check no NaN/overflow" over a range test. A physics organ whose defining invariant is
stated in prose and asserted nowhere is the vacuous-tooth shape: green forever, proving nothing.
THE INVARIANTS, DERIVED FROM THE SOURCE, NOT ASSUMED:
RAIN sum(d) after add_rain == sum(d) before + n*rain. EXACT: pure per-cell addition.
FLOW sum(d) after flow+update == sum(d) before, within a bound. Every outflow is a neighbour's
inflow and edges emit zero, so the true sum of (in - out) is zero; the per-cell integer
division `(in - out) * dt / q` truncates toward zero once per cell, so the bound is n units
of Q14 per stage. Printed beside the measurement so it can be tightened on evidence.
EROSION sum(h) + sum(s) after terrain_update == before. EXACT, tolerance ZERO: erode is
`h - delta, s + delta` and deposit is `h + delta, s - delta` -- sediment is lifted from the
bed and set back down and not one unit is created. This is the claim float engines cannot
make and the reason an integer erosion sim is a Houdini-exceed, not a Houdini-parity.
EVAPORATE sum(d) after <= before, every cell >= 0.
TRANSPORT is semi-Lagrangian bilinear resampling and does NOT conserve sediment exactly by
construction (Mei 2007 section 3.5 accepts this). It is measured and PRINTED here, never
asserted, so nobody reads a green as a conservation proof it is not.
The original nine self-test teeth are migrated onto gv_check below so the estate loses nothing; the
hand-rolled `__syscall(93, N)` exits they used could not carry a third state and never printed a value.
Fixture: a seeded slope in caller-owned mmap, so the gate never touches a production plane.
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_tier.nxnx_gate_verdict.nxnx_water_erosion.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 35 | const WE_W: i64 = 16 |
| 36 | const WE_H: i64 = 16 |
| 39 | const WE_STEP_M: i64 = 100 |
| 41 | const WE_RAIN_M: i64 = 5 |
| 42 | const WE_TICKS: i64 = 10 |
functions
| 44 | func we_sum_field(state: *i64, n: i64, off: i64) -> i64 |
| 51 | func we_min_field(state: *i64, n: i64, off: i64) -> i64 |
| 58 | func we_absdiff(a: i64, b: i64) -> i64 { if a > b { return a - b } return b - a } |
| 62 | func we_hs_drift(state: *i64, n: i64, before: i64) -> i64 |
| 67 | func we_seed_slope(state: *i64, w: i64, h: i64, q: i64) -> i64 |
| 88 | func main() -> i64 |