Skip to content
Skillpedia
Misc81k Β· #1601

cost-federation

What it does

This skill tracks spending per connected peer over one hour, one day and one week. It is for people who share AI work with several other connected systems.

When to use it

  • βœ“When you open AI work to a new connected peer and want a baseline first.
  • βœ“When you want to watch per-peer spending on a repeating check.
  • βœ“When you want to confirm that a spending limit would catch a peer that goes too far.

Skill link

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-federation/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-federation/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œHow much has each connected peer spent on my tasks in the last day?”

5 new skills a week. 1 minute to read.

How it works

The skill reads spend events from a shared store and totals them per peer across the three windows. It then compares each peer with a dollar threshold and reports any that are over it.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Cost Federation

ADR-097 Phase 3 specifies a federation_spend event bus that publishes one event per federation_send completion: {peerId, taskId, tokensUsed, usdSpent, ts}. Cost-tracker is the declared consumer β€” it aggregates per-peer rolling windows (1h / 24h / 7d) and the federation breaker queries that aggregate to suspend peers exceeding the configured threshold.

Phase 3 isn't landed upstream yet. This skill is the consumer-side wiring; it activates the moment upstream publishes events to the federation-spend namespace. Until then it reports cleanly with a "no events found" notice.

When to use

  • Before opening federation traffic to a new peer β€” establish baseline.
  • Periodically (e.g. /loop 5m) to monitor per-peer spend across windows.
  • After ADR-097 Phase 2/3 lands β€” to verify breaker suspension reasoning.

Steps

  1. Run the script:

    node plugins/ruflo-cost-tracker/scripts/federation.mjs
    

    Optional env:

    • FED_FORMAT=json β€” JSON instead of markdown
    • FED_NAMESPACE=federation-spend β€” override target namespace
    • FED_SUSPEND_THRESHOLD_USD=5.0 β€” breaker threshold (ADR-097 default)
  2. Inspect β€” per-peer 1h/24h/7d windows of count + USD spent, plus a "Suspension threshold check" block flagging peers over the breaker line.

Storage contract (consumer side)

When Phase 3 lands, events should be persisted to namespace federation-spend with key prefix fed-spend- and JSON value matching:

{
  "peerId": "<peer-uuid>",
  "taskId": "<task-uuid>",
  "tokensUsed": 12345,
  "usdSpent": 0.0287,
  "ts": "2026-05-05T..."
}

The script reads any record matching that prefix, regardless of how upstream produces them. Multiple events per peer accumulate cleanly into the rolling-window sums.

Cross-references

  • ADR-097: Federation budget circuit breaker β€” the complete spec
  • cost-report β€” same data, different lens (cost-report focuses on local agent spend; this skill on per-peer federated spend)
  • ruflo-federation plugin β€” the producer side (when Phase 3 lands)
FAQ

Does it work right now?

Only once the upstream system starts publishing events. Until then, it reports that no events were found.

What is the default threshold?

The source sets a default of five dollars, and you can change it with a setting.

What happens when a peer is over the limit?

The peer is flagged in the report. Suspending the peer is done by a separate breaker that reads this data, not by this skill.

Details

Original description by the author

Consumer-side wiring for ADR-097 Phase 3 federation_spend events β€” per-peer rolling windows + suspension-threshold check

repo: ruvnet/ruflo

Popularity

GitHub stars
81k
Ranking position
#1601
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills