refactor: remove worker capability summary flags
This commit is contained in:
@@ -240,12 +240,6 @@ pub struct InternalWorkerImplementationSummary {
|
||||
pub display_hint: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct InternalWorkerCapabilitySummary {
|
||||
pub can_stop: bool,
|
||||
pub can_spawn_followup: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct InternalWorkerSummary {
|
||||
#[serde(flatten)]
|
||||
@@ -273,7 +267,6 @@ pub struct InternalWorkerSummary {
|
||||
#[serde(default)]
|
||||
pub retention_state: String,
|
||||
pub implementation: InternalWorkerImplementationSummary,
|
||||
pub capabilities: InternalWorkerCapabilitySummary,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub workdir_attachments: Vec<WorkingDirectoryAttachmentStatus>,
|
||||
pub diagnostics: Vec<RuntimeDiagnostic>,
|
||||
@@ -384,10 +377,6 @@ pub(crate) fn workspace_worker_summary(
|
||||
kind: summary.implementation.kind,
|
||||
display_hint: summary.implementation.display_hint,
|
||||
},
|
||||
capabilities: server_api::WorkerCapabilitySummary {
|
||||
can_stop: summary.capabilities.can_stop,
|
||||
can_spawn_followup: summary.capabilities.can_spawn_followup,
|
||||
},
|
||||
workdir_attachments,
|
||||
diagnostics: summary.diagnostics.into_iter().map(Into::into).collect(),
|
||||
}
|
||||
@@ -2231,10 +2220,6 @@ impl EmbeddedWorkerRuntime {
|
||||
Some(EmbeddedWorkerRef::new(EmbeddedWorkerId::parse(worker_id)?))
|
||||
}
|
||||
|
||||
fn can_stop_embedded_worker(&self, status: EmbeddedWorkerStatus) -> bool {
|
||||
runtime_worker_can_stop(self.execution_enabled, status)
|
||||
}
|
||||
|
||||
fn map_worker_summary(
|
||||
&self,
|
||||
summary: worker_runtime::catalog::WorkerSummary,
|
||||
@@ -2274,11 +2259,6 @@ impl EmbeddedWorkerRuntime {
|
||||
kind: "embedded_worker_runtime".to_string(),
|
||||
display_hint: "backend-internal worker-runtime Worker".to_string(),
|
||||
},
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: summary.execution_metadata_available
|
||||
&& self.can_stop_embedded_worker(summary.status),
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: summary.workdir_attachments,
|
||||
diagnostics: embedded_worker_projection_diagnostics(
|
||||
summary.execution_metadata_available,
|
||||
@@ -2319,11 +2299,6 @@ impl EmbeddedWorkerRuntime {
|
||||
kind: "embedded_worker_runtime".to_string(),
|
||||
display_hint: "backend-internal worker-runtime Worker".to_string(),
|
||||
},
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: detail.execution_metadata_available
|
||||
&& self.can_stop_embedded_worker(detail.status),
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: detail.workdir_attachments,
|
||||
diagnostics: embedded_worker_projection_diagnostics(
|
||||
detail.execution_metadata_available,
|
||||
@@ -4127,11 +4102,6 @@ impl RemoteWorkerRuntime {
|
||||
kind: "remote_worker_runtime".to_string(),
|
||||
display_hint: "Backend-proxied remote worker-runtime Worker".to_string(),
|
||||
},
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: summary.execution_metadata_available
|
||||
&& runtime_worker_can_stop(true, summary.status),
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: summary.workdir_attachments,
|
||||
diagnostics: remote_worker_projection_diagnostics(summary.execution_metadata_available),
|
||||
}
|
||||
@@ -4170,11 +4140,6 @@ impl RemoteWorkerRuntime {
|
||||
kind: "remote_worker_runtime".to_string(),
|
||||
display_hint: "Backend-proxied remote worker-runtime Worker".to_string(),
|
||||
},
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: detail.execution_metadata_available
|
||||
&& runtime_worker_can_stop(true, detail.status),
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: detail.workdir_attachments,
|
||||
diagnostics: remote_worker_projection_diagnostics(detail.execution_metadata_available),
|
||||
}
|
||||
@@ -5152,10 +5117,6 @@ fn embedded_runtime_status_label(status: RuntimeStatus) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
fn runtime_worker_can_stop(execution_enabled: bool, status: EmbeddedWorkerStatus) -> bool {
|
||||
execution_enabled && status.is_active()
|
||||
}
|
||||
|
||||
fn embedded_worker_status_label(status: EmbeddedWorkerStatus) -> &'static str {
|
||||
match status {
|
||||
EmbeddedWorkerStatus::Idle => "idle",
|
||||
@@ -5963,10 +5924,6 @@ pub fn placeholder_worker(host_id: impl Into<String>) -> InternalWorkerSummary {
|
||||
kind: "placeholder".to_string(),
|
||||
display_hint: "unsupported".to_string(),
|
||||
},
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: false,
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: Vec::new(),
|
||||
diagnostics: vec![diagnostic(
|
||||
"runtime_capability_unsupported",
|
||||
@@ -6621,10 +6578,6 @@ mod tests {
|
||||
kind: "fixture".to_string(),
|
||||
display_hint: "test fixture".to_string(),
|
||||
},
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: false,
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: Vec::new(),
|
||||
diagnostics: Vec::new(),
|
||||
}],
|
||||
@@ -7123,7 +7076,12 @@ mod tests {
|
||||
let spawned = runtime.spawn_worker(test_create_binding(), embedded_spawn_request());
|
||||
assert_eq!(spawned.state, InternalWorkerOperationState::Accepted);
|
||||
let worker = spawned.worker.expect("created embedded worker");
|
||||
assert!(worker.capabilities.can_stop);
|
||||
assert!(
|
||||
serde_json::to_value(&worker)
|
||||
.unwrap()
|
||||
.get("capabilities")
|
||||
.is_none()
|
||||
);
|
||||
|
||||
let input = runtime.send_input(
|
||||
&worker.worker.worker_id,
|
||||
@@ -7496,7 +7454,12 @@ mod tests {
|
||||
workers.items[0].workspace.identity,
|
||||
"runtime_registry_worker"
|
||||
);
|
||||
assert!(workers.items[0].capabilities.can_stop);
|
||||
assert!(
|
||||
serde_json::to_value(&workers.items[0])
|
||||
.unwrap()
|
||||
.get("capabilities")
|
||||
.is_none()
|
||||
);
|
||||
|
||||
let input = registry
|
||||
.send_input(
|
||||
@@ -7581,11 +7544,14 @@ mod tests {
|
||||
|
||||
let workers = registry.list_workers(10);
|
||||
assert_eq!(workers.items.len(), 5);
|
||||
assert!(!workers.items[0].capabilities.can_stop);
|
||||
assert!(workers.items[1].capabilities.can_stop);
|
||||
assert!(workers.items[2].capabilities.can_stop);
|
||||
assert!(workers.items[3].capabilities.can_stop);
|
||||
assert!(!workers.items[4].capabilities.can_stop);
|
||||
for worker in &workers.items {
|
||||
assert!(
|
||||
serde_json::to_value(worker)
|
||||
.unwrap()
|
||||
.get("capabilities")
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
assert_eq!(workers.items[0].state, "stopped");
|
||||
assert_eq!(workers.items[1].state, "running");
|
||||
assert_eq!(workers.items[2].state, "paused");
|
||||
@@ -7601,7 +7567,12 @@ mod tests {
|
||||
let stopped_detail = registry
|
||||
.worker(&RuntimeWorkerRef::new("remote:primary", &worker_id))
|
||||
.unwrap();
|
||||
assert!(!stopped_detail.capabilities.can_stop);
|
||||
assert!(
|
||||
serde_json::to_value(&stopped_detail)
|
||||
.unwrap()
|
||||
.get("capabilities")
|
||||
.is_none()
|
||||
);
|
||||
assert_eq!(stopped_detail.state, "stopped");
|
||||
|
||||
server.join().expect("mock remote server finished");
|
||||
|
||||
@@ -152,17 +152,16 @@ use crate::companion::{
|
||||
use crate::config_source::ConfigCommitRequest;
|
||||
use crate::hosts::{
|
||||
EMBEDDED_RUNTIME_ID, EmbeddedWorkerRuntime, HostDiagnosticSeverity, InternalHostSummary,
|
||||
InternalWorkerCapabilitySummary, InternalWorkerImplementationSummary,
|
||||
InternalWorkerOperationState, InternalWorkerRestoreResult, InternalWorkerSummary,
|
||||
InternalWorkerWorkspaceSummary, RemoteRuntimeConfig, RemoteWorkerRuntime, RuntimeDiagnostic,
|
||||
RuntimePingFailureKind, RuntimeRegistry, RuntimeRegistryError, RuntimeRegistryUnregisterResult,
|
||||
TicketWorkerRole, WorkerCompletionsRequest, WorkerCompletionsResult, WorkerControlOperation,
|
||||
WorkerCreateBinding, WorkerInputKind, WorkerInputRequest, WorkerInputResult,
|
||||
WorkerLifecycleRequest, WorkerLifecycleResult, WorkerSpawnAcceptanceRequirement,
|
||||
WorkerSpawnIntent, WorkerSpawnRequest, WorkerSpawnResult, WorkerSpawnWorkingDirectoryRequest,
|
||||
WorkerTicketAssignmentRequest, WorkspaceRuntimeAuthorization,
|
||||
is_disallowed_remote_runtime_address, is_loopback_runtime_origin,
|
||||
worker_spawn_create_fingerprint, workspace_worker_summary,
|
||||
InternalWorkerImplementationSummary, InternalWorkerOperationState, InternalWorkerRestoreResult,
|
||||
InternalWorkerSummary, InternalWorkerWorkspaceSummary, RemoteRuntimeConfig,
|
||||
RemoteWorkerRuntime, RuntimeDiagnostic, RuntimePingFailureKind, RuntimeRegistry,
|
||||
RuntimeRegistryError, RuntimeRegistryUnregisterResult, TicketWorkerRole,
|
||||
WorkerCompletionsRequest, WorkerCompletionsResult, WorkerControlOperation, WorkerCreateBinding,
|
||||
WorkerInputKind, WorkerInputRequest, WorkerInputResult, WorkerLifecycleRequest,
|
||||
WorkerLifecycleResult, WorkerSpawnAcceptanceRequirement, WorkerSpawnIntent, WorkerSpawnRequest,
|
||||
WorkerSpawnResult, WorkerSpawnWorkingDirectoryRequest, WorkerTicketAssignmentRequest,
|
||||
WorkspaceRuntimeAuthorization, is_disallowed_remote_runtime_address,
|
||||
is_loopback_runtime_origin, worker_spawn_create_fingerprint, workspace_worker_summary,
|
||||
};
|
||||
use crate::memory_backend::execute_memory_backend_operation_with_authority;
|
||||
use crate::memory_staging::{
|
||||
@@ -5175,10 +5174,6 @@ fn runtime_worker_summary_to_api(
|
||||
kind: worker.implementation.kind,
|
||||
display_hint: worker.implementation.display_hint,
|
||||
},
|
||||
capabilities: server_api::WorkerCapabilitySummary {
|
||||
can_stop: worker.capabilities.can_stop,
|
||||
can_spawn_followup: worker.capabilities.can_spawn_followup,
|
||||
},
|
||||
workdir_attachments: worker
|
||||
.workdir_attachments
|
||||
.into_iter()
|
||||
@@ -16956,10 +16951,6 @@ fn worker_launch_worker_summary(worker: InternalWorkerSummary) -> WorkerLaunchWo
|
||||
kind: worker.implementation.kind,
|
||||
display_hint: worker.implementation.display_hint,
|
||||
},
|
||||
capabilities: server_api::WorkerCapabilitySummary {
|
||||
can_stop: worker.capabilities.can_stop,
|
||||
can_spawn_followup: worker.capabilities.can_spawn_followup,
|
||||
},
|
||||
workdir_attachments: worker
|
||||
.workdir_attachments
|
||||
.into_iter()
|
||||
@@ -24806,10 +24797,6 @@ fn worker_summary_from_registry(record: &WorkerRegistryRecord) -> InternalWorker
|
||||
last_seen_at: Some(record.updated_at.clone()),
|
||||
pinned: record.retention_state == "pinned",
|
||||
retention_state: record.retention_state.clone(),
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: false,
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workspace: InternalWorkerWorkspaceSummary {
|
||||
visibility: "backend_registry".to_string(),
|
||||
identity: record.workspace_id.clone(),
|
||||
@@ -24855,8 +24842,6 @@ fn worker_summary_from_projection(
|
||||
.then(|| observation.worker.worker_state.clone())
|
||||
.flatten();
|
||||
summary.last_seen_at = Some(observation.observed_at.clone());
|
||||
summary.capabilities.can_stop = observed
|
||||
&& observation.worker.state != protocol::subscription::SubscriptionWorkerState::Stopped;
|
||||
summary.implementation.display_hint = if observed {
|
||||
"Runtime-backed Worker".to_string()
|
||||
} else {
|
||||
@@ -26709,7 +26694,12 @@ mod tests {
|
||||
assert_eq!(unavailable.availability, availability);
|
||||
assert_eq!(unavailable.state, "unavailable");
|
||||
assert_eq!(unavailable.worker_state, None);
|
||||
assert!(!unavailable.capabilities.can_stop);
|
||||
assert!(
|
||||
serde_json::to_value(&unavailable)
|
||||
.unwrap()
|
||||
.get("capabilities")
|
||||
.is_none()
|
||||
);
|
||||
|
||||
let mut observed_stopped = projection;
|
||||
let observation = observed_stopped.observation.as_mut().unwrap();
|
||||
@@ -28645,10 +28635,6 @@ mod tests {
|
||||
kind: "fixture".to_string(),
|
||||
display_hint: "Workdirless fixture".to_string(),
|
||||
},
|
||||
capabilities: InternalWorkerCapabilitySummary {
|
||||
can_stop: true,
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: Vec::new(),
|
||||
diagnostics: Vec::new(),
|
||||
}
|
||||
@@ -40983,10 +40969,6 @@ mod tests {
|
||||
kind: "remote".to_string(),
|
||||
display_hint: "remote".to_string(),
|
||||
},
|
||||
capabilities: server_api::WorkerCapabilitySummary {
|
||||
can_stop: true,
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: Vec::new(),
|
||||
diagnostics: Vec::new(),
|
||||
}
|
||||
@@ -41081,10 +41063,6 @@ mod tests {
|
||||
kind: "remote".to_string(),
|
||||
display_hint: "remote".to_string(),
|
||||
},
|
||||
capabilities: server_api::WorkerCapabilitySummary {
|
||||
can_stop: true,
|
||||
can_spawn_followup: false,
|
||||
},
|
||||
workdir_attachments: Vec::new(),
|
||||
diagnostics: Vec::new(),
|
||||
}],
|
||||
@@ -43445,7 +43423,12 @@ mod tests {
|
||||
// catalog remains controllable while its failed execution is represented in
|
||||
// `worker_state` rather than by removing the catalog Worker.
|
||||
assert_eq!(restored_worker.state, "idle");
|
||||
assert!(restored_worker.capabilities.can_stop);
|
||||
assert!(
|
||||
serde_json::to_value(&restored_worker)
|
||||
.unwrap()
|
||||
.get("capabilities")
|
||||
.is_none()
|
||||
);
|
||||
|
||||
let bundles = restored
|
||||
.runtime
|
||||
|
||||
Reference in New Issue
Block a user