"""Deposit-flight playbook, step 4: the protocol, before any build.

The lead-time comparison is fixed first: the label, the metrics, the tuned
internal quality safeguard, the lead-time metrics and margins, and the bank's
review bands with their alert budget. Class `fixture`.
"""

import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))  # playbooks/playbook_api.py
from playbook_api import Api, State

api, state = Api(), State("deposit-flight")

protocol = api.post(
    "/protocols",
    {
        "name": "deposit flight lead time against the quality safeguard (fixture)",
        "provenance": "fixture",
        "labels": [state["label_id"]],
        "metrics": ["auc", "capture@10pct"],
        "arms": ["gbm_tuned"],
        "margins": {"auc": 0.0, "capture@10pct": 0.0},
        "lead_time_metrics": ["median_lead_days", "share_alerted@14d"],
        "lead_time_margins": {"median_lead_days": 0.0, "share_alerted@14d": 0.0},
        "banding_policy": {
            "bands": [
                {"band": "retention_call", "min_score": 0.5},
                {"band": "relationship_review", "min_score": 0.2},
                {"band": "no_action", "min_score": 0.0},
            ],
            "list_size": 40,
            "alert_budget": 20,
        },
    },
    key="deposit-flight-protocol",
)
print(f"provenance: {protocol['provenance']}")
print(f"declared_at: {protocol['declared_at']}")
state.update(
    protocol_id=protocol["protocol_id"],
    banding_policy=protocol["banding_policy"],
    banding_policy_fingerprint=protocol["banding_policy_fingerprint"],
)
