from phase_memory.troubleshooting import ( TROUBLESHOOTING_REQUIRED_CATEGORIES, operator_troubleshooting_matrix, validate_operator_troubleshooting_matrix, ) def test_operator_troubleshooting_matrix_covers_required_categories() -> None: matrix = operator_troubleshooting_matrix() validation = validate_operator_troubleshooting_matrix(matrix) categories = {row["category"] for row in matrix["rows"]} assert set(TROUBLESHOOTING_REQUIRED_CATEGORIES) <= categories assert validation["valid"] is True assert validation["diagnostics"] == [] def test_operator_troubleshooting_matrix_validation_reports_missing_fields() -> None: matrix = { "schema_version": "phase_memory.operator_troubleshooting.v1", "rows": [{"category": "credentials", "diagnostic_code": "credential_env_missing"}], } validation = validate_operator_troubleshooting_matrix(matrix) codes = {diagnostic["code"] for diagnostic in validation["diagnostics"]} assert validation["valid"] is False assert "troubleshooting_matrix_missing_category" in codes assert "troubleshooting_matrix_missing_field" in codes