Skip to content

chore: cargo fmt + clippy -D warnings clean + regenerate Cargo.lock#1

Merged
Nelson Spence (Fieldnote-Echo) merged 3 commits into
mainfrom
prod/hygiene
May 22, 2026
Merged

chore: cargo fmt + clippy -D warnings clean + regenerate Cargo.lock#1
Nelson Spence (Fieldnote-Echo) merged 3 commits into
mainfrom
prod/hygiene

Conversation

@Fieldnote-Echo

@Fieldnote-Echo Fieldnote-Echo commented May 22, 2026

Copy link
Copy Markdown
Member

Foundational hygiene — merge first

Brings the extracted crate up to a strict lint gate (including the cross-platform matrix) so the three workstream PRs build on a clean base. No behavior change.

Changes

  • cargo fmt --all across src/, tests/, examples/.
  • cargo clippy --all-targets --all-features -- -D warnings clean (26 lints):
    • Mechanical rewrites: manual_is_multiple_of (13×, x % n == 0is_multiple_of, stable since 1.87 ≤ MSRV 1.89), manual_range_contains (2×), manual_repeat_n (1×, test).
    • #[allow] with justification: too_many_arguments (7× — SIMD kernels + bench fns whose arity is intrinsic) and needless_range_loop (7× — kernel loops doing raw pointer arithmetic / multi-array indexing). Only 2 trivial single-array test loops were converted to iterators.
  • Cross-platform build fix: the x86 SIMD glue (SimdTier::Avx2/Avx512, BATCHED_AVX512_CHUNK, the simd_tier / centre_drop_used bindings) was defined unconditionally but referenced only by cfg(target_arch="x86_64") dispatch → dead/unused on aarch64, failing -D warnings (caught by macos-latest). Gated each with cfg_attr(not(x86_64), allow(...)) so the crate builds clean on ARM (scalar path); x86 untouched.
  • Regenerate Cargo.lock (was version 3 with stale serde; now version 4, serde gone).

Verification

  • cargo fmt --all --check + clippy --all-targets --all-features -- -D warnings — clean
  • cargo test 80/0; --features experimental 86/0; RUSTFLAGS="-D warnings" cargo test 80/0 (rustc-warning-clean)
  • cargo +1.89.0 build (MSRV) + cargo build --locked — pass
  • aarch64 cross-build (lib + tests + examples, -D warnings) — clean; CI macos-latest (aarch64) green

No tests deleted or skipped.

All 26 clippy errors fixed across src/, tests/, and examples/:
- manual_is_multiple_of (13×): x % n == 0 → x.is_multiple_of(n),
  stable since 1.87, safe on MSRV 1.89
- manual_range_contains (2×): negated range comparisons →
  !(a..=b).contains(&x)
- manual_repeat_n (1×): repeat(v).take(n) → repeat_n(v, n),
  stable 1.82
- too_many_arguments (7×): #[allow] with justifying comment on
  scan_b2_fastscan_avx512, scan_b2_fastscan_scalar,
  scan_via_lut_scalar (src), finalise_row, bench_two_stage,
  bench_two_stage_batched, bench_sign_two_stage_batched (examples)
- needless_range_loop (9×): #[allow] on all SIMD kernel loops
  (bitmap.rs AVX-512 kernels, sign_bitmap.rs AVX-512 kernel,
  fastscan.rs scalar finalize) plus two clear mechanical rewrites
  in tests/rank_index/quant.rs and two #[allow] in
  tests/rank_index/index.rs (raw index used in assertion message)

cargo fmt --all run; reformatted bitmap.rs, fastscan.rs and
several test/example files. No behavior change.
Old lockfile was version 3 and still listed serde as a transitive
dependency that no longer exists in the dependency tree. Regenerated
with `cargo generate-lockfile`; new lockfile is version 4, contains
no serde entries, and passes `cargo build --locked` and
`cargo test --locked`.
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Apply cargo fmt and fix 26 clippy lints; regenerate Cargo.lock

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Applied cargo fmt across all source, test, and example files
• Fixed 26 clippy lints via mechanical rewrites and justified #[allow] attributes
  - manual_is_multiple_of (13×): replaced x % n == 0 with x.is_multiple_of(n)
  - manual_range_contains (2×): replaced negated range comparisons with !(a..=b).contains(&x)
  - manual_repeat_n (1×): replaced repeat(v).take(n) with repeat_n(v, n)
  - too_many_arguments (7×): added #[allow] on kernel functions with intrinsic arity
  - needless_range_loop (9×): added #[allow] on SIMD kernel loops and raw pointer arithmetic
• Regenerated Cargo.lock from version 3 to version 4, removing stale serde dependency
Diagram
flowchart LR
  A["Source/Test/Example Files"] -->|cargo fmt| B["Formatted Code"]
  B -->|clippy fixes| C["Lint-Clean Code"]
  C -->|manual rewrites| D["is_multiple_of, range_contains, repeat_n"]
  C -->|justified allows| E["SIMD kernels, too_many_arguments"]
  F["Cargo.lock v3"] -->|regenerate| G["Cargo.lock v4"]
  G -->|remove stale| H["No serde dependency"]

Loading

File Changes

1. examples/bench_rank.rs Formatting +141/-63

Format and add clippy allow attributes

examples/bench_rank.rs


2. src/rank.rs Formatting +15/-8

Add needless_range_loop allow and format assertions

src/rank.rs


3. src/rank_index/bitmap.rs ✨ Enhancement +19/-29

Replace modulo with is_multiple_of, add allow attributes

src/rank_index/bitmap.rs


View more (17)
4. src/rank_index/fastscan.rs Formatting +10/-19

Add too_many_arguments allow and format macro calls

src/rank_index/fastscan.rs


5. src/rank_index/index.rs Formatting +5/-1

Format struct initialization

src/rank_index/index.rs


6. src/rank_index/multi_bucket.rs Formatting +3/-6

Format iterator chain

src/rank_index/multi_bucket.rs


7. src/rank_index/quant.rs ✨ Enhancement +30/-15

Replace modulo with is_multiple_of, format function calls

src/rank_index/quant.rs


8. src/rank_index/quant_kernels.rs Formatting +13/-8

Add too_many_arguments allow and format assertions

src/rank_index/quant_kernels.rs


9. src/rank_index/util.rs Formatting +2/-7

Format conditional expression and function signature

src/rank_index/util.rs


10. src/rank_io.rs ✨ Enhancement +11/-21

Replace modulo checks with is_multiple_of and range contains

src/rank_io.rs


11. src/sign_bitmap.rs ✨ Enhancement +10/-11

Replace modulo with is_multiple_of, add allow attributes

src/sign_bitmap.rs


12. tests/rank_index/bitmap.rs Formatting +40/-23

Reorder imports and format assertions

tests/rank_index/bitmap.rs


13. tests/rank_index/fastscan.rs Formatting +15/-7

Reorder imports and format iterator chains

tests/rank_index/fastscan.rs


14. tests/rank_index/index.rs Formatting +3/-1

Reorder imports and add allow attributes

tests/rank_index/index.rs


15. tests/rank_index/main.rs ✨ Enhancement +14/-11

Reorder imports and replace repeat with repeat_n

tests/rank_index/main.rs


16. tests/rank_index/multi_bucket.rs Formatting +2/-2

Reorder imports

tests/rank_index/multi_bucket.rs


17. tests/rank_index/quant.rs ✨ Enhancement +17/-14

Reorder imports and refactor loop to iterator

tests/rank_index/quant.rs


18. tests/redteam_alpha.rs Formatting +21/-6

Format iterator chains and map expressions

tests/redteam_alpha.rs


19. tests/redteam_beta.rs Formatting +11/-29

Format filter chains

tests/redteam_beta.rs


20. tests/redteam_delta.rs Formatting +7/-5

Format file path construction

tests/redteam_delta.rs


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented May 22, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request primarily focuses on code formatting, dependency cleanup, and minor refactoring for idiomatic improvements and lint compliance. Key changes include updating Cargo.lock to version 4, removing serde and its related sub-crates, and applying extensive formatting across the codebase, such as reordering imports and breaking long function signatures into multiple lines. The PR also introduces several clippy allow attributes for intentional manual indexing and high-arity functions, replaces manual modulo checks with is_multiple_of, and refactors various test loops and assertions for better readability. I have no feedback to provide as no review comments were submitted.

The x86 SIMD dispatch (select_simd_tier + the SimdTier match arms, the AVX
kernels, BATCHED_AVX512_CHUNK) is cfg(target_arch=x86_64)-gated, but the glue
it references — the SimdTier::Avx2/Avx512 variants, the batched-chunk consts,
and the simd_tier / centre_drop_used bindings — was defined unconditionally.
On non-x86 (aarch64 / macos-latest CI) those are dead/unused and, under
RUSTFLAGS=-D warnings, fail the build with 7 dead_code/unused errors.

Add cfg_attr(not(target_arch=x86_64), allow(...)) to each so the crate builds
clean on aarch64 (scalar path) while x86 is untouched. Verified: aarch64 lib +
tests + examples compile clean under -D warnings; x86 fmt/clippy/test 80/86.
@Fieldnote-Echo
Nelson Spence (Fieldnote-Echo) deleted the prod/hygiene branch May 23, 2026 00:08
Nelson Spence (Fieldnote-Echo) added a commit that referenced this pull request May 23, 2026
… review)

Address the bot review wave (gemini/Codex/qodo) — all "convert core panics to
clean Python errors", completing the binding's boundary-guard design:

- Width validation (check_width): every f32 input now checks ncols == dim (2-D)
  / len == dim (1-D). The core derives n = len/dim and only asserts divisibility,
  so a wrong-but-divisible shape (e.g. (1,128) into a dim-64 index) was silently
  reinterpreted as a different vector count, or panicked on the result reshape.
  Now a clean ValueError. (gemini x3 critical, Codex x2 P1, qodo #3)
- Constructor validation: Rank/RankQuant/Bitmap/SignBitmap `new` return PyResult
  and validate against the EXACT core asserts (dim in [2, u16::MAX]; bits in
  {1,2,4} + dim multiple of 8/bits and 2^bits; dim % 64 + 0 < n_top < dim;
  dim % 64 + <= MAX_SIGN_BITMAP_DIM) -> ValueError instead of panic. (gemini x4)
- swap_remove (Rank, RankQuant): bounds-check -> IndexError, not panic.
  (gemini high, qodo #4)
- README provenance tightened to the canonical "developed within turbovec,
  factored out" phrasing. (qodo #2)

Tests: +9 (width-mismatch x6, swap_remove OOB x3); constructor-rejection tests
tightened from BaseException to ValueError. Suite now 117 passed + 1 xfail.
clippy -D warnings + fmt clean; MSRV 1.89 builds core + binding.

Not changed: qodo #1 (ndarray via numpy) is a deliberate, documented core-vs-
binding split (deps grep + publish scoped to -p ordvec; the core's published lock
is clean; the binding is publish = false, PyPI-only) -- explained on-thread.
Nelson Spence (Fieldnote-Echo) added a commit that referenced this pull request May 25, 2026
… (qodo)

Two robustness fixes to part (2) of release_publish_invariants.sh:

- Publish-scoped (qodo #1): step_line grepped the whole workflow with head -1,
  so a download-artifact in another job could satisfy the ordering even if the
  publish job regressed. Now extract the 'publish:' job body (its key to the next
  2-space-indented job key or EOF) and search only within it.

- Multi-line aware (qodo #4): the cleanup was anchored on a single-line 'run:',
  so a 'run: |' block would false-fail. Now match the delete command on its own
  line, so both 'run: ... -delete' and a multi-line 'run: |' block work — still
  requiring a real delete ('find ... -delete' or 'rm ... *.cdx.json').

Verified A-G: passes on the real workflow and multi-line run:| (F); fails on
removed / reordered-in-publish / comment-only / non-deleting-find; and is no
longer fooled by a decoy download-artifact in another job (G).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant