Skip to content

Commit de12eb5

Browse files
committed
thought_loop: tick sensors/instincts/drives + evolution per cycle
1 parent 1f7e446 commit de12eb5

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/runtime/thought_loop.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,43 @@ def run_cycle(self) -> dict:
328328
if is_dream_time:
329329
result["dream"] = True
330330

331+
# --- Sprint 3: Start-of-cycle ticks ---
332+
if self._runtime is not None:
333+
# Sensors tick
334+
if hasattr(self._runtime, 'sensors'):
335+
try:
336+
self._runtime.sensors.tick()
337+
except Exception as exc:
338+
logger.debug("Sensors tick error: %s", exc)
339+
340+
# Instinct evaluation
341+
if hasattr(self._runtime, 'instinct_executor'):
342+
try:
343+
state_snapshot = self.state.snapshot()
344+
instinct_results = self._runtime.instinct_executor.evaluate(state_snapshot)
345+
if instinct_results:
346+
result["instincts_fired"] = [r["instinct"] for r in instinct_results]
347+
# Broadcast instinct firings via AURA
348+
if hasattr(self._runtime, 'aura'):
349+
for ir in instinct_results:
350+
if ir.get("aura_broadcast"):
351+
try:
352+
self._runtime.aura.broadcast(
353+
ir["aura_broadcast"].get("kind", "instinct"),
354+
ir["aura_broadcast"].get("payload", {}),
355+
)
356+
except Exception:
357+
pass
358+
except Exception as exc:
359+
logger.debug("Instinct evaluation error: %s", exc)
360+
361+
# DriveEngine tick
362+
if hasattr(self._runtime, 'drive_engine'):
363+
try:
364+
self._runtime.drive_engine.tick()
365+
except Exception as exc:
366+
logger.debug("DriveEngine tick error: %s", exc)
367+
331368
# --- Reflect (every cycle) ---
332369
insight = self._reflect(dream_mode=is_dream_time)
333370
if insight:
@@ -436,6 +473,13 @@ def run_cycle(self) -> dict:
436473
except Exception as exc:
437474
logger.debug("Non-productive drive resolution error: %s", exc)
438475

476+
# --- Sprint 3: End-of-cycle tick ---
477+
if self._runtime is not None and hasattr(self._runtime, 'evolution'):
478+
try:
479+
self._runtime.evolution.tick()
480+
except Exception as exc:
481+
logger.debug("Evolution tick error: %s", exc)
482+
439483
self._cycle_count += 1
440484
self._cycles_completed += 1
441485

0 commit comments

Comments
 (0)