cellos-host-stub 0.5.1

Stub backend for CellOS — in-process test double for the CellBackend trait. Use in CI / dev when you don't want to boot a real VM.
Documentation
//! In-memory stub for [`cellos_core::ports::CellBackend`] — no real isolation.

use async_trait::async_trait;
use tracing::instrument;

use cellos_core::ports::{CellBackend, CellHandle, TeardownReport};
use cellos_core::{CellosError, ExecutionCellDocument};

/// Stub backend: always reports successful create/destroy (for wiring tests only).
pub struct StubCellBackend;

#[async_trait]
impl CellBackend for StubCellBackend {
    #[instrument(skip(self, spec))]
    async fn create(&self, spec: &ExecutionCellDocument) -> Result<CellHandle, CellosError> {
        if spec.spec.id.is_empty() {
            return Err(CellosError::InvalidSpec("spec.id must be non-empty".into()));
        }
        Ok(CellHandle {
            cell_id: spec.spec.id.clone(),
            cgroup_path: None,
            // Stub backend does not manage network enforcement; the supervisor's
            // host-subprocess path surfaces the signal via `run_cell_command`.
            nft_rules_applied: None,
            // FC-08: stub backend has no boot artifact manifest.
            kernel_digest_sha256: None,
            rootfs_digest_sha256: None,
            firecracker_digest_sha256: None,
        })
    }

    #[instrument(skip(self, handle))]
    async fn destroy(&self, handle: &CellHandle) -> Result<TeardownReport, CellosError> {
        Ok(TeardownReport {
            cell_id: handle.cell_id.clone(),
            destroyed: true,
            peers_tracked_after: 0,
        })
    }
}