Civil, hydraulic, and geotechnical engineers usually face an uncomfortable trade-off when choosing quick verification software. Either you rely on legacy Windows-only desktop installers locked behind corporate IT permissions, or you upload sensitive infrastructure alignments and boring logs to a cloud SaaS server just to run a retaining-wall or culvert headwater check.
We built HyGeoWorks in Rust to eliminate that trade-off: one 24-crate numerical engine (Release 1.0.3) compiles simultaneously into HyGeoWorks Desktop for Windows, a native C-ABI library (hy_ffi.dll), and a standalone wasm32-unknown-unknown module (hy_tools_bg.wasm, 4.53 MiB raw / 1.88 MiB inline gzip) that executes 100% locally in the browser across 189 static HTML pages (including 131 dedicated WebAssembly calculator pages across 4 regional standards) and a self-contained 39-tool offline single-file HTML workbench.
Every solver step prints worked equations and clause citations rather than opaque numbers, and all 69 automated embedded benchmarks (against FHWA HDS-5, EPA SWMM 5.2.4, ACADS, Rocscience Slide2, USGS SLAMMER, and analytical solutions) are archived openly under CC BY 4.0 on GitHub and Zenodo (Concept DOI 10.5281/zenodo.24458320).
1. The Engineering Problem: Desktop Fidelity vs. Zero-Upload Browser Access
Direct Answer: Compiling one shared Rust workspace into both desktop native code and WebAssembly prevents formula drift between engineering teams and guarantees that preview parameters never leave the user's machine.
In public works and infrastructure consulting, calculation drift between a quick browser script (JavaScript) and a formal desktop submittal suite (Fortran/C++/Rust) creates real QA liability. When a senior PE reviews a culvert headwater check or a braced excavation sheet in a browser, it must produce the exact same floating-point answer as the desktop binary.
Instead of rewriting formulas in TypeScript for the web, we organized the entire physics and regulatory engine into a 24-crate Rust workspace backed by 1,565+ unit tests (cargo test --workspace):
- Desktop & CLI: Uses the workspace directly at native speed (
hydro.exeCLI and WPF desktop application). - Spreadsheet Bridge (
hy_ffi.dll): Exposes a stable JSON-over-C-ABI contract for ourHydroCalc.xlsmExcel workbook. - Browser & Air-Gapped HTML (
hy_tools_bg.wasm): Exposes the exact same solver dispatch through barewasm32-unknown-unknown.
Across 376 desktop-versus-WebAssembly comparison cases (101,613 values) benchmarked on 2026-11-13, the compiled browser calculators match the desktop Rust library with a maximum relative difference of <= 4.9e-16 — pure IEEE 754 double-precision equivalence.
2. Why Bare wasm32-unknown-unknown Without wasm-bindgen
Direct Answer: Skipping wasm-bindgen keeps the browser boundary down to a tiny set of C-style exports using a 4-byte length-prefixed UTF-8 JSON buffer, matching our desktop hy_ffi.dll ABI and preventing runtime dependency churn.
wasm-bindgen is fantastic for DOM-heavy Rust web apps. However, our browser frontend is deliberately lightweight static HTML (189 static pages across US Customary, International SI/Eurocode, Japanese, and Traditional Chinese frameworks) with vanilla JavaScript and zero runtime frameworks.
All we needed between JavaScript and Rust was a deterministic RPC pipe:
-
hy_alloc(n)/hy_free(p, n)to manage linear memory slices safely. -
hy_tools_list()/hy_tool_names()so the shared localization and field-label tables (TOOL_TITLES,FIELD_LABELS,CHOICE_LABELS) live solely inside the Rust crate rather than being duplicated in frontend scripts. -
hy_tool_run(p, n),hy_tool_sketch(p, n),hy_project_toml(p, n), andhy_project_merge(p, n)reading UTF-8 JSON requests and returning a pointer to[4-byte little-endian u32 length | UTF-8 JSON payload]. -
std::panic::catch_unwindaround every solver call so an extreme user geometry input returns a clean JSON error instead of silently poisoning the module.
Core-Level Preview Stamping (Bypass-Resistant Boundary)
A subtle architectural detail in hy-wasm: free browser previews are not stamped by hiding a CSS overlay in JavaScript. Instead, run_json calls stamp_run(&mut env, loc) directly inside Rust before serializing the pointer back to linear memory:
- It prepends the localization-aware preview header directly into
/output/textandplainoutputs. - It injects vector diagonal watermark strokes and corner labels inside
sketch_json(stamp_sketch) at the geometry coordinate level. - Even if someone strips frontend display scripts, the returned calculation payload itself carries the preview mark, and client flags attempting to disable stamping are ignored. Licensed single-tool Word/DXF formal exports bypass the free preview path via memory-only server generation with RFC 8032 Ed25519 QR seals verifiable client-side at hygeoworks.com/en/verify/.
Here is the minimal ABI pattern from crates/hy-wasm/src/lib.rs:
fn out_str(s: &str) -> *mut u8 { let s = s.as_bytes(); let mut buf = Vec::with_capacity(4 + s.len()); buf.extend_from_slice(&(s.len() as u32).to_le_bytes()); buf.extend_from_slice(s); let mut b = buf.into_boxed_slice(); let p = b.as_mut_ptr(); std::mem::forget(b); p } #[no_mangle] pub extern "C" fn hy_alloc(n: usize) -> *mut u8 { let mut b = vec![0u8; n.max(1)].into_boxed_slice(); let p = b.as_mut_ptr(); std::mem::forget(b); p } pub fn run_json(text: &str) -> Value { let v: Value = match serde_json::from_str(text) { Ok(v) => v, Err(e) => return json!({"ok": false, "error": format!("Invalid JSON: {e}")}), }; let id = v.get("id").and_then(|x| x.as_str()).unwrap_or(""); let input = v.get("input").cloned().unwrap_or(Value::Null); let loc = locale_of(&input); let mut env = std::panic::catch_unwind(|| hy_tools::run_envelope(id, &input)) .unwrap_or_else(|_| json!({"ok": false, "error": "Calculation kernel panic"})); stamp_run(&mut env, loc); env } On the JavaScript side, the shared loader checks for WebAssembly.compileStreaming (falling back gracefully to ArrayBuffer if a static host omits application/wasm), caches a single compiled WebAssembly.Module across page switches, reads the 4-byte DataView header, frees both input and output slices immediately, and re-instantiates the module automatically if a WebAssembly.RuntimeError trap occurs on pathological inputs:
function takePtr(ex, ptr) { const len = new DataView(ex.memory.buffer).getUint32(ptr, true); const jsonStr = dec.decode(new Uint8Array(ex.memory.buffer, ptr + 4, len)); ex.hy_free(ptr, 4 + len); return JSON.parse(jsonStr); } try { const inPtr = ex.hy_alloc(bytes.length); new Uint8Array(ex.memory.buffer, inPtr, bytes.length).set(bytes); const outPtr = ex.hy_tool_run(inPtr, bytes.length); ex.hy_free(inPtr, bytes.length); return takePtr(ex, outPtr); } catch (err) { if (err instanceof WebAssembly.RuntimeError) { WebAssembly.instantiate(wasmMod, {}).then((next) => { ex = next.exports; }); return { ok: false, error: "Numerical exception; check input geometry bounds." }; } throw err; } Because hy_project_toml and hy_project_merge run inside this exact same contract, single tools or multi-tool project carts built in the browser export directly as .toml files that open cleanly in the desktop application.
3. Zero-Upload & Air-Gapped file:// Delivery (4.53 MiB Raw / 1.88 MiB Inline Gzip)
Direct Answer: Using native browser DecompressionStream("gzip") lets an air-gapped, double-clickable .html file boot all 39 Rust WebAssembly tools directly under file:// where browsers block fetch(.wasm).
Deploying over https:// is straightforward: browsers fetch hy_tools_bg.wasm (4,746,478 bytes) once with a SHA-256 cache-busting query string and keep the compiled module cached across calculator pages.
Field engineers inspecting culverts on remote highways or reviewing classified government dams behind air-gapped networks, however, often save a single file to a USB drive and double-click it (file://). Modern browsers block fetch() against local .wasm files due to null-origin CORS policies.
Our loader detects location.protocol === "file:" automatically, reads a base64-encoded gzip payload embedded in hy_tools_wasm_inline.js (1,975,115 bytes) or inline inside <script>, and streams it through the standard browser DecompressionStream("gzip") API into WebAssembly.compile():
async function gunzipBase64ToBytes(b64Str) { const raw = Uint8Array.from(atob(b64Str.trim()), (c) => c.charCodeAt(0)); if (raw.length >= 4 && raw[0] === 0x00 && raw[1] === 0x61 && raw[2] === 0x73 && raw[3] === 0x6d) { return raw.buffer; } return await new Response( new Blob([raw]).stream().pipeThrough(new DecompressionStream("gzip")) ).arrayBuffer(); } This powers our self-contained 39-Tool Offline Workbench (hydro-offline-workbench-en.html, 2.75 MiB total self-contained HTML) — zero Node.js server, zero Python backend, and zero cloud round-trips.
4. Verification Benchmarks: 69 Automated Cases, Zenodo DOI & EPA SWMM Cross-Checks
Direct Answer: HyGeoWorks (Release 1.0.3) publishes all 69 deterministic benchmark inputs, reference values, tolerances, and computed outputs openly under Zenodo Concept DOI 10.5281/zenodo.24458320 — passing 69/69 with zero widened tolerances, alongside 5 external cross-check suites against EPA SWMM 5.2.4 and GDAL/PROJ.
Engineering trust cannot rest on marketing claims. Our open verification archive on GitHub (hygeoworks/hygeoworks-benchmarks, v1.0.2 dataset snapshot verified 2026-11-23) records fixed, non-randomized regression benchmarks covering 51 published manual examples, 9 third-party software benchmarks, 7 analytical closed-form solutions, and 2 independent regression baselines, plus 5 external program comparisons. Anyone can reproduce the entire suite locally with the free HyGeoWorks Desktop trial CLI (hydro.exe verify-benchmarks --include-slow --out results).
Here is a curated sample across North American, European, and academic standards:
| Case / ID | Standard / Reference Benchmark | Reference Value | HyGeoWorks Computed | Difference | Notes |
|---|---|---|---|---|---|
| C-01 | FHWA HDS-5 (3rd Ed.) Ex 1.3.2: 54 in RCP inlet control (HY-8 polynomial) | 7.9 ft | 7.900 ft | +0.00047% | Q = 200 cfs, S = 0.01 |
| C-02 | FHWA HDS-5 (3rd Ed.) Ex 1.4.2: 5 ft × 5 ft box culvert inlet control | 9.65 ft | 9.6469 ft | -0.0316% | Q = 300 cfs, S = 0.02 |
| C-04 | FHWA HDS-5 Ex 1.3: 54 in RCP outlet control full-flow head loss H | 4.7 ft | 4.706 ft | +0.118% | ke = 0.2, n = 0.012, L = 200 ft |
| X-02 | FHWA HEC-22 Street Inlets vs. EPA SWMM 5.2.4 (142 scenarios) | SWMM 5.2.4 | Matches | <= 0.019% (grade) / 0.000% (sag) | 128 on-grade + 14 sag runs |
| X-01 / X-04 | EPA SWMM 5.2.4 Dynamic Wave (S1 free-surface & 3-pond network) | SWMM 5.2.4 | Matches | <= 0.02% (S1) / +0.08% (network) | NSE >= 0.9997, 0.000% continuity error |
| W-06 / W-07 | FHWA-NHI-10-025 MSE Wall Ex E4: Strength I Sliding / Bearing CDR | 1.37 / 1.57 | 1.3716 / 1.5657 | +0.118% / -0.277% | Layer 4 Tmax: 12.7611 vs 12.77 kip (-0.070%) |
| S-01 | ACADS (1989) Ex 1(a) slope stability (Bishop simplified grid) | 1.00 (other soft. ~0.99) | 0.9854 | -1.46% | Homogeneous 2:1 slope |
| S-02 | Planar Wedge Closed-Form Solution (Spencer method) | 1.3415 | 1.341506 | -6.0e-09% | Closed-form verification |
| S-03 / S-06 | Rocscience Slide2 #85 & #54: Passive anchor / Pile-reinforced slope | 1.324 / 1.193 | 1.32032 / 1.19513 | -0.278% / +0.178% | Duncan & Wright (2005) & Yamagami (2000) |
| S-11 | Rocscience Slide2 #86: Non-circular Spencer 5-layer geogrid search | 1.594 | 1.59509 | +0.0682% | Deterministic multi-start fixed-seed search |
| S-12 | Newmark (1965) rigid block rectangular pulse analytical displacement | 2.4516625 m | 2.451662500 m | -1.8e-14% | A = 0.5 g, T = 0.5 s, ky = 0.1 |
| FL-01 | Ritter (1892) 2D dry-bed dam break (2nd-order HLL finite volume) | 0.0000 (exact) | L1 = 0.002554 | 0.255% relative L1 | Well inside ±2% tolerance |
Even More Important: Handling Numerical Discrepancies Honestly
In Case S-13 (Newmark rigid block integration on the 1992 Cape Mendocino Petrolia accelerogram vs. USGS SLAMMER v1.1), our engine computes 34.9703180 cm while SLAMMER's default sample-grid integrator prints 35.40369 cm (-1.22%).
Why? SLAMMER snaps sliding start/stop crossings to discrete 0.02 s sample timestamps, whereas our solver locates exact sub-sample zero-crossings analytically. When we refined the time series linearly by 50x and fed it back into SLAMMER, SLAMMER converged onto our 34.97031795 cm analytical value within < 2e-5. Instead of hiding that variance behind a loose tolerance, we documented the exact reason in the public verification archive.
5. Honest Engineering Boundaries: ERRATA.md, EXTERNAL.md & EXCLUDED.md
Direct Answer: A credible engineering kernel is defined as much by what it refuses to claim or alter silently as by what it passes — so we publish ERRATA.md (11 literature misprints side by side), EXTERNAL.md, and EXCLUDED.md openly.
Software verification goes wrong when developers silently widen tolerances or edit reference numbers until red tests turn green. We refuse to do that. Our public benchmark repository pairs cases.csv / cases.json with three plainspoken audits:
-
ERRATA.md(Side-by-Side Table of 11 Documented Literature Misprints): Where a published manual contains a misprint, an irreproducible chart reading, or rounded intermediate figures, we keep the original printed number unaltered next to the exact target checked and explain the derivation. -
EXTERNAL.md(Recorded External Program Limitations): Documents known physical formulation differences, such as pressurized/surcharged pipe flow (X-01ScenarioS2), where HyGeoWorks manhole depths run5.3%to9.3%higher than EPA SWMM because SWMM includes the Preissmann/Sjoberg slot area inside active conduit flow area while our solver keeps geometric pipe area unmodified. -
EXCLUDED.md(Items Not Counted in Automatic Acceptance): Lists every textbook or manual discrepancy we refuse to paper over — such as HDS-5 Ex 1.4 outlet-control hand calculations differing by2.1%–4.2%without an upstream audit trail, and non-circular slope searches remaining local optimizations whose seed behavior is explicitly disclosed in generated reports.
Finally, calculation kernels do not replace engineering judgment: site investigation, geological boundary assumptions, surcharge plausibility, and statutory professional seal (PE / CEng) always remain with the licensed engineer of record.
6. Inspect the Permanent DOI Archive or Run the Calculators Locally
Everything described above can be inspected or tested directly in your browser with zero account signup and zero file uploads:
- Permanent Zenodo Archive (
CC BY 4.0, Concept DOI): doi.org/10.5281/zenodo.24458320 (Releasev1.0.2snapshot: doi.org/10.5281/zenodo.24458321) - Public Verification Dataset & Audits: github.com/hygeoworks/hygeoworks-benchmarks (see ERRATA.md, EXTERNAL.md, EXCLUDED.md & CITATION.cff)
- Interactive Benchmark Whitepaper (English, 69 Cases): hygeoworks.com/en/benchmarks/
- US Customary Online Suite (
FHWA HDS-5,HEC-22,AASHTO LRFD Sec. 119th Ed. values): hygeoworks.com/us/tools/ - International SI / Eurocode Suite (
EN 1997-1 DA1,EN 1992-1-1,Geoguide 1): hygeoworks.com/en/tools/ - Single-File Air-Gapped Offline Workbench (39 Tools): hygeoworks.com/downloads/hydro-offline-workbench-en.html (or default multi-market portal: hydro-offline-workbench.html)
- Report Seal Verifier & Free Reviewer / Faculty Licence: hygeoworks.com/en/verify/#academic-reviewer-license
If you have built numerical WebAssembly modules without wasm-bindgen, implemented return-layer integrity watermarks, or benchmarked FHWA / Eurocode solvers against legacy engines, I would love to compare notes in the comments — especially on sub-grid 2D shallow-water vs. finite-element compromises or Preissmann slot damping edge cases.