mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-30 10:52:15 +00:00
Complete implementation across six development phases (v0.1 through v1.0): - Core: Registry system, config, event bus, types (Phase 0) - Intelligence + Inference: Model routing, Ollama/vLLM/llama.cpp/Cloud engines (Phase 1) - Memory: SQLite/FAISS/ColBERT/BM25/Hybrid backends, document ingest, context injection (Phase 2) - Agents: Simple/Orchestrator/Custom/OpenClaw agents, tool system (Phase 3) - Learning: HeuristicRouter, reward functions, GRPO stub, telemetry aggregation (Phase 4) - SDK: Jarvis class, OpenClaw protocol/transport, benchmarks, Docker deployment (Phase 5) 520 tests passing, 8 skipped (optional deps). Ruff lint clean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
"""Tests for LearningConfig and its integration into JarvisConfig."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from openjarvis.core.config import (
|
|
HardwareInfo,
|
|
JarvisConfig,
|
|
LearningConfig,
|
|
generate_default_toml,
|
|
load_config,
|
|
)
|
|
|
|
|
|
class TestLearningConfig:
|
|
def test_defaults(self) -> None:
|
|
cfg = LearningConfig()
|
|
assert cfg.default_policy == "heuristic"
|
|
assert cfg.reward_weights == ""
|
|
|
|
def test_custom_values(self) -> None:
|
|
cfg = LearningConfig(
|
|
default_policy="grpo",
|
|
reward_weights="latency=0.4,cost=0.3,efficiency=0.3",
|
|
)
|
|
assert cfg.default_policy == "grpo"
|
|
assert cfg.reward_weights == "latency=0.4,cost=0.3,efficiency=0.3"
|
|
|
|
def test_jarvis_config_has_learning(self) -> None:
|
|
cfg = JarvisConfig()
|
|
assert hasattr(cfg, "learning")
|
|
assert isinstance(cfg.learning, LearningConfig)
|
|
assert cfg.learning.default_policy == "heuristic"
|
|
|
|
def test_toml_loading_with_learning(self, tmp_path: Path) -> None:
|
|
toml_file = tmp_path / "config.toml"
|
|
toml_file.write_text(
|
|
'[learning]\ndefault_policy = "grpo"\n'
|
|
'reward_weights = "latency=0.5"\n'
|
|
)
|
|
cfg = load_config(toml_file)
|
|
assert cfg.learning.default_policy == "grpo"
|
|
assert cfg.learning.reward_weights == "latency=0.5"
|
|
|
|
def test_toml_loading_without_learning(self, tmp_path: Path) -> None:
|
|
toml_file = tmp_path / "config.toml"
|
|
toml_file.write_text("[engine]\n")
|
|
cfg = load_config(toml_file)
|
|
assert cfg.learning.default_policy == "heuristic"
|
|
|
|
def test_generate_default_toml_includes_learning(self) -> None:
|
|
hw = HardwareInfo()
|
|
toml_str = generate_default_toml(hw)
|
|
assert "[learning]" in toml_str
|
|
assert 'default_policy = "heuristic"' in toml_str
|