#![allow(
    clippy::assertions_on_constants,
    clippy::assertions_on_result_states,
    clippy::clone_on_copy,
    clippy::decimal_literal_representation,
    clippy::doc_markdown,
    clippy::empty_line_after_doc_comments,
    clippy::field_reassign_with_default,
    clippy::get_unwrap,
    clippy::identity_op,
    clippy::inconsistent_digit_grouping,
    clippy::indexing_slicing,
    clippy::integer_division,
    clippy::len_zero,
    clippy::let_underscore_must_use,
    clippy::manual_div_ceil,
    clippy::manual_let_else,
    clippy::manual_range_contains,
    clippy::modulo_arithmetic,
    clippy::needless_range_loop,
    clippy::non_ascii_literal,
    clippy::redundant_clone,
    clippy::shadow_reuse,
    clippy::shadow_same,
    clippy::shadow_unrelated,
    clippy::single_match_else,
    clippy::str_to_string,
    clippy::string_slice,
    clippy::tests_outside_test_module,
    clippy::too_many_lines,
    clippy::unnecessary_wraps,
    clippy::unseparated_literal_suffix,
    clippy::use_debug,
    clippy::useless_vec,
    clippy::wildcard_enum_match_arm,
    clippy::else_if_without_else,
    clippy::expect_used,
    clippy::missing_const_for_fn,
    clippy::similar_names,
    clippy::type_complexity,
    clippy::collapsible_else_if,
    clippy::doc_lazy_continuation,
    clippy::items_after_test_module,
    clippy::map_clone,
    clippy::multiple_unsafe_ops_per_block,
    clippy::unwrap_or_default,
    clippy::assign_op_pattern,
    clippy::needless_borrow,
    clippy::println_empty_string,
    clippy::unnecessary_cast,
    clippy::used_underscore_binding,
    clippy::create_dir,
    clippy::implicit_saturating_sub,
    clippy::exit,
    clippy::expect_fun_call,
    clippy::too_many_arguments,
    clippy::unnecessary_map_or,
    clippy::unwrap_used,
    dead_code,
    unused_imports,
    unused_variables,
    clippy::cloned_ref_to_slice_refs,
    clippy::neg_multiply,
    clippy::while_let_loop,
    clippy::bool_assert_comparison,
    clippy::excessive_precision,
    clippy::trivially_copy_pass_by_ref,
    clippy::op_ref,
    clippy::redundant_closure,
    clippy::unnecessary_lazy_evaluations,
    clippy::if_then_some_else_none,
    clippy::unnecessary_to_owned,
    clippy::single_component_path_imports,
)]
// BLOCKER #2 FIX: Action Masking Parameter Exposure - TDD Test Suite
// Tests for max_position_absolute hyperopt integration
//
// RED Phase: Create failing tests to drive implementation
// Expected to FAIL until fixes are applied

use ml::trainers::DQNHyperparameters;

/// Test 1: Verify max_position_absolute exists in DQNHyperparameters struct
#[test]
fn test_hyperopt_max_position_absolute_field_exists() {
    // This test verifies the struct has the new field
    let params = DQNHyperparameters::conservative();

    // RED PHASE: This will fail because max_position_absolute doesn't exist yet
    let max_position = params.max_position_absolute;

    assert!(
        max_position >= 1.0 && max_position <= 10.0,
        "max_position_absolute should be in safe range [1.0, 10.0], got: {}",
        max_position
    );
}

/// Test 2: Verify default value matches current hardcoded behavior (2.0)
#[test]
fn test_hyperopt_max_position_default_value() {
    let params = DQNHyperparameters::conservative();

    // RED PHASE: This will fail because max_position_absolute doesn't exist yet
    assert_eq!(
        params.max_position_absolute, 2.0,
        "Default max_position_absolute should be 2.0 (backward compatible)"
    );
}

/// Test 3: Verify parameter can be set to different values
#[test]
fn test_hyperopt_max_position_configurable() {
    // Test tight limit
    let params_tight = DQNHyperparameters {
        max_position_absolute: 1.5,
        ..DQNHyperparameters::conservative()
    };
    assert_eq!(params_tight.max_position_absolute, 1.5);

    // Test loose limit
    let params_loose = DQNHyperparameters {
        max_position_absolute: 8.0,
        ..DQNHyperparameters::conservative()
    };
    assert_eq!(params_loose.max_position_absolute, 8.0);
}

/// Test 4: Verify range validation (1.0-10.0)
#[test]
fn test_hyperopt_position_limit_range_validation() {
    // Test minimum boundary
    let params_min = DQNHyperparameters {
        max_position_absolute: 1.0,
        ..DQNHyperparameters::conservative()
    };
    assert_eq!(params_min.max_position_absolute, 1.0);

    // Test maximum boundary
    let params_max = DQNHyperparameters {
        max_position_absolute: 10.0,
        ..DQNHyperparameters::conservative()
    };
    assert_eq!(params_max.max_position_absolute, 10.0);

    // Test mid-range value
    let params_mid = DQNHyperparameters {
        max_position_absolute: 5.0,
        ..DQNHyperparameters::conservative()
    };
    assert_eq!(params_mid.max_position_absolute, 5.0);
}

/// Test 5: Document expected behavior with action masking
#[test]
fn test_hyperopt_action_masking_integration() {
    // This test documents how max_position_absolute interacts with action masking

    // Tight limit scenario (1.0 contract)
    let params_tight = DQNHyperparameters {
        max_position_absolute: 1.0,
        enable_action_masking: true,
        ..DQNHyperparameters::conservative()
    };

    assert_eq!(params_tight.max_position_absolute, 1.0);
    assert!(params_tight.enable_action_masking);

    // Expected behavior: 60-70% action filtering with tight limit
    // This is tested in integration tests, not unit tests

    // Loose limit scenario (10.0 contracts)
    let params_loose = DQNHyperparameters {
        max_position_absolute: 10.0,
        enable_action_masking: true,
        ..DQNHyperparameters::conservative()
    };

    assert_eq!(params_loose.max_position_absolute, 10.0);
    assert!(params_loose.enable_action_masking);

    // Expected behavior: 5-10% action filtering with loose limit
}

/// Test 6: Verify backward compatibility
#[test]
fn test_hyperopt_backward_compatibility() {
    // Existing code should work without specifying max_position_absolute
    let params = DQNHyperparameters::conservative();

    // Should default to 2.0 (current production value)
    assert_eq!(
        params.max_position_absolute, 2.0,
        "Default should match current hardcoded value for backward compatibility"
    );

    // Action masking should still be enabled by default
    assert!(
        params.enable_action_masking,
        "Action masking should be enabled by default"
    );
}

// Note: Hyperopt-specific tests (suggest_float, trial creation) are integration tests
// and should be in ml/examples/hyperopt_dqn_demo.rs or a separate integration test file.
// These unit tests focus on the DQNHyperparameters struct itself.
