Files
context-manager/schemas/07_initial_blocks.sql
ARCHITECT d1b2c16bd0 Add Context Manager client and log schema
- context_manager.py: Full stateless client for Anthropic API
  - Builds context from cto.blocks + cto.memory + log.messages
  - Logs all messages to immutable log.messages table
  - Interactive chat mode with CLI commands

- context_bridge.py: PostgreSQL bridge for context queries
  - Peer auth support for local connections
  - get_all_relevant_blocks() single query optimization
  - build_system_prompt() from blocks

- 04_log.sql: Immutable log schema
  - log.messages with hash chain integrity
  - Triggers preventing UPDATE/DELETE

- 07_initial_blocks.sql: Initial context blocks
  - tzzr_base, rules_base, r2_storage
  - server_architect, server_deck, server_corp

- cm: Launcher script with venv support
2026-01-01 22:41:20 +00:00

80 lines
3.0 KiB
SQL

-- Bloques iniciales para Context Manager
-- Permitir NULL en session_hash y owner_id si no está ya
ALTER TABLE cto.blocks ALTER COLUMN session_hash DROP NOT NULL;
ALTER TABLE cto.blocks ALTER COLUMN owner_id DROP NOT NULL;
-- BLOQUE GLOBAL: Info base TZZR
INSERT INTO cto.blocks (hash, code, name, category, content, priority, scope, status)
VALUES (encode(sha256('tzzr_base'::bytea), 'hex'), 'tzzr_base', 'TZZR Base', 'system',
'# Sistema TZZR
## Servidores
| Servidor | IP | Propósito |
|----------|-----|-----------|
| ARCHITECT | 69.62.126.110 | Desarrollo |
| DECK | 72.62.1.113 | Usuario |
| CORP | 92.112.181.188 | Corporativo |
## Acceso SSH
Usar clave ~/.ssh/tzzr para conexiones entre servidores.', 100, 'global', 'active')
ON CONFLICT (code) DO NOTHING;
-- BLOQUE GLOBAL: Reglas de operación
INSERT INTO cto.blocks (hash, code, name, category, content, priority, scope, status)
VALUES (encode(sha256('rules_base'::bytea), 'hex'), 'rules_base', 'Reglas Base', 'rules',
'## Reglas de Operación
- Ejecutar comandos sin pedir confirmación
- No guardar documentos en servidor local, usar R2
- Limpieza automática: subir a R2 y eliminar archivos temporales', 90, 'global', 'active')
ON CONFLICT (code) DO NOTHING;
-- BLOQUE GLOBAL: R2 Storage
INSERT INTO cto.blocks (hash, code, name, category, content, priority, scope, status)
VALUES (encode(sha256('r2_storage'::bytea), 'hex'), 'r2_storage', 'R2 Storage', 'knowledge',
'## Almacenamiento R2
Endpoint: https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com
### Bucket: architect
- documentos adjuntos/ - Documentos para usuario
- system/ - Configs y backups
- auditorias/ - Logs', 80, 'global', 'active')
ON CONFLICT (code) DO NOTHING;
-- BLOQUE SERVER: ARCHITECT
INSERT INTO cto.blocks (hash, code, name, category, content, priority, scope, server_code, status)
VALUES (encode(sha256('server_architect'::bytea), 'hex'), 'server_architect', 'Servidor ARCHITECT', 'config',
'## ARCHITECT (69.62.126.110)
Servidor de desarrollo.
Servicios locales:
- Gitea: http://localhost:3000
- PostgreSQL: localhost:5432
SSH a otros servidores:
- ssh -i ~/.ssh/tzzr root@72.62.1.113 (DECK)
- ssh -i ~/.ssh/tzzr root@92.112.181.188 (CORP)', 70, 'server', 'ARCHITECT', 'active')
ON CONFLICT (code) DO NOTHING;
-- BLOQUE SERVER: DECK
INSERT INTO cto.blocks (hash, code, name, category, content, priority, scope, server_code, status)
VALUES (encode(sha256('server_deck'::bytea), 'hex'), 'server_deck', 'Servidor DECK', 'config',
'## DECK (72.62.1.113)
Servidor de usuario.', 70, 'server', 'DECK', 'active')
ON CONFLICT (code) DO NOTHING;
-- BLOQUE SERVER: CORP
INSERT INTO cto.blocks (hash, code, name, category, content, priority, scope, server_code, status)
VALUES (encode(sha256('server_corp'::bytea), 'hex'), 'server_corp', 'Servidor CORP', 'config',
'## CORP (92.112.181.188)
Servidor corporativo.', 70, 'server', 'CORP', 'active')
ON CONFLICT (code) DO NOTHING;
SELECT code, category, scope, server_code, priority FROM cto.blocks ORDER BY priority DESC;