fix(ci): lint the whole workspace, and clear what that exposes (gh#743) - #757
Open
vsbuffalo wants to merge 2 commits into
Open
fix(ci): lint the whole workspace, and clear what that exposes (gh#743)#757vsbuffalo wants to merge 2 commits into
vsbuffalo wants to merge 2 commits into
Conversation
vsbuffalo
force-pushed
the
fix/clippy-workspace-lint
branch
2 times, most recently
from
August 27, 2026 22:28
866d82b to
c2b5962
Compare
`clippy::items_after_test_module` fires where a `#[cfg(test)] mod tests`
sits between the items above it and the items below, which is easy to
read past when scanning a file for a definition.
This commit is a PURE REORDERING and nothing else. Verified by comparing
the whitespace-normalized set of lines before and after — identical in
both files:
git show origin/main:<f> | sed 's/[[:space:]]\+/ /g' | sort
<same over the working copy> # diff is empty
Kept separate from the rest of the lint cleanup precisely because the
line count (~800) is otherwise the largest thing in the diff and would
bury the substantive changes.
`cd rust && cargo clippy --all-targets -- -D warnings` linted ONE
package. rust/Cargo.toml declares the workspace root as a package
(`camdl-tests`), so with no `-p` and no `--workspace` cargo lints only
that; sim, cli and io compile as dependencies and were never linted. The
check could not go red for anything in the real crates — an assurance
that wasn't there. Add `--workspace`, and clear everything it exposes.
The ten `neg_cmp_op_on_partial_ord` are the valuable ones, and none was
a bug: every `!(x > 0.0)` was deliberate NaN handling, some carrying a
comment saying so (obs_loglik cites gh#645). Rewritten so the NaN arm is
in the code rather than a comment — `x.is_nan() || x <= 0.0` — which is
exactly equivalent, and pinned by assertions. Eight more of the same
shape surfaced in cli, which clippy had never reached.
NaN coverage added: boundary_times monotonicity guards, optimize_det
bounds, neg_binomial_dispersion, a NaN forcing knot, and a NaN `Cond`
predicate in the flat-VM byte-identity A/B. The last was confirmed to
have teeth: reverting the guard makes it fail with eval_resolved=2.0 vs
eval_flat=1.0. Two arms are left untested — ode's `h` fallback and the
multi_stream_obs denominator — because reaching them needs a fixture out
of proportion to a provably equivalent rewrite.
Two real defects fell out:
- spatial_density's -inf diagnostic tested
`(rate <= 0.0 && flow > 0) || (flow > 0)`, which collapses to
`flow > 0`. The pathological case the author wanted to see — flow
out of a transition with no propensity — was printed but never
distinguished. Same rows, now marked.
- three orphaned doc comments. `apply_params_file` lost its docs to a
function inserted between them (reattached); sampling.rs's module
overview was written with `///` so it documented a `use` statement
(now `//!`); and a doc block for the removed `--starts-from` flag
outlived it (deleted).
Four lints are allowed workspace-wide, with reasons in Cargo.toml:
`too_many_arguments` and `type_complexity` (numerical kernels where the
parameter list is the domain), `needless_range_loop` (the index IS the
notation, and de-indexing invites a silent transposition in exactly the
files CLAUDE.md calls high-risk), `upper_case_acronyms` (PGAS/PMMH are
the method names) and `large_enum_variant` (boxing argv-built enums).
`approx_constant` is allowed at four call sites where the literal is an
arbitrary test value or a scipy oracle — 3.14 is not pi, and
substituting the constant would change what is asserted.
No correctness lint is silenced anywhere.
vsbuffalo
force-pushed
the
fix/clippy-workspace-lint
branch
from
August 29, 2026 03:03
c2b5962 to
6d3683c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #743.
The gate linted one package
cd rust && cargo clippy --all-targets -- -D warningslints only the current package.rust/Cargo.tomldeclares the workspace root as a package (camdl-tests), sosim,cliandiocompiled as dependencies and were never linted — the check could not go red for anything in the real crates. Adding--workspacemakes it real; this PR clears everything that then surfaces.Workspace clippy is now 0 lints under
-D warnings.The
neg_cmp_op_on_partial_ordeighteen — none was a bugEvery one was deliberate NaN handling, several with a comment saying so (
obs_loglikcites gh#645). They are rewritten so the NaN arm lives in the code rather than a comment:Exactly equivalent by truth table. Ten were in
sim; eight more surfaced incli, which clippy had never reached.NaN coverage added: the
boundary_timesmonotonicity guards,optimize_detbounds,neg_binomial_dispersion, a NaN forcing knot, and a NaNCondpredicate in the flat-VM byte-identity A/B. That last one is verified to have teeth — reverting the guard fails it witheval_resolved=2.0 != eval_flat=1.0.Two arms are left untested and I would rather say so than pad:
odeshfallback and themulti_stream_obsdenominator. Both need a fixture out of proportion to a provably equivalent rewrite.Two real defects fell out
spatial_density.rs— the-infdiagnostic tested(rate <= 0.0 && flow > 0) || (flow > 0), which collapses toflow > 0. The pathology the author wanted to see (flow out of a transition with no propensity) was printed but never distinguished. Same rows, now marked.apply_params_filelost its docs to a function inserted between them (reattached);sampling.rss module overview used///, so it documented ausestatement (now//!); and a doc block for the removed--starts-fromflag outlived it (deleted).Design calls to sanity-check
Allowed workspace-wide, each with its reason in
rust/Cargo.toml:needless_range_looppgas/pmmh/nuts/ode/resampling, where the index mirrors the derivation and often walks several arrays at once. De-indexing buys no correctness and makes a silent transposition easier to introduce — CLAUDE.md flags these exact files as high-risk "regardless of how mechanical the change looks".too_many_arguments,type_complexityupper_case_acronymsPGAS/PMMHare the method nameslarge_enum_variantapprox_constantis allowed at four call sites where it is a false positive:3.14is not π, and substituting the constant would change what the test asserts. One is a scipy oracle value that happens to equal-ln(2).No correctness lint is silenced anywhere.
Commits
items_after_test_moduleproduced an ~800-line reordering intrajectories.rsandpmmh.rs. It is in its own commit, verified as a pure move by comparing whitespace-normalized sorted line sets againstmain(diff empty), so it does not bury the substantive changes.Verification
Full
make test— every phase, ending with the install-script suite — exit 0, 0 failures.