from typing import Protocol, List, Dict, Optional, Set, Any, runtime_checkable
from ..models.graph import QuipuNode


@runtime_checkable
class HistoryReader(Protocol):
    def load_all_nodes(self) -> List[QuipuNode]: ...
    def get_node_content(self, node: QuipuNode) -> str: ...
    def get_node_blobs(self, commit_hash: str) -> Dict[str, bytes]: ...
    def find_nodes(
        self, summary_regex: Optional[str] = None, node_type: Optional[str] = None, limit: int = 10
    ) -> List[QuipuNode]: ...
    def get_node_count(self) -> int: ...
    def load_nodes_paginated(self, limit: int, offset: int) -> List[QuipuNode]: ...
    def get_ancestor_output_trees(self, start_output_tree_hash: str) -> Set[str]: ...
    def get_private_data(self, node_commit_hash: str) -> Optional[str]: ...
    def get_descendant_output_trees(self, start_output_tree_hash: str) -> Set[str]: ...
    def get_node_position(self, output_tree_hash: str) -> int: ...


@runtime_checkable
class HistoryWriter(Protocol):
    def create_node(
        self, node_type: str, input_tree: str, output_tree: str, content: str, **kwargs: Any
    ) -> QuipuNode: ...
