Menu

Cosmo Wiki

Testing

Testing scripts and operational validation commands.

Testing and Validation

Validation uses a mix of automated test scripts and manual operational checks.

ScriptPurposeDependencies
test_database.pyRepository CRUD operations.SQLite.
test_memory_manager.pyMemory extraction, filtering, deduplication.SQLite, extractor rules.
test_response_generator_memory_integration.pyLLM response to memory extraction to prompt injection.LLM provider, memory system.
test_local_command_db.pyDatabase-backed local command parsing.SQLite, local command phrases.
test_persona_command_parser.pyPersonality parameter parsing.Database personality aliases.
test_runtime_state.pyRuntime state transitions.RuntimeState.
test_concurrency_guards.pyDuplicate transcript guard, duplicate TTS guard.RuntimeState guards.
test_tts_pipeline.pyTTS listener returns quickly; speaking in background.TTSPipeline, Piper, aplay.
test_event_bus_metrics.pyEvent bus metrics under normal, timeout, and error listeners.AsyncEventBus.
priority_test.pyPriority queue ordering, FIFO, starvation, overflow.AsyncEventBus.
critical_event_test.pyCritical priority dispatch during background flood.AsyncEventBus.
stress_test.pyHigh-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_quality unusable_dark and face_count 0.
  • Strong light behind the subject: expect backlit, high_contrast, or partially_overexposed classifications depending on the frame.
  • Face close to camera: expect face_count >= 1 when image quality allows detection.
  • Face far from camera: inspect raw_faces, accepted faces, and rejected_faces.
  • False positives: inspect raw_face_count, filtered_out_count, rejected_faces, and filter_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