"""Check 原语注册中心：通过 register 装饰器收集，runner 通过 get 查找。"""

from __future__ import annotations
from fastapi_modules.fastapi_leaudit.govdoc_engine.engine.checks.base import CheckBase

_REGISTRY: dict[str, type[CheckBase]] = {}


def register(name: str):
    def deco(cls):
        cls.name = name
        _REGISTRY[name] = cls
        return cls
    return deco


def get_check(name: str) -> type[CheckBase]:
    if name not in _REGISTRY:
        raise KeyError(f"unknown check: {name}; known: {list(_REGISTRY)}")
    return _REGISTRY[name]


def all_checks() -> list[str]:
    return list(_REGISTRY.keys())
