Feature: ExecutePhaseDecisionHook records execute-phase decisions
  As a developer
  I want decisions during the Execute phase recorded via ExecHook
  So that Strategize+Execute form a single unified decision tree

  Background:
    Given dexe plan "P1" ULID and service initialized
    And an ExecHook created for plan "P1" with parent None

  Scenario: Record implementation choice via ExecHook
    When dexe record impl_choice question="Which sort?" chosen="Quick"
    Then dexe decision recorded successfully type="implementation_choice"
    And dexe decision recorded successfully phase="execute"

  Scenario: Record tool invocation via ExecHook
    When dexe record tool_inv q="Tool?" tool_write="file_tool"
    Then dexe decision recorded successfully type="tool_invocation"

  Scenario: Record error recovery via ExecHook
    When dexe record error_recove q="File miss" action_ret="Retry"
    Then dexe decision recorded successfully type="error_recovery"
    And dexe decision recorded successfully phase="execute"

  Scenario: Record validation response via ExecHook
    When dexe record val_respond q="Lint fail" fix="Manual"
    Then dexe decision recorded successfully type="validation_response"

  Scenario: Record subplan spawn via ExecHook (Execute)
    When dexe record sub_spawn q="Extra transform" chosen="ChildPlan"
    Then dexe decision recorded successfully type="subplan_spawn"
    And dexe decision recorded successfully phase="execute"

  Scenario: Record parallel subplan spawn via ExecHook
    When dexe record par_spawn alt="SeqTrans" chosen="ParallelGroup"
    Then dexe decision recorded successfully type="subplan_parallel_spawn"

  Scenario: Record resource selection via ExecHook (Execute)
    When dexe record res_select q="Files?" chosen="src/*.py,tests/*.py"
    Then dexe decision recorded successfully type="resource_selection"
    And dexe decision recorded successfully phase="execute"

  Scenario: Decision with alternatives and confidence
    When dexe record impl_choice question="Sort?" alts="Merge|Heap|Quick" chosen="Quick" conf=0.8
    Then dexe decision recorded successfully alternatives_count=3
    And dexe decision recorded successfully confidence_score=0.8

  Scenario: Capture context snapshot hash
    When dexe record impl_choice question="ctx test" chose="A" with_context_json=1
    Then dexe decision recorded successfully snapshot_hash_not_empty=True

  Scenario: Empty question raises ValidationError
    When dexe record impl_choice question="" chosen="X" expect_error=True
    Then dexe validation error raised mentions="question"

  Scenario: Whitespace question raises ValidationError
    When dexe record impl_choice question="   " chosen="X" expect_error=True
    Then dexe validation error raised mentions="question"

  Scenario: Empty chosen_option raises ValidationError
    When dexe record tool_inv q="Q" tool_write="" expect_error=True
    Then dexe validation error raised mentions="chosen_option"

  Scenario: Whitespace chosen_option raises ValidationError
    When dexe record tool_inv q="Q" tool_write="   " expect_error=True
    Then dexe validation error raised mentions="chosen_option"

  Scenario: Empty plan_id raises ValidationError on construction
    When dexe construct hook with empty plan_id
    Then dexe validation error raised mentions="plan_id"

  Scenario: Whitespace plan_id raises ValidationError on construction
    When dexe construct hook with whitespace plan_id
    Then dexe validation error raised mentions="plan_id"
