1515from ..capabilities .turn_context import configured_post_settlement
1616from ..cli_rollout import append_cli_rollout_event
1717from ..control_plane .agents .workspace_guard import capture_delivery_workspace
18- from ..control_plane .effect_program import SettlementBindingKind
1918from ..control_plane .goals .first_party_host_admission import (
2019 FirstPartyHostGoalAdmission ,
2120 FirstPartyHostRuntimeRejected ,
@@ -750,14 +749,7 @@ def scheduler(_spend_payload: dict[str, object]) -> dict[str, object]:
750749
751750 host_runner : Callable [[Mapping [str , Any ]], dict [str , Any ]] | None = None
752751 session_binding_resolver = None
753- native_dsh_dispatch = (
754- args .host == "dsh"
755- and not getattr (args , "dsh_operation_module" , None )
756- and not getattr (args , "dsh_runner" , None )
757- and settlement_identity .binding_kind in (
758- SettlementBindingKind .TODO , SettlementBindingKind .AUTONOMOUS_REPLAN ,
759- )
760- )
752+ dispatch_operation : str | None = None
761753
762754 def current_launch_decision (current_registry : Path ) -> Mapping [str , Any ]:
763755 nonlocal prior_launch_decision
@@ -771,9 +763,9 @@ def current_launch_decision(current_registry: Path) -> Mapping[str, Any]:
771763 scheduler_execution_context = payload .get ("scheduler_execution_context" ) or {},
772764 operator_inbox_urgency_projector = operator_inbox_urgency_projector ,
773765 turn_start_hook_dispatch = turn_start_hook_dispatch , goal_ref = goal_ref ,
774- fresh_dispatch = native_dsh_dispatch ,
766+ fresh_dispatch = dispatch_operation is not None ,
775767 )
776- if native_dsh_dispatch :
768+ if dispatch_operation is not None :
777769 current = launch ["current" ]
778770 recovery = current .get ("unsettled_host_turn_recovery" )
779771 if (current .get ("effective_action" ) == EffectiveAction .UNSETTLED_HOST_TURN_RECOVERY .value
@@ -838,6 +830,10 @@ def resolve_built_in_session_binding(
838830
839831 session_binding_resolver = resolve_built_in_session_binding
840832 elif args .host == "dsh" :
833+ from .turn_dsh_host import native_dispatch_operation
834+
835+ dispatch_operation = native_dispatch_operation (args , settlement_identity .binding_kind )
836+ native_dsh_dispatch = dispatch_operation is not None
841837 dsh_operation = bool (getattr (args , "dsh_operation_module" , None ))
842838 if dsh_operation :
843839 host_runner = getattr (_sys .modules [__name__ ], "build_dsh_operation_host_runner" )(
@@ -933,15 +929,15 @@ def on_managed_start_admitted() -> None:
933929 )
934930
935931 def admit_managed_start (identity : Mapping [str , Any ]) -> dict [str , Any ]:
936- if native_dsh_dispatch and not getattr (args , "resume_turn_key" , None ):
932+ if dispatch_operation is not None and not getattr (args , "resume_turn_key" , None ):
937933 # The plan can predate another Turn's dispatch. Recheck inside
938934 # the executing lane before reserving cadence or binding work.
939935 admission = goal_admission or FirstPartyHostGoalAdmission .for_plan (
940936 registry_path = registry_path , goal_id = args .goal_id , planned_goal_ref = goal_ref ,
941937 agent_id = args .agent_id ,
942938 )
943939 with admission .with_launch_decision (current_launch_decision ).launch_lifetime (
944- operation = "dsh_turn_launch" ,
940+ operation = dispatch_operation ,
945941 ):
946942 pass
947943 return managed_cadence .admit (identity )
0 commit comments