import json
from datetime import datetime
from pathlib import Path

class DecisionTracker:
    """
    Genesis Decision Tracker.
    Captures strategic pivots and design choices for RLM storage.
    """
    def __init__(self, rlm_bridge):
        self.rlm = rlm_bridge

    def track(self, decision_id: str, rationale: str, impact: str, status: str = "COMPLETED"):
        """Record a decision in the Knowledge Graph."""
        print(f"⚖️ [DECISION] {decision_id}: {rationale[:50]}...")
        
        observations = [
            f"Rationale: {rationale}",
            f"Impact: {impact}",
            f"Status: {status}",
            f"Timestamp: {datetime.now().isoformat()}"
        ]
        
        self.rlm.store(
            name=f"DECISION_{decision_id}",
            entity_type="DECISION",
            observations=observations
        )
        
        # Link to general 'GENESIS_EVOLUTION' node
        self.rlm.create_relation(f"DECISION_{decision_id}", "is_part_of", "GENESIS_EVOLUTION")
        
        return True

if __name__ == "__main__":
    # Test
    from rlm_bridge import RLMBridge
    bridge = RLMBridge()
    tracker = DecisionTracker(bridge)
    tracker.track("RLM_SWITCH", "User requested Relational Semantic Memory instead of file-based", "Improved query speed and context depth")
