cost-federation
できること
このスキルは、ピアごとの支出を1時間、1日、1週間の単位で追跡します。複数の接続されたシステムとAI作業を共有している人向けです。
使う場面
- ✓新しい接続ピアにAI作業を開放する前に、基準値がほしいとき。
- ✓繰り返しの確認で、ピアごとの支出を監視したいとき。
- ✓支出の上限があれば、行き過ぎたピアを検出できるかを確かめたいとき。
スキルのリンク
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-federation/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“接続されている各ピアは、直近1日に私のタスクにどれくらい支出しましたか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
スキルは共有ストアから支出のイベントを読み、3つの期間ごとにピアごとの合計を出します。次に、各ピアをドルの基準値と比べ、上限を超えたものを報告します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
Run the script:
node plugins/ruflo-cost-tracker/scripts/federation.mjsOptional env:
FED_FORMAT=json— JSON instead of markdownFED_NAMESPACE=federation-spend— override target namespaceFED_SUSPEND_THRESHOLD_USD=5.0— breaker threshold (ADR-097 default)
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-federationplugin — the producer side (when Phase 3 lands)
よくある質問
今すぐ動きますか?
上流システムがイベントの配信を始めた後にのみ動きます。それまでは、イベントが見つからなかったと報告します。
既定の基準値はいくらですか?
ソースは既定で5ドルを設定しており、設定で変更できます。
上限を超えたピアはどうなりますか?
レポートでそのピアに印が付けられます。ピアを停止するのは、このデータを読む別のブレーカー(遮断機能)の仕事で、このスキルの役割ではありません。
詳細
作者による元の説明
Consumer-side wiring for ADR-097 Phase 3 federation_spend events — per-peer rolling windows + suspension-threshold check
repo: ruvnet/ruflo
人気
- GitHubのスター
- 81k
- ランキング
- #1601
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
agent-adaptive-coordinator
81k作業量の変化に合わせて、エージェントのグループを分割し、再配分する手助けをします。作業に合った配置を選びます。
agent-agent
81k大きな目標を順番に並んだ行動計画にし、状況が変わったときに計画を立て直す方法をエージェントに教えます。
agent-agentic-payments
81kAIの買い物のために、支出の上限、期間、販売店のルール、署名付きの承認を含む支出の委任を管理する手助けをします。
agent-analyze-code-quality
81kコードの品質を確認し、コードの臭い、技術的負債、リファクタリングの案を見つける手助けをします。ファイルは変更しません。