Initial commit: Context Manager v1.0.0

Sistema local de gestión de contexto para IA:
- Log inmutable (blockchain-style)
- Algoritmos versionados y mejorables
- Agnóstico al modelo (Anthropic, OpenAI, Ollama)
- Sistema de métricas y A/B testing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
ARCHITECT
2025-12-29 18:55:27 +00:00
commit 6ab93d3485
19 changed files with 4253 additions and 0 deletions

39
schemas/00_base.sql Normal file
View File

@@ -0,0 +1,39 @@
-- ============================================
-- CONTEXT MANAGER - BASE TYPES
-- Sistema local de gestión de contexto para IA
-- ============================================
-- Extension para UUIDs
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
-- ============================================
-- TIPOS ENUMERADOS
-- ============================================
CREATE TYPE mensaje_role AS ENUM ('user', 'assistant', 'system', 'tool');
CREATE TYPE context_source AS ENUM ('memory', 'knowledge', 'history', 'ambient', 'dataset');
CREATE TYPE algorithm_status AS ENUM ('draft', 'testing', 'active', 'deprecated');
CREATE TYPE metric_type AS ENUM ('relevance', 'token_efficiency', 'response_quality', 'latency');
-- ============================================
-- FUNCIÓN: Timestamp de actualización
-- ============================================
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = CURRENT_TIMESTAMP;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- ============================================
-- FUNCIÓN: Hash SHA-256
-- ============================================
CREATE OR REPLACE FUNCTION sha256_hash(content TEXT)
RETURNS VARCHAR(64) AS $$
BEGIN
RETURN encode(digest(content, 'sha256'), 'hex');
END;
$$ LANGUAGE plpgsql IMMUTABLE;