1616from ..cli_rollout import append_cli_rollout_event
1717from ..hosts .capabilities import builtin_native_session_file
1818from ..control_plane .agents .workspace_guard import capture_delivery_workspace
19- from ..control_plane .effect_program import SettlementBindingKind
2019from ..control_plane .goals .first_party_host_admission import (
2120 FirstPartyHostGoalAdmission ,
2221 FirstPartyHostRuntimeRejected ,
@@ -793,14 +792,7 @@ def scheduler(_spend_payload: dict[str, object]) -> dict[str, object]:
793792
794793 host_runner : Callable [[Mapping [str , Any ]], dict [str , Any ]] | None = None
795794 session_binding_resolver = None
796- native_dsh_dispatch = (
797- args .host == "dsh"
798- and not getattr (args , "dsh_operation_module" , None )
799- and not getattr (args , "dsh_runner" , None )
800- and settlement_identity .binding_kind in (
801- SettlementBindingKind .TODO , SettlementBindingKind .AUTONOMOUS_REPLAN ,
802- )
803- )
795+ dispatch_operation : str | None = None
804796
805797 def current_launch_decision (current_registry : Path ) -> Mapping [str , Any ]:
806798 nonlocal prior_launch_decision
@@ -814,9 +806,9 @@ def current_launch_decision(current_registry: Path) -> Mapping[str, Any]:
814806 scheduler_execution_context = payload .get ("scheduler_execution_context" ) or {},
815807 operator_inbox_urgency_projector = operator_inbox_urgency_projector ,
816808 turn_start_hook_dispatch = turn_start_hook_dispatch , goal_ref = goal_ref ,
817- fresh_dispatch = native_dsh_dispatch ,
809+ fresh_dispatch = dispatch_operation is not None ,
818810 )
819- if native_dsh_dispatch :
811+ if dispatch_operation is not None :
820812 current = launch ["current" ]
821813 recovery = current .get ("unsettled_host_turn_recovery" )
822814 if (current .get ("effective_action" ) == EffectiveAction .UNSETTLED_HOST_TURN_RECOVERY .value
@@ -932,6 +924,10 @@ def resolve_built_in_session_binding(
932924
933925 session_binding_resolver = resolve_built_in_session_binding
934926 elif args .host == "dsh" :
927+ from .turn_dsh_host import native_dispatch_operation
928+
929+ dispatch_operation = native_dispatch_operation (args , settlement_identity .binding_kind )
930+ native_dsh_dispatch = dispatch_operation is not None
935931 dsh_operation = bool (getattr (args , "dsh_operation_module" , None ))
936932 if dsh_operation :
937933 host_runner = getattr (_sys .modules [__name__ ], "build_dsh_operation_host_runner" )(
@@ -1014,15 +1010,15 @@ def on_managed_start_admitted() -> None:
10141010 )
10151011
10161012 def admit_managed_start (identity : Mapping [str , Any ]) -> dict [str , Any ]:
1017- if native_dsh_dispatch and not getattr (args , "resume_turn_key" , None ):
1013+ if dispatch_operation is not None and not getattr (args , "resume_turn_key" , None ):
10181014 # The plan can predate another Turn's dispatch. Recheck inside
10191015 # the executing lane before reserving cadence or binding work.
10201016 admission = goal_admission or FirstPartyHostGoalAdmission .for_plan (
10211017 registry_path = registry_path , goal_id = args .goal_id , planned_goal_ref = goal_ref ,
10221018 agent_id = args .agent_id ,
10231019 )
10241020 with admission .with_launch_decision (current_launch_decision ).launch_lifetime (
1025- operation = "dsh_turn_launch" ,
1021+ operation = dispatch_operation ,
10261022 ):
10271023 pass
10281024 return managed_cadence .admit (identity )
0 commit comments