From c696829568a8aec1c03f7529ad20be27ac881258 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 1 Jul 2026 17:53:42 +0200 Subject: [PATCH] feat(capabilities): bound web.scrape batch and expose worst-case units --- .../app/capabilities/web/scrape/schemas.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/surfsense_backend/app/capabilities/web/scrape/schemas.py b/surfsense_backend/app/capabilities/web/scrape/schemas.py index 3e77dd56b..91de17a53 100644 --- a/surfsense_backend/app/capabilities/web/scrape/schemas.py +++ b/surfsense_backend/app/capabilities/web/scrape/schemas.py @@ -4,13 +4,21 @@ from __future__ import annotations from typing import Literal -from pydantic import BaseModel +from pydantic import BaseModel, Field + +MAX_SCRAPE_URLS = 20 +"""Per-call batch cap: bounds a synchronous request's crawl fan-out (05).""" class ScrapeInput(BaseModel): - urls: list[str] + urls: list[str] = Field(min_length=1, max_length=MAX_SCRAPE_URLS) max_length: int = 50_000 + @property + def estimated_units(self) -> int: + """Worst-case billable crawls for pre-flight: one per requested URL.""" + return len(self.urls) + class ScrapeRow(BaseModel): url: str