Give a world a quota, and Plurics charges its CPU time, the bytes it writes, and its egress traffic against it. When the quota runs out, the world freezes instead of dying, and a grant resumes it with no lost work. This RFC specifies the quota tree and its conservation rules, the declarative meter that turns a response stream into units, and the userland tools built on them.
$ plsh world fork job --compute-ms 60000 --units 5000000
forked job from main (id a1bb11354781, quota node 2)
$ plsh quota ls
ID NAME STATE REASON COMPUTE_MS COW_BYTES EGRESS_BYTES UNITS
1 root RUNNING - 2/- 0/- 0/- 0/-
2 job RUNNING - 2/60000 0/- 0/- 0/5000000
$ plsh quota grant job --units 1000000
granted {"units":1000000} to job (node 2): RUNNINGQuotas#
Plurics keeps one tree of quota nodes. In the session above, job gets node 2 under the root, node 1. Every node holds a QuotaVector of four generic dimensions:
| Dimension | Counts | Charged by |
|---|---|---|
compute_ms | CPU time in milliseconds | Each execution: a 1 ms hold before it starts, settled at the CPU time of its process tree |
cow_bytes | Copy-on-write bytes written | WriteFile, reserved and settled before the write lands; the files a running process or a verification creates or changes, settled when it ends |
egress_bytes | Bytes moved through the egress door | The gateway's meter, in both directions |
units | An opaque counter: requests, rows, pages, or tokens | The gateway's meter, as a route's meter spec defines it |
The core gives units no meaning. A userland tool decides what one unit is worth.
A process writes straight into its working copy, so the daemon meters cow_bytes by comparison. When a process first starts in a metered world, the daemon records every regular file of the working copy by inode, so a hard link counts once. When the process ends, and before a fork, seal, merge, rewind, or discard, it charges each new or changed file its allocated bytes. Deleting files earns no credit. An overrun freezes the node with QuotaExhausted(cow_bytes).
- Limits hold. For every node and every dimension,
limit ≥ settled + held + leased, andavailable = limit − settled − held − leased. - All-or-nothing holds.
reserveandextendare vector transactions against the node and every ancestor: either the whole vector is held everywhere, or nothing is. - Reservations move through
Held,Streaming,Settling, and one ofSettled,SettledConservative, orReleased.settlerefundsheld − actualand is idempotent. A deniedextendmoves the hold toSettling, and the work stops at its next boundary. - Descent. A world without a node of its own draws on its nearest ancestor's, and a new node is carved under that same ancestor. No fork, however deep, escapes the quota of the world it came from. Escrow leases fund remote nodes and count as
leasedin every ancestor. - Restarts. Each broker start bumps a
BrokerEpoch. Holds from an older epoch settle conservatively, at the amount held, and reconcile later. - Conservation. Every call writes balanced double-entry records against a system account in the ledger, and the audit balances after every call.
plsh statusreports it.
Freeze and thaw#
A node is Running, WrapUp, or Frozen. Past its soft watermark, 80% of its limit by default, it enters WrapUp. There, only a pre-reserved wrap-up allowance, 5% of its compute_ms and units stock, remains for small calls. A frozen node refuses every new hold: an execution does not start, a write fails with Quota, and the egress gateway answers 402.
FreezeReason | Cause | Lifted by |
|---|---|---|
QuotaExhausted(dim) | A dimension hit its limit | QuotaGrant that covers the shortfall |
ThrashDetected(detector) | A loop breaker reached its last stage | QuotaThaw |
Revoked | The parent reclaimed the subtree | QuotaThaw |
EmergencyFreeze | An operator stop | QuotaThaw |
Freezing kills nothing. A frozen world keeps its state, and a top-up such as the plsh quota grant in the opening session resumes it with no lost work.
Loop breakers. A program can also burn its quota without making progress, by repeating one failing call or by forking without end. Five deterministic detectors watch a node's step signals for such loops. Each detector is a pure function of its window, so replaying the same signals yields the same verdicts.
| Breaker | Trips on |
|---|---|
D1IdenticalCall | The same deterministic call, against the same world root, 3 times in 16 calls |
D2ZeroProgress | Units spent with no progress event reaching min(20_000, available / 10) |
D3TreeOscillation | The world tree flipping between two hashes, A B A B, within 16 commits |
D4ErrorStorm | The same error from the same method 5 times in a row; a backoff warns at 2 |
D6SpawnFanOut | More than 16 active descendants, or delegation deeper than 4 |
A firing breaker escalates through four stages:
- Annotate the next step.
- Throttle with a backoff of 250, 1,000, then 4,000 ms.
- Restrict the offending call for 4 steps.
- Freeze the node with
ThrashDetected.
A progress event (a non-empty diff, a new output, a flipped verdict, or a new outbox intent) resets D2.
Response metering#
Counting bytes is easy; counting what a response is worth is not. A model provider reports tokens in a usage field, a database reports rows, and a crawler counts pages. A route may carry a JsonFieldMeterSpec: rules that read unsigned integer fields out of a response and turn them into units. Whoever writes the route decides which fields count and what each is worth.
{
"reserve_units": 2000000,
"rules": [
{"pointer": "/message/usage/input_tokens", "weight": 3000, "counter": "input"},
{"pointer": "/usage/input_tokens", "weight": 3000, "counter": "input"},
{"pointer": "/usage/output_tokens", "weight": 15000, "counter": "output"}
],
"fallback_units_per_byte": 500
}- Pointers are RFC 6901 JSON pointers.
JsonFieldTallyapplies them to every complete line of the decoded body, whether an event stream'sdata:line or an NDJSON line. If no line parses, it applies them to the whole body as one JSON document. - Weights are fixed-point integers: a match adds
value × weightunits. Arithmetic saturates. Negative and non-integer values never match. - Repeats. When a pointer matches in several events of one response, the largest value counts by default, so a cumulative counter that later events repeat is not counted twice. With
accumulate, every match is summed. - Counters. Rules that name the same
countermeasure one quantity reported at different places. The counter costs the largestvalue × weightamong its rules, not their sum. - Reserve and fallback. The gateway holds
reserve_unitsbefore it forwards the request. A 2xx response that matched no rule costsfallback_units_per_byteper byte: lenient when parsing fails, conservative on the quota. - Bounds. At most 64 rules (
METER_RULES_MAX) and 256-byte pointers (METER_POINTER_MAX). The meter skips lines over 1 MiB (METER_LINE_MAX) and parses a whole body only up to 256 KiB (METER_BODY_MAX).
The meter reads bytes and never rewrites them. A route without a spec uses the gateway's default meter: one unit per request or tunnel, plus the bytes it moved. The same spec meters rows for a database migration, pages for a crawler, and compile jobs for a build farm.
Userland tools#
These programs ship with Plurics. Each depends only on plurics-core and reaches the daemon through its socket, as any other program could.
plsh is the shell and CLI. The same binary runs on the host and inside a world, where it reaches the daemon through the world's port and every command is checked against that port's grants. Inside a world, self names the caller, and world fork --from defaults to it. plsh exits 0 on success, 1 when the daemon refuses a request, and 2 on a usage or connection error. exec, shell, exec-attach, and exec-wait exit with the program's own status instead: 124 if it timed out, 137 if it was killed. plsh help lists every command.
plurics-tui is the terminal review console, built on OpenTUI. It observes the daemon and merges on a person's behalf: views of worlds, triage, and quotas, a diff drawer, and live merge, discard, and quota top-up. Pressing e on a world with staged effects opens a ReleaseOutbox card that shows the staged calls and the bundle's approval digest; approving it calls EffectRelease with that digest. A newly shown control ignores activation for 200 ms, so a stray keypress cannot approve what the person did not see. --once prints one frame and exits. Like plsh, it connects over TCP with --addr and --key.
plurics-agent, from plurics-porcelain, runs coding agents in worlds. It turns what it knows about each provider into the generic pieces above:
- Presets.
--provider anthropic,openai, oropenai-responsesbecomes an egress route to the provider. The route carries the vault credential that the gateway injects and a meter spec over the provider'susagefields, priced in nano-dollarunits: one dollar is 1,000,000,000 units. The world seesANTHROPIC_BASE_URLorOPENAI_BASE_URLat its own egress door and a placeholder key; the real key never enters it. runruns an agent in a world, forked if needed and capped by--budget-usd.spawn --n <count>forkscountworlds, runs the agent in all of them in parallel, then reports each world's status, spend, and state. A world out of budget gets402untilplsh quota granttops it up.mcpserves the Model Context Protocol on standard input and output as newline-delimited JSON-RPC 2.0. An agent that speaks it gets tools that each make onepluricsdcall: fork, list, diff, seal, verify, and discard worlds; stage an outbound call; read and bundle an outbox; and release a bundle. Inside a world, the server connects to$PLURICS_PORTfirst, so every tool call is confined to that port's grants and subtree. A release througheffect_releasepasses the same daemon checks as any other: a reviewer world releases only a strict descendant's clean outbox (RFC-002). Host-only methods such asVaultStore,InitRepo, andShutdownare not tools.export-gitcommits a world's tree ontorefs/heads/<branch>of a real Git repository with the realgitbinary. It parents the commit on the commit the world was imported at, or on--base. It never touches the repository's working trees or indexes, and it refuses a branch that is checked out.