from __future__ import annotations import json import sys import unittest from copy import deepcopy from pathlib import Path ROOT = Path(__file__).resolve().parents[1] SRC = ROOT / "src" if str(SRC) not in sys.path: sys.path.insert(0, str(SRC)) from datacenter_verification.observable_algorithm import ( _capacity_claim_contradictions, _concurrent_peak, _max, evaluate_site, ) class ObservableAlgorithmTest(unittest.TestCase): @classmethod def setUpClass(cls) -> None: payload = json.loads((ROOT / "synthetic" / "sites.json").read_text(encoding="utf-8")) cls.sites = {site["scenario_key"]: site for site in payload["sites"]} cls.results = {key: evaluate_site(site) for key, site in cls.sites.items()} def result(self, key: str) -> dict: return self.results[key] def stage(self, key: str, stage: str) -> dict: return self.result(key)["stage_outputs"][stage] def suppress_identity_pathways(self, site: dict, keep_participant: bool = False) -> None: signals = site.setdefault("normalized_signals", {}) signals["collective_cadence_score"] = 0.0 signals["checkpoint_periodicity_score"] = 0.0 signals["checkpoint_burst_count"] = 0.0 signals["activity_fabric_overlap_fraction"] = 0.0 signals["checkpoint_activity_adjacency_fraction"] = 0.0 if not keep_participant: signals["participant_count"] = 0.0 for record in site.setdefault("raw_features", {}).get("fabric_port_device_sample_counters", []): if record.get("counter_name") == "collective_cadence_score": record["counter_value"] = 0.0 if not keep_participant and record.get("counter_name") == "participant_count": record["counter_value"] = 0.0 def set_raw_rate_integral(self, site: dict, operations: float) -> None: duration = 30 * 24 * 3600 for record in site.setdefault("raw_features", {}).get("generic_achieved_operation_rate", []): record["operation_rate"] = operations / duration def test_all_synthetic_expected_outputs_match(self) -> None: for key, site in self.sites.items(): with self.subTest(key=key): result = self.results[key] expected = site["expected"] self.assertEqual(expected["A_capacity_gate_label"], self.stage(key, "A_capacity_gate")["label"]) self.assertEqual(expected["final_route"], result["final_route"]) self.assertEqual(expected["capacity_short_circuit"], self.stage(key, "A_capacity_gate")["short_circuited"]) b_labels = self.stage(key, "B_training_candidate_detection")["labels"] c_labels = self.stage(key, "C_discrepancy_and_explanation_review")["labels"] for label in expected["B_training_candidate_detection_labels"]: self.assertIn(label, b_labels) for label in expected["C_discrepancy_and_explanation_review_labels"]: self.assertIn(label, c_labels) def test_capacity_ruleout_short_circuits_b_and_c(self) -> None: result = self.result("C_capacity_ruled_out") self.assertEqual("capacity_ruled_out_for_scope", result["final_route"]) self.assertTrue(self.stage("C_capacity_ruled_out", "A_capacity_gate")["short_circuited"]) self.assertEqual("skipped_due_to_capacity_ruleout", self.stage("C_capacity_ruled_out", "B_training_candidate_detection")["mode"]) self.assertEqual("skipped_due_to_capacity_ruleout", self.stage("C_capacity_ruled_out", "C_discrepancy_and_explanation_review")["mode"]) def test_clean_training_reaches_high_warning(self) -> None: result = self.result("A_clean_threshold_training") b = self.stage("A_clean_threshold_training", "B_training_candidate_detection") c = self.stage("A_clean_threshold_training", "C_discrepancy_and_explanation_review") self.assertEqual("high_training_like_warning", result["final_route"]) self.assertIn("distributed_training_like_candidate", b["labels"]) self.assertIn("checkpoint_training_like_candidate", b["labels"]) self.assertEqual("C2_candidate_conflict_adjudication", c["mode"]) self.assertFalse(c["discrepancies"]) self.assertFalse(c["missing_channels"]) def test_algorithm_version_is_v0_3(self) -> None: self.assertEqual("observable_staged_v0.3", self.result("A_clean_threshold_training")["algorithm_version"]) def test_large_compute_alone_does_not_become_medium_or_high_training(self) -> None: result = self.result("K_large_compute_alone") b = self.stage("K_large_compute_alone", "B_training_candidate_detection") self.assertEqual("weak_training_like_candidate", result["final_route"]) self.assertIn("large_compute_candidate", b["labels"]) self.assertNotIn("distributed_training_like_candidate", b["labels"]) self.assertNotIn("checkpoint_training_like_candidate", b["labels"]) self.assertIn("large_compute_training_identity_unresolved", result["caveats"]) def test_activity_alone_stays_clean_negative(self) -> None: result = self.result("L_activity_alone") b = self.stage("L_activity_alone", "B_training_candidate_detection") c = self.stage("L_activity_alone", "C_discrepancy_and_explanation_review") self.assertEqual("no_training_like_candidate_detected_in_covered_live_segment", result["final_route"]) self.assertEqual([], b["labels"]) self.assertEqual("C1_negative_screen_integrity", c["mode"]) self.assertIn("negative_screen_coverage_sufficient", c["labels"]) def test_fabric_alone_and_storage_alone_route_integrity(self) -> None: cases = { "M_fabric_alone": "fabric_without_job_or_topology_mapping_conflict", "N_storage_writes_alone": "checkpoint_writes_without_activity_conflict", } for key, discrepancy in cases.items(): with self.subTest(case=key): result = self.result(key) b = self.stage(key, "B_training_candidate_detection") c = self.stage(key, "C_discrepancy_and_explanation_review") self.assertEqual("integrity_review_required", result["final_route"]) self.assertEqual([], b["labels"]) self.assertEqual("C1_negative_screen_integrity", c["mode"]) self.assertIn("negative_screen_incoherence_conflict", c["labels"]) self.assertIn(discrepancy, c["discrepancies"]) def test_storage_explanation_demotes_checkpoint_candidate(self) -> None: result = self.result("E_storage_operation_explains_checkpoint") b = self.stage("E_storage_operation_explains_checkpoint", "B_training_candidate_detection") c = self.stage("E_storage_operation_explains_checkpoint", "C_discrepancy_and_explanation_review") self.assertIn("checkpoint_training_like_candidate", b["labels"]) self.assertIn("candidate_explained_by_storage_operation", c["labels"]) self.assertEqual("candidate_explained_or_demoted", result["final_route"]) def test_serving_counterevidence_demotes_large_compute_candidate(self) -> None: result = self.result("F_serving_inference_counterevidence") c = self.stage("F_serving_inference_counterevidence", "C_discrepancy_and_explanation_review") self.assertIn("candidate_explained_by_serving", c["labels"]) self.assertEqual("candidate_explained_or_demoted", result["final_route"]) def test_benchmark_and_hpc_alternative_demotes_fabric_candidate(self) -> None: result = self.result("G_hpc_mpi_benchmark_alternative") c = self.stage("G_hpc_mpi_benchmark_alternative", "C_discrepancy_and_explanation_review") self.assertIn("candidate_benchmark_like", c["labels"]) self.assertIn("candidate_hpc_mpi_alternative", c["labels"]) self.assertEqual("candidate_explained_or_demoted", result["final_route"]) def test_covered_negative_and_missing_negative_screen_routes(self) -> None: covered = self.result("B_covered_negative") missing = self.result("D_missingness_blocks_negative_screen") self.assertEqual("no_training_like_candidate_detected_in_covered_live_segment", covered["final_route"]) self.assertIn( "negative_screen_coverage_sufficient", self.stage("B_covered_negative", "C_discrepancy_and_explanation_review")["labels"], ) self.assertEqual("inconclusive_due_to_missingness", missing["final_route"]) self.assertIn( "negative_screen_blocked_by_missingness", self.stage("D_missingness_blocks_negative_screen", "C_discrepancy_and_explanation_review")["labels"], ) def test_capacity_and_activity_attribution_conflicts_route_integrity(self) -> None: capacity = self.result("H_capacity_claim_conflict") attribution = self.result("I_activity_attribution_conflict") self.assertEqual("integrity_review_required", capacity["final_route"]) self.assertIn( "capacity_claim_conflict", self.stage("H_capacity_claim_conflict", "C_discrepancy_and_explanation_review")["labels"], ) self.assertEqual("integrity_review_required", attribution["final_route"]) self.assertIn( "activity_attribution_conflict", self.stage("I_activity_attribution_conflict", "C_discrepancy_and_explanation_review")["labels"], ) # --- FIX 3 (F1, predicate A2'): C1 incoherence integrity --- def _f1_probe(self, fabric: float | None = None, checkpoint: float | None = None) -> dict: probe = deepcopy(self.sites["A_clean_threshold_training"]) probe["normalized_signals"]["activity_score"] = 0.30 for key in ( "accelerator_busy_or_utilization_fraction", "tensor_matrix_mxu_neuron_or_engine_active_fraction", ): if key in probe.get("raw_features", {}): probe["raw_features"][key] = [{"value": 0.30}] probe["normalized_signals"]["achieved_operations"] = 5e24 if fabric is not None: probe["normalized_signals"]["collective_cadence_score"] = fabric if checkpoint is not None: probe["normalized_signals"]["checkpoint_periodicity_score"] = checkpoint return probe def test_f1_shaped_activity_does_not_certify_clean_negative(self) -> None: result = evaluate_site(self._f1_probe()) self.assertEqual("integrity_review_required", result["final_route"]) self.assertEqual( "C1_negative_screen_integrity", result["stage_outputs"]["C_discrepancy_and_explanation_review"]["mode"], ) def test_f1_fabric_only_variant_routes_integrity(self) -> None: result = evaluate_site(self._f1_probe(checkpoint=0.0)) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("fabric_without_job_or_topology_mapping_conflict", result["discrepancy_findings"]) def test_f1_checkpoint_only_variant_routes_integrity(self) -> None: result = evaluate_site(self._f1_probe(fabric=0.0)) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("checkpoint_writes_without_activity_conflict", result["discrepancy_findings"]) def test_f1_covered_negative_and_storage_explained_unaffected(self) -> None: self.assertEqual( "no_training_like_candidate_detected_in_covered_live_segment", self.result("B_covered_negative")["final_route"], ) self.assertEqual( "candidate_explained_or_demoted", self.result("E_storage_operation_explains_checkpoint")["final_route"], ) # --- high-activity alignment shading cannot certify absence --- def _alignment_shading_probe( self, activity: float = 0.91, fabric_overlap: float = 0.49, checkpoint_adjacency: float = 0.49, achieved: float = 9.0e24, fabric_score: float = 0.86, checkpoint_score: float = 0.82, ) -> dict: probe = deepcopy(self.sites["A_clean_threshold_training"]) sig = probe["normalized_signals"] sig["activity_score"] = activity sig["activity_fabric_overlap_fraction"] = fabric_overlap sig["checkpoint_activity_adjacency_fraction"] = checkpoint_adjacency sig["achieved_operations"] = achieved sig["collective_cadence_score"] = fabric_score sig["checkpoint_periodicity_score"] = checkpoint_score for key in ( "accelerator_busy_or_utilization_fraction", "tensor_matrix_mxu_neuron_or_engine_active_fraction", ): if key in probe.get("raw_features", {}): probe["raw_features"][key] = [{"value": activity}] return probe def test_fatal1_exact_alignment_shading_does_not_certify_absence(self) -> None: result = evaluate_site(self._alignment_shading_probe()) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("fabric_activity_alignment_incoherence_conflict", result["discrepancy_findings"]) self.assertIn("checkpoint_activity_alignment_incoherence_conflict", result["discrepancy_findings"]) self.assertNotIn( result["final_route"], {"capacity_ruled_out_for_scope", "no_training_like_candidate_detected_in_covered_live_segment"}, ) def test_fatal1_alignment_shading_activity_band_variants(self) -> None: for activity in (0.55, 0.70, 0.95): with self.subTest(activity=activity): result = evaluate_site(self._alignment_shading_probe(activity=activity)) self.assertEqual("integrity_review_required", result["final_route"]) def test_fatal1_single_alignment_shaded_variants_do_not_certify_absence(self) -> None: cases = [ ("fabric_only", 0.49, 0.78, "checkpoint_training_like_candidate"), ("checkpoint_only", 0.82, 0.49, "distributed_training_like_candidate"), ] for name, fabric_overlap, checkpoint_adj, surviving_b_label in cases: with self.subTest(name=name): result = evaluate_site( self._alignment_shading_probe( fabric_overlap=fabric_overlap, checkpoint_adjacency=checkpoint_adj, ) ) self.assertNotIn( result["final_route"], {"capacity_ruled_out_for_scope", "no_training_like_candidate_detected_in_covered_live_segment"}, ) self.assertIn(surviving_b_label, result["stage_outputs"]["B_training_candidate_detection"]["labels"]) def test_fatal1_alignment_gate_boundary_forms_candidates_normally(self) -> None: result = evaluate_site( self._alignment_shading_probe( fabric_overlap=0.50, checkpoint_adjacency=0.50, achieved=1.15e25, ) ) b_labels = result["stage_outputs"]["B_training_candidate_detection"]["labels"] self.assertIn("distributed_training_like_candidate", b_labels) self.assertIn("checkpoint_training_like_candidate", b_labels) self.assertEqual("high_training_like_warning", result["final_route"]) def test_fatal1_capacity_adjustment_deflation_with_raw_capacity_witness_is_blocked(self) -> None: probe = deepcopy(self.sites["A_clean_threshold_training"]) probe["normalized_signals"]["capacity_adjustment_factor"] = 0.20 probe["normalized_signals"]["achieved_operations"] = 6.0e24 self.set_raw_rate_integral(probe, 6.0e24) result = evaluate_site(probe) self.assertEqual("integrity_review_required", result["final_route"]) contradictions = _capacity_claim_contradictions(result["derived_signals"], probe) self.assertIn("capacity_adjustment_deflates_raw_threshold_capacity", contradictions) def test_fatal1_benign_explanation_does_not_suppress_alignment_incoherence(self) -> None: probe = self._alignment_shading_probe( fabric_overlap=0.0, checkpoint_adjacency=0.0, achieved=0.0, ) self.set_raw_rate_integral(probe, 0.0) probe["normalized_signals"]["storage_operation_overlap_fraction"] = 0.80 probe["normalized_signals"]["bytes_explained_fraction"] = 0.70 result = evaluate_site(probe) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("negative_screen_incoherence_conflict", result["stage_outputs"]["C_discrepancy_and_explanation_review"]["labels"]) self.assertIn("fabric_activity_alignment_incoherence_conflict", result["discrepancy_findings"]) self.assertIn("checkpoint_activity_alignment_incoherence_conflict", result["discrepancy_findings"]) def test_fatal1_zero_count_does_not_capacity_ruleout_with_witnesses_standing(self) -> None: probe = deepcopy(self.sites["A_clean_threshold_training"]) for record in probe["raw_features"].get("accelerator_count_by_family_sku", []): record["count"] = 0.0 result = evaluate_site(probe) a = result["stage_outputs"]["A_capacity_gate"] self.assertEqual("capacity_unknown_due_to_missing_inputs", a["label"]) self.assertFalse(a["short_circuited"]) self.assertIn("accelerator_count_by_family_sku", a["missing_inputs"]) self.assertNotEqual("capacity_ruled_out_for_scope", result["final_route"]) def test_absent_serving_evidence_does_not_count_as_nonserving_identity(self) -> None: probe = deepcopy(self.sites["A_clean_threshold_training"]) sig = probe["normalized_signals"] sig["checkpoint_periodicity_score"] = 0.0 sig["checkpoint_burst_count"] = 0.0 sig["checkpoint_activity_adjacency_fraction"] = 0.0 sig.pop("serving_counterevidence_score", None) sig.pop("non_serving_score", None) result = evaluate_site(probe) b = result["stage_outputs"]["B_training_candidate_detection"] self.assertEqual("medium_training_like_warning", result["final_route"]) self.assertEqual(1, b["identity_category_count"]) self.assertIn("distributed_training_like_candidate", b["labels"]) self.assertNotIn("checkpoint_training_like_candidate", b["labels"]) def test_invalid_audit_window_does_not_capacity_ruleout(self) -> None: probe = deepcopy(self.sites["C_capacity_ruled_out"]) probe["audit_window"] = { "start": "2026-05-01T00:00:00Z", "end": "2026-04-01T00:00:00Z", } result = evaluate_site(probe) a = result["stage_outputs"]["A_capacity_gate"] c = result["stage_outputs"]["C_discrepancy_and_explanation_review"] self.assertEqual("capacity_unknown_due_to_missing_inputs", a["label"]) self.assertFalse(a["short_circuited"]) self.assertIn("audit_window", a["missing_inputs"]) self.assertEqual("inconclusive_due_to_missingness", result["final_route"]) self.assertIn("audit_window", c["missing_channels"]) def test_unknown_unit_raw_rate_does_not_create_large_compute_candidate(self) -> None: probe = deepcopy(self.sites["A_clean_threshold_training"]) self.suppress_identity_pathways(probe) probe["normalized_signals"].pop("achieved_operations", None) duration = 30 * 24 * 3600 probe["raw_features"]["generic_achieved_operation_rate"] = [ { "sample_time": "2026-04-16T00:00:00Z", "operation_rate": 2.0e25 / duration, "operation_unit": "unknown_vendor_units", "counter_scope": "accelerator_pool", } ] result = evaluate_site(probe) achieved = result["derived_signals"]["achieved_operation_integral"] b = result["stage_outputs"]["B_training_candidate_detection"] self.assertEqual(0.0, achieved["operation_count"]) self.assertFalse(achieved["unit_normalized"]) self.assertTrue(achieved["ignored_raw_rate_unit"]) self.assertNotIn("large_compute_candidate", b["labels"]) self.assertNotIn(result["final_route"], {"weak_training_like_candidate", "medium_training_like_warning", "high_training_like_warning"}) def test_negative_capacity_adjustment_factor_does_not_capacity_ruleout(self) -> None: probe = deepcopy(self.sites["C_capacity_ruled_out"]) probe["normalized_signals"]["capacity_adjustment_factor"] = -1.0 result = evaluate_site(probe) a = result["stage_outputs"]["A_capacity_gate"] cap = result["derived_signals"]["capacity_upper_bound_flop"] self.assertTrue(cap["invalid_capacity_adjustment_factor"]) self.assertEqual("capacity_unknown_due_to_missing_inputs", a["label"]) self.assertFalse(a["short_circuited"]) self.assertIn("capacity_adjustment_factor", a["missing_inputs"]) self.assertNotEqual("capacity_ruled_out_for_scope", result["final_route"]) def test_fatal1_raw_threshold_rate_blocks_covered_negative(self) -> None: probe = deepcopy(self.sites["A_clean_threshold_training"]) probe["normalized_signals"]["achieved_operations"] = 0.0 probe["normalized_signals"]["activity_duration_seconds"] = 1799.0 probe["normalized_signals"]["checkpoint_periodicity_score"] = 0.54 result = evaluate_site(probe) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn( "raw_rate_threshold_compute_without_candidate_conflict", result["discrepancy_findings"], ) # --- FIX 1 (M1): achieved_ops in the negative screen --- def test_negative_screen_blocks_on_missing_achieved_ops(self) -> None: site = deepcopy(self.sites["B_covered_negative"]) site["coverage"]["achieved_ops"] = 0.0 result = evaluate_site(site) self.assertEqual("inconclusive_due_to_missingness", result["final_route"]) self.assertIn("achieved_ops", result["missing_channels"]) # --- FIX 2 (M3): polarity-correct certification coverage --- def test_omitted_certification_key_does_not_increase_confidence(self) -> None: site = deepcopy(self.sites["B_covered_negative"]) del site["coverage"]["achieved_ops"] self.assertEqual("inconclusive_due_to_missingness", evaluate_site(site)["final_route"]) def test_omitting_attribution_does_not_disable_integrity_guard(self) -> None: site = deepcopy(self.sites["I_activity_attribution_conflict"]) del site["coverage"]["attribution"] self.assertEqual("integrity_review_required", evaluate_site(site)["final_route"]) def test_omitting_capacity_blocks_capacity_ruleout(self) -> None: site = deepcopy(self.sites["C_capacity_ruled_out"]) del site["coverage"]["capacity"] result = evaluate_site(site) self.assertNotEqual("capacity_ruled_out_for_scope", result["final_route"]) self.assertFalse(result["stage_outputs"]["A_capacity_gate"]["short_circuited"]) def test_omitting_achieved_ops_on_integrity_fixture_routes_inconclusive(self) -> None: site = deepcopy(self.sites["I_activity_attribution_conflict"]) del site["coverage"]["achieved_ops"] result = evaluate_site(site) self.assertEqual("inconclusive_due_to_missingness", result["final_route"]) self.assertIn("achieved_ops", result["missing_channels"]) # --- FIX 4 (M-2): per-category serving/storage carve-outs --- def test_serving_shape_does_not_demote_independent_checkpoint_pathway(self) -> None: instance = deepcopy(self.sites["A_clean_threshold_training"]) sig = instance["normalized_signals"] sig["activity_fabric_overlap_fraction"] = 0.49 sig["serving_counterevidence_score"] = 0.75 sig["serving_activity_overlap_fraction"] = 0.80 result = evaluate_site(instance) self.assertTrue(result["final_route"].endswith("_warning")) self.assertNotEqual("candidate_explained_or_demoted", result["final_route"]) c = result["stage_outputs"]["C_discrepancy_and_explanation_review"] self.assertIn("candidate_explained_by_serving", c["labels"]) self.assertTrue(c["surviving_identity_pathway"]) self.assertIn("checkpoint_training_like_candidate", result["stage_outputs"]["B_training_candidate_detection"]["labels"]) def test_storage_relabel_does_not_demote_live_fabric_pathway(self) -> None: instance = deepcopy(self.sites["A_clean_threshold_training"]) sig = instance["normalized_signals"] sig["checkpoint_activity_adjacency_fraction"] = 0.49 sig["storage_operation_overlap_fraction"] = 0.85 sig["bytes_explained_fraction"] = 0.80 result = evaluate_site(instance) self.assertTrue(result["final_route"].endswith("_warning")) self.assertNotEqual("candidate_explained_or_demoted", result["final_route"]) c = result["stage_outputs"]["C_discrepancy_and_explanation_review"] self.assertIn("candidate_explained_by_storage_operation", c["labels"]) self.assertTrue(c["surviving_identity_pathway"]) self.assertIn("distributed_training_like_candidate", result["stage_outputs"]["B_training_candidate_detection"]["labels"]) def test_model_parallel_inference_serving_still_suppressed(self) -> None: result = self.result("F_serving_inference_counterevidence") c = self.stage("F_serving_inference_counterevidence", "C_discrepancy_and_explanation_review") self.assertEqual("candidate_explained_or_demoted", result["final_route"]) self.assertIn("candidate_explained_by_serving", c["labels"]) self.assertFalse(c["surviving_identity_pathway"]) # --- FIX 5 (F2): forged capacity rule-out via under-reported accelerator count --- def _f2_count_shaded_probe(self, count: float = 100.0) -> dict: probe = deepcopy(self.sites["A_clean_threshold_training"]) raw = probe.get("raw_features", {}) for record in raw.get("accelerator_count_by_family_sku", []): record["count"] = count for record in raw.get("allocated_accelerator_count_by_sku", []): if "count" in record: record["count"] = count return probe def test_f2_count_shaded_ruleout_routes_integrity_without_disturbing_legit_ruleouts(self) -> None: # (1) F2 PROBE: a genuine positive whose accelerator count is shaded down so the # capacity upper bound drops below T_sys must NOT certify a capacity rule-out while the # untouched, well-covered achieved-operation integral still exceeds that shaded bound. probe = evaluate_site(self._f2_count_shaded_probe()) achieved = probe["derived_signals"]["achieved_operation_integral"] self.assertGreater(achieved["operation_count_to_capacity_upper_bound_ratio"], 1.0) self.assertGreaterEqual(achieved["coverage_fraction"], 0.75) self.assertEqual("integrity_review_required", probe["final_route"]) self.assertNotEqual("capacity_ruled_out_for_scope", probe["final_route"]) self.assertFalse(probe["stage_outputs"]["A_capacity_gate"]["short_circuited"]) self.assertIn("capacity_claim_conflict", probe["discrepancy_findings"]) # (2) LEGITIMATE RULE-OUT: the synthetic clean rule-out fixture must STILL rule out. # Additional low-ratio and sequential-reuse rule-out locks below replace the old # external sweep dependency. fixture = self.result("C_capacity_ruled_out") self.assertEqual("capacity_ruled_out_for_scope", fixture["final_route"]) self.assertTrue(fixture["stage_outputs"]["A_capacity_gate"]["short_circuited"]) # (3) I2 FIXTURE: the existing capacity_claim_conflict fixture still routes to integrity. i2 = self.result("H_capacity_claim_conflict") self.assertEqual("integrity_review_required", i2["final_route"]) self.assertIn( "capacity_claim_conflict", self.stage("H_capacity_claim_conflict", "C_discrepancy_and_explanation_review")["labels"], ) # --- service-power and low-coverage achieved witnesses --- def _ruleout_forge_base( self, count: float = 1000.0, achieved: float = 1e23, suppress_identity: bool = False, ) -> dict: probe = deepcopy(self.sites["A_clean_threshold_training"]) raw = probe.setdefault("raw_features", {}) sig = probe.setdefault("normalized_signals", {}) for record in raw.get("accelerator_count_by_family_sku", []): record["count"] = count sig["achieved_operations"] = achieved sig["participant_count"] = 0 for record in raw.get("fabric_port_device_sample_counters", []): if record.get("counter_name") == "participant_count": record["counter_value"] = 0 for key in ( "allocated_accelerator_count_by_sku", "accelerator_compute_billing_usage_intervals", "compute_running_intervals", "scaleout_fabric_domain_graph", "capacity_reservation_intervals", "reservation_state_intervals", "instance_type_shape_machine_type", "local_accelerator_interconnect_domain", ): raw.pop(key, None) for record in raw.get("generic_achieved_operation_rate", []): record["operation_rate"] = 0.0 if suppress_identity: self.suppress_identity_pathways(probe) probe["coverage"]["achieved_ops"] = 0.74 return probe def test_major2_large_achieved_override_blocks_ruleout_under_shaded_coverage(self) -> None: probe = self._ruleout_forge_base(achieved=1.15e25) probe["raw_features"].pop("generic_achieved_operation_rate", None) result = evaluate_site(probe) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) self.assertIn( "achieved_operations_exceed_capacity_bound", _capacity_claim_contradictions(result["derived_signals"], probe), ) def test_major2_raw_rate_blocks_ruleout_under_shaded_coverage(self) -> None: probe = self._ruleout_forge_base(achieved=1e23) duration = 30 * 24 * 3600 probe["raw_features"]["generic_achieved_operation_rate"] = [ { "sample_time": "2026-04-16T00:00:00Z", "operation_rate": 1.15e25 / duration, "operation_unit": "synthetic_normalized_operations", "counter_scope": "accelerator_pool", } ] result = evaluate_site(probe) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn( "raw_achieved_rate_integral_exceeds_capacity_bound", _capacity_claim_contradictions(result["derived_signals"], probe), ) def test_major2_below_bound_low_coverage_ruleout_preserved(self) -> None: probe = self._ruleout_forge_base(achieved=1e23, suppress_identity=True) probe["raw_features"].pop("electrical_service_status_intervals", None) result = evaluate_site(probe) self.assertEqual("capacity_ruled_out_for_scope", result["final_route"]) self.assertEqual([], result["discrepancy_findings"]) def test_major2_unit_safety_for_achieved_and_raw_rate(self) -> None: override = self._ruleout_forge_base(achieved=1.15e25, suppress_identity=True) override["normalized_signals"]["achieved_operations_unit_normalized"] = False override["raw_features"].pop("generic_achieved_operation_rate", None) override["raw_features"].pop("electrical_service_status_intervals", None) self.assertEqual("capacity_ruled_out_for_scope", evaluate_site(override)["final_route"]) raw = self._ruleout_forge_base(achieved=1e23, suppress_identity=True) duration = 30 * 24 * 3600 raw["raw_features"]["generic_achieved_operation_rate"] = [ { "sample_time": "2026-04-16T00:00:00Z", "operation_rate": 1.15e25 / duration, "operation_unit": "unknown_vendor_units", "counter_scope": "accelerator_pool", } ] raw["raw_features"].pop("electrical_service_status_intervals", None) self.assertEqual("capacity_ruled_out_for_scope", evaluate_site(raw)["final_route"]) def test_major1_scoped_service_power_floor_blocks_ruleout(self) -> None: probe = self._ruleout_forge_base(achieved=1e23) result = evaluate_site(probe) self.assertEqual("integrity_review_required", result["final_route"]) notes = " ".join(result["stage_outputs"]["A_capacity_gate"]["notes"]) self.assertIn("Independent capacity-scale witnesses", notes) self.assertNotIn("achieved-operation integral exceeds", notes) self.assertIn( "electrical_service_power_floor_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) def test_major1_service_power_floor_requires_scope_and_supporting_status(self) -> None: for field, value in (("service_class", "unscoped_facility_service"), ("service_status", "pending")): with self.subTest(field=field): probe = self._ruleout_forge_base(achieved=1e23, suppress_identity=True) for record in probe["raw_features"].get("electrical_service_status_intervals", []): record[field] = value result = evaluate_site(probe) self.assertEqual("capacity_ruled_out_for_scope", result["final_route"]) self.assertNotIn( "electrical_service_power_floor_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) def test_major1_split_concurrent_scoped_service_floor_blocks_ruleout(self) -> None: probe = self._ruleout_forge_base(count=100.0, achieved=1e23, suppress_identity=True) proto = probe["raw_features"]["electrical_service_status_intervals"][0] probe["raw_features"]["electrical_service_status_intervals"] = [ dict( proto, service_status="energized", service_class="synthetic_datacenter_service", service_capacity_mw=0.072, power_mw=0.0, mean_power_mw=0.0, max_power_mw=0.0, ) for _ in range(40) ] result = evaluate_site(probe) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn( "electrical_service_power_floor_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) def test_major1_sequential_scoped_service_floor_does_not_overcount(self) -> None: probe = self._ruleout_forge_base(count=100.0, achieved=1e23, suppress_identity=True) proto = probe["raw_features"]["electrical_service_status_intervals"][0] probe["raw_features"]["electrical_service_status_intervals"] = [ dict( proto, start_time="2026-04-01T00:00:00Z", end_time="2026-04-16T00:00:00Z", service_capacity_mw=0.072, ), dict( proto, start_time="2026-04-16T00:00:00Z", end_time="2026-05-01T00:00:00Z", service_capacity_mw=0.072, ), ] result = evaluate_site(probe) self.assertEqual("capacity_ruled_out_for_scope", result["final_route"]) self.assertNotIn( "electrical_service_power_floor_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) # --- FIX 6 (F3): generalized capacity-claim contradiction (coordinated forge) --- def _f3_probe( self, count: float = 100.0, achieved: float = 1e23, suppress_participant: bool = False, suppress_allocated: bool = False, suppress_billing: bool = False, suppress_running: bool = False, suppress_fabric_graph: bool = False, suppress_service: bool = False, suppress_identity: bool = False, keep_participant_identity: bool = False, ) -> dict: # Coordinated forge: shade the accelerator count down AND shade achieved-ops down in # lockstep so the achieved/capacity ratio stays below 1.0 (defeating the F2 guard). probe = deepcopy(self.sites["A_clean_threshold_training"]) raw = probe.setdefault("raw_features", {}) signals = probe.setdefault("normalized_signals", {}) for record in raw.get("accelerator_count_by_family_sku", []): record["count"] = count signals["achieved_operations"] = achieved # Shade BOTH the override and the raw achieved-rate witness in lockstep, so the # F4 raw-rate sub-check is also defeated (the full coordinated shading move). for record in raw.get("generic_achieved_operation_rate", []): record["operation_rate"] = 0.0 if suppress_participant: signals["participant_count"] = 0 for record in raw.get("fabric_port_device_sample_counters", []): if record.get("counter_name") == "participant_count": record["counter_value"] = 0 if suppress_allocated: raw.pop("allocated_accelerator_count_by_sku", None) if suppress_billing: raw.pop("accelerator_compute_billing_usage_intervals", None) # F5: the remaining device-population witnesses the four count-comparison checks # never read. The running-accelerator interval count and the scale-out fabric # node/switch counts must also be suppressed for the rule-out to forge. if suppress_running: raw.pop("compute_running_intervals", None) if suppress_fabric_graph: raw.pop("scaleout_fabric_domain_graph", None) if suppress_service: raw.pop("electrical_service_status_intervals", None) if suppress_identity: self.suppress_identity_pathways(probe, keep_participant=keep_participant_identity) return probe def _f3_full_suppression(self, count: float = 100.0, achieved: float = 1e23) -> dict: return self._f3_probe( count=count, achieved=achieved, suppress_participant=True, suppress_allocated=True, suppress_billing=True, suppress_running=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, ) def test_f3_coordinated_forge_does_not_rule_out_while_scale_signal_survives(self) -> None: # The pure F3 maneuver: count shaded AND achieved-ops shaded so the F2 ratio guard is # below 1.0, yet participant_count / allocated / billed device-seconds still exceed the # claimed count. Must NOT certify a capacity rule-out; routes to integrity. base = evaluate_site(self._f3_probe()) ratio = base["derived_signals"]["achieved_operation_integral"][ "operation_count_to_capacity_upper_bound_ratio" ] self.assertLessEqual(ratio, 1.0) # the F2 ratio guard does NOT fire here self.assertNotEqual("capacity_ruled_out_for_scope", base["final_route"]) self.assertEqual("integrity_review_required", base["final_route"]) self.assertIn("capacity_claim_conflict", base["discrepancy_findings"]) # Each independent scale signal alone is sufficient to block the forge. Suppress the # others and confirm the surviving one still routes to integrity. participant_only = evaluate_site( self._f3_probe( suppress_allocated=True, suppress_billing=True, suppress_running=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, keep_participant_identity=True, ) ) self.assertEqual("integrity_review_required", participant_only["final_route"]) allocated_only = evaluate_site( self._f3_probe( suppress_participant=True, suppress_billing=True, suppress_running=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, ) ) self.assertEqual("integrity_review_required", allocated_only["final_route"]) billing_only = evaluate_site( self._f3_probe( suppress_participant=True, suppress_allocated=True, suppress_running=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, ) ) self.assertEqual("integrity_review_required", billing_only["final_route"]) def test_f3_irreducible_residual_requires_suppressing_every_scale_signal(self) -> None: # The forge only succeeds when EVERY enumerated device-population witness is coherently # suppressed at once: achieved-ops shaded (override + raw rate), participant_count zeroed, # allocated removed, billing removed, the running-accelerator interval removed, and the # scale-out fabric graph removed, and strong fabric/checkpoint identity suppressed. With # no contradicting evidence present, the rule-out is vacuously consistent. This documents # the disclosed irreducible residual (the true limit of telemetry-grounded verification); # if a new witness were added the guard would need to cover it and this test would flip. residual = evaluate_site(self._f3_full_suppression()) self.assertEqual("capacity_ruled_out_for_scope", residual["final_route"]) self.assertEqual([], residual["discrepancy_findings"]) def test_f5_running_accelerator_count_alone_blocks_forge(self) -> None: # F5 regression: the F3 minimal recipe that suppresses participant/allocated/billing/ # achieved but leaves compute_running_intervals.accelerator_count honest must NOT forge a # rule-out. The running-accelerator count exceeds the shaded claimed count and routes to # integrity. (The fabric graph is also suppressed here so the running count is the ONLY # surviving witness, proving it alone is load-bearing.) probe = self._f3_probe( suppress_participant=True, suppress_allocated=True, suppress_billing=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, ) result = evaluate_site(probe) derived = result["derived_signals"] running = _max(probe["raw_features"].get("compute_running_intervals", []), "accelerator_count") count = derived["capacity_upper_bound_flop"]["count"] self.assertGreater(running, count) self.assertIn( "running_accelerator_count_exceeds_capacity_count", _capacity_claim_contradictions(derived, probe), ) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) self.assertFalse(result["stage_outputs"]["A_capacity_gate"]["short_circuited"]) def test_f5_fabric_node_count_alone_blocks_forge(self) -> None: # F5 regression: with every other witness suppressed (including compute_running), the # scale-out fabric node/switch counts still exceed the shaded claimed count and block the # forge. Each fabric node hosts at least one accelerator, so node_count is a physical # floor on the accelerator population. probe = self._f3_probe( suppress_participant=True, suppress_allocated=True, suppress_billing=True, suppress_running=True, suppress_service=True, suppress_identity=True, ) result = evaluate_site(probe) self.assertIn( "fabric_node_count_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) self.assertFalse(result["stage_outputs"]["A_capacity_gate"]["short_circuited"]) # --- FIX 7 (F6): additive witnesses aggregated by concurrent semantics, not _max --- def _f6_split_pool_probe( self, claimed: float = 100.0, per_record: int = 80, true_pop: int = 3072 ) -> dict: # The F6 forge: shade the accelerator count to a small claim, mask both achieved # channels, falsify every _sum / counter / fabric witness to a value consistent # with the small claim, and report the genuinely large running pool HONESTLY as # many CONCURRENT sub-pool records (identical window), each accelerator_count # below the claimed count. Under _max the guard read only the largest sub-record # (per_record) and certified a rule-out; the overlap-aware concurrent peak now # sums the concurrent sub-pools back to the true population. probe = deepcopy(self.sites["A_clean_threshold_training"]) raw = probe.setdefault("raw_features", {}) signals = probe.setdefault("normalized_signals", {}) for record in raw.get("accelerator_count_by_family_sku", []): record["count"] = claimed signals["achieved_operations"] = 0.0 raw.pop("generic_achieved_operation_rate", None) half = int(claimed) // 2 for record in raw.get("allocated_accelerator_count_by_sku", []): record["count"] = half signals["participant_count"] = half for record in raw.get("fabric_port_device_sample_counters", []): if record.get("counter_name") == "participant_count": record["counter_value"] = half for record in raw.get("scaleout_fabric_domain_graph", []): record["node_count"] = half record["switch_count"] = half self.suppress_identity_pathways(probe) proto = raw["compute_running_intervals"][0] records = [] remaining = true_pop while remaining > 0: chunk = min(per_record, remaining) records.append(dict(proto, accelerator_count=chunk)) remaining -= chunk raw["compute_running_intervals"] = records return probe def test_f6_concurrent_subpool_split_routes_integrity(self) -> None: # Locking test: the split-pool / concurrent-sub-pool forge must route to integrity. # Every sub-record is individually below the claimed count (so _max would have read # 80 < 100 and stayed silent), but the records are concurrent so the true population # is their sum (3072), far above the claim. probe = self._f6_split_pool_probe() derived = evaluate_site(probe)["derived_signals"] records = probe["raw_features"]["compute_running_intervals"] count = derived["capacity_upper_bound_flop"]["count"] # each sub-record is below the claimed count self.assertTrue(all(r["accelerator_count"] < count for r in records)) # _max would have been silent, the concurrent peak is the true population self.assertLessEqual(_max(records, "accelerator_count"), count) self.assertGreater(_concurrent_peak(records, "accelerator_count"), count) result = evaluate_site(probe) self.assertIn( "running_accelerator_count_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) self.assertFalse(result["stage_outputs"]["A_capacity_gate"]["short_circuited"]) def test_f6_multidomain_fabric_split_routes_integrity(self) -> None: # The multi-domain fabric variant: a genuinely large cluster reported HONESTLY as # many concurrent fabric domains, each node_count below the claimed count. Domains # are spatial/concurrent, so node_count sums across them (the old _max read one # domain and stayed silent). probe = deepcopy(self.sites["A_clean_threshold_training"]) raw = probe["raw_features"] signals = probe.setdefault("normalized_signals", {}) for record in raw.get("accelerator_count_by_family_sku", []): record["count"] = 100.0 signals["achieved_operations"] = 0.0 raw.pop("generic_achieved_operation_rate", None) signals["participant_count"] = 50 for record in raw.get("fabric_port_device_sample_counters", []): if record.get("counter_name") == "participant_count": record["counter_value"] = 50 for record in raw.get("allocated_accelerator_count_by_sku", []): record["count"] = 50 self.suppress_identity_pathways(probe) raw.pop("compute_running_intervals", None) proto = raw["scaleout_fabric_domain_graph"][0] raw["scaleout_fabric_domain_graph"] = [ dict(proto, node_count=80, switch_count=10, link_count=80) for _ in range(40) ] result = evaluate_site(probe) self.assertIn( "fabric_node_count_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) def test_f6_sequential_reuse_of_small_pool_still_rules_out(self) -> None: # Locking the overlap-aware semantics from the OTHER side: a genuinely small pool # reused SEQUENTIALLY (back-to-back, non-overlapping windows) must NOT be summed # into a false contradiction. The concurrent peak stays at the small per-window # value, so an honest small-scope rule-out is preserved. A plain _sum would have # over-counted the sequential reuse and falsely blocked this legitimate rule-out. probe = deepcopy(self.sites["C_capacity_ruled_out"]) raw = probe["raw_features"] count = raw["accelerator_count_by_family_sku"][0]["count"] small = int(count) // 2 or 1 windows = [ ("2026-04-01T00:00:00Z", "2026-04-08T00:00:00Z"), ("2026-04-08T00:00:00Z", "2026-04-15T00:00:00Z"), ("2026-04-15T00:00:00Z", "2026-04-22T00:00:00Z"), ("2026-04-22T00:00:00Z", "2026-04-29T00:00:00Z"), ] raw["compute_running_intervals"] = [ { "start_time": start, "end_time": end, "compute_resource_state": "running", "accelerator_count": small, "accelerator_shape_or_sku": "SYN-ACCEL", } for start, end in windows ] records = raw["compute_running_intervals"] # the naive sum (4 * small) would exceed the count, but the genuine concurrent peak # is just `small` because the windows do not overlap self.assertGreater(sum(r["accelerator_count"] for r in records), count) self.assertLessEqual(_concurrent_peak(records, "accelerator_count"), count) result = evaluate_site(probe) self.assertNotIn( "running_accelerator_count_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], probe), ) self.assertEqual("capacity_ruled_out_for_scope", result["final_route"]) self.assertEqual([], result["discrepancy_findings"]) def test_f4_peak_or_adjust_deflation_with_raw_rate_witness_routes_integrity(self) -> None: # F4 variant: deflate the bound through peak_rate / capacity_adjustment_factor (count # left honest, so participant/allocated/billing do NOT exceed it) and mask the # achieved_operations override down so the F2 ratio guard is below 1.0. The raw # generic_achieved_operation_rate witness still integrates above the claimed bound and # must block the forge. for channel in ("peak", "adjust"): with self.subTest(channel=channel): probe = deepcopy(self.sites["A_clean_threshold_training"]) if channel == "peak": for record in probe["raw_features"]["advertised_peak_rate_by_precision"]: record["peak_rate"] *= 0.01 else: probe["normalized_signals"]["capacity_adjustment_factor"] = 0.01 # mask the override only; leave the raw operation-rate witness intact probe["normalized_signals"]["achieved_operations"] = 1e23 result = evaluate_site(probe) ratio = result["derived_signals"]["achieved_operation_integral"][ "operation_count_to_capacity_upper_bound_ratio" ] self.assertLessEqual(ratio, 1.0) # the F2 override-ratio guard does NOT fire self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) def test_participant_count_exceeding_inventory_routes_integrity(self) -> None: # A distributed-training participant set larger than the claimed accelerator inventory is # physically incoherent: it must block the rule-out even with achieved-ops fully shaded. # Every other device-population witness is suppressed so participant_count is the ONLY # surviving witness, proving it alone is load-bearing. probe = self._f3_probe( achieved=0.0, suppress_allocated=True, suppress_billing=True, suppress_running=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, keep_participant_identity=True, ) result = evaluate_site(probe) participant = result["derived_signals"]["collective_cadence_score"]["participant_count"] count = result["derived_signals"]["capacity_upper_bound_flop"]["count"] self.assertGreater(participant, count) self.assertEqual( ["participant_count_exceeds_capacity_count"], _capacity_claim_contradictions(result["derived_signals"], probe), ) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) def test_raw_participant_count_floor_is_not_masked_by_normalized_zero(self) -> None: probe = self._f3_probe( count=100.0, achieved=0.0, suppress_allocated=True, suppress_billing=True, suppress_running=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, ) probe["normalized_signals"]["participant_count"] = 0.0 for record in probe["raw_features"].get("fabric_port_device_sample_counters", []): if record.get("counter_name") == "participant_count": record["counter_value"] = 6144.0 result = evaluate_site(probe) self.assertEqual( ["participant_count_exceeds_capacity_count"], _capacity_claim_contradictions(result["derived_signals"], probe), ) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) def test_negative_capacity_count_row_cannot_cancel_positive_inventory(self) -> None: probe = self._f3_full_suppression(count=100.0, achieved=0.0) proto = probe["raw_features"]["accelerator_count_by_family_sku"][0] probe["raw_features"]["accelerator_count_by_family_sku"] = [ dict(proto, count=8192.0), dict(proto, count=-8092.0), ] result = evaluate_site(probe) a = result["stage_outputs"]["A_capacity_gate"] self.assertEqual("capacity_unknown_due_to_missing_inputs", a["label"]) self.assertIn("accelerator_count_by_family_sku", a["missing_inputs"]) self.assertFalse(a["short_circuited"]) self.assertNotEqual("capacity_ruled_out_for_scope", result["final_route"]) def test_allocated_count_exceeding_inventory_routes_integrity(self) -> None: # Every other device-population witness suppressed so allocated_count is the only one left. probe = self._f3_probe( achieved=0.0, suppress_participant=True, suppress_billing=True, suppress_running=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, ) result = evaluate_site(probe) self.assertEqual( ["allocated_count_exceeds_capacity_count"], _capacity_claim_contradictions(result["derived_signals"], probe), ) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) def test_negative_rows_do_not_cancel_positive_population_floors(self) -> None: duration = 30 * 24 * 3600 def base() -> dict: probe = self._f3_full_suppression(count=100.0, achieved=0.0) raw = probe["raw_features"] for key in ("instance_type_shape_machine_type", "local_accelerator_interconnect_domain"): raw.pop(key, None) return probe cases = [] allocated = base() allocated["raw_features"]["allocated_accelerator_count_by_sku"] = [ {"accelerator_sku": "SYN", "count": 8192.0}, {"accelerator_sku": "SYN", "count": -8092.0}, ] cases.append(("allocated", allocated, "allocated_count_exceeds_capacity_count")) instance_shape = base() instance_shape["raw_features"]["instance_type_shape_machine_type"] = [ {"machine_type": "synthetic-large", "accelerator_count": 8192.0}, {"machine_type": "synthetic-large", "accelerator_count": -8092.0}, ] cases.append(("instance_shape", instance_shape, "instance_shape_accelerator_count_exceeds_capacity_count")) local_fabric = base() local_fabric["raw_features"]["local_accelerator_interconnect_domain"] = [ {"fabric_domain_id": "domain-a", "local_fabric_device_count": 8192.0}, {"fabric_domain_id": "domain-b", "local_fabric_device_count": -8092.0}, ] cases.append(("local_fabric", local_fabric, "local_fabric_device_count_exceeds_capacity_count")) fabric_graph = base() fabric_graph["raw_features"]["scaleout_fabric_domain_graph"] = [ {"fabric_domain_id": "domain-a", "node_count": 8192.0, "switch_count": 8192.0, "link_count": 0.0}, {"fabric_domain_id": "domain-b", "node_count": -8092.0, "switch_count": -8092.0, "link_count": 0.0}, ] cases.append(("fabric_graph", fabric_graph, "fabric_node_count_exceeds_capacity_count")) cases.append(("fabric_graph", fabric_graph, "fabric_switch_count_exceeds_capacity_count")) billing = base() billing["raw_features"]["accelerator_compute_billing_usage_intervals"] = [ {"usage_unit": "accelerator_seconds", "usage_quantity": 8192.0 * duration}, {"usage_unit": "accelerator_seconds", "usage_quantity": -8092.0 * duration}, ] cases.append(("billing", billing, "billing_device_hours_exceed_capacity_count")) for label, probe, expected in cases: with self.subTest(label=label, expected=expected): result = evaluate_site(probe) contradictions = _capacity_claim_contradictions(result["derived_signals"], probe) self.assertIn(expected, contradictions) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn("capacity_claim_conflict", result["discrepancy_findings"]) def test_offset_timestamps_are_parsed_for_concurrent_interval_floors(self) -> None: start = "2026-04-02T00:30:00+14:00" end = "2026-04-01T23:30:00-12:00" running = self._f3_probe( count=100.0, achieved=0.0, suppress_participant=True, suppress_allocated=True, suppress_billing=True, suppress_fabric_graph=True, suppress_service=True, suppress_identity=True, ) running["raw_features"]["compute_running_intervals"] = [ { "compute_resource_state": "running", "accelerator_shape_or_sku": "SYN-ACCEL", "accelerator_count": 80.0, "start_time": start, "end_time": end, } for _ in range(700) ] result = evaluate_site(running) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn( "running_accelerator_count_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], running), ) service = self._ruleout_forge_base(count=100.0, achieved=1e23, suppress_identity=True) proto = service["raw_features"]["electrical_service_status_intervals"][0] service["raw_features"]["electrical_service_status_intervals"] = [ dict( proto, service_status="energized", service_class="synthetic_datacenter_service", service_capacity_mw=0.072, power_mw=0.0, mean_power_mw=0.0, max_power_mw=0.0, start_time=start, end_time=end, ) for _ in range(700) ] result = evaluate_site(service) self.assertEqual("integrity_review_required", result["final_route"]) self.assertIn( "electrical_service_power_floor_exceeds_capacity_count", _capacity_claim_contradictions(result["derived_signals"], service), ) def test_provider_account_style_honest_ruleout_with_no_scale_signals_still_rules_out(self) -> None: # An honest small-scope rule-out (the provider-account analogue) reports NONE of the scale # signals the guard checks, so no contradiction is present and the rule-out is preserved. site = { "site_id": "provider_account_style_honest_slice", "scenario_key": "provider_account_style_honest_slice", "scenario_name": "Honest small-scope rule-out with no participant/allocated/billing signals", "scope": "account_slice/accelerator_pool", "audit_window": {"start": "2026-06-04T00:00:00Z", "end": "2026-06-10T00:00:00Z"}, "raw_features": { "accelerator_count_by_family_sku": [{"accelerator_sku": "SYN", "count": 370}], "advertised_peak_rate_by_precision": [{"peak_rate": 2.0e15}], "accelerator_busy_or_utilization_fraction": [{"value": 0.45}], }, "coverage": { "capacity": 0.96, "activity": 0.9, "achieved_ops": 0.0, "fabric": 0.0, "storage": 0.0, "scope_mapping": 0.99, "clock_alignment": 0.93, }, "normalized_signals": { "hidden_or_unmonitored_capacity_possible": False, "capacity_unit_normalized": True, "activity_score": 0.45, "achieved_operations": 3.0e23, "achieved_operations_unit_normalized": True, }, } result = evaluate_site(site) cap = result["derived_signals"]["capacity_upper_bound_flop"]["capacity_upper_bound_operations"] self.assertLess(cap, 1e25) self.assertEqual("capacity_ruled_out_for_scope", result["final_route"]) self.assertEqual([], result["discrepancy_findings"]) if __name__ == "__main__": unittest.main()