import pytest from becomingone import KAIROSTemporalEngine from becomingone.core.engine import TemporalConfig def test_engine_initialization(): config = TemporalConfig(coherence_threshold=0.95) engine = KAIROSTemporalEngine(config=config, name="test_master") # Engine should start uncollapsed with 0 coherence assert not engine._collapsed assert engine.coherence == 1.0 def test_temporalize_stream(): config = TemporalConfig(coherence_threshold=0.95, tau_scale=1.0) engine = KAIROSTemporalEngine(config=config, name="test_master") stream = ["I", "am", "the", "Master", "Transducer"] states = engine.temporalize_stream(stream) assert len(states) == len(stream) # Coherence should increase as tokens are processed assert engine.coherence > 0.0 def test_collapse_threshold(): config = TemporalConfig(coherence_threshold=0.01, tau_scale=10.0) engine = KAIROSTemporalEngine(config=config, name="test_master") # Send enough tokens to force coherence above the low threshold stream = ["test"] * 50 engine.temporalize_stream(stream) collapsed, coherence = engine.check_collapse() assert collapsed is True assert engine._collapsed is True