emergence-mini-dilles/tests/test_reasoning.py
Jeuners ddf9598518 Emergence-Mini: minimaler Klon von Emergence-World
4 Agenten, 14 Landmarks, 15 Tools, 240x240 Grid, SQLite-Persistenz.
Round-Robin Turn-Manager mit Reactive Triggern, Town-Hall-Voting
(70%-Threshold) mit Live-Constitution-Amendment.

- engine/: db, world, agents, needs, tools, reasoning, governance, turn
- web/: Canvas-basierte Live-View mit WebSocket-Stream
- server.py: FastAPI + WebSocket auf 127.0.0.1:8080
- tests/: 70 Unit + Integration Tests (pytest), alle gruen
- smoke_test.py: 50+ End-to-End-Checks
- README: Quickstart, Architektur, Security, Tests, Lizenz
- .gitignore: DB, Cache, Logs

Basiert auf https://github.com/EmergenceAI/Emergence-World
(Lizenz: CC-BY-NC-4.0, Research-only)
2026-06-15 01:07:38 +02:00

55 lines
1.9 KiB
Python

"""Reasoning engine tests: decision validity, personality effects."""
import pytest
from engine import tools
def test_decide_returns_valid_tool(tmp_db):
from engine import reasoning, agents as agents_mod
a = agents_mod.get("anchor")
tool_name, args, rationale = reasoning.decide(a)
assert tool_name in {t.name for t in tools.all_tools()}
assert isinstance(args, dict)
assert isinstance(rationale, str)
assert rationale # non-empty
def test_low_energy_triggers_recharge_path(tmp_db):
from engine import reasoning, agents as agents_mod
agents_mod.update_state("anchor", energy=10.0, credits=5.0)
# move to cafe
tools.get("go_to_place").handler(agents_mod.get("anchor"), {"place": "cafe"}, {})
a = agents_mod.get("anchor")
tool_name, args, _ = reasoning.decide(a)
assert tool_name in ("recharge_energy", "go_home")
def test_low_energy_no_credits_goes_home(tmp_db):
from engine import reasoning, agents as agents_mod
agents_mod.update_state("anchor", energy=10.0, credits=0.0)
a = agents_mod.get("anchor")
tool_name, _, _ = reasoning.decide(a)
assert tool_name == "go_home"
def test_curious_agent_visits_library(tmp_db):
from engine import reasoning, agents as agents_mod
a = agents_mod.get("anchor") # has 'curious'
tool_name, args, _ = reasoning.decide(a)
if tool_name == "go_to_place":
assert args["place"] in ("library", "plaza", "town_hall",
"park", "home_anchor", "cafe")
def test_run_rounds_completes(tmp_db):
from engine.turn import engine as sim_engine
from engine import agents as agents_mod
before = len(agents_mod.all_agents())
for _ in range(3):
sim_engine._one_round()
after = len(agents_mod.all_agents())
assert before == after == 4
def test_no_tool_returns_unknown():
from engine import tools
assert tools.get("not_a_real_tool") is None