"""mgf.vm.core — pure VM-domain library.

The stable core of the Magogi Foundation distributed VManager:
domain types, exceptions, the four Protocols (``HypervisorBackend``,
``StorageBackend``, ``DeviceBackend``, ``LifecycleObserver``),
cancellation primitive, capability descriptors, and common utilities.

The full method-by-method spec lives at
``vm-vmanager-docs/component-specs/contracts.md``.

For the architectural backstory, read the central docs repo:

  * vm-vmanager-docs/ARCHITECTURE.md          (end-to-end)
  * vm-vmanager-docs/component-specs/contracts.md  (the contract)
  * vm-vmanager-docs/DECISIONS.md             (the why)
"""

from __future__ import annotations

__version__ = "0.1.14"

# --- Legacy domain types (lifted from mgf-vm umbrella) ----------------------
# --- Cancellation -----------------------------------------------------------
from mgf.vm.core.cancellation import CancellationEvent, CancellationToken

# --- Capabilities -----------------------------------------------------------
from mgf.vm.core.capabilities import (
    DeviceCapabilities,
    HypervisorCapabilities,
    StorageCapabilities,
)

# --- The four Protocols + supporting types ----------------------------------
from mgf.vm.core.contracts import (
    CURRENT_BACKUP_SCHEMA_VERSION,
    CURRENT_VMSPEC_SCHEMA_VERSION,
    AsyncLifecycleObserver,
    AttachedDevice,
    BackupDiskArtifact,
    BackupManifest,
    ClaimMode,
    CompatibilityResult,
    DeviceAssignment,
    DeviceBackend,
    DeviceInfo,
    DeviceSpec,
    DiskImageInfo,
    DiskIo,
    DiskSpec,
    DiskStatus,
    DomainInfo,
    EventGap,
    HostDiskBackend,
    HypervisorBackend,
    LeaseEvent,
    LifecycleObserver,
    MetricsBackend,
    MetricsSample,
    MigrationPlan,
    MigrationTarget,
    NetworkBackend,
    NetworkLease,
    NetworkProfile,
    NetworkSpec,
    NicIo,
    NicSpec,
    NicStatus,
    OperationHandle,
    OperationKind,
    OperationStatus,
    PoolInfo,
    PoolSpec,
    RestoredDisk,
    RestoredImages,
    StorageBackend,
    TransitionCause,
    TransitionEvent,
    Vm,
    VmEvent,
    VmSpec,
    VmState,
    VmStatus,
    VolumeSpec,
    migrate_vmspec,
)

# The Wave-B engine-neutral host-network observation type is
# :class:`~mgf.vm.core.contracts.NetworkProfile` (returned by
# ``HypervisorBackend.list_networks`` per D-G14). The top-level
# ``NetworkInfo`` name binds the LEGACY libvirt-shaped
# ``mgf.vm.core.domain.NetworkInfo`` (the umbrella code still being retired
# depends on it).
from mgf.vm.core.domain import (
    HostMetrics,
    IsolationLevel,
    LeaseInfo,
    NetworkInfo,
    SnapshotInfo,
    StoragePoolInfo,
    VMCredential,
    VMHandle,
    VMMetrics,
    VMState,
    VMStatus,
    VolumeInfo,
)

# --- Fakes (D-F3 — first-class shipped fakes) ------------------------------
from mgf.vm.core.fakes import (
    FakeDeviceBackend,
    FakeHostDiskBackend,
    FakeHypervisorBackend,
    FakeMetricsBackend,
    FakeNetworkBackend,
    FakeStorageBackend,
)

# --- Contracts-aligned ID types ---------------------------------------------
from mgf.vm.core.ids import (
    DeviceId,
    DomainId,
    HostId,
    LeaseId,
    OperationId,
    SnapshotId,
    TenantId,
    VmId,
    VolumeId,
)

# --- Provisioning (engine-neutral first-boot config; part of VmSpec) --------
from mgf.vm.core.provisioning.spec import ProvisioningSpec

# --- VmSpec serialization (D-G8 — pairs with migrate_vmspec) ----------------
from mgf.vm.core.serde import vmspec_from_mapping, vmspec_to_mapping

# --- The state machine -----------------------------------------------------
from mgf.vm.core.state_machine import InvalidTransition, VmLifecycleStateMachine

__all__: list[str] = [
    "CURRENT_BACKUP_SCHEMA_VERSION",
    "CURRENT_VMSPEC_SCHEMA_VERSION",
    # ---- The four Protocols ----
    "AsyncLifecycleObserver",
    "AttachedDevice",
    # ---- Host disk-image I/O types (Wave-R4, D-G18) ----
    "BackupDiskArtifact",
    "BackupManifest",
    # ---- Cancellation ----
    "CancellationEvent",
    "CancellationToken",
    # ---- Protocol supporting types ----
    "ClaimMode",
    "CompatibilityResult",
    "DeviceAssignment",
    "DeviceBackend",
    # ---- Capabilities ----
    "DeviceCapabilities",
    # ---- ID types (contracts.md §2) ----
    "DeviceId",
    "DeviceInfo",
    "DeviceSpec",
    "DiskImageInfo",
    "DiskIo",
    "DiskSpec",
    "DiskStatus",
    "DomainId",
    "DomainInfo",
    "EventGap",
    "FakeDeviceBackend",
    "FakeHostDiskBackend",
    "FakeHypervisorBackend",
    "FakeMetricsBackend",
    "FakeNetworkBackend",
    "FakeStorageBackend",
    "HostDiskBackend",
    "HostId",
    # ---- Legacy domain types (lifted from mgf-vm) ----
    "HostMetrics",
    "HypervisorBackend",
    "HypervisorCapabilities",
    "InvalidTransition",
    "IsolationLevel",
    "LeaseEvent",
    "LeaseId",
    "LeaseInfo",
    "LifecycleObserver",
    "MetricsBackend",
    "MetricsSample",
    "MigrationPlan",
    "MigrationTarget",
    "NetworkBackend",
    "NetworkInfo",
    "NetworkLease",
    "NetworkProfile",
    "NetworkSpec",
    "NicIo",
    "NicSpec",
    "NicStatus",
    "OperationHandle",
    "OperationId",
    "OperationKind",
    "OperationStatus",
    "PoolInfo",
    "PoolSpec",
    "ProvisioningSpec",
    "RestoredDisk",
    "RestoredImages",
    "SnapshotId",
    "SnapshotInfo",
    "StorageBackend",
    "StorageCapabilities",
    "StoragePoolInfo",
    "TenantId",
    "TransitionCause",
    "TransitionEvent",
    "VMCredential",
    "VMHandle",
    "VMMetrics",
    "VMState",
    "VMStatus",
    "Vm",
    "VmEvent",
    "VmId",
    "VmLifecycleStateMachine",
    "VmSpec",
    "VmState",
    "VmStatus",
    "VolumeId",
    "VolumeInfo",
    "VolumeSpec",
    "__version__",
    "migrate_vmspec",
    "vmspec_from_mapping",
    "vmspec_to_mapping",
]
