Architecture adr/ADR-0002-enrichment-seam.md
View source on GitHub ↗
ADR-0002: Enrichment Seam Architecture
- Status: Accepted
- Date: 2026-04-05
- Deciders: Architecture Team
- Tags: enrichment|extensibility|orchestration
Context
VulnParse-Pin’s enrichment pipeline was tightly coupled within app/enrichment.py, mixing concerns of:
- Source loading and discovery (KEV, EPSS, Exploit-DB, NVD)
- Finding-level enrichment application
- Post-enrichment indexing and pass orchestration
This monolithic approach made it difficult to:
- Test source loading independently
- Extend enrichment behavior via composition
- Understand source contract boundaries
- Compose custom enrichment workflows for derived products
Decision
Implement a seam architecture decomposing enrichment orchestration into explicit boundary-crossing layers:
Stage 1: Source Loading Module (app/enrichment_source_loader.py)
- Extracted source loading into
EnrichmentSourceLoaderclass - Owns KeySource Loading and NVD cache initialization
- Returns
EnrichmentSourceResultcontract with loaded data and metadata - Preserves all existing source flags and load-fallback semantics
Future Stages (design-ready, implementation deferred)
- Stage 2: Move enrichment application into dedicated applicator module
- Stage 3: Extract post-enrichment indexing and handoff into projector module
Alternatives Considered
- Full 4-stage decomposition in one PR: Larger refactor; higher regression risk
- Standalone enrichment service: Over-engineered for current scale; adds complexity
- Monolithic retention: Loses extensibility and boundaries
Consequences
Positive:
- Source loading is now independently testable and reusable
- Enrichment pipeline logic becomes clearer through separation of concerns
- Future enrichment extensions (threat feeds, third-party sources) have clear entry point
- Staged implementation allows incremental de-risking and validation
Negative:
- Light increase in module count (1 new focused module for Stage 1)
- Requires minimal refactor to
enrichment.pyto call loader
Compatibility Impact
- Classification: additive (no breaking changes)
- Affected contracts: None (all internal; public pipeline behavior unchanged)
- Migration guidance: None required; enrichment pipeline remain fully backward-compatible
Test and Validation Plan
- Contract tests: Existing enrichment tests remain green
- Regression tests: Full suite validates no behavior change in source loading or enrichment output
- Runtime verification:
- Source loader loads all supported feed types
- Existing feed caching and refresh logic preserved
- Offline and online modes work as before
Rollout and Rollback
-
Rollout steps:
- Deploy enrichment_source_loader module
- Verify full enrichment test suite passes (no regressions)
- Monitor enrichment phase in first production runs
-
Rollback strategy:
- If
EnrichmentSourceLoaderfails, route back to monolithicenrichment.pylogic - Source module can be safely disabled without affecting pipeline (low risk)
- All feed loading contracts and caching remain unchanged
- If
v2.0.0 Status
In v2.0.0 (Apache-2.0), Stages 2 and 3 were completed and integrated with DuckDB workspace persistence:
EnrichmentSourceLoader(app/enrichment_source_loader.py) loads all 6 source families (KEV,EPSS v5,Exploit-DB,NVD,GHSA, andOSV) with strict HMAC anti-downgrade and HTTPS per-hop redirect protections.- Stage 2 (
EnrichmentApplicatorinapp/enrichment.py) and Stage 3 (EnrichmentHandoffBuilderinapp/enrichment_handoff.py+PostEnrichmentIndexinapp/index_builder.py) are shipped. populate_enrichment_snapshots()(app/enrichment.py) hydrates matched CVEs andpackage_purls into DuckDB’senrichment_snapshotstable (recording unified CVSS provenanceNVD > CNA > GHSA > OSV > Scanner-Supplied > Missing, EPSS v5#model_version+ percentile, KEV metadata, and negation-aware exploit flags) and updatesruns.intel_metadata_json.
v2.1.0 Status
In v2.1.0 (Apache-2.0), the enrichment seam adds longitudinal EPSS velocity tracking and Pre-KEV early-warning snapshot hydration:
EPSSFeedCache(src/vulnparse_pin/utils/enricher.py:409-483) maintains anepss_history (cve_id, score_date, epss_score, epss_percentile)SQLite table inside the HMAC-signed EPSS cache (VP_SQLITE_HMAC_KEY), pruning history to a rolling90-day (max_days=90) window across feed syncs.populate_enrichment_snapshots()(src/vulnparse_pin/app/enrichment.py) combinesEPSSFeedCachehistory (and prior DuckDB snapshots when available) to computecompute_epss_velocity()(epss_delta_7d,epss_delta_30d,epss_slope) and runs the signedPreKEVModel(pre_kev_score,pre_kev_flag,pre_kev_reasons_json) wheneverml.mode != "off", persisting all six v2.1.0 columns into DuckDBenrichment_snapshots(src/vulnparse_pin/storage/schema.sql:123-128).
References
- Related docs:
- Related code:
src/vulnparse_pin/app/enrichment_source_loader.py(EnrichmentSourceLoader)src/vulnparse_pin/app/enrichment.py(EnrichmentApplicator,populate_enrichment_snapshots)src/vulnparse_pin/app/enrichment_handoff.py(EnrichmentHandoffBuilder)src/vulnparse_pin/app/index_builder.py(PostEnrichmentIndex)src/vulnparse_pin/utils/enricher.py(EPSSFeedCache)src/vulnparse_pin/ml/pre_kev.py(PreKEVModel,compute_epss_velocity)