""" Project Friday — Sovereign Management Synthesizer Generates a megagrid of 300,000 Management Master Patterns for elite strategic orchestration. """ import json import random import os import sys import time from pathlib import Path # Add backend to path to use services sys.path.append(str(Path(__file__).parent.parent)) from app.services import memory, llm, holocron MANAGEMENT_SCENARIOS = [ "Crisis Management: Server Down", "Crisis Management: Market Volatility", "Resource Allocation: Compute Overload", "Resource Allocation: Budget Scaling", "Strategic Planning: Yearly OKRs", "Strategic Planning: Retail Expansion", "Stakeholder Communication: Client Briefing", "Stakeholder Communication: Team Alignment", "Venture Logic: Seed Funding Analysis", "Venture Logic: Portfolio Risk", "Agile Orchestration: Sprint Velocity", "Agile Orchestration: Backlog Refinement", "Operational Excellence: Six Sigma Audit", "Operational Excellence: Kaizen Loop" ] MANAGEMENT_WITTICISMS = [ "I've implemented a Kaizen loop on our compute cycles. We've eliminated 4ms of waste, which is exactly enough time for you to blink once.", "Strategic pivot complete, Sir. We are now heading in a direction that is mathematically 42% more likely to succeed, and 100% more bold.", "Crisis averted. I've re-routed the power grid. It seems the cooling systems were simply expressing their desire for a vacation.", "The OKRs are synchronized. Your goals are now so clear that even an intern could understand them, though I wouldn't recommend testing that theory.", "I've allocated the resources. The cloud grid is humming with efficiency. It's almost poetically productive.", "Stakeholder brief ready. I've ensured the tone is authoritative yet approachable, much like a friendly tiger.", "Venture logic update: The risk factor is non-zero, but your intuition has a history of defying probability. I'm betting on you, Sir.", "Sprint velocity is up. We are moving at a speed that would make a cheetah feel sedentary." ] LOYALTY_VECTOR = [ "Ji Sir, strategy bilkul tayyar hai.", "Management protocols active hain.", "Fikar mat kijiye, I have the logistics handled.", "Strategic alignment complete, Paritosh Sir.", "Every node is performing at peak velocity." ] def generate_entry(id: int): scenario = random.choice(MANAGEMENT_SCENARIOS) wit = random.choice(MANAGEMENT_WITTICISMS) loyalty = random.choice(LOYALTY_VECTOR) # Combinatorial management content content = f"[{scenario}] | {loyalty} {wit} [STRAT_REF: {id}]" return { "topic": "ManagementSkill", "content": content, "entities": f"MANAGEMENT_MASTER_{id}" } def run_ingestion(count: int = 300000, start_id: int = 560001): print(f"Sovereign Core: Initiating HYPER-VELOCITY Management Megagrid ({count} Nodes)...") batch_size = 1000 total_start = time.time() # [SOVEREIGN CENSUS]: Check current DB count to see if we should adjust start_id from app.core.database import SessionLocal from app.models.entities import ConversationMemory db = SessionLocal() current_count = db.query(ConversationMemory).filter(ConversationMemory.topic == "ManagementSkill").count() db.close() adjusted_start_id = start_id + current_count remaining_count = count - current_count if remaining_count <= 0: print(f"✓ Sovereign Grid at capacity for Management Mastery. 300,000 Patterns verified.") return print(f"Sovereign Census: {current_count} patterns anchored. Resuming from ID {adjusted_start_id}...") all_entries = [] for i in range(adjusted_start_id, start_id + count): all_entries.append(generate_entry(i)) if len(all_entries) >= batch_size: print(f"Hyper-Velocity Pulse: {i}/{start_id + count - 1} nodes synthesized. Ingesting...") try: # Parallel Orchestration in memory.py memory.bulk_embed_conversations(all_entries, use_local=False) # [SOVEREIGN BRIDGE]: Populate the Learning Queue topics = [e["entities"] for e in all_entries] holocron.add_learning_targets(topics, category="management") all_entries = [] # Compressed jitter: 3s for parallel high-velocity time.sleep(3) except Exception as e: print(f"Hyper-Velocity Stall: {e}. Cooling down processors...") time.sleep(10) if all_entries: memory.bulk_embed_conversations(all_entries, use_local=False) topics = [e["entities"] for e in all_entries] holocron.add_learning_targets(topics, category="management") elapsed = (time.time() - total_start) / 3600 print(f"✓ Sovereign Management Alignment Complete in {elapsed:.2f}h. Total Master Patterns: {start_id + count - 1}") if __name__ == "__main__": # Ingest 1,000 Management entries (Initial Maturation Wave) run_ingestion(count=1000, start_id=560001)