2.3 KiB
2.3 KiB
Experience Bus Phase-2 (Lessons Extractor)
Scope
- Source stream:
EXPERIENCE - Source subjects:
agent.experience.v1.> - Consumer mode: durable pull + explicit ack
- Output table:
agent_lessons(append-only) - Output subject:
agent.lesson.v1(optional publish)
Service
- Container:
dagi-experience-learner-node1 - Endpoint:
GET /healthGET /metrics
Environment
NATS_URL=nats://nats:4222EXPERIENCE_STREAM_NAME=EXPERIENCEEXPERIENCE_SUBJECT=agent.experience.v1.>EXPERIENCE_DURABLE=experience-learner-v1EXPERIENCE_ACK_WAIT_SECONDS=30EXPERIENCE_MAX_DELIVER=20EXPERIENCE_FETCH_BATCH=64EXPERIENCE_FETCH_TIMEOUT_SECONDS=2EXPERIENCE_WINDOW_SECONDS=1800EXPERIENCE_OK_SAMPLE_PCT=10EXPERIENCE_LATENCY_SPIKE_MS=5000EXPERIENCE_ERROR_THRESHOLD=3EXPERIENCE_SILENT_THRESHOLD=5EXPERIENCE_LATENCY_THRESHOLD=3EXPERIENCE_EVENT_DEDUP_TTL_SECONDS=3600LEARNER_DATABASE_URL=postgresql://<user>:<pass>@<host>:5432/daarion_memoryLESSON_SUBJECT=agent.lesson.v1LESSON_PUBLISH_ENABLED=true
Deploy
- Apply migration
migrations/055_agent_lessons.sql. - Deploy service
experience-learner. - Verify service health and metrics.
Smoke
# Generate event traffic (Phase-1 router path)
for i in $(seq 1 50); do
agent=$([ $((i%2)) -eq 0 ] && echo "aistalk" || echo "devtools")
curl -sS -m 8 -o /dev/null \
-X POST "http://127.0.0.1:9102/v1/agents/${agent}/infer" \
-H "content-type: application/json" \
-d "{\"prompt\":\"phase2-smoke-${agent}-${i}-$(date +%s%N)\"}" || true
done
Verify
# Lessons rows
docker exec dagi-postgres psql -U daarion -d daarion_memory -tAc \
"SELECT count(*) FROM agent_lessons WHERE ts > now()-interval '30 minutes';"
# Idempotency check (run again, duplicates should not explode)
docker exec dagi-postgres psql -U daarion -d daarion_memory -tAc \
"SELECT count(*), count(distinct lesson_key) FROM agent_lessons;"
# Learner metrics
curl -sS http://127.0.0.1:9109/metrics | grep -E 'lessons_|js_messages_'
Acceptance
agent_lessonsreceives rows under live event flow.- Reprocessing/redelivery does not duplicate lessons (
lesson_keyunique). js_messages_acked_totalincreases.js_messages_redelivered_totalis observable when replay/redelivery occurs.