"""Prepare a serializable catalog representation (stage 050 op).

WHY:
    export.py prepares the in-memory serializable form of the built catalog --
    the {count, elements[], schema} structure matching the declared catalog's
    shape, so a later stage can write it if/when generated-export emission is
    in scope.

OBS (CRITICAL boundary):
    This op does NOT write files. It does not create or touch
    data/export/elements/ or any generated artifact on disk. Despite the name
    "export", stage 050 owns catalog *preparation*, not export *emission*.
    Writing generated artifacts is deferred to a later stage; folding it in
    here would breach the source/export separation the pipeline maintains.

OBS:
    Returning a plain dict (not writing it) keeps the stage pure and testable,
    and leaves the serialization format owned in one place (the model's
    serializable()), so a later writer stage consumes a single canonical form.
"""

from accountable_record.stage_050_catalog.model import Catalog


def prepare_serializable_catalog(catalog: Catalog) -> dict[str, object]:
    """Return the in-memory serializable representation of the catalog.

    Args:
        catalog: The built catalog.

    Returns:
        A dict of shape {count, elements[], schema}. NOT written to disk by
        this stage.
    """
    return catalog.serializable()
