Files
prose-contracts/zulip-mention-reliability.prose.md
T
Abiba c1d993fe01 fix: GPU table correction + OpenProse v0.15 alignment + self-heal rules 7-9
- hello-world: Ensures -> Maintains (v0.15.0 rename).
- zulip-mention-reliability: fold Success Criteria into Maintains postconditions.
- litellm-self-heal: swap gemma/qwen GPU hosts to match actual deployment;
  add Strix Halo 64GB UMA detail; add Rules 7 (roster stuck), 8 (agent keys
  invalid/401), 9 (stale Redis active counter).
2026-07-02 20:39:17 +00:00

72 lines
2.9 KiB
Markdown

---
kind: responsibility
name: zulip-mention-reliability
description: >
Monitors whether Abiba Bot is correctly detecting and responding to
@mentions in Zulip stream topics. Tests periodically, diagnoses
failures, and attempts fixes. Same self-improving pattern as
litellm-self-heal.
---
## Maintains
- mention_response_rate: number — % of @mentions that get a response (target: >95%)
- last_test_result: "pass" | "fail" | "degraded"
- known_failure_modes: array — History of what went wrong and how it was fixed
- queue_health: "healthy" | "expired" | "reconnecting"
**Postconditions**
- test_mention_gets_response == true — Send @Abiba Bot test, confirm response within 30s
- stream_subscription_active == true — Bot is subscribed to #agent-hub and #general chat
- queue_active == true — PM2's event queue is registered and polling
- no_echo_loop == true — Bot doesn't respond to its own messages
- dm_always_works == true — DMs still respond even if streams are broken
## Known Failure Modes (from History)
| Failure | Root Cause | Fix |
|---|---|---|
| No stream events | Bot had 0 stream subscriptions | Subscribe via API |
| No @mention detection | botUserId was null (register endpoint doesn't return it) | Fetch from /api/v1/users/me |
| No stream events | zulip-js library sends multipart/form-data instead of form-urlencoded | Use URLSearchParams directly |
| Double responses | Both TUI and PM2 loaded the extension | ZULIP_EXTENSION_ACTIVE guard |
## Remediation Rules
### Rule 1: Queue Expired
- Detect: Poll returns BAD_EVENT_QUEUE_ID
- Fix: `pm2 restart abiba-zulip`
- Verify: Check logs for "Connected, queue:"
### Rule 2: Subscription Missing
- Detect: `GET /api/v1/users/me/subscriptions` returns 0 for #agent-hub
- Fix: Subscribe via `POST /api/v1/users/me/subscriptions`
- Verify: Re-check subscriptions
### Rule 3: Extension Crashed
- Detect: PM2 status shows "errored" for abiba-zulip
- Fix: `pm2 restart abiba-zulip`
- Escalate: If restarts >5 in last hour, alert user
### Rule 4: No Response to Test Mention
- Detect: Send test @mention, wait 30s, check if response appeared
- Fix: Run diagnostics (check queue, check code, check logs)
- Log: Record failure mode as new entry in Known Failure Modes
## Continuity
- **On user report**: User says "you didn't respond" → run diagnostic
- **On test failure**: Test mention fails → run remediation
- **Retrospective**: Every 6 hours — send a test @mention to self-verify
- **On PM2 restart**: Always run a self-test after restart
## Execution
1. **Self-test**: Send `@**Abiba Bot** _selftest_` in #agent-hub, wait for response
2. **If no response in 30s**: Run diagnostics
3. **Diagnose**: Check queue, subscriptions, PM2 status, logs
4. **Fix**: Apply matching remediation rule
5. **Retest**: Try again
6. **Log**: Record success or new failure mode
7. **Report**: DM user only if escalation needed