"""π* domain library — canonical projections registered by name@version.

Implements ticket #000015. Centralizes arborist's canonicalizers
behind a unified protocol so:

- New domain π*'s register against a single namespace.
- Composition (``π*_a ∘ π*_b``) is itself a registered π*.
- Versioning is mechanical: ``name@version`` is the registry key;
  changing a π* means a new key.

Concrete π*'s shipped today (alphabetical):

- ``algebra-symbolic@v1`` — symbolic algebra (SymPy expand + srepr).
  Optional; registers only when ``sympy`` is importable.
- ``algebra-symbolic-simplified@v1`` — full-simplify variant
  (SymPy simplify + srepr). Slower than expand-only sibling;
  collapses trig identity. Optional, gates on ``sympy``.
- ``arithmetic@v1`` — closed-form rational arithmetic (SQD §14.1).
- ``calculus-derivative@v1`` — symbolic derivative (SymPy diff +
  expand). Optional; gates on ``sympy`` like algebra-symbolic.
- ``calculus-integral@v1`` — symbolic integral (SymPy integrate +
  thread-timeout + expand). Optional; gates on ``sympy``. Returns
  an ``unevaluated:Integral(...)`` sentinel when no closed form
  exists or the timeout fires.
- ``calculus-limit@v1`` — symbolic limit (one/two-sided +
  ±∞ / complex-infinity sentinels). Optional; gates on ``sympy``.
- ``calculus-series@v1`` — truncated Taylor / Maclaurin series
  (drops the ``O(x**n)`` remainder for finite-byte canonical).
  Optional; gates on ``sympy``.
- ``claim-lattice@v1`` — claim lines → JSON parsed-claim list.
- ``code-py-ast@v1`` — Python source → canonical AST S-expression.
- ``combinatorics@v1`` — pure-integer counting kernel (binomial,
  factorial, Catalan, Bell, partition, …). Fail-closed on
  symbolic / negative / non-integer outputs. Tighter sibling of
  ``algebra-symbolic@v1``. Optional; gates on ``sympy``.
- ``function-sampled@v1`` — symbolic expression + sample grid →
  quantized integer-vector signature in time-series-quantized@v1
  format. Optional; gates on ``sympy``.
- ``linear-algebra@v1`` — matrix RREF / det / eigenvalues / inverse
  via ``{op, matrix}`` JSON. Optional; gates on ``sympy``.
- ``logic-kernel@v1`` — propositional Boolean → CNF (SQD §14.3).
- ``tabular-pinned@v1`` — JSON-rows → pinned-schema canonical bytes
  (last reserved-stub graduated; closes the registry chapter).
- ``time-series-quantized@v1`` — JSON sample array → quantized
  integer vector (SQD §13.5).
- ``wikitext-base@v1`` — wraps :func:`arborist.wikitext.to_base`.

The registry has no remaining reserved stubs.

Composition theory: see ``docs/pi-star-composition.md``.
"""

from __future__ import annotations

from arborist.pi_star.compose import (
    PiStarComposition,
    canonical_composition_id,
    compose,
)
from arborist.pi_star.protocol import PiStar, PiStarError
from arborist.pi_star.registry import (
    REGISTRY,
    domains,
    get,
    list_keys,
    register,
)


# Side-effect imports populate REGISTRY at package load time.
# Order is alphabetical for predictability. Optional-extra modules
# (algebra_symbolic, calculus_derivative — both gate on sympy) self-
# guard via a defensive `import sympy` and skip register(...) when
# absent, so a fresh checkout without the [math] extra still loads.
from arborist.pi_star import algebra_symbolic  # noqa: F401,E402
from arborist.pi_star import algebra_symbolic_simplified  # noqa: F401,E402
from arborist.pi_star import arithmetic  # noqa: F401,E402
from arborist.pi_star import calculus_derivative  # noqa: F401,E402
from arborist.pi_star import calculus_integral  # noqa: F401,E402
from arborist.pi_star import calculus_limit  # noqa: F401,E402
from arborist.pi_star import calculus_series  # noqa: F401,E402
from arborist.pi_star import claim_lattice  # noqa: F401,E402
from arborist.pi_star import code  # noqa: F401,E402
from arborist.pi_star import combinatorics  # noqa: F401,E402
from arborist.pi_star import function_sampled  # noqa: F401,E402
from arborist.pi_star import linear_algebra  # noqa: F401,E402
from arborist.pi_star import logic  # noqa: F401,E402
from arborist.pi_star import tabular  # noqa: F401,E402
from arborist.pi_star import text  # noqa: F401,E402
from arborist.pi_star import time_series  # noqa: F401,E402


__all__ = [
    "PiStar",
    "PiStarError",
    "PiStarComposition",
    "REGISTRY",
    "canonical_composition_id",
    "compose",
    "domains",
    "get",
    "list_keys",
    "register",
]
