ruvector/crates/thermorust
rUv eafba64fa5
fix(security): RUSTSEC advisories + clippy hardening in RuVector (#504)
* fix(security): RUSTSEC advisories + clippy hardening in RuVector

- Replace all bare `partial_cmp().unwrap()` calls on f32/f64 with
  `.unwrap_or(Ordering::Equal)` to prevent panics on NaN values in
  sorting/max-by operations across ruvllm, ruvector-dag, prime-radiant,
  and rvagent-wasm (12 sites in production code).
- Add input validation guards to the HTTP search endpoint: reject k=0,
  k > 10_000, empty vectors, and vectors exceeding 65_536 dimensions,
  preventing memory exhaustion via unbounded allocations.
- Harden LocalFsBackend::execute in rvagent-cli with env_clear() +
  safe-env allowlist (SEC-005), deadline-based timeout enforcement, and
  1 MB output truncation, matching the security posture of LocalShellBackend.
- Remove 129 occurrences of the deprecated `unused_unit = "allow"` lint
  and 3 occurrences of the removed `clippy::match_on_vec_items` lint from
  Cargo.toml files workspace-wide; both are no-ops in current Rust/Clippy.
- All 653+ tests across ruvector-core, ruvector-server, ruvector-dag,
  rvagent-cli, and prime-radiant pass with zero failures.

Note: `bytes` is already at 1.11.1 (>= 1.10.0); `paste` 1.0.15 is a
transitive dependency with no semver fix available upstream; `cargo audit`
returns clean.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(ci): cargo fmt + restore workspace unused_unit lint allow

- Run cargo fmt --all across all 9 files that drifted from rustfmt style
  (prime-radiant/energy.rs, ruvector-dag/bottleneck.rs+reasoning_bank.rs,
   ruvector-server/points.rs, ruvllm/pretrain_pipeline.rs+report.rs+registry.rs,
   rvagent-cli/app.rs, rvagent-wasm/gallery.rs)
- Add [workspace.lints.clippy] unused_unit = "allow" to root Cargo.toml;
  the per-crate entries removed in the security commit were still needed —
  moving to workspace-level is cleaner and restores -D warnings CI pass

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(ci): remove unneeded unit return type in ruvix bench

Removes `-> ()` from the Fn bound in run_benchmark_with_kernel
(crates/ruvix/benches/src/ruvix.rs:50) — triggers clippy::unused_unit
under -D warnings. Clippy prefers `Fn(&mut Kernel)` without explicit
unit return.

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(ci): resolve rustfmt and clippy unused_unit failures

- Run cargo fmt --all to fix long closure formatting in 9 files
  (energy.rs, bottleneck.rs, reasoning_bank.rs, points.rs,
  pretrain_pipeline.rs, report.rs, registry.rs, app.rs, gallery.rs)
- Add unused_unit = "allow" to [lints.clippy] in ruvix-bench and
  ruvector-mincut Cargo.toml files to suppress the unused_unit lint
  that was previously suppressed globally and now fires on two
  Fn(&mut T) -> () and FnMut() -> () function bounds

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-05-23 05:40:24 -04:00
..
benches fix: format all files, add EXO crate READMEs, convert path deps to version deps 2026-02-27 16:21:14 +00:00
src fix: format all files, add EXO crate READMEs, convert path deps to version deps 2026-02-27 16:21:14 +00:00
tests fix: format all files, add EXO crate READMEs, convert path deps to version deps 2026-02-27 16:21:14 +00:00
Cargo.toml fix(security): RUSTSEC advisories + clippy hardening in RuVector (#504) 2026-05-23 05:40:24 -04:00
README.md docs: add README files for ruvector-dither and thermorust crates 2026-02-27 16:14:34 +00:00

thermorust

A minimal thermodynamic neural-motif engine for Rust. Treats computation as energy-driven state transitions with Landauer-style dissipation tracking and Langevin/Metropolis noise baked in.

Features

  • Ising and soft-spin Hamiltonians with configurable coupling matrices and local fields.
  • Metropolis-Hastings (discrete) and overdamped Langevin (continuous) dynamics.
  • Landauer dissipation accounting -- every accepted irreversible transition charges kT ln 2 of heat, giving a physical energy audit of your computation.
  • Langevin and Poisson spike noise sources satisfying the fluctuation-dissipation theorem.
  • Thermodynamic observables -- magnetisation, pattern overlap, binary entropy, free energy, and running energy/dissipation traces.
  • Pre-wired motif factories -- ring, fully-connected, Hopfield memory, and random soft-spin networks ready to simulate out of the box.
  • Simulated annealing helpers for both discrete and continuous models.

Quick start

use thermorust::{motifs::IsingMotif, dynamics::{Params, anneal_discrete}};
use rand::SeedableRng;

let mut motif = IsingMotif::ring(16, 0.2);
let params    = Params::default_n(16);
let mut rng   = rand::rngs::StdRng::seed_from_u64(42);

let trace = anneal_discrete(
    &motif.model, &mut motif.state, &params, 10_000, 100, &mut rng,
);
println!("Mean energy: {:.3}", trace.mean_energy());
println!("Heat shed:   {:.3e} J", trace.total_dissipation());

Continuous soft-spin simulation

use thermorust::{motifs::SoftSpinMotif, dynamics::{Params, anneal_continuous}};
use rand::SeedableRng;

let mut motif = SoftSpinMotif::random(32, 1.0, 0.5, 42);
let params    = Params::default_n(32);
let mut rng   = rand::rngs::StdRng::seed_from_u64(7);

let trace = anneal_continuous(
    &motif.model, &mut motif.state, &params, 5_000, 50, &mut rng,
);

Modules

Module Description
state State -- activation vector with cumulative dissipation counter
energy EnergyModel trait, Ising, SoftSpin, Couplings
dynamics step_discrete (MH), step_continuous (Langevin), annealers
noise Langevin Gaussian and Poisson spike noise sources
metrics Magnetisation, overlap, entropy, free energy, Trace
motifs Pre-wired ring, fully-connected, Hopfield, and soft-spin motifs

Dependencies

  • rand 0.8 (with small_rng)
  • rand_distr 0.4

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.