Skip to content

Repository files navigation

ROI Ledger — Self-Healing Scraper Fleet with Cost-Avoidance Accounting

Into the Scrape-Verse Hackathon (WeMakeDevs x Bright Data, August 2026)
Target Tracks: Web-Slinger (Best Use of Bright Data), Suit-Up (Best UI), Spider-Sense (Best Clean Code)
Live Demo: https://roi-ledger-mu.vercel.app | Live Dashboard: https://roi-ledger-mu.vercel.app/dashboard


0. One-Liner

A universal, self-healing operational layer for Bright Data Scraper Studio that detects structural breakages via two-proportion hypothesis testing, self-heals through a 2-tier adaptive escalation ladder and 3-gate quality check with explicit rejection audit trails, and prices every recovery in dollars: verifiable Bright Data credit spend vs disclosed developer patch labor avoided.


1. Why ROI Ledger Matters (The Impact & Universal Ops Layer)

Scrapers inevitably break when upstream websites mutate their DOM. In production, unmonitored breaks cause an average 4.0 hours Mean Time to Detect (MTTD) plus 20 minutes manual developer triage (MTTR), resulting in 4.33 hours of broken 0%-fill data feeds and downstream pipeline poisoning.

ROI Ledger transforms Scraper Studio from isolated collector scripts into an enterprise self-healing fleet:

  • Universal BYOC (Bring Your Own Collector): Drop in any Bright Data Scraper Studio collector ID (c_...) into the fleet via CLI, REST API, or the web dashboard.
  • 2-Tier Heal Escalation Ladder: Tier 1 fast statistical repair -> Tier 2 deep context retry -> explicit --reject & quarantine.
  • Credit Budget Guardrail: Pre-flight FinOps ceiling prevents credit overspend (configurable threshold, e.g. spend <= USD 40.00).
  • Counterfactual Downtime Prevention: Eliminates 4.33h of silent outage per break with automated recovery in ~1.4 seconds (maintaining 99.98% fleet SLA).

2. Fleet Architecture & The 3 Distinct Long-Tail Targets

Per Rule 5, all targets were verified absent from the Bright Data Pre-Built Scraper Library and were custom-generated via the Scraper Studio AI compiler (bdata scraper create):

Target Real Collector ID Domain & URL Scraper Type Role & Interaction Pattern Ground Truth Gate
Target A c_mt1zjqxg1nyair2wrj shopalto.xyz/product/aurora-wireless-headphones PDP E-commerce detail page with Section 9 ground-truth fixture accuracy check & live layout mutation testbed (v1, v2, v3). 100% Precision
Target B c_mt20lcyc1czybtdgpw scrapethissite.com/pages/forms/ Sitemap/Discovery Multi-page niche sports historical index discovering teams, win rates, and goals across 24 paginated discovery pages. 100% Precision
Target C c_mt20lkbp18qy5baork scrapethissite.com/pages/ajax-javascript/ Discovery+functions Dynamic AJAX SPA where data is gated behind automated browser interactions: bdata.click('#2015') -> bdata.wait() -> AJAX JSON hydration -> dynamic table extraction. 100% Precision

Engineering Disclosure (Rule 12 & 13): Targets B and C use scrapethissite.com's sandbox pages specifically to reliably demonstrate multi-page discovery and AJAX-hydrated functions-driven extraction within the hackathon window, rather than risk instability or rate-limiting on a live third-party site for the interactive proof.


3. Core Technical Differentiation

Target C: Interactive functions-Driven Scraper (Rule 3 & 12)

Static requests return 0 records on Target C because initial HTML is empty. The scraper is compiled with Scraper Studio browser functions:

// Scraper Studio functions execution sequence:
await bdata.click("#2015");
await bdata.wait_for_selector(".film", { timeout: 3000 });
return extract_film_rows();

Verified in live execution: returns 16 Oscars records with film titles, nominations, awards, and best picture boolean tags (response_id: d2t1787260605737ru1uelq5dos).

2-Tier Heal Escalation Ladder & 3-Gate Quality Check

Every proposed heal must pass 3 independent verification gates:

  1. Gate 1 — Schema Contract: Type conformance and required field presence.
  2. Gate 2 — Section 9 Golden-Fixture Precision: Field-level match against known ground truth (Threshold >= 85%).
  3. Gate 3 — Continuity Sanity Bounds: Range checks on numeric values to detect selector swapping bugs (e.g. price mapped to rating).

The Escalation Ladder:

  • If Tier 1 fails, the orchestrator generates a Tier 2 Deep Context Diagnosis Prompt with historical fill rates, exact gate failure diagnostics, and DOM structural hints.
  • If Tier 2 fails, the orchestrator explicitly executes bdata scraper approve <id> --reject and logs the rejection reason in SQLite.

Cost-Avoidance Accounting Ledger (FinOps Math)

1. Verifiable Real Cost:
   Real Cost (USD) = (11 runs × 2c + 5 heals × 15c) × $0.0015 = $0.145

2. Disclosed Estimated Labor Avoided:
   Labor Avoided (USD) = 4 heals × (20 min / 60 min) × $50.00/hr = $66.67

3. Net Return on Investment:
   Net ROI (USD) = $66.67 - $0.145 = +$66.53 (+99.8% Net ROI)

All wage and duration assumptions are fully disclosed in ROI_CONFIG.md.

Downstream Integrations & Export

  • Live Webhooks: Direct integrations with #slack-inventory-alerts, #discord-sports-analytics, and #telegram-film-tracker.
  • Data Export: Programmatic and one-click export endpoints available in JSON (/api/export/json) and CSV (/api/export/csv).

4. Quickstart & Live Execution

Requirements

  • Node.js 18+
  • Python 3.10+
  • Bright Data CLI (npx -p @brightdata/cli bdata)

Run Backend API & Fleet Watchdog

python -m uvicorn orchestrator.api:app --host 127.0.0.1 --port 8000

Run Next.js FinOps Dashboard

cd dashboard
npm install
npm run dev

Open http://localhost:3000/dashboard in your browser.

Run Unit Tests

pytest tests/ -v

All 22 unit tests pass offline in <0.3s.


5. Repository Manifest

  • collectors/collectors.json — Registry of the 3 custom Bright Data collectors with pre-built check notes + BYOC endpoint.
  • functions_scraper/target_c_flow.md — Dynamic functions interaction flow sequence diagram.
  • orchestrator/ — Classifier, 2-tier escalation ladder, 3-gate quality check, budget guardrail, golden fixture scorer, and FastAPI backend.
  • dashboard/ — Next.js 14 + TypeScript + Tailwind CSS pitch-black dashboard with native trackpad physics and Counterfactual telemetry.
  • samples/example_output.json — Real structured JSON output from live Bright Data responses.
  • ROI_CONFIG.md — Disclosed financial assumptions and formulas.
  • DISCLOSURE.md — AI tool usage disclosure per Rule 11.
  • LICENSE — MIT License.

About

Universal self-healing FinOps ops-layer for Bright Data Scraper Studio with 2-tier escalation ladder, 3-gate verification, and cost-avoidance accounting

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages