perturbation-sim: NaN/panic hardening sweep (total_cmp + cascade NaN-abort + stats guard) before the kanban/jitson wiring#554
Conversation
…e NaN-abort, stats empty-guard Foundation-hardening before the kanban↔Lance↔jitson wiring rides on it. - NaN-panic fix: 20 `partial_cmp(...).unwrap()` sites across 14 example files replaced with `f64::total_cmp` (never panics; deterministic NaN order). The lib `src/` had none in non-test code — the foundation was not panicking; this hardens the example/probe surface (the "speaking errors"). - Cascade NaN-abort: `simulate_outage` now breaks if any `theta`/`flow` value is non-finite (matching the islanding-break style) — a NaN can neither propagate into the perturbation shape nor loop to max_rounds. The "timeout for NaN". - stats.rs: empty-slice guard on `mean`/`pop_var` (0/0 = NaN). Currently unreachable (all callers validate len ≥ 2) but wired at the source so a future caller can't leak it. - NaN-source audit (src/): eigen, flow, perturbation, resilience, rolling_floor float producers all already guarded (SPECTRAL_GAP_FLOOR / rel_tol / .max(eps) / filter) — verified, no change needed. - clippy --all-targets: zero warnings (default build, no ndarray-simd/cranelift). cargo-machete: not installed; only dep is the optional feature-gated ndarray. - 95 lib tests pass. Disk-light: no cranelift/ndarray build touched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CcpLeEC3XK8Eye53GKBVvi
|
Warning Review limit reached
More reviews will be available in 49 minutes and 29 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (18)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 657f0fb3bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // NaN guard: a non-finite angle/flow signals numerical failure; treat | ||
| // as terminal (matching the islanding-break style) so NaN cannot | ||
| // propagate into the output shape or keep the loop alive. | ||
| if theta.iter().any(|x| !x.is_finite()) || flow.iter().any(|x| !x.is_finite()) { |
There was a problem hiding this comment.
Avoid returning the non-finite state after aborting
When this new guard fires (for example after a solver failure or large finite inputs that overflow dc_flows), theta and/or flow are already the non-finite vectors assigned above. The break then falls through to build node_field and edge_field from those same values at lines 168–172, so the advertised NaN-abort still returns NaN/Inf in the perturbation shape and downstream rankings/statistics can be corrupted. Preserve the last finite state or sanitize/return an error before constructing the shape.
Useful? React with 👍 / 👎.
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
…pe (codex #554 P2) The previous guard broke the loop on a non-finite theta/flow, but the shape was then built from those SAME non-finite values (node_field/edge_field at the build step) — so the "abort" still leaked NaN/Inf into the perturbation shape and downstream rankings/stats. Fix: seed theta/flow with the finite base state and overwrite them each round ONLY after the new values are confirmed finite (theta_next/flow_next). A non-finite round now breaks WITHOUT adopting it, so theta/flow/components_final retain the last finite state and the shape is built from that — never from NaN/Inf. Matches the islanding-break semantics (which already left a finite proxy). New test perturbation_shape_is_always_finite locks the invariant across all terminal paths (converge / cascade / island); islanding_is_flagged also now asserts finite shape. clippy --all-targets clean; cascade suite green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CcpLeEC3XK8Eye53GKBVvi
Foundation-hardening on
perturbation-simbefore the kanban ↔ Lance-subscription ↔ jitson loop rides on it. Disk-light — no cranelift/ndarray build touched (default build only).What it fixes
partial_cmp(...).unwrap()sites across 14 example files →f64::total_cmp(never panics, deterministic NaN order). The libsrc/had none in non-test code — the foundation wasn't panicking; this hardens the example/probe surface.simulate_outagenow breaks if anytheta/flowvalue is non-finite (same style as the islanding break) — a NaN can neither propagate into the perturbation shape nor spin tomax_rounds.stats.rsempty-slice guard:mean/pop_varreturned0/0 = NaNon an empty slice. Currently unreachable (all callers validatelen ≥ 2) but wired at the source so a future caller can't leak it.src/):eigen,flow,perturbation,resilience,rolling_floorfloat producers were checked — all already guarded (SPECTRAL_GAP_FLOOR/rel_tol/.max(eps)/filter). Verified, no change needed.Gates
--all-targets: zero warnings (default build, cranelift-free).ndarray(not removed; it's behindndarray-simd).Branched off main pre-#553; the 18 files are pre-existing examples +
cascade.rs+stats.rsthat #553 never touched, so it merges cleanly onto the post-#553 main.🤖 Generated with Claude Code
Generated by Claude Code