Enrichment Seam Contract
This document defines the v2.1.0 seam contract separating threat-intelligence source loading, finding/snapshot enrichment application, and downstream pipeline handoff.
Objective
Isolate enrichment concerns across explicit module boundaries:
- Source loading & cache verification (
src/vulnparse_pin/app/enrichment_source_loader.py) - Enrichment application & DuckDB snapshot hydration (
src/vulnparse_pin/app/enrichment.py) - Post-enrichment indexing & handoff (
src/vulnparse_pin/app/index_builder.py,src/vulnparse_pin/app/enrichment_handoff.py)
Implemented v2.1.0 Architecture
Contract A: Source Loader (EnrichmentSourceLoader)
EnrichmentSourceLoader (src/vulnparse_pin/app/enrichment_source_loader.py) resolves EnrichmentSourcePlan from CLI flags and config policy and loads all 6 source families:
- KEV (
KEVFeedCache/kev_cache.sqlite3) - EPSS v5 (
EPSSFeedCache/epss_cache.sqlite3) - Exploit-DB (
files_exploit.csvviaFeedCacheManager) - NVD (
NVDFeedCache/nvd_cache.sqlite3) - GHSA (
GHSAEnrichmentSource/ghsa_cache.sqlite3, opt-in via--ghsa) - OSV (
OSVEnrichmentSource/osv_cache.sqlite3, opt-in via--osv)
It returns EnrichmentSourceResult, encapsulating loaded lookup objects/dicts, source metadata (epss_model_version, kev_catalog_version, SHA-256 digests), and nvd_status.
Contract B: DuckDB Snapshot Hydration (populate_enrichment_snapshots) & EnrichmentApplicator
- v2.1.0 DuckDB path (
populate_enrichment_snapshots): Queries.vpp.db(finding_cves,findings) for only the matched CVEs andpackage_purls in the activerun_id, appliesresolve_cvss_with_provenance()(NVD > CNA > GHSA > OSV > Scanner-Supplied > Missing), merges KEV, EPSS v5, and Exploit-DB/negation-aware heuristic flags, computes trailing EPSS velocity (epss_delta_7d,epss_delta_30d,epss_slope) fromepss_cache.sqlite3(epss_history) / prior DuckDB snapshots, runsPreKEVModel(pre_kev_v1_core, hydratingpre_kev_score,pre_kev_flag,pre_kev_reasons_jsonwhenml_pol.mode != "off"andepss_scoreis present), and bulk-inserts rows intoenrichment_snapshotswhile updatingruns.intel_metadata_json. - Legacy
ScanResultpath (EnrichmentApplicator.apply): Applies loaded sources andapply_heuristic_exploit_tags_batch()in-memory forScanResultcallers, returningEnrichmentApplyResult(scan_result, stats_summary).
Contract C: Post-Enrichment Index & Handoff
index_builder.pybuildsPostEnrichmentIndexforScanResultconsumers.EnrichmentHandoffBuilder(enrichment_handoff.py) attaches source metadata toServicesand handsEnrichmentPipelineStateoff cleanly toPassRunner/run_v2_duckdb_pipeline().
Invariants
- Strict source isolation: Parsers never fetch network feeds; scoring/triage passes read
enrichment_snapshotsrather than querying external APIs or raw cache files. - Fail-closed cache integrity:
VP_FEED_CACHE_HMAC_KEYandVP_SQLITE_HMAC_KEYanti-downgrade and quarantine rules are enforced inside the source/cache layer before data reachesenrichment_snapshots. - Deterministic provenance: Every snapshot records
cvss_provenance,sources_json,epss_model_version, andenrichment_confidence.
Blast Radius & Compatibility
Affected modules:
src/vulnparse_pin/app/enrichment_source_loader.pysrc/vulnparse_pin/app/enrichment.pysrc/vulnparse_pin/app/enrichment_handoff.pysrc/vulnparse_pin/app/index_builder.pysrc/vulnparse_pin/utils/{enricher.py,feed_cache.py,nvdcacher.py,ghsa_enrichment.py,osv_enrichment.py,exploit_enrichment_service.py}
Both run_enrichment_pipeline() (for legacy ScanResult callers) and populate_enrichment_snapshots() (for v2.1.0 .vpp.db pipelines) share EnrichmentSourceLoader and resolve_cvss_with_provenance().