Summary
Code audit revealed significant technical debt where demo-specific values were hardcoded into the workflow code. The code works for the Hafnium demo dataset but will silently produce wrong results for other datasets.
Audit Grade: D+
Critical Issues
1. Hardcoded Hafnium Isotopes/Abundances (lines 801-815)
elif primary_isotope.startswith("Hf-"):
analysis_isotopes = ["Hf-174", "Hf-176", "Hf-177", "Hf-178", "Hf-179", "Hf-180"]
abundances = [0.0016, 0.0526, 0.1860, 0.2728, 0.1362, 0.3508]
Impact: Analysis of natural U, W, Gd, or any multi-isotope element will use wrong isotopes/abundances.
2. Hardcoded Hafnium Mass Number (lines 876-880)
if primary_isotope.startswith("Hf"):
mass_number = 178 # Weighted average for natural Hf
Impact: Other elements don't get weighted average mass calculation.
3. Hardcoded VENUS Resolution Path (lines 1067-1096)
default_venus_res = Path.home() / "SNS" / "VENUS" / "shared" / "instrument" / "resonance"
Impact: Non-VENUS facilities won't find resolution files.
4. No Natural Abundance Lookup System
IsotopeInfo.abundance field exists but is never populated from data files.
Impact: Forces developers to hardcode abundances.
5. Hardcoded ORNL Facility Default (line 720-722)
facility = Facility.ornl # Always defaults to ORNL
Impact: LANL data processed with wrong facility assumptions.
6. Magic Number Defaults in inp_manager.py
DEFAULT_DENSITY = 9.000000 # What material is this?
DEFAULT_T0_VALUE = 0.86000000 # VENUS-specific?
Impact: Wrong physics if material properties not explicitly provided.
Required Fixes
Immediate (Before Production)
Short-term
Architecture Changes
Root Cause
Code was developed with Hafnium foil demo in mind, with "shortcuts" to make the demo work. These shortcuts were not generalized before being committed.
Files Affected
src/pleiades/workflows/resonance.py - Main offender
src/pleiades/sammy/io/inp_manager.py - Magic numbers
src/pleiades/nuclear/isotopes/manager.py - Missing abundance lookup
tests/unit/pleiades/workflows/test_resonance.py - Only tests happy path
Related Issues
🤖 Generated with Claude Code
Summary
Code audit revealed significant technical debt where demo-specific values were hardcoded into the workflow code. The code works for the Hafnium demo dataset but will silently produce wrong results for other datasets.
Audit Grade: D+
Critical Issues
1. Hardcoded Hafnium Isotopes/Abundances (lines 801-815)
Impact: Analysis of natural U, W, Gd, or any multi-isotope element will use wrong isotopes/abundances.
2. Hardcoded Hafnium Mass Number (lines 876-880)
Impact: Other elements don't get weighted average mass calculation.
3. Hardcoded VENUS Resolution Path (lines 1067-1096)
Impact: Non-VENUS facilities won't find resolution files.
4. No Natural Abundance Lookup System
IsotopeInfo.abundancefield exists but is never populated from data files.Impact: Forces developers to hardcode abundances.
5. Hardcoded ORNL Facility Default (line 720-722)
Impact: LANL data processed with wrong facility assumptions.
6. Magic Number Defaults in inp_manager.py
Impact: Wrong physics if material properties not explicitly provided.
Required Fixes
Immediate (Before Production)
Short-term
Architecture Changes
Root Cause
Code was developed with Hafnium foil demo in mind, with "shortcuts" to make the demo work. These shortcuts were not generalized before being committed.
Files Affected
src/pleiades/workflows/resonance.py- Main offendersrc/pleiades/sammy/io/inp_manager.py- Magic numberssrc/pleiades/nuclear/isotopes/manager.py- Missing abundance lookuptests/unit/pleiades/workflows/test_resonance.py- Only tests happy pathRelated Issues
🤖 Generated with Claude Code