1 """Regression tests for Stage-A bounded Phase 3.1 correctness-evidence sibling (P31-S10-E02).""" 3 from __future__
import annotations
5 from pathlib
import Path
10 REPO_ROOT = Path(__file__).resolve().parents[3]
11 if str(REPO_ROOT)
not in sys.path:
12 sys.path.insert(0, str(REPO_ROOT))
14 from benchmarks.density_matrix.correctness_evidence.case_selection
import (
15 CORRECTNESS_EVIDENCE_CASE_KIND_CONTINUITY,
16 CORRECTNESS_EVIDENCE_CASE_KIND_MICROCASE,
17 build_phase31_correctness_evidence_case_contexts,
19 from benchmarks.density_matrix.correctness_evidence.common
import (
20 CORRECTNESS_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION,
21 CORRECTNESS_EVIDENCE_PHASE31_PACKAGE_SCHEMA_VERSION,
22 CORRECTNESS_EVIDENCE_PHASE31_SUMMARY_SCHEMA_VERSION,
24 from benchmarks.density_matrix.correctness_evidence.phase31_correctness_bundle_validation
import (
25 build_artifact_bundle
as build_phase31_correctness_package_bundle,
27 from benchmarks.density_matrix.correctness_evidence.phase31_correctness_matrix_validation
import (
28 build_artifact_bundle
as build_phase31_matrix_bundle,
29 build_cases
as build_phase31_matrix_cases,
31 from benchmarks.density_matrix.correctness_evidence.phase31_external_correctness_validation
import (
32 build_artifact_bundle
as build_phase31_external_bundle,
33 build_cases
as build_phase31_external_cases,
35 from benchmarks.density_matrix.correctness_evidence.phase31_output_integrity_validation
import (
36 build_artifact_bundle
as build_phase31_output_integrity_bundle,
37 build_cases
as build_phase31_output_integrity_cases,
39 from benchmarks.density_matrix.correctness_evidence.phase31_runtime_classification_validation
import (
40 build_artifact_bundle
as build_phase31_runtime_classification_bundle,
41 build_cases
as build_phase31_runtime_classification_cases,
43 from benchmarks.density_matrix.correctness_evidence.phase31_sequential_correctness_validation
import (
44 build_artifact_bundle
as build_phase31_sequential_bundle,
45 build_cases
as build_phase31_sequential_cases,
47 from benchmarks.density_matrix.correctness_evidence.phase31_summary_consistency_validation
import (
48 build_artifact_bundle
as build_phase31_summary_consistency_bundle,
50 from benchmarks.density_matrix.correctness_evidence.records
import (
51 build_phase31_correctness_evidence_positive_records,
52 counted_supported_case,
59 kinds = [c.metadata[
"case_kind"]
for c
in ctxs]
60 assert kinds.count(CORRECTNESS_EVIDENCE_CASE_KIND_MICROCASE) == 4
61 assert kinds.count(CORRECTNESS_EVIDENCE_CASE_KIND_CONTINUITY) == 2
62 assert sum(c.metadata[
"external_reference_required"]
for c
in ctxs) == 5
68 assert all(r[
"record_schema_version"] == CORRECTNESS_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION
for r
in recs)
71 assert r[
"claim_surface_id"] ==
"phase31_bounded_mixed_motif_v1" 72 assert r[
"representation_primary"] ==
"kraus_bundle" 73 assert r[
"contains_noise"]
is True 74 assert r[
"counted_phase31_case"]
is True 75 assert "runtime_class" in r
76 if r[
"case_kind"] == CORRECTNESS_EVIDENCE_CASE_KIND_MICROCASE:
77 assert r[
"channel_invariants"]
is not None 78 assert r[
"channel_invariants"][
"invariant_slice_pass"]
is True 79 assert r[
"partition_route_summary"]
is None 80 assert r[
"fused_block_support_qbits"]
is not None 82 assert r[
"channel_invariants"]
is None 83 assert r[
"partition_route_summary"]
is not None 84 assert r[
"partition_route_summary"][
"partition_count"] >= 1
85 assert r[
"fused_block_support_qbits"]
is None 88 @pytest.mark.parametrize(
89 "build_cases_fn,build_bundle_fn",
91 (build_phase31_matrix_cases, build_phase31_matrix_bundle),
92 (build_phase31_sequential_cases, build_phase31_sequential_bundle),
93 (build_phase31_external_cases, build_phase31_external_bundle),
94 (build_phase31_output_integrity_cases, build_phase31_output_integrity_bundle),
95 (build_phase31_runtime_classification_cases, build_phase31_runtime_classification_bundle),
101 "phase31_output_integrity",
102 "phase31_runtime_classification",
106 cases = build_cases_fn()
107 bundle = build_bundle_fn(cases)
108 assert bundle[
"status"] ==
"pass" 109 assert bundle[
"record_schema_version"] == CORRECTNESS_EVIDENCE_PHASE31_CASE_SCHEMA_VERSION
113 bundle = build_phase31_matrix_bundle(build_phase31_matrix_cases())
114 s = bundle[
"summary"]
115 assert s[
"total_cases"] == 6
116 assert s[
"microcases"] == 4
117 assert s[
"continuity_cases"] == 2
118 assert s[
"structured_cases"] == 0
119 assert s[
"external_slice_cases"] == 5
123 bundle = build_phase31_external_bundle(build_phase31_external_cases())
124 assert bundle[
"status"] ==
"pass" 125 assert bundle[
"summary"][
"total_cases"] == 5
126 assert bundle[
"summary"][
"microcases"] == 4
127 assert bundle[
"summary"][
"continuity_cases"] == 1
131 pkg = build_phase31_correctness_package_bundle()
132 assert pkg[
"schema_version"] == CORRECTNESS_EVIDENCE_PHASE31_PACKAGE_SCHEMA_VERSION
133 assert pkg[
"status"] ==
"pass" 134 assert len(pkg[
"cases"]) == 6
135 summ = build_phase31_summary_consistency_bundle()
136 assert summ[
"status"] ==
"pass" 137 assert summ[
"schema_version"] == CORRECTNESS_EVIDENCE_PHASE31_SUMMARY_SCHEMA_VERSION
138 assert summ[
"summary"][
"counted_supported_cases"] == 6
def build_phase31_correctness_evidence_positive_records()
def test_phase31_case_contexts_bounded_counts()
def test_phase31_positive_records_fields_and_counted_supported()
def test_phase31_correctness_package_and_summary()
def test_phase31_external_slice_counts()
def test_phase31_correctness_matrix_summary()
def test_phase31_positive_slice_bundles_pass(build_cases_fn, build_bundle_fn)
def build_phase31_correctness_evidence_case_contexts()
def counted_supported_case