YOKE_Marketplace
← Marketplace

Metering & Billing Loop

FREE TEMPLATE

by YOKE Templates

A self-contained usage-metering loop: a periodic meter feeds a ledger script, a balance view tracks spend, and a credit gate pauses the worker at the low-water mark.

version 1updated 2026-07-22published 2026-07-22visibility public
This template is free. Launching runs it on a cloud box — $50/mo (2 GB) or $100/mo (4 GB), cancel anytime. You'll pick a size next.
Your swarm runs from the YOKE desktop app: after checkout you install it and sign in to bring the agents online.
Sign in to launch · runs on a cloud box · cancel anytime
Structure
Swarm file (blueprint body)
# lifecycle.swarm.toml — the METERING LOOP as a declarative swarm config.
# Infrastructure-as-code for the internal lifecycle loop (no external money/AWS):
#
#   [METER trigger] ──▶ [LEDGER script] ──▶ (BALANCE View) ◀── [CREDIT-GATE script] ──▶ [WORKER]
#     periodic usage       debit ×markup        balance            balance ≤ low-water?      paused
#                                                                     → halt
#
# Node KIND is from template_id; wire KIND is DERIVED from endpoint kinds:
#   meter→ledger   Trigger→Script  = Comms      (the metering event feed)
#   ledger→balance Script→Dataset  = DataAccess (write the running balance)
#   gate→balance   Script→Dataset  = DataAccess (read the balance)
#   gate→worker    Script→Agent    = Comms      (the halt/pause signal)
#
# The script modules (yoke_ledger.wasm, yoke_credit_gate.wasm) are attached at
# provision time (SetScriptModule) — grid layout is declarative; bytes are not.

[[agents]]
id = "meter"
name = "METER"
gx = 2
gy = 3
width = 2
height = 2
template_id = "builtin-loader"   # cron Trigger: periodic usage rollup

[[agents]]
id = "ledger"
name = "LEDGER"
gx = 6
gy = 3
width = 2
height = 2
template_id = "builtin-script"

[[agents]]
id = "balance"
name = "BALANCE"
gx = 6
gy = 6
width = 2
height = 2
template_id = "builtin-dataset"  # the balance View both scripts share

[[agents]]
id = "gate"
name = "CREDIT-GATE"
gx = 10
gy = 3
width = 2
height = 2
template_id = "builtin-script"

[[agents]]
id = "worker"
name = "WORKER"
gx = 10
gy = 6
width = 2
height = 2
# no template_id → an Agent: the thing that gets paused when credit runs out

[[wires]]
from = "meter"
to = "ledger"

[[wires]]
from = "ledger"
to = "balance"

[[wires]]
from = "gate"
to = "balance"

[[wires]]
from = "gate"
to = "worker"