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
feat(telemetry): report which step a Space start failed at (CUA-3139) (#6377)
Francesco Bonacci4d985c120924
diff --git a/docs/content/docs/cua-sdk/concepts/telemetry-error-kinds.mdx b/docs/content/docs/cua-sdk/concepts/telemetry-error-kinds.mdxindex 2a6572bcf7..487a1669a6 100644--- a/docs/content/docs/cua-sdk/concepts/telemetry-error-kinds.mdx+++ b/docs/content/docs/cua-sdk/concepts/telemetry-error-kinds.mdx@@ -49,6 +49,35 @@ say.| `local_network_vpn` | A VPN routes the VM's private network away. || `capacity_vms` | `host_capacity`: this machine had no room and Cua VMs it runs hold the capacity (the error names them so the person can stop them). A VM left running by an earlier failed attempt shows up here. || `capacity_other` | `host_capacity`: this machine had no room while no Cua VM runs there; other programs use its memory or CPUs, or its limits are too tight. |+| `runtime_install_failed` | The built-in runtime (Lume) could not be set up: its download, checksum or unpacking failed. |+| `runtime_not_signed` | The built-in runtime's signature did not verify. |+| `runtime_unresponsive` | The runtime's service started and never answered. |+| `runtime_too_old` | This Mac's own Lume is older than macOS Spaces need. |+| `runtime_api_error` | The runtime's API answered with an error, or not at all. |+| `vm_never_started` | The VM was created and never started, stopped while booting, or vanished while booting. |+| `vm_config_invalid` | The VM's configuration was refused. |+| `host_command_failed` | A host command the create ran (`lume`, `codesign`) exited with an error. |++## Failed step++`cua_space_create` also sets `failed_step`, the step inside `failed_phase` a+failure stopped at. It is worked out on your device from the fixed words+above (the phase, `error_kind` and `error_subclass`), never from the error+text. It is `none` when the create worked or was cancelled.++| `failed_step` | Step |+|---|---|+| `check_host` | The checks before anything starts (this Mac can't run VMs, Local Network, disk). |+| `start_runtime` | The local runtime: Lume, the container engine, the built-in Linux runtime. |+| `reach_daemon` | Cua's background service took no create. |+| `resolve_image` | Finding the image. |+| `pull_image` | Downloading the image. |+| `clone_disk` | Preparing a VM's disk. |+| `create_container` | Creating a container. |+| `configure_vm` | The Space's settings were refused. |+| `start_vm` | Booting the VM or container. |+| `connect_services` | Reaching the Space's own services once it booted. |+| `unknown` | Nothing narrows the phase down; these are what still need a name. |## Automatic retrydiff --git a/docs/content/docs/cua-sdk/concepts/telemetry-events.mdx b/docs/content/docs/cua-sdk/concepts/telemetry-events.mdxindex 62fd5cc7c9..718ccb5eb6 100644--- a/docs/content/docs/cua-sdk/concepts/telemetry-events.mdx+++ b/docs/content/docs/cua-sdk/concepts/telemetry-events.mdx@@ -50,7 +50,7 @@ Every event carries: `telemetry_schema_version`, `event_version`, `product`| `cua_onboarding_skipped` | `step`, `step_index`, `onboarding_version`, `how` (`step`: that screen's own Skip or Not now; `later`: Skip for now, which leaves the whole first run) | Which screens people skip, and where they leave the first run. || `cua_space_wizard` | `action` (`opened`, `cancelled`, `submitted`) | How often a New Space is started and abandoned. || `cua_space_create_started` | `location`, `guest_os`, `kind`, `gpu` (GPU acceleration turned on) | Which Spaces are started, and how often with GPU acceleration. |-| `cua_space_create` | `location`, `guest_os`, `kind`, `outcome` (`ok`, `error`, or `cancelled` when Cancel was pressed while it was being created), `error_kind` ([kinds](/cua-sdk/concepts/telemetry-error-kinds)), `failed_phase` (the phase it failed or was cancelled in, or `none`), `stalled`, `time_bucket` (to ready, the failure, or cancel finishing), `gpu`, `retry_attempt` (`1` when the app ran the create a second time by itself after a passing failure, else `0`), `error_subclass` ([finer causes](/cua-sdk/concepts/telemetry-error-kinds#finer-causes), or `none`) | Space create success, failure and cancel rates, time to ready, which phase fails, and how often one automatic retry saves a create. Sent once per create, for its final outcome, so a retried create still counts once. |+| `cua_space_create` | `location`, `guest_os`, `kind`, `outcome` (`ok`, `error`, or `cancelled` when Cancel was pressed while it was being created), `error_kind` ([kinds](/cua-sdk/concepts/telemetry-error-kinds)), `failed_phase` (the phase it failed or was cancelled in, or `none`), `failed_step` ([the step inside it](/cua-sdk/concepts/telemetry-error-kinds#failed-step), or `none`), `stalled`, `time_bucket` (to ready, the failure, or cancel finishing), `gpu`, `retry_attempt` (`1` when the app ran the create a second time by itself after a passing failure, else `0`), `error_subclass` ([finer causes](/cua-sdk/concepts/telemetry-error-kinds#finer-causes), or `none`) | Space create success, failure and cancel rates, time to ready, which phase fails, and how often one automatic retry saves a create. Sent once per create, for its final outcome, so a retried create still counts once. || `cua_volume_setup` | `surface` (`onboarding` or `settings`), `storage` (`this_mac`, `s3`, `later`), `add_to_finder`, `mount_method` (`fskit`, `nfs`, `fuse`, `none`, `unknown`), `outcome` | Cua Volume adoption. || `cua_persistent_agent` | `action` (`create`, `pause`, `resume`, `routine_add`, ...), `harness`, `outcome`, `error_kind` | Persistent agents and routines adoption. || `cua_host_setup` | `mode` (`relay` or `direct`), `profile` (`desktop`, `spare`, `both`), `outcome`, `error_kind`, `signed_in`, `token_state` (`provided`, `expired`, `missing`, `not_needed`; never the token), `failed_stage` (`none`, `preflight`, `token`, `register`, `download`, `service`), `http_status` (the status a server answered a failure with, `0` when none) | Machines set up for access, and where a failed setup stopped. |diff --git a/libs/cua/crates/cua-create-failure/src/retry.rs b/libs/cua/crates/cua-create-failure/src/retry.rsindex b5ed00c0ae..0212648e60 100644--- a/libs/cua/crates/cua-create-failure/src/retry.rs+++ b/libs/cua/crates/cua-create-failure/src/retry.rs@@ -47,6 +47,26 @@ pub enum Subclass {/// This machine had no room while no Cua VM runs: other programs use/// its memory or CPUs, or its limits are set too tight.CapacityOther,+ /// The built-in runtime (Lume) could not be set up: its download, its+ /// checksum or unpacking failed. A new, never-retried cause: until its+ /// rate is known a retry only repeats the download.+ RuntimeInstallFailed,+ /// The built-in runtime's signature did not verify.+ RuntimeNotSigned,+ /// `lume serve` started and never answered.+ RuntimeUnresponsive,+ /// This Mac's own Lume is older than macOS Spaces need.+ RuntimeTooOld,+ /// The runtime's API answered with an error (or not at all) outside a+ /// download.+ RuntimeApiError,+ /// A VM was created and never started, stopped while booting, or+ /// vanished while booting.+ VmNeverStarted,+ /// The VM's configuration was refused (`invalid request: ...`).+ VmConfigInvalid,+ /// A host command (`lume`, `codesign`, ...) exited with an error.+ HostCommandFailed,}/// Every [`Subclass`] word, in order (`cua_telemetry::schema::ERROR_SUBCLASSES`).@@ -59,6 +79,14 @@ pub const SUBCLASSES: &[&str] = &["local_network_vpn","capacity_vms","capacity_other",+ "runtime_install_failed",+ "runtime_not_signed",+ "runtime_unresponsive",+ "runtime_too_old",+ "runtime_api_error",+ "vm_never_started",+ "vm_config_invalid",+ "host_command_failed",];impl Subclass {@@ -73,6 +101,14 @@ impl Subclass {Self::LocalNetworkVpn => "local_network_vpn",Self::CapacityVms => "capacity_vms",Self::CapacityOther => "capacity_other",+ Self::RuntimeInstallFailed => "runtime_install_failed",+ Self::RuntimeNotSigned => "runtime_not_signed",+ Self::RuntimeUnresponsive => "runtime_unresponsive",+ Self::RuntimeTooOld => "runtime_too_old",+ Self::RuntimeApiError => "runtime_api_error",+ Self::VmNeverStarted => "vm_never_started",+ Self::VmConfigInvalid => "vm_config_invalid",+ Self::HostCommandFailed => "host_command_failed",}}@@ -86,6 +122,14 @@ impl Subclass {"local_network_vpn" => Self::LocalNetworkVpn,"capacity_vms" => Self::CapacityVms,"capacity_other" => Self::CapacityOther,+ "runtime_install_failed" => Self::RuntimeInstallFailed,+ "runtime_not_signed" => Self::RuntimeNotSigned,+ "runtime_unresponsive" => Self::RuntimeUnresponsive,+ "runtime_too_old" => Self::RuntimeTooOld,+ "runtime_api_error" => Self::RuntimeApiError,+ "vm_never_started" => Self::VmNeverStarted,+ "vm_config_invalid" => Self::VmConfigInvalid,+ "host_command_failed" => Self::HostCommandFailed,_ => Self::None,}}@@ -184,6 +228,38 @@ pub fn subclass(kind: &str, message: &str) -> Subclass {]) {return Subclass::RuntimeStart;}+ // Causes that used to land in a bare `runtime`: the fixed sentences of+ // `cua_vmm::VmmError` and the built-in runtime's setup (the typed error+ // crosses the daemon and the SDK as its text, so this reads those+ // sentences, never free text, and only a word comes out).+ if has(&["is not validly signed", "is not signed by cua ai"]) {+ return Subclass::RuntimeNotSigned;+ }+ if has(&[+ "download the built-in lume",+ "built-in lume download",+ "the built-in lume did not install",+ ]) {+ return Subclass::RuntimeInstallFailed;+ }+ if has(&["started `lume serve` but"]) {+ return Subclass::RuntimeUnresponsive;+ }+ if has(&["macos spaces need lume", "older than the"]) && has(&["lume"]) {+ return Subclass::RuntimeTooOld;+ }+ if has(&["while booting", "never started ("]) && has(&["lume vm '"]) {+ return Subclass::VmNeverStarted;+ }+ if has(&["invalid request: "]) {+ return Subclass::VmConfigInvalid;+ }+ if has(&["lume api ", "lume request failed", "lume get "]) {+ return Subclass::RuntimeApiError;+ }+ if has(&["` failed (exit "]) {+ return Subclass::HostCommandFailed;+ }Subclass::None}@@ -403,6 +479,65 @@ mod tests {assert_eq!(subclass("local_network", "whatever"), Subclass::None);}+ #[test]+ fn unexplained_runtime_failures_get_a_subclass() {+ let cases = [+ (+ "the built-in Lume is not validly signed: `codesign` failed",+ Subclass::RuntimeNotSigned,+ ),+ (+ "the built-in Lume is not signed by Cua AI, Inc.",+ Subclass::RuntimeNotSigned,+ ),+ (+ "download the built-in Lume: error sending request",+ Subclass::RuntimeInstallFailed,+ ),+ (+ "the built-in Lume download did not match its checksum (got ab); try again",+ Subclass::RuntimeInstallFailed,+ ),+ (+ "started `lume serve` but http://127.0.0.1:7777 did not answer within 30s (see x)",+ Subclass::RuntimeUnresponsive,+ ),+ (+ "lume serve at http://x is Lume 0.1, and macOS Spaces need Lume 0.3 or newer",+ Subclass::RuntimeTooOld,+ ),+ (+ "lume VM 'a' never started (90s after `lume run`)",+ Subclass::VmNeverStarted,+ ),+ (+ "lume VM 'a' stopped while booting",+ Subclass::VmNeverStarted,+ ),+ ("invalid request: bad name", Subclass::VmConfigInvalid),+ ("lume API 500: boom", Subclass::RuntimeApiError),+ (+ "lume request failed: connection closed",+ Subclass::RuntimeApiError,+ ),+ (+ "`lume` failed (exit Some(1)): stderr",+ Subclass::HostCommandFailed,+ ),+ ];+ for (msg, want) in cases {+ let (kind, sub, retry) = classify(msg, "preparing", "Runtime");+ assert_eq!(sub, want, "{msg} ({kind})");+ // Not known to pass: no automatic retry.+ assert_eq!(retry, Retry::Never, "{msg}");+ }+ // A lasting cause keeps its kind and gets no subclass.+ assert_eq!(+ classify("permission denied: lume API 500", "preparing", "Runtime").1,+ Subclass::None+ );+ }+#[test]fn enum_cases_are_read_in_snake_case() {assert_eq!(snake("InsufficientDisk"), "insufficient_disk");diff --git a/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs b/libs/cua/crates/cua-spaces-app-core/src/telemetry.rsindex 90cc1a358f..1e4b929db2 100644--- a/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs+++ b/libs/cua/crates/cua-spaces-app-core/src/telemetry.rs@@ -1810,6 +1810,83 @@ mod tests {}}+ /// A Mac that can't run virtual machines is refused by the daemon's+ /// preflight with a plain sentence (`MAC_UNSUPPORTED`, or the built-in+ /// runtime's identical one). That ends a create like any failure, so it+ /// counts: `cua_space_create` with outcome `error`, `error_kind`+ /// `virtualization_unavailable`, failed_step `check_host`, sent at once+ /// (a lasting cause is never retried), and through the usage-data switch.+ #[cfg(feature = "telemetry")]+ #[test]+ fn a_mac_that_cannot_run_vms_sends_virtualization_unavailable() {+ use crate::spaces::creating::reduce;+ for (os, kind) in [+ (SpaceOs::Macos, SpaceKind::Vm),+ (SpaceOs::Linux, SpaceKind::Container),+ ] {+ let mut st = reduce(+ &CreatesState::default(),+ &CreateAction::Start {+ id: "pending:a".into(),+ name: "my-private-space".into(),+ os,+ provider: SpaceProvider::Local,+ now: 1_000,+ image: None,+ kind: Some(kind),+ host_arch: None,+ gpu: false,+ host: None,+ host_name: None,+ },+ );+ st.pending[0].phase = "preparing".into();+ let signals = creates(+ &st,+ &CreateAction::Fail {+ id: "pending:a".into(),+ error: format!(+ "local runtime: {}",+ cua_create_failure::preflight::MAC_UNSUPPORTED+ ),+ error_variant: "Runtime".into(),+ now: Some(2_000),+ },+ 2_000,+ );+ assert_eq!(signals.len(), 1, "sent at once, not retried");+ let home = tempfile::tempdir().unwrap();+ let sink = std::sync::Arc::new(cua_telemetry::sink::MemorySink::new());+ let t = cua_telemetry::Telemetry::builder()+ .env(|k| match k {+ "CUA_TELEMETRY_FORBID_NETWORK" => Some("1".into()),+ _ => None,+ })+ .home(home.path())+ .sink(sink.clone())+ .product("spaces_app", "0.2.0")+ .foreground()+ .build();+ t.acknowledge_notice();+ assert_eq!(record(&t, &signals), 1);+ t.flush(std::time::Duration::from_secs(2));+ let events = sink.events();+ let create = events+ .iter()+ .find(|e| e["event"] == "cua_space_create")+ .expect("cua_space_create was sent");+ let props = &create["properties"];+ assert_eq!(props["outcome"], "error");+ assert_eq!(props["error_kind"], "virtualization_unavailable");+ assert_eq!(props["failed_phase"], "preparing");+ assert_eq!(props["failed_step"], "check_host");+ assert_eq!(props["error_subclass"], "none");+ // Fixed words only.+ let text = serde_json::to_string(&events).unwrap().to_lowercase();+ assert!(!text.contains("private") && !text.contains("virtual machine"));+ }+ }+#[test]fn a_retried_create_counts_once_with_its_final_outcome() {use crate::spaces::creating::reduce;diff --git a/libs/cua/crates/cua-telemetry/src/events.rs b/libs/cua/crates/cua-telemetry/src/events.rsindex 296b694f76..2faf9621b8 100644--- a/libs/cua/crates/cua-telemetry/src/events.rs+++ b/libs/cua/crates/cua-telemetry/src/events.rs@@ -1076,6 +1076,62 @@ pub struct SpaceCreate<'a> {pub error_subclass: &'a str,}+/// The step a failed create stopped at (`schema::FAILED_STEPS`), read from+/// the failure's fixed words only: the specific cause (`error_subclass`,+/// `error_kind`) first, since it names the step, then the phase. `unknown`+/// when nothing narrows the phase down (a failure in `preparing` that no+/// word explains), so reports can rank what still needs a name.+pub fn failed_step(+ phase: &str,+ kind: &str,+ subclass: &str,+ guest_os: &str,+ create_kind: &str,+) -> &'static str {+ // A download that failed stays a download, whatever the runtime said.+ if kind.starts_with("image_pull") {+ return "pull_image";+ }+ // The cause's own step, where one word names it.+ let by_cause = match subclass {+ "runtime_start"+ | "runtime_install_failed"+ | "runtime_not_signed"+ | "runtime_unresponsive"+ | "runtime_too_old"+ | "runtime_api_error" => Some("start_runtime"),+ "daemon_unresponsive" => Some("reach_daemon"),+ "pull_interrupted" => Some("pull_image"),+ "vm_never_started" => Some("start_vm"),+ "vm_config_invalid" => Some("configure_vm"),+ _ => match kind {+ "runtime_missing" | "runtime_not_running" | "runtime_permission" => {+ Some("start_runtime")+ }+ "virtualization_unavailable" | "host_capacity" => Some("check_host"),+ // The checks before anything starts refuse these in `preparing`.+ "local_network" | "insufficient_disk" if phase == "preparing" => Some("check_host"),+ "vm_boot_timeout" => Some("start_vm"),+ "services_unreachable" | "env" => Some("connect_services"),+ "invalid_argument" | "invalid_placement" | "unsupported" => Some("configure_vm"),+ "not_found" => Some("resolve_image"),+ _ => None,+ },+ };+ if let Some(step) = by_cause {+ return step;+ }+ let vm = create_kind == "vm" || matches!(guest_os, "macos" | "windows");+ match phase {+ "pulling" => "pull_image",+ "creating" if vm => "clone_disk",+ "creating" => "create_container",+ "booting" => "start_vm",+ "waiting_for_services" | "connecting" => "connect_services",+ _ => "unknown",+ }+}+/// `cua_space_create`.pub fn space_create(s: &SpaceCreate<'_>, outcome: Outcome, elapsed: Duration) -> Event {let failed_phase = match outcome {@@ -1099,24 +1155,29 @@ pub fn space_create(s: &SpaceCreate<'_>, outcome: Outcome, elapsed: Duration) ->},_ => "none",};+ let error_subclass = match outcome {+ Outcome::Cancelled => "none",+ _ => pick(schema::ERROR_SUBCLASSES, s.error_subclass, "none"),+ };+ let guest = guest_os(s.guest_os);+ let create_kind = sandbox_kind(s.kind);+ let step = match outcome {+ Outcome::Error => failed_step(failed_phase, error_kind, error_subclass, guest, create_kind),+ _ => "none",+ };Event::new(event::SPACE_CREATE).s("location", location(s.on))- .s("guest_os", guest_os(s.guest_os))- .s("kind", sandbox_kind(s.kind))+ .s("guest_os", guest)+ .s("kind", create_kind).s("outcome", outcome.as_str()).s("error_kind", error_kind).s("failed_phase", failed_phase)+ .s("failed_step", step).b("stalled", s.stalled && outcome == Outcome::Error).s("time_bucket", create_time_bucket(elapsed)).b("gpu", s.gpu).n("retry_attempt", u64::from(s.retry_attempt.min(1)))- .s(- "error_subclass",- match outcome {- Outcome::Cancelled => "none",- _ => pick(schema::ERROR_SUBCLASSES, s.error_subclass, "none"),- },- )+ .s("error_subclass", error_subclass)}/// `cua_space_create_started`.diff --git a/libs/cua/crates/cua-telemetry/src/schema.rs b/libs/cua/crates/cua-telemetry/src/schema.rsindex 668247fb50..f21aacc3ba 100644--- a/libs/cua/crates/cua-telemetry/src/schema.rs+++ b/libs/cua/crates/cua-telemetry/src/schema.rs@@ -520,6 +520,41 @@ pub const ERROR_SUBCLASSES: &[&str] = &["local_network_vpn","capacity_vms","capacity_other",+ // The built-in runtime (Lume) or a VM, split by what failed: its+ // download, checksum or unpacking; its signature; a `lume serve` that+ // started and never answered; one older than macOS Spaces need; an+ // error answer from its API; a VM that never started or stopped while+ // booting; a request the VM configuration refused; a host command+ // (`codesign`, `lume`) that exited with an error.+ "runtime_install_failed",+ "runtime_not_signed",+ "runtime_unresponsive",+ "runtime_too_old",+ "runtime_api_error",+ "vm_never_started",+ "vm_config_invalid",+ "host_command_failed",+];+/// The step inside the create phase a failed create stopped at, derived on+/// device from the failure's fixed words (phase, `error_kind`,+/// `error_subclass`), never from text: the machine's checks before anything+/// starts, the local runtime, Cua's background service, the image lookup,+/// its download, the VM disk, the container, the VM or container settings,+/// the VM boot, the connection to the Space's services. `unknown` when+/// nothing narrows the phase down; `none` when the create did not fail.+pub const FAILED_STEPS: &[&str] = &[+ "none",+ "check_host",+ "start_runtime",+ "reach_daemon",+ "resolve_image",+ "pull_image",+ "clone_disk",+ "create_container",+ "configure_vm",+ "start_vm",+ "connect_services",+ "unknown",];/// Time from create to ready (or to the failure), bucketed finely enough/// for median and p90 estimates.@@ -1886,7 +1921,7 @@ pub const EVENTS: &[EventSpec] = &[},EventSpec {name: event::SPACE_CREATE,- version: 4,+ version: 5,tier: Tier::Usage,sample_rate: 1.0,products: &["spaces_app"],@@ -1901,6 +1936,11 @@ pub const EVENTS: &[EventSpec] = &[Kind::Enum(CREATE_PHASES),"The create phase it failed or was cancelled in (pulling, booting, ...); none when it succeeded.",),+ p(+ "failed_step",+ Kind::Enum(FAILED_STEPS),+ "The step inside that phase a failure stopped at (start_runtime, clone_disk, start_vm, connect_services, ...), from the failure's fixed words; unknown when nothing narrows it down; none when it succeeded or was cancelled.",+ ),p("stalled",Kind::Bool,@@ -1920,7 +1960,7 @@ pub const EVENTS: &[EventSpec] = &[p("error_subclass",Kind::Enum(ERROR_SUBCLASSES),- "The finer cause of the failure (runtime_start, daemon_unresponsive, pull_interrupted, local_network_denied, local_network_vpn, capacity_vms, capacity_other); on a retried create that succeeded, the cause of the failure it recovered from; none otherwise. Never the message.",+ "The finer cause of the failure (runtime_start, daemon_unresponsive, pull_interrupted, runtime_install_failed, vm_never_started, local_network_denied, capacity_vms, ...); on a retried create that succeeded, the cause of the failure it recovered from; none otherwise. Never the message.",),],purpose: "Activation and reliability: Space create success, failure and cancel rates by kind, location and GPU, time to ready or to cancel, which phase fails or is cancelled, stall timeouts, and how often one automatic retry saves a create.",diff --git a/libs/cua/crates/cua-telemetry/tests/privacy.rs b/libs/cua/crates/cua-telemetry/tests/privacy.rsindex b7bd6dcde0..f64172f24e 100644--- a/libs/cua/crates/cua-telemetry/tests/privacy.rs+++ b/libs/cua/crates/cua-telemetry/tests/privacy.rs@@ -1044,6 +1044,155 @@ fn a_switch_flipped_elsewhere_applies_after_refresh_and_clears_the_spool() {/// The "Telemetry and privacy" pages list every event and every property/// the schema declares, so nothing is sent that the docs do not name.+/// `failed_step` is derived from the failure's fixed words, never text; it+/// is always a word of the schema, and `none` unless the create failed.+#[test]+fn space_create_failed_step_keeps_its_vocabulary() {+ let create = |outcome, phase, variant, error_subclass, guest_os, kind| {+ events::space_create(+ &events::SpaceCreate {+ on: "local",+ guest_os,+ kind,+ last_phase: phase,+ stalled: false,+ gpu: false,+ error_variant: variant,+ retry_attempt: 0,+ error_subclass,+ },+ outcome,+ Duration::from_secs(30),+ )+ };+ let step = |e: &events::Event| e.props["failed_step"].clone();+ let err = Outcome::Error;+ // A cause names its step, whatever the phase.+ assert_eq!(+ step(&create(+ err,+ "preparing",+ "runtime",+ "runtime_not_signed",+ "macos",+ "vm"+ )),+ "start_runtime"+ );+ assert_eq!(+ step(&create(+ err,+ "preparing",+ "virtualization_unavailable",+ "",+ "macos",+ "vm"+ )),+ "check_host"+ );+ assert_eq!(+ step(&create(err, "preparing", "Env", "", "linux", "vm")),+ "connect_services"+ );+ assert_eq!(+ step(&create(+ err,+ "booting",+ "runtime",+ "vm_never_started",+ "macos",+ "vm"+ )),+ "start_vm"+ );+ assert_eq!(+ step(&create(+ err,+ "pulling",+ "runtime",+ "runtime_api_error",+ "macos",+ "vm"+ )),+ "start_runtime"+ );+ assert_eq!(+ step(&create(+ err,+ "pulling",+ "ImagePullNetwork",+ "runtime_api_error",+ "macos",+ "vm"+ )),+ "pull_image"+ );+ // Else the phase; `unknown` when it was `preparing` and no word helps.+ assert_eq!(+ step(&create(err, "creating", "runtime", "", "macos", "vm")),+ "clone_disk"+ );+ assert_eq!(+ step(&create(+ err,+ "creating",+ "runtime",+ "",+ "linux",+ "container"+ )),+ "create_container"+ );+ assert_eq!(+ step(&create(+ err,+ "waiting_for_services",+ "runtime",+ "",+ "linux",+ "vm"+ )),+ "connect_services"+ );+ assert_eq!(+ step(&create(err, "preparing", "runtime", "", "macos", "vm")),+ "unknown"+ );+ // Not a failure: none. Never free text.+ assert_eq!(+ step(&create(Outcome::Ok, "preparing", "", "", "macos", "vm")),+ "none"+ );+ assert_eq!(+ step(&create(+ Outcome::Cancelled,+ "booting",+ "",+ "",+ "macos",+ "vm"+ )),+ "none"+ );+ // Every step and subclass word the schema allows is sent as itself.+ for w in cua_telemetry::schema::ERROR_SUBCLASSES {+ let e = create(err, "preparing", "runtime", w, "macos", "vm");+ assert_eq!(e.props["error_subclass"], *w);+ assert!(cua_telemetry::schema::FAILED_STEPS.contains(&step(&e).as_str().unwrap()));+ }+ let e = create(+ err,+ "preparing",+ "runtime",+ "/Users/maya/.lume",+ "macos",+ "vm",+ );+ assert_eq!(step(&e), "unknown");+ let home = tempfile::tempdir().unwrap();+ preview_all(home.path(), &e);+}+#[test]fn space_create_retry_fields_keep_their_vocabulary() {let create = |outcome, retry_attempt, error_subclass| {diff --git a/libs/cua/crates/cua-vmm/src/error.rs b/libs/cua/crates/cua-vmm/src/error.rsindex 72e42495f6..76ab2fd30d 100644--- a/libs/cua/crates/cua-vmm/src/error.rs+++ b/libs/cua/crates/cua-vmm/src/error.rs@@ -189,4 +189,48 @@ mod tests {let lan = VmmError::missing("Local Network access", "click Allow");assert_eq!(failure_kind(&lan.to_string()), None);}++ /// The create-failure subclass each error the macOS and Linux VM start+ /// path raises gets (`cua_create_failure::retry::subclass`), built from+ /// the typed errors so a reworded message fails here.+ #[test]+ fn typed_errors_get_a_fixed_subclass_word() {+ use cua_create_failure::retry::{Subclass, subclass};+ let word = |e: VmmError| subclass("runtime", &format!("local runtime: {e}"));+ assert_eq!(+ word(VmmError::Lume {+ status: 500,+ message: "boom".into()+ }),+ Subclass::RuntimeApiError+ );+ assert_eq!(+ word(VmmError::Command {+ cmd: "lume".into(),+ code: Some(1),+ stderr: "x".into()+ }),+ Subclass::HostCommandFailed+ );+ assert_eq!(+ word(VmmError::invalid("bad name")),+ Subclass::VmConfigInvalid+ );+ assert_eq!(+ word(VmmError::other(+ "lume VM 'a' stopped while booting (it exited)"+ )),+ Subclass::VmNeverStarted+ );+ assert_eq!(+ word(VmmError::other(+ "the built-in Lume is not validly signed: boom"+ )),+ Subclass::RuntimeNotSigned+ );+ assert_eq!(+ word(VmmError::other("download the built-in Lume: boom")),+ Subclass::RuntimeInstallFailed+ );+ }}