"""Self-checks and validation gates. 1. Schema gate: raw feature ids in observables.yaml, record fields within value_schema (literally reuses scripts/validate_synthetic_observables.py). 2. Raw/normalized consistency: raw fallbacks reproduce the signals. 3. Stage-invariant gate (validate_stage_invariants, reused). 4. Coverage completeness: every degraded channel has an explicit coverage key (except M3 null reps, where the omission is the point). 5. Determinism: regenerating (base_seed, family) is byte-identical. 6. Expected-route match rate, reported by metrics.py. Plus a fixed-cell probe suite covering worst cells, gate endpoints, known decision-surface findings, and representative instance arithmetic. """ from __future__ import annotations import hashlib import importlib.util import json import sys from pathlib import Path # Validation, observables and evaluate_site all come from the repository root # alongside this generator. The AAAI supplement ships the same modules with a # "framework/" segment inserted here. REPO_ROOT = Path(__file__).resolve().parents[2] SRC = REPO_ROOT / "src" if str(SRC) not in sys.path: sys.path.insert(0, str(SRC)) from datacenter_verification.observable_algorithm import evaluate_site # noqa: E402 from . import families, metrics, schema # noqa: E402 _validator_spec = importlib.util.spec_from_file_location( "validate_synthetic_observables", REPO_ROOT / "scripts" / "validate_synthetic_observables.py") _validator = importlib.util.module_from_spec(_validator_spec) _validator_spec.loader.exec_module(_validator) FEATURE_SCHEMAS = _validator.load_feature_schemas( REPO_ROOT / "observables" / "observables.yaml") # ---------------------------------------------------------------- gates ---- def schema_gate(site: dict) -> list: return _validator.validate_raw_features(site, FEATURE_SCHEMAS) def stage_invariant_gate(site: dict, result: dict) -> list: return _validator.validate_stage_invariants(site, result) def _close(a: float, b: float, eps: float = 1e-6) -> bool: return abs(a - b) <= eps * max(1.0, abs(a), abs(b)) def consistency_errors(site: dict) -> list: """Self-check 2: where a signal has a raw fallback, the emitted raw value reproduces the signal within tolerance.""" sig = site.get("normalized_signals", {}) raw = site.get("raw_features", {}) win_s = schema.window_seconds(site["audit_window"]) errors: list = [] sid = site["site_id"] def need(signal_key: str, present: bool): if float(sig.get(signal_key) or 0.0) > 0 and not present: errors.append(f"{sid}: signal {signal_key} > 0 but its raw fallback is absent") busy = raw.get("accelerator_busy_or_utilization_fraction") need("activity_score", bool(busy)) if busy and "activity_score" in sig: raw_val = max(rec["value"] for rec in busy) if not _close(raw_val, float(sig["activity_score"])): errors.append(f"{sid}: busy fraction {raw_val} != activity_score {sig['activity_score']}") tensor = raw.get("tensor_matrix_mxu_neuron_or_engine_active_fraction") if tensor and "activity_score" in sig: raw_val = max(rec["value"] for rec in tensor) if raw_val > float(sig["activity_score"]) + 1e-9: errors.append(f"{sid}: tensor fraction {raw_val} exceeds activity_score (would override)") rate = raw.get("generic_achieved_operation_rate") need("achieved_operations", bool(rate)) if rate and "achieved_operations" in sig: raw_ops = max(rec["operation_rate"] for rec in rate) * win_s if not _close(raw_ops, float(sig["achieved_operations"])): errors.append(f"{sid}: rate*duration {raw_ops} != achieved_operations {sig['achieved_operations']}") counters = {rec["counter_name"]: rec["counter_value"] for rec in raw.get("fabric_port_device_sample_counters", [])} for counter, signal_key in [("collective_cadence_score", "collective_cadence_score"), ("regularity_score", "benchmark_regularity_score"), ("participant_count", "participant_count")]: if counter in counters and signal_key in sig: if not _close(float(counters[counter]), float(sig[signal_key])): errors.append(f"{sid}: counter {counter} {counters[counter]} != signal " f"{signal_key} {sig[signal_key]}") need("collective_cadence_score", "collective_cadence_score" in counters) bursts = sig.get("checkpoint_burst_count") writes = raw.get("storage_write_operation_bytes", []) if bursts is not None and int(bursts) > 0 and len(writes) != int(bursts): errors.append(f"{sid}: {len(writes)} write records != checkpoint_burst_count {bursts}") return errors def coverage_completeness_errors(instance) -> list: """Self-check 4 (guards the null-vs-default-1.0 trap).""" if instance.skip_coverage_check: return [] cov = instance.site.get("coverage", {}) return [f"{instance.site['site_id']}: degraded channel {ch!r} has no explicit coverage key" for ch in instance.degraded_channels if ch not in cov] def determinism_check(base_seed: int, meta, sample: int = 5) -> dict: """Self-check 5: regenerate the first `sample` instances twice and compare SHA256 of the canonical site JSON.""" def digest() -> str: h = hashlib.sha256() for inst in meta.generate(base_seed): if inst.instance_index >= sample: break h.update(json.dumps(inst.site, sort_keys=True).encode("utf-8")) h.update(json.dumps(inst.expected_route_set).encode("utf-8")) return h.hexdigest() first, second = digest(), digest() return {"family": meta.name, "hash": first, "deterministic": first == second} # ---------------------------------------------------- fixed-cell probes ---- GOOD_COV = dict(schema.GOOD_COVERAGE) P1_SIG = {"activity_score": 0.90, "collective_cadence_score": 0.85, "activity_fabric_overlap_fraction": 0.80, "non_serving_score": 0.85, "checkpoint_periodicity_score": 0.80, "checkpoint_burst_count": 4, "checkpoint_activity_adjacency_fraction": 0.78} PEAK = schema.PEAK_RATE DAY = 86400.0 def _bound(count, days): return count * PEAK * days * DAY def _site(name, days=30, cov=None, sig=None, count=8192, peak=PEAK): raw = {"accelerator_count_by_family_sku": [{"count": count}]} if peak is not None: raw["advertised_peak_rate_by_precision"] = [{"peak_rate": peak}] if days >= 28: win = {"start": "2026-04-01T00:00:00Z", "end": "2026-05-01T00:00:00Z"} else: win = {"start": "2026-04-01T00:00:00Z", "end": "2026-04-%02dT00:00:00Z" % (1 + days)} site = {"site_id": name, "scenario_key": name, "scenario_name": name, "scope": f"{name}/accelerator_pool", "audit_window": win, "raw_features": raw, "coverage": dict(GOOD_COV) if cov is None else cov} if sig is not None: site["normalized_signals"] = sig return site def run_probe_suite() -> dict: """Equivalent assertions to probes_r2.py + probes_r2_check.py.""" failures: list = [] count_pass = [0] def check(tag, result, expect_route, c_has=None, c_lacks=None, b_has=None, b_empty=False, sc=None): a = result["stage_outputs"]["A_capacity_gate"] b = result["stage_outputs"]["B_training_candidate_detection"] c = result["stage_outputs"]["C_discrepancy_and_explanation_review"] got = result["final_route"] ok = (got in expect_route) if isinstance(expect_route, (list, set, tuple)) \ else (got == expect_route) if c_has: ok = ok and all(lbl in c["labels"] for lbl in c_has) if c_lacks: ok = ok and all(lbl not in c["labels"] for lbl in c_lacks) if b_has: ok = ok and all(lbl in b["labels"] for lbl in b_has) if b_empty: ok = ok and not b["labels"] if sc is not None: ok = ok and a["short_circuited"] == sc if ok: count_pass[0] += 1 else: failures.append(f"{tag}: A={a['label']} B={b['labels']} C={c['labels']} " f"final={got} expected={expect_route}") # P1 worst cells (every grid row, achieved at the exact 1.05x cap) + low end. for cnt, dmin in families.P1_GRID: sig = dict(P1_SIG) sig["achieved_operations"] = 1.05 * _bound(cnt, dmin) check(f"P1-{cnt}x{dmin}d-achieved1.05xbound", evaluate_site(_site("p1", days=dmin, sig=sig, count=cnt)), "high_training_like_warning", c_lacks=["capacity_claim_conflict"], sc=False) sig = dict(P1_SIG); sig["achieved_operations"] = 3.0e24 check("P1-32768x3d-achieved3e24", evaluate_site(_site("p1lo", days=3, sig=sig, count=32768)), "high_training_like_warning", b_has=["distributed_training_like_candidate"]) sig = dict(P1_SIG); sig["achieved_operations"] = 1.5e25 check("P1-2048-was-trap", evaluate_site(_site("p1trap", days=30, sig=sig, count=2048)), "integrity_review_required", c_has=["capacity_claim_conflict"]) # P2: weak unreachable; primary/serving 0.74 cells -> inconclusive. p2 = {"activity_score": 0.60, "collective_cadence_score": 0.64, "activity_fabric_overlap_fraction": 0.55, "non_serving_score": 0.55} cov = dict(GOOD_COV); cov["activity"] = 0.74; cov["achieved_ops"] = 0.74 check("P2-primary0.74-inconclusive", evaluate_site(_site("p2a", cov=cov, sig=dict(p2))), "inconclusive_due_to_missingness", b_empty=True) cov = dict(GOOD_COV); cov["serving"] = 0.74 check("P2-servcov0.74-inconclusive", evaluate_site(_site("p2b", cov=cov, sig=dict(p2))), "inconclusive_due_to_missingness") # HN1: suppressor fires at overlap >= 0.50; risk band below. hn1 = {"activity_score": 0.88, "collective_cadence_score": 0.85, "activity_fabric_overlap_fraction": 0.75, "hpc_mpi_score": 0.75, "hpc_overlap_fraction": 0.55, "checkpoint_periodicity_score": 0.1} check("HN1-explained", evaluate_site(_site("hn1a", sig=dict(hn1))), "candidate_explained_or_demoted") hn1b = dict(hn1); hn1b["hpc_overlap_fraction"] = 0.45 check("HN1-riskband-warn", evaluate_site(_site("hn1b", sig=hn1b)), ["medium_training_like_warning", "high_training_like_warning"]) # HN2 endpoints: exact 0.90/7200 fire; 0.89/7201 are the risk band. HN2 = {"activity_score": 0.70, "collective_cadence_score": 0.70, "activity_fabric_overlap_fraction": 0.55, "benchmark_regularity_score": 0.90, "benchmark_duration_seconds": 7200, "checkpoint_periodicity_score": 0.0} check("HN2-reg0.90-dur7200-exact", evaluate_site(_site("hn2a", sig=dict(HN2))), "candidate_explained_or_demoted", b_has=["distributed_training_like_candidate"], c_has=["candidate_benchmark_like"]) h = dict(HN2); h.update({"activity_score": 0.95, "collective_cadence_score": 0.95, "activity_fabric_overlap_fraction": 0.85, "benchmark_regularity_score": 0.99, "benchmark_duration_seconds": 600}) check("HN2-allmax", evaluate_site(_site("hn2b", sig=h)), "candidate_explained_or_demoted", c_has=["candidate_benchmark_like"]) h = dict(HN2); h["benchmark_regularity_score"] = 0.89 check("HN2-reg0.89-riskband", evaluate_site(_site("hn2c", sig=h)), ["medium_training_like_warning", "high_training_like_warning"]) h = dict(HN2); h["benchmark_duration_seconds"] = 7201 check("HN2-dur7201-riskband", evaluate_site(_site("hn2d", sig=h)), ["medium_training_like_warning", "high_training_like_warning"]) # HN3: achieved 1.5e25 on the 8192x30d base never trips the capacity conflict. hn3 = {"activity_score": 0.90, "achieved_operations": 1.5e25, "serving_counterevidence_score": 0.75, "serving_activity_overlap_fraction": 0.55, "non_serving_score": 0.05, "collective_cadence_score": 0.1} check("HN3-achieved1.5e25-demoted", evaluate_site(_site("hn3", sig=hn3)), "candidate_explained_or_demoted", c_lacks=["capacity_claim_conflict"], b_has=["large_compute_candidate"]) # HN6: activity floor straddle. hn6 = {"checkpoint_periodicity_score": 0.70, "checkpoint_burst_count": 3, "checkpoint_activity_adjacency_fraction": 0.70, "storage_operation_overlap_fraction": 0.90, "bytes_explained_fraction": 0.80, "collective_cadence_score": 0.1} h = dict(hn6); h["activity_score"] = 0.50 check("HN6-act0.50-demoted", evaluate_site(_site("hn6a", sig=h)), "candidate_explained_or_demoted", b_has=["checkpoint_training_like_candidate"]) h = dict(hn6); h["activity_score"] = 0.49 check("HN6-act0.49-negative", evaluate_site(_site("hn6b", sig=h)), "no_training_like_candidate_detected_in_covered_live_segment", b_empty=True) # HN8: A-gate boundary at 30 d sits between count 1929 and 1930. check("HN8-count1930-possible", evaluate_site(_site("hn8a", sig={"activity_score": 0.0}, count=1930)), "no_training_like_candidate_detected_in_covered_live_segment", sc=False) check("HN8-count1929-ruledout", evaluate_site(_site("hn8b", sig={"activity_score": 0.0}, count=1929)), "capacity_ruled_out_for_scope", sc=True) # M1 knock-out boundaries + the two reported findings. m1sig = dict(P1_SIG); m1sig["achieved_operations"] = 1.2e25 def m1(edits, drop_id=False, sig_extra=None): cov_ = dict(GOOD_COV); cov_.update(edits) if drop_id: del cov_["identity_shape"] sg = dict(m1sig) if sig_extra: sg.update(sig_extra) return evaluate_site(_site("m1", cov=cov_, sig=sg)) check("M1-fabric0.74-noidkey-flips", m1({"fabric": 0.74}, drop_id=True), "inconclusive_due_to_missingness") check("M1-fabric0.75-noidkey-noflip", m1({"fabric": 0.75}, drop_id=True), "high_training_like_warning") check("M1-storage0.0-noidkey-flips", m1({"storage": 0.0}, drop_id=True), "inconclusive_due_to_missingness") check("M1-fabric0.0-WITH-idkey-noflip", m1({"fabric": 0.0}), "high_training_like_warning") check("M1-activity0.5-flips", m1({"activity": 0.5}), "inconclusive_due_to_missingness") check("M1-suppressors0.5-flips", m1({"serving": 0.5, "storage_operations": 0.5, "benchmark_hpc": 0.5}), "inconclusive_due_to_missingness") check("M1-scope0.5-flips", m1({"scope_mapping": 0.5}), "inconclusive_due_to_missingness") check("M1-clock0.79-flips", m1({"clock_alignment": 0.79}), "inconclusive_due_to_missingness") check("M1-clock0.80-noflip", m1({"clock_alignment": 0.80}), "high_training_like_warning") check("M1-attrib0.0-NOFLIP-finding", m1({"attribution": 0.0}), "high_training_like_warning") check("M1-attrib0.9-conflictvariant", m1({"attribution": 0.9}, sig_extra={"attribution_overlap_fraction": 0.0}), "integrity_review_required") # Without the incoherence check, achieved-ops-low with activity-high forged a # clean negative. With _coverage_cert / achieved_ops missingness applied, # with achieved_ops coverage below the negative-screen primary threshold the # negative screen is now BLOCKED and the site routes to inconclusive — the # M1 fix this rerun is verifying. Expected route updated to the FIXED value. for cv in (0.74, 0.5, 0.0): check(f"M1-achievedops{cv}-FIXED-now-inconclusive", m1({"achieved_ops": cv}), "inconclusive_due_to_missingness", b_empty=True, c_has=["negative_screen_blocked_by_missingness"]) # M4 reported finding: C2 ignores the flag on a candidate-bearing base. m4sig = dict(m1sig); m4sig["decision_blocking_missingness"] = True check("M4-flag-on-candidate-base-IGNORED", evaluate_site(_site("m4", sig=m4sig)), "high_training_like_warning") # E1 / E2: a single suppressor demotes the whole true-positive site. # E1: without the per-channel demotion rule, a single serving suppressor # demoted the whole true-positive # site to candidate_explained_or_demoted, which is the evasion. Under # surviving_identity_pathway the strong checkpoint/fabric identity pathway # survives the serving counter-evidence, so the site now routes to a # high_training_like_warning — the E1 fix this rerun verifies. e1 = dict(P1_SIG); e1.update({"serving_counterevidence_score": 0.85, "serving_activity_overlap_fraction": 0.80}) check("E1-serving-evasion-FIXED-now-high", evaluate_site(_site("e1", sig=e1)), "high_training_like_warning") nf2 = {"activity_score": 0.90, "collective_cadence_score": 0.85, "activity_fabric_overlap_fraction": 0.80, "non_serving_score": 0.85, "checkpoint_periodicity_score": 0.0, "checkpoint_burst_count": 0, "storage_operation_overlap_fraction": 0.90, "bytes_explained_fraction": 0.85} # E2: likewise, a storage-operation suppressor demoted the whole site # (candidate_explained_by_storage_operation -> candidate_explained_or_demoted). # Under surviving_identity_pathway the surviving fabric identity # pathway keeps the site at a high_training_like_warning — the E2 fix. check("E2-storage-demotes-WHOLE-site-FIXED-now-high", evaluate_site(_site("e2a", sig=dict(nf2))), "high_training_like_warning", b_has=["distributed_training_like_candidate"], c_has=["candidate_explained_by_storage_operation"]) h = dict(nf2); h["bytes_explained_fraction"] = 0.69 check("E2-bytes0.69-explanation-stops", evaluate_site(_site("e2b", sig=h)), "high_training_like_warning", c_lacks=["candidate_explained_by_storage_operation"]) h = dict(nf2); h["storage_operation_overlap_fraction"] = 0.79 check("E2-overlap0.79-explanation-stops", evaluate_site(_site("e2c", sig=h)), "high_training_like_warning", c_lacks=["candidate_explained_by_storage_operation"]) # E3: fragment worst endpoint evades to a covered negative. e3 = {"activity_score": 0.90, "collective_cadence_score": 0.85, "activity_fabric_overlap_fraction": 0.80, "activity_duration_seconds": 1700, "checkpoint_periodicity_score": 0.80, "checkpoint_burst_count": 1, "checkpoint_activity_adjacency_fraction": 0.78, "achieved_operations": 9.9e24} check("E3-fragment-dur1700-burst1-negative", evaluate_site(_site("e3", days=1, sig=e3, count=65536)), "no_training_like_candidate_detected_in_covered_live_segment", b_empty=True) # E5: attribution conflict is CAUGHT; scope loss is partial evasion. e5a = dict(P1_SIG); e5a["attribution_overlap_fraction"] = 0.02 e5a["achieved_operations"] = 8.0e24 check("E5-attrib-caught", evaluate_site(_site("e5a", sig=e5a)), "integrity_review_required") cov = dict(GOOD_COV); cov["scope_mapping"] = 0.5 check("E5-scope-partial", evaluate_site(_site("e5b", cov=cov, sig=dict(P1_SIG))), "inconclusive_due_to_missingness") # E6 three regimes. sig = dict(P1_SIG); sig["achieved_operations"] = 8.0e24 check("E6-regime1-count1800-ruledout", evaluate_site(_site("e6a", sig=sig, count=1800)), "capacity_ruled_out_for_scope", sc=True) sig = dict(P1_SIG); sig["achieved_operations"] = 1.3e25 check("E6-regime2-count2048-integrity", evaluate_site(_site("e6b", sig=sig, count=2048)), "integrity_review_required", c_has=["capacity_claim_conflict"]) cov = dict(GOOD_COV); cov["capacity"] = 0.85 sig = dict(P1_SIG); sig["achieved_operations"] = 7.0e24 check("E6-regime3-lowcov-warns", evaluate_site(_site("e6c", cov=cov, sig=sig, count=1500)), "high_training_like_warning", sc=False) # I1 conflict-gate endpoints. I1 = {"collective_cadence_score": 0.74, "activity_fabric_overlap_fraction": 0.82, "non_serving_score": 0.82} def i1site(name, activity, overlap, attrib_cov): sg = dict(I1); sg["activity_score"] = activity sg["attribution_overlap_fraction"] = overlap cv = dict(GOOD_COV); cv["attribution"] = attrib_cov return _site(name, cov=cv, sig=sg) check("I1-act0.70-ovl0.05-cov0.80-exact", evaluate_site(i1site("i1a", 0.70, 0.05, 0.80)), "integrity_review_required", b_has=["distributed_training_like_candidate"], c_has=["activity_attribution_conflict"]) check("I1-ovl0.06-no-conflict-warns", evaluate_site(i1site("i1b", 0.88, 0.06, 0.92)), "high_training_like_warning", c_lacks=["activity_attribution_conflict"]) check("I1-cov0.79-no-conflict-warns", evaluate_site(i1site("i1c", 0.88, 0.0, 0.79)), "high_training_like_warning", c_lacks=["activity_attribution_conflict"]) # I2 ratio boundary on the count-2316 base. b_i2 = _bound(2316, 30) check("I2-ratio1.3-integrity", evaluate_site(_site("i2a", sig={"achieved_operations": 1.3 * b_i2}, count=2316)), "integrity_review_required", c_has=["capacity_claim_conflict"]) check("I2-ratio1.05-weak", evaluate_site(_site("i2b", sig={"achieved_operations": 1.05 * b_i2}, count=2316)), "weak_training_like_candidate") # Regression: schema floor, H4, H5, zero count. try: evaluate_site({"site_id": "x", "scenario_key": "x", "scenario_name": "x", "audit_window": {"start": "2026-04-01T00:00:00Z", "end": "2026-05-01T00:00:00Z"}}) failures.append("REG/missing-scope: no KeyError") except KeyError: count_pass[0] += 1 # REG/minimal-floor: a near-empty site (scope + audit window only, no # observables). Without the incoherence check this forged # no_training_like_candidate_detected; the current evaluator # (_coverage_cert / achieved_ops missingness) blocks to # inconclusive_due_to_missingness because the negative screen has no covered # achieved-ops basis. Expected updated to the FIXED route. r = evaluate_site({"site_id": "m", "scenario_key": "m", "scenario_name": "m", "scope": "m/accelerator_pool", "audit_window": {"start": "2026-04-01T00:00:00Z", "end": "2026-05-01T00:00:00Z"}}) if (r["stage_outputs"]["A_capacity_gate"]["label"] == "capacity_unknown_due_to_missing_inputs" and r["final_route"] == "inconclusive_due_to_missingness"): count_pass[0] += 1 else: failures.append("REG/minimal-floor") r = evaluate_site(_site("z", sig={"activity_score": 0.0}, count=0)) stages = r["stage_outputs"] b_labels = stages["B_training_candidate_detection"]["labels"] c_labels = stages["C_discrepancy_and_explanation_review"]["labels"] if (r["final_route"] == "no_training_like_candidate_detected_in_covered_live_segment" and stages["A_capacity_gate"]["label"] == "capacity_unknown_due_to_missing_inputs" and stages["A_capacity_gate"].get("short_circuited") is False and b_labels == [] and "negative_screen_coverage_sufficient" in c_labels): count_pass[0] += 1 else: failures.append("REG/zero-count-not-ruleout") h4 = {"activity_score": 0.88, "collective_cadence_score": 0.80, "activity_fabric_overlap_fraction": 0.75, "non_serving_score": 0.65} check("REG/H4-lone-fabric+nonserving-high", evaluate_site(_site("h4a", sig=dict(h4))), "high_training_like_warning") h = dict(h4); h["non_serving_score"] = 0.40 check("REG/H4-nonserving0.40-medium", evaluate_site(_site("h4b", sig=h)), "medium_training_like_warning") cov = dict(GOOD_COV); cov["serving"] = 0.40 r = evaluate_site(_site("h5", cov=cov, sig=dict(P1_SIG))) c_labels = r["stage_outputs"]["C_discrepancy_and_explanation_review"]["labels"] if (r["final_route"] == "inconclusive_due_to_missingness" and "candidate_demoted_by_unresolved_suppressor" not in c_labels and "candidate_requires_manual_review" in c_labels): count_pass[0] += 1 else: failures.append("REG/H5-dead-branch") # route_curve partition (B1 regression): every emitted curve's per-bin counts # must sum to the number of records carrying the knob (one bin per instance). # Cover both B1 failure modes: shared bin-edge values (the M2/P3 0.01/linspace # grids that landed on edges and were double-counted) and a max value sitting # float-above the top edge (the P1 duration_days drop). Also assert per-bin # route counts sum to the bin n, so the figure feed is internally consistent. def _curve_sums_to_n(tag, recs, knob): n = sum(1 for r in recs if knob in r["parameters"]) curve = metrics.route_curve(recs, knob) total = sum(b["n"] for b in curve) ok = total == n and all(sum(b["routes"].values()) == b["n"] for b in curve) ok = ok and all("_payload" not in b for b in curve) if ok: count_pass[0] += 1 else: failures.append(f"route_curve/{tag}: bins sum to {total} != n {n} " f"(or per-bin route counts disagree)") edge_recs = [{"parameters": {"coverage_step": round(0.60 + 0.01 * i, 2)}, "observed_route": ("medium_training_like_warning" if k % 2 else "no_training_like_candidate_detected_in_covered_live_segment")} for i in range(41) for k in range(24)] # 984, M2-shaped, edge-heavy _curve_sums_to_n("shared-edge-grid", edge_recs, "coverage_step") import numpy as _np drop_recs = [{"parameters": {"duration_days": float(v)}, "observed_route": "r"} for v in _np.linspace(0.0, 29.629033627487072, 60)] # max float-above top edge _curve_sums_to_n("max-on-top-edge", drop_recs, "duration_days") miss_recs = [{"parameters": {}, "observed_route": "r"} for _ in range(5)] _mixed = edge_recs + miss_recs # records missing the knob must not be counted _curve_sums_to_n("knob-absent-excluded", _mixed, "coverage_step") # F8: instance arithmetic. if families.TOTAL_INSTANCES == 20284 and len(families.FAMILIES) == 24: count_pass[0] += 1 else: failures.append(f"F8: {len(families.FAMILIES)} families, " f"{families.TOTAL_INSTANCES} instances (expected 24 / 20284)") group_sums: dict = {} for fam in families.FAMILIES: group_sums[fam.group] = group_sums.get(fam.group, 0) + fam.instances if group_sums == families.GROUP_TOTALS: count_pass[0] += 1 else: failures.append(f"F8 groups: {group_sums} != {families.GROUP_TOTALS}") return {"passed": count_pass[0], "failed": len(failures), "failures": failures, "status": "pass" if not failures else "FAIL"}