Spaces:
Running
Running
A6-R2E-PAY8-D2-B Flagship trial runtime closure
#134
by GuXiaopeng - opened
- core/generation_runner.py +28 -4
core/generation_runner.py
CHANGED
|
@@ -4160,11 +4160,35 @@ class GenerationRunner:
|
|
| 4160 |
entitlement_class = str(snapshot.get("entitlement_class") or "").strip().upper()
|
| 4161 |
if tier not in {"STANDARD", "FLAGSHIP"}:
|
| 4162 |
raise RuntimeError("trusted_task_policy_product_tier_invalid")
|
| 4163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4164 |
raise RuntimeError("trusted_task_policy_entitlement_invalid")
|
| 4165 |
-
if
|
| 4166 |
-
raise RuntimeError("trusted_task_policy_entitlement_mismatch")
|
| 4167 |
-
if tier == "FLAGSHIP" and entitlement_class != "FLAGSHIP_PAID":
|
| 4168 |
raise RuntimeError("trusted_task_policy_entitlement_mismatch")
|
| 4169 |
if str(resolved.get("product_tier") or "").strip().upper() != tier:
|
| 4170 |
raise RuntimeError("trusted_task_policy_product_tier_mismatch")
|
|
|
|
| 4160 |
entitlement_class = str(snapshot.get("entitlement_class") or "").strip().upper()
|
| 4161 |
if tier not in {"STANDARD", "FLAGSHIP"}:
|
| 4162 |
raise RuntimeError("trusted_task_policy_product_tier_invalid")
|
| 4163 |
+
|
| 4164 |
+
# Keep runner validation aligned with the executor's trusted-policy
|
| 4165 |
+
# contract. Entitlement authority comes from the SHA-bound resolved
|
| 4166 |
+
# ProductPolicy, not from a duplicated runtime enum. This preserves
|
| 4167 |
+
# fail-closed behavior while allowing FLAGSHIP_TRIAL when (and only
|
| 4168 |
+
# when) the trusted trial policy explicitly authorizes it.
|
| 4169 |
+
trial = resolved.get("trial") if isinstance(resolved.get("trial"), dict) else None
|
| 4170 |
+
billing = resolved.get("billing") if isinstance(resolved.get("billing"), dict) else None
|
| 4171 |
+
allowed_entitlements: list[str] = []
|
| 4172 |
+
if trial and str(trial.get("entitlement_class") or "").strip():
|
| 4173 |
+
allowed_entitlements.append(str(trial.get("entitlement_class") or "").strip().upper())
|
| 4174 |
+
if billing and str(billing.get("entitlement_class") or "").strip():
|
| 4175 |
+
paid_class = str(billing.get("entitlement_class") or "").strip().upper()
|
| 4176 |
+
if paid_class not in allowed_entitlements:
|
| 4177 |
+
allowed_entitlements.append(paid_class)
|
| 4178 |
+
|
| 4179 |
+
# Backward-compatible trusted snapshots created before the nested
|
| 4180 |
+
# trial/billing objects were embedded still carry SHA-bound policy
|
| 4181 |
+
# version links. Derive their same-tier classes from those links
|
| 4182 |
+
# rather than reopening a duplicated global entitlement whitelist.
|
| 4183 |
+
if not allowed_entitlements:
|
| 4184 |
+
if str(resolved.get("trial_policy_version") or "").strip():
|
| 4185 |
+
allowed_entitlements.append(f"{tier}_TRIAL")
|
| 4186 |
+
if str(resolved.get("billing_policy_version") or "").strip():
|
| 4187 |
+
allowed_entitlements.append(f"{tier}_PAID")
|
| 4188 |
+
|
| 4189 |
+
if not entitlement_class or entitlement_class not in allowed_entitlements:
|
| 4190 |
raise RuntimeError("trusted_task_policy_entitlement_invalid")
|
| 4191 |
+
if any(not value.startswith(f"{tier}_") for value in allowed_entitlements):
|
|
|
|
|
|
|
| 4192 |
raise RuntimeError("trusted_task_policy_entitlement_mismatch")
|
| 4193 |
if str(resolved.get("product_tier") or "").strip().upper() != tier:
|
| 4194 |
raise RuntimeError("trusted_task_policy_product_tier_mismatch")
|