feat: complete Plugin controller lifecycle and owner diagnostics with real runtime coverage

This commit is contained in:
2026-10-30 07:15:03 +09:00
parent 9f13446afd
commit b824195b36
36 changed files with 2942 additions and 139 deletions
+1 -1
View File
@@ -275,7 +275,7 @@ fn build_runtime(config: &ProcessConfig) -> Result<Runtime, ProcessError> {
);
let plugins = worker_runtime::plugin::PinnedPluginToolRuntime::new(
providers,
&runtime_store_dir.join("plugin-cache"),
&runtime_store_dir.with_extension("plugin-cache"),
)
.map_err(ProcessError::WorkerAdapter)?;
factory = factory.with_plugin_runtime(Arc::new(plugins));
+2 -8
View File
@@ -196,7 +196,7 @@ pub mod remote {
plugin_delivery::{CurrentArtifactServer, RemotePluginArtifactSource},
},
};
use std::{collections::HashMap, sync::Arc, time::Duration};
use std::{collections::HashMap, sync::Arc};
pub type CurrentPluginServer = dyn Fn(&str) -> Result<WorkspaceIssuerTrustRecord, yoi_plugin_runtime::delivery::DeliveryError>
+ Send
+ Sync;
@@ -268,13 +268,7 @@ pub mod remote {
.map_err(|_| "Plugin Server trust unavailable")?,
);
let generated = client
.server_api_client(
crate::auth::WORKSPACE_REQUEST_PERMISSION,
Some(worker.worker_id.to_string()),
reqwest::header::HeaderMap::new(),
Duration::from_secs(30),
8 * 1024 * 1024,
)
.plugin_host_client(worker.worker_id.to_string())
.map_err(|_| "Plugin Host client unavailable")?;
let owner = Arc::new(RegisteredOwner {
source: source.clone(),
@@ -191,6 +191,37 @@ impl RuntimeWorkspaceRequestClient {
})
}
pub(crate) fn plugin_host_client(
&self,
worker_id: String,
) -> Result<
server_api::ServerApiClient<RuntimeWorkspaceRequestAuthorizer>,
RuntimeWorkspaceRequestError,
> {
let http = reqwest::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.no_proxy()
.timeout(Duration::from_secs(30))
.build()
.map_err(RuntimeWorkspaceRequestError::transport)?;
let authorizer = RuntimeWorkspaceRequestAuthorizer {
workspace_id: self.workspace_id.clone(),
runtime_id: self.runtime_id.clone(),
request_source: self.request_source.clone(),
permission: crate::auth::WORKSPACE_REQUEST_PERMISSION.into(),
worker_id: Some(worker_id),
extra_headers: HeaderMap::new(),
};
server_api::ServerApiClient::builder(&self.base_url)
.map_err(|error| RuntimeWorkspaceRequestError::InvalidRequest(error.to_string()))?
.client(http)
.authorizer(authorizer)
.request_timeout(Duration::from_secs(30))
.response_body_limit(yoi_plugin_runtime::owner::PLUGIN_HOST_RESPONSE_BODY_LIMIT)
.build()
.map_err(|error| RuntimeWorkspaceRequestError::InvalidRequest(error.to_string()))
}
pub(crate) fn server_api_client(
&self,
permission: impl Into<String>,