Lean formalisation attribution + SearchResults #[must_use] (external-review quick fixes)#89
Conversation
The README and docs/RANK_MODES.md claimed the rank-transform monotone- reparametrisation invariance was machine-checked in Lean without linking an artifact, and RANK_MODES still said the Bayes-optimality theorem was not claimed. Both are now public, sorry-free Lean 4 proofs: - ordinal (rank) invariance under strictly monotone reparametrisation -> Project-Navi/takens-formalization (isOrdinalPatternOf_comp_strictMono) - in-model Bayes-threshold optimality of the popcount overlap cutoff + exact hypergeometric null -> Fieldnote-Echo/ordvec-formalization (exists_uniformBitmapOverlapTail_finiteBayesRisk_le_and_hypergeomTail) Link both and keep the in-model scoping explicit (optimal under the modeled MLR/FNCH assumptions, not a claim that any corpus obeys them). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Discarding a search result is a silent no-op footgun: e.g. `index.search_asymmetric(&queries, 10);` does the work and drops it. Annotate SearchResults (covers every search* method that returns it) and the pure top_m_candidates* query methods on Bitmap/SignBitmap so the compiler warns on an unused result. Compile-only metadata; no runtime change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Review Summary by QodoAdd #[must_use] to SearchResults and correct Lean formalization attribution
WalkthroughsDescription• Add #[must_use] attribute to SearchResults and candidate-generation methods - Prevents silent no-op footgun of discarding search results - Covers all search* methods and top_m_candidates* on Bitmap/SignBitmap • Correct and expand Lean formalization attribution in documentation - Link ordinal invariance proof to takens-formalization repo - Link Bayes-optimality theorem to ordvec-formalization repo - Clarify in-model scoping of optimality result (not corpus-level claim) Diagramflowchart LR
A["SearchResults & top_m_candidates methods"] -->|"Add #[must_use] attribute"| B["Compiler warns on unused results"]
C["README & RANK_MODES.md"] -->|"Link to Lean repos"| D["takens-formalization<br/>ordvec-formalization"]
D -->|"Clarify in-model scope"| E["Explicit assumptions documented"]
File Changes1. src/bitmap.rs
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Code Review
This pull request updates the documentation in README.md and docs/RANK_MODES.md to reference the Lean 4 formalizations of ordinal invariance and the bitmap candidate filter. It also adds #[must_use] attributes to several candidate generation functions in src/bitmap.rs and src/sign_bitmap.rs, as well as the SearchResults struct in src/lib.rs. The review comments suggest minor grammatical improvements to the documentation and recommend adding descriptive warning messages to the #[must_use] attributes to ensure consistent and informative compiler warnings.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR applies a small set of “fix now” items from an external review: it corrects/clarifies Lean formalisation attribution in the docs, and adds #[must_use] to search/candidate-result-returning APIs to prevent silent result dropping.
Changes:
- Update README +
docs/RANK_MODES.mdto attribute two distinct Lean 4 proofs to the correct external repositories and to clarify the “in-model” nature of the optimality claim. - Add
#[must_use]toSearchResultsto warn on ignored search results. - Add
#[must_use]toBitmap/SignBitmaptop_m_candidates*methods to warn on ignored candidate sets.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/sign_bitmap.rs | Adds #[must_use] to candidate-generation APIs to prevent silently ignored results. |
| src/lib.rs | Marks SearchResults as #[must_use] to warn when search outputs are dropped. |
| src/bitmap.rs | Adds #[must_use] to candidate-generation helpers (single, batched, chunked). |
| README.md | Corrects Lean formalisation attribution and clarifies theorem scope (“in-model”). |
| docs/RANK_MODES.md | Updates the research-program section to reflect the now-checked formal link and reiterates scope limits. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82801039a5
ℹ️ 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".
- SearchResults #[must_use]: reword (Copilot) — the scan already ran, so a dropped result discards work; it is not a no-op. - top_m_candidates* (Bitmap/SignBitmap): add descriptive #[must_use] messages for consistency (gemini). - README: 'on which the rank transform rests' grammar (gemini). Declined: RANK_MODES 'rather than claiming that' reword — kept 'not a claim that' parallel with the README. Codex's theorem-name finding is a false alarm (it read a pre-sweep snapshot of ordvec-formalization; the headline theorem is real at HEAD) — name-stability guard tracked in ordvec-formalization#5. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
Review triage (pushed in
|
| Finding | Reviewer | Disposition |
|---|---|---|
SearchResults #[must_use] message says "no work" — misleading |
Copilot | Fixed — reworded: the scan already ran, so a dropped result discards work |
Add descriptive messages to the top_m_candidates* #[must_use] (×5) |
gemini | Fixed — added consistent messages |
| README: "on which the rank transform rests" grammar | gemini | Fixed |
| RANK_MODES: "rather than claiming that" | gemini | Declined — kept not a claim that parallel with the README's matching caveat |
README headline theorem "not defined" in ordvec-formalization |
Codex | False alarm — the theorem is real at HEAD (BitmapCalibration.lean:305); the review read a pre-sweep snapshot (the name it cites, overlapNull_threshold_isBayesOptimal, was renamed away by b4205e2). Filed a name-stability guard upstream: Fieldnote-Echo/ordvec-formalization#5 |
Gate re-run green: fmt / clippy --all-targets --all-features -D warnings / cargo test (all suites pass).
What
The "fix now" slice of triaging an external technical review of v0.2.0. The remaining 13 recommendations are filed as #80–#88 (+ comments on #32/#33). Two changes here:
1.
docs:correct the Lean formalisation claims (README +docs/RANK_MODES.md)The README claimed the rank-transform monotone-reparametrisation invariance was "machine-checked in Lean" with no link, and
docs/RANK_MODES.mdstill said the Bayes-optimality theorem was "not claimed here". Both are now public,sorry-free Lean 4 proofs — but in two repos, proving two different theorems:Project-Navi/takens-formalization(isOrdinalPatternOf_comp_strictMono)Fieldnote-Echo/ordvec-formalization(exists_uniformBitmapOverlapTail_finiteBayesRisk_le_and_hypergeomTail)Now attributes the right theorem to the right repo, with the in-model conditional kept explicit — optimal under the modelled MLR/FNCH assumptions, not a claim that any corpus obeys the model (whether real neighbours clear the bar stays empirical, per §6/§7).
2.
feat:#[must_use]onSearchResults+top_m_candidates*Discarding a search result is a silent no-op footgun —
index.search_asymmetric(&queries, 10);does the work and drops it. AnnotatesSearchResults(covers everysearch*method returning it) and the puretop_m_candidates*query methods onBitmap/SignBitmap. Compile-only metadata; no runtime change.Test plan
cargo fmt --all --checkcargo clippy --all-targets --all-features -- -D warnings— compiles all tests, so would catch any in-tree discarded#[must_use]value; cleancargo test— 131 passedFollow-ups (not in this PR)
Filed from the same review, with corrections baked in: #80 (remove
ordered-float— viaf32::total_cmp, not the review'ssort_unstablewhich would break the documented stable tie-break), #81 (Debug), #82 (serde), #83 (iteratoradd), #84 (fastscan feature-gate), #85 (parallelfeature — scoped;no_stdis a bigger lift than the review implied, sincewrite/loadarestd-only), #86 (try_*/Result), #87 (C-ABI), #88 (tombstone). Dropped: real-corpus harness (lives inordvec-harness) and Criterion (cuts against the self-containedbench_rank).🤖 Generated with Claude Code