62 lines
2.6 KiB
Markdown
62 lines
2.6 KiB
Markdown
# Improvement Scan -- 2026-05-05
|
||
|
||
## Branch
|
||
`research/scan-2026-05-05-symclaw-1`
|
||
|
||
## Summary
|
||
|
||
Eliminated 39 latent `clippy::redundant_clone` warnings across 19 files in 5
|
||
crates, plus a follow-up `redundant_field_names`, plus one `partial_cmp` /
|
||
`unwrap_or(Equal)` fall-back that should have been `total_cmp` from the start.
|
||
|
||
## Changes
|
||
|
||
### 1. Eliminate `clippy::redundant_clone` (37 sites, 19 files)
|
||
|
||
`cargo clippy --fix --workspace --no-deps` was applied for `redundant_clone`
|
||
across the workspace. The lint flagged values that were dropped without further
|
||
use (or never mutated), so removing the `.clone()` is a behaviour-preserving
|
||
optimisation that also clarifies ownership.
|
||
|
||
- `crates/symclaw-core/src/codegen.rs` (3): `name.to_string()` etc.
|
||
- `crates/symclaw-core/src/ode/mod.rs` (6): expression-tree clones in
|
||
`Bernoulli` / linear-1st-order ODE construction.
|
||
- `crates/symclaw-core/src/solve/mod.rs` (6): Cramer-rule and quadratic
|
||
formula intermediates, plus `int_coeffs.clone()` in rational-roots search.
|
||
- `crates/symclaw-core/src/transforms/mod.rs` (2),
|
||
`crates/symclaw-core/src/poly/{mod.rs,rational.rs}` (3),
|
||
`crates/symclaw-core/src/proof.rs` (2),
|
||
`crates/symclaw-core/src/precision.rs` (2),
|
||
`crates/symclaw-core/src/integrate_advanced/{mod.rs,rational.rs}` (2),
|
||
`crates/symclaw-core/src/{partial_fraction,summation,units,analyze,
|
||
compiled_eval,eval}.rs` (1 each).
|
||
- `crates/symclaw-cli/src/commands.rs`,
|
||
`crates/symclaw-python/src/lib.rs`,
|
||
`crates/symclaw-skill/src/handlers_advanced.rs`,
|
||
`crates/symclaw-wasm/src/lib.rs` (1 each).
|
||
|
||
### 2. Fix `clippy::redundant_field_names` introduced by step 1 -- `crates/symclaw-core/src/proof.rs:341`
|
||
|
||
After dropping the redundant `.clone()` on `from`, the struct literal became
|
||
`from: from`, which is now collapsed to the field-shorthand `from`.
|
||
|
||
### 3. Replace `partial_cmp(...).unwrap_or(Ordering::Equal)` with `total_cmp` -- `crates/symclaw-core/src/discover.rs:172`
|
||
|
||
`min_by` over `penalized_fitness(...)` (a `f64`) was using
|
||
`partial_cmp(...).unwrap_or(Equal)` as a NaN fall-back. Symbolic-regression
|
||
fitness is exactly the kind of expression that can produce NaN under bad
|
||
candidates, and silently mapping NaN to `Equal` lets a NaN-fitness candidate
|
||
masquerade as the best-so-far. `f64::total_cmp` orders NaN deterministically at
|
||
the high end, so a NaN is never picked as `min`. Net: NaN-safe ordering with
|
||
one fewer fallible call.
|
||
|
||
## Verification
|
||
|
||
- `cargo clippy --workspace -- -D warnings` -- clean (0 warnings, 0 errors)
|
||
- `cargo test -p symclaw-core` -- 1279 passed (lib) + 56 passed (integration);
|
||
0 failed across the suite.
|
||
|
||
## Files changed
|
||
|
||
21 files, +38 / −39.
|