SearchWala Engineering Log: The v7 to v8.3 Rebuild in Rust, Bug by Bug
Published: November 29, 2026 | Author: SandeepCH | Version: v8.3.1 (Apache-2.0) | Repository: SandeepAi369/SearchWala
SearchWala started life as a Rust meta-search server that looked impressive on paper: 35+ search engines, BoringSSL TLS impersonation, reciprocal rank fusion (RRF), BM25+, MMR reranking, and an offline evaluation suite. When we actually measured a live query end to end at commit 6b05c9e (v7.0), almost every layer underneath the ranking stack was silently failing.
This engineering log documents the bugs we measured, the fixes shipped across v8.0 through v8.3.1, the upstream patches contributed back to Rust dependencies, and the resulting single-binary architecture now serving both the local Web UI and native MCP (searchwala mcp).
1. Measuring v7.0 Before Touching Code
Instead of tuning prompts or adding a reranker on top of broken retrieval, we ran a single reproducible query against v7.0 (amar ujala cricket world cup 2027) and logged what actually entered and exited every stage. The full raw audit is archived in the v8.0 Implementation Blueprint.
| Stage / Metric | Measured in v7.0 (6b05c9e) |
Root Cause |
|---|---|---|
| Engines returning >= 1 result | 4 of 35 dispatched | wreq BoringSSL client was passed as _stealth_client and never called; 28 engines silently returned 0 results |
| URLs chosen for scraping | Arrival order (not RRF) | 85 URLs were RRF-scored, then the first 20 to arrive were scraped; Brave (44) and Yahoo (56) were dropped behind bing_news |
| Extracted text per chunk | 470 chars avg (11,768 chars total) | Ordering bug returned 466-byte <meta> descriptions while an 11,716-byte articleBody sat unread in the same HTML (26x loss) |
| Hindi / Devanagari queries | Task panic (connection reset) | Byte-slicing UTF-8 strings (&q[..q.len().min(50)], &raw[..300]) split multi-byte characters mid-codepoint |
| Evaluation harness | 474 LOC unused | eval.rs and the 50-query golden dataset existed in the repo but were never wired into a binary or CI |
Three lessons came out of that audit:
- Silent zero-result failures are worse than errors. Engines skipped HTTP status checks, so 202 CAPTCHAs, 403 blocks, and 429 rate limits parsed cleanly into empty
Vecs. - Dead code behind
puband_prefixes hides rot.cargo builddid not warn about_stealth_clientor unusedpubmodules. - Downstream ranking cannot fix garbage input. BM25+ and MMR were spending CPU reranking 470-byte meta-descriptions.
2. Fixing Retrieval: Unified Fetcher, BoringSSL, zstd, and Consensus Ranking
Wiring wreq without duplicating every engine
In v7.0, wreq::Client (with BoringSSL Chrome JA4/HTTP2 fingerprint emulation) was constructed per search and ignored. Testing the same blocked queries through wreq turned Brave 429 into 200 (42 .snippet elements) and DuckDuckGo 202 CAPTCHA into 200 (10 primary results + 40 links).
Rather than writing two versions of every engine, v8.0 introduced a single Fetcher enum (src/fetcher.rs) unifying Fetcher::Plain(reqwest::Client) for independent/open engines and Fetcher::Stealth(wreq::Client) for WAF-protected engines, reusing a shared client across searches and enforcing HTTP status validation on every fetch.
The missing zstd feature bug
During v8.0 P0 triage we hit another silent bug: the HTTP client advertised zstd in Accept-Encoding, but reqwest did not have its zstd Cargo feature enabled. Servers responded with compressed zstd frames that arrived as undecodable raw bytes and failed HTML parsing silently. Enabling zstd in Cargo.toml immediately recovered affected responses.
Pruning 28 dead engines to 19 live engines with index-family voting
Dead domains (alexandria, excite, lycos, mullvad_leta, pipilika, searchencrypt) and broken endpoints were removed rather than kept for marketing numbers. SearchWala now dispatches up to 19 live engines across web, news, and scholarly sources (including OpenAlex and arXiv), with index-family consensus ranking:
- Multiple Bing-backed engines count as one independent vote, not seven.
- Real SERP HTML snapshots live in
tests/fixtures/so selector rot breakscargo test --releasein CI instead of silently returning zero results.
3. Fixing Extraction: 10x to 37x More Content per Page
Replacing the v7.0 ad-hoc extractor in Phase 3 (d3a713f) and promoting dom_smoothie in v8.2 (733904e) turned 470-character boilerplate snippets into clean full-article Markdown:
- Primary extractor:
dom_smoothiewithTextMode::Formatted, preserving Markdown headings, code blocks, data tables, and LaTeX math annotations. - Secondary fallback:
rs-trafilaturafor layouts where Readability heuristics under-extract. - Deep Reader + Stage 1 pre-cleaner (
01b8ef9): Zero-allocation pre-cleaner for Next.js hydration payloads, Sandpack code embeds, and AMP variants, plus metadata normalization (modified_time,lang,byline,site_name). - Removed dead fallbacks (
d2b47fa): Stripped redundant ego-tree density and microdata fallbacks oncedom_smoothie+rs-trafilaturacovered those cases cleanly.
Upstreaming fixes to the Rust ecosystem
Real-world web scraping exposed edge cases inside upstream Rust crates that we fixed and submitted back upstream instead of keeping private forks:
niklak/dom_smoothie(merged PRs#249,#250; open PRs#252–#256): preserving data tables and section headings whose CSS class contains"header", replacing MathML with its TeX<annotation>, unwrapping<noscript>fallback content on near-empty pages, and removing"scroll"from negative class penalties. Oncedom_smoothie 0.20.0landed on crates.io, we dropped our local patch (f907355).0x676e67/wreq(merged PR#1389, open PR#1390): cookie store scaling/public-suffix handling and draining bounded 3xx redirect response bodies.
4. Ranking, UTF-8 Safety, and the Offline Eval Harness
With live retrieval and clean extraction restored, we fixed the pipeline plumbing that had been throwing away computed signals:
- Respect RRF before scraping (
32315e9): Top URLs are selected by cross-engine consensus + RRF score rather than network arrival order. - UTF-8-safe string slicing (
ef75b36): Replaced raw byte-index slices with UTF-8-safe helpers (clean.get(..10)and char-boundary truncation) and addedCatchPanicLayerso multi-byte queries (Hindi, CJK, emoji) can never panic a request handler. - Pre-scrape triage and dynamic authority matching (
493a6b4,2aff2ac,9b5e50a): Filters off-topic or stale URLs before fetching, boosts official domains dynamically with zero hardcoded allowlists, applies chunk-level inline date decay, and handles HTTP413payload limits via auto-trim retries without conflating429rate limits. - Wired evaluation binaries (
2131a70,ci.yml): cargo run --release --bin intent_proberuns offline deterministic intent classification and is hard-gated at 50/50 (100%) in CI.cargo run --release --bin eval -- --limit 20 --baseline benchmarks/baseline_v8.jsontracks nDCG@10 (0.341), MRR (0.539), Recall@10/20, and per-engine health across the 50-query golden set.cargo run --release --bin highlight_probeverifies non-LLM verbatim quick answers across 45 saved real queries.
5. v8.1 to v8.3.1: Local SQLite Chats, Native MCP, and Security Hardening
Zero-dependency MCP server in the same Rust binary (80deb86)
In v8.3.0, we added a native Model Context Protocol (MCP) server directly into the searchwala binary so coding agents (Claude Code, Cursor, VS Code, Gemini CLI, Codex) can use SearchWala with zero search API keys and zero LLM API keys:
searchwala mcp(stdio): Speaks JSON-RPC 2.0 (2025-11-25down to2024-11-05), keeps stdout strictly clean for protocol frames, and skips opening~/.searchwala/searchwala.dbso parallel agent processes never contend on SQLite locks.- Streamable HTTP (
/mcp): Mounted automatically alongside the local Web UI on127.0.0.1:8000/mcpor headless viasearchwala mcp --http. - Four focused tools:
search_web,search_passages(withinclude_domains,exclude_domains,strict_domains, anddiscovered_domains),extract_url, andsearch_status, plus three read-onlysearchwala://resources.
Security, packaging, and single-binary footprint (d7b2039, f0dd4b9, 0c7e8a2)
- SSRF protection: Blocks private, loopback, link-local, and cloud metadata ranges, checks DNS rebinding, and re-validates every HTTP redirect hop.
- Supply-chain hardening: Patched
RUSTSEC-2026-0594andRUSTSEC-2026-0592, pinned multi-stage Debian TrixieDockerfilebase images by SHA-256 digest (fixing a glibc 2.41 vs 2.36 builder/runtime mismatch discovered in32399e4), runs non-root inside containers, and enforces SHA-pinned GitHub Actions, CodeQL, dailycargo-audit, and OpenSSF Scorecard. - Zero-config distribution: Published on crates.io (
cargo install searchwala), GitHub Releases, and the Official MCP Registry (io.github.SandeepAi369/searchwala).
6. Snapshot: v7.0 vs v8.3.1
| Metric | v7.0 (6b05c9e) |
v8.3.1 (a5702ab) |
|---|---|---|
| Live working engines | 4 / 35 dispatched | Up to 19 live engines, index-family consensus |
Stealth TLS (wreq BoringSSL) |
Built, unused (_stealth_client) |
Wired via unified Fetcher enum |
| Extraction quality | 470 chars/chunk avg (26x loss) | Full Markdown, tables, LaTeX (dom_smoothie + rs-trafilatura) |
| Runtime memory (RSS) | Unbounded leaks / duplicate clients | ~30 to 80 MB single static-like Rust binary |
| Local persistence | In-memory only | Local SQLite (~/.searchwala/searchwala.db), O(1) history |
| Agent integration | HTTP only | Native stdio + Streamable HTTP MCP server (searchwala mcp) |
| Automated verification | Unwired eval, dead code | 360 tests, real SERP fixtures, 50/50 intent gate, -D warnings |