refactor: Separate runtime from build. Enhance configuration and registry management, migrate to registry-based component handling

This commit is contained in:
2026-02-22 23:19:16 -08:00
parent 033a76ccfd
commit d52d8829ba
37 changed files with 1271 additions and 414 deletions

View File

@@ -4,11 +4,13 @@ from pathlib import Path
from pydantic_settings import BaseSettings
from castle_core.config import CastleConfig, load_config
from castle_core.registry import NodeRegistry, load_registry
class Settings(BaseSettings):
"""Service settings loaded from environment variables."""
castle_root: Path = Path("/data/repos/castle")
host: str = "0.0.0.0"
port: int = 9020
@@ -19,3 +21,32 @@ class Settings(BaseSettings):
settings = Settings()
def get_registry() -> NodeRegistry:
"""Load the node registry. Raises if not found."""
return load_registry()
def get_castle_root() -> Path | None:
"""Get the castle repo root from the registry, if available."""
try:
registry = load_registry()
if registry.node.castle_root:
return Path(registry.node.castle_root)
except (FileNotFoundError, ValueError):
pass
return None
def get_config() -> CastleConfig:
"""Load castle.yaml via the registry's castle_root.
Raises FileNotFoundError if repo not available.
"""
root = get_castle_root()
if root is None:
raise FileNotFoundError(
"Castle repo not available. Set castle_root in registry."
)
return load_config(root)