From eac07cf5a88848e693a6fb06adb2a0b055ef8e82 Mon Sep 17 00:00:00 2001 From: Hare Date: Wed, 26 Aug 2026 10:16:10 +0900 Subject: [PATCH] fix: provide subworker control service --- crates/worker/src/controller.rs | 8 +++ .../src/feature/builtin/manage_worker.rs | 51 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/crates/worker/src/controller.rs b/crates/worker/src/controller.rs index e801107e..7f47f650 100644 --- a/crates/worker/src/controller.rs +++ b/crates/worker/src/controller.rs @@ -975,6 +975,14 @@ where if feature_config.sub_worker.enabled { worker.register_worker_orchestration_instruction(); + if !feature_config.worker.enabled { + feature_registry.add_module( + crate::feature::builtin::manage_worker::sub_worker_control_feature( + worker.workspace_client_handle(), + spawned_registry.clone(), + ), + ); + } } let host_worker_observation_provider = worker.worker_observation_provider(); diff --git a/crates/worker/src/feature/builtin/manage_worker.rs b/crates/worker/src/feature/builtin/manage_worker.rs index caf527bf..bc7e55e9 100644 --- a/crates/worker/src/feature/builtin/manage_worker.rs +++ b/crates/worker/src/feature/builtin/manage_worker.rs @@ -356,6 +356,57 @@ pub fn manage_worker_feature( } } +#[derive(Clone)] +pub struct SubWorkerControlFeature { + control: Arc, +} + +impl std::fmt::Debug for SubWorkerControlFeature { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter + .debug_struct("SubWorkerControlFeature") + .finish_non_exhaustive() + } +} + +pub fn sub_worker_control_feature( + client: Arc, + registry: Arc, +) -> SubWorkerControlFeature { + let workspace_id = client.workspace_id().unwrap_or_default().to_string(); + SubWorkerControlFeature { + control: Arc::new(WorkspaceWorkerControlService { + client, + workspace_id, + registry: Some(registry), + }), + } +} + +impl FeatureModule for SubWorkerControlFeature { + fn descriptor(&self) -> FeatureDescriptor { + FeatureDescriptor::builtin("sub_worker", "SubWorker") + .with_description("Parent-owned SubWorker control authority.") + .with_provided_service(ServiceDeclaration::new( + ServiceId::builtin(WORKER_CONTROL_SERVICE_ID), + WORKER_LIFECYCLE_SERVICE_VERSION, + "Known-SubWorker discovery and permission-fenced control operations", + )) + } + + fn install(&self, context: &mut FeatureInstallContext<'_>) -> Result<(), FeatureInstallError> { + context.services().provide( + ServiceDeclaration::new( + ServiceId::builtin(WORKER_CONTROL_SERVICE_ID), + WORKER_LIFECYCLE_SERVICE_VERSION, + "Known-SubWorker discovery and permission-fenced control operations", + ), + self.control.clone(), + )?; + Ok(()) + } +} + impl FeatureModule for ManageWorkerFeature { fn descriptor(&self) -> FeatureDescriptor { let mut descriptor = FeatureDescriptor::builtin(FEATURE_ID, FEATURE_NAME)