Repository navigation
[Tracking] Migrate dedx_web wasm/dedx_extra.c helpers upstream into libdedx #118
Description
Summary
The web frontend (APTG/dedx_web) carries ~810 LOC of C in wasm/dedx_extra.c that sits on top of libdedx because the upstream public API does not yet expose what a GUI needs. This tracking issue coordinates moving that proven code upstream so libdedx gains a GUI-friendly API, downstream duplication is removed, and the WASM build links a clean vendored libdedx with no local C patches.
Full design: docs/12-libdedx-migration-plan.md in dedx_web (per-symbol inventory + phased plan).
Why this matters
- Duplication / drift — the material display-name table exists twice (C
dedx_get_material_friendly_nameand TSsrc/lib/config/material-names.ts, 151 entries each). - A bug fix stranded downstream —
dedx_extra.ccontains a corrected inverse-stopping-power branch selection that works around a real bug in upstreamdedx_get_inverse_stp(); every other consumer (CLI, Python, openshieldhit) still hits the original bug. - Re-exported internals — four accessors just publish
dedx_internal_*functions that already exist in libdedx but lack a public header entry.
Relationship to existing issues
This is the C-API-surface counterpart to the ecosystem work in the health review #108 (which calls for the Python binding to expose inverse/custom-compound functionality, and lists the GUI query API). It does not duplicate:
- Add query API for valid (program, ion, material) combinations to support GUI/frontend development #79 — query API for valid (program, ion, material) combinations → that is "Phase F" of the plan; tracked there, not re-filed here.
- simple override of elemental I-values #6 — per-element I-value override → a decision point for Phase E below.
- Check mass stopping power units #48 — units documentation → new docstrings added here will use
MeV cm²/g/MeV/nucl/g/cm²consistently.
Phases (each a self-contained, independently releasable PR)
- Phase A — Expose nucleon number, atom mass, density and is-gas in the public header #119 — Expose existing internal accessors (nucleon number, atom mass, density, is-gas) in the public header
- Phase B — Add public dedx_get_material_display_name() and make C the single source of truth for display names #120 — Public
dedx_get_material_display_name()+ make C the single source of truth for display names - Phase C — Fix dedx_get_inverse_stp() branch selection for monotone STP curves; add Bragg-peak STP tool #121 — Fix
dedx_get_inverse_stp()branch selection for monotone curves + add a Bragg-peak STP tool (bug) - Phase D — Add flat inverse / Bragg-peak convenience wrappers to dedx_wrappers.h #122 — Add flat inverse / Bragg-peak convenience wrappers to
dedx_wrappers.h - Phase E — Public custom-compound config builder + flat forward/inverse/peak wrappers #123 — Public custom-compound config builder + flat forward/inverse/peak wrappers
- Phase F — Add query API for valid (program, ion, material) combinations to support GUI/frontend development #79 — Query API for valid combinations (no separate issue)
Suggested order: A (#119) and F (#79) first (smallest, unblock the GUI), then C (#121, highest physics value), then B (#120), then D (#122) → E (#123).
Filed via Claude Code as part of the dedx_extra.c → libdedx migration plan.
Activity