# 0034 — E2E: verificar skill /create-bot con robot de prueba ## Objetivo Crear un robot de prueba usando la skill `/create-bot` y escribir tests E2E con Playwright que verifiquen que el robot se creo correctamente y responde a comandos en Matrix. Esto valida el pipeline completo: scaffold → build → register → verify → comandos funcionales. ## Contexto - La skill `/create-bot` existe en `.claude/skills/create-bot/` y ejecuta `create-full.sh` + conversion a robot - Ya hay E2E tests para agentes (`assistant-bot`, `asistente-2`) en `e2e/tests/` - No hay tests que validen robots ni el pipeline de creacion de bots - Los robots solo responden a comandos (`!xxx`), no tienen LLM — los assertions pueden ser estrictos (deterministicos) - El issue 0032 hace lo mismo pero para agentes con LLM — este es el equivalente para robots ## Arquitectura ``` agents/test-bot/ NEW — robot creado por /create-bot agents/test-bot/agent.go NEW — Rules() retorna nil agents/test-bot/config.yaml NEW — config tipo robot agents/test-bot/commands.go NEW — comandos custom de prueba cmd/launcher/main.go MOD — blank import + registro de comandos custom e2e/tests/test-bot.spec.ts NEW — tests E2E del robot e2e/tests/create-bot-pipeline.spec.ts NEW — tests del pipeline de creacion ``` ### Patron pure core / impure shell - `pkg/` — sin cambios - `shell/` — sin cambios - `agents/test-bot/` — composicion: agent.go puro (nil rules) + config YAML + commands.go - `e2e/` — tests Playwright (fuera del modulo Go) ## Tareas ### Fase 1: Crear robot de prueba con /create-bot - [ ] **1.1** Ejecutar `/create-bot test-bot "Test Bot"` con los siguientes inputs: - `bot-id`: `test-bot` - `display-name`: `"Test Bot"` - `description`: `"Robot de prueba para validar el pipeline de creacion de bots"` - Comandos custom: `!echo ` (repite el texto), `!dice` (numero aleatorio 1-6) - [ ] **1.2** Verificar que `create-full.sh` completa las 4 etapas sin errores - [ ] **1.3** Verificar que el config tiene `agent.type: robot` - [ ] **1.4** Verificar que no existe `agents/test-bot/prompts/` (robots no tienen system prompt) - [ ] **1.5** Implementar los comandos custom en `agents/test-bot/commands.go`: - `!echo `: devuelve el texto tal cual (util para assertions exactas) - `!dice`: devuelve un numero aleatorio entre 1 y 6 - [ ] **1.6** Registrar comandos en `cmd/launcher/main.go` - [ ] **1.7** Verificar compilacion: `go build -tags goolm ./...` - [ ] **1.8** Arrancar y verificar que el robot responde: `./dev-scripts/server/start.sh` ### Fase 2: E2E tests del robot - [ ] **2.1** Crear `e2e/tests/test-bot.spec.ts` con los siguientes tests: - **!help funciona**: enviar `!help` → verificar que lista comandos built-in + custom (echo, dice) - **!ping funciona**: enviar `!ping` → verificar respuesta (assertion estricta) - **!echo funciona**: enviar `!echo hello world` → verificar que responde "hello world" (assertion estricta) - **!dice funciona**: enviar `!dice` → verificar que responde un numero entre 1 y 6 - **Comando desconocido**: enviar `!unknown` → verificar respuesta de error - **Mensaje normal ignorado**: enviar "hola" sin prefijo → verificar que NO responde (silencio) - **Sin errores de descifrado**: verificar `assertNoDecryptionErrors` en cada test - [ ] **2.2** Seguir el patron de los tests existentes para fixtures, imports y estructura - [ ] **2.3** Ejecutar los tests: `./dev-scripts/e2e/run.sh test-bot` ### Fase 3: E2E test del pipeline de creacion (validacion estructural) - [ ] **3.1** Crear `e2e/tests/create-bot-pipeline.spec.ts` que valide la estructura: - Verificar que `agents/test-bot/agent.go` existe y `Rules()` retorna nil - Verificar que `agents/test-bot/config.yaml` tiene `agent.type: robot` - Verificar que NO existe `agents/test-bot/prompts/system.md` - Verificar que `cmd/launcher/main.go` tiene el blank import - Verificar que `agents/test-bot/commands.go` existe - [ ] **3.2** Estos tests pueden ser scripts bash o tests Node.js — no requieren Playwright ### Fase 4: Tests - [ ] **4.1** Ejecutar suite E2E completa: `./dev-scripts/e2e/run.sh` - [ ] **4.2** Verificar que tests existentes siguen pasando (no regresion) - [ ] **4.3** Verificar build completo: `go build -tags goolm ./...` y `go test -tags goolm ./...` ### Fase 5: Cleanup y docs - [ ] **5.1** Actualizar `CLAUDE.md` tabla de agentes con `test-bot` (tipo robot) - [ ] **5.2** Documentar en `e2e/README.md` el nuevo spec y la estrategia de testing para robots ## Ejemplo de uso ``` # 1. Crear el robot con la skill > /create-bot test-bot "Test Bot" (skill ejecuta create-full.sh, convierte a robot, crea comandos) # 2. Arrancar y probar manualmente > ./dev-scripts/server/start.sh > (en Matrix) !help < Comandos disponibles: < !help — Muestra esta ayuda < !ping — Verifica conectividad < !echo — Repite el texto < !dice — Lanza un dado (1-6) > !echo hola mundo < hola mundo > !dice < 4 > hola # mensaje sin prefijo > (sin respuesta) # robot lo ignora # 3. Correr E2E > ./dev-scripts/e2e/run.sh test-bot ✓ !help lista todos los comandos (2s) ✓ !ping responde (2s) ✓ !echo repite el texto (2s) ✓ !dice devuelve numero valido (2s) ✓ comando desconocido muestra error (2s) ✓ mensaje sin prefijo es ignorado (5s) 6 passed ``` ## Decisiones de diseno - **Assertions estrictas**: a diferencia de los tests de agentes con LLM (assertions flexibles por no-determinismo), los tests de robots son 100% deterministicos. Cada comando tiene una respuesta predecible → assertions exactas. - **`!echo` como comando de prueba**: permite enviar cualquier texto y verificar que lo devuelve exactamente — ideal para debugging y assertions. - **`!dice` como comando con variabilidad**: permite testear que el bot responde algo valido dentro de un rango, sin ser deterministico exacto. - **Test de silencio**: verificar que un mensaje normal NO genera respuesta es critico para robots — asegura que el robot no intenta procesar mensajes como un agente LLM. - **Robot permanente**: el robot de prueba se queda en el repo como referencia de creacion y target permanente para E2E. ## Prerequisitos - Issue 0030 completado (Robot vs Agent separacion) ✓ - Skill `/create-bot` funcionando (en `.claude/skills/create-bot/`) - E2E infrastructure funcionando (issue 0022 completado) ✓ - Variables de entorno del homeserver configuradas ## Riesgos - **create-full.sh no soporta robots nativamente**: el script crea un agente por defecto, la skill lo convierte despues. Riesgo bajo — la conversion es solo editar config y borrar prompts. - **Timing en test de silencio**: verificar que el bot NO responde requiere esperar un timeout. Mitigacion: timeout corto (5s) ya que los robots responden en <1s. - **E2EE verification**: el robot necesita cross-signing funcional. Mitigacion: `verify.sh` ya maneja esto.