feat(optimization): Regulatory Optimization — Roadmap/Management renderer over the Capability Delta

Roadmap item 5. GAP analysis and measure-prioritisation are the SAME computation: Required −
Known = the Capability Delta. The Capability Delta Engine (RS-005) computes it once; renderers
read that ONE delta. Interview Renderer (missing info → questions) was already built; this adds
the Roadmap/Management Renderer (missing capabilities → measures ranked by regulatory leverage).

- compliance/optimization/: regulatory_leverage() + select_within_budget() (pure leverage math)
  + roadmap_from_delta(assessment, ...) — the keystone binding optimization to the RS-005 delta
  (dependency optimization → transition_reasoning, acyclic; the delta engine stays hermetic).
  leverage(measure) = number of regulatory requirements it closes at once (e.g. patch management
  → CRA+MaschinenVO+IEC62443+ISO27001 = 4). No new corpus, no new meta-model class (freeze v1.0).
- Welt-1 honesty: percentages are exact count ratios over the IDENTIFIED requirements (the known
  delta), never "% gesetzeskonform".
- reference suite: "Regulatory Optimization" section runs the SAME convergence delta → ranked
  measures + budget answer + the management sentence "of N identified requirements you close M
  with the top-K measures (X%) — highest regulatory leverage".
- ADR-003: Capability Delta Engine — one delta, many renderers; rename Gap → Capability Delta.

13 optimization tests (31 with transition+company), mypy --strict clean, check-loc 0.
Product code with no app caller + ADR/reference = non-runtime → no deploy (ADR-001).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-27 09:49:38 +02:00
parent ffff9bb592
commit cfafa31ea2
7 changed files with 448 additions and 2 deletions
@@ -0,0 +1,48 @@
"""Schemas for the Regulatory Optimization Engine.
These DTOs are *derived views* (computed-not-stored): nothing here is persisted; every value
is recomputed from the input each call. No new meta-model class, no graph (freeze v1.0).
Python 3.9 compatible (no `|` unions).
"""
from __future__ import annotations
from typing import List
from pydantic import BaseModel, Field
class RankedMeasure(BaseModel):
"""One measure (a capability to implement) ranked by its regulatory leverage."""
capability_id: str
covers: List[str] = Field(default_factory=list) # the in-scope requirements it satisfies
leverage: int = 0 # = len(covers): how many it closes at once
cumulative_requirements: int = 0 # running total of requirements closed (ranked order)
cumulative_coverage: float = 0.0 # cumulative_requirements / total_requirements (0..1)
class OptimizationPlan(BaseModel):
"""Measures ranked by regulatory leverage — greatest regulatory effect first.
`total_requirements` counts the IDENTIFIED requirements in scope (the known delta from the
patterns), NOT a company's total legal duties. The percentages are exact count ratios over
this identified set — never a compliance verdict (Welt-1 discipline).
"""
in_scope_requirements: List[str] = Field(default_factory=list) # the distinct requirement keys counted
total_measures: int = 0 # number of distinct measures (delta capabilities)
total_requirements: int = 0 # Sum of leverage = identified requirements closable
ranked_measures: List[RankedMeasure] = Field(default_factory=list)
headline: str = "" # "N identifizierte Anforderungen -> M Massnahmen ..."
class BudgetPlan(BaseModel):
"""The budget answer: with a budget of K measures, which K and how much do they close?"""
budget: int = 0
selected_capabilities: List[str] = Field(default_factory=list)
requirements_closed: int = 0
total_requirements: int = 0
coverage_ratio: float = 0.0 # requirements_closed / total_requirements (0..1)
headline: str = ""