Usage counts¶
TL;DR
usage(#510) keeps one number per UTC day, account, API token, library and operation (read,search,answer). Never a query, a path or any text.- No domain knows it is counted: bootstrap wraps the driving ports and counts after the request is served.
- Counts are written in the background every 10 s, never on the request's path.
- The people leaderboard is opt-in, per person and per instance.
usage (#510) counts how ExactDocs is used: one number per UTC day, account, API token, library and
operation (read, search, answer) in usage_daily_counts, never a query, a path or any text.
Accounts, tokens and libraries are held by value (empty for none: no person, a browser session, an
operation over several libraries), so the table depends on no other domain's.
Who counts¶
- No domain knows it is counted.
bootstrap/usage_meter.pywraps the driving ports the REST and MCP adapters serve reads, searches and answers with: catalog'sGetArticle, retrieval'sReadChunk,SearchDocs,SearchAllLibraries,QueryDocsandAnswerQuestion. - The request is served, then counted with the account and token of the request (
bootstrap.caller). - Not counted:
- a request that fails;
- calls made inside the server (the answering agent's own reads, jobs), which use the plain ports;
- anything in a stdio MCP process (read-only).
Never on the request's path¶
RecordUsageadds to an in-memoryUsageTally, at most 100,000 counters. Past that, new ones are dropped and logged.bootstrap.usage_meter.flushingwrites it everyUSAGE_FLUSH_SECONDS(10 s) and once more when the server stops.- Each write is one
INSERT ... ON CONFLICT DO UPDATEtransaction, in key order, so processes sharing a PostgreSQL database never deadlock. - A failed write keeps its counts for the next one.
- A report writes the pending counts first, so it includes the requests just served.
Retention¶
The nightly upkeep runs PruneUsage, deleting the days before EXACTDOCS_USAGE__RETENTION_MONTHS
(13 by default).
Reports and leaderboards¶
- Counts are summed in SQL by day and operation, then bucketed into days, ISO weeks, months or years in UTC.
- A leaderboard ranks either:
- libraries: always, and only those the caller may read (the
LibraryAccessport, bridged to identity's library roles byIdentityAccessPolicy.readable); - or people: only while
EXACTDOCS_USAGE__PEOPLE_LEADERBOARDis on.
- libraries: always, and only those the caller may read (the
- Each subject also gets its rank in the previous period among the same subjects.
People are opt-in¶
- The
Peopleport (bootstrap/bridges.py:IdentityLeaderboardPeople, over identity'sFindLeaderboardPeople) answers which accounts exist, are enabled and set theleaderboard_opt_ininterface preference. - Whether the board is on is usage's own setting (
UsagePolicy); identity only knows who agreed. - Anyone not shown by name is summed into one
othersgroup of the operators' report.