Config Seam Contract
This document defines the shipped v2.1.0 configuration architecture separating file discovery/provisioning, schema & semantic validation, v1 -> v2 projection, and typed runtime policy bundles, plus workspace inventory/decision context configs.
Objective
Enforce clean boundaries across four stages of runtime configuration plus two workspace context surfaces:
- File discovery and provisioning (
ConfigSource) - Draft 2020-12 schema and semantic validation (
ConfigValidator) - Version compatibility projection & typed runtime bundle (
ConfigProjector) - Workspace context configs (
assets.yamlviaAssetContextMatcher,decisions.yamlviaDecisionsRegistry)
Implemented Contracts
Contract A: Config Source (src/vulnparse_pin/core/config_source.py)
ConfigSource discovers, provisions missing defaults from vulnparse_pin.resources, and reads config.yaml, scoring.json, and tn_triage.json through PermFileHandler (YAML(typ="safe", pure=True) + json.load):
ConfigSource.ensure_files(paths) -> ConfigFileSet(global_yaml, scoring_json, topn_json)ConfigSource.read_payloads(ctx, files) -> RawConfigPayloads(global_config, scoring_config, topn_config)ConfigSource.load_packaged_defaults() -> RawConfigPayloads
Contract B: Config Validator (src/vulnparse_pin/core/config_validator.py)
ConfigValidator.validate(ctx, payloads) -> ConfigValidationResult enforces:
- JSON Schema Draft 2020-12 validation against
config.schema.json,scoring.schema.json, andtopN.schema.json. - Webhook URL/timeout invariants (
https://only, no embedded credentials,timeout_seconds >= max(connect_timeout_seconds, read_timeout_seconds)). - Scoring semantic invariants (monotonically non-decreasing
epss.breakpoints, strictly orderedbands:critical > high > medium > low >= 0). - ML governance config validation (
_validate_ml_configagainstconfig.schema.jsonproperties.ml): enforcesml.mode(off | shadow | active),ml.provider(auto | core | onnx), finiteml.max_aci_upliftin[0.0, 2.5], finiteml.pre_kev_thresholdin[0.05, 0.99], integerml.top_k_attributionsin[1, 20](rejecting booleans), and non-emptyaci_model_path/pre_kev_model_pathstrings without NUL bytes. - Version policy (
SUPPORTED_CONFIG_VERSIONS = ("v1", "v2")): acceptsv2cleanly and auto-projectsv1(or unversioned) configs tov2defaults (_project_global_v1_to_v2,_project_scoring_v1_to_v2) while emitting structured warnings. Unsupported versions raiseRuntimeError.
Contract C: Config Projector (src/vulnparse_pin/core/config_projector.py)
ConfigProjector.project(validation) -> RuntimeConfigBundle builds immutable typed policy dataclasses:
RuntimeConfigBundle.v2_config(VppConfigV2, includingml: MLPolicyV2)RuntimeConfigBundle.scoring_policy(ScoringPolicyV2with.to_v1_policy()bridge)RuntimeConfigBundle.triage_policy(TriagePolicyV2—default/bod-26-04,static_sast_p1_cap)RuntimeConfigBundle.aci_policy(ACIPolicyV2)RuntimeConfigBundle.signal_reliability(SignalReliabilityPolicy)RuntimeConfigBundle.ml_policy(MLPolicyV2—mode,max_aci_uplift,pre_kev_threshold,top_k_attributions,aci_model_path,pre_kev_model_path,provider)
Contract D: Workspace Context Configs (src/vulnparse_pin/core/assets_context.py, src/vulnparse_pin/core/inventory_compiler.py)
Optional per-engagement / per-repository context files are loaded separately from global AppPaths configs and validated against Draft 2020-12 schemas:
assets.yaml(--assets): Validated againstassets.schema.json(version: v1|v2,defaults,rules[], optional inlinedecisions[]) viaAssetContextMatcher.from_file(path, pfh=ctx.pfh). Automated compilation, idempotent rule merging, coverage/drift auditing, and Shadow-IT stub bootstrapping are handled bysrc/vulnparse_pin/core/inventory_compiler.py(vpp assets compile|audit|bootstrap), which validates compiled output againstassets.schema.jsonand writes atomically viaPermFileHandler+locked_yaml_file().decisions.yaml(--decisions): Validated againstdecisions.schema.json(version: v1|v2,decisions[]) viaDecisionsRegistry.from_file(path, pfh=ctx.pfh).