"""
helix_cdc.zc - Zero-Copy Infrastructure for CDNA Streaming

Provides mmap -> mlock -> cudaHostRegister -> DLPack pipeline
for zero-copy GPU access to compressed model weights.

Work Order: WO-ZC-SHIM

Components:
  - zc_bind: Low-level ctypes bindings to libcdna_zc.so
  - bar_lru: BAR1 LRU manager for registered memory budget

Usage:
    from helix_cdc.zc import BARLRU, map_register, HostSpan

    # Simple mapping
    span = map_register("/path/to/shard.cdna2.hxz", 0, 4096)

    # With LRU budget management
    lru = BARLRU(budget_bytes=512 * 1024 * 1024)
    span, created = lru.acquire(path, offset, nbytes)
"""

# Lazy imports to avoid loading C library until needed
def __getattr__(name):
    if name in ("map_register", "unregister_unmap", "HostSpan", "MappedSpan",
                "get_page_size", "get_cuda_device_count", "get_bar1_free_bytes",
                "span_to_numpy", "library_info"):
        from . import zc_bind
        return getattr(zc_bind, name)

    if name in ("BARLRU", "get_global_lru", "reset_global_lru", "CachedSpan"):
        from . import bar_lru
        return getattr(bar_lru, name)

    raise AttributeError(f"module 'helix_cdc.zc' has no attribute {name!r}")

__all__ = [
    # zc_bind
    "map_register",
    "unregister_unmap",
    "HostSpan",
    "MappedSpan",
    "get_page_size",
    "get_cuda_device_count",
    "get_bar1_free_bytes",
    "span_to_numpy",
    "library_info",
    # bar_lru
    "BARLRU",
    "CachedSpan",
    "get_global_lru",
    "reset_global_lru",
]
