@tdd_issue @tdd_issue_10496
Feature: AutoDebugAgent LangGraph node contract — _generate_fix, _validate_fix, _finalize
  As a developer using LangGraph
  I want AutoDebugAgent._generate_fix(), _validate_fix(), and _finalize() to return update dicts
  So that LangGraph can correctly merge state without side-effects or double-applied mutations

  LangGraph node functions must return a dict containing only the keys that changed,
  not the full state object. These tests verify the node contract for the three remaining
  AutoDebugAgent nodes beyond _analyze_error (covered by bug #10494 tests).

  Scenario: _generate_fix returns an update dict containing only current_fix
    Given an AutoDebugAgent with a mock LLM for the node contract test
    And a state with an error_analysis message for the node contract test
    When _generate_fix is called with the state for the node contract test
    Then the generate_fix result should be a plain dict of updates
    And the generate_fix result should contain only the current_fix key
    And the generate_fix result should not be the same object as the input state

  Scenario: _validate_fix returns an update dict with fix_validated True when fix is valid
    Given an AutoDebugAgent with a mock LLM returning valid for the node contract test
    And a state with a current_fix for the node contract test
    When _validate_fix is called with the state for the node contract test
    Then the validate_fix result should be a plain dict of updates
    And the validate_fix result should contain fix_validated set to True
    And the validate_fix result should not be the same object as the input state

  Scenario: _validate_fix adds attempted_fixes when fix is invalid
    Given an AutoDebugAgent with a mock LLM returning invalid for the node contract test
    And a state with a current_fix for the node contract test
    When _validate_fix is called with the state for the node contract test
    Then the validate_fix result should contain fix_validated set to False
    And the validate_fix result should contain the attempted_fixes key

  Scenario: _finalize returns an update dict containing only result
    Given an AutoDebugAgent with a mock LLM for the node contract test
    And a state with fix_validated True and a current_fix for the finalize test
    When _finalize is called with the state for the node contract test
    Then the finalize result should be a plain dict of updates
    And the finalize result should contain only the result key
    And the finalize result should not be the same object as the input state
