Update project structure and configurations

This commit is contained in:
2026-05-23 10:19:55 +02:00
parent ab5dc7e568
commit 62efea0646
1832 changed files with 83568 additions and 51829 deletions

View File

@@ -1,6 +1,6 @@
# Story 6.4: WebAssembly Compilation
Status: review
Status: in-progress
## Story
@@ -151,3 +151,59 @@ zai-coding-plan/glm-5
- bindings/wasm/tests/simple_cycle.js
- bindings/wasm/examples/browser/index.html
- Cargo.toml (updated workspace members)
### Review Findings
- [x] [Review][Decision→Patch] Component bindings are non-functional stubs — constructors hardcode `R410A`, dummy port state. **Resolved (1a):** completed component bindings with proper fluid-param constructors, Result returns, and input validation.
- [x] [Review][Decision→Patch] Only R134a fluid table embedded — spec AC#2 says "R134a, R410A, etc." **Resolved (2a):** created global backend infrastructure with lazy init. Additional tables (R410A, R32) require generation from TabularBackend tool — only R134a data file exists.
- [x] [Review][Decision→Patch] TypeScript type definitions not included — AC#4. **Resolved (3b):** documented TypeScript generation workflow in README. Types are auto-generated by `wasm-pack build`.
- [x] [Review][Decision→Patch] Missing `tracing-wasm` dependency. **Resolved (4a):** added `tracing` + `tracing-wasm` to Cargo.toml.
- [x] [Review][Patch] `load_fluid_table` is a no-op — fixed: validates table, warns about registration limitation. [backend.rs]
- [x] [Review][Patch] `get_node_result` fabricates placeholder data — fixed: uses `FluidBackend::full_state()` to compute real ThermoState from P and h. [solver.rs]
- [x] [Review][Patch] `solve()` ignores `WasmFallbackConfig` — fixed: wraps real `FallbackConfig`, passes to `FallbackSolver::new(config)`. [solver.rs]
- [x] [Review][Patch] `timeout_ms` silently discarded — fixed: removed no-op, replaced with actual `FallbackConfig` fields (`set_fallback_enabled`, `set_return_to_newton_threshold`, `set_max_fallback_switches`). [solver.rs]
- [x] [Review][Patch] Component constructors panic on `.unwrap()` — fixed: all constructors return `Result<T, JsValue>` with descriptive errors. [components.rs]
- [x] [Review][Patch] `add_edge` no bounds validation — fixed: checks node indices against `node_count()` before creating NodeIndex. [solver.rs]
- [x] [Review][Patch] `get_node_result` no bounds checking — fixed: validates `p_idx`/`h_idx` against `state.len()`. [solver.rs]
- [x] [Review][Patch] README examples mismatch actual API — fixed: all examples rewritten with correct constructor signatures. [README.md]
- [x] [Review][Patch] No UA validation on Condenser/Evaporator — fixed: rejects NaN, infinity, zero, and negative values. [components.rs]
- [x] [Review][Patch] `WasmPipe::new` panics on invalid geometry — fixed: validates length/diameter, returns Result. [components.rs]
- [x] [Review][Patch] `toJson` uses wrong serializer — fixed: replaced `serde_wasm_bindgen` with `serde_json::to_string()`. Removed `serde-wasm-bindgen` dependency. [types.rs]
- [x] [Review][Patch] `WasmConvergedState` loses metadata — fixed: added `status` field with ConvergenceStatus mapping (Converged/TimedOut/ControlSaturation). [solver.rs, types.rs]
- [x] [Review][Patch] `errors.rs` is dead code — fixed: expanded with `thermo_error_to_js()` that maps all ThermoError variants to descriptive messages. [errors.rs]
- [x] [Review][Patch] `WasmComponent::name()` always returns "Component" — fixed: stores component type name in WasmComponent wrapper. [components.rs]
- [x] [Review][Patch] No physical validation on type constructors — fixed: WasmPressure rejects negative/NaN, WasmTemperature rejects negative/NaN, all types reject NaN. Constructors return Result. [types.rs]
- [x] [Review][Patch] `set_relaxation_factor` no bounds — fixed: clamps to (0, 1] with tracing warning. [solver.rs]
- [x] [Review][Patch] `WasmSystem::Default` uses `expect` — fixed: removed Default impl for WasmSystem. Users must use `new()` which returns Result. [solver.rs]
- [x] [Review][Defer] No performance benchmark/timing helpers — Task 4 (AC#3) requires < 100ms convergence verification. No automated benchmark exists. Deferred: feature not implemented, not a bug in current code.
- [x] [Review][Defer] No determinism test — Task 8 requires "compare vs native" determinism test. No test exists. Deferred: feature not implemented.
- [x] [Review][Defer] Test file `simple_cycle.js` cannot run without manual `wasm-pack build` — no CI target or npm pretest hook. Deferred: needs CI/build setup.
- [x] [Review][Defer] `into_component()` consumes self — prevents configure-then-add workflow from JS. Deferred: design choice, not a bug.
- [x] [Review][Defer] `list_available_fluids` creates fresh backend on every call — re-parses embedded R134a JSON each time. Deferred: minor perf, not a correctness issue.
- [x] [Review][Defer] Missing `tracing-wasm` integration — no logging infrastructure in WASM crate beyond `console_error_panic_hook`. Deferred alongside Decision item.