| """ |
| Project Friday — Master Learning Queue Flush |
| Bridges existing ConversationMemory patterns into the LearningTarget queue for high-velocity maturation. |
| """ |
| import sys |
| import os |
| from pathlib import Path |
| import logging |
|
|
| |
| sys.path.append(os.path.join(os.getcwd(), "backend")) |
|
|
| from app.core import database |
| from app.models.entities import ConversationMemory |
| from app.services import holocron |
|
|
| logging.basicConfig(level=logging.INFO, format="%(asctime)s | FLUSH | %(message)s") |
| logger = logging.getLogger("friday.flush") |
|
|
| def flush_memory_to_queue(): |
| """Converts 310,000+ memory patterns into formal learning targets.""" |
| logger.info("Initializing Master Queue Sync...") |
| |
| with database.SessionLocal() as db: |
| |
| logger.info("Scanning for unqueued mandates in memory store...") |
| |
| |
| |
| |
| |
| for category, target_type in [("ManagementSkill", "management"), ("PersonalityExample", "personality")]: |
| logger.info(f"Processing category: {category} -> {target_type}") |
| |
| |
| batch_size = 5000 |
| offset = 0 |
| |
| while True: |
| mem_items = db.query(ConversationMemory.entities)\ |
| .filter_by(topic=category)\ |
| .offset(offset).limit(batch_size).all() |
| |
| if not mem_items: break |
| |
| topics = [m.entities for m in mem_items] |
| holocron.add_learning_targets(topics, category=target_type) |
| |
| offset += batch_size |
| logger.info(f"Synchronized {offset} patterns for {target_type}...") |
| |
| logger.info("✓ Master Learning Queue Flush Complete.") |
|
|
| if __name__ == "__main__": |
| flush_memory_to_queue() |
|
|