| import asyncio
|
| import sys
|
| import os
|
| import json
|
| import logging
|
| from datetime import datetime
|
|
|
|
|
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
| from mnemocore.core.async_storage import AsyncRedisStorage
|
| from mnemocore.subconscious.daemon import SubconsciousDaemon
|
| from mnemocore.core.config import get_config
|
|
|
|
|
| logging.basicConfig(level=logging.INFO)
|
| logger = logging.getLogger("repro_sync")
|
|
|
| async def test_receive_event():
|
|
|
| storage = AsyncRedisStorage.get_instance()
|
| if not await storage.check_health():
|
| logger.error("Redis not available. Cannot run reproduction.")
|
| return
|
|
|
|
|
| daemon = SubconsciousDaemon()
|
| daemon.storage = storage
|
|
|
|
|
| test_id = f"mem_test_{int(datetime.now().timestamp())}"
|
| test_payload = {
|
| "id": test_id,
|
| "content": "Test memory for synchronization",
|
| "metadata": {"source": "repro_script"},
|
| "ltp_strength": 0.5,
|
| "created_at": datetime.now().isoformat()
|
| }
|
|
|
| logger.info(f"Simulating API: Publishing memory.created for {test_id}")
|
| await storage.store_memory(test_id, test_payload)
|
| await storage.publish_event("memory.created", {"id": test_id})
|
|
|
|
|
|
|
|
|
|
|
|
|
| await asyncio.sleep(2)
|
|
|
| if test_id in daemon.engine.tier_manager.hot:
|
| logger.info("SUCCESS: Daemon received the memory!")
|
| else:
|
| logger.error("FAILURE: Daemon did NOT receive the memory.")
|
|
|
|
|
| await storage.delete_memory(test_id)
|
| await storage.close()
|
|
|
| if __name__ == "__main__":
|
| asyncio.run(test_receive_event())
|
|
|