# AUTO-GENERATED by scripts/codegen_kernel_abi.py — DO NOT EDIT
# Source: rust/kernel/src/dispatch.rs, metastore.rs, backend.rs

"""Kernel dispatch protocols — Python typing contracts for Rust traits.

These Protocol classes mirror Rust traits in the kernel. Implement them
in Python to provide hooks, resolvers, observers, or storage backends.

Re-run: python scripts/codegen_kernel_abi.py
"""

from __future__ import annotations

from typing import Any, Protocol, runtime_checkable


@runtime_checkable
class PathResolver(Protocol):
    def try_read(self, path: str) -> bytes | None: ...
    def try_write(self, path: str, content: bytes) -> None | None: ...
    def try_delete(self, path: str) -> None | None: ...


@runtime_checkable
class MutationObserver(Protocol):
    def on_mutation(self, event: Any) -> None: ...


@runtime_checkable
class PermissionProvider(Protocol):
    def check(self, path: str, permission: Any, ctx: Any) -> Any: ...


@runtime_checkable
class NativeInterceptHook(Protocol):
    def name(self) -> str: ...
    def on_pre(self, _ctx: Any) -> Any: ...
    def on_post(self, _ctx: Any) -> None: ...
    def mutating_path_suffix(self) -> Any | None: ...


@runtime_checkable
class InterceptHook(Protocol):
    def name(self) -> str: ...
    def on_pre_read(self, ctx: Any) -> Any: ...
    def on_post_read(self, ctx: Any) -> None: ...
    def on_pre_write(self, ctx: Any) -> Any: ...
    def on_post_write(self, ctx: Any) -> None: ...
    def on_pre_delete(self, ctx: Any) -> Any: ...
    def on_post_delete(self, ctx: Any) -> None: ...
    def on_pre_rename(self, ctx: Any) -> Any: ...
    def on_post_rename(self, ctx: Any) -> None: ...
    def on_pre_mkdir(self, ctx: Any) -> Any: ...
    def on_post_mkdir(self, ctx: Any) -> None: ...
    def on_pre_rmdir(self, ctx: Any) -> Any: ...
    def on_post_rmdir(self, ctx: Any) -> None: ...
    def on_pre_copy(self, ctx: Any) -> Any: ...
    def on_post_copy(self, ctx: Any) -> None: ...
    def on_pre_stat(self, ctx: Any) -> Any: ...
    def on_post_stat(self, ctx: Any) -> None: ...
    def on_pre_access(self, ctx: Any) -> Any: ...
    def on_post_access(self, ctx: Any) -> None: ...
    def on_pre_write_batch(self, ctx: Any) -> Any: ...
    def on_post_write_batch(self, ctx: Any) -> None: ...


@runtime_checkable
class PipeBackend(Protocol):
    def push(self, data: bytes) -> Any: ...
    def pop(self) -> Any: ...
    def close(self) -> None: ...
    def is_closed(self) -> bool: ...
    def is_empty(self) -> bool: ...
    def size(self) -> int: ...
    def msg_count(self) -> int: ...


@runtime_checkable
class StreamBackend(Protocol):
    def push(self, data: bytes) -> Any: ...
    def read_at(self, offset: int) -> Any: ...
    def read_batch(self, offset: int, count: int) -> Any: ...
    def close(self) -> None: ...
    def is_closed(self) -> bool: ...
    def tail_offset(self) -> int: ...
    def msg_count(self) -> int: ...


@runtime_checkable
class CacheStore(Protocol):
    def get(self, key: str) -> Any: ...
    def set(self, key: str, value: bytes, ttl: int | None) -> Any: ...
    def delete(self, key: str) -> Any: ...
    def exists(self, key: str) -> Any: ...
    def delete_by_pattern(self, pattern: str) -> Any: ...
    def keys_by_pattern(self, pattern: str) -> Any: ...
    def publish(self, channel: str, message: bytes) -> Any: ...
    def subscribe(self, channel: str) -> Any: ...
    def health_check(self) -> Any: ...
    def close(self) -> Any: ...


@runtime_checkable
class MetaStore(Protocol):
    def get(self, path: str) -> Any: ...
    def put(self, path: str, metadata: Any) -> Any: ...
    def delete(self, path: str) -> Any: ...
    def list(self, prefix: str) -> Any: ...
    def exists(self, path: str) -> Any: ...
    def put_batch(self, items: Any) -> Any: ...
    def get_batch(self, paths: Any) -> Any: ...
    def delete_batch(self, paths: Any) -> Any: ...
    def put_if_version(self, metadata: Any, expected_version: int) -> Any: ...
    def rename_path(self, old_path: str, new_path: str, is_pas: bool) -> Any: ...
    def set_file_metadata(self, path: str, key: str, value: str) -> Any: ...
    def get_file_metadata(self, path: str, key: str) -> Any: ...
    def get_file_metadata_bulk(self, paths: Any, key: str) -> Any: ...
    def is_implicit_directory(self, path: str) -> Any: ...
    def list_paginated(
        self, prefix: str, recursive: bool, limit: int, cursor: str | None
    ) -> Any: ...
    def batch_get_content_ids(self, paths: Any) -> Any: ...
    def coherence_key(self) -> int | None: ...
    def append_stream_entry(self, key: str, data: bytes) -> Any: ...
    def get_stream_entry(self, key: str) -> Any: ...


@runtime_checkable
class ExternalTransport(Protocol):
    def generate_download_url(self, object_key: str, expires_seconds: int) -> Any: ...


@runtime_checkable
class ObjectStore(Protocol):
    def name(self) -> str: ...
    def as_cas(self) -> Any | None: ...
    def as_llm_streaming(self) -> Any | None: ...
    def posix_capabilities(self) -> Any: ...
    def write_content(self, content: bytes, content_id: str, ctx: Any, offset: int) -> Any: ...
    def read_content(self, content_id: str, ctx: Any) -> Any: ...
    def delete_content(self, content_id: str) -> Any: ...
    def get_content_size(self, content_id: str) -> Any: ...
    def mkdir(self, path: str, parents: bool, exist_ok: bool) -> Any: ...
    def rmdir(self, path: str, recursive: bool) -> Any: ...
    def delete_file(self, path: str) -> Any: ...
    def rename(self, old_path: str, new_path: str) -> Any: ...
    def copy_file(self, src_path: str, dst_path: str) -> Any: ...
    def list_dir(self, path: str) -> Any: ...


@runtime_checkable
class DistributedCoordinator(Protocol):
    def list_zones(self, kernel: Any) -> list[str]: ...
    def is_initialized(self, kernel: Any) -> bool: ...
    def cluster_info(self, kernel: Any, zone_id: str) -> Any: ...
    def create_zone(self, kernel: Any, zone_id: str) -> Any: ...
    def remove_zone(self, kernel: Any, zone_id: str, force: bool) -> Any: ...
    def join_zone(self, kernel: Any, zone_id: str, as_learner: bool) -> Any: ...
    def join_cluster(
        self, kernel: Any, zone_id: str, leader_addr: str, as_learner: bool
    ) -> Any: ...
    def wire_mount(
        self, kernel: Any, parent_zone: str, mount_path: str, target_zone: str
    ) -> Any: ...
    def unwire_mount(self, kernel: Any, parent_zone: str, mount_path: str) -> Any: ...
    def share_zone(self, kernel: Any, local_path: str, new_zone_id: str) -> Any: ...
    def lookup_share(self, kernel: Any, remote_path: str) -> Any: ...
    def metastore_for_zone(self, kernel: Any, zone_id: str) -> Any: ...
    def locks_for_zone(self, kernel: Any, zone_id: str) -> Any: ...


@runtime_checkable
class ObjectStoreProvider(Protocol):
    def build(self, args: Any) -> Any: ...
