Files
shard-memory/runbooks/bridge-test-plan.md
T

95 lines
2.4 KiB
Markdown

# Bridge Test Plan (MVP)
## Test levels
- Unit: routing, dedupe, loop guard, conversation rules
- Integration: chattr client + adapters + sqlite
- E2E: k8s deployment with real channel traffic
---
## A. Unit tests
### A1 Routing
- `@prime` routes to prime only
- `@shard` routes to shard only
- no mention routes to both
### A2 Conversation rules
- reply/thread inherits conversation_id
- new top-level starts new conversation_id
- explicit fork creates new conversation_id
### A3 Dedupe
- same dedupe_key processed once
- expired dedupe key accepted again after TTL
### A4 Loop controls
- hop_count > max blocked
- self-echo blocked
- cycle trace detection blocks repeated ring
- relay cooldown blocks rapid ping-pong
### A5 Handoff limits
- payload > max truncates correctly
- handoff trigger fires on inactivity/msg threshold
---
## B. Integration tests
### B1 Adapter ack/error
- accepted queued response handled
- retryable error enters retry queue
- non-retryable error goes directly to DLQ/log
### B2 Retry worker
- exponential backoff schedule honored
- max attempts sends to DLQ
### B3 Callback responses
- adapter callback with correlation_id maps to correct chattr thread
### B4 Restart resilience
- restart service; cursors/state resume without duplicate flood
---
## C. E2E scenarios (k8s)
### C1 Fanout baseline
Input: unmentioned message in #general
Expected: both adapters receive ingest, 0/1/2 responses accepted
### C2 Explicit mention
Input: @prime request
Expected: shard adapter not called
### C3 Cross-agent relay
Input: Prime mentions @shard in response
Expected: one relay hop; loop guard active if repeated chain
### C4 Surface switch handoff
Input: simulate Telegram-origin conversation routed into chattr
Expected: handoff packet present and conversation_id continuity maintained
### C5 Failure path
Input: prime adapter unreachable
Expected: retries, then DLQ, no bridge crash
---
## Acceptance gates
- 95%+ unit test pass (100% required in CI)
- all integration tests green
- E2E C1-C5 pass in shard namespace
- no unbounded queue growth under 30-min soak
---
## Observability checks during E2E
- `messages_in_total` increments
- `messages_routed_total{target}` matches expected fanout
- `dedupe_drops_total` increases only in duplicate scenarios
- `loop_guard_drops_total` non-zero only in loop tests
- latency p95 within agreed threshold (target < 3s for local adapters)