"""Memory-root: lifelong-learning audit summary (ticket #000017).

Distinct from per-cache_key providence answers and per-event audit
chain — ``memory_root`` is a periodic, deterministic projection over
``audit_events`` that summarizes recurring failure motifs, accepted
corrections, and other cross-query state.

Hierarchical layout (per ticket #000017 §2.1):

- One ``memory_records`` row per snapshot, with ``memory_root``
  derived from the canonical body bytes.
- Multiple ``memory_branch_summaries`` rows per snapshot, one per
  named branch (e.g., ``failure-motif:title-mismatch``,
  ``failure-motif:warrant-missing``).

Each branch's ``summary_blob`` is a deterministic projection of a
slice of ``audit_events``; the projection rule is committed by
canonical-JSON-hashing it as part of the branch summary's preimage.

Public surface:

- :func:`snapshot` — build a memory_root + branch summaries from
  current store state.
- :func:`store_snapshot` — persist snapshot + emit
  ``memory_snapshot_landed`` audit event.
- :func:`falsify` / :func:`mark_stale` — state transitions.
- :func:`load` / :func:`latest` / :func:`branches_for` — read APIs.
"""

from __future__ import annotations

from arborist.memory.canonical import (
    SCHEMA_VERSION,
    BranchSummary,
    MemorySnapshot,
    branch_digest,
    canonical_branches_blob,
    memory_root,
)
from arborist.memory.falsify import falsify, mark_stale
from arborist.memory.snapshot import snapshot
from arborist.memory.store import branches_for, latest, load, store_snapshot

__all__ = [
    "SCHEMA_VERSION",
    "BranchSummary",
    "MemorySnapshot",
    "branch_digest",
    "canonical_branches_blob",
    "memory_root",
    "snapshot",
    "store_snapshot",
    "falsify",
    "mark_stale",
    "load",
    "latest",
    "branches_for",
]
