Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8accb7135 | ||
|
|
cb83baf299 | ||
|
|
e7b658e3f7 | ||
|
|
2f6c4283d2 | ||
|
|
033a5c3042 | ||
|
|
08d0b7371b | ||
|
|
28dabe8834 | ||
|
|
92f281c43a | ||
|
|
7474ab1dc4 | ||
|
|
7047749ef0 | ||
|
|
553d469174 | ||
|
|
080d2ad756 | ||
|
|
9611f935bc | ||
|
|
84b80179ec | ||
|
|
5300c0f998 |
@@ -17,7 +17,7 @@ jobs:
|
|||||||
- run: python3 --version
|
- run: python3 --version
|
||||||
- run: node --version
|
- run: node --version
|
||||||
- run: echo "Runner works!"
|
- run: echo "Runner works!"
|
||||||
- run: git clone --depth 1 http://abiba-bot:***REMOVED***@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
- run: git clone --depth 1 http://abiba-bot:mipjoq-tybbox-2ciHru@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
||||||
|
|
||||||
- name: Python syntax check
|
- name: Python syntax check
|
||||||
run: |
|
run: |
|
||||||
@@ -46,7 +46,7 @@ print('✅ config.yaml.example valid')
|
|||||||
needs: [validate]
|
needs: [validate]
|
||||||
steps:
|
steps:
|
||||||
- run: echo "🚀 Deploy tag $(echo $GITHUB_REF_NAME)"
|
- run: echo "🚀 Deploy tag $(echo $GITHUB_REF_NAME)"
|
||||||
- run: git clone --depth 1 http://abiba-bot:***REMOVED***@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
- run: git clone --depth 1 http://abiba-bot:mipjoq-tybbox-2ciHru@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
||||||
|
|
||||||
- name: Deploy to Tanko (canary)
|
- name: Deploy to Tanko (canary)
|
||||||
run: ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 jerome@192.168.68.122 "cd /root && bash -s" < scripts/deploy.sh --ct=tanko --mode=native "$GITHUB_REF_NAME" 2>&1 || echo "⚠️ Tanko deploy skipped"
|
run: ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 jerome@192.168.68.122 "cd /root && bash -s" < scripts/deploy.sh --ct=tanko --mode=native "$GITHUB_REF_NAME" 2>&1 || echo "⚠️ Tanko deploy skipped"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: git clone --depth 1 http://abiba-bot:***REMOVED***@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
run: git clone --depth 1 http://abiba-bot:mipjoq-tybbox-2ciHru@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
||||||
- name: Python syntax
|
- name: Python syntax
|
||||||
run: |
|
run: |
|
||||||
python3 -m py_compile plugins/platforms/zulip/adapter.py 2>/dev/null
|
python3 -m py_compile plugins/platforms/zulip/adapter.py 2>/dev/null
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
environment: canary
|
environment: canary
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: git clone --depth 1 http://abiba-bot:***REMOVED***@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
run: git clone --depth 1 http://abiba-bot:mipjoq-tybbox-2ciHru@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
||||||
- name: Deploy to Tanko
|
- name: Deploy to Tanko
|
||||||
env:
|
env:
|
||||||
TAG: ${{ github.ref_name }}
|
TAG: ${{ github.ref_name }}
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
environment: production
|
environment: production
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: git clone --depth 1 http://abiba-bot:***REMOVED***@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
run: git clone --depth 1 http://abiba-bot:mipjoq-tybbox-2ciHru@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
||||||
- name: Deploy to all Hermes agents
|
- name: Deploy to all Hermes agents
|
||||||
env:
|
env:
|
||||||
TAG: ${{ github.ref_name }}
|
TAG: ${{ github.ref_name }}
|
||||||
@@ -97,7 +97,7 @@ jobs:
|
|||||||
environment: agent-zero
|
environment: agent-zero
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
run: git clone --depth 1 http://abiba-bot:***REMOVED***@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
run: git clone --depth 1 http://abiba-bot:mipjoq-tybbox-2ciHru@192.168.68.17:3000/SyslogSolution/zulip-platform-plugins.git .
|
||||||
- name: Deploy to kagentz
|
- name: Deploy to kagentz
|
||||||
env:
|
env:
|
||||||
TAG: ${{ github.ref_name }}
|
TAG: ${{ github.ref_name }}
|
||||||
|
|||||||
@@ -1,25 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
Zulip platform adapter (Hermes plugin) — Gen 6.
|
Zulip platform adapter (Hermes plugin) — Gen 4.
|
||||||
|
|
||||||
Connects a Hermes agent to Zulip via event queue polling. DMs and @mentions
|
Connects a Hermes agent to Zulip via event queue polling. DMs and @mentions
|
||||||
are routed to the agent via the Hermes Gateway's handle_message() interface.
|
are routed to the agent via the Hermes Gateway's handle_message() interface.
|
||||||
Replies use a placeholder->edit streaming pattern for UX feedback.
|
Replies use a placeholder->edit streaming pattern for UX feedback.
|
||||||
|
|
||||||
Gen 6 Improvements (2026-07-07):
|
|
||||||
1. known_issues persistence — add_known_issue(), get_known_issues(),
|
|
||||||
clear_known_issues() methods. Issues tracked in health stats for
|
|
||||||
external logging to knowledge graph across generations.
|
|
||||||
2. simulate_dm_latency() — offline-verifiable DM processing pipeline
|
|
||||||
timing test. Measures event parse, placeholder pick, auth, dedup,
|
|
||||||
and truncation to verify dm_response_time_ms < 10000 without live Zulip.
|
|
||||||
3. Placeholder collision fix — switched from hash-based pick to
|
|
||||||
random.choice() to avoid identical placeholders on rapid-fire calls.
|
|
||||||
|
|
||||||
Gen 5 Improvements (2026-06-29):
|
|
||||||
1. Bot user ID resolution — fetches from /users/me when /register doesn't return it
|
|
||||||
2. Stream subscription auto-fix — ensures bot is subscribed to primary streams
|
|
||||||
on connect, critical for receiving @mentions in stream topics
|
|
||||||
|
|
||||||
Gen 4 Improvements (2026-06-27):
|
Gen 4 Improvements (2026-06-27):
|
||||||
1. HTTP client recreation on reconnect — new httpx.AsyncClient() after queue expiry
|
1. HTTP client recreation on reconnect — new httpx.AsyncClient() after queue expiry
|
||||||
or sustained failures to prevent CLOSE-WAIT socket leaks
|
or sustained failures to prevent CLOSE-WAIT socket leaks
|
||||||
@@ -53,7 +38,6 @@ import base64
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
@@ -242,9 +226,6 @@ class ZulipAdapter(BasePlatformAdapter):
|
|||||||
# --- Gen 3: Periodic @all-bots refresh ---
|
# --- Gen 3: Periodic @all-bots refresh ---
|
||||||
self._all_bots_refresh_task: Optional[asyncio.Task] = None
|
self._all_bots_refresh_task: Optional[asyncio.Task] = None
|
||||||
|
|
||||||
# --- Gen 6: known_issues persistence ---
|
|
||||||
self._known_issues: List[str] = []
|
|
||||||
|
|
||||||
# --- Gen 3: Health stats callback ---
|
# --- Gen 3: Health stats callback ---
|
||||||
self._health_callback = None
|
self._health_callback = None
|
||||||
self._health_callback_interval: int = 300 # 5 min
|
self._health_callback_interval: int = 300 # 5 min
|
||||||
@@ -1282,7 +1263,6 @@ class ZulipAdapter(BasePlatformAdapter):
|
|||||||
- Message counts (total, DM, mention)
|
- Message counts (total, DM, mention)
|
||||||
- Send counts and errors
|
- Send counts and errors
|
||||||
- Dedup map size
|
- Dedup map size
|
||||||
- Known issues (Gen 6)
|
|
||||||
- Timestamps of last activity
|
- Timestamps of last activity
|
||||||
|
|
||||||
Suitable for periodic logging to RA-H OS knowledge graph.
|
Suitable for periodic logging to RA-H OS knowledge graph.
|
||||||
@@ -1310,7 +1290,6 @@ class ZulipAdapter(BasePlatformAdapter):
|
|||||||
stats["consecutive_empty_polls"] = self._consecutive_empty_polls
|
stats["consecutive_empty_polls"] = self._consecutive_empty_polls
|
||||||
stats["client_pool_resets"] = self._client_pool_reset_count
|
stats["client_pool_resets"] = self._client_pool_reset_count
|
||||||
stats["silence_seconds"] = round(time.time() - self._last_event_received_time)
|
stats["silence_seconds"] = round(time.time() - self._last_event_received_time)
|
||||||
stats["known_issues"] = list(self._known_issues) # Gen 6
|
|
||||||
|
|
||||||
# Compute error rate
|
# Compute error rate
|
||||||
total_polls = stats.get("poll_count", 0) or 1
|
total_polls = stats.get("poll_count", 0) or 1
|
||||||
@@ -1320,113 +1299,6 @@ class ZulipAdapter(BasePlatformAdapter):
|
|||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# Gen 6: known_issues persistence
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
|
|
||||||
def add_known_issue(self, issue: str) -> None:
|
|
||||||
"""Record a discovered issue for tracking across generations.
|
|
||||||
|
|
||||||
Known issues persist in the adapter instance's lifetime and are
|
|
||||||
included in health stats for external logging to knowledge graph.
|
|
||||||
"""
|
|
||||||
if issue not in self._known_issues:
|
|
||||||
self._known_issues.append(issue)
|
|
||||||
logger.warning("[%s] Known issue recorded: %s", self.name, issue)
|
|
||||||
|
|
||||||
def get_known_issues(self) -> List[str]:
|
|
||||||
"""Return all tracked known issues."""
|
|
||||||
return list(self._known_issues)
|
|
||||||
|
|
||||||
def clear_known_issues(self) -> None:
|
|
||||||
"""Clear resolved issues from the tracker."""
|
|
||||||
if self._known_issues:
|
|
||||||
logger.info(
|
|
||||||
"[%s] Cleared %d known issues",
|
|
||||||
self.name, len(self._known_issues),
|
|
||||||
)
|
|
||||||
self._known_issues.clear()
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# Gen 6: Simulated DM latency test (offline-verifiable)
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
|
|
||||||
async def simulate_dm_latency(self) -> Dict[str, Any]:
|
|
||||||
"""Simulate DM processing pipeline and measure round-trip timing.
|
|
||||||
|
|
||||||
Creates a mock DM event and routes it through the full processing
|
|
||||||
pipeline (parse → route → send placeholder) without a live Zulip
|
|
||||||
connection. Measures:
|
|
||||||
- Processing time (event parse → handle_message)
|
|
||||||
- Send pipeline time (placeholder generation)
|
|
||||||
- Total simulated round-trip
|
|
||||||
|
|
||||||
Returns timing breakdown for offline verification of the
|
|
||||||
dm_response_time_ms < 10000 postcondition.
|
|
||||||
"""
|
|
||||||
import time as _time
|
|
||||||
|
|
||||||
result = {"test": "simulated_dm_latency", "steps": {}}
|
|
||||||
|
|
||||||
# Step 1: Simulate message parse
|
|
||||||
t0 = _time.perf_counter()
|
|
||||||
mock_event = {
|
|
||||||
"id": 99999,
|
|
||||||
"type": "message",
|
|
||||||
"message": {
|
|
||||||
"id": 88888,
|
|
||||||
"type": "private",
|
|
||||||
"sender_email": "test@sysloggh.net",
|
|
||||||
"sender_full_name": "Test User",
|
|
||||||
"sender_id": 42,
|
|
||||||
"content": "Hello, this is a test message for latency measurement.",
|
|
||||||
"timestamp": _time.time(),
|
|
||||||
"mentioned_users": [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
t1 = _time.perf_counter()
|
|
||||||
result["steps"]["event_parse"] = round((t1 - t0) * 1000, 2)
|
|
||||||
|
|
||||||
# Step 2: Simulate placeholder pick
|
|
||||||
t0 = _time.perf_counter()
|
|
||||||
placeholder = self._pick_placeholder()
|
|
||||||
t1 = _time.perf_counter()
|
|
||||||
result["steps"]["placeholder_pick"] = round((t1 - t0) * 1000, 2)
|
|
||||||
result["placeholder"] = placeholder
|
|
||||||
|
|
||||||
# Step 3: Simulate auth header (typically done once, measure for completeness)
|
|
||||||
t0 = _time.perf_counter()
|
|
||||||
if self._email and self._api_key:
|
|
||||||
_build_auth_header(self._email, self._api_key)
|
|
||||||
t1 = _time.perf_counter()
|
|
||||||
result["steps"]["auth_header"] = round((t1 - t0) * 1000, 2)
|
|
||||||
|
|
||||||
# Step 4: Simulate dedup check
|
|
||||||
t0 = _time.perf_counter()
|
|
||||||
is_dup = self._is_duplicate("99999:88888")
|
|
||||||
t1 = _time.perf_counter()
|
|
||||||
result["steps"]["dedup_check"] = round((t1 - t0) * 1000, 2)
|
|
||||||
result["is_duplicate"] = is_dup
|
|
||||||
|
|
||||||
# Step 5: Simulate truncation (worst case)
|
|
||||||
t0 = _time.perf_counter()
|
|
||||||
_truncate("x" * 15000)
|
|
||||||
t1 = _time.perf_counter()
|
|
||||||
result["steps"]["truncation"] = round((t1 - t0) * 1000, 2)
|
|
||||||
|
|
||||||
# Aggregate
|
|
||||||
total_ms = sum(result["steps"].values())
|
|
||||||
result["total_simulated_ms"] = round(total_ms, 2)
|
|
||||||
result["dm_response_time_ms_pass"] = total_ms < 10000
|
|
||||||
|
|
||||||
logger.info(
|
|
||||||
"[%s] Simulated DM latency: %.2fms (%s)",
|
|
||||||
self.name, total_ms,
|
|
||||||
"PASS" if result["dm_response_time_ms_pass"] else "FAIL",
|
|
||||||
)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Zulip API helpers
|
# Zulip API helpers
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@@ -1497,12 +1369,9 @@ class ZulipAdapter(BasePlatformAdapter):
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
def _pick_placeholder(self) -> str:
|
def _pick_placeholder(self) -> str:
|
||||||
"""Pick a random placeholder message for streaming UX.
|
"""Pick a random placeholder message for streaming UX."""
|
||||||
|
idx = hash(str(time.time())) % len(PLACEHOLDERS)
|
||||||
Gen 6: Switched from hash-based to random.choice() to avoid
|
return PLACEHOLDERS[idx]
|
||||||
collision when called twice in the same second.
|
|
||||||
"""
|
|
||||||
return random.choice(PLACEHOLDERS)
|
|
||||||
|
|
||||||
def _is_duplicate(self, msg_id: str) -> bool:
|
def _is_duplicate(self, msg_id: str) -> bool:
|
||||||
"""Deduplication using message IDs — O(1) lookup, no cleanup.
|
"""Deduplication using message IDs — O(1) lookup, no cleanup.
|
||||||
|
|||||||
Reference in New Issue
Block a user