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

"""Type stubs for nexus_runtime — Rust-accelerated PyO3 extension module.

Auto-generated from rust/kernel/src/*.rs exports.
Re-run: python scripts/codegen_kernel_abi.py
"""

from typing import Any, Self  # noqa: F401  (Self used by codegen-emitted classes)

# ---------------------------------------------------------------------------
# Path utilities (path_utils.rs)
# ---------------------------------------------------------------------------

def split_path(path: str) -> list[str]: ...
def get_parent(path: str) -> str | None: ...
def get_ancestors(path: str) -> list[str]: ...
def get_parent_chain(path: str) -> list[tuple[str, str]]: ...
def parent_path(path: str) -> str | None: ...
def validate_path(path: str, allow_root: bool = False) -> str: ...
def normalize_path(path: str) -> str: ...
def path_matches_pattern(path: str, pattern: str) -> bool: ...
def unscope_internal_path(path: str) -> str: ...
def canonicalize_path(path: str, zone_id: str = "root") -> str: ...
def extract_zone_id(canonical_path: str) -> tuple[str, str]: ...

# ---------------------------------------------------------------------------
# Path prefix matching (prefix.rs)
# ---------------------------------------------------------------------------

def any_path_starts_with(paths: list[str], prefix: str) -> bool: ...
def batch_prefix_check(paths: list[str], prefixes: list[str]) -> list[bool]: ...
def filter_paths_by_prefix(paths: list[str], prefix: str) -> list[str]: ...

# ---------------------------------------------------------------------------
# Hash (hash.rs)
# ---------------------------------------------------------------------------

def hash_content_py(content: bytes) -> str: ...
def hash_content_smart_py(content: bytes) -> str: ...
def hash_bytes(data: bytes) -> str: ...

# ---------------------------------------------------------------------------
# Search (search.rs)
# ---------------------------------------------------------------------------

def grep_bulk(
    pattern: str, file_contents: dict[str, Any], ignore_case: bool = False, max_results: int = 1000
) -> list[dict[str, Any]]: ...
def grep_files_mmap(
    pattern: str, file_paths: list[str], ignore_case: bool = False, max_results: int = 1000
) -> list[dict[str, Any]]: ...

# ---------------------------------------------------------------------------
# Glob (glob.rs)
# ---------------------------------------------------------------------------

def glob_match_bulk(patterns: list[str], paths: list[str]) -> list[str]: ...
def filter_paths(paths: list[str], exclude_patterns: list[str]) -> list[str]: ...

# ---------------------------------------------------------------------------
# File I/O (io.rs)
# ---------------------------------------------------------------------------

def read_file(path: str) -> bytes | None: ...
def read_files_bulk(paths: list[str]) -> dict[str, bytes]: ...

# ---------------------------------------------------------------------------
# ReBAC (rebac.rs)
# ---------------------------------------------------------------------------

def compute_permissions_bulk(
    checks: list[Any], tuples: list[Any], namespace_configs: dict[str, Any], tuple_version: int
) -> dict[Any, bool]: ...
def compute_permission_single(
    subject_type: str,
    subject_id: str,
    permission: str,
    object_type: str,
    object_id: str,
    tuples: list[Any],
    namespace_configs: dict[str, Any],
) -> bool: ...
def expand_subjects(
    permission: str,
    object_type: str,
    object_id: str,
    tuples: list[Any],
    namespace_configs: dict[str, Any],
) -> list[tuple[str, str]]: ...
def list_objects_for_subject(
    subject_type: str,
    subject_id: str,
    permission: str,
    object_type: str,
    tuples: list[Any],
    namespace_configs: dict[str, Any],
    path_prefix: str | None = None,
    limit: int = 1000,
    offset: int = 0,
) -> list[tuple[str, str]]: ...
def check_permission_bitmap(user_bitmap_bytes: bytes, resource_bitmap_bytes: bytes) -> bool: ...
def check_permission_bitmap_batch(
    user_bitmap_bytes: bytes, resource_bitmaps: list[bytes]
) -> list[bool]: ...

# ---------------------------------------------------------------------------
# Tiger Cache Bitmap (bitmap.rs)
# ---------------------------------------------------------------------------

def filter_paths_with_tiger_cache(path_int_ids: list[int], bitmap_bytes: bytes) -> list[int]: ...
def filter_paths_with_tiger_cache_parallel(
    path_int_ids: list[int], bitmap_bytes: bytes
) -> list[int]: ...
def intersect_paths_with_tiger_cache(path_int_ids: list[int], bitmap_bytes: bytes) -> list[int]: ...
def any_path_accessible_tiger_cache(path_int_ids: list[int], bitmap_bytes: bytes) -> bool: ...
def tiger_cache_bitmap_stats(bitmap_bytes: bytes) -> dict[str, Any]: ...

# ---------------------------------------------------------------------------
# SIMD vector similarity (simd.rs)
# ---------------------------------------------------------------------------

def cosine_similarity_f32(a: list[float], b: list[float]) -> float: ...
def dot_product_f32(a: list[float], b: list[float]) -> float: ...
def euclidean_sq_f32(a: list[float], b: list[float]) -> float: ...
def batch_cosine_similarity_f32(query: list[float], vectors: list[list[float]]) -> list[float]: ...
def top_k_similar_f32(
    query: list[float], vectors: list[list[float]], k: int
) -> list[tuple[int, float]]: ...
def cosine_similarity_i8(a: list[int], b: list[int]) -> float: ...
def batch_cosine_similarity_i8(query: list[int], vectors: list[list[int]]) -> list[float]: ...
def top_k_similar_i8(
    query: list[int], vectors: list[list[int]], k: int
) -> list[tuple[int, float]]: ...

# ---------------------------------------------------------------------------
# Trigram Index (trigram.rs)
# ---------------------------------------------------------------------------

def build_trigram_index(file_paths: list[str], output_path: str) -> None: ...
def build_trigram_index_from_entries(
    entries: list[tuple[str, bytes]], output_path: str
) -> None: ...
def trigram_grep(
    index_path: str, pattern: str, ignore_case: bool = False, max_results: int = 1000
) -> list[dict[str, Any]]: ...
def trigram_search_candidates(
    index_path: str, pattern: str, ignore_case: bool = False
) -> list[str]: ...
def trigram_index_stats(index_path: str) -> dict[str, Any]: ...
def invalidate_trigram_cache(index_path: str) -> None: ...

# ---------------------------------------------------------------------------
# Classes
# ---------------------------------------------------------------------------

class PyOperationContext:
    def __init__(
        self,
        user_id: str = "anonymous",
        zone_id: str = "root",
        is_admin: bool = False,
        agent_id: str | None = None,
        is_system: bool = False,
        groups: list[str] = [],
        admin_capabilities: list[str] = [],
        subject_type: str = "user",
        subject_id: str | None = None,
        request_id: str = "",
        context_zone_id: str | None = None,
        zone_perms: list[tuple[str, str]] = [],
    ) -> None: ...

class PyKernel:
    def __init__(self) -> None: ...
    def start_write_buffer_flusher(self, interval_ms: int) -> None: ...
    def set_vfs_lock_timeout(self, timeout_ms: int) -> None: ...
    def set_self_address(self, addr: str) -> None: ...
    def set_permission_provider(self, provider: Any) -> None: ...
    def set_permission_admin_bypass(self, enabled: bool) -> None: ...
    def permission_lease_invalidate_path(self, path: str) -> None: ...
    def permission_lease_invalidate_agent(self, agent_id: str) -> None: ...
    def permission_lease_invalidate_all(self) -> None: ...
    def set_metastore_path(self, path: str) -> None: ...
    def release_metastores(self) -> None: ...
    def metastore_list_paginated(
        self, prefix: str, recursive: bool = True, limit: int = 1000, cursor: str | None = None
    ) -> Any: ...
    def stat_batch(self, paths: list[str], zone_id: str = "root") -> list[Any | None]: ...
    def set_xattr(self, path: str, key: str, value: str) -> None: ...
    def get_xattr(self, path: str, key: str) -> str | None: ...
    def get_xattr_bulk(self, paths: list[str], key: str) -> Any: ...
    def write(self, path: str, ctx: Any, content: bytes, offset: int) -> Any: ...
    def get_content_id(self, path: str, zone_id: str = "root") -> str | None: ...
    def is_directory(self, path: str, zone_id: str = "root") -> bool: ...
    def get_top_level_mounts(self, zone_id: str = "root") -> list[str]: ...
    def exists_batch(self, paths: list[str], zone_id: str = "root") -> list[bool]: ...
    def readdir_paged(
        self,
        parent_path: str,
        zone_id: str = "root",
        is_admin: bool = False,
        limit: int = 0,
        cursor: str | None = None,
    ) -> Any: ...
    def sys_lock(
        self,
        path: str,
        lock_id: str = "",
        mode: str = "exclusive",
        max_holders: int = 1,
        ttl_secs: int = 60,
        holder_info: str = "",
    ) -> str | None: ...
    def sys_unlock(self, path: str, lock_id: str = "", force: bool = False) -> bool: ...
    def metastore_list_locks(self, prefix: str = "", limit: int = 1024) -> dict[str, Any]: ...
    def cas_write(
        self, mount_point: str, zone_id: str, content: bytes, ttl_seconds: int | None = None
    ) -> tuple[str, bool]: ...
    def cas_read(
        self, mount_point: str, zone_id: str, content_id: str, origins: list[str] | None = None
    ) -> bytes: ...
    def cas_delete(self, mount_point: str, zone_id: str, content_id: str) -> None: ...
    def cas_exists(self, mount_point: str, zone_id: str, content_id: str) -> bool: ...
    def cas_size(self, mount_point: str, zone_id: str, content_id: str) -> int: ...
    def cas_is_chunked(self, mount_point: str, zone_id: str, content_id: str) -> bool: ...
    def cas_write_partial(
        self,
        mount_point: str,
        zone_id: str,
        old_hash: str,
        buf: bytes,
        offset: int,
        origins: list[str] | None = None,
    ) -> str: ...
    def llm_start_streaming(
        self, mount_point: str, zone_id: str, request_bytes: bytes, stream_path: str
    ) -> None: ...
    def sys_setattr(
        self,
        path: str,
        entry_type: int,
        backend_name: str,
        local_root: str | None,
        fsync: bool,
        backend_type: str,
        follow_symlinks: bool,
        openai_base_url: str | None,
        openai_api_key: str | None,
        openai_model: str | None,
        openai_blob_root: str | None,
        anthropic_base_url: str | None,
        anthropic_api_key: str | None,
        anthropic_model: str | None,
        anthropic_blob_root: str | None,
        s3_bucket: str | None,
        s3_prefix: str | None,
        aws_region: str | None,
        aws_access_key: str | None,
        aws_secret_key: str | None,
        s3_endpoint: str | None,
        gcs_bucket: str | None,
        gcs_prefix: str | None,
        access_token: str | None,
        root_folder_id: str | None,
        bot_token: str | None,
        default_channel: str | None,
        hn_stories_per_feed: int | None,
        hn_include_comments: bool | None,
        cli_command: str | None,
        cli_service: str | None,
        cli_auth_env_json: str | None,
        x_bearer_token: str | None,
        metastore_path: str | None,
        io_profile: str,
        zone_id: str,
        is_external: bool,
        capacity: int,
        mime_type: str | None,
        modified_at_ms: int | None,
        content_id: str | None,
        size: int | None,
        version: int | None,
        created_at_ms: int | None,
        read_fd: int | None,
        write_fd: int | None,
        server_address: str | None,
        remote_auth_token: str | None,
        remote_ca_pem: bytes | None,
        remote_cert_pem: bytes | None,
        remote_key_pem: bytes | None,
        remote_timeout: float,
        link_target: str | None,
        source: str | None,
    ) -> Any: ...
    def has_mount(self, mount_point: str, zone_id: str) -> bool: ...
    def get_mount_points(self) -> list[str]: ...
    def kernel_unmount(self, mount_point: str, zone_id: str = "root") -> bool: ...
    def create_pipe(self, path: str, capacity: int) -> None: ...
    def destroy_pipe(self, path: str) -> None: ...
    def close_pipe(self, path: str) -> None: ...
    def has_pipe(self, path: str) -> bool: ...
    def pipe_write_nowait(self, path: str, data: bytes) -> int: ...
    def pipe_read_nowait(self, path: str) -> bytes | None: ...
    def list_pipes(self) -> list[str]: ...
    def close_all_pipes(self) -> None: ...
    def create_stream(self, path: str, capacity: int) -> None: ...
    def destroy_stream(self, path: str) -> None: ...
    def close_stream(self, path: str) -> None: ...
    def has_stream(self, path: str) -> bool: ...
    def stream_write_nowait(self, path: str, data: bytes) -> int: ...
    def stream_read_at(self, path: str, offset: int) -> tuple[bytes, int] | None: ...
    def stream_read_batch(self, path: str, offset: int, count: int) -> tuple[list[bytes], int]: ...
    def stream_collect_all(self, path: str) -> bytes: ...
    def list_streams(self) -> list[str]: ...
    def close_all_streams(self) -> None: ...
    def trie_register(self, pattern: str, resolver_idx: int) -> None: ...
    def trie_unregister(self, resolver_idx: int) -> bool: ...
    def trie_lookup(self, path: str) -> int | None: ...
    def trie_len(self) -> int: ...
    def register_hook(self, op: str, hook: Any) -> None: ...
    def unregister_hook(self, op: str, hook: Any) -> bool: ...
    def get_pre_hooks(self, op: str) -> list[Any]: ...
    def get_post_hooks(self, op: str) -> tuple[list[Any], list[Any]]: ...
    def get_all_hooks(self, op: str) -> list[Any]: ...
    def hook_count(self, op: str) -> int: ...
    def sys_watch(self, pattern: str, timeout_ms: int) -> tuple[str, str] | None: ...
    def dispatch_event(self, event_type: str, path: str) -> None: ...
    def flush_observers(self) -> None: ...
    def kernel_observer_count(self) -> int: ...
    def set_hook_count(self, op: str, count: int) -> None: ...
    def dispatch_pre_hooks(self, op: str, hook_ctx: Any) -> None: ...
    def dispatch_post_hooks(self, op: str, hook_ctx: Any) -> list[Any]: ...
    def dispatch_pre_hooks_batch_stat(
        self, paths: list[str], ctx: Any, permission: str
    ) -> list[bool]: ...
    def sys_read(self, path: str, ctx: Any, timeout_ms: int = 5000, offset: int = 0) -> Any: ...
    def sys_write(self, path: str, ctx: Any, content: bytes, offset: int = 0) -> Any: ...
    def flush_write_buffer(self, path: str | None = None, zone_id: str | None = None) -> Any: ...
    def flush_due_write_buffer(self) -> Any: ...
    def sys_stat(self, path: str, zone_id: str) -> dict[str, Any]: ...
    def sys_unlink(self, path: str, ctx: Any, recursive: bool = False) -> Any: ...
    def sys_rename(self, old_path: str, new_path: str, ctx: Any) -> Any: ...
    def sys_copy(self, src_path: str, dst_path: str, ctx: Any) -> Any: ...
    def sys_mkdir(
        self, path: str, ctx: Any, parents: bool = True, exist_ok: bool = True
    ) -> Any: ...
    def access(self, path: str, zone_id: str) -> bool: ...
    def readdir(
        self, parent_path: str, zone_id: str, is_admin: bool = False
    ) -> list[tuple[str, int]]: ...
    def sys_glob(self, pattern: str, prefix: str = "/", zone_id: str = "root") -> list[str]: ...
    def sys_grep(
        self,
        pattern: str,
        prefix: str = "/",
        ignore_case: bool = False,
        max_results: int = 1000,
        zone_id: str = "root",
        disk_paths: list[str] | None = None,
    ) -> list[Any]: ...
    def sys_read_raw(self, path: str, zone_id: str) -> Any: ...
    def sys_cat(self, path: str, zone_id: str = "root", strict_json: bool = True) -> bytes: ...
    def op_metadata_for_path(self, path: str, zone_id: str = "root") -> dict[str, Any]: ...
    def backend_fingerprint(self, path: str, zone_id: str = "root") -> str | None: ...
    def sys_write_batch(self, items: list[tuple[str, bytes]], ctx: Any) -> list[Any]: ...
    def sys_read_batch(self, reqs: Any, ctx: Any) -> list[Any]: ...
    def sys_unlink_batch(self, paths: list[str], ctx: Any) -> list[Any]: ...
    def increment_zone_revision(self, zone_id: str) -> int: ...
    def notify_zone_revision(self, zone_id: str, revision: int) -> None: ...
    def get_zone_revision(self, zone_id: str) -> int: ...
    def wait_zone_revision(self, zone_id: str, min_revision: int, timeout_ms: int) -> bool: ...
    def register_watch(self, pattern: str) -> int: ...
    def unregister_watch(self, watch_id: int) -> bool: ...
    def match_watches(self, path: str) -> list[int]: ...
    def agent_register(
        self,
        pid: str,
        name: str,
        kind: str,
        owner_id: str,
        zone_id: str,
        created_at_ms: int,
        parent_pid: str | None = None,
        connection_id: str | None = None,
    ) -> bool: ...
    def agent_unregister(self, pid: str) -> bool: ...
    def agent_get(self, pid: str) -> dict[str, Any]: ...
    def agent_update_state(self, pid: str, new_state: str) -> bool: ...
    def agent_list(
        self,
        zone_id: str | None = None,
        owner_id: str | None = None,
        state: str | None = None,
        kind: str | None = None,
    ) -> dict[str, Any]: ...
    def agent_heartbeat(self, pid: str, timestamp_ms: int) -> bool: ...
    def agent_count(self) -> int: ...
    def agent_wait(self, pid: str, target_state: str, timeout_ms: int) -> str: ...
    def service_enlist(
        self, name: str, instance: Any, exports: list[str] = [], allow_overwrite: bool = False
    ) -> None: ...
    def service_lookup(self, name: str) -> Any | None: ...
    def service_swap(
        self, name: str, new_instance: Any, exports: list[str] = [], timeout_ms: int = 10000
    ) -> None: ...
    def service_unregister(self, name: str) -> bool: ...
    def service_start_all(self, timeout_ms: int = 30000) -> list[str]: ...
    def service_stop_all(self, timeout_ms: int = 10000) -> list[str]: ...
    def service_close_all(self) -> None: ...
    def service_mark_bootstrapped(self) -> None: ...
    def service_snapshot(self) -> dict[str, Any]: ...
    @property
    def agent_registry(self) -> Any: ...

class PySysReadResult:
    data: bytes | None
    post_hook_needed: bool
    content_id: str | None
    gen: int
    entry_type: int
    stream_next_offset: int | None

class PyBatchReadItem:
    data: bytes | None
    content_id: str | None
    gen: int
    entry_type: int
    post_hook_needed: bool
    error_kind: str
    error_message: str

class PySysWriteResult:
    hit: bool
    content_id: str | None
    post_hook_needed: bool
    version: int
    gen: int
    size: int
    is_new: bool
    old_content_id: str | None
    old_size: int | None
    old_version: int | None
    old_modified_at_ms: int | None

class AgentRegistry:
    def __init__(self) -> None: ...
    def spawn(
        self,
        name: str,
        owner_id: str,
        zone_id: str,
        kind: str = "managed",
        pid: str | None = None,
        parent_pid: str | None = None,
        cwd: str = "/",
        labels: dict[str, str] | None = None,
    ) -> Any: ...
    def unregister(self, pid: str) -> bool: ...
    def reap(self, pid: str) -> bool: ...
    def get(self, pid: str) -> Any | None: ...
    def update_state(self, pid: str, new_state: str) -> bool: ...
    def update_state_with_exit(self, pid: str, new_state: str, exit_code: int) -> bool: ...
    def signal(self, pid: str, sig: str, payload: dict[str, str] | None = None) -> Any: ...
    def kill(self, pid: str, exit_code: int = 0) -> Any: ...
    def register_external(
        self,
        name: str,
        owner_id: str,
        zone_id: str,
        connection_id: str,
        host_pid: int | None = None,
        remote_addr: str | None = None,
        protocol: str = "grpc",
        parent_pid: str | None = None,
        labels: dict[str, str] | None = None,
    ) -> Any: ...
    def unregister_external(self, pid: str) -> None: ...
    def heartbeat(self, pid: str) -> Any: ...
    def heartbeat_at(self, pid: str, timestamp_ms: int) -> bool: ...
    def count_by_state(self, state: str, zone_id: str | None = None) -> int: ...
    def list_by_priority(self, zone_id: str | None = None, batch_size: int = 10) -> list[Any]: ...
    def list_processes(
        self,
        zone_id: str | None = None,
        owner_id: str | None = None,
        kind: str | None = None,
        state: str | None = None,
    ) -> list[Any]: ...
    def wait_for_state(self, pid: str, target_state: str, timeout_ms: int) -> str: ...
    def close_all(self) -> None: ...
    def set_provisioner(self, callback: Any) -> None: ...
    def get_provisioner(self) -> Any | None: ...
    def take_provisioner(self) -> Any | None: ...
    @property
    def count(self) -> int: ...

class AgentDescriptor:
    def to_dict(self) -> dict[str, Any]: ...
    def __repr__(self) -> str: ...
    @property
    def pid(self) -> str: ...
    @property
    def ppid(self) -> str | None: ...
    @property
    def name(self) -> str: ...
    @property
    def owner_id(self) -> str: ...
    @property
    def zone_id(self) -> str: ...
    @property
    def kind(self) -> str: ...
    @property
    def state(self) -> str: ...
    @property
    def exit_code(self) -> int | None: ...
    @property
    def generation(self) -> int: ...
    @property
    def cwd(self) -> str: ...
    @property
    def root(self) -> str: ...
    @property
    def children(self) -> list[str]: ...
    @property
    def created_at_ms(self) -> int: ...
    @property
    def updated_at_ms(self) -> int: ...
    @property
    def last_heartbeat_ms(self) -> int | None: ...
    @property
    def connection_id(self) -> str | None: ...
    @property
    def labels(self) -> dict[str, str]: ...
    @property
    def repos(self) -> dict[str, Any]: ...
    @property
    def external_info(self) -> dict[str, Any]: ...

class BloomFilter:
    def __init__(self, expected_items: int = 100000, fp_rate: float = 0.01) -> None: ...
    def add(self, key: str) -> None: ...
    def add_bulk(self, keys: list[str]) -> None: ...
    def might_exist(self, key: str) -> bool: ...
    def check_bulk(self, keys: list[str]) -> list[bool]: ...
    def clear(self) -> None: ...
    @property
    def capacity(self) -> int: ...
    @property
    def fp_rate(self) -> float: ...
    @property
    def memory_bytes(self) -> int: ...

class PyFederationClient:
    def __init__(
        self,
        local_ca_pem: bytes | None = None,
        node_cert_pem: bytes | None = None,
        node_key_pem: bytes | None = None,
        tofu_store_path: str | None = None,
    ) -> None: ...
    def discover_mount(self, peer_addr: str, path: str) -> dict[str, Any]: ...
    def request_join_zone(
        self, peer_addr: str, zone_id: str, node_id: int, node_address: str, as_learner: bool
    ) -> None: ...

class TaskEngine:
    def __init__(self, db_path: str, max_pending: int = 1000, max_wait_secs: int = 300) -> None: ...
    def submit(
        self,
        task_type: str,
        params: bytes,
        priority: int = 2,
        max_retries: int = 3,
        run_at: int = 0,
    ) -> int: ...
    def claim_next(self, worker_id: str, lease_secs: int = 300) -> Any | None: ...
    def heartbeat(self, task_id: int, progress_pct: int = 0, message: str = "") -> bool: ...
    def complete(self, task_id: int, worker_id: str, result: bytes = b"") -> None: ...
    def fail(self, task_id: int, worker_id: str, error_message: str) -> None: ...
    def cancel(self, task_id: int) -> None: ...
    def status(self, task_id: int) -> Any | None: ...
    def list_tasks(
        self,
        status: int | None = None,
        task_type: str | None = None,
        limit: int = 100,
        offset: int = 0,
    ) -> list[Any]: ...
    def requeue_abandoned(self) -> int: ...
    def cleanup(self, max_completed_age_secs: int = 86400) -> int: ...
    def stats(self) -> Any: ...

class TaskRecord:
    task_id: int
    task_type: str
    params: bytes
    priority: int
    status: int
    result: bytes | None
    error_message: str | None
    attempt: int
    max_retries: int
    created_at: int
    run_at: int
    claimed_by: str | None
    progress_pct: int
    progress_message: str | None
    completed_at: int | None
    def __repr__(self) -> str: ...

class QueueStats:
    pending: int
    running: int
    completed: int
    failed: int
    dead_letter: int
    cancelled: int
    def __repr__(self) -> str: ...

# ---------------------------------------------------------------------------
# Raft-side classes re-exported via nexus_runtime
# (rust/raft/src/federation/tofu.rs, rust/raft/src/pyo3_bindings.rs)
# ---------------------------------------------------------------------------

class PyTrustedZone:
    zone_id: str
    ca_fingerprint: str
    ca_pem: str
    first_seen: str
    last_verified: str
    peer_addresses: list[str]

class PyTofuTrustStore:
    def __init__(self, path: str) -> None: ...
    def verify_or_trust(self, zone_id: str, ca_pem: bytes, peer_address: str) -> str: ...
    def remove(self, zone_id: str) -> bool: ...
    def get_ca_pem(self, zone_id: str) -> bytes | None: ...
    def list_trusted(self) -> list[PyTrustedZone]: ...
    def build_ca_bundle(self, local_ca_path: str) -> str: ...
    def path(self) -> str: ...

def hostname_to_node_id(hostname: str) -> int: ...
def install_federation_wiring(kernel: Any) -> None: ...
def federation_is_initialized(kernel: Any) -> bool: ...
def federation_create_zone(kernel: Any, zone_id: str) -> str: ...
def federation_remove_zone(kernel: Any, zone_id: str, force: bool = False) -> None: ...
def federation_join_zone(kernel: Any, zone_id: str, as_learner: bool = False) -> str: ...
def federation_share_zone(kernel: Any, local_path: str, new_zone_id: str) -> dict[str, Any]: ...
def federation_lookup_share(kernel: Any, remote_path: str) -> str | None: ...
def federation_cluster_info(kernel: Any, zone_id: str) -> dict[str, Any]: ...

# ---------------------------------------------------------------------------
# Audit stream-only registration (rust/services/src/python/mod.rs)
# ---------------------------------------------------------------------------

def prepare_audit_stream_only(kernel: Any, zone_id: str, stream_path: str) -> None: ...

# ---------------------------------------------------------------------------
# Driver gate (rust/services/src/python/mod.rs)
# ---------------------------------------------------------------------------

def nx_set_enabled_drivers(drivers: list[str]) -> None: ...

# ---------------------------------------------------------------------------
# ManagedAgentService PyO3 surface (rust/services/src/python/mod.rs)
# ---------------------------------------------------------------------------

def nx_managed_agent_install(py_kernel: Any) -> None: ...

# ---------------------------------------------------------------------------
# AcpService PyO3 surface (rust/services/src/acp/pyo3.rs)
# ---------------------------------------------------------------------------

def nx_acp_install(py_kernel: Any, default_zone: str = "root") -> None: ...
def nx_acp_set_agent_registry(py_kernel: Any, registry: Any) -> None: ...
def nx_acp_register_on_terminate(py_kernel: Any, callback_id: str, callback: Any) -> None: ...

# ---------------------------------------------------------------------------
# Generic Rust-service dispatch (rust/services/src/python/mod.rs)
# ---------------------------------------------------------------------------

def nx_kernel_dispatch_rust_call(
    py_kernel: Any, service: str, method: str, payload: bytes
) -> bytes | None: ...

# ---------------------------------------------------------------------------
# PrefetchEngine PyO3 surface (rust/nexus-prefetch/src/pyo3_bindings.rs)
# Issue #4057 — adaptive prefetcher exposed to Python via cdylib.  Manually
# maintained: the codegen at scripts/codegen_kernel_abi.py only scans
# rust/kernel/src; PrefetchEngine lives in rust/nexus-prefetch.
# ---------------------------------------------------------------------------

class PrefetchEngine:
    def __init__(
        self,
        read_callable: Any,
        block_size: int,
        initial_window: int,
        max_window: int,
        max_workers: int,
        queue_capacity: int,
        max_blocks_per_trigger: int,
        sequential_tolerance: int,
        min_sequential_count: int,
        detector: str = "sequential",
        shutdown_timeout_ms: int = 2000,
        max_buffer_bytes: int = 134217728,
    ) -> None: ...
    def on_open(self, fh: int, path: str, file_size: int | None) -> None: ...
    def on_read(self, fh: int, offset: int, size: int) -> bytes | None: ...
    def on_release(self, fh: int) -> None: ...
    def invalidate_fh(self, fh: int) -> None: ...
    def invalidate_path(self, path: str) -> None: ...
    def metrics(self) -> tuple[int, int, int, int, int]: ...
    def shutdown(self) -> None: ...
