# ============================================================
# src/accountable_record/stage_070_resolution/verify.py
# ============================================================
"""Verify stage 070 lock/export structural parity.

WHY:
    Stage 070 verifies that locked element ids and exported element ids agree.
    This is structural parity only: it does not recompute digests and does not
    validate generated artifact freshness.

OBS:
    The comparison is element-scoped. Package lock records are not compared to
    exports here.
"""

from accountable_record.stage_060_exports.model import ExportsArtifact
from accountable_record.stage_070_resolution.model import (
    ElementsLock,
    LockExportReconciliation,
)

__all__ = ["reconcile_lock_with_exports"]


def reconcile_lock_with_exports(
    lock: ElementsLock,
    exports: ExportsArtifact,
) -> LockExportReconciliation:
    """Reconcile locked elements against exported element artifacts.

    WHY: s070 verifies that every locked element has the generated export
    artifact its digest target refers to. It does not require every exported
    element to be locked.
    """
    locked_element_ids = lock.element_ids()
    exported_element_ids = exports.registry.compact_ids()

    return LockExportReconciliation(
        lock_missing_export=tuple(sorted(locked_element_ids - exported_element_ids)),
    )
