Feature: Estimation lifecycle hook and actor.default.estimation config fallback As a developer using CleverAgents I want the estimation actor to be resolved via a 4-level fallback chain And I want a PLAN_ESTIMATION_COMPLETE event emitted after estimation And I want cost_estimate_usd populated from the estimation result So that estimation integrates cleanly into the Strategize-to-Execute lifecycle # ── Subtask 1: 4-level fallback chain in use_action() ────────────────── Scenario: estimation_actor from action YAML takes precedence over global config Given I have a lifecycle service with a global estimation actor config "global/estimator" And I create an action with estimation_actor "action/estimator" When I use the action to create a plan Then the plan estimation_actor should be "action/estimator" Scenario: estimation_actor falls back to actor.default.estimation global config when action has none Given I have a lifecycle service with a global estimation actor config "global/estimator" And I create an action without an estimation_actor When I use the action to create a plan Then the plan estimation_actor should be "global/estimator" Scenario: estimation_actor is None when neither action nor global config provides one Given I have a lifecycle service without a global estimation actor config And I create an action without an estimation_actor When I use the action to create a plan Then the plan estimation_actor should be None for fallback tests Scenario: estimation_actor from action YAML is used even when global config is set Given I have a lifecycle service with a global estimation actor config "global/estimator" And I create an action with estimation_actor "action/specific-estimator" When I use the action to create a plan Then the plan estimation_actor should be "action/specific-estimator" # ── Subtask 2: PLAN_ESTIMATION_COMPLETE event ─────────────────────────── Scenario: PLAN_ESTIMATION_COMPLETE event is emitted when estimation runs Given I have a lifecycle service with an event bus for estimation tests And I create an action with estimation_actor "local/estimator" for event tests When I use the action and drive through strategize to execute Then a PLAN_ESTIMATION_COMPLETE event should have been emitted Scenario: No PLAN_ESTIMATION_COMPLETE event when no estimation actor configured Given I have a lifecycle service with an event bus for estimation tests And I create an action without estimation_actor for event tests When I use the action and drive through strategize to execute without estimation Then no PLAN_ESTIMATION_COMPLETE event should have been emitted # ── Subtask 3: Conditional estimation step in Strategize-to-Execute ───── Scenario: Estimation step runs between Strategize completion and Execute start Given I have a plan lifecycle service for estimation lifecycle tests And I create an action with estimation_actor "local/estimator" for lifecycle tests When I use the action and complete strategize for lifecycle tests And I call execute_plan for lifecycle tests Then the plan should be in Execute phase And the plan estimation_result should be populated Scenario: Estimation step is skipped cleanly when no estimation actor is set Given I have a plan lifecycle service for estimation lifecycle tests And I create an action without estimation_actor for lifecycle tests When I use the action and complete strategize for lifecycle tests And I call execute_plan for lifecycle tests Then the plan should be in Execute phase And the plan estimation_result should be None for lifecycle tests # ── Subtask 4: cost_estimate_usd populated from estimation result ──────── Scenario: cost_estimate_usd is populated from estimation result after estimation runs Given I have a plan lifecycle service for cost estimate tests And I create an action with estimation_actor "local/estimator" for cost tests When I use the action and drive through strategize to execute for cost tests Then the plan cost_estimate_usd should be set # ── Subtask 5: Clean skip when no estimation actor configured ──────────── Scenario: Plan transitions to Execute cleanly when no estimation actor is configured Given I have a plan lifecycle service for skip tests And I create an action without estimation_actor for skip tests When I use the action and complete strategize for skip tests And I call execute_plan for skip tests Then the plan should transition to Execute phase cleanly And no estimation result should be set on the plan # ── EventType enum has PLAN_ESTIMATION_COMPLETE ────────────────────────── Scenario: EventType enum includes PLAN_ESTIMATION_COMPLETE Then the EventType enum should have PLAN_ESTIMATION_COMPLETE And the PLAN_ESTIMATION_COMPLETE value should be "plan.estimation_complete"