Elamur Groupants⌕
☰

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

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

componentlabelwhere
ApproximantpartialApproximant
Astpartialsyntax.json
Costsymbolic source derivedCost
DescriptantpresentDescriptant
InvariantpartialInvariant
Testsexecuted bounded checksTests

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.

relationtypelabelwhere
Behavior complementbehavior complementpartial source derived modelBehavior complement
Reverse reconstructionreverse reconstructionpartial source derived modelReverse reconstruction
Model presencemodel presencepartial source derived modelModel 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

This page in Markdown → https://md.groupants.elamur.ai/free/en/mova/tools/mova-serve/src/quota.rs.groupant/