Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(fleet-sdk): random petname claim names (#6368)
r33drichards41ece8b3980e
diff --git a/libs/fleet/Cargo.lock b/libs/fleet/Cargo.lockindex b30f07a15e..3ece20285c 100644--- a/libs/fleet/Cargo.lock+++ b/libs/fleet/Cargo.lock@@ -193,7 +193,7 @@ checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81"dependencies = ["cfg-if","cpufeatures",- "rand_core",+ "rand_core 0.10.1",][[package]]@@ -269,8 +269,10 @@ dependencies = ["camino","cyclops-sdk-schema","futures-timer",+ "getrandom 0.2.17","gloo-timers","js-sys",+ "petname","reqwest","serde","serde_json",@@ -411,6 +413,12 @@ version = "1.0.20"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555"+[[package]]+name = "either"+version = "1.17.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d"+[[package]]name = "equivalent"version = "1.0.2"@@ -525,7 +533,7 @@ dependencies = ["js-sys","libc","r-efi",- "rand_core",+ "rand_core 0.10.1","wasm-bindgen",]@@ -795,6 +803,15 @@ version = "2.12.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2"+[[package]]+name = "itertools"+version = "0.15.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc"+dependencies = [+ "either",+]+[[package]]name = "itoa"version = "1.0.18"@@ -1002,6 +1019,19 @@ version = "2.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"+[[package]]+name = "petname"+version = "2.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9cd31dcfdbbd7431a807ef4df6edd6473228e94d5c805e8cf671227a21bad068"+dependencies = [+ "anyhow",+ "itertools",+ "proc-macro2",+ "quote",+ "rand 0.8.7",+]+[[package]]name = "pin-project-lite"version = "0.2.17"@@ -1038,6 +1068,15 @@ dependencies = ["zerovec",]+[[package]]+name = "ppv-lite86"+version = "0.2.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"+dependencies = [+ "zerocopy",+]+[[package]]name = "proc-macro2"version = "1.0.107"@@ -1076,7 +1115,7 @@ dependencies = ["bytes","getrandom 0.4.3","lru-slab",- "rand",+ "rand 0.10.2","rand_pcg","ring","rustc-hash",@@ -1118,6 +1157,17 @@ version = "6.0.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"+[[package]]+name = "rand"+version = "0.8.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "22f6172bdec972074665ed81ed53b71da00bfc44b65a753cfde883ec4c702a1a"+dependencies = [+ "libc",+ "rand_chacha",+ "rand_core 0.6.4",+]+[[package]]name = "rand"version = "0.10.2"@@ -1126,7 +1176,26 @@ checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80"dependencies = ["chacha20","getrandom 0.4.3",- "rand_core",+ "rand_core 0.10.1",+]++[[package]]+name = "rand_chacha"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"+dependencies = [+ "ppv-lite86",+ "rand_core 0.6.4",+]++[[package]]+name = "rand_core"+version = "0.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"+dependencies = [+ "getrandom 0.2.17",][[package]]@@ -1141,7 +1210,7 @@ version = "0.10.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a"dependencies = [- "rand_core",+ "rand_core 0.10.1",][[package]]@@ -2195,6 +2264,26 @@ dependencies = ["synstructure",]+[[package]]+name = "zerocopy"+version = "0.8.55"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b5a105cd7b140f6eeec8acff2ea38135d3cab283ada58540f629fe51e46696eb"+dependencies = [+ "zerocopy-derive",+]++[[package]]+name = "zerocopy-derive"+version = "0.8.55"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0fe976fb70c78cd64cccfe3a6fc142244e8a77b70959b30faf9d0ac37ee228eb"+dependencies = [+ "proc-macro2",+ "quote",+ "syn 2.0.119",+]+[[package]]name = "zerofrom"version = "0.1.8"diff --git a/libs/fleet/sdk/Cargo.toml b/libs/fleet/sdk/Cargo.tomlindex 812c8a6ede..bace32dab1 100644--- a/libs/fleet/sdk/Cargo.toml+++ b/libs/fleet/sdk/Cargo.toml@@ -13,6 +13,10 @@ async-trait.workspace = truebase64.workspace = truecyclops-sdk-schema = { path = "../sdk-schema" }futures-timer.workspace = true+petname = { version = "2", default-features = false, features = [+ "default-rng",+ "default-words",+] }serde.workspace = trueserde_json.workspace = truethiserror.workspace = true@@ -25,6 +29,7 @@ reqwest.workspace = truetokio = { workspace = true, features = ["rt-multi-thread"] }[target.'cfg(target_arch = "wasm32")'.dependencies]+getrandom = { version = "0.2", features = ["js"] }gloo-timers = { version = "0.3", features = ["futures"] }js-sys = "0.3"wasm-bindgen = "0.2"diff --git a/libs/fleet/sdk/src/claims.rs b/libs/fleet/sdk/src/claims.rsindex e3a02814da..c87da704fe 100644--- a/libs/fleet/sdk/src/claims.rs+++ b/libs/fleet/sdk/src/claims.rs@@ -57,7 +57,7 @@ impl CyclopsClient {kind: "OSGymSandboxClaim".into(),metadata: ResourceMetadata {namespace: pool.metadata.namespace.clone(),- name: claim_name(self.next_claim_sequence()?),+ name: claim_name()?,labels: None,},spec,@@ -184,8 +184,15 @@ impl CyclopsClient {}}-fn claim_name(sequence: u64) -> String {- format!("claim-{sequence}")+// Random petnames instead of a sequence: a per-client counter restarts at 1+// for every fresh client, so retries and concurrent leases all proposed+// claim-1 and collided with whatever the previous lease still held.+fn claim_name() -> Result<String, SdkError> {+ petname::petname(2, "-")+ .map(|name| format!("claim-{name}"))+ .ok_or_else(|| SdkError::Configuration {+ reason: "claim name generation returned no words".into(),+ })}fn service_names(template: &Template) -> Vec<String> {diff --git a/libs/fleet/sdk/src/client.rs b/libs/fleet/sdk/src/client.rsindex c51d0b952d..d303218bf0 100644--- a/libs/fleet/sdk/src/client.rs+++ b/libs/fleet/sdk/src/client.rs@@ -5,10 +5,7 @@ use crate::{};use std::{collections::HashMap,- sync::{- Arc, Mutex, Weak,- atomic::{AtomicU64, Ordering},- },+ sync::{Arc, Mutex, Weak},};use tokio::sync::Mutex as AsyncMutex;#[cfg(not(target_arch = "wasm32"))]@@ -18,7 +15,6 @@ use url::Url;#[derive(uniffi::Object)]pub struct CyclopsClient {base_url: Url,- claim_sequence: AtomicU64,claim_poll_interval_ms: u64,claim_poll_limit: u32,lifecycle_locks: Arc<NamespaceLifecycleLocks>,@@ -56,7 +52,6 @@ impl CyclopsClient {Ok(Arc::new(Self {base_url,- claim_sequence: AtomicU64::new(0),claim_poll_interval_ms: configuration.claim_poll_interval_ms,claim_poll_limit: configuration.claim_poll_limit,lifecycle_locks: Arc::new(NamespaceLifecycleLocks {@@ -103,7 +98,6 @@ impl CyclopsClient {Ok(Arc::new(Self {base_url,- claim_sequence: AtomicU64::new(0),claim_poll_interval_ms: configuration.claim_poll_interval_ms,claim_poll_limit: configuration.claim_poll_limit,lifecycle_locks: Arc::new(NamespaceLifecycleLocks {@@ -129,7 +123,6 @@ impl CyclopsClient {Ok(Arc::new(Self {base_url,- claim_sequence: AtomicU64::new(0),claim_poll_interval_ms: configuration.claim_poll_interval_ms,claim_poll_limit: configuration.claim_poll_limit,lifecycle_locks: Arc::new(NamespaceLifecycleLocks {@@ -209,17 +202,6 @@ impl CyclopsClient {&self.base_url}- pub(crate) fn next_claim_sequence(&self) -> Result<u64, SdkError> {- self.claim_sequence- .fetch_update(Ordering::Relaxed, Ordering::Relaxed, |current| {- current.checked_add(1)- })- .map(|previous| previous + 1)- .map_err(|_| SdkError::Configuration {- reason: "claim name sequence is exhausted".into(),- })- }-pub(crate) fn claim_poll_interval_ms(&self) -> u64 {self.claim_poll_interval_ms}diff --git a/libs/fleet/sdk/tests/claim_flow.rs b/libs/fleet/sdk/tests/claim_flow.rsindex cbecf58a9b..96c4f0621c 100644--- a/libs/fleet/sdk/tests/claim_flow.rs+++ b/libs/fleet/sdk/tests/claim_flow.rs@@ -32,7 +32,7 @@ async fn creates_pending_demand_immediately_for_a_nonzero_unavailable_pool() {client(Arc::clone(&http), 2, 2).create_claim(CreateClaimRequest {pool: unavailable_pool,- spec: Some(spec),+ spec: Some(spec.clone()),}).await.unwrap(),@@ -41,16 +41,11 @@ async fn creates_pending_demand_immediately_for_a_nonzero_unavailable_pool() {let requests = http.authenticated_requests().await;assert_eq!(requests.len(), 1);- assert_request(- &requests[0],- "POST",- CLAIM_COLLECTION,- Some(&json_bytes(&created)),- );+ assert_claim_post(&requests[0], &spec);}#[tokio::test]-async fn zero_and_nonzero_pools_post_claims_with_identical_sequencing() {+async fn zero_and_nonzero_pools_post_a_single_claim_create() {for replicas in [0, 1] {let expected = claim("claim-1", claim_spec("example-pool-template"), None);let http = Arc::new(ScriptedHttpClient::new([@@ -68,12 +63,7 @@ async fn zero_and_nonzero_pools_post_claims_with_identical_sequencing() {let requests = http.authenticated_requests().await;assert_eq!(requests.len(), 1, "replicas={replicas}");- assert_request(- &requests[0],- "POST",- CLAIM_COLLECTION,- Some(&json_bytes(&expected)),- );+ assert_claim_post(&requests[0], &claim_spec("example-pool-template"));}}#[tokio::test]@@ -371,6 +361,26 @@ fn response(status: u16, body: &[u8]) -> HttpResponse {body: body.to_vec(),}}+fn assert_claim_post(request: &cyclops_sdk::HttpRequest, spec: &ClaimSpec) {+ assert_eq!(request.method, "POST");+ assert_eq!(request.url, CLAIM_COLLECTION);+ let body: Claim = serde_json::from_slice(request.body.as_deref().unwrap()).unwrap();+ assert_eq!(body.api_version, "osgym.cua.ai/v1alpha1");+ assert_eq!(body.kind, "OSGymSandboxClaim");+ assert_eq!(body.metadata.namespace, NAMESPACE);+ assert_eq!(+ serde_json::to_value(&body.spec).unwrap(),+ serde_json::to_value(spec).unwrap()+ );+ let name = &body.metadata.name;+ assert!(name.starts_with("claim-"), "unexpected claim name {name:?}");+ assert!(name.len() <= 63);+ assert!(+ name.bytes()+ .all(|byte| byte.is_ascii_lowercase() || byte.is_ascii_digit() || byte == b'-')+ );+}+fn assert_request(request: &cyclops_sdk::HttpRequest,method: &str,