79 lines
3 KiB
Python
79 lines
3 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import replace
|
|
from pathlib import Path
|
|
|
|
from adaptive_pricing_core.governance import assess_tier_definition_assurance
|
|
from adaptive_pricing_core.pricing_models import AssuranceClaim
|
|
from observatory.api import build_dashboard_payload
|
|
from observatory.load import load_pricing_models
|
|
|
|
DATA_DIR = Path(__file__).resolve().parent.parent / "data"
|
|
|
|
|
|
def test_governance_payload_contains_policy_health_and_audit_surfaces() -> None:
|
|
payload = build_dashboard_payload(DATA_DIR, "2026-06")
|
|
governance = payload["governance"]
|
|
|
|
assert governance["policy"]["policy_id"] == "coulomb-governance-v1"
|
|
assert governance["publication_assessment"]["decision"] == "approval_required"
|
|
assert governance["audit_surface"]["provider"] == "stripe"
|
|
assert governance["audit_surface"]["revision_count"] == 0
|
|
assert any(
|
|
check["id"] == "provider-execution-health" and check["status"] == "warn"
|
|
for check in governance["health_checks"]
|
|
)
|
|
|
|
|
|
def test_safe_tuning_contract_stays_pilot_only_and_hides_customer_visibility() -> None:
|
|
payload = build_dashboard_payload(DATA_DIR, "2026-06")
|
|
contract = next(
|
|
item
|
|
for item in payload["governance"]["safe_tuning_contracts"]
|
|
if item["model_id"] == "membership-plus-overage"
|
|
)
|
|
|
|
assert contract["mode"] == "pilot_only"
|
|
assert contract["customer_visible"] is False
|
|
assert any(example["outcome"] == "accepted" for example in contract["examples"])
|
|
assert all(example["visible_to_customer"] is False for example in contract["examples"])
|
|
|
|
|
|
def test_recommendations_include_governed_execution_gate() -> None:
|
|
payload = build_dashboard_payload(DATA_DIR, "2026-06")
|
|
execution_gate = next(
|
|
item for item in payload["recommendations"] if item["id"] == "execution-governance-gate"
|
|
)
|
|
|
|
assert execution_gate["recommendation_type"] == "execution"
|
|
assert execution_gate["governance"]["decision"] == "approval_required"
|
|
assert execution_gate["confidence"] == "0.88"
|
|
assert execution_gate["risks"]
|
|
assert execution_gate["supporting_observations"]
|
|
|
|
|
|
def test_changed_assurance_claim_requires_one_time_definition_approval() -> None:
|
|
previous = next(
|
|
item for item in load_pricing_models(DATA_DIR) if item.id == "flat-899-eur-monthly"
|
|
)
|
|
current = replace(
|
|
previous,
|
|
assurance_claims=(
|
|
AssuranceClaim(
|
|
id="availability-tier",
|
|
kind="availability",
|
|
customer_wording="Survives a zone loss.",
|
|
minimum_levels={"V": 3},
|
|
delivering_service="railiance-platform",
|
|
evidence_ref="evidence/zone-failover.json",
|
|
),
|
|
),
|
|
)
|
|
|
|
assessment = assess_tier_definition_assurance(current, previous)
|
|
unchanged = assess_tier_definition_assurance(current, current)
|
|
|
|
assert assessment.decision == "approval_required"
|
|
assert assessment.approvals[0].evidence_refs == ("evidence/zone-failover.json",)
|
|
assert unchanged.decision == "proceed"
|
|
assert unchanged.approvals == ()
|