fix: gate runtime projection broadcasts
This commit is contained in:
@@ -1382,12 +1382,7 @@ impl RuntimeRegistry {
|
|||||||
&self,
|
&self,
|
||||||
projection: worker::WorkspacePromptProjection,
|
projection: worker::WorkspacePromptProjection,
|
||||||
) -> Vec<RuntimeDiagnostic> {
|
) -> Vec<RuntimeDiagnostic> {
|
||||||
let runtimes = self
|
self.runtimes_snapshot()
|
||||||
.runtimes
|
|
||||||
.read()
|
|
||||||
.map(|runtimes| runtimes.clone())
|
|
||||||
.unwrap_or_default();
|
|
||||||
runtimes
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|runtime| {
|
.filter_map(|runtime| {
|
||||||
runtime
|
runtime
|
||||||
@@ -5198,18 +5193,23 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn registry_gate_rejects_cached_runtime_immediately_after_binding_revocation() {
|
fn registry_gate_rejects_cached_runtime_immediately_after_binding_revocation() {
|
||||||
let registry = RuntimeRegistry::new(vec![Arc::new(FixtureRuntime::with_worker(
|
let remote =
|
||||||
"runtime-a",
|
FixtureRuntime::with_worker("runtime-a", "host-a", "worker-a", "worker from runtime a");
|
||||||
"host-a",
|
let remote_observed = remote.observed_prompt_revisions.clone();
|
||||||
"worker-a",
|
let embedded = FixtureRuntime::with_worker(
|
||||||
"worker from runtime a",
|
EMBEDDED_RUNTIME_ID,
|
||||||
))]);
|
"embedded-host",
|
||||||
|
"embedded-worker",
|
||||||
|
"embedded worker",
|
||||||
|
);
|
||||||
|
let embedded_observed = embedded.observed_prompt_revisions.clone();
|
||||||
|
let registry = RuntimeRegistry::new(vec![Arc::new(remote), Arc::new(embedded)]);
|
||||||
let active = Arc::new(Mutex::new(true));
|
let active = Arc::new(Mutex::new(true));
|
||||||
let gate_state = active.clone();
|
let gate_state = active.clone();
|
||||||
registry.set_runtime_binding_gate(move |_| {
|
registry.set_runtime_binding_gate(move |_| {
|
||||||
*gate_state.lock().expect("gate state lock poisoned")
|
*gate_state.lock().expect("gate state lock poisoned")
|
||||||
});
|
});
|
||||||
assert_eq!(registry.list_runtimes(10).items.len(), 1);
|
assert_eq!(registry.list_runtimes(10).items.len(), 2);
|
||||||
assert!(
|
assert!(
|
||||||
registry
|
registry
|
||||||
.worker(&RuntimeWorkerRef::new("runtime-a", "worker-a"))
|
.worker(&RuntimeWorkerRef::new("runtime-a", "worker-a"))
|
||||||
@@ -5217,11 +5217,36 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
*active.lock().expect("gate state lock poisoned") = false;
|
*active.lock().expect("gate state lock poisoned") = false;
|
||||||
assert!(registry.list_runtimes(10).items.is_empty());
|
assert_eq!(registry.list_runtimes(10).items.len(), 1);
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
registry.worker(&RuntimeWorkerRef::new("runtime-a", "worker-a")),
|
registry.worker(&RuntimeWorkerRef::new("runtime-a", "worker-a")),
|
||||||
Err(RuntimeRegistryError::UnknownRuntime(runtime_id)) if runtime_id == "runtime-a"
|
Err(RuntimeRegistryError::UnknownRuntime(runtime_id)) if runtime_id == "runtime-a"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
let catalog = worker::EffectivePromptCatalog::new(
|
||||||
|
std::collections::BTreeMap::from([(
|
||||||
|
"default".to_string(),
|
||||||
|
"workspace prompt".to_string(),
|
||||||
|
)]),
|
||||||
|
12,
|
||||||
|
"schema",
|
||||||
|
"toolchain",
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let projection = worker::WorkspacePromptProjection::new(
|
||||||
|
"workspace-a",
|
||||||
|
"source-12",
|
||||||
|
catalog.catalog_digest.clone(),
|
||||||
|
catalog,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
assert!(
|
||||||
|
registry
|
||||||
|
.observe_workspace_prompt_projection(projection)
|
||||||
|
.is_empty()
|
||||||
|
);
|
||||||
|
assert!(remote_observed.lock().unwrap().is_empty());
|
||||||
|
assert_eq!(*embedded_observed.lock().unwrap(), vec![12]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user