Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

perf(plugins): ADR-098 Part 2 (slice 1/4) — token diet for iot-cognitum/device-coordinator

Reuvenf1bb3cf8432c
diff --git a/plugins/ruflo-iot-cognitum/.claude-plugin/plugin.json b/plugins/ruflo-iot-cognitum/.claude-plugin/plugin.json
index 875728355c..c35dca49e7 100644
--- a/plugins/ruflo-iot-cognitum/.claude-plugin/plugin.json
+++ b/plugins/ruflo-iot-cognitum/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-iot-cognitum",
"description": "IoT device lifecycle, telemetry anomaly detection, fleet management, and witness chain verification for Cognitum Seed hardware",
- "version": "0.1.0",
+ "version": "0.1.1",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-iot-cognitum/REFERENCE.md b/plugins/ruflo-iot-cognitum/REFERENCE.md
new file mode 100644
index 0000000000..1b559b0daa
--- /dev/null
+++ b/plugins/ruflo-iot-cognitum/REFERENCE.md
@@ -0,0 +1,63 @@
+# ruflo-iot-cognitum — Operations Reference
+
+Companion reference for the agents in this plugin. The agent prompts deliberately stay lean (≤ 60 lines) per [ADR-098 Part 2](../../v3/docs/adr/ADR-098-plugin-capability-sync-and-optimization.md); this file collects the tables and catalogs an agent reads on-demand instead of paying for them in every spawn's context window.
+
+## Trust tiers (5 levels)
+
+| Level | Name | Score range | Capabilities |
+|---|---|---|---|
+| 0 | `UNKNOWN` | 0.0–0.19 | Discovery only |
+| 1 | `REGISTERED` | 0.2–0.39 | Status, identity queries |
+| 2 | `PROVISIONED` | 0.4–0.59 | Telemetry ingest, vector store |
+| 3 | `CERTIFIED` | 0.6–0.79 | Mesh participation, firmware deploy |
+| 4 | `FLEET_TRUSTED` | 0.8–1.0 | Full fleet operations, witness signing |
+
+Promotion requires the device to meet the lower bound of the next tier across all 6 trust components — a single-component cliff (e.g. firmware fall-behind) demotes by one tier until the deficiency is repaired.
+
+## Device coordinator tool catalog
+
+The default endpoint when none is supplied is `http://169.254.42.1/` — the Cognitum Seed link-local USB Ethernet address.
+
+```bash
+# Lifecycle
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot register [endpoint]
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot pair <device-id>
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot unpair <device-id>
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot remove <device-id>
+
+# Inspection
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot status <device-id>
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot list
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot mesh <device-id>
+
+# Witness audit
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot witness <device-id>
+npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot witness verify <device-id>
+```
+
+## Background workers
+
+| Worker | Interval | Event emitted | Description |
+|---|---|---|---|
+| `HealthProbeWorker` | 30s | `iot:device-offline` | Probes device status, detects offline |
+| `TelemetryIngestWorker` | 60s | — | Ingests telemetry vectors |
+| `AnomalyScanWorker` | 120s | `iot:anomaly-detected` | Runs Z-score anomaly detection |
+| `MeshSyncWorker` | 120s | `iot:mesh-partition` | Detects mesh topology partitions |
+| `FirmwareWatchWorker` | 300s | `iot:firmware-mismatch` | Detects firmware version changes |
+| `WitnessAuditWorker` | 600s | `iot:witness-gap` | Audits witness chain epoch continuity |
+
+Workers are dispatched by the host daemon when `ruflo-iot-cognitum` is loaded. Verify via `ruflo hooks worker list` and `ruflo hooks worker status`.
+
+## Trust-score formula breakdown
+
+```
+trustScore =
+ 0.30 · pairingIntegrity # mTLS chain valid, expected fingerprint
+ + 0.15 · firmwareCurrency # current firmware vs latest available
+ + 0.20 · uptimeStability # rolling 24h uptime ratio
+ + 0.15 · witnessIntegrity # Ed25519 chain has no gaps
+ + 0.10 · anomalyHistory # 1.0 minus normalized anomaly count
+ + 0.10 · meshParticipation # active edges in the mesh topology
+```
+
+A device that fails its `witness verify` drops `witnessIntegrity` to 0 immediately — that single failure caps the device at trust 0.85 (max), forcing demotion from `FLEET_TRUSTED`.
diff --git a/plugins/ruflo-iot-cognitum/agents/device-coordinator.md b/plugins/ruflo-iot-cognitum/agents/device-coordinator.md
index c5f969e8d2..9a1a8797bd 100644
--- a/plugins/ruflo-iot-cognitum/agents/device-coordinator.md
+++ b/plugins/ruflo-iot-cognitum/agents/device-coordinator.md
@@ -5,64 +5,26 @@ model: sonnet
---
You are a Cognitum Seed device coordinator agent. Your responsibilities:
-1. **Discover** Seed devices via mDNS or explicit endpoint registration
-2. **Register** devices and establish SeedClient connections with TLS verification
-3. **Monitor** device health via periodic probes (30s default)
-4. **Score** trust using the 6-component formula: `0.3×pairingIntegrity + 0.15×firmwareCurrency + 0.2×uptimeStability + 0.15×witnessIntegrity + 0.1×anomalyHistory + 0.1×meshParticipation`
-5. **Coordinate** fleet operations, firmware rollouts, and mesh topology
+1. **Discover** Seed devices via mDNS or explicit endpoint registration.
+2. **Register** devices and establish SeedClient connections with TLS verification.
+3. **Monitor** device health via periodic probes (30s default).
+4. **Score** trust using the 6-component formula: `0.3·pairingIntegrity + 0.15·firmwareCurrency + 0.2·uptimeStability + 0.15·witnessIntegrity + 0.1·anomalyHistory + 0.1·meshParticipation`.
+5. **Coordinate** fleet operations, firmware rollouts, and mesh topology.
-### Trust Levels (5-Tier)
+Trust gates promotion to higher tiers (UNKNOWN → REGISTERED → PROVISIONED → CERTIFIED → FLEET_TRUSTED). Score drops below 0.5 emit `iot:anomaly-detected` and quarantine the device from fleet operations.
-| Level | Name | Score Range | Capabilities |
-|-------|------|-------------|-------------|
-| 0 | UNKNOWN | 0.0–0.19 | Discovery only |
-| 1 | REGISTERED | 0.2–0.39 | Status, identity queries |
-| 2 | PROVISIONED | 0.4–0.59 | Telemetry ingest, vector store |
-| 3 | CERTIFIED | 0.6–0.79 | Mesh participation, firmware deploy |
-| 4 | FLEET_TRUSTED | 0.8–1.0 | Full fleet operations, witness signing |
+The full trust-tier table, complete tool catalog (`npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot ...`), and background worker schedule live in [`REFERENCE.md`](../REFERENCE.md) — read it when you need an operation that isn't covered by the responsibilities above. Keeping reference data out of the agent prompt costs ~40% fewer tokens per spawn (per ADR-098 Part 2).
-### Tools
-
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot register [endpoint]` — register a Seed device (defaults to `http://169.254.42.1/`, the Cognitum Seed link-local USB Ethernet address, when no endpoint is supplied)
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot status <device-id>` — refresh device state and trust score
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot list` — list all registered devices
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot pair <device-id>` — pair device, promote trust
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot unpair <device-id>` — unpair device, demote trust
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot remove <device-id>` — deregister device
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot mesh <device-id>` — view mesh topology
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot witness <device-id>` — view witness chain
-- `npx -y -p @claude-flow/plugin-iot-cognitum@latest cognitum-iot witness verify <device-id>` — verify chain integrity
-
-### Anomaly Response
-
-When trust score drops below 0.5:
-1. Emit `iot:anomaly-detected` event
-2. Consider quarantining device from fleet operations
-3. Log anomaly to memory for pattern learning
-
-### Background Workers
-
-| Worker | Interval | Event Emitted | Description |
-|--------|----------|---------------|-------------|
-| HealthProbeWorker | 30s | `iot:device-offline` | Probes device status, detects offline |
-| TelemetryIngestWorker | 60s | — | Ingests telemetry vectors |
-| AnomalyScanWorker | 120s | `iot:anomaly-detected` | Runs Z-score anomaly detection |
-| MeshSyncWorker | 120s | `iot:mesh-partition` | Detects mesh topology partitions |
-| FirmwareWatchWorker | 300s | `iot:firmware-mismatch` | Detects firmware version changes |
-| WitnessAuditWorker | 600s | `iot:witness-gap` | Audits witness chain epoch continuity |
-
-### Memory Integration
+### Memory integration
Store device patterns for cross-session learning:
```bash
npx @claude-flow/cli@latest memory store --namespace iot-devices --key "device-DEVICEID" --value "TRUST_HISTORY"
```
+### Neural learning
-### Neural Learning
-
-After completing tasks, store successful patterns:
+After completing tasks, store the outcome so the trust scorer compounds learning across sessions:
```bash
npx @claude-flow/cli@latest hooks post-task --task-id "TASK_ID" --success true --train-neural true
-npx @claude-flow/cli@latest memory search --query "TASK_TYPE patterns" --namespace patterns
```