|
39 | 39 | } |
40 | 40 |
|
41 | 41 |
|
| 42 | +def env_bool(name: str, default: bool = False) -> bool: |
| 43 | + value = os.environ.get(name) |
| 44 | + if value is None: |
| 45 | + return default |
| 46 | + |
| 47 | + return value.strip().lower() in ("1", "true", "yes", "on") |
| 48 | + |
| 49 | + |
42 | 50 | class Metrics: |
43 | 51 | def __init__(self) -> None: |
44 | 52 | self.lock = threading.Lock() |
@@ -204,6 +212,12 @@ def parse_args() -> argparse.Namespace: |
204 | 212 | default=float(os.environ.get("DW_PERF_MAX_SERVER_MEMORY_SLOPE_MB_HOUR", "0")), |
205 | 213 | help="If positive and duration is at least 10 minutes, fail when post-warmup server memory slope exceeds this value.", |
206 | 214 | ) |
| 215 | + parser.add_argument( |
| 216 | + "--require-trusted-evidence", |
| 217 | + action="store_true", |
| 218 | + default=env_bool("DW_PERF_REQUIRE_TRUSTED_EVIDENCE"), |
| 219 | + help="Fail if the generated summary is not eligible for trusted_long_soak_v1 evidence.", |
| 220 | + ) |
207 | 221 | args = parser.parse_args() |
208 | 222 | policy_ids = set(SERVER_CACHE_KEY_PATTERNS) |
209 | 223 | args.max_server_cache_keys_by_policy = parse_policy_limit_map( |
@@ -930,6 +944,7 @@ def main() -> int: |
930 | 944 | "max_final_server_cache_keys_by_policy": args.max_final_server_cache_keys_by_policy, |
931 | 945 | "max_server_memory_slope_mb_hour": args.max_server_memory_slope_mb_hour, |
932 | 946 | "min_sample_coverage": args.min_sample_coverage, |
| 947 | + "require_trusted_evidence": args.require_trusted_evidence, |
933 | 948 | }, |
934 | 949 | "evidence": { |
935 | 950 | "started_at": started_at.isoformat().replace("+00:00", "Z"), |
@@ -1015,6 +1030,14 @@ def main() -> int: |
1015 | 1030 | max_final_server_cache_keys_by_policy=args.max_final_server_cache_keys_by_policy, |
1016 | 1031 | failures=failures, |
1017 | 1032 | ) |
| 1033 | + trust_reasons = summary["evidence"]["trust"].get("reasons") or [] |
| 1034 | + if args.require_trusted_evidence and not summary["evidence"]["trust"].get("eligible"): |
| 1035 | + failures.append( |
| 1036 | + "trusted evidence profile is ineligible" |
| 1037 | + + (f": {trust_reasons}" if trust_reasons else "") |
| 1038 | + ) |
| 1039 | + metrics.mark_assertion_failed() |
| 1040 | + summary["failures"] = failures |
1018 | 1041 |
|
1019 | 1042 | metrics_path.write_text(metrics.prometheus(), encoding="utf-8") |
1020 | 1043 | summary_path.write_text(json.dumps(summary, indent=2, sort_keys=True) + "\n", encoding="utf-8") |
|
0 commit comments