from __future__ import annotations

from typing import Any

from rights_filter.domain.knowledge_base import create_manual_knowledge_entry
from rights_filter.domain.records import (
    InMemoryRightsFilterRepository,
    KnowledgeBaseEntry,
    KnowledgeEntryType,
)
from rights_filter.governance.policies import assert_no_biometric_template


def register_manual_entry(
    repository: InMemoryRightsFilterRepository,
    entry_type: KnowledgeEntryType,
    name: str,
    aliases: list[str] | None = None,
    related_keywords: list[str] | None = None,
    policy_memo: str = "",
    exception_conditions: str = "",
    sample_fingerprints: list[str] | None = None,
    **payload: Any,
) -> KnowledgeBaseEntry:
    assert_no_biometric_template(payload)
    entry = create_manual_knowledge_entry(
        entry_type=entry_type,
        name=name,
        aliases=aliases,
        related_keywords=related_keywords,
        policy_memo=policy_memo,
        exception_conditions=exception_conditions,
        sample_fingerprints=sample_fingerprints,
    )
    repository.save_knowledge_entry(entry)
    return entry
