COMPONENT_STARTUP, COMPONENT_TABLE and COMPONENT_KERNEL record schemas (schema_component.json), validate_component.py (record / --negative-suite / merge), one sample per level (two for start-up: ours and vanilla), a negative-case table and 41 unittest tests. Shares the STRA-246 evaluator and definitions; stdlib only, Python >= 3.9. Classes are computed elsewhere (STRA-313); the validator checks presence and consistency. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
65 lines
11 KiB
JSON
65 lines
11 KiB
JSON
{
|
|
"$comment": "Negative suite of validate_component.py (STRA-287). Each case is a committed sample plus edits (op set/delete on a JSON pointer, list indexes are integers) and the rule code the validator must reject it with; the suite fails when a case is accepted or rejected for another code. 'samples' must validate unedited.",
|
|
"samples": [
|
|
"sample_component_startup_ours.json",
|
|
"sample_component_startup_vanilla.json",
|
|
"sample_component_table.json",
|
|
"sample_component_kernel.json"
|
|
],
|
|
"cases": [
|
|
{"id": "table_row_without_class_n30", "base": "sample_component_table.json", "ops": [{"op": "delete", "path": "/rows/0/class"}], "expect": "RULE_CLASS_REQUIRED"},
|
|
{"id": "table_row_without_paired_n30", "base": "sample_component_table.json", "ops": [{"op": "delete", "path": "/rows/0/paired"}], "expect": "RULE_PAIRED_REQUIRED"},
|
|
{"id": "table_equal_ci_high_outside_interval", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/1/paired/ci95_high", "value": 0.02}], "expect": "RULE_EQUAL_INTERVAL"},
|
|
{"id": "table_equal_ci_low_outside_interval", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/1/paired/ci95_low", "value": -0.02}], "expect": "RULE_EQUAL_INTERVAL"},
|
|
{"id": "table_equal_ci_excludes_zero_inside_interval", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/1/paired/ci95_low", "value": 0.001}, {"op": "set", "path": "/rows/1/paired/log_ratio_mean", "value": 0.002}], "expect": "RULE_EQUAL_INTERVAL"},
|
|
{"id": "table_equal_without_aa", "base": "sample_component_table.json", "ops": [{"op": "delete", "path": "/rows/1/aa"}], "expect": "RULE_EQUAL_AA"},
|
|
{"id": "table_equal_with_invalid_aa", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/1/aa/ours_vs_ours/ci95_low", "value": 0.01}, {"op": "set", "path": "/rows/1/aa/ours_vs_ours/ci95_high", "value": 0.02}, {"op": "set", "path": "/rows/1/aa/valid", "value": false}], "expect": "RULE_EQUAL_AA"},
|
|
{"id": "table_aa_valid_flag_contradicts_cis", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/0/aa/valid", "value": false}], "expect": "RULE_AA_VALID"},
|
|
{"id": "table_class_on_invalid_aa", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/0/aa/vanilla_vs_vanilla/ci95_low", "value": 0.01}, {"op": "set", "path": "/rows/0/aa/vanilla_vs_vanilla/ci95_high", "value": 0.02}, {"op": "set", "path": "/rows/0/aa/valid", "value": false}], "expect": "RULE_AA_INVALID_CLASS"},
|
|
{"id": "table_faster_ci_contains_zero", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/0/paired/ci95_low", "value": -0.01}], "expect": "RULE_FASTER_CI"},
|
|
{"id": "table_slower_ci_contains_zero", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/2/paired/ci95_high", "value": 0.01}], "expect": "RULE_SLOWER_CI"},
|
|
{"id": "table_class_faster_below_30", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/5/class", "value": "FASTER"}], "expect": "RULE_SMALL_N_CLASS"},
|
|
{"id": "table_slower_not_suspected", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/2/suspected", "value": false}], "expect": "RULE_SUSPECTED"},
|
|
{"id": "table_confirmed_slower_without_confirmation", "base": "sample_component_table.json", "ops": [{"op": "delete", "path": "/rows/3/confirmation"}], "expect": "RULE_CONFIRMATION"},
|
|
{"id": "table_not_confirmed_with_negative_confirm_ci", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/4/confirmation/paired/ci95_high", "value": -0.005}], "expect": "RULE_CONFIRMATION"},
|
|
{"id": "table_confirmation_on_faster_row", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/0/confirmation", "value": {"run_ids": ["x"], "n": 30, "paired": {"log_ratio_mean": 0.1, "ci95_low": 0.09, "ci95_high": 0.11, "ci_method": "sample"}}}], "expect": "RULE_CONFIRMATION"},
|
|
{"id": "table_component_not_in_mapping", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/0/component", "value": "unmapped_component"}], "expect": "RULE_COMPONENT_UNMAPPED"},
|
|
{"id": "table_class_outside_vocabulary", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/1/class", "value": "TIE"}], "expect": "BAD_VALUE"},
|
|
{"id": "table_without_source_run_ids", "base": "sample_component_table.json", "ops": [{"op": "delete", "path": "/source_run_ids"}], "expect": "MISSING_FIELD"},
|
|
{"id": "table_without_stage_mapping", "base": "sample_component_table.json", "ops": [{"op": "delete", "path": "/stage_to_component"}], "expect": "MISSING_FIELD"},
|
|
{"id": "table_distribution_out_of_order", "base": "sample_component_table.json", "ops": [{"op": "set", "path": "/rows/0/ours/p05", "value": 99.0}], "expect": "RULE_DISTRIBUTION_ORDER"},
|
|
{"id": "kernel_without_toolchain", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/toolchain"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_without_triple", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/toolchain/ours/target_triple"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_without_equality_verdict", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/equality"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_without_kab1_manifest_sha256", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/kab1_manifest_sha256"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_tolerance_without_basis", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/equality/tolerance/basis"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_tolerance_basis_written_after_run", "base": "sample_component_kernel.json", "ops": [{"op": "set", "path": "/equality/tolerance/basis_written_utc", "value": "2026-01-01T00:45:00Z"}], "expect": "RULE_TOLERANCE_BASIS_ORDER"},
|
|
{"id": "kernel_tolerance_mode_without_tolerance", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/equality/tolerance"}], "expect": "RULE_EQUALITY_MODE"},
|
|
{"id": "kernel_bitwise_with_mismatches_but_equal", "base": "sample_component_kernel.json", "ops": [{"op": "set", "path": "/equality", "value": {"mode": "bitwise", "verdict": "EQUAL", "compared_values": 100, "mismatches": 3}}], "expect": "RULE_EQUALITY_MODE"},
|
|
{"id": "kernel_regime_outside_vocabulary", "base": "sample_component_kernel.json", "ops": [{"op": "set", "path": "/regime", "value": "warm"}], "expect": "BAD_VALUE"},
|
|
{"id": "kernel_streamed_without_block", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/streamed"}], "expect": "RULE_REGIME_STREAMED"},
|
|
{"id": "kernel_streamed_fits_in_cache", "base": "sample_component_kernel.json", "ops": [{"op": "set", "path": "/streamed/copies", "value": 2}], "expect": "RULE_REGIME_STREAMED"},
|
|
{"id": "kernel_without_aa_noise_floor", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/aa_noise_floor"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_without_input_hash", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/input_sha256"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_without_clock_calibration", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/clock_calibration"}], "expect": "MISSING_FIELD"},
|
|
{"id": "kernel_clock_drops_more_than_measured", "base": "sample_component_kernel.json", "ops": [{"op": "set", "path": "/clock_calibration/slices_dropped", "value": 301}], "expect": "RULE_CLOCK"},
|
|
{"id": "kernel_without_pin", "base": "sample_component_kernel.json", "ops": [{"op": "delete", "path": "/pin"}], "expect": "MISSING_FIELD"},
|
|
{"id": "startup_without_build_identity", "base": "sample_component_startup_ours.json", "ops": [{"op": "delete", "path": "/build_identity"}], "expect": "MISSING_FIELD"},
|
|
{"id": "startup_vanilla_without_build_identity", "base": "sample_component_startup_vanilla.json", "ops": [{"op": "delete", "path": "/build_identity"}], "expect": "MISSING_FIELD"},
|
|
{"id": "startup_ours_build_identity_without_triple", "base": "sample_component_startup_ours.json", "ops": [{"op": "delete", "path": "/build_identity/target_triple"}], "expect": "RULE_BUILD_IDENTITY_FORM"},
|
|
{"id": "startup_ours_bare_cpu_prefix", "base": "sample_component_startup_ours.json", "ops": [{"op": "set", "path": "/kernel_lines/0", "value": "cpu: logical cores 16, sample line"}], "expect": "BAD_PATTERN"},
|
|
{"id": "startup_ours_without_cpu_line", "base": "sample_component_startup_ours.json", "ops": [{"op": "set", "path": "/kernel_lines", "value": ["leleka-serve gpu: sample device line"]}], "expect": "RULE_OURS_CPU_LINE"},
|
|
{"id": "startup_ours_without_kernel_lines", "base": "sample_component_startup_ours.json", "ops": [{"op": "delete", "path": "/kernel_lines"}], "expect": "RULE_OURS_CPU_LINE"},
|
|
{"id": "startup_ours_with_vanilla_block", "base": "sample_component_startup_ours.json", "ops": [{"op": "set", "path": "/vanilla_cpu_family", "value": {"printed": "none printed", "reading_rule": "x", "control": {"env": "STRATA_FORCE_AVX2=1", "printed": "none printed"}, "predicate": "unavailable: x", "binary_identity": {"engine_version": "x", "sha256": "990deb85bfb5f096fe5b0997c7028095a6b84ecb8f684283606b31381a06609e"}}}], "expect": "RULE_OURS_NO_VANILLA_BLOCK"},
|
|
{"id": "startup_vanilla_claims_cpu_lines", "base": "sample_component_startup_vanilla.json", "ops": [{"op": "set", "path": "/vanilla_cpu_family/printed", "value": ["cpu: logical cores 16, kernel family avx512"]}], "expect": "RULE_VANILLA_CLAIMS_CPU"},
|
|
{"id": "startup_vanilla_with_ours_prefixed_lines", "base": "sample_component_startup_vanilla.json", "ops": [{"op": "set", "path": "/kernel_lines", "value": ["leleka-serve cpu: process kernel family avx512"]}], "expect": "RULE_VANILLA_CLAIMS_CPU"},
|
|
{"id": "startup_vanilla_without_family_block", "base": "sample_component_startup_vanilla.json", "ops": [{"op": "delete", "path": "/vanilla_cpu_family"}], "expect": "RULE_VANILLA_BLOCK"},
|
|
{"id": "startup_vanilla_family_block_without_control", "base": "sample_component_startup_vanilla.json", "ops": [{"op": "delete", "path": "/vanilla_cpu_family/control"}], "expect": "MISSING_FIELD"},
|
|
{"id": "startup_vanilla_binary_identity_mismatch", "base": "sample_component_startup_vanilla.json", "ops": [{"op": "set", "path": "/vanilla_cpu_family/binary_identity/sha256", "value": "3b86764a23ef1654ba243617b81964d5c4b5513161ceff3d621b95715f9f9864"}], "expect": "RULE_BUILD_IDENTITY_MISMATCH"},
|
|
{"id": "startup_without_machine", "base": "sample_component_startup_ours.json", "ops": [{"op": "delete", "path": "/machine"}], "expect": "MISSING_FIELD"},
|
|
{"id": "header_wrong_schema_version", "base": "sample_component_startup_ours.json", "ops": [{"op": "set", "path": "/schema_version", "value": "2"}], "expect": "BAD_VALUE"},
|
|
{"id": "header_unknown_level", "base": "sample_component_startup_ours.json", "ops": [{"op": "set", "path": "/level", "value": "COMPONENT_MISC"}], "expect": "LEVEL_NOT_COMPONENT"},
|
|
{"id": "end_to_end_record_here", "base": "sample_ours.json", "ops": [], "expect": "LEVEL_NOT_COMPONENT"}
|
|
]
|
|
}
|