"""Smoke tests for ``arborist.world`` — v7-W namespace reservation
(#000013).

This package is a namespace-only stub today (substrate paper at
``docs/_source/merkle-agi-v7w-spatial-temporal.rst``; no kernels
yet). These tests pin the reservation contract so downstream
consumers can rely on the import path being stable.
"""

from __future__ import annotations

import importlib


def test_world_namespace_imports():
    """Reservation: arborist.world loads without error."""
    mod = importlib.import_module("arborist.world")
    assert mod is not None


def test_world_namespace_reports_draft_version():
    """V7W_VERSION is the draft-version pin. Downstream consumers
    can read this to detect spec drift before a kernel ships."""
    from arborist.world import V7W_VERSION
    assert isinstance(V7W_VERSION, str)
    assert V7W_VERSION.startswith("v")


def test_world_namespace_status_is_reserved():
    """STATUS pins the namespace's lifecycle stage. Today: just
    reserved (no kernels). Becomes 'kernel_in_progress' once the
    first verifier kernel lands; 'v1' once all four ε-frontiers
    + their kernels ship."""
    from arborist.world import STATUS
    assert STATUS == "namespace_reserved"


def test_world_namespace_exports_only_metadata():
    """Stub contract: nothing but metadata. No kernels, no sources,
    no public-API surface yet. __all__ pins this."""
    import arborist.world as world
    assert set(world.__all__) == {"V7W_VERSION", "STATUS"}


def test_substrate_paper_lands_alongside_namespace():
    """Closure-criterion guard for #000013: the substrate paper
    must exist alongside the namespace stub. Future maintainers
    that delete one without the other break the ticket's closure
    contract."""
    from pathlib import Path
    repo_root = Path(__file__).resolve().parent.parent
    paper = repo_root / "docs" / "_source" / "merkle-agi-v7w-spatial-temporal.rst"
    catalog = repo_root / "docs" / "v7w-frontier-catalog.md"
    assert paper.is_file(), f"missing substrate paper at {paper}"
    assert catalog.is_file(), f"missing frontier catalog at {catalog}"
