cost-federation

Aggregates per-peer federation spend events into rolling windows and checks suspension thresholds.

70.1k|8.4k|Updated Jun 2, 2025
One-click install
npx skills add https://github.com/ruvnet/claude-flow --skill cost-federation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cost-federation
Source: https://github.com/ruvnet/claude-flow/tree/main/plugins/ruflo-cost-tracker/skills/cost-federation
Command: npx skills add https://github.com/ruvnet/claude-flow --skill cost-federation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Federated agent networks need visibility into how much each peer spends in tokens and USD, and operators need a way to detect peers exceeding budget thresholds before the federation circuit breaker suspends them.

Core Features & Use Cases

  • Per-Peer Rolling Windows: Aggregates federation_spend events into 1-hour, 24-hour, and 7-day windows showing event counts and USD spent per peer.
  • Suspension Threshold Check: Flags peers whose spend exceeds the configured breaker threshold (default 5.0 USD per ADR-097).
  • Flexible Output: Renders results as markdown or JSON via the FED_FORMAT environment variable.
  • Use Case: Before opening federation traffic to a new peer, run the script to establish a spend baseline, then schedule it periodically (e.g. every 5 minutes) to monitor per-peer spend across windows.

Quick Start

Run the federation script with node plugins/ruflo-cost-tracker/scripts/federation.mjs to inspect per-peer spend windows and suspension threshold status.

Frequently Asked Questions about cost-federation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I monitor per-peer federation spend?

Run node plugins/ruflo-cost-tracker/scripts/federation.mjs to aggregate federation_spend events into per-peer 1-hour, 24-hour, and 7-day windows. Set FED_FORMAT=json for machine-readable output instead of markdown.

How do I check if a federation peer exceeded the budget threshold?

The script includes a suspension threshold check block that flags peers whose spend exceeds the breaker limit. Override the default 5.0 USD threshold from ADR-097 by setting the FED_SUSPEND_THRESHOLD_USD environment variable.

Why does the federation spend report show no events found?

The report shows no events because ADR-097 Phase 3 has not landed upstream yet, so no federation_spend events are being published. The skill activates automatically once upstream writes events to the federation-spend namespace with fed-spend- key prefixes.

What event format does federation spend tracking expect?

Events must be JSON records with peerId, taskId, tokensUsed, usdSpent, and ts fields, stored in the federation-spend namespace with keys prefixed fed-spend-. Multiple events per peer accumulate into the rolling-window sums.

What is the difference between cost-federation and cost-report?

Cost-federation tracks per-peer federated spend across the network, while cost-report focuses on local agent spend. Both read similar underlying data but answer different operational questions.