From ea765410b686c3ddbafbebb8b6362ff0cdd427a6 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Sep 2026 04:04:38 +0000 Subject: [PATCH] sigker: fix both clippy findings and arm the lint in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes TD-SIGKER-CLIPPY-RED-ON-BASE-1. sigker now passes `cargo clippy --manifest-path crates/sigker/Cargo.toml --all-targets -D warnings`. TWO findings, not the one the tech-debt entry claimed: 1. signature.rs — `segment_signature`'s level-fill loop used its loop variable only to index `level` (needs_range_loop). Rewritten as `level.iter_mut().enumerate()`; behaviour-identical, same traversal, same arithmetic. 2. examples/depth_scaling.rs — `doc list item overindented` on a wrapped list continuation. THIS WAS INVISIBLE until (1) was fixed: `-D warnings` makes clippy abort at the first error, so the entry's "single site" claim was a lower bound read off a run that never got past the first failure, not a total. Recorded in the entry rather than quietly corrected. Also armed the lint in CI. The sigker step added earlier was deliberately tests-only because the crate was red on arrival; with both findings fixed that reason is gone, and a lint fix with no gate decays straight back — this crate was unlinted precisely because no CI step reached it (workspace-excluded, so root clippy never sees it). Tests + clippy now both run. The tech-debt entry needed re-anchoring, for a reason worth stating: it cited `signature.rs:133` anchored on `for flat in 0..len`, and DELETING that line is the fix — so applying it made the entry's own citation decay, and citation_decay.py fired on it. An entry that cites the code it wants removed is self-invalidating by construction. Re-anchored on the enclosing function name, `segment_signature`, which survives its own body being rewritten. That is the property a citation into mutable source actually needs, and it is the second time this session the gate has corrected a citation of mine. While rewriting the overindented line, also qualified its "7-13x smaller" claim as asymptotic (N>=8, ~2x at shallow depth) with a pointer to the crate's own falsifier test — the same misquote E-A-SKETCH-THAT-MISSED-TWICE-WILL-MISS- A-THIRD-TIME-1 flagged in the consumer contract, propagated here too. Verified locally, all gates green against origin/main: - cargo clippy --all-targets -D warnings: 0 errors - cargo test: 62 passed, 0 failed - cargo fmt --check: clean - citation_decay.py --since origin/main: 0 new decays (148 backlog unchanged) - append_only_gate.py origin/main: no protected file shrank, 9 checked - supersession_index.py: current, byte-identical - plan_dids.py: no added plans Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016WkNBjHc2e3zuyz9i8qJEv --- .claude/board/TECH_DEBT.md | 33 ++++++++++++++++++------- .github/workflows/rust-test.yml | 19 ++++++++------ crates/sigker/examples/depth_scaling.rs | 3 ++- crates/sigker/src/signature.rs | 4 +-- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/.claude/board/TECH_DEBT.md b/.claude/board/TECH_DEBT.md index 797036f7a..5422e92cf 100644 --- a/.claude/board/TECH_DEBT.md +++ b/.claude/board/TECH_DEBT.md @@ -1,15 +1,31 @@ -## TD-SIGKER-CLIPPY-RED-ON-BASE-1 (2026-09-04) — OPEN +## TD-SIGKER-CLIPPY-RED-ON-BASE-1 (2026-09-04) — RESOLVED 2026-09-04 **`crates/sigker` does not pass `cargo clippy --all-targets -- -D warnings`, and did not before this session's changes.** Measured by stashing the working tree and re-running against the base commit: the failure reproduces identically. -Single site: `crates/sigker/src/signature.rs:133` — `for flat in 0..len` trips -clippy's needs_range_loop lint: the loop variable is used only to index `level`. - -(Anchored on the loop header, not on the lint name. The lint name is not text -that appears at the cited line, so citing it as the anchor is exactly the decay -`citation_decay.py` exists to catch — it flagged this entry's first draft.) +> **⊘ RESOLVED 2026-09-04.** Both findings fixed; sigker now passes +> `cargo clippy --manifest-path crates/sigker/Cargo.toml --all-targets -- -D warnings` +> clean, and the CI step below was promoted from tests-only to tests+clippy so +> it cannot silently return. Two things this entry got WRONG, recorded rather +> than edited away: +> +> 1. **"Single site" was wrong — there were TWO.** `-D warnings` makes clippy +> stop at the first error, so `doc list item overindented` in +> `examples/depth_scaling.rs` was invisible behind the loop finding and only +> appeared once that one was fixed. A findings count taken from a run that +> aborted on the first error is a lower bound, never a total. +> 2. **The citation decayed the moment the fix landed** — deleting the cited +> line IS the fix, so the anchor `for flat in 0..len` went absent and +> `citation_decay.py` fired on this very entry. Re-anchored below on the +> enclosing function, which survives the change. An entry that cites the +> code it wants deleted is self-invalidating by construction. + +Site: `segment_signature` in `crates/sigker/src/signature.rs:122` — the +level-fill loop used its loop variable only to index `level`, tripping +needs_range_loop. Anchored on the function name, not the loop body: a function +name survives its own body being rewritten, which is exactly the property a +citation into mutable source needs. ```rust for flat in 0..len { // clippy: needs_range_loop @@ -19,8 +35,7 @@ for flat in 0..len { // clippy: needs_range_loop } ``` -Proposed fix (3 lines, mechanical, deliberately NOT applied here to avoid -widening a wiring PR): +Fix, as applied: ```rust for (flat, slot) in level.iter_mut().enumerate() { diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index c9be8a552..68e830bca 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -210,15 +210,20 @@ jobs: # # Verified locally before landing: 62 passed, 0 failed. # - # Deliberately TESTS ONLY, on the causal-edge precedent above. A - # `clippy -D warnings` step would be red on arrival: the crate carries one - # pre-existing finding at signature.rs:133 (needs_range_loop), which - # reproduces identically on the base commit and is NOT in the - # randomized.rs this PR touches. Gating it here would fail this PR for a - # defect it did not introduce; it is recorded in TECH_DEBT - # TD-SIGKER-CLIPPY-RED-ON-BASE-1 instead, with its patch. + # TESTS + CLIPPY. This step was tests-only when first added, because the + # crate was clippy-red on arrival (TD-SIGKER-CLIPPY-RED-ON-BASE-1) and + # gating it would have failed that PR for a defect it did not introduce. + # Both findings are now fixed, so the clippy half is armed here: a lint + # fix with no gate decays back, and this crate's whole reason for being + # unlinted was that no step reached it. + # + # Verified locally before landing: 62 tests passed, clippy clean. - name: Run sigker tests (workspace-excluded, ndarray sibling) run: cargo test --manifest-path crates/sigker/Cargo.toml + - name: Lint sigker (workspace-excluded, so root clippy never reaches it) + run: | + cargo clippy --manifest-path crates/sigker/Cargo.toml \ + --all-targets -- -D warnings # lance-graph-callcenter UNDER `--features query` — the same blind gate as # supervisor above, but one level subtler: the crate was not merely # untested, it has `default = []`, so even a bare `cargo test` on it would diff --git a/crates/sigker/examples/depth_scaling.rs b/crates/sigker/examples/depth_scaling.rs index 80c5eb527..c524e885c 100644 --- a/crates/sigker/examples/depth_scaling.rs +++ b/crates/sigker/examples/depth_scaling.rs @@ -3,7 +3,8 @@ //! - Truncated kernel: O(d^(2N)) per pair, materializes the signature //! - Goursat-PDE kernel: O(T₁·T₂) per pair, NEVER materializes the signature //! - Log-signature: O(d^(2N)) compute (still has Magnus expansion), -//! but storage is dim L_N(d) — 7-13× smaller +//! but storage is dim L_N(d) — 7-13× smaller (asymptotic, N≥8; ~2× at +//! shallow depth, per `compression_at_shallow_depth_is_far_below_the_headline`) //! //! Run: //! cargo run --manifest-path crates/sigker/Cargo.toml \ diff --git a/crates/sigker/src/signature.rs b/crates/sigker/src/signature.rs index 29570d3dd..23e59302e 100644 --- a/crates/sigker/src/signature.rs +++ b/crates/sigker/src/signature.rs @@ -130,7 +130,7 @@ fn segment_signature(delta: &[f64], depth: usize) -> Signature { let mut level = vec![0.0; len]; // Outer-product expansion of Δ ⊗ ⋯ ⊗ Δ (k times) divided by k! // Index mapping: flat_idx = i₁ · d^(k-1) + i₂ · d^(k-2) + … + iₖ. - for flat in 0..len { + for (flat, slot) in level.iter_mut().enumerate() { let mut idx = flat; let mut prod = 1.0; for _ in 0..k { @@ -138,7 +138,7 @@ fn segment_signature(delta: &[f64], depth: usize) -> Signature { idx /= dim; prod *= delta[ax]; } - level[flat] = prod / factorial; + *slot = prod / factorial; } levels.push(level); }