Skip to content
SprecherEast
Issue 352

enhancement: Fetch strategy for intelligence sources — direct fetch first, Playwright as fallback

Back to our plan
Done
enhancementcmstoolingpriority: high

Type

enhancement

Problem

The intelligence pipeline (#337, #255, epic #161) currently treats HTML-only sources (Parks events, District 16 blog, city news) as pending because no feed exists. The owner (Amine, 2026-10-24, voice) decided the fetch order: try a direct fetch first, use Playwright only as a fallback when the response is unclear, JavaScript-rendered, or the structured parse fails. Playwright is not for routine collection — it's for the cases where a plain HTTP GET can't produce usable data.

Decisions

  • Primary path: plain HTTP GET (or the existing feed/API client) with content-type detection, ETag/Last-Modified caching, and deterministic parsing (RSS/Atom/ICS/JSON/HTML).
  • Fallback path: Playwright headless browser, launched only when the direct fetch returns empty, blocked, or a page that requires client-side rendering to expose events/news. Not run on a schedule for every source.
  • Out of scope: bypassing logins, CAPTCHAs, paywalls, or robots.txt disallows. madison.com's Tollbit redirect stays a hard no. Dane County's press page remains restricted pending an official feed.
  • Legal posture (US, 2026): public pages, logged out, no gate — CFAA doesn't apply after Van Buren/hiQ. robots.txt is a request, not a lock (Ziff Davis v. OpenAI, 2025). The main residual risks are contract (terms accepted via login) and copyright (summarize facts, don't republish articles). Playwright-at-user-direction is the most defensible shape per the Ninth Circuit's Sept 2026 Perplexity/Comet ruling.
  • Rate limiting: gentle, per-source caps, respect Retry-After.

Proposed fix

  • Add a fetch module (or extend the scout stage in intelligence/pipeline.yaml) with two strategies: direct and playwright, selected per source in intelligence/sources.yaml via a fetch_strategy field (default direct, override playwright only where needed).
  • Playwright fallback triggers on: non-200, empty body, content that looks like a JS shell (no text nodes matching expected selectors), or a parse confidence below threshold.
  • Log which strategy was used per source per run so the digest shows direct-vs-fallback ratios.
  • Add Playwright to devDependencies only (or a separate optional extra); CI runs the direct path; Playwright tests are opt-in/manual for the HTML sources.
  • Document the fallback trigger conditions in intelligence/README.md.

Acceptance criteria

  • Not done: sources.yaml supports a per-source fetch strategy with direct as default.
  • Not done: Direct fetch handles all four pilot feeds (Legistar JSON, Legistar meetings, Pinney ICS, Madison365 RSS) with zero Playwright.
  • Not done: Playwright fallback is implemented and tested against at least one HTML-only pending source (Parks or District 16 blog) once page-parsing approval exists.
  • Not done: Run logs record which strategy handled each source.
  • Not done: No Playwright usage against madison.com, Dane County press page, or any login-walled source.
  • Not done: Docs note the legal rationale and the hard nos.

Dependencies

  • #337 (versioned prompts/sources — the intelligence/ folder this plugs into).
  • #271 (closed — approved feed registry; this extends it with a fetch-strategy column).
  • #272 (dry-run collector — this defines how it fetches).
  • Page-parsing approval for Parks/District 16 blog still needed before the Playwright path has a real target.
  • Umbrella #255, epic #161.

Area

tooling, cms

Priority

priority: high


Owner direction 2026-10-24 (voice): direct fetch first, Playwright only when data is unclear or JavaScript-dependent. Relates to #337, #271, #272.

See it on GitHub, opens in a new tab