astrid-runtime/astrid · error

durable capsule removal is unavailable on portable hosts

Error message

durable capsule removal is unavailable on portable hosts

What it means

The WASM (`target_family = "wasm"`) stub of `remove_one_capsule` unconditionally returns this error. Durable capsule removal requires native filesystem-backed storage, which is not available on portable (WASM) hosts, so the operation is compiled out and always fails with this message.

Source

Thrown at crates/astrid-kernel/src/lib.rs:3296

        if !removed {
            // A concurrent administrative writer won the generation race. The
            // durable package is still authoritative; restore the just-closed
            // runtime view before surfacing the conflict.
            self.ensure_principal_loaded(principal).await;
            return Err(anyhow::anyhow!(
                "durable capsule package '{id}' disappeared during removal"
            ));
        }
        Ok(true)
    }

    #[cfg(target_family = "wasm")]
    pub(crate) async fn remove_one_capsule(
        &self,
        _id: &astrid_capsule_types::CapsuleId,
        _principal: &PrincipalId,
    ) -> Result<bool, anyhow::Error> {
        Err(anyhow::anyhow!(
            "durable capsule removal is unavailable on portable hosts"
        ))
    }

    /// Remove every capsule view owned by `principal` before that principal's
    /// persistent state is reclaimed.
    ///
    /// The load lock closes the race with background warm/install discovery:
    /// once the profile/identity fence has closed new authorization, no loader
    /// can re-attach a view between the snapshot and the last unload. Each
    /// release uses [`Self::unload_one_capsule`]. Principal runtimes are always
    /// removed; dependent `SystemResident` views survive only while their
    /// explicit owner remains installed.
    pub(crate) async fn unload_principal_capsules(
        &self,
        principal: &PrincipalId,
    ) -> Result<Vec<astrid_capsule_types::CapsuleId>, anyhow::Error> {
        let mut ids: Vec<_> = {

View on GitHub (pinned to affd8760f4)

Solutions

  1. Compile for a native target if durable removal is required.
  2. On WASM, gate removal features out of the UI/API and surface 'not supported on this platform' to users.
  3. Use an alternative removal mechanism provided by the host environment, or only unload in-memory on portable hosts.

Example fix

// before
kernel.remove_one_capsule(&id, &principal).await?;
// after
#[cfg(target_family = "wasm")]
anyhow::bail!("capsule removal is not supported on portable hosts");
#[cfg(not(target_family = "wasm"))]
kernel.remove_one_capsule(&id, &principal).await?;
Defensive patterns

Strategy: validation

Validate before calling

#[cfg(target_family = "wasm")]
fn durable_removal_supported() -> bool { false }
#[cfg(not(target_family = "wasm"))]
fn durable_removal_supported() -> bool { true }

Type guard

fn supports_durable_removal() -> bool {
    cfg!(not(target_family = "wasm"))
}

Try / catch

if cfg!(target_family = "wasm") {
    return Err(anyhow!("capsule removal is not available on portable hosts"));
}
kernel.remove_one_capsule(&id, &principal).await?;

Prevention

When it happens

Trigger: Any call to `remove_one_capsule` when the kernel is compiled for a WASM target (browser, in-process sandbox, portable runtime) — there is no code path that can succeed.

Common situations: Running the kernel embedded in a browser or WASM sandbox and attempting capsule uninstall/management; reusing native admin code unmodified on a portable host.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/6ce17210853341ec. Report an issue: GitHub.