---
title: "mova-serve-quota — Mova code model"
description: "Mova code model of tools/mova-serve/src/quota.rs: components with their labels, obernants and the model text."
url: "https://groupants.elamur.ai/free/en/mova/tools/mova-serve/src/quota.rs.groupant/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · [Research](https://md.research.elamur.ai/free/en/) · **Groupants**

This page as HTML: <https://groupants.elamur.ai/free/en/mova/tools/mova-serve/src/quota.rs.groupant/>

# mova-serve-quota

The groupant beside tools/mova-serve/src/quota.rs in the Mova repository: what the code computes, what it never does, how to go back from its outputs, its invariants, cost and checks.

## Facts

- **kind:** groupant
- **status:** partial source bound model
- **source:** [`tools/mova-serve/src/quota.rs`](https://github.com/ElamurAI/mova-free/blob/main/tools/mova-serve/src/quota.rs)
- **repository folder:** [`tools/mova-serve/src/quota.rs.groupant`](https://github.com/ElamurAI/mova-free/tree/main/tools/mova-serve/src/quota.rs.groupant)

> **Implementation material.** A Mova code model describes this code at one source revision: partial models, finite checks and their stated scope. It is not a reviewed general exposition, and its labels are shown as written, never raised.

## Components

| component | label | where |
|---|---|---|
| **Approximant** | partial | [Approximant](#approximant) |
| **Ast** | partial | `syntax.json` |
| **Cost** | symbolic source derived | [Cost](#cost) |
| **Descriptant** | present | [Descriptant](#descriptant) |
| **Invariant** | partial | [Invariant](#invariant) |
| **Tests** | executed bounded checks | [Tests](#tests) |

## Obernants

The typed relations around the forward model: the behaviour complement (what the code never does), the reverse reconstruction (every input compatible with an output) and specialised views.

| relation | type | label | where |
|---|---|---|---|
| Behavior complement | behavior complement | partial source derived model | [Behavior complement](#behavior-complement) |
| Reverse reconstruction | reverse reconstruction | partial source derived model | [Reverse reconstruction](#reverse-reconstruction) |
| Model presence | model presence | partial source derived model | [Model presence](#model-presence) |

## Model text


### Descriptant

Word quotas: anonymous 5 000 words a request and 250 000 a day per IP; accounts by tier (free: 20 000 and 1 000 000;
more tiers from a plans file); day counts kept two days on disk.

### Approximant

`check(who, w) = w ≤ per_request ∧ used(who, day) + w ≤ per_day`; `charge` adds w.

### Invariant

Counts never decrease within a UTC day; files older than yesterday are removed at the change of day; an unknown tier
falls back to free.

### Cost

O(log n) a call; a flush writes the day's map.

### Behavior complement

No billing, no carry-over between days.

### Reverse reconstruction

The day's file recovers each client's words that day.

### Model presence

Plans: the anonymous plan is fixed; tiers come from the plans file.

### Tests

`quota::tests`: plan limits, the daily refusal, another client and the next day unaffected, counts surviving a
restart, old days removed, word counting; `plan_tests`: tiers from the file and a malformed tier refused.

## Provenance

- **source SHA-256:** `bc190c619940e9d5…`
- **repository commit:** `2e25d7bfae9a`
