Skip to content

fix(search): honor case-sensitive fields#139

Merged
oritwoen merged 1 commit intomainfrom
fix/search-case-sensitive-fields
Mar 24, 2026
Merged

fix(search): honor case-sensitive fields#139
oritwoen merged 1 commit intomainfrom
fix/search-case-sensitive-fields

Conversation

@oritwoen
Copy link
Owner

Closes #138

--case-sensitive was narrowing the search surface instead of just changing the comparison mode, so exact-case address prefixes like 1BgGZ missed. The matcher now checks the same fields in both modes, and the CLI test covers the address case plus a real no-match variant.

@oritwoen oritwoen self-assigned this Mar 24, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e1cdfb4e-d6e3-4dcf-a613-ed2b917ad335

📥 Commits

Reviewing files that changed from the base of the PR and between 7c4849b and 99f66f7.

📒 Files selected for processing (2)
  • src/cli.rs
  • tests/cli.rs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
tests/cli.rs

📄 CodeRabbit inference engine (AGENTS.md)

Use assert_cmd for CLI integration tests in tests/cli.rs to verify command behavior and output formats

Files:

  • tests/cli.rs
src/cli.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/cli.rs: Implement CLI binary in src/cli.rs using clap derive macros, not src/main.rs, and gate behind --features cli
In src/cli.rs, use clap for argument parsing, tabled for table output, owo-colors for colored output, and human-panic for panic messages

Files:

  • src/cli.rs
🧠 Learnings (15)
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to tests/author_lineage.rs : In tests/author_lineage.rs, verify funding source tracking and author metadata consistency across all puzzles

Applied to files:

  • tests/cli.rs
  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to tests/cli.rs : Use assert_cmd for CLI integration tests in tests/cli.rs to verify command behavior and output formats

Applied to files:

  • tests/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Define Puzzle struct with exactly 16 fields covering id, title, description, difficulty, status, author, solver, status_date, reward, addresses, keys, seeds, shares, profiles, and metadata

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Use `Option<T>` for all optional fields in puzzle data structures (Address, Key, Seed, Shares, Profile, Author, Solver)

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : For Bitcoin/crypto addresses, include kind field with values: P2PKH (legacy), P2SH (script), P2WPKH/P2WSH (SegWit), P2TR (Taproot)

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Track both Solver (who revealed/found the key) and Claimer (who swept funds) separately in Puzzle struct, as these may be different people

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Use `&'static str` for all string data in Puzzle structs, never heap-allocated Strings

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to data/**/*.jsonc : Store puzzle data in `data/*.jsonc` files, not hardcoded in Rust source code

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/lib.rs : Implement lib.rs public API with three core functions: get(id) for puzzle lookup, all() for iterating puzzles, and stats() for aggregate statistics

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Define Chain enum including Bitcoin, Ethereum, Litecoin, Monero, Decred, and Arweave

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to build.rs : In build.rs, validate that cryptographic key bits match hex representations and WIF↔hex consistency

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to data/hash_collision.jsonc : For hash_collision puzzles, track that these are Peter Todd's P2SH bounties for finding pre-image hash collisions

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to tests/validation.rs : In data validation tests (tests/validation.rs), verify cryptographic consistency (h160, script_hash), range validation, and format checks

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/verify.rs : In src/verify.rs (--features cli), implement cryptographic key→address verification across all supported address types and chains

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to data/solvers.jsonc : In data/solvers.jsonc, define solver identities once with name, addresses[], and profiles[], then reference by ID in puzzle files

Applied to files:

  • src/cli.rs
🔇 Additional comments (3)
src/cli.rs (1)

943-995: Case-sensitive mode now checks the full field surface

This fixes the real failure path: --case-sensitive no longer drops address/pubkey/key/tx scans, so exact-case prefixes like 1BgGZ can match where they should.

Also applies to: 1007-1010, 1015-1019

tests/cli.rs (2)

571-575: Negative case now actually exercises case sensitivity

Using gSmg makes the failure deterministic for case-sensitive mode instead of relying on a query shape that could pass for other reasons.


586-597: Address-prefix regression is now covered

This test hits the exact bug path from #138 by asserting --case-sensitive 1BgGZ matches both puzzle id and full address output.

As per coding guidelines, "Use assert_cmd for CLI integration tests in tests/cli.rs to verify command behavior and output formats."


📝 Walkthrough

Walkthrough

Removed conditional branches gating field searches when case_sensitive was false. Addresses, pubkeys, transaction hashes, and key material now always get scanned—the matches_in function handles actual case sensitivity. Fixes searches like boha search --case-sensitive 1BgGZ failing on address prefixes.

Changes

Cohort / File(s) Summary
Search Logic Fix
src/cli.rs
Removed if !case_sensitive guards wrapping address fields (address.value, address.hash160, address.witness_program), pubkeys, nested key subfields (hex, wif.*, seed.phrase, mini), solver addresses, and transactions. These branches now execute unconditionally; case sensitivity logic delegated to matches_in function.
Test Coverage
tests/cli.rs
Updated case_sensitive_no_match input from "GSMG" to "gSmg" and added new case_sensitive_address_match test asserting that search --case-sensitive 1BgGZ successfully matches the address 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Requires tracing through each field branch removal to confirm matches_in correctly handles case sensitivity. Logic is straightforward (dropping gates, not restructuring), but manual verification of all affected field paths (8+ branches) and test coverage validation adds moderate overhead.

Poem

🔍 Case-sensitive searches now see the light,
No longer hiding addresses from sight—
The gates came down, all fields now fair,
1BgGZ found everywhere! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title directly describes the main change: removing case_sensitive gates from field matching to honor the flag's intent.
Description check ✅ Passed Description explains the bug (flag narrowing search surface), the fix (checking same fields), and test coverage—all directly related to the changeset.
Linked Issues check ✅ Passed PR removes case_sensitive conditionals from address, hash, pubkey, and key field checks [#138], allowing case-sensitive searches to maintain full search surface while only changing comparison mode.
Out of Scope Changes check ✅ Passed All changes directly address issue #138: removing case_sensitive gates in puzzle_matches and adding test coverage for the fix. No unrelated modifications present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/search-case-sensitive-fields
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/search-case-sensitive-fields

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

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: This PR modifies core search matching logic and conditional flows within a primary CLI function, which requires human verification for correctness.

Architecture diagram
sequenceDiagram
    participant User
    participant CLI as CLI Entrypoint
    participant Search as Search Logic (puzzle_matches)
    participant Matcher as Matcher (matches_in)
    participant Registry as Match Registry (record_match)

    User->>CLI: boha search --case-sensitive "1BgGZ"
    CLI->>Search: puzzle_matches(puzzle, case_sensitive=true)

    Note over Search,Matcher: NEW: All fields are now checked regardless of case-sensitivity

    Search->>Matcher: matches_in(puzzle.id)
    opt Match Found
        Matcher-->>Search: position
        Search->>Registry: record_match("id", pos, 0)
    end

    Search->>Matcher: CHANGED: matches_in(puzzle.address.value)
    alt Case-Sensitive Match
        Matcher-->>Search: position
        Search->>Registry: record_match("address.value", pos, 1)
    else No Match
        Matcher-->>Search: None
    end

    Search->>Matcher: CHANGED: matches_in(puzzle.pubkey.value)
    opt Match Found
        Matcher-->>Search: position
        Search->>Registry: record_match("pubkey.value", pos, 4)
    end

    Note over Search,Matcher: Loop continues for Hash160, Keys, WIF, and TXIDs

    Search-->>CLI: Return matches
    CLI-->>User: Display results (e.g., "1BgGZ9tc...")
Loading

@oritwoen oritwoen merged commit 733de37 into main Mar 24, 2026
6 checks passed
@oritwoen oritwoen deleted the fix/search-case-sensitive-fields branch March 24, 2026 15:02
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.

Case-sensitive search skips address fields

1 participant