Files
leleka/scripts/e2e/evidence/schema_component.json
Pavlo RatushnyiandClaude Sonnet 5.5 bcd8321941 Add COMPONENT evidence-record schemas and validator (STRA-287, S0.1b)
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>
2026-10-28 20:17:25 +01:00

327 lines
16 KiB
JSON

{
"$comment": "COMPONENT evidence-record schema v1 (STRA-287, S0.1b): COMPONENT_STARTUP, COMPONENT_TABLE, COMPONENT_KERNEL. Interpreted by validate_component.py with the evaluator of validate.py (STRA-246); the definitions of schema.json (sha256, commit, utc, text, build_id, vanilla_cpu_family, env_entry, ...) are shared and referenced here, never redefined. The validator checks presence and consistency only: the classes FASTER / SLOWER / EQUAL / INCONCLUSIVE / CONFIRMED-SLOWER / NOT-CONFIRMED and the A/A verdict are computed by STRA-313, the statistics by STRA-290. A COMPONENT record is never merged with an END_TO_END record (AC9). Paired log ratio convention fixed here: log_ratio = ln(vanilla_cost / ours_cost) per pair, so a positive value always means ours is better (cost = time, cycles; for rates use ln(ours_rate / vanilla_rate)).",
"schema_version": "1",
"levels_list": ["COMPONENT_STARTUP", "COMPONENT_TABLE", "COMPONENT_KERNEL"],
"constants": {
"min_classified_n": 30,
"equal_ratio_low": 0.99,
"equal_ratio_high": 1.01,
"ours_cpu_line_regex": "^leleka-serve cpu: ",
"bare_cpu_line_regex": "^(leleka-serve )?cpu:",
"min_negative_cases": 20,
"log_ratio_convention": "positive_means_ours_better"
},
"rules": [
{"id": "RULE_OURS_CPU_LINE", "level": "COMPONENT_STARTUP", "text": "arm ours: kernel_lines holds at least one 'leleka-serve cpu: ' line (verbatim stderr of cpu_kernel_report; gpu lines optional)"},
{"id": "RULE_OURS_NO_VANILLA_BLOCK", "level": "COMPONENT_STARTUP", "text": "arm ours: vanilla_cpu_family absent"},
{"id": "RULE_VANILLA_CLAIMS_CPU", "level": "COMPONENT_STARTUP", "text": "arm vanilla: kernel_lines absent or empty, no printed line (also in the control) starting 'cpu:' or 'leleka-serve cpu:'; the vanilla engine prints none"},
{"id": "RULE_VANILLA_BLOCK", "level": "COMPONENT_STARTUP", "text": "arm vanilla: vanilla_cpu_family block present"},
{"id": "RULE_BUILD_IDENTITY_FORM", "level": "COMPONENT_STARTUP", "text": "arm ours: build_identity is a build_id (commit, target_triple, cargo_features, profile_value_sha256); arm vanilla: {engine_version, binary_sha256, strata_upstream_commit}"},
{"id": "RULE_BUILD_IDENTITY_MISMATCH", "level": "COMPONENT_STARTUP", "text": "arm vanilla: build_identity engine_version and binary_sha256 equal vanilla_cpu_family.binary_identity"},
{"id": "RULE_MAPPING_DUPLICATE", "level": "COMPONENT_TABLE", "text": "stage_to_component: no repeated stage"},
{"id": "RULE_COMPONENT_UNMAPPED", "level": "COMPONENT_TABLE", "text": "every row component appears in stage_to_component; row components are unique"},
{"id": "RULE_DISTRIBUTION_ORDER", "level": "COMPONENT_TABLE", "text": "min <= p05 <= median <= p95 <= max and min <= mean <= max for ours and vanilla"},
{"id": "RULE_CLASS_REQUIRED", "level": "COMPONENT_TABLE", "text": "n >= 30: class present"},
{"id": "RULE_PAIRED_REQUIRED", "level": "COMPONENT_TABLE", "text": "n >= 30: paired difference with its 95 percent CI present"},
{"id": "RULE_SMALL_N_CLASS", "level": "COMPONENT_TABLE", "text": "n < 30: class absent or INCONCLUSIVE (screening, E6)"},
{"id": "RULE_CI_ORDER", "level": "COMPONENT_TABLE", "text": "ci95_low <= log_ratio_mean <= ci95_high"},
{"id": "RULE_FASTER_CI", "level": "COMPONENT_TABLE", "text": "FASTER: ci95_low > 0"},
{"id": "RULE_SLOWER_CI", "level": "COMPONENT_TABLE", "text": "SLOWER: ci95_high < 0"},
{"id": "RULE_EQUAL_INTERVAL", "level": "COMPONENT_TABLE", "text": "EQUAL: the CI contains 0 and lies inside [ln 0.99, ln 1.01]"},
{"id": "RULE_EQUAL_AA", "level": "COMPONENT_TABLE", "text": "EQUAL: an A/A result is present and valid"},
{"id": "RULE_AA_VALID", "level": "COMPONENT_TABLE", "text": "aa.valid is true iff both A/A CIs contain 0"},
{"id": "RULE_AA_INVALID_CLASS", "level": "COMPONENT_TABLE", "text": "aa.valid false: the cell is invalid, class must be INCONCLUSIVE (re-run)"},
{"id": "RULE_SUSPECTED", "level": "COMPONENT_TABLE", "text": "suspected is true iff class is SLOWER (an unconfirmed SLOWER)"},
{"id": "RULE_CONFIRMATION", "level": "COMPONENT_TABLE", "text": "CONFIRMED-SLOWER / NOT-CONFIRMED need a confirmation block (n >= 30, its CI: CONFIRMED-SLOWER ci95_high < 0, NOT-CONFIRMED ci95_high >= 0); any other class has none"},
{"id": "RULE_CLOCK", "level": "COMPONENT_KERNEL", "text": "clock_calibration: slices_dropped <= slices_total"},
{"id": "RULE_REGIME_STREAMED", "level": "COMPONENT_KERNEL", "text": "streamed: block streamed present with copies * expert_bytes > llc_bytes; resident: block absent"},
{"id": "RULE_EQUALITY_MODE", "level": "COMPONENT_KERNEL", "text": "bitwise: no tolerance block; tolerance: tolerance block present; bitwise EQUAL has mismatches 0"},
{"id": "RULE_TOLERANCE_BASIS_ORDER", "level": "COMPONENT_KERNEL", "text": "tolerance.basis_written_utc <= run_started_utc (the basis is written before the run)"},
{"id": "RULE_KERNEL_ROW_DUPLICATE", "level": "COMPONENT_KERNEL", "text": "rows: no repeated row_type"}
],
"definitions": {
"machine": {
"type": "object",
"required": ["machine_role", "cpu_model", "gpu_name", "os"],
"additionalProperties": false,
"properties": {
"machine_role": {"$ref": "#/definitions/text"},
"cpu_model": {"$ref": "#/definitions/text"},
"gpu_name": {"$ref": "#/definitions/text"},
"os": {"$ref": "#/definitions/text"}
}
},
"vanilla_build_identity": {
"type": "object",
"required": ["engine_version", "binary_sha256", "strata_upstream_commit"],
"additionalProperties": false,
"properties": {
"engine_version": {"$ref": "#/definitions/text"},
"binary_sha256": {"$ref": "#/definitions/sha256"},
"strata_upstream_commit": {"$ref": "#/definitions/commit"}
}
},
"distribution": {
"type": "object",
"required": ["mean", "median", "p05", "p95", "min", "max"],
"additionalProperties": false,
"properties": {
"mean": {"type": "number"},
"median": {"type": "number"},
"p05": {"type": "number"},
"p95": {"type": "number"},
"min": {"type": "number"},
"max": {"type": "number"}
}
},
"log_ratio_ci": {
"type": "object",
"required": ["log_ratio_mean", "ci95_low", "ci95_high", "ci_method"],
"additionalProperties": false,
"properties": {
"log_ratio_mean": {"type": "number"},
"ci95_low": {"type": "number"},
"ci95_high": {"type": "number"},
"ci_method": {"$ref": "#/definitions/text"}
}
},
"aa_pair": {
"type": "object",
"required": ["n", "ci95_low", "ci95_high"],
"additionalProperties": false,
"properties": {
"n": {"$ref": "#/definitions/pos_int"},
"ci95_low": {"type": "number"},
"ci95_high": {"type": "number"}
}
},
"aa_result": {
"type": "object",
"required": ["ours_vs_ours", "vanilla_vs_vanilla", "valid"],
"additionalProperties": false,
"properties": {
"ours_vs_ours": {"$ref": "#/definitions/aa_pair"},
"vanilla_vs_vanilla": {"$ref": "#/definitions/aa_pair"},
"valid": {"type": "boolean"}
}
},
"confirmation": {
"type": "object",
"required": ["run_ids", "n", "paired"],
"additionalProperties": false,
"properties": {
"run_ids": {"type": "array", "minItems": 1, "items": {"$ref": "#/definitions/text"}},
"n": {"$ref": "#/definitions/pos_int"},
"paired": {"$ref": "#/definitions/log_ratio_ci"}
}
},
"stage_mapping_entry": {
"type": "object",
"required": ["stage", "component"],
"additionalProperties": false,
"properties": {
"stage": {"$ref": "#/definitions/text"},
"component": {"$ref": "#/definitions/text"}
}
},
"table_row": {
"type": "object",
"required": ["component", "unit", "n", "ours", "vanilla", "suspected"],
"additionalProperties": false,
"properties": {
"component": {"$ref": "#/definitions/text"},
"unit": {"$ref": "#/definitions/text"},
"n": {"$ref": "#/definitions/pos_int"},
"ours": {"$ref": "#/definitions/distribution"},
"vanilla": {"$ref": "#/definitions/distribution"},
"class": {"type": "string", "enum": ["FASTER", "SLOWER", "EQUAL", "INCONCLUSIVE", "CONFIRMED-SLOWER", "NOT-CONFIRMED"]},
"paired": {"$ref": "#/definitions/log_ratio_ci"},
"aa": {"$ref": "#/definitions/aa_result"},
"suspected": {"type": "boolean"},
"confirmation": {"$ref": "#/definitions/confirmation"}
}
},
"toolchain_side": {
"type": "object",
"required": ["compiler", "version", "target_triple", "flags"],
"additionalProperties": false,
"properties": {
"compiler": {"$ref": "#/definitions/text"},
"version": {"$ref": "#/definitions/text"},
"target_triple": {"type": "string", "pattern": "^[a-z0-9_]+(-[a-z0-9_.]+){2,3}$"},
"flags": {"$ref": "#/definitions/text"}
}
},
"tree_name": {"type": "string", "enum": ["avx512", "avx2", "scalar", "cuda"]},
"cpu_pin": {
"type": "object",
"required": ["logical_cpu", "sibling_idle"],
"additionalProperties": false,
"properties": {
"logical_cpu": {"$ref": "#/definitions/nonneg_int"},
"sibling_idle": {"type": "boolean"}
}
},
"clock_calibration": {
"type": "object",
"required": ["method", "ghz_before", "ghz_after", "max_drift_fraction", "slices_total", "slices_dropped"],
"additionalProperties": false,
"properties": {
"method": {"$ref": "#/definitions/text"},
"ghz_before": {"$ref": "#/definitions/pos_number"},
"ghz_after": {"$ref": "#/definitions/pos_number"},
"max_drift_fraction": {"$ref": "#/definitions/fraction"},
"slices_total": {"$ref": "#/definitions/pos_int"},
"slices_dropped": {"$ref": "#/definitions/nonneg_int"}
}
},
"kernel_side_stat": {
"type": "object",
"required": ["median", "p05", "p95"],
"additionalProperties": false,
"properties": {
"median": {"$ref": "#/definitions/pos_number"},
"p05": {"$ref": "#/definitions/pos_number"},
"p95": {"$ref": "#/definitions/pos_number"}
}
},
"kernel_row": {
"type": "object",
"required": ["row_type", "unit", "rounds", "ours", "reference"],
"additionalProperties": false,
"properties": {
"row_type": {"$ref": "#/definitions/text"},
"unit": {"type": "string", "enum": ["ns", "cycles"]},
"rounds": {"$ref": "#/definitions/pos_int"},
"ours": {"$ref": "#/definitions/kernel_side_stat"},
"reference": {"$ref": "#/definitions/kernel_side_stat"}
}
},
"aa_noise_floor": {
"type": "object",
"required": ["ours_vs_ours", "reference_vs_reference", "floor_fraction"],
"additionalProperties": false,
"properties": {
"ours_vs_ours": {"$ref": "#/definitions/aa_pair"},
"reference_vs_reference": {"$ref": "#/definitions/aa_pair"},
"floor_fraction": {"$ref": "#/definitions/nonneg_number"}
}
},
"tolerance": {
"type": "object",
"required": ["value", "basis", "basis_written_utc"],
"additionalProperties": false,
"properties": {
"value": {"$ref": "#/definitions/pos_number"},
"basis": {"$ref": "#/definitions/text"},
"basis_written_utc": {"$ref": "#/definitions/utc"}
}
},
"equality": {
"type": "object",
"required": ["mode", "verdict", "compared_values", "mismatches"],
"additionalProperties": false,
"properties": {
"mode": {"type": "string", "enum": ["bitwise", "tolerance"]},
"verdict": {"type": "string", "enum": ["EQUAL", "NOT_EQUAL"]},
"compared_values": {"$ref": "#/definitions/pos_int"},
"mismatches": {"$ref": "#/definitions/nonneg_int"},
"tolerance": {"$ref": "#/definitions/tolerance"}
}
},
"streamed": {
"type": "object",
"required": ["copies", "expert_bytes", "llc_bytes"],
"additionalProperties": false,
"properties": {
"copies": {"type": "integer", "minimum": 2},
"expert_bytes": {"$ref": "#/definitions/pos_int"},
"llc_bytes": {"$ref": "#/definitions/pos_int"}
}
}
},
"levels": {
"COMPONENT_STARTUP": {
"type": "object",
"required": ["schema_version", "level", "record_id", "created_utc", "machine", "arm", "build_identity"],
"additionalProperties": false,
"properties": {
"schema_version": {"type": "string", "const": "1"},
"level": {"type": "string", "const": "COMPONENT_STARTUP"},
"synthetic": {"type": "boolean"},
"record_id": {"$ref": "#/definitions/text"},
"created_utc": {"$ref": "#/definitions/utc"},
"machine": {"$ref": "#/definitions/machine"},
"arm": {"type": "string", "enum": ["ours", "vanilla"]},
"build_identity": {"type": "object"},
"kernel_lines": {"type": "array", "items": {"type": "string", "pattern": "^leleka-serve (cpu|gpu): "}},
"vanilla_cpu_family": {"$ref": "#/definitions/vanilla_cpu_family"}
}
},
"COMPONENT_TABLE": {
"type": "object",
"required": ["schema_version", "level", "record_id", "created_utc", "machine", "source_run_ids", "stage_to_component", "log_ratio_convention", "rows"],
"additionalProperties": false,
"properties": {
"schema_version": {"type": "string", "const": "1"},
"level": {"type": "string", "const": "COMPONENT_TABLE"},
"synthetic": {"type": "boolean"},
"record_id": {"$ref": "#/definitions/text"},
"created_utc": {"$ref": "#/definitions/utc"},
"machine": {"$ref": "#/definitions/machine"},
"source_run_ids": {"type": "array", "minItems": 1, "items": {"$ref": "#/definitions/text"}},
"stage_to_component": {"type": "array", "minItems": 1, "items": {"$ref": "#/definitions/stage_mapping_entry"}},
"log_ratio_convention": {"type": "string", "const": "positive_means_ours_better"},
"rows": {"type": "array", "minItems": 1, "items": {"$ref": "#/definitions/table_row"}}
}
},
"COMPONENT_KERNEL": {
"type": "object",
"required": [
"schema_version", "level", "record_id", "created_utc", "run_started_utc", "machine", "kernel", "toolchain", "case_id", "input_sha256",
"kab1_manifest_sha256", "tree", "regime", "pin", "strata_upstream_commit", "clock_calibration", "rows", "aa_noise_floor", "equality"
],
"additionalProperties": false,
"properties": {
"schema_version": {"type": "string", "const": "1"},
"level": {"type": "string", "const": "COMPONENT_KERNEL"},
"synthetic": {"type": "boolean"},
"record_id": {"$ref": "#/definitions/text"},
"created_utc": {"$ref": "#/definitions/utc"},
"run_started_utc": {"$ref": "#/definitions/utc"},
"machine": {"$ref": "#/definitions/machine"},
"kernel": {"$ref": "#/definitions/text"},
"toolchain": {
"type": "object",
"required": ["ours", "reference"],
"additionalProperties": false,
"properties": {
"ours": {"$ref": "#/definitions/toolchain_side"},
"reference": {"$ref": "#/definitions/toolchain_side"}
}
},
"case_id": {"$ref": "#/definitions/text"},
"input_sha256": {"$ref": "#/definitions/sha256"},
"kab1_manifest_sha256": {"$ref": "#/definitions/sha256"},
"tree": {
"type": "object",
"required": ["ours", "reference"],
"additionalProperties": false,
"properties": {
"ours": {"$ref": "#/definitions/tree_name"},
"reference": {"$ref": "#/definitions/tree_name"}
}
},
"regime": {"type": "string", "enum": ["resident", "streamed"]},
"streamed": {"$ref": "#/definitions/streamed"},
"pin": {"$ref": "#/definitions/cpu_pin"},
"strata_upstream_commit": {"$ref": "#/definitions/commit"},
"clock_calibration": {"$ref": "#/definitions/clock_calibration"},
"rows": {"type": "array", "minItems": 1, "items": {"$ref": "#/definitions/kernel_row"}},
"aa_noise_floor": {"$ref": "#/definitions/aa_noise_floor"},
"equality": {"$ref": "#/definitions/equality"}
}
}
}
}