Skip to content

Pipeline Orchestration

Decoupled end-to-end orchestration connecting feed watching, URL checking, OSV file scanning, and the offline wheel-bundled demo without coupling core business logic to CLI formatting.

pipeline

Decoupled end-to-end orchestration pipeline shared by CLI, demos, and benchmarks.

check_url(url, *, fetcher, extractor, backend=None, source_name='Manual URL', source_tier=SourceTier.UNKNOWN, registry_checker=None, state_store=None, run_prefilter=True, query_on_triage=False, only_vulnerable=True)

Fetch a single advisory URL securely and run it through the full verification pipeline.

Parameters:

Name Type Description Default
url str

HTTP/HTTPS URL of the security blog post.

required
fetcher SafeHttpFetcher

SSRF-hardened :class:SafeHttpFetcher.

required
extractor Extractor

Narrow LLM extractor.

required
backend InventoryBackend | None

Optional inventory backend to check against verified advisories.

None
source_name str

Publisher name attached to the fetched article.

'Manual URL'
source_tier SourceTier

Credibility tier weight assigned to the source.

UNKNOWN
registry_checker RegistryChecker | None

Optional upstream registry existence checker.

None
state_store IngestStateStore | None

Optional ingestion state store.

None
run_prefilter bool

Whether to apply the pre-LLM keyword/regex filter.

True
query_on_triage bool

Whether TRIAGE advisories also query backend.

False
only_vulnerable bool

Whether to return only vulnerable inventory matches.

True

Returns:

Name Type Description
A PipelineOutcome

class:PipelineOutcome describing ingestion, verification, and inventory matches.

Source code in src/zerobom/pipeline.py
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
def check_url(
    url: str,
    *,
    fetcher: SafeHttpFetcher,
    extractor: Extractor,
    backend: InventoryBackend | None = None,
    source_name: str = "Manual URL",
    source_tier: SourceTier = SourceTier.UNKNOWN,
    registry_checker: RegistryChecker | None = None,
    state_store: IngestStateStore | None = None,
    run_prefilter: bool = True,
    query_on_triage: bool = False,
    only_vulnerable: bool = True,
) -> PipelineOutcome:
    """Fetch a single advisory URL securely and run it through the full verification pipeline.

    Args:
        url: HTTP/HTTPS URL of the security blog post.
        fetcher: SSRF-hardened :class:`SafeHttpFetcher`.
        extractor: Narrow LLM extractor.
        backend: Optional inventory backend to check against verified advisories.
        source_name: Publisher name attached to the fetched article.
        source_tier: Credibility tier weight assigned to the source.
        registry_checker: Optional upstream registry existence checker.
        state_store: Optional ingestion state store.
        run_prefilter: Whether to apply the pre-LLM keyword/regex filter.
        query_on_triage: Whether ``TRIAGE`` advisories also query ``backend``.
        only_vulnerable: Whether to return only vulnerable inventory matches.

    Returns:
        A :class:`PipelineOutcome` describing ingestion, verification, and inventory matches.
    """
    article, resp = fetcher.fetch_article(
        url,
        source_name=source_name,
        source_tier=source_tier,
    )
    if article is None:
        return PipelineOutcome(skipped_reason="Article unchanged (304 Not Modified).")

    return process_article(
        article,
        extractor=extractor,
        backend=backend,
        registry_checker=registry_checker,
        state_store=state_store,
        etag=resp.etag,
        last_modified=resp.last_modified,
        run_prefilter=run_prefilter,
        query_on_triage=query_on_triage,
        only_vulnerable=only_vulnerable,
    )

convert_external_osv(inp)

Convert an external :class:OsvAdvisoryInput into an evaluable :class:OsvAdvisory.

Handles spec-optional fields (missing published, summary, or purl), skips withdrawn records cleanly, and skips unsupported GIT ranges with diagnostic warnings.

Source code in src/zerobom/pipeline.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
def convert_external_osv(inp: OsvAdvisoryInput) -> tuple[OsvAdvisory | None, tuple[str, ...]]:
    """Convert an external :class:`OsvAdvisoryInput` into an evaluable :class:`OsvAdvisory`.

    Handles spec-optional fields (missing ``published``, ``summary``, or ``purl``), skips
    ``withdrawn`` records cleanly, and skips unsupported ``GIT`` ranges with diagnostic warnings.
    """
    if inp.withdrawn is not None:
        return (
            None,
            (f"Advisory {inp.id} was withdrawn on {inp.withdrawn.isoformat()}.",),
        )

    warnings: list[str] = []
    converted_affected: list[OsvAffected] = []

    for aff in inp.affected:
        if aff.package is None:
            continue

        resolved_purl = aff.package.purl
        if not resolved_purl:
            base_eco, _ = parse_osv_ecosystem(aff.package.ecosystem)
            purl_res = resolve_purl(aff.package.name, ecosystem=base_eco)
            if not purl_res.is_valid or purl_res.canonical_purl is None:
                warnings.append(
                    f"Skipped package {aff.package.name!r} ({aff.package.ecosystem}) in "
                    f"{inp.id}: could not derive canonical PURL."
                )
                continue
            resolved_purl = purl_res.canonical_purl

        converted_ranges: list[OsvRange] = []
        for rng in aff.ranges:
            if rng.type == "GIT":
                warnings.append(
                    f"Skipped unsupported GIT range in {inp.id} for {aff.package.name}."
                )
                continue
            strict_events = tuple(
                OsvRangeEvent(
                    introduced=ev.introduced,
                    fixed=ev.fixed,
                    last_affected=ev.last_affected,
                    limit=ev.limit,
                )
                for ev in rng.events
            )
            converted_ranges.append(OsvRange(type=rng.type, events=strict_events))

        if not converted_ranges and not aff.versions:
            continue

        db_spec = dict(aff.database_specific) if aff.database_specific is not None else None
        if aff.ecosystem_specific is not None:
            db_spec = dict(db_spec or {})
            db_spec.setdefault("ecosystem_specific", aff.ecosystem_specific)

        converted_affected.append(
            OsvAffected(
                package=OsvPackage(
                    ecosystem=aff.package.ecosystem,
                    name=aff.package.name,
                    purl=resolved_purl,
                ),
                ranges=tuple(converted_ranges),
                versions=aff.versions,
                database_specific=db_spec,
            )
        )

    if not converted_affected:
        if not warnings:
            warnings.append(f"Advisory {inp.id} contains no evaluable package ranges.")
        return None, tuple(warnings)

    refs: list[OsvReference] = []
    for ref in inp.references:
        ref_type = ref.type.strip().upper()
        normalized_type = ref_type if ref_type in _VALID_OSV_REF_TYPES else "WEB"
        refs.append(OsvReference(type=normalized_type, url=ref.url))  # type: ignore[arg-type]

    advisory = OsvAdvisory(
        schema_version=inp.schema_version,
        id=inp.id,
        modified=inp.modified,
        published=inp.published or inp.modified,
        withdrawn=inp.withdrawn,
        summary=inp.summary or inp.id,
        details=inp.details,
        aliases=inp.aliases,
        related=inp.related,
        upstream=inp.upstream,
        severity=inp.severity,
        affected=tuple(converted_affected),
        references=tuple(refs),
        database_specific=dict(inp.database_specific),
    )
    return advisory, tuple(warnings)

load_osv_advisories(path, *, max_file_bytes=MAX_OSV_FILE_BYTES, max_files=MAX_OSV_FILES)

Load, validate, and normalize OSV v1.x JSON advisories from a file or directory.

Withdrawn or GIT-only records are omitted cleanly during conversion rather than failing directory scans.

Parameters:

Name Type Description Default
path Path | str

Path to a single OSV JSON file or a directory of *.json files.

required
max_file_bytes int

Maximum byte size permitted per OSV JSON file.

MAX_OSV_FILE_BYTES
max_files int

Maximum number of JSON files permitted in a directory scan.

MAX_OSV_FILES

Returns:

Type Description
tuple[OsvAdvisory, ...]

Tuple of evaluable :class:OsvAdvisory objects.

Raises:

Type Description
ValueError

If path is missing, exceeds limits, contains invalid OSV JSON, or yields zero files.

Source code in src/zerobom/pipeline.py
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
def load_osv_advisories(
    path: Path | str,
    *,
    max_file_bytes: int = MAX_OSV_FILE_BYTES,
    max_files: int = MAX_OSV_FILES,
) -> tuple[OsvAdvisory, ...]:
    """Load, validate, and normalize OSV v1.x JSON advisories from a file or directory.

    Withdrawn or GIT-only records are omitted cleanly during conversion rather than failing
    directory scans.

    Args:
        path: Path to a single OSV JSON file or a directory of ``*.json`` files.
        max_file_bytes: Maximum byte size permitted per OSV JSON file.
        max_files: Maximum number of JSON files permitted in a directory scan.

    Returns:
        Tuple of evaluable :class:`OsvAdvisory` objects.

    Raises:
        ValueError: If ``path`` is missing, exceeds limits, contains invalid OSV JSON, or
            yields zero files.
    """
    raw_inputs = load_osv_inputs(path, max_file_bytes=max_file_bytes, max_files=max_files)
    advisories: list[OsvAdvisory] = []
    for inp in raw_inputs:
        adv, _ = convert_external_osv(inp)
        if adv is not None:
            advisories.append(adv)
    return tuple(advisories)

load_osv_inputs(path, *, max_file_bytes=MAX_OSV_FILE_BYTES, max_files=MAX_OSV_FILES)

Load and validate OSV JSON advisories using the spec-compliant lenient consumer contract.

Parameters:

Name Type Description Default
path Path | str

Path to a single OSV JSON file or a directory of *.json files.

required
max_file_bytes int

Maximum byte size permitted per OSV JSON file.

MAX_OSV_FILE_BYTES
max_files int

Maximum number of JSON files permitted in a directory scan.

MAX_OSV_FILES

Returns:

Type Description
tuple[OsvAdvisoryInput, ...]

Tuple of validated :class:OsvAdvisoryInput objects.

Raises:

Type Description
ValueError

If path is missing, exceeds limits, contains invalid OSV JSON, or yields zero advisories.

Source code in src/zerobom/pipeline.py
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
def load_osv_inputs(
    path: Path | str,
    *,
    max_file_bytes: int = MAX_OSV_FILE_BYTES,
    max_files: int = MAX_OSV_FILES,
) -> tuple[OsvAdvisoryInput, ...]:
    """Load and validate OSV JSON advisories using the spec-compliant lenient consumer contract.

    Args:
        path: Path to a single OSV JSON file or a directory of ``*.json`` files.
        max_file_bytes: Maximum byte size permitted per OSV JSON file.
        max_files: Maximum number of JSON files permitted in a directory scan.

    Returns:
        Tuple of validated :class:`OsvAdvisoryInput` objects.

    Raises:
        ValueError: If ``path`` is missing, exceeds limits, contains invalid OSV JSON, or
            yields zero advisories.
    """
    if max_file_bytes < 1 or max_files < 1:
        raise ValueError("max_file_bytes and max_files must be >= 1")

    target = Path(path)
    if not target.exists():
        raise ValueError(f"OSV path does not exist: {target}")

    if target.is_file():
        return (_load_single_osv_input(target, max_file_bytes=max_file_bytes),)

    if not target.is_dir():
        raise ValueError(f"Unsupported OSV path type: {target}")

    candidates = sorted(target.rglob("*.json"))
    if len(candidates) > max_files:
        raise ValueError(
            f"Directory {target} contains {len(candidates)} JSON files, "
            f"exceeding max_files={max_files}."
        )

    inputs: list[OsvAdvisoryInput] = []
    for candidate in candidates:
        # Skip symlinks and resolved paths escaping the scan root.
        if candidate.is_symlink() or not _is_path_within_root(candidate, target):
            continue
        if not candidate.is_file():
            continue
        inputs.append(_load_single_osv_input(candidate, max_file_bytes=max_file_bytes))

    if not inputs:
        raise ValueError(f"No OSV JSON files found in directory: {target}")

    return tuple(inputs)

process_article(article, *, extractor, backend=None, registry_checker=None, state_store=None, etag=None, last_modified=None, run_prefilter=True, query_on_triage=False, only_vulnerable=True, mark_seen=True, extra_urls=())

Run an ingested :class:RawArticle through pre-filter, extraction, verification, and match.

Parameters:

Name Type Description Default
article RawArticle

Normalized article text and metadata.

required
extractor Extractor

Narrow LLM (or fixture) extractor implementing :class:Extractor.

required
backend InventoryBackend | None

Optional inventory backend queried when routing passes the credibility gate.

None
registry_checker RegistryChecker | None

Optional upstream package registry verifier.

None
state_store IngestStateStore | None

Optional SQLite store updated after processing finishes.

None
etag str | None

Optional HTTP ETag validator persisted when marking state_store seen.

None
last_modified str | None

Optional HTTP Last-Modified validator persisted in state_store.

None
run_prefilter bool

Whether to gate non-vulnerability noise prior to invoking extractor.

True
query_on_triage bool

Whether TRIAGE advisories (0.50-0.74) also query backend.

False
only_vulnerable bool

Whether returned matches exclude patched/non-vulnerable versions.

True
mark_seen bool

Whether to persist article state into state_store upon completion.

True
extra_urls Sequence[str]

Additional canonicalizable alias URLs (e.g., pre-redirect feed entry URLs) recorded alongside article.url when mark_seen is enabled.

()

Returns:

Name Type Description
A PipelineOutcome

class:PipelineOutcome capturing every intermediate stage and inventory hits.

Source code in src/zerobom/pipeline.py
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
def process_article(
    article: RawArticle,
    *,
    extractor: Extractor,
    backend: InventoryBackend | None = None,
    registry_checker: RegistryChecker | None = None,
    state_store: IngestStateStore | None = None,
    etag: str | None = None,
    last_modified: str | None = None,
    run_prefilter: bool = True,
    query_on_triage: bool = False,
    only_vulnerable: bool = True,
    mark_seen: bool = True,
    extra_urls: Sequence[str] = (),
) -> PipelineOutcome:
    """Run an ingested :class:`RawArticle` through pre-filter, extraction, verification, and match.

    Args:
        article: Normalized article text and metadata.
        extractor: Narrow LLM (or fixture) extractor implementing :class:`Extractor`.
        backend: Optional inventory backend queried when routing passes the credibility gate.
        registry_checker: Optional upstream package registry verifier.
        state_store: Optional SQLite store updated after processing finishes.
        etag: Optional HTTP ``ETag`` validator persisted when marking ``state_store`` seen.
        last_modified: Optional HTTP ``Last-Modified`` validator persisted in ``state_store``.
        run_prefilter: Whether to gate non-vulnerability noise prior to invoking ``extractor``.
        query_on_triage: Whether ``TRIAGE`` advisories (0.50-0.74) also query ``backend``.
        only_vulnerable: Whether returned matches exclude patched/non-vulnerable versions.
        mark_seen: Whether to persist ``article`` state into ``state_store`` upon completion.
        extra_urls: Additional canonicalizable alias URLs (e.g., pre-redirect feed entry URLs)
            recorded alongside ``article.url`` when ``mark_seen`` is enabled.

    Returns:
        A :class:`PipelineOutcome` capturing every intermediate stage and inventory hits.
    """
    prefilter_res = None
    known_aliases: tuple[str, ...] = ()
    content_sha = compute_content_sha256(article.body)

    if run_prefilter:
        prefilter_res = prefilter_article(article)
        known_aliases = prefilter_res.extracted_aliases
        if not prefilter_res.passed:
            if state_store is not None and mark_seen:
                state_store.record_processed_with_outbox(
                    article.url,
                    content_sha,
                    extra_urls=extra_urls,
                    etag=etag,
                    last_modified=last_modified,
                    routing=RoutingDecision.DROP,
                )
            return PipelineOutcome(
                article=article,
                prefilter=prefilter_res,
                skipped_reason="Prefilter dropped non-vulnerability or marketing article.",
            )

    advisory = extractor.extract(article, known_aliases=known_aliases)
    credibility = verify_advisory(article, advisory, registry_checker=registry_checker)
    osv = compile_osv_advisory(advisory, credibility, article=article)

    should_query = (
        backend is not None
        and osv is not None
        and (
            credibility.routing == RoutingDecision.AUTO
            or (query_on_triage and credibility.routing == RoutingDecision.TRIAGE)
        )
    )
    matches: tuple[MatchResult, ...] = ()
    if should_query and backend is not None and osv is not None:
        matches = match_advisory_with_backend(osv, backend, only_vulnerable=only_vulnerable)

    if state_store is not None and mark_seen:
        state_store.record_processed_with_outbox(
            article.url,
            content_sha,
            extra_urls=extra_urls,
            etag=etag,
            last_modified=last_modified,
            advisory_id=osv.id if osv is not None else None,
            routing=credibility.routing,
        )

    return PipelineOutcome(
        article=article,
        prefilter=prefilter_res,
        advisory=advisory,
        credibility=credibility,
        osv=osv,
        matches=matches,
    )

run_offline_demo()

Run the zero-config offline demo using wheel-bundled advisory and SBOM fixtures.

Returns:

Name Type Description
A PipelineOutcome

class:PipelineOutcome demonstrating quote verification, generic-name blocking,

PipelineOutcome

OSV compilation, and CycloneDX upstream/PURL SBOM matching.

Source code in src/zerobom/pipeline.py
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
def run_offline_demo() -> PipelineOutcome:
    """Run the zero-config offline demo using wheel-bundled advisory and SBOM fixtures.

    Returns:
        A :class:`PipelineOutcome` demonstrating quote verification, generic-name blocking,
        OSV compilation, and CycloneDX upstream/PURL SBOM matching.
    """
    data_pkg = importlib.resources.files("zerobom.data")
    article_raw = data_pkg.joinpath("demo_article.json").read_text(encoding="utf-8")
    extracted_raw = data_pkg.joinpath("demo_extracted.json").read_text(encoding="utf-8")
    sbom_bytes = data_pkg.joinpath("demo_sbom.cdx.json").read_bytes()

    article = RawArticle.model_validate_json(article_raw)
    advisory = ExtractedAdvisory.model_validate_json(extracted_raw)
    extractor = _StaticExtractor(advisory)

    demo_components = parse_sbom_bytes(
        sbom_bytes,
        asset_id="demo_sbom.cdx.json",
        backend="local_sbom",
        location="demo_sbom.cdx.json",
    )
    backend = _StaticDemoBackend(InMemoryComponentIndex(demo_components))
    return process_article(
        article,
        extractor=extractor,
        backend=backend,
        run_prefilter=True,
    )

scan_osv_files(osv_path, *, backend, only_vulnerable=True)

Deterministically evaluate OSV JSON advisories against an inventory backend (zero LLM).

Parameters:

Name Type Description Default
osv_path Path | str

Path to an OSV JSON file or directory of OSV JSON files.

required
backend InventoryBackend

Configured :class:InventoryBackend to query.

required
only_vulnerable bool

Whether to omit non-vulnerable versions from returned matches.

True

Returns:

Type Description
tuple[PipelineOutcome, ...]

Tuple of :class:PipelineOutcome entries, one per loaded OSV advisory.

Source code in src/zerobom/pipeline.py
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
def scan_osv_files(
    osv_path: Path | str,
    *,
    backend: InventoryBackend,
    only_vulnerable: bool = True,
) -> tuple[PipelineOutcome, ...]:
    """Deterministically evaluate OSV JSON advisories against an inventory backend (zero LLM).

    Args:
        osv_path: Path to an OSV JSON file or directory of OSV JSON files.
        backend: Configured :class:`InventoryBackend` to query.
        only_vulnerable: Whether to omit non-vulnerable versions from returned matches.

    Returns:
        Tuple of :class:`PipelineOutcome` entries, one per loaded OSV advisory.
    """
    inputs = load_osv_inputs(osv_path)
    outcomes: list[PipelineOutcome] = []
    for inp in inputs:
        adv, warnings = convert_external_osv(inp)
        if adv is None:
            outcomes.append(
                PipelineOutcome(
                    osv=None,
                    skipped_reason="; ".join(warnings)
                    or f"Advisory {inp.id} contains no evaluable package ranges.",
                )
            )
            continue
        outcomes.append(
            PipelineOutcome(
                osv=adv,
                matches=match_advisory_with_backend(adv, backend, only_vulnerable=only_vulnerable),
            )
        )
    return tuple(outcomes)

watch_feeds(feeds, *, fetcher, extractor, backend=None, state_store=None, registry_checker=None, run_prefilter=True, query_on_triage=False, only_vulnerable=True)

Poll allowlisted feeds and process newly discovered or edited articles end-to-end.

Parameters:

Name Type Description Default
feeds Sequence[SourceFeedConfig]

Allowlisted :class:SourceFeedConfig definitions.

required
fetcher SafeHttpFetcher

SSRF-hardened :class:SafeHttpFetcher.

required
extractor Extractor

Narrow LLM extractor.

required
backend InventoryBackend | None

Optional inventory backend queried on verified advisories.

None
state_store IngestStateStore | None

Optional SQLite state store for conditional fetch & edit detection.

None
registry_checker RegistryChecker | None

Optional upstream registry existence verifier.

None
run_prefilter bool

Whether to run pre-LLM keyword/regex filtering.

True
query_on_triage bool

Whether TRIAGE advisories also query backend.

False
only_vulnerable bool

Whether to return only vulnerable matches.

True

Returns:

Type Description
tuple[PipelineOutcome, ...]

Tuple of :class:PipelineOutcome objects for newly fetched/edited articles.

Source code in src/zerobom/pipeline.py
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
def watch_feeds(
    feeds: Sequence[SourceFeedConfig],
    *,
    fetcher: SafeHttpFetcher,
    extractor: Extractor,
    backend: InventoryBackend | None = None,
    state_store: IngestStateStore | None = None,
    registry_checker: RegistryChecker | None = None,
    run_prefilter: bool = True,
    query_on_triage: bool = False,
    only_vulnerable: bool = True,
) -> tuple[PipelineOutcome, ...]:
    """Poll allowlisted feeds and process newly discovered or edited articles end-to-end.

    Args:
        feeds: Allowlisted :class:`SourceFeedConfig` definitions.
        fetcher: SSRF-hardened :class:`SafeHttpFetcher`.
        extractor: Narrow LLM extractor.
        backend: Optional inventory backend queried on verified advisories.
        state_store: Optional SQLite state store for conditional fetch & edit detection.
        registry_checker: Optional upstream registry existence verifier.
        run_prefilter: Whether to run pre-LLM keyword/regex filtering.
        query_on_triage: Whether ``TRIAGE`` advisories also query ``backend``.
        only_vulnerable: Whether to return only vulnerable matches.

    Returns:
        Tuple of :class:`PipelineOutcome` objects for newly fetched/edited articles.
    """
    polled_items = poll_feed_items(
        feeds,
        fetcher=fetcher,
        state_store=state_store,
        mark_seen=False,
    )
    return tuple(
        process_article(
            item.article,
            extractor=extractor,
            backend=backend,
            registry_checker=registry_checker,
            state_store=state_store,
            etag=item.etag,
            last_modified=item.last_modified,
            run_prefilter=run_prefilter,
            query_on_triage=query_on_triage,
            only_vulnerable=only_vulnerable,
            extra_urls=(
                (item.source_entry_url,)
                if item.source_entry_url is not None
                and canonicalize_url(item.source_entry_url) != canonicalize_url(item.article.url)
                else ()
            ),
        )
        for item in polled_items
    )

watch_feeds_report(feeds, *, fetcher, extractor, backend=None, state_store=None, registry_checker=None, run_prefilter=True, query_on_triage=False, only_vulnerable=True, mark_seen=True, outcome_sink_keys=None)

Poll allowlisted feeds with per-feed and per-article failure isolation.

Failures in feed fetching, XML/HTML parsing, article extraction, or backend matching are recorded cleanly in :class:WatchReport without aborting remaining feeds or discarding prior outcomes. When state_store and outcome_sink_keys are supplied, each article's state and pending outbound alert deliveries are committed atomically per item.

Parameters:

Name Type Description Default
feeds Sequence[SourceFeedConfig]

Allowlisted :class:SourceFeedConfig definitions.

required
fetcher SafeHttpFetcher

SSRF-hardened :class:SafeHttpFetcher.

required
extractor Extractor

Narrow LLM extractor.

required
backend InventoryBackend | None

Optional inventory backend queried on verified advisories.

None
state_store IngestStateStore | None

Optional SQLite state store for conditional fetch & outbox persistence.

None
registry_checker RegistryChecker | None

Optional upstream registry existence verifier.

None
run_prefilter bool

Whether to run pre-LLM keyword/regex filtering.

True
query_on_triage bool

Whether TRIAGE advisories also query backend.

False
only_vulnerable bool

Whether to return only vulnerable matches.

True
mark_seen bool

Whether to persist processed article state to state_store.

True
outcome_sink_keys Callable[[PipelineOutcome], Sequence[str]] | None

Optional callback returning outbox sink keys triggered by an outcome.

None

Returns:

Name Type Description
Structured WatchReport

class:WatchReport with per-feed status, outcomes, and isolated errors.

Source code in src/zerobom/pipeline.py
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
def watch_feeds_report(
    feeds: Sequence[SourceFeedConfig],
    *,
    fetcher: SafeHttpFetcher,
    extractor: Extractor,
    backend: InventoryBackend | None = None,
    state_store: IngestStateStore | None = None,
    registry_checker: RegistryChecker | None = None,
    run_prefilter: bool = True,
    query_on_triage: bool = False,
    only_vulnerable: bool = True,
    mark_seen: bool = True,
    outcome_sink_keys: Callable[[PipelineOutcome], Sequence[str]] | None = None,
) -> WatchReport:
    """Poll allowlisted feeds with per-feed and per-article failure isolation.

    Failures in feed fetching, XML/HTML parsing, article extraction, or backend matching are
    recorded cleanly in :class:`WatchReport` without aborting remaining feeds or discarding prior
    outcomes. When ``state_store`` and ``outcome_sink_keys`` are supplied, each article's state
    and pending outbound alert deliveries are committed atomically per item.

    Args:
        feeds: Allowlisted :class:`SourceFeedConfig` definitions.
        fetcher: SSRF-hardened :class:`SafeHttpFetcher`.
        extractor: Narrow LLM extractor.
        backend: Optional inventory backend queried on verified advisories.
        state_store: Optional SQLite state store for conditional fetch & outbox persistence.
        registry_checker: Optional upstream registry existence verifier.
        run_prefilter: Whether to run pre-LLM keyword/regex filtering.
        query_on_triage: Whether ``TRIAGE`` advisories also query ``backend``.
        only_vulnerable: Whether to return only vulnerable matches.
        mark_seen: Whether to persist processed article state to ``state_store``.
        outcome_sink_keys: Optional callback returning outbox sink keys triggered by an outcome.

    Returns:
        Structured :class:`WatchReport` with per-feed status, outcomes, and isolated errors.
    """
    polled_items, feed_results, poll_errors = poll_feed_items_isolated(
        feeds,
        fetcher=fetcher,
        state_store=state_store,
        mark_seen=False,
    )
    errors: list[WatchItemError] = list(poll_errors)
    outcomes: list[PipelineOutcome] = []
    use_outbox = state_store is not None and mark_seen and outcome_sink_keys is not None

    for item in polled_items:
        extra_urls = (
            (item.source_entry_url,)
            if item.source_entry_url is not None
            and canonicalize_url(item.source_entry_url) != canonicalize_url(item.article.url)
            else ()
        )
        try:
            outcome = process_article(
                item.article,
                extractor=extractor,
                backend=backend,
                registry_checker=registry_checker,
                state_store=None if use_outbox else state_store,
                etag=item.etag,
                last_modified=item.last_modified,
                run_prefilter=run_prefilter,
                query_on_triage=query_on_triage,
                only_vulnerable=only_vulnerable,
                mark_seen=mark_seen and not use_outbox,
                extra_urls=extra_urls,
            )
        except ExtractionError as exc:
            errors.append(
                WatchItemError(
                    stage="extract",
                    source_name=item.article.source_name,
                    target=item.article.url,
                    error=str(exc),
                )
            )
            continue
        except (BackendError, SbomParseError, ValueError) as exc:
            errors.append(
                WatchItemError(
                    stage="backend",
                    source_name=item.article.source_name,
                    target=item.article.url,
                    error=str(exc),
                )
            )
            continue

        if use_outbox and state_store is not None and outcome_sink_keys is not None:
            sink_keys = tuple(outcome_sink_keys(outcome)) if outcome.osv is not None else ()
            routing = (
                RoutingDecision.DROP
                if outcome.skipped_reason is not None
                else (outcome.credibility.routing if outcome.credibility is not None else None)
            )
            state_store.record_processed_with_outbox(
                item.article.url,
                item.content_sha256,
                extra_urls=extra_urls,
                etag=item.etag,
                last_modified=item.last_modified,
                advisory_id=outcome.osv.id if outcome.osv is not None else None,
                routing=routing,
                sink_keys=sink_keys,
                outcome=outcome if sink_keys else None,
            )

        outcomes.append(outcome)

    return WatchReport(
        per_feed=feed_results,
        outcomes=tuple(outcomes),
        errors=tuple(errors),
    )