Skip to content

Clear the clippy backlog by hand — 121 warnings the -D warnings gate will fail on - #145

Merged
AdaWorldAPI merged 4 commits into
mainfrom
claude/lint-backlog
Sep 6, 2026
Merged

AdaWorldAPI merged 4 commits into
mainfrom
claude/lint-backlog

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Sep 6, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #144. That PR fixed only what the 1.98 toolchain move broke —
the two chunks_exact_to_as_chunks sites and the two iter_kv_map sites that
turned the cargo xtask verify gate red. This PR clears the rest of the
backlog the same sweep surfaced — the warnings the gate's -D warnings turns
into errors — across 28 files in 9 crates.

Measured end state: aiwar-ingest, neural-debug, notebook-query and
graph-flow are clippy-clean. cockpit-server has 36 findings left,
and what they are is the one open question on this PR (see below).

Based on main (post-#144 merge), not stacked on the merged branch.

Method

Every edit was made by hand. cargo clippy --fix was run once, inspected,
and reverted before any of this work: its unused_* machinery rewrites code
whose value is a product decision, and a lint pass is not where that decision
belongs. The captured autofix diff was 749 lines.

Fan-out was five workers on disjoint file sets (a shared file is a
lost-write race), each briefed to edit only — no cargo, no git, no
worktree — with compilation and linting done centrally afterwards. Each was
told explicitly not to delete anything reported "never used" / "never
read" / "never constructed", and to report it instead.

What changed

Behaviour-preserving rewrites:

lint sites rewrite
collapsible_if 11 edition-2024 let-chains; every merged site was verified to have no else on either arm
needless_borrows_for_generic_args 19 dropped & in assert! / panic! / println! format args
get_unwrap 14 get(k).unwrap() → &map[k] in tests — same panic, different message
redundant_closure 2 pass the fn item to spawn_blocking
unused_imports 8 removed, each verified to have no remaining use in its file
needless_return 3 the cfg(not(instrument)) arms; each return was already the tail expression
misc .map_or(false, f) → .is_some_and(f); .ok().is_some_and(f) → .is_ok_and(f); Iterator::last → .next_back(); let ... else { return None } → ?; .map(|s| s.clone()) → .cloned(); sort_by(cmp) → sort_by_key(Reverse(..)); manual find loop → .find(..); unused State params → _state; one unnecessary mut; one unreadable literal regrouped (identical value)

Two places the clippy suggestion was not taken verbatim

manual_clamp is not behaviour-preserving here. It rewrites
w.min(1.0).max(0.0) as w.clamp(0.0, 1.0), and the two disagree on NaN:
f64::min returns the non-NaN operand, so the old chain turned a NaN weight
into 1.0 — maximum confidence — while clamp propagates NaN into the truth
value. The weight comes from w.parse::<f64>() on a graph column, and Rust's
float parser accepts "NaN", so it is reachable. Kept clamp and added
.filter(|w| w.is_finite()) ahead of it, so a non-finite weight falls back to
the default frequency instead of becoming certainty. A comment records why.

doc_lazy_continuation in osm_features.rs fired because a wrapped
>=95% was opening an accidental rustdoc blockquote mid-sentence. Clippy's
suggestion is to mark the five continuation lines as quoted; that silences the
lint but renders five lines of ordinary prose as a blockquote they were never
meant to be. Escaped the > instead (\>=95%), which removes the blockquote
entirely and the lint with it.

Reported, deliberately not fixed

About 30 never used / never read / never constructed findings across
cockpit-server (main.rs, codebook.rs, openai.rs, graph_engine.rs,
scene_player.rs), osm_artifact_manager.rs, osm_tiles.rs and
notebook-query. Deleting them is a product decision, not a lint fix, and the
stubs/ crates deliberately mirror an upstream API surface. Also left alone:
five new()-without-Default suggestions in stubs/ for the same reason, a
compute with 11 arguments, and a "very complex type" on decode_tile_bin —
all design-level.

One genuine smell surfaced and not silenced:
osm_features.rs:2374's assert!(GEOMETRY_CITY_BUDGET > GEOMETRY_OVERVIEW_BUDGET)
compares two consts, so it folds at compile time and can never fail at
runtime. Flagged rather than removed.

Formatting

rustfmt was not run on aiwar-ingest, neural-debug or stubs/. Those
files carry substantial pre-existing drift at HEAD (measured: 27, 52, 77, 133,
1986, 564, 297, 205, 92, 192 and 79 lines respectively), so formatting them
would bury the lint fixes in several thousand lines of unrelated churn. Files
that were already rustfmt-clean stayed clean.

Verification

Run locally, CARGO_PROFILE_DEV_DEBUG=0 CARGO_INCREMENTAL=0, all --all-targets:

crate result
neural-debug clean
aiwar-ingest clean
notebook-query clean
graph-flow clean
cockpit-server 36 findings remain — see below

cargo build --workspace and cargo nextest run --workspace are not runnable
in this sandbox (nextest is absent, and the tree links v8, aws-lc-sys and
datafusion against a ~1.7 GB remaining disk budget).

⚠️ There is no CI on this fork, so nothing else will run either

Worth stating plainly, because it changes what "wait for CI" means here.
.github/workflows/test-suite.yml:29 reads:

name: Run test suite
if: github.repository == 'quarto-dev/q2'

ts-test-suite.yml, hub-client-e2e.yml, release.yml and
cleanup-caches.yml carry the same guard. That job is the one holding
cargo fmt --all -- --check, cargo xtask lint and the clippy -D warnings
gate — so on AdaWorldAPI/q2 every one of them reports skipped, on this PR
and on every fork PR before it. The green checkmark on #144 was three skipped
jobs.

Two consequences:

  1. The local runs in the table above are the only verification this change
    gets.
    Not a formality — please read them as the gate.
  2. The gate has never run against the fork-only crates. cargo fmt --all -- --check currently reports 189 files needing formatting — aiwar-ingest,
    neural-debug, osint-bake, cpic, stubs/*, cockpit-server — none of
    which exist upstream, so upstream's green gate says nothing about them. It
    would fail on formatting before ever reaching clippy. (It also walks into
    the sibling openstreetmap-website-rs checkout through a path dep, which is
    its own problem for a CI runner.)

That is why this PR deliberately does not run rustfmt on the drifted
files: doing it here would mix a 189-file reformat into a lint cleanup. It is
worth its own PR, and worth deciding whether the fork should un-gate the test
suite so the question stops being invisible.

The 36 that remain, and why I did not touch them

33 of the 36 are dead_code — never used / never read /
never constructed. They are not a lint problem, they are a question about
what this crate is for, and the answer is not mine to assume:

group items
unwired feature surface resolve_garmin_{map,scene,drape,contours}, garmin_scene_slugs, morton_interleave, morton_deinterleave, stride_for, mime_from_path, publish_lifecycle, publish_artifact
unwired codebook surface token_to_index, tokens_to_indices, extract_cypher_identifiers, default_distance_table, CODEBOOK_SIZE, CYPHER_KEYWORDS, MAX_IDENTIFIERS_PER_CALL, NAMESPACE (×6)
wire-schema DTOs whose fields nothing reads openai.rs request/response structs, ErrorResp, ErrorObj, scene_player's source/timestamp, main.rs's jsonrpc
unused methods truth_f, truth_c

There are two defensible dispositions and they differ per group. The DTO group
is the same case as RawNode::node_type in this PR, which I closed with
#[expect(dead_code)] and a comment: the struct documents a wire schema, and
deleting the field leaves a type that is a partial and misleading record of the
protocol. The unwired-surface groups are different — code written ahead of its
caller is a real signal, and blanket-suppressing it buries that signal rather
than resolving it.

So: say which way you want each group to go and I will push it. What I will
not do unprompted is delete them, which is exactly what clippy --fix does.

The remaining 3 are not dead_code:

  • osm_features.rs:2374 — assert!(GEOMETRY_CITY_BUDGET > GEOMETRY_OVERVIEW_BUDGET, ...)
    compares two consts, so it folds at compile time and can never fail at
    runtime. A genuine smell, flagged rather than silenced.
  • osint_gotham.rs:704 — osint_node_rows is more public than BasinPlan,
    the type it takes.
  • osm_features.rs:2246 — decode_tile_bin's return type is flagged
    "very complex".

All three are design-level and would widen this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V

…pampa, neural-debug

Every edit here was made by hand and reviewed. `cargo clippy --fix` was
deliberately not used: its `unused_*` machinery deletes code the author
may still want, and a lint pass is not the place to decide that.

Behaviour-preserving rewrites only:

- `collapsible_if` -> edition-2024 let-chains (9 sites; none had an `else`
  on either arm, so the merge cannot change control flow).
- `get(k).unwrap()` -> `&map[k]` in tests (14 sites). Same panic-on-missing
  behaviour, different message.
- `needless_borrows_for_generic_args` -> dropped the `&` in `assert!`,
  `panic!` and `println!` format arguments (19 sites).
- `redundant_closure` -> pass the fn item directly to `spawn_blocking`.
- `.map_or(false, f)` -> `.is_some_and(f)`; `.ok().is_some_and(f)` ->
  `.is_ok_and(f)`.
- `Iterator::last` on a `DoubleEndedIterator` -> `.next_back()`.
- `let ... else { return None }` -> `?` where the fn already returns Option.
- Unused imports removed (`header`, `ShaderDispatch`, `CallStats`, `Header`);
  unused `State` params renamed to `_state`; an unnecessary `mut` dropped.
- `unneeded_late_init`/`needless_return` in the `cfg(not(instrument))` arms
  of neural-debug: each `return` was that arm's sole statement and therefore
  already the function's tail expression.
- One unreadable literal regrouped (`0x00AB_12u32` -> `0x0000_AB12_u32`,
  identical value).
- `doc_lazy_continuation` in osm_features: a wrapped `>=95%` was opening an
  accidental rustdoc blockquote. Escaped it (`\>=95%`) rather than marking
  five continuation lines as quoted prose they were never meant to be.

Deliberately NOT touched, and reported instead: ~30 `never used` /
`never read` / `never constructed` findings across cockpit-server,
osm_artifact_manager, osm_tiles and codebook. Deleting them is a product
decision, not a lint fix.

Verified: `cargo clippy -p neural-debug -p aiwar-ingest --all-targets` is
clean. The heavier crates are verified in the follow-up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
Same discipline as the previous commit — every edit by hand, no
`clippy --fix`, nothing deleted on a "never used" finding.

- Unused imports removed (`InferenceType`, `nars_deduction`,
  `nars_induction`, `nars_abduction`, `PlanResult`, `HashMap`, `Instant`);
  each verified to have no remaining use in its file.
- `collapsible_if` -> let-chain in `execute_graph_query` (no `else` on the
  outer arm, so the fallthrough to the graph echo is unchanged).
- `sort_by(|a, b| b.len().cmp(&a.len()))` -> `sort_by_key(Reverse(len))`.
- `.map(|s| s.clone())` -> `.cloned()`; `if let Some(x) = r.ok()` ->
  `if let Ok(x) = r`; manual `Iterator::find` loop -> `.find(..)`.
- `if calls > 0 { total / calls / 1000 } else { 0 }` ->
  `checked_div(calls).map(|q| q / 1000).unwrap_or(0)`.
- `revise_edges(&mut Vec<TruthEdge>)` -> `&mut [TruthEdge]`. The body only
  iterates; `grep` over the whole tree finds no caller, and `&mut Vec`
  coerces at any future one.

One clippy suggestion was NOT applied verbatim, because it is not
behaviour-preserving. `manual_clamp` rewrites `w.min(1.0).max(0.0)` as
`w.clamp(0.0, 1.0)`, but the two disagree on NaN: `f64::min` returns the
non-NaN operand, so the old chain turned a NaN weight into 1.0 — maximum
confidence — while `clamp` propagates NaN into the truth value. The weight
comes from `w.parse::<f64>()` on a graph column and Rust's float parser
accepts "NaN", so it is reachable. Kept `clamp` and added
`.filter(|w| w.is_finite())` ahead of it, so a non-finite weight falls back
to the default frequency instead of becoming certainty. Comment records why.

Reported, not fixed: `RawNode::node_type` never read; `compute` takes 11
arguments; five `new()`-without-`Default` suggestions. This crate mirrors an
upstream API surface, so adding `Default` impls is a product decision.

`rustfmt` deliberately not run on these files: they carry 1986/564/297/205/
92/192/79 lines of pre-existing drift at HEAD, which would bury seven lint
fixes in ~3400 lines of unrelated churn.

Verification of `-p notebook-query` is still running at commit time; any
finding it reports lands as a follow-up on this branch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 75 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: c28b1d57-8fa5-457b-b6fa-9b3e7e91a16f

📥 Commits

Reviewing files that changed from the base of the PR and between 1be952d and 68b0510.

📒 Files selected for processing (30)
  • crates/aiwar-ingest/src/encounter_round.rs
  • crates/aiwar-ingest/src/lib.rs
  • crates/cockpit-server/src/main.rs
  • crates/cockpit-server/src/openai.rs
  • crates/cockpit-server/src/osint_gotham.rs
  • crates/cockpit-server/src/osm_features.rs
  • crates/cockpit-server/src/osm_lance.rs
  • crates/cockpit-server/src/osm_slab_hydrate.rs
  • crates/cockpit-server/src/osm_tiles.rs
  • crates/cockpit-server/src/shader_stream.rs
  • crates/neural-debug/src/diagnosis.rs
  • crates/neural-debug/src/instrument.rs
  • crates/pampa/tests/integration/test.rs
  • crates/pampa/tests/integration/test_treesitter_coverage.rs
  • crates/quarto-core/src/engine/capture_splice.rs
  • crates/quarto-core/src/pipeline.rs
  • crates/quarto-core/src/transforms/shortcode_resolve.rs
  • crates/quarto-core/tests/integration/replay_engine.rs
  • crates/quarto-core/tests/integration/website_post_render.rs
  • crates/quarto-hub/src/auth.rs
  • crates/quarto-trace/tests/roundtrip.rs
  • crates/stubs/graph-flow/src/storage.rs
  • crates/stubs/notebook-query/src/analyst.rs
  • crates/stubs/notebook-query/src/diagnostics.rs
  • crates/stubs/notebook-query/src/lib.rs
  • crates/stubs/notebook-query/src/mri.rs
  • crates/stubs/notebook-query/src/orchestrator.rs
  • crates/stubs/notebook-query/src/osint_audit.rs
  • crates/stubs/notebook-query/src/reasoning.rs
  • crates/stubs/notebook-query/tests/gremlin_e2e.rs

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Sep 6, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_80126e8e-092d-4408-a60d-c256888aabd7)

`cargo clippy -p notebook-query --all-targets` came back clean apart from the
five items the previous commit deliberately left for a decision. The gate runs
`-D warnings`, so "reported, not fixed" still fails it — these are now closed,
each in the direction that removes nothing.

- `Default` for `StyleTopology`, `OsintCounter`, `OsintRegistry`: implemented
  as `Self::new()`. Purely additive; the lint fires precisely because each
  `new()` takes no arguments.
- `GraphSensorium::compute` (11 args): `#[expect(clippy::too_many_arguments)]`
  with a reason. The arity mirrors the upstream API this stub stands in for,
  so grouping the counters into a parameter struct would make the stub diverge
  from the thing it exists to mirror.
- `RawNode::node_type` never read: kept, with `#[expect(dead_code)]` and a
  comment. The struct is deserialize-only and documents the shape of
  `aiwar_graph.json`; deleting the field would leave a type that is a partial
  and misleading record of the file it parses.

`#[expect]` rather than `#[allow]` deliberately — it warns if the lint ever
stops firing, so neither suppression can outlive its reason unnoticed.

Verified: `cargo clippy -p notebook-query --all-targets` is now clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
Same closeout as the notebook-query commit, for the other stub crate:
`Session::new()` and `SessionContext::new()` both take no arguments, which is
exactly what makes clippy ask for `Default`. Implemented as `Self::new()` —
additive, nothing removed.

Verified: `cargo clippy -p graph-flow --all-targets` is clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review September 6, 2026 08:32
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@AdaWorldAPI
AdaWorldAPI merged commit b06f85b into main Sep 6, 2026
4 checks passed
AdaWorldAPI pushed a commit that referenced this pull request Sep 6, 2026
…pit build

CodeRabbit flagged `mime_from_path`'s `#[expect(dead_code)]` as unfulfilled under
`--features embed-cockpit`. It was right, and chasing it found something bigger
sitting underneath: with that feature enabled, cockpit-server did not compile at
all.

## The regression, and it is mine

`25f4b940` (the #145 lint sweep) removed `use axum::http::{StatusCode, header}`
down to `StatusCode` alone. `header::CONTENT_TYPE` is used at five sites — 614,
670, 712, 745, 757 — and every one of them is inside a
`#[cfg(feature = "embed-cockpit")]` block. In a default build those blocks are
compiled out, so the import genuinely looks unused and clippy said so. I removed
it. With the feature on:

    error[E0433]: cannot find module or crate `header`   x5

CI never enables `embed-cockpit`, so nothing caught it. The Dockerfile does
(`cargo build -p cockpit-server --features embed-cockpit`), so this has been
broken on the production build path since #145 merged.

Fix: restore the import gated to match its usage, rather than merging it back
into the braced form that caused the problem — a single `use` cannot be
half-gated:

    use axum::http::StatusCode;              // both configurations
    #[cfg(feature = "embed-cockpit")]
    use axum::http::header;                  // only where it is used

## The lint finding that led here

`mime_from_path` keeps its annotation but as `#[allow]`, not `#[expect]`: with
the feature enabled `static_handler` calls it, so no expectation holds in every
configuration. Same structural rule this PR already applied to 18 other items —
I simply failed to apply it here, because my gate only ever ran the default
feature set. That was the real hole: the classification was sound, the
measurement behind it was too narrow.

main.rs now carries 1 `expect` (the `jsonrpc` wire field, dead in every
configuration) and 6 `allow`.

## Verification — both configurations this time

    default, workspace, -D warnings                     0 findings
    --features embed-cockpit, cockpit-server            0 errors
    cargo fmt --all -- --check                          clean

The feature build needs `cockpit/dist` to exist for `include_dir!`; a stub was
created locally to verify and removed afterwards (it is gitignored either way).

## Deliberately NOT fixed here

The feature build still reports 6 style warnings — 3 `needless_return`, 3
`collapsible_if`, at main.rs 629/668/678/710/720/755 — in code that until this
commit could not be compiled, so nothing had ever linted it. They block neither
CI (which does not enable the feature) nor `cargo build`. Left alone because the
`needless_return` fix turns on cfg-dependent tail-expression semantics: those
`return`s are only redundant because the paired `cfg(not(...))` block disappears,
and getting that wrong would re-break the build path this commit repairs. Worth
its own change, not a drive-by on a lint PR.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGVLyRZNEKKBSfBDJfbY3V
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.

2 participants