Coverage for core / platform / __init__.py: 44.4%

18 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-12 04:49 +0000

1""" 

2HART OS Platform Layer — Durable, extensible OS substrate. 

3 

4Provides the foundational abstractions that unify all HART OS subsystems: 

5- ServiceRegistry: Typed, lazy-loaded service container (replaces ad-hoc singletons) 

6- PlatformConfig: 3-layer config resolution (env > DB > defaults) 

7- EventBus: Topic-based pub/sub for decoupled communication 

8- AppManifest: Universal manifest schema for all app types 

9- AppRegistry: Discovery + lifecycle for panels, desktop apps, agents, extensions 

10- ExtensionRegistry: Platform-wide plugin system with hot-reload 

11 

12Namespace lives under core/ (alongside config_cache, circuit_breaker, event_loop) 

13to avoid collision with Python's stdlib `platform` module. 

14 

15Imports are lazy to allow each module to be used independently. 

16""" 

17 

18 

19def __getattr__(name): 

20 """Lazy imports — modules loaded on first access, not at import time.""" 

21 if name in ('ServiceRegistry', 'get_registry', 'reset_registry'): 

22 from core.platform.registry import ServiceRegistry, get_registry, reset_registry 

23 return {'ServiceRegistry': ServiceRegistry, 'get_registry': get_registry, 

24 'reset_registry': reset_registry}[name] 

25 if name == 'PlatformConfig': 

26 from core.platform.config import PlatformConfig 

27 return PlatformConfig 

28 if name == 'EventBus': 

29 from core.platform.events import EventBus 

30 return EventBus 

31 if name in ('AppManifest', 'AppType'): 

32 from core.platform.app_manifest import AppManifest, AppType 

33 return {'AppManifest': AppManifest, 'AppType': AppType}[name] 

34 if name == 'AppRegistry': 

35 from core.platform.app_registry import AppRegistry 

36 return AppRegistry 

37 raise AttributeError(f"module 'core.platform' has no attribute {name!r}") 

38 

39 

40__all__ = [ 

41 'ServiceRegistry', 

42 'get_registry', 

43 'reset_registry', 

44 'PlatformConfig', 

45 'EventBus', 

46 'AppManifest', 

47 'AppType', 

48 'AppRegistry', 

49]