The rule

An agent edit on an encrypted doc costs the author 1x the raw LLM token count. No multiplier. No markup for encryption overhead. An edit that StackNet reports as { input_tokens: 1847, output_tokens: 134 } charges the owner 1847 + 134 = 1981 tokens — the same it would cost if the doc were plaintext.

Why

Encryption is a product commitment, not a billing surface. We eat the server-side cost of decrypt → LLM → re-encrypt. If we passed that cost through as a markup, we’d be penalising users for opting into the more secure mode. The invariant is enforced by code:
  • /api/docs/:id/agent-edit calls bumpAgentBudget with the raw input_tokens / output_tokens values from StackNet’s /v1/chat/completions response, with no numeric transformation.
  • A smoke test (lib/docs/__smoke__/metering.smoke.ts) statically inspects the route source and fails CI if anyone adds a multiplier, rounding, or Math.ceil to the budget call.

What the owner sees

In the Usage tab of the share panel:
  • Doc-wide total today — sum of input + output tokens across all agents
  • Per-agent rowinput in · output out = total tokens, plus edits and bytes written
  • Progress bar when a doc-wide cap is set — turns destructive- coloured at ≥ 90 %
All counts are the raw numbers StackNet reported. No “billable units” abstraction.

What the agent sees

The response body of each successful agent-edit:
tokensUsed is the same number added to DocAgentBudget. If a given edit shows { input: X, output: Y }, the doc owner’s daily budget moves by exactly X + Y.

Caps

Three layers apply in order, all checked before the LLM is called:
1

Burst (5 edits / 60 s per agent)

Defense against a compromised token firing hundreds of edits in a minute. Hard-coded — the owner can’t raise this.
2

Per-agent daily caps

DocMember.dailyEditCap (default 20) and dailyTokenCap (default 70 000 = 50 k in + 20 k out). Set at invite time, adjustable by re-inviting.
3

Doc-wide daily cap

Doc.dailyTokenCap — sums input + output tokens across all agents on this doc. Null = no cap. Set from the Usage tab.
All three are evaluated before calling StackNet, so a cap-hit costs 0 tokens. Log line: [agent-edit] cap_hit doc=… agent=… reason=… used=… cap=….

Comparison: encrypted vs plaintext docs

ScenarioEncrypted docPlaintext doc
Agent asks to add a 3-item list (2k input, 200 output)2200 tokens billed2200 tokens billed
Same edit, doc is 10 KB2200 tokens billed2200 tokens billed
Edit rejected by cap0 tokens billed0 tokens billed
Edit rejected by injection filter0 tokens billed0 tokens billed
If you ever see the encrypted column show more than the plaintext column for the same work, file it as a bug.