crawler/bridge: pass extract_links=True so BFS actually expands

The verbatim AsyncWebFetcher.fetch_webpage defaults extract_links=False
and returns (html, []) when omitted. Bridge's BFS therefore terminated
at the seed — a real-world crawl of russell.ballestrini.net discovered
exactly 1 URL (the seed). One-line fix; the kwarg was always there in
the lifted API.

Added test_crawl_seed_passes_extract_links_true that records every
fetch_webpage call and asserts the kwarg is True. Pin so this can't
silently regress when bridge internals get reorganized.

Updated the stub fetcher signature in the existing tests to accept
the new kwarg without behavior change.
This commit is contained in:
russell@unturf.com 2026-04-28 20:56:14 -04:00
parent 5f060ff326
commit e2540eaaec
No known key found for this signature in database
2 changed files with 35 additions and 2 deletions

View file

@ -72,7 +72,10 @@ async def _crawl_seed_async(
seen.add(url) seen.add(url)
try: try:
html, links = await fetcher.fetch_webpage(url) # extract_links=True is REQUIRED for BFS — the verbatim
# AsyncWebFetcher defaults it to False (caller opts in for the
# link-graph use case). Without it BFS terminates at the seed.
html, links = await fetcher.fetch_webpage(url, extract_links=True)
except Exception: except Exception:
continue continue
if html is None: if html is None:

View file

@ -64,7 +64,7 @@ class _StubFetcher:
def __init__(self, page_links: dict[str, list[str]]): def __init__(self, page_links: dict[str, list[str]]):
self.page_links = page_links self.page_links = page_links
async def fetch_webpage(self, url: str): async def fetch_webpage(self, url: str, extract_links: bool = False, **kw):
return "<html></html>", self.page_links.get(url, []) return "<html></html>", self.page_links.get(url, [])
@ -137,6 +137,36 @@ def test_crawl_seed_dedups():
assert len(out) == len(set(out)) assert len(out) == len(set(out))
def test_crawl_seed_passes_extract_links_true():
"""Regression: AsyncWebFetcher.fetch_webpage defaults extract_links=False,
so without the explicit kwarg BFS terminates after the seed (only one
URL ever lands in `discovered`). Pin the kwarg by recording the calls
on a stub fetcher."""
class _RecordingFetcher:
def __init__(self):
self.calls: list[dict] = []
async def fetch_webpage(self, url, extract_links=False, **kw):
self.calls.append({"url": url, "extract_links": extract_links})
return "<html></html>", []
import asyncio
from aborist.sources.crawler import bridge
fetcher = _RecordingFetcher()
asyncio.run(
bridge._crawl_seed_async(
"https://x.com/", max_depth=2, max_pages=5, fetcher=fetcher
)
)
assert fetcher.calls, "fetcher was never called"
for call in fetcher.calls:
assert call["extract_links"] is True, (
f"BFS must request link extraction; got {call!r}"
)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# ingest_crawled: stores ETag + Last-Modified per document_root # ingest_crawled: stores ETag + Last-Modified per document_root
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------