Skip to main content
VulnParse-Pin emblem VulnParse-Pin emblem
VulnParse-Pin
Architecture adr/ADR-0001-config-seam.md
View source on GitHub ↗

ADR-0001: Config Seam Architecture

  • Status: Accepted
  • Date: 2026-04-05
  • Deciders: Architecture Team
  • Tags: config|runtime-policy|extensibility

Context

VulnParse-Pin’s configuration loading was tightly coupled within apppaths.py, mixing concerns of:

  1. File discovery and provisioning
  2. Parsing and deserialization
  3. Schema validation and version policy
  4. Runtime projection into typed bundles

This monolithic approach made it difficult to:

  • Test individual concerns
  • Reuse components for configuration extensions
  • Understand the config loading contract
  • Inject custom validators or loaders for derived use cases

Decision

Implement a staged seam architecture decomposing config loading into explicit boundary-crossing layers:

Stage 0: Compatibility Wrappers

  • Added internal helper functions in apppaths.py as adapters (still present for rollback).
  • Preserved existing load_config(ctx) entrypoint.

Stage 1: Source Module (config_source.py)

  • Extracted file provisioning and reading into ConfigSource class.
  • Owns file discovery, default provisioning, and YAML/JSON parsing.
  • Returns ConfigFileSet and RawConfigPayloads contracts.

Stage 2: Validator Module (config_validator.py)

  • Extracted schema validation and version policy into ConfigValidator class.
  • Owns JSON schema validation and global config version checks.
  • Returns ConfigValidationResult with warnings and errors.

Stage 3: Projector Module (config_projector.py)

  • Extracted runtime projection into ConfigProjector class.
  • Owns conversion of validated payloads to typed RuntimeConfigBundle.
  • Enables future policy object construction (scoring, TopN).

Alternatives Considered

  1. Monolithic refactor in one stage: Higher risk of regressions; harder to test incrementally.
  2. Dependency injection framework: Overkill for current scale; adds runtime complexity.
  3. Configuration factory pattern: Similar outcome but more ceremony for current single config mode.

Consequences

Positive:

  1. Clear contract boundaries enable independent testing and extension.
  2. Schema validation is now testable in isolation.
  3. Future enrichment/pass configuration can reuse same seam pattern.
  4. Staged migration reduces rollback risk.
  5. Configuration policy decisions are now explicit and documented.

Negative:

  1. Light increase in module count (3 new focused modules).
  2. Import graph now requires coordination across config modules.

Compatibility Impact

  • Classification: additive (no breaking changes)
  • Affected contracts: None (all internal refactor)
  • Migration guidance: None required; backward-compatible entrypoint preserved

Test and Validation Plan

  1. Contract tests: Existing tests remain green (155 passed, 38 xfailed expected).
  2. Regression tests: Full suite validates no behavior change.
  3. Runtime verification:
    • Config schema validation tests pass
    • Pass contract tests pass
    • RunManifest tests pass

Rollout and Rollback

  • Rollout steps:

    1. Deploy new modules to codebase
    2. Verify full test suite passes
    3. Monitor config load paths in first runs
  • Rollback strategy:

    1. Stage 0 helpers remain in apppaths.py but unused (can be removed in cleanup stage)
    2. If drift detected, route back to legacy monolithic path via feature toggle (not implemented; low risk)
    3. All config file formats and version policies remain unchanged

v2.0.0 Status

In v2.0.0 (Apache-2.0), this seam architecture was completed and extended for typed v2 policies and workspace context files:

  • ConfigValidator validates both v1 and v2 global/scoring/TopN configs (auto-projecting legacy v1 configs to v2 defaults with structured warnings) and enforces monotonic epss.breakpoints and webhook invariants.
  • ConfigProjector projects validated payloads into RuntimeConfigBundle (VppConfigV2, ScoringPolicyV2, TriagePolicyV2, ACIPolicyV2, and SignalReliabilityPolicy).
  • Workspace-scoped assets.yaml (assets.schema.json -> AssetContextMatcher) and decisions.yaml (decisions.schema.json -> DecisionsRegistry) follow the same safe-YAML + Draft 2020-12 schema validation pattern in src/vulnparse_pin/core/assets_context.py.

v2.1.0 Status

In v2.1.0 (Apache-2.0), the config seam adds typed ML governance and automated assets.yaml inventory compilation:

  • ConfigValidator._validate_ml_config() (src/vulnparse_pin/core/config_validator.py:443-474) validates the ml block in config.yaml (mode, provider, max_aci_uplift, pre_kev_threshold, top_k_attributions, and NUL-free model paths) alongside config.schema.json.
  • ConfigProjector projects MLPolicyV2 onto both VppConfigV2.ml and RuntimeConfigBundle.ml_policy (src/vulnparse_pin/core/config_projector.py:214-232, defaulting to mode="shadow", provider="auto").
  • src/vulnparse_pin/core/inventory_compiler.py (vpp assets compile|audit|bootstrap) integrates with the Contract D assets.yaml seam, enforcing assets.schema.json validation (defaults.criticality nullable, non-whitespace \S patterns) and comment/pin-preserving atomic merges via locked_yaml_file() and PermFileHandler.

References

  • Related docs:
  • Related PRs/code:
    • src/vulnparse_pin/core/config_source.py (ConfigSource)
    • src/vulnparse_pin/core/config_validator.py (ConfigValidator)
    • src/vulnparse_pin/core/config_projector.py (ConfigProjector, MLPolicyV2)
    • src/vulnparse_pin/core/assets_context.py (AssetContextMatcher, DecisionsRegistry)
    • src/vulnparse_pin/core/inventory_compiler.py (compile_inventory_sources, audit_assets_against_db, bootstrap_shadow_stubs)
    • src/vulnparse_pin/core/apppaths.py (load_config)