Testing and Validation
Validation uses a mix of automated test scripts and manual operational checks.
| Script | Purpose | Dependencies |
|---|---|---|
test_database.py | Repository CRUD operations. | SQLite. |
test_memory_manager.py | Memory extraction, filtering, deduplication. | SQLite, extractor rules. |
test_response_generator_memory_integration.py | LLM response to memory extraction to prompt injection. | LLM provider, memory system. |
test_local_command_db.py | Database-backed local command parsing. | SQLite, local command phrases. |
test_persona_command_parser.py | Personality parameter parsing. | Database personality aliases. |
test_runtime_state.py | Runtime state transitions. | RuntimeState. |
test_concurrency_guards.py | Duplicate transcript guard, duplicate TTS guard. | RuntimeState guards. |
test_tts_pipeline.py | TTS listener returns quickly; speaking in background. | TTSPipeline, Piper, aplay. |
test_event_bus_metrics.py | Event bus metrics under normal, timeout, and error listeners. | AsyncEventBus. |
priority_test.py | Priority queue ordering, FIFO, starvation, overflow. | AsyncEventBus. |
critical_event_test.py | Critical priority dispatch during background flood. | AsyncEventBus. |
stress_test.py | High-volume async event bus. | AsyncEventBus. |
Running Tests
python -m cosmo.tests.test_database
python -m cosmo.tests.test_memory_manager
python -m cosmo.tests.test_memory_filter
python -m cosmo.tests.test_response_generator_memory_integration
python -m cosmo.tests.test_local_command_db
python -m cosmo.tests.test_local_status_command
python -m cosmo.tests.test_local_memory_commands
python -m cosmo.tests.test_persona_command_parser
python -m cosmo.tests.test_persona_command_integration
python -m cosmo.tests.test_persona_persistance
python -m cosmo.tests.priority_test
python -m cosmo.tests.critical_event_test
python -m cosmo.tests.stress_test Vision Validation Commands
python -m py_compile \
vision/analysis/vision_analyzer.py \
vision/detection/face_detector.py \
vision/camera/camera_manager.py \
data/diagnostics/diagnostics_manager.py python - <<'PY'
from cosmo.vision.camera.camera_manager import camera_manager
frame = camera_manager.capture_frame()
snapshot = camera_manager.snapshot()
print("frame:", frame is not None)
print("quality:", snapshot.get("image_quality"))
print("metrics:", snapshot.get("image_metrics"))
print("face_detection:", snapshot.get("face_detection"))
PY curl -N "http://127.0.0.1:8765/api/status/stream" | head -n 3 curl "http://127.0.0.1:8765/api/vision/snapshot" --output /tmp/cosmo-vision.jpg
file /tmp/cosmo-vision.jpg Manual Vision Checks
- Dark room or covered camera: expect
image_qualityunusable_darkandface_count0. - Strong light behind the subject: expect
backlit,high_contrast, orpartially_overexposedclassifications depending on the frame. - Face close to camera: expect
face_count >= 1when image quality allows detection. - Face far from camera: inspect
raw_faces, acceptedfaces, andrejected_faces. - False positives: inspect
raw_face_count,filtered_out_count,rejected_faces, andfilter_reason.
Operational Validation Commands
curl http://127.0.0.1:8765/api/status/compact | jq .
curl -N "http://127.0.0.1:8765/api/status/stream" | head -n 3
curl http://127.0.0.1:8765/api/vision/snapshot --output /tmp/cosmo-vision.jpg
curl http://127.0.0.1:8765/api/memories?limit=10 | jq .
curl http://127.0.0.1:8765/api/conversations?limit=10 | jq .
curl http://127.0.0.1:8765/api/events?limit=50 | jq .
curl http://127.0.0.1:8765/api/logs?limit=50 | jq .
curl http://127.0.0.1:8765/static/css/webui.css
curl http://127.0.0.1:8765/static/js/webui.js
sqlite3 cosmo/data/database/cosmo.db "SELECT COUNT(*) as memory_count FROM memories;"
sqlite3 cosmo/data/database/cosmo.db "SELECT * FROM conversations ORDER BY timestamp DESC LIMIT 10;"
sqlite3 cosmo/data/database/cosmo.db "SELECT * FROM events ORDER BY created_at DESC LIMIT 20;"
tail -f cosmo/data/logs/cosmo.log | grep -E "ERROR|CRITICAL|listener_timeout"
ps aux --sort=-%mem | head -10
ps aux --sort=-%cpu | head -10
ps -L -p $PID -o pid,tid,pcpu,pmem,comm 
