"""The locked GLM-5.2 Max alpha target: identity, resource plan, and acceptance contract.

Three files, three jobs:

- :mod:`~meshnet_node.glm_alpha.manifest` — *is this the exact artifact?* Pinned
  repository revisions, six shard digests, and the architecture-critical config
  snapshot they must agree with.
- :mod:`~meshnet_node.glm_alpha.planner` — *can this route hold it?* Deterministic
  memory, KV, and seam arithmetic over the exact artifact bytes, counting unified
  memory once.
- :mod:`~meshnet_node.glm_alpha.contract` — *what would have counted as success?*
  The acceptance thresholds, locked before the target runs and digest-bound so a
  later change cannot be silent.

Nothing here downloads, loads, or executes a model. This package is the contract
DGR-018, DGR-019, and DGR-020 are judged against.
"""

from __future__ import annotations

from .contract import (
    ALPHA_CONTRACT_ID,
    ALPHA_CONTRACT_SCHEMA_VERSION,
    VERDICT_ALPHA,
    VERDICT_STOP,
    AlphaContract,
    AlphaContractError,
    compute_contract_digest,
    load_alpha_contract,
    parse_alpha_contract,
    require_contract_target,
    seal_contract,
)
from .manifest import (
    ALPHA_QUANTIZATION,
    ALPHA_SHARD_COUNT,
    ArchitectureSnapshot,
    GlmTargetError,
    Shard,
    TargetManifest,
    canonical_sha256,
    load_architecture_snapshot,
    load_target_manifest,
    parse_architecture_snapshot,
    parse_target_manifest,
    require_pinned_target,
)
from .planner import (
    AGGREGATE_HARD_FIT_FLOOR_GIB,
    ALPHA_CONTEXT_TOKENS,
    ALPHA_KV_DTYPE,
    MIN_LINK_RATE_GBPS,
    PLACEMENT_IMBALANCE_FACTOR,
    RECOMMENDED_LINK_RATE_GBPS,
    RESERVE_FLOOR_GIB,
    RESERVE_FRACTION,
    NodeMemory,
    ResourcePlanError,
    RouteFit,
    SeamPlan,
    TopologyPlan,
    kv_bytes,
    plan_all_tiers,
    plan_route,
    plan_seams,
    plan_topology,
)


def load_locked_target() -> tuple[AlphaContract, TargetManifest, ArchitectureSnapshot]:
    """Load and cross-bind the packaged alpha contract, manifest, and snapshot."""

    contract = load_alpha_contract()
    manifest = load_target_manifest()
    snapshot = load_architecture_snapshot()
    require_contract_target(contract, manifest, snapshot)
    return contract, manifest, snapshot


__all__ = [
    "AGGREGATE_HARD_FIT_FLOOR_GIB",
    "ALPHA_CONTEXT_TOKENS",
    "ALPHA_CONTRACT_ID",
    "ALPHA_CONTRACT_SCHEMA_VERSION",
    "ALPHA_KV_DTYPE",
    "ALPHA_QUANTIZATION",
    "ALPHA_SHARD_COUNT",
    "MIN_LINK_RATE_GBPS",
    "PLACEMENT_IMBALANCE_FACTOR",
    "RECOMMENDED_LINK_RATE_GBPS",
    "RESERVE_FLOOR_GIB",
    "RESERVE_FRACTION",
    "VERDICT_ALPHA",
    "VERDICT_STOP",
    "AlphaContract",
    "AlphaContractError",
    "ArchitectureSnapshot",
    "GlmTargetError",
    "NodeMemory",
    "ResourcePlanError",
    "RouteFit",
    "SeamPlan",
    "Shard",
    "TargetManifest",
    "TopologyPlan",
    "canonical_sha256",
    "compute_contract_digest",
    "kv_bytes",
    "load_alpha_contract",
    "load_architecture_snapshot",
    "load_locked_target",
    "load_target_manifest",
    "parse_alpha_contract",
    "parse_architecture_snapshot",
    "parse_target_manifest",
    "plan_all_tiers",
    "plan_route",
    "plan_seams",
    "plan_topology",
    "require_contract_target",
    "require_pinned_target",
    "seal_contract",
]
