"""The public API is a promise: everything advertised is importable, once.""" import importlib import inspect import tiny_computer_agent as tca def test_everything_in_all_is_reachable_from_the_package_root(): missing = [name for name in tca.__all__ if not hasattr(tca, name)] assert missing == [], f"advertised but not exported: {missing}" def test_all_is_sorted_and_free_of_duplicates(): assert tca.__all__ == sorted(tca.__all__), "keep __all__ alphabetical" assert len(tca.__all__) == len(set(tca.__all__)), "no duplicate exports" def test_no_public_callable_in_a_module_is_missing_from_all(): """A capability a user cannot import is a capability they cannot use.""" modules = ["actions", "act", "observe", "perception", "brain", "models", "loop", "safety", "desktop", "demo", "trace", # 2.0: the operator layer, all of which must stay importable from the root "diff", "gates", "runner", "skills", "watchdog", "audit"] unexported = [] for name in modules: module = importlib.import_module(f"tiny_computer_agent.{name}") for attr, obj in vars(module).items(): if attr.startswith("_") or getattr(obj, "__module__", "") != module.__name__: continue if attr in tca.__all__ or attr.endswith(("Error", "Unavailable", "Violation")): continue unexported.append(f"{name}.{attr}") assert unexported == [], f"public names not exported from the package root: {unexported}" def test_the_documented_entry_points_are_callable(): for name in ["doctor", "run_checks", "display_available", "build_agent", "make_detector", "make_model_brain", "benchmark", "score"]: assert callable(getattr(tca, name)), name