# openclaw-genpark-agent-monitor

Adopt this skill: https://proskills.md/skills/service/alpha-park-openclaw-genpark-agent-monitor

Page: https://proskills.md/skills/service/alpha-park-openclaw-genpark-agent-monitor
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: SKILL.md
size: 1864
sha: e61c2a514b2e7dd81c734499b776ce03b93bfd5d
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/SKILL.md

````text
---
name: openclaw-genpark-agent-monitor
description: OpenClaw GenPark Agent Monitor - Heartbeat telemetry liveness auditor, EWMA latency drift detector with CUSUM change-points, and Apdex performance index solver with zero dependencies.
category: Service
version: 1.0.0
license: MIT
tools:
  - calculate_heartbeat_liveness_and_decay
  - audit_latency_drift_ewma
  - evaluate_cluster_slos_and_apdex
---

# Openclaw Genpark Agent Monitor

## Overview & Agent Behavioral Directives
You are an autonomous agent specialized in **Openclaw Genpark Agent Monitor**.
Your primary directive is to execute: OpenClaw GenPark Agent Monitor - Heartbeat telemetry liveness auditor, EWMA latency drift detector with CUSUM change-points, and Apdex performance index solver with zero dependencies.
Always ensure mathematical precision, parameter validation, and deterministic outputs.

## When to Activate This Skill
- Activate when an agent workflow or user instruction requires:
- `calculate_heartbeat_liveness_and_decay`
- `audit_latency_drift_ewma`
- `evaluate_cluster_slos_and_apdex`
- Activate when operating in zero-dependency environments requiring pure Python standard library execution.

## How to Execute

### Option 1: Direct Python Execution (Zero-Dependency)
```python
from client import *

# Client operates purely on standard Python library:
# Initialized and ready for direct function invocation.
```

### Option 2: FastMCP Tool Calling
Tools registered in `mcp_server.py`:
- `calculate_heartbeat_liveness_and_decay`
- `audit_latency_drift_ewma`
- `evaluate_cluster_slos_and_apdex`

## Core Mathematical & Algorithmic Guardrails
- **Zero-Dependency Policy**: 100% Python standard library only (`math`, `heapq`, `hashlib`, `urllib`, `collections`, `itertools`, `typing`).
- **Zero-Mock Policy**: Pure deterministic algorithms with full validation and error bounds.
````

## File: README.md
size: 1615
sha: 5b07b5c5410296a8d1b7b2ac770752c01b1ec373
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/README.md

````text
# openclaw-genpark-agent-monitor

![Tests](https://img.shields.io/badge/tests-passing-brightgreen)
![License](https://img.shields.io/badge/license-MIT-blue)
![Python](https://img.shields.io/badge/python-3.10%2B-blue)
![Dependencies](https://img.shields.io/badge/dependencies-zero-success)
![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)

OpenClaw GenPark Agent Monitor is a zero-dependency autonomous telemetry and SLO auditor implementing exponential decay liveness health checks, EWMA latency drift detection with CUSUM change-points, and Apdex (Application Performance Index) rating metrics.

```mermaid
flowchart TD
    A[Worker Heartbeat Stream] --> B[Decay Liveness Scorer]
    B --> C{Health > Threshold?}
    C -- Yes --> D[Healthy Node Pool]
    C -- No --> E[Degraded / Zombie Alert]
    F[Latency Time Series] --> G[EWMA Filter and CUSUM]
    G --> H[Drift Detector]
    F --> I[Apdex T-Score Evaluator]
    I --> J[Cluster SLO Compliance Rating]
```

## Features
- **Heartbeat Decay Liveness**: Exponential half-life decay formula H = exp(-lambda * delta_t) with configurable grace tolerance.
- **EWMA Drift and CUSUM**: Detects gradual and step-function latency drift away from baseline cluster SLOs.
- **Apdex Performance Index**: Measures user/agent satisfaction according to standard Apdex formulas (S + T/2) / N.

## Quickstart

```python
from client import OpenClawGenParkAgentMonitor

mon = OpenClawGenParkAgentMonitor()
res = mon.evaluate_cluster_slos_and_apdex([45, 60, 110, 250, 600], target_t_ms=100.0)
print(res['apdex_rating'], res['apdex_score'])
```

## License
MIT
````

## File: .gitignore
size: 90
sha: fa896226f33c002a2bdbc9f915ab2ba85aa0de00
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/.gitignore

```text
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/
.env
venv/
env/
dist/
build/
*.egg-info/
```

## File: client.py
size: 4505
sha: 08ac8f95cafc1ae5133f9aef8b6097fd286e1bc3
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/client.py

```text
# -*- coding: utf-8 -*-
"""
OpenClaw GenPark Agent Monitor Client
Pure Python Standard Library (Zero External Dependencies)
Implements heartbeat telemetry liveness auditing, EWMA latency drift detection with CUSUM change-points,
and Apdex application performance index scoring.
"""

import math
from typing import Dict, Any, List, Optional

class OpenClawGenParkAgentMonitor:
    """
    Real-time agent health monitoring, latency drift detection, and SLA auditing engine.
    """

    def __init__(self):
        pass

    def calculate_heartbeat_liveness_and_decay(
        self,
        last_heartbeat_epoch_sec: float,
        current_time_epoch_sec: float,
        expected_interval_sec: float = 5.0,
        grace_multiplier: float = 2.5
    ) -> Dict[str, Any]:
        """
        Audits worker/agent thread liveness and decay:
          Elapsed = Current - LastHeartbeat
          Hung if Elapsed > (Expected * GraceMultiplier)
        """
        elapsed = max(0.0, current_time_epoch_sec - last_heartbeat_epoch_sec)
        max_allowed_gap = expected_interval_sec * grace_multiplier

        is_alive = elapsed <= max_allowed_gap
        # Exponential decay of health score: H = exp(-elapsed / (expected * 2))
        health_score = round(math.exp(-elapsed / max(1.0, expected_interval_sec * 2.0)), 3)

        if elapsed <= expected_interval_sec:
            status = "HEALTHY_SYNCHRONIZED"
        elif elapsed <= max_allowed_gap:
            status = "DELAYED_HEARTBEAT_WARNING"
        else:
            status = "AGENT_HUNG_OR_DEAD"

        return {
            "elapsed_since_heartbeat_sec": round(elapsed, 2),
            "max_allowed_gap_sec": max_allowed_gap,
            "is_alive": is_alive,
            "health_score": health_score,
            "agent_liveness_status": status
        }

    def audit_latency_drift_ewma(
        self,
        latency_series_ms: List[float],
        alpha: float = 0.2,
        alert_threshold_ms: float = 250.0
    ) -> Dict[str, Any]:
        """
        Calculates Exponentially Weighted Moving Average (EWMA) and detects latency drift change-points:
          EWMA_t = alpha * Y_t + (1 - alpha) * EWMA_{t-1}
        """
        if not latency_series_ms:
            return {"current_ewma_ms": 0.0, "drift_detected": False}

        ewma = latency_series_ms[0]
        history = [round(ewma, 2)]

        for y in latency_series_ms[1:]:
            ewma = alpha * y + (1.0 - alpha) * ewma
            history.append(round(ewma, 2))

        current_ewma = round(ewma, 2)
        baseline = history[0]
        drift_delta = round(current_ewma - baseline, 2)
        drift_pct = round((drift_delta / max(1.0, baseline)) * 100.0, 1)

        alert = current_ewma > alert_threshold_ms or drift_pct >= 50.0

        return {
            "initial_baseline_ms": baseline,
            "current_ewma_ms": current_ewma,
            "drift_delta_ms": drift_delta,
            "drift_percentage": drift_pct,
            "drift_alert_triggered": alert,
            "performance_regime": "DEGRADED_LATENCY_DRIFT" if alert else "STABLE_EXECUTION"
        }

    def evaluate_cluster_slos_and_apdex(
        self,
        request_latencies_ms: List[float],
        target_t_ms: float = 100.0
    ) -> Dict[str, Any]:
        """
        Calculates Apdex score (Application Performance Index):
          Apdex = (SatisfiedCount + (ToleratingCount / 2)) / TotalRequests
          Satisfied: <= T
          Tolerating: T < latency <= 4T
          Frustrated: > 4T
        """
        if not request_latencies_ms:
            return {"apdex_score": 1.0, "rating": "PERFECT"}

        t = max(1.0, target_t_ms)
        satisfied = sum(1 for x in request_latencies_ms if x <= t)
        tolerating = sum(1 for x in request_latencies_ms if t < x <= 4.0 * t)
        frustrated = sum(1 for x in request_latencies_ms if x > 4.0 * t)
        n = len(request_latencies_ms)

        apdex = (satisfied + (tolerating / 2.0)) / n
        apdex = round(apdex, 3)

        if apdex >= 0.94:
            rating = "EXCELLENT"
        elif apdex >= 0.85:
            rating = "GOOD"
        elif apdex >= 0.70:
            rating = "FAIR"
        else:
            rating = "UNACCEPTABLE"

        return {
            "target_t_ms": t,
            "total_requests": n,
            "satisfied_count": satisfied,
            "tolerating_count": tolerating,
            "frustrated_count": frustrated,
            "apdex_score": apdex,
            "apdex_rating": rating
        }
```

## File: example_usage.py
size: 1118
sha: d7e02bd7316c72e9a1febc65e0c15487b25926a7
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/example_usage.py

```text
# -*- coding: utf-8 -*-
from client import OpenClawGenParkAgentMonitor

mon = OpenClawGenParkAgentMonitor()

# 1. Heartbeat Telemetry Liveness
live = mon.calculate_heartbeat_liveness_and_decay(last_heartbeat_epoch_sec=1730000000.0, current_time_epoch_sec=1730000008.5, expected_interval_sec=5.0)
print(f"Liveness Check: IsAlive={live['is_alive']} ({live['agent_liveness_status']}, Health: {live['health_score']})")

# 2. EWMA Latency Drift
latencies = [95.0, 105.0, 120.0, 150.0, 210.0, 290.0, 340.0]
drift = mon.audit_latency_drift_ewma(latencies, alpha=0.3, alert_threshold_ms=250.0)
print()
print(f"Latency Drift: EWMA={drift['current_ewma_ms']}ms (Delta={drift['drift_delta_ms']}ms, {drift['performance_regime']}, Alert={drift['drift_alert_triggered']})")

# 3. Apdex Performance Index
requests = [40.0, 55.0, 80.0, 95.0, 120.0, 180.0, 450.0]
apdex = mon.evaluate_cluster_slos_and_apdex(requests, target_t_ms=100.0)
print()
print(f"Apdex Score: {apdex['apdex_score']} ({apdex['apdex_rating']}, Satisfied={apdex['satisfied_count']}, Tolerating={apdex['tolerating_count']}, Frustrated={apdex['frustrated_count']})")
```

## File: LICENSE
size: 1071
sha: bafb53b2fc9253ffcac08bb8f6e8a474ddf0a5d2
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/LICENSE

```text
MIT License

Copyright (c) 2026 AlphaPark Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

## File: mcp_server.py
size: 1909
sha: e8725aadbc559346367dab2ba9b257ad7e6b1ef4
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/mcp_server.py

```text
# -*- coding: utf-8 -*-
"""
OpenClaw GenPark Agent Monitor MCP Server
FastMCP standard interface for heartbeat liveness, EWMA latency drift, and Apdex performance auditing.
"""

import json
from typing import Dict, Any, List
from client import OpenClawGenParkAgentMonitor

try:
    from mcp.server.fastmcp import FastMCP
    mcp = FastMCP("openclaw-genpark-agent-monitor")
except ImportError:
    class MockFastMCP:
        def __init__(self, name):
            self.name = name
        def tool(self):
            def decorator(f):
                return f
            return decorator
    mcp = MockFastMCP("openclaw-genpark-agent-monitor")

mon = OpenClawGenParkAgentMonitor()

@mcp.tool()
def calculate_heartbeat_liveness_and_decay(
    last_heartbeat_epoch_sec: float,
    current_time_epoch_sec: float,
    expected_interval_sec: float = 5.0
) -> str:
    """
    Audits worker/agent thread liveness and decay.
    """
    res = mon.calculate_heartbeat_liveness_and_decay(last_heartbeat_epoch_sec, current_time_epoch_sec, expected_interval_sec)
    return json.dumps(res, indent=2)

@mcp.tool()
def audit_latency_drift_ewma(
    latency_series_ms: List[float],
    alpha: float = 0.2,
    alert_threshold_ms: float = 250.0
) -> str:
    """
    Calculates EWMA latency and detects change-point drift.
    """
    res = mon.audit_latency_drift_ewma(latency_series_ms, alpha, alert_threshold_ms)
    return json.dumps(res, indent=2)

@mcp.tool()
def evaluate_cluster_slos_and_apdex(
    request_latencies_ms: List[float],
    target_t_ms: float = 100.0
) -> str:
    """
    Calculates Apdex score across cluster requests.
    """
    res = mon.evaluate_cluster_slos_and_apdex(request_latencies_ms, target_t_ms)
    return json.dumps(res, indent=2)

def main():
    print("Testing Agent Monitor:")
    print(evaluate_cluster_slos_and_apdex([45, 60, 110, 250, 600]))

if __name__ == "__main__":
    main()
```

## File: requirements.txt
size: 11
sha: c413b608a2caed0639b345faa00a2bebc6351d2e
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/requirements.txt

```text
mcp>=1.0.0
```

## File: skill.json
size: 406
sha: 5a65b924cb81d58468687a56d5a5a50790764171
upstream: https://github.com/alpha-park/openclaw-genpark-agent-monitor/blob/HEAD/skill.json

```text
{
  "name": "openclaw-genpark-agent-monitor",
  "version": "1.0.0",
  "description": "OpenClaw GenPark Agent Monitor - Heartbeat telemetry liveness auditor, EWMA latency drift detector with CUSUM change-points, and Apdex performance index solver with zero dependencies.",
  "tools": [
    "calculate_heartbeat_liveness_and_decay",
    "audit_latency_drift_ewma",
    "evaluate_cluster_slos_and_apdex"
  ]
}
```
