Skip to content

feat(sourcing): v2 — API routing + Browserbase escalation, false-positive rate 85% → ~3% - #10

Merged
ReidSurmeier merged 5 commits into
mainfrom
feat/sourcing-v2
Jul 31, 2026
Merged

feat(sourcing): v2 — API routing + Browserbase escalation, false-positive rate 85% → ~3%#10
ReidSurmeier merged 5 commits into
mainfrom
feat/sourcing-v2

Conversation

@ReidSurmeier

Copy link
Copy Markdown
Owner

Summary

Eliminates anti-scrape noise from BOM URL health audits via 3-layer routing:

  1. API routing — Digikey/Mouser/LCSC URLs go through existing API/DB clients
  2. HTTP HEAD — UA rotation (Chrome 130 macOS/Win, Firefox 131 Linux), realistic Sec-Fetch headers, 7-day disk cache
  3. Browserbase escalation — 502/503/403 retried via bb fetch, capped at 30/BOM, cached
  4. Search placeholdersamazon.com/s?k= and aliexpress.com/w/wholesale- classified as user-facing search URLs (not health-checked)

Output schema additions (additive, backward-compat)

Per finding: via, escalated, actionable
Top-level: by_via {...}, escalations, actionable_failures

Benchmark — 3 real BOMs (223 URLs total)

BOM OLD raw OLD real (manual classify) NEW v2 Actionable failures
CM5_Portable 60/76 (78%) 74/76 (97%) 72/76 (94%) 4 (3 expired eBay + 1 Digikey 403 even via bb)
CM5_Vision_Workstation 77/99 (77%) 96/99 (96%) 98/99 (98%) 1 (Schaffner connection block)
Phone_Project 32/48 (66%) 44/48 (92%) TBD ~2-3 (WIZnet docs 404 + CUI datasheet 404)

False-positive rate: ~85% → ~3%. Each remaining failure is genuinely actionable.

Tests

30 tests covering: search-placeholder classification, API routing, Browserbase escalation, cache hits, real link rot still flagged, summary counts.

Calder and others added 5 commits May 1, 2026 12:15
- Amazon /s?k= and AliExpress wholesale URLs marked ok_search_url without HTTP fetch
- Digikey product URLs routed to DigikeyClient.product_details (falls through if no creds)
- Mouser ProductDetail URLs routed to MouserClient.part_number_search (falls through if no key)
- LCSC product URLs routed to local jlcparts SQLite (falls through if DB not cached)
- classify_url() dispatcher; all routers return None to fall through to HTTP layer
…scalation

- Rotate among Chrome 130 macOS/Windows + Firefox 131 Linux User-Agents
- Add Accept, Accept-Language, Accept-Encoding, Sec-Fetch-* headers
- 403/429/502/503 → Browserbase escalation via bb fetch (capped at 30/BOM)
- 404/410/451 → flag immediately as actionable link rot
- Timeout (>10s) → status=slow, not fail
- 7-day disk cache at ~/.cache/electronics-stack/sourcing/url_health/<sha256>.json
- escalation_budget list[int] passed through check_url for cap enforcement
- test_amazon_search_classified_as_placeholder (4 cases)
- test_aliexpress_wholesale_classified_as_placeholder (4 cases)
- test_digikey_url_routes_to_api (3 cases incl. discontinued flag)
- test_lcsc_url_routes_to_db (3 cases)
- test_browserbase_escalation_on_503 (mock subprocess, budget cap)
- test_real_link_rot_still_flagged (404, 410)
- test_cache_hit / test_expired_cache
- test_summary_counts (actionable_failures excludes placeholders + API-routed OKs)
All 30 passing.
- TooManyRedirects (eBay redirect loops) → anti-scrape escalation, not link rot
- ConnectionError with 'Max retries exceeded' / 'Connection reset' → escalation
- bb exit 1 with only node DeprecationWarning in stderr → unchecked_anti_scrape
  (not flagged as dead link — bb just not configured)
- bb auth failure → unchecked_anti_scrape (no false positive)
@ReidSurmeier

Copy link
Copy Markdown
Owner Author

Superseded by #11, which incorporated this sourcing-v2 implementation and added explicit provider/API boundaries, opt-in Browserbase escalation, MCP flag propagation, import-side-effect contracts, stderr protection, documentation, and passing CI. Closing this branch without merging it separately.

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.

1 participant