TripoFisch.
← SturgeonNext: History & Lineage
Sturgeon Deep Dive · Architecture · How it is built and how to change it

Architecture.

How Sturgeon is put together — the layers, the seams between them, and the regions, reaches and blocks every model is built from — and, above all, where you can change the math and do it your own way: in the browser with no code, in a region’s settings, or as a plug-in of your own, judged against the live model.

The architecture belongs to no one place. One engine runs every region, and a region is data. Three run today — the San Francisco Bay–Delta, the Rhine–Meuse delta in the Netherlands, and a deliberately plain test river, the Colorado below Glen Canyon Dam — and on this page they appear only as examples.

The layers, and what each owns

Everything lives in one repository, FischerDeltaModelReturns ↗. Each layer has one job, and the published files are the only thing that passes from the model runner to your screen.

Level 0: the whole systemPublic data sources, of a few kinds, feed the model runner on the server (container 705): gauges (for example USGS and CDEC in the Bay–Delta, Rijkswaterstaat in the Rhine–Meuse), forecasts (the National Weather Service and California’s River Forecast Center; Rijkswaterstaat’s own), ocean models (NOAA’s SFBOFS and WCOFS), operations (dam releases, gates, pumps), and satellites and maps (SWOT, the National Hydrography Dataset, the Dutch PDOK). On the runner: adapters into a local store, the model runner, which runs each region in turn, and a what-if worker. The runner publishes index.json and per-reach, per-day .fdf files. In the browser the map viewer draws them and its worker moves parcels; the validation page and the model editor read them too. GitHub holds the code that is deployed to the runner. The model editor can send a what-if to the runner with the owner’s key only, or download a proposed change as a patch for a pull request.L0 · System›L1 · Layers›L2 · Region›L3 · Block›L4 · Lawyou are hereData sourcesby kind, for example:GaugesUSGS, CDEC;RijkswaterstaatForecastsNWS, CNRFC;RijkswaterstaatOcean modelsNOAA SFBOFS,WCOFSOperationsdams, gates, pumpsSatellites, mapsSWOT, NHD; PDOKTHE RUNNER · CT 705Adapters → storeSI units, each value’s sourceModel runnercycle.sh, each region inturn: blocks, plug-ins,Rust maths; the ledgerzoom ▸ L1What-if workerwhatif.py: one at a time,beside the live forecastPublishedindex.jsonper reach,per day:.fdf fileswhatif/<id>/YOUR BROWSERMap viewerdraws; its workermoves parcels(WebAssembly)ValidationModel editorswap a law,change a value,add an eventGitHub repositorycode, CI checks, pull requeststripofisch.comthese reading pagesdeployed to the runnerowner’s key onlyproposed change → patchcomputesdata, filesoutside the modela checkLevel 0: the whole systemPublic data sources, of a few kinds, feed the model runner on the server (container 705): gauges (for example USGS and CDEC in the Bay–Delta, Rijkswaterstaat in the Rhine–Meuse), forecasts (the National Weather Service and California’s River Forecast Center; Rijkswaterstaat’s own), ocean models (NOAA’s SFBOFS and WCOFS), operations (dam releases, gates, pumps), and satellites and maps (SWOT, the National Hydrography Dataset, the Dutch PDOK). On the runner: adapters into a local store, the model runner, which runs each region in turn, and a what-if worker. The runner publishes index.json and per-reach, per-day .fdf files. In the browser the map viewer draws them and its worker moves parcels; the validation page and the model editor read them too. GitHub holds the code that is deployed to the runner. The model editor can send a what-if to the runner with the owner’s key only, or download a proposed change as a patch for a pull request.L0SystemL1LayersL2RegionL3BlockL4LawData sources, by kind, for example:gauges: USGS, CDEC; Rijkswaterstaatforecasts: NWS, CNRFC; Rijkswaterstaatocean models: NOAA SFBOFS, WCOFSoperations: dams, gates, pumpssatellites, maps: SWOT, NHD; PDOKTHE RUNNER · CT 705Adapters → storeSI units, each value’s sourceModel runnercycle.sh, each region in turn: blocks,plug-ins, Rust maths; the ledgerzoom ▸ L1What-if workerwhatif.py, beside the live forecastpublishPublished filesindex.json · .fdf per reach per daywhatif/<id>/YOUR BROWSERMap viewer and validationthe map draws; a worker moves parcelsModel editorswap a law, change a value, an eventowner’s key onlyGitHubcode, CI, PRstripofisch.comreading pagescomputesdata, filesoutside the modela check
Level 0, the whole system. Data in on the left, the screen on the right; the published files are the only thing that passes between. The sources are shown by kind; each region picks its own of each kind, and the names are examples from the Bay–Delta and the Rhine–Meuse. The teal loop is the what-if: only the owner’s key sends one to the runner. The badge marks the box that the next level opens.
Level 1: the software layersOn the runner, in Python: the regions’ data files, the adapters and the store, the runner and its plug-ins, and fdmr-py, the Rust maths bound for Python. The runner publishes index.json and .fdf files in the format of fdmr-format. In the browser: the viewer, written in Svelte with MapLibre, which only draws, and its worker, which runs fdmr-wasm, the same Rust maths built to WebAssembly. The maths, fdmr-math and fdmr-compute, are written once and run in both places. check_seams.py keeps each module to what seams.toml lets it use and keeps place names out of engine code.L0 · System›L1 · Layers›L2 · Region›L3 · Block›L4 · Lawyou are hereON THE RUNNER · PYTHONRegions: data onlyregions/<id>/*.tomlAdaptersone perdata serviceStorevalue, sourceand timeRunner and plug-insfdmr_runner · fdmr_pluginsthe cycle; blocks; registry.pyzoom ▸ L2fdmr-pyRust, bound for PythonPublishedfdmr-formatindex.jsonone .fdf fileper reachper dayversionedIN YOUR BROWSERViewerui: Svelte and MapLibrethe map only drawsWorkermoves parcels on thepublished flowsfdmr-wasmRust, built to WebAssemblyThe maths, written once in Rustfdmr-math the equations, nothing about any placefdmr-compute parcels and flows on the fieldsrun hereand herecheck_seams.py: each module uses only what seams.toml lists; engine code names no place; regions/ holds no codecomputesdata, filesoutside the modela checkLevel 1: the software layersOn the runner, in Python: the regions’ data files, the adapters and the store, the runner and its plug-ins, and fdmr-py, the Rust maths bound for Python. The runner publishes index.json and .fdf files in the format of fdmr-format. In the browser: the viewer, written in Svelte with MapLibre, which only draws, and its worker, which runs fdmr-wasm, the same Rust maths built to WebAssembly. The maths, fdmr-math and fdmr-compute, are written once and run in both places. check_seams.py keeps each module to what seams.toml lets it use and keeps place names out of engine code.L0SystemL1LayersL2RegionL3BlockL4LawRegions: data onlyregions/<id>/*.tomlAdaptersone per serviceStorevalue, source, timeRunner and plug-insfdmr_runner · fdmr_pluginsthe cycle; blocks; registry.pyzoom ▸ L2fdmr-py: Rust bound for PythonThe maths, written once in Rustfdmr-math: the equationsfdmr-compute: parcels, flowsfdmr-wasm: built to WebAssemblyViewer and its workerSvelte, MapLibre: the map only drawspublished: index.json, .fdfcheck_seams.pyeach module uses only what seams.tomllists; engine code names no placecomputesdata, filesoutside the modela check
Level 1, the layers. The Rust maths are written once and built twice: for Python, where the runner calls them, and to WebAssembly, where your browser’s worker runs the same code. The published files are the one interface between the two sides.

The seams

seams.toml ↗ lists every module and what it may use, and check_seams.py ↗ fails the build if any module reaches past its list, if a data-only folder holds code, or if engine code names a place. That last rule is the code’s own statement that the architecture belongs to no region. Every region lists its own guard words in its region.toml, and none of them may appear anywhere in the engine: for example Sacramento, Chipps and Golden Gate in the Bay–Delta; Lobith, Waal and Nieuwe Waterweg in the Rhine–Meuse; Lees Ferry and Glen Canyon in the test region. Data sources are named only through their adapters or the region’s own files. Each new region adds its own words, so the check grows stricter with every region added.

A region: reaches, model kinds and handoffs

A region is data: regions/<id>/region.toml ↗ and the files beside it. It lists the region’s reaches, and each reach is of a model kind, the code’s name for a kind of water and the model that runs it. The kinds today are the register’s: river-routing, one-way rivers between gauges, often below a dam; 1d-tidal-network, tidal rivers and branching channels; 2d-field, a bay or lagoon on a mesh; coastal-field, the open coast and shelf past a bay; and canal-network, canals fed by a network’s exports. The specification sketches more to come, such as pools and flooded areas, and every kind writes the same published format.

Reaches are joined by handoffs (the region’s [[handoffs]]), each of a kind: at a node, a river’s parcels enter a network’s channel at a junction; on a reach, a tributary enters another river some way along it; split by flow, a river divides and each branch takes its measured share; along a line, a mesh’s edge cuts a network’s channels, both ways; shared mesh, two meshes meet edge for edge; and at an export, what a network’s pumps take enters a canal. The published format carries every handoff, so the browser hands parcels across them without knowing which region it is in.

Level 2: a region as a chain of reachesThe general chain: a region is a chain of reaches, each of a model kind, joined by handoffs. River-routing reaches (one-way, gauged rivers; flow always ours) hand their water to a 1d-tidal-network reach at a node; a river may also hand to another river, on that reach or split by measured flow. The tidal network (flow ours, or an external model) feeds canal-network reaches at an export and meets a 2d-field reach (a bay on a mesh, its flow a forecast from outside) along a line, both ways; the bay field and a coastal-field reach (the open coast and shelf) share their mesh edges. Wherever the chain stops, the sea is a boundary, and a region uses only the kinds its water needs. Worked examples. The Bay–Delta: fifteen river reaches from the dams, at nodes into the Delta, a tidal network driven by DWR’s DSM2 with our own solver beside it as a shadow; the export canals; the Bay from NOAA’s SFBOFS; the coast from NOAA’s WCOFS; the Pacific. The Rhine–Meuse: six river reaches; the Bovenrijn from Lobith splits by flow into the Waal and the Pannerdensch Kanaal, which splits into the Nederrijn and the IJssel; the Waal, the Nederrijn and the Maas enter the tidal rivers at nodes 9, 6 and 14; the tidal rivers run on our own solver on a network built from open data, and meet the North Sea’s tide. The plain test region: one river-routing reach, the Colorado below Glen Canyon Dam, with four USGS gauges and no tide, no bay and no external model.L0 · System›L1 · Layers›L2 · Region›L3 · Block›L4 · Lawyou are hereTHE GENERAL CHAIN: REACHES, EACH OF A MODEL KIND, JOINED BY HANDOFFSRiversriver-routingone-way rivers,gauged, oftenbelow a damflow: oursTidal network1d-tidal-networktidal rivers andbranching channelsflow: ours, or anexternal modelBay field2d-fielda bay or lagoonon a meshflow: a forecastfrom outsideCoast fieldcoastal-fieldthe open coastand the shelfflow: a forecastfrom outsideat anodealong alinesharedmeshon a reach, orsplit by flowAnother riverriver-routingat anexportCanalscanal-networkthe sea: a boundaryA region uses only the kinds its water needs,joined in the order the water flows; wherever itschain stops, the sea is a boundary.WORKED EXAMPLES: THE SAME CHAIN IN TWO REGIONSBAY–DELTAsf-bay-deltaRHINE–MEUSErhine-meuseRivers: 15 reaches, from the damsriver-routingSacramento, Feather, San Joaquin and the restat a nodeDelta1d-tidal-networkflow: DSM2, externalours beside it: the shadowCanalscanal-networkfed by exportsalong a lineBay2d-fieldflow: NOAA’s SFBOFS, externalshared meshCoastcoastal-fieldflow: NOAA’s WCOFS, externalthe Pacific: a boundaryRivers: 6 reaches, eachriver-routingBovenrijnfrom Lobithsplit by flowWaalzoom ▸ L3Pannerdensch K.split by flowNederrijnIJsselKetelmeerMaasnode 14node 9node 6at a nodeTidal rivers1d-tidal-networkflow: ours, a network built from open datathe North Sea’s tide: a boundaryAND THE PLAIN TEST REGIONtest-coloradoColorado River below Glen Canyon Damriver-routingone reach, four USGS gaugesNo tide, no bay, no external model: if the engineneeds changing to run it, something regional hasleaked in.computesdata, filesoutside the modela checkLevel 2: a region as a chain of reachesThe general chain: a region is a chain of reaches, each of a model kind, joined by handoffs. River-routing reaches (one-way, gauged rivers; flow always ours) hand their water to a 1d-tidal-network reach at a node; a river may also hand to another river, on that reach or split by measured flow. The tidal network (flow ours, or an external model) feeds canal-network reaches at an export and meets a 2d-field reach (a bay on a mesh, its flow a forecast from outside) along a line, both ways; the bay field and a coastal-field reach (the open coast and shelf) share their mesh edges. Wherever the chain stops, the sea is a boundary, and a region uses only the kinds its water needs. Worked examples. The Bay–Delta: fifteen river reaches from the dams, at nodes into the Delta, a tidal network driven by DWR’s DSM2 with our own solver beside it as a shadow; the export canals; the Bay from NOAA’s SFBOFS; the coast from NOAA’s WCOFS; the Pacific. The Rhine–Meuse: six river reaches; the Bovenrijn from Lobith splits by flow into the Waal and the Pannerdensch Kanaal, which splits into the Nederrijn and the IJssel; the Waal, the Nederrijn and the Maas enter the tidal rivers at nodes 9, 6 and 14; the tidal rivers run on our own solver on a network built from open data, and meet the North Sea’s tide. The plain test region: one river-routing reach, the Colorado below Glen Canyon Dam, with four USGS gauges and no tide, no bay and no external model.L0SystemL1LayersL2RegionL3BlockL4LawTHE GENERAL CHAINRiversriver-routingone-way rivers, gaugedflow: oursA riveron a reach, orsplit by flowat a nodeTidal network1d-tidal-networkbranching tidal channelsflow: ours, or anexternal modelCanalscanal-networkat an exportalong a lineBay field2d-fielda bay or lagoon, on a meshflow: a forecast from outsideshared meshA region usesonly the kindsits water needs,in the orderthe water flows.Coast fieldcoastal-fieldthe open coast and shelfflow: a forecast from outsidethe sea: a boundaryEXAMPLE: BAY–DELTARivers: 15 reaches, from the damsriver-routingSacramento, Feather, San Joaquin and the restat a nodeDelta1d-tidal-networkflow: DSM2, externalours beside it: the shadowCanalscanal-networkfed by exportsalong a lineBay2d-fieldflow: NOAA’s SFBOFS, externalshared meshCoastcoastal-fieldflow: NOAA’s WCOFS, externalthe Pacific: a boundaryEXAMPLE: RHINE–MEUSERivers: 6 reaches, eachriver-routingBovenrijnfrom Lobithsplit by flowWaalzoom ▸ L3Pannerdensch K.split by flowNederrijnIJsselKetelmeerMaasnode 14node 9node 6at a nodeTidal rivers1d-tidal-networkflow: ours, a network built from open datathe North Sea’s tide: a boundaryEXAMPLE: THE TEST REGIONColorado River below Glen Canyon Damriver-routingone reach, four USGS gaugesNo tide, no bay, no external model: if theengine needs changing to run it, somethingregional has leaked in.computesdata, filesoutside the modela check
Level 2, a region as a chain of reaches. The top is the architecture: every reach is one of a few model kinds (kind in region.toml), and every join between two reaches is one of a few kinds of handoff (the [[handoffs]]). Below it, the regions running today, as examples of the same chain: each uses only the kinds its water needs. The Waal is opened at the next level.

For example, the Bay–Delta’s chain uses every kind: fifteen rivers into the Delta’s network at nodes, the Delta into its export canals and, along a line, into the Bay, and the Bay into the coast by a shared mesh. The Rhine–Meuse uses two: six rivers, which split by measured flow at the Pannerdensche Kop and the IJsselkop, into a tidal network at three nodes, which meets the North Sea’s tide as a boundary. The test region uses one: a single river.

Where a reach’s flow comes from: our solver, or an external model

Within a kind, the source of the flow can be swapped. A reach names it in its region’s data (flow_source, or its choice of the kind’s flow maths), and our own solvers and established external models stand side by side in the register as that part’s implementations, each external one with the checks against stations it is judged by in every cycle. So a reach may be driven by an established external model, with ours run beside it as a shadow until it matches. (In the code, a driver is how a source’s inputs reach our solver: one reads an existing model’s own input files, another builds a network from open data.)

Blocks and the block contract

Inside a region, the model is built from blocks, one for each kind of water: a river reach, a tidal channel network, a pool, a gate, a bay, the shelf. Each block holds its own physics, and blocks meet at ports. The block contract, contract.md ↗, fixes what crosses a port, so any two blocks can be joined without either knowing how the other works inside — and someone can replace one block, or one law inside it, with their own while the rest still fits. The contract is the same for every block in every region.

Level 3: one block and its contractAn example block, the Waal in the Rhine–Meuse, described in regions/rhine-meuse/blocks/waal.toml; every block in every region has the same parts. The Waal is a river reach in one dimension, contract version 0.1, with one named law per process: flow gauge-blend-lag-route, channel wide-channel-uniform-flow, travel time measured-release-waves, dispersion cross-channel-shear, dead-zone storage groyne-field-storage, particles advection-random-walk, decay first-order. It has three ports: from the Bovenrijn block and from the gauge at Millingen, each taking flow; and its mouth into the tidal network at node 9, taking level, carrying discharge and parcels. Its dispersion law can be swapped for another registered one, fischer-longitudinal or your own, and its ports and its neighbours stay the same. check_contract.py checks that every law is registered and is the region’s choice, that every value has a source and that joined ports agree; check_seams.py keeps place names out of engine code.L0 · System›L1 · Layers›L2 · Region›L3 · Block›L4 · Lawyou are hereAN EXAMPLE: THE WAAL,IN THE RHINE–MEUSETHE PARTS ARE THESAME IN EVERY BLOCKregions/rhine-meuse/blocks/waal.tomlExample block: waaltype river-reach · 1D · contract 0.1LAWS, ONE PER PROCESSflow= gauge-blend-lag-routechannel= wide-channel-uniform-flowtravel-time= measured-release-wavesdispersion= cross-channel-sheardead-zone-storage= groyne-field-storageparticles= advection-random-walkdecay= first-orderzoom ▸ L4each value with its source: ref:visser2000 …Bovenrijnblock, unchangedGaugeMillingenTidal riversblock, unchangedport bovenrijntakes-flowdischarge, parcelsport releasetakes-flow · dischargeport mouth → node 9takes-leveldischarge, parcelsRegistered dispersion laws (registry.py)cross-channel-shearthe Waal’s choice todayfischer-longitudinalFischer’s Kyour-lawregistered, citedswap one law: the ports, and so the neighbours, stay the samecheck_contract.pylaws registered and the region’s; values sourced; ports agreecheck_seams.pyno place names in engine codecomputesdata, filesoutside the modela checkLevel 3: one block and its contractAn example block, the Waal in the Rhine–Meuse, described in regions/rhine-meuse/blocks/waal.toml; every block in every region has the same parts. The Waal is a river reach in one dimension, contract version 0.1, with one named law per process: flow gauge-blend-lag-route, channel wide-channel-uniform-flow, travel time measured-release-waves, dispersion cross-channel-shear, dead-zone storage groyne-field-storage, particles advection-random-walk, decay first-order. It has three ports: from the Bovenrijn block and from the gauge at Millingen, each taking flow; and its mouth into the tidal network at node 9, taking level, carrying discharge and parcels. Its dispersion law can be swapped for another registered one, fischer-longitudinal or your own, and its ports and its neighbours stay the same. check_contract.py checks that every law is registered and is the region’s choice, that every value has a source and that joined ports agree; check_seams.py keeps place names out of engine code.L0SystemL1LayersL2RegionL3BlockL4LawAN EXAMPLE BLOCK: THE WAAL, RHINE–MEUSEregions/rhine-meuse/blocks/waal.tomlBovenrijntakes-flowGauge, Millingentakes-flowExample block: waalriver-reach · 1D · contract 0.1flowgauge-blend-lag-routechannelwide-channel-uniform-flowtravel-timemeasured-release-wavesdispersioncross-channel-sheardead-zonegroyne-field-storageparticlesadvection-random-walkdecayfirst-orderzoom ▸ L4each value with its sourceTidal rivers, node 9port mouth: takes-levelRegistered dispersion lawscross-channel-shear (today)fischer-longitudinalyour-lawswap one law; the ports stay the samecheck_contract.pylaws registered; values sourced;joined ports agreecheck_seams.pyno place names in engine codecomputesdata, filesoutside the modela check
Level 3, one block. The example is the Waal, a river reach in the Rhine–Meuse, as its descriptor gives it; a Bay–Delta river, its Delta or its Bay has the same parts. One law per process, every value sourced, and ports that say who sets the level and who answers with the flow. A law can be swapped for another in the register without touching the blocks either side. Two checks in CI hold every block, in every region, to the contract.

How to change the math

There are three ways in, from no code at all to a law of your own, and one way every change is judged.

How to change the math: four routesRoute a, least effort: the model editor in the browser, with no code, works on a block’s laws and values (levels 3 and 4) on a what-if. With the owner’s key only, it is sent to the runner, which runs it with whatif.py and publishes it as whatif/<id>/ beside the live forecast; or it is downloaded as a patch to the region’s data, for a pull request. Route b: a region’s settings (level 2 and 3): a reach’s maths = { part = "name" } in region.toml, or another setting in the region’s own files (in the Bay–Delta, for example, flows in dsm2.toml), tried first as a trial (fdmr_runner.trial --maths '*.dispersion=your-law') or an experiment, scored apart, then a pull request. Route c, most effort: a law of your own (level 4) in Rust in fdmr-math or Python in the plug-ins, registered in registry.py with its tests and its source cited in references.toml, through CI (seams, contract, references, documents, Rust, Python and WebAssembly) to a pull request. Every route is judged the same way: the prediction ledger against persistence, the validation page per region, and experiments rerunning a region’s past interventions. Adopting a change is done by hand.LEAST EFFORTMOST EFFORTaModel editorin the browser, no code:swap a law, change a value,add a release or a breachL3–L4, on a what-ifWhat-if runwhatif.py: owner’s key onlyProposed changea patch to the region’s datawhatif/<id>/beside the live forecastPull requestreviewed by handbA region’s settingsmaths = { part = "name" }or other settings, e.g.Bay–Delta: dsm2.toml flowsL2–L3Trial or experimentfdmr_runner.trial --maths'*.dispersion=your-law'A hindcastin its own ledger, scoredapart; then a PRcA law of your ownRust in fdmr-math (thebrowser runs it too) orPython in fdmr_pluginsL4Registered and citedregistry.py, with itstests; its source by itsref: key in references.tomlCI, then a PRseams, contract,references, docs,Rust, Python, WasmdEvery route is judged the same waythe prediction ledger: each prediction scored against persistence, the last reading heldthe validation page, per region · experiments rerun a region’s past interventionsNothing is tuned to the scores: a person reads them, and adopting a change is done by hand.computesdata, filesoutside the modela checkHow to change the math: four routesRoute a, least effort: the model editor in the browser, with no code, works on a block’s laws and values (levels 3 and 4) on a what-if. With the owner’s key only, it is sent to the runner, which runs it with whatif.py and publishes it as whatif/<id>/ beside the live forecast; or it is downloaded as a patch to the region’s data, for a pull request. Route b: a region’s settings (level 2 and 3): a reach’s maths = { part = "name" } in region.toml, or another setting in the region’s own files (in the Bay–Delta, for example, flows in dsm2.toml), tried first as a trial (fdmr_runner.trial --maths '*.dispersion=your-law') or an experiment, scored apart, then a pull request. Route c, most effort: a law of your own (level 4) in Rust in fdmr-math or Python in the plug-ins, registered in registry.py with its tests and its source cited in references.toml, through CI (seams, contract, references, documents, Rust, Python and WebAssembly) to a pull request. Every route is judged the same way: the prediction ledger against persistence, the validation page per region, and experiments rerunning a region’s past interventions. Adopting a change is done by hand.aL3–L4, on a what-ifModel editor, in the browserswap a law, change a value, add an eventWhat-if run (whatif.py)owner’s key only; published aswhatif/<id>/ beside the live forecast,or a patch for a pull requestbL2–L3A region’s settingsmaths = { part = "name" }or other settings, e.g. the Bay–Delta’sdsm2.toml flowsA trial or an experimentfdmr_runner.trial --maths'*.dispersion=your-law'cL4A law of your ownRust in fdmr-math, or Python in plug-insRegistered and citedregistry.py, its tests; references.tomlCI, then a pull requestseams, contract, references, testsdAll judged the same waythe prediction ledger, against persistencethe validation page, per regionexperiments rerun past eventsadopting a change is done by handcomputesdata, filesoutside the modela check
Changing the math, across the levels. Each route starts at a different level, from a what-if in the browser to a law of your own, and all four end the same way: judged against what was measured, and adopted, if at all, by a person.

Worked example: your own dispersion law

Say you are a hydrologist with a better estimate of a river’s longitudinal dispersion coefficient than Fischer’s 0.011 U2W2/(d u*). Dispersion is a part of every river reach, so here is the whole path, the same for a river in any region.

Level 4: one lawThe law fischer-longitudinal: K equals 0.011 U squared W squared over d u-star, with the shear velocity u-star the square root of g d S. Its code is the Rust function fischer_k in crates/fdmr-math/src/dispersion.rs; Python calls it through fischer_ks in crates/fdmr-py/src/lib.rs, from dispersion_field in python/fdmr_plugins/river_routing/fields.py. It is registered in python/fdmr_plugins/registry.py under the river-routing kind’s dispersion part, cites Fischer, List, Koh, Imberger and Brooks 1979, chapter 5, by its key fischer1979 in references.toml, and is chosen per reach in region.toml. The tests it must pass include fischer_k_textbook: U 0.5 m/s, W 50 m, d 2 m and u-star 0.05 m/s give K = 68.75 m² per second.L0 · System›L1 · Layers›L2 · Region›L3 · Block›L4 · Lawyou are herelaw: fischer-longitudinalK = 0.011 U² W² / (d u*)u* = √(g d S)U velocity, W width, d depth,u* shear velocity, S slope (SI)The code: Rustcrates/fdmr-math/src/dispersion.rspub fn fischer_k(velocity, width, depth, shear_velocity) -> f64Called from Pythoncrates/fdmr-py/src/lib.rs: fischer_kspython/fdmr_plugins/river_routing/ fields.py: dispersion_fieldChosen per reachregion.toml:maths = { dispersion = "fischer- longitudinal" }Documentedtools/maths_doc.pywrites docs/maths.mdtools/references.pychecks every ref:Registeredpython/fdmr_plugins/registry.pyREGISTER["river-routing"] ["dispersion"]Its cited sourcereferences.toml [fischer1979]Fischer, List, Koh, Imberger and Brooks1979, Mixing in Inland and Coastal WatersThe tests it must pass (registry.py CHECKS)dispersion.rs::fischer_k_textbook: U 0.5, W 50, d 2, u* 0.05 → K = 68.75 m²/sand change_of_moment_recovers_known_k, moment_method_recovers_k_from_parcels …computesdata, filesoutside the modela checkLevel 4: one lawThe law fischer-longitudinal: K equals 0.011 U squared W squared over d u-star, with the shear velocity u-star the square root of g d S. Its code is the Rust function fischer_k in crates/fdmr-math/src/dispersion.rs; Python calls it through fischer_ks in crates/fdmr-py/src/lib.rs, from dispersion_field in python/fdmr_plugins/river_routing/fields.py. It is registered in python/fdmr_plugins/registry.py under the river-routing kind’s dispersion part, cites Fischer, List, Koh, Imberger and Brooks 1979, chapter 5, by its key fischer1979 in references.toml, and is chosen per reach in region.toml. The tests it must pass include fischer_k_textbook: U 0.5 m/s, W 50 m, d 2 m and u-star 0.05 m/s give K = 68.75 m² per second.L0SystemL1LayersL2RegionL3BlockL4Lawlaw: fischer-longitudinalK = 0.011 U² W² / (d u*)u* = √(g d S)U velocity, W width, d depth,u* shear velocity, S slopeThe code: Rustcrates/fdmr-math/src/dispersion.rsfn fischer_k(velocity, width, depth, shear_velocity) -> f64Called from Pythonfdmr-py lib.rs: fischer_ks; thenriver_routing/fields.py:dispersion_fieldRegistered: registry.pyREGISTER["river-routing"] ["dispersion"]Its cited sourcereferences.toml [fischer1979]Fischer et al. 1979, Mixing in Inlandand Coastal Waters, chapter 5Chosen per reach: region.tomlmaths = { dispersion = "…" }Its tests (CHECKS)fischer_k_textbook:U 0.5, W 50, d 2, u* 0.05 → 68.75 m²/schange_of_moment_recovers_known_kcomputesdata, filesoutside the modela check
Level 4, one law. Fischer’s longitudinal dispersion, one of the registered choices for any river reach in any region (the Waal’s among them), down to its function: where its code is, where it is registered and cited, where a reach chooses it, and the textbook case it is tested against. The worked example below adds a law beside it.
  1. Write it. Add your function beside fischer_k in dispersion.rs ↗, with a test against a published case.
  2. Bind it. Expose it to Python in fdmr-py’s lib.rs ↗, as fischer_ks is.
  3. Compute it. dispersion_field in fields.py ↗ gives each element’s K; add yours beside it, and call it from publish.py ↗, where the reach’s chosen dispersion maths is read. The browser needs no change: with any dispersion law but the default cross-channel shear, the reach publishes its K as the dispersion field, and the engine (river.rs ↗) spreads parcels by it.
  4. Register and cite it. Add it to the register’s river-routing dispersion part with its tests, and its sources to references.toml; regenerate the documents.
  5. Try it. python -m fdmr_runner.trial on any region, with --maths '*.dispersion=your-law', reruns that region’s rivers as a hindcast and scores it apart from the live model.
  6. Adopt it. If it holds up, a reach chooses it in its region.toml entry, maths = { dispersion = "your-law" } — the Waal in regions/rhine-meuse, say, or the Sacramento in regions/sf-bay-delta — and its block descriptor names the same law; CI must pass.

Where the data comes from, and one cycle

Every value reaches the model through an adapter, into the local store, with its source and time. A region names the sources it reads in its own files (a gauge’s source, or the region’s gauge_source), so no source is assumed in the engine. A failed fetch is named in the cycle’s fetch status and the rest carry on; every input past its last reading is carried on in a named way — held, its own forecast, a release rule — and each cycle’s index.json says which, input by input. Every source cited anywhere is listed once in references.toml. The whole flow, in diagrams, is how-it-works.md ↗.

The runner works in cycles. Timers start cycle.sh ↗, which runs every region in turn the same way: fetch; nightly, calibrate; each reach that has a run of its own, after the reach it is joined to; publish, which routes the rivers, joins every reach and writes the files; and the checks. What runs in a region is what its files ask for. For example, every six hours the Bay–Delta runs DSM2, its canals, the Bay, the coast and the shadow; every hour the Rhine–Meuse runs its tidal network; the test region only fetches and publishes.

One forecast cycle on the runnerThree systemd timers run cycle.sh, in UTC: hourly at twenty past the hour; every 6 hours from 00:20 (the delta mode), which adds the reaches that run on external models; and nightly at 08:05, which adds calibration, the hindcast as of five days before, and the scores. Each cycle runs every region in turn, the same way: fetch, from every adapter the region names; nightly, calibrate the rivers’ channels; each reach with a run of its own, after the reach it is joined to; publish, which routes the rivers, joins every reach and writes the files; and the checks: every step logged, and nightly the hindcast and scores. Example, the Bay–Delta every 6 hours: fetch, about 2.5 minutes; DSM2 for the Delta, HYDRO then QUAL and GTM, about 5 minutes; the export canals; the Bay from NOAA’s SFBOFS, 3 to 6 minutes; the coast from NOAA’s WCOFS, about 1.5 minutes; the shadow, our solver beside HYDRO, about 1.5 minutes; and publish, about 30 seconds. Example, the Rhine–Meuse every hour: fetch from Rijkswaterstaat, about 70 seconds; the tidal network on our own solver, about 6 seconds; publish, about 5 seconds. Example, the test region every hour: fetch from USGS, then publish.THE TIMERS, OVER ONE DAY00:0006:0012:0018:0024:00UTChourly at :20 — every region: fetch, the reaches that run every hour, publishevery 6 hours from 00:20 (the “delta” mode) — adds the reaches that run on external modelsnightly at 08:05 — adds calibration, the hindcast as of five days before, and the scoresEACH CYCLE, THE SAME FOR EVERY REGION (cycle.sh)FOR EACH REGION, IN TURNfetchevery adapterthe region namescalibratenightly: therivers’ channelsreacheseach with a runof its own, afterthe one it joinspublishroutes the rivers,joins every reach,writes the fileschecksevery step logged;nightly: hindcastand scoresEXAMPLE: THE BAY–DELTA, EVERY 6 HOURSfetcheveryadapter≈2.5 minDSM2the Delta:HYDRO, QUAL≈5 mincanalsfrom theexportsBayNOAASFBOFS3–6 mincoastNOAAWCOFS≈1.5 minshadowours besideHYDRO≈1.5 minpublishrivers, andevery join≈30 sits reaches with a run of their own, in chain order, and the shadowEXAMPLE: THE RHINE–MEUSE, EVERY HOURfetchRijks-waterstaat≈70 snetworktidal rivers,our solver≈6 spublishrivers, andevery join≈5 sa run of its ownEXAMPLE: THE TEST REGION, EVERY HOURfetchUSGSgaugespublishthe oneriverThe regions run one after another. A cycle still running when the next is due makes the next wait. Timesmeasured on the runner, November 2026 (docs/run-times.md).computesdata, filesoutside the modela checkOne forecast cycle on the runnerThree systemd timers run cycle.sh, in UTC: hourly at twenty past the hour; every 6 hours from 00:20 (the delta mode), which adds the reaches that run on external models; and nightly at 08:05, which adds calibration, the hindcast as of five days before, and the scores. Each cycle runs every region in turn, the same way: fetch, from every adapter the region names; nightly, calibrate the rivers’ channels; each reach with a run of its own, after the reach it is joined to; publish, which routes the rivers, joins every reach and writes the files; and the checks: every step logged, and nightly the hindcast and scores. Example, the Bay–Delta every 6 hours: fetch, about 2.5 minutes; DSM2 for the Delta, HYDRO then QUAL and GTM, about 5 minutes; the export canals; the Bay from NOAA’s SFBOFS, 3 to 6 minutes; the coast from NOAA’s WCOFS, about 1.5 minutes; the shadow, our solver beside HYDRO, about 1.5 minutes; and publish, about 30 seconds. Example, the Rhine–Meuse every hour: fetch from Rijkswaterstaat, about 70 seconds; the tidal network on our own solver, about 6 seconds; publish, about 5 seconds. Example, the test region every hour: fetch from USGS, then publish.THE TIMERS, OVER ONE DAY00:0006:0012:0018:0024:00UTChourly at :20every region: fetch, its hourly reaches, publishevery 6 hours from 00:20 (“delta”)adds the reaches run on external modelsnightly at 08:05adds calibration, the hindcast, the scoresEACH CYCLE, FOR EACH REGION IN TURNfetchevery adapter the region namescalibratenightly: the rivers’ channelsreacheseach with its own run, in chain orderpublishroutes the rivers, joins every reachchecksevery step logged; nightly, the scoresEXAMPLE: THE BAY–DELTA, EVERY 6 HOURSfetchevery adapter≈2.5 minDSM2the Delta: HYDRO, then QUAL, GTM≈5 mincanalscarried on from the exportsBayNOAA’s SFBOFS, joined3–6 mincoastNOAA’s WCOFS, joined≈1.5 minshadowour solver beside HYDRO≈1.5 minpublishthe rivers, and every join≈30 sEXAMPLE: THE RHINE–MEUSE, EVERY HOURfetchRijkswaterstaat≈70 snetworkthe tidal rivers, our solver≈6 spublishthe rivers, and every join≈5 sEXAMPLE: THE TEST REGION, EVERY HOURfetchUSGS gaugespublishthe one riverThe regions run one after another.computesdata, filesoutside the modela check
Time: one cycle. The top two rows are the architecture: the timers, and one cycle that is the same for every region. Below, what that cycle is in each region today, as examples: a region runs only the steps its reaches need. In the Bay–Delta, the shadow, greyed, is compared every cycle but never published, and never stops the cycle.

A new region is data, not code

Everything above is general; a region only fills it in. To build a new one, you write data: a regions/<id>/region.toml naming its reaches, with a model kind and a flow source for each, its gauges and the adapters that feed them, its handoffs and its guard words; a block descriptor for each reach; and the settings files its kinds need. You write code only where its water needs something the engine does not have yet — an adapter for a new data source, a new model kind or a new law — and that code is general too: it names no place, the seams check makes sure of it, and every region can use it from then on.

Three regions keep the engine honest. test-colorado ↗ is deliberately plain: one gauged river below Glen Canyon Dam, run with only the river model and national adapters — if the engine needs changing to run it, something regional has leaked in. rhine-meuse ↗ tested whether the first region had shaped the engine. Porting it found what was tied to the United States and met each as configuration: river lines from Rijkswaterstaat’s waterway network or OpenStreetMap, channels from sourced width, slope and roughness where no field surveys are published, and, with no open model of its tidal rivers to be had, a channel network built from open data and run on our own solver. And sf-bay-delta ↗, the largest, where the model began, is one region among them: an example of the architecture, not the architecture itself. The next region, a Mississippi or a Thames, starts as a new folder of data.