How this repository is put together, written for someone arriving at it: the pieces, how a request moves between them, where state lives, and which module owns what. Product intent, credential rules, ownership and non-goals live in the master design, apache/rai-private → services/llmao/README.md. Each part of the system has its own design doc, linked where it comes up; this document is the map between them.
Two processes are ours, both on one Puppet-managed host, and everything else is outside.
main.py. It knows who you are at the Foundation (OAuth, LDAP), turns projects into LiteLLM teams, issues and revokes keys, runs the fleet's control plane, meters the fleet, and renders every page. It never carries a prompt.llm.apache.org, the inference pipe and the meter. A tool calls its OpenAI-compatible API with a key; it checks the key, the team's budget and rate limits, routes to a deployment, and records the spend. Two callbacks of ours, litellm_hooks.py, run inside it: empty_completion_guard, which rejects a 200 that carries no answer with a message saying why, and prompt_log, which writes every request to the prompt log./v1/memory store, a key-value table in the same Postgres./x1, written by the hook inside the proxy and read only by tools at a shell on the host. Design: docs/prompt-logging-design.md.docs/rental-protocol.md; states: docs/rental-lifecycle.md; provisioning: hosting/README.md.apache/infrastructure-p6, renders the three config files from one set of node data: config.yaml for the portal, litellm.yaml for the proxy, and the systemd units. models.yaml, the model recipes, is in this repository and read by the portal only.The inference path, tool to model, never enters the portal. The portal sees it afterwards, in LiteLLM's spend log and in the demand values rolled up from it; the hooks see it as it happens, inside the proxy.
Five traces, each from the first touch to the last place it leaves a mark. Together they are the connections between the pages, LiteLLM, the log files and the fleet.
asfquart.construct(...), locally with mkcert certificates for localhost.apache.org.projects and the PMC committees. That is all the portal knows about membership: the current person‘s projects, never a PMC’s roster.llmao/seam.py turns that into authorization per project: a member may see the project; a PMC member, or a site admin named in config.yaml, may administer it. @asfquart.auth.require guards the route; the project-scoped rule is the seam's./keys a person picks a project and a purpose. A personal key binds the ASF uid to the project's team; an automation key is team-scoped, and who may create one is an open policy question (docs/STATUS.md).LiteLLMBackend (llmao/proxy/client.py), which speaks LiteLLM‘s admin API with the master key over async httpx. The project is a LiteLLM team whose alias is the project’s LDAP name; the team id is cached in-process, warmed at startup and fail-fast if LiteLLM is down.llmao:tiers) are applied to it there./x1. Nothing a client sends switches the log off./projects reads the team‘s spend from LiteLLM each time, and the usage API reads LiteLLM’s daily activity.demand-rollup runner reads the closed day‘s spend log page by page, folds it into one demand value per model per hour, spawns bin/llmao-prompt-log rollup --json for the day’s file to add what only the log knows, and stores the result. /admin/capacity reads those values as “What was asked”.provision.sh as its entrypoint. The rental boots, installs vLLM, and asks the portal GET /vllm/config with the fleet key, naming itself by the provider‘s instance id in X-LLMAO-Host. That name is the server’s identity: the key it is looked up by in fleet.hosts, what its bearer is derived from, what an approval is granted to.models.yaml, a container listen port, and the derived key. The public port the provider maps it to is never sent; the portal learns it from the provider's listing.fleet-lifecycle runner reads the provider's listing to place each server at an address, then probes /health and, when the key or context window needs asking, /v1/models. A server moves through Awaiting, Loading, Healthy, and on trouble Unhealthy, Stalled, Rejected or Foreign (docs/rental-lifecycle.md).DeploymentManager adds a deployment to LiteLLM with /model/new, re-reading /model/info to confirm, and the proxy starts routing to it. When it is down the deployment is deleted. fleet.hosts plus in-memory approvals are the single source of intent; what LiteLLM holds that nothing intends is an orphan, shown to admins and never deleted unattended.metrics-sampler reads the server's /metrics every sample_interval_s, folds the readings into the current hour, and the capacity-writer stores each finished hour as a capacity value. /admin/capacity reads those as what each server did, beside the demand values for what was asked. Design: docs/capacity-design.md.health_interval_s), the RunPod listing (ten minutes), the skew and outside-edits checks (skew_interval_s), the metrics sample (sample_interval_s).prompt_log_retention_days.capacity-prune and memory-prune delete what has outlived its retention in the memory store.All of these are runners: app.add_runner in main.py, each one while True loop with its own interval, listed by name in the portal diagram under “Reference”.
One thing is not a runner and not the portal‘s at all: the analysis of the prompt log’s content. An admin runs the scripts in analysis/ at a shell on the host, in the quiet hours; they read the day files and keep their own store, and nothing of theirs reaches the portal except what an admin writes down. Design: docs/analysis-design.md.
| Where | What | Written by | Read by | Kept |
|---|---|---|---|---|
| Postgres, LiteLLM's tables | teams, keys, spend log, daily activity, deployments (store_model_in_db) | LiteLLM | the portal through the admin API | LiteLLM's own rules |
/v1/memory: llmao:request:<id> | access requests | the portal | /admin | pending ones always; decided capped at the last 50, lapsed approvals dropped, by memory-prune |
llmao:tiers | the tier limits an admin changed, one value | /admin | key issuance | overwritten |
llmao:skew: | what the outside-edits check found | litellm-outside-edits | the “Work needed” strip | rewritten each pass |
llmao:action:<stamp> | what site admins did | the admin actions | /admin Recent work | action_retention_days, by memory-prune |
llmao:log:admin:, llmao:log:user:<uid>: | notices: something happened that the admins, or one person, ought to know | whatever has something to say | /admin, the person's pages | until acknowledged |
llmao:capacity:<hour>:<server> | a capacity value: what one server did in one hour | capacity-writer | /admin/capacity | capacity_retention_days, by capacity-prune |
llmao:demand:<hour>:<model> | a demand value: what was asked of one model in one hour, with each project's share | demand-rollup | /admin/capacity | the same |
llmao:demand-day:<day> | a day marker: fold version, sources, count, log status for a rolled-up day | demand-rollup | demand-rollup | the same |
/x1/llmao/prompt-log/prompts-<day>.jsonl, .gz after the day | the prompt log: one record per request | the prompt_log hook, through loguru | bin/llmao-prompt-log for the rollup; the analysis/ scripts | prompt_log_retention_days, by the sink; root only |
analysis_dir/prompts.db | the analysis store: which days are in, the clusters of records with one exemplar each, the judge's verdicts | the analysis/ scripts, run by an admin | the same scripts; never the portal | analysis_retention_days, by the scripts; root only |
| in the portal's memory | Fleet (servers, deployments, approvals, rentals, orphans), HourlyRollup (the hour being sampled), the team-id cache | the runners | the pages | lost at restart, rebuilt from config and probing |
config.yaml, litellm.yaml | settings, secrets, fleet.hosts, providers | Puppet | the portal, the proxy | the node data in p6 |
models.yaml | model recipes, capability chips, governance fields | committers | the portal | this repository |
Per-project token caps are still team metadata in LiteLLM. Those three stored kinds in the capacity domain have one name each, capacity value, demand value and day marker; “row” means a row of LiteLLM's spend log or a line of a rendered table.
Stored values outlive the code that wrote them, so each kind has a rule for how a change reaches history.
FOLD_VERSION in llmao/capacity.py is stamped into every day marker. When the fold changes what a demand value holds or what counts as demand, the constant is bumped, and the rollup‘s next run treats every day whose marker carries an older version as missing: it re-reads that day from LiteLLM’s spend log and the prompt log, deletes the day's old demand values, writes the new ones and a new marker, oldest day first, one day at a time, stopping at the first failure and resuming next run. Nobody touches the store by hand. Observed on 2026-11-04, version 2 to 3: 89 days, the whole retention window, re-rolled in about five minutes, roughly three seconds a day, with the page serving throughout and reading a mix of old and new shapes, which the reader tolerates. Both design docs name the version and what each bump changed./metrics readings that cannot be taken again, so they carry no version. A change to their shape is a change the reader must tolerate for a retention window.| Module | Role | Design |
|---|---|---|
main.py | construct the asfquart app, build Fleet and LiteLLMBackend, register the runners | |
pages.py, api.py | the HTML pages and the JSON API; both bind to asfquart.APP | |
llmao/auth.py, llmao/seam.py | identity from the session; authorization per project; the project-scoped team and key operations | docs/access-control-design.md |
llmao/proxy/client.py | LiteLLMBackend: the one transport to LiteLLM's admin API and its managers for teams, keys, metering, tiers, requests, skew, notices, memory | |
llmao/proxy/deployments.py | DeploymentManager: what LiteLLM has, and the only writes that change it | docs/fleet-reconcile-design.md |
llmao/fleet.py, llmao/intent.py, llmao/reconcile.py | the live fleet, what we intend to serve, and the pure joins between intent, rentals and LiteLLM | docs/fleet-reconcile-design.md |
llmao/provisioning.py, llmao/vllm_client.py, llmao/vast_client.py, llmao/runpod_client.py, llmao/rental.py | the rental's config at boot; what we read from a vLLM process; what each provider reports about our rentals | docs/rental-protocol.md |
llmao/model_status.py | the lifecycle verdicts and the model roll-up, as pure functions of a snapshot | docs/rental-lifecycle.md |
llmao/models.py | models.yaml | |
llmao/sampler.py, llmao/capacity.py, llmao/planning.py | reading /metrics; capacity values, demand values, the rollup and the pruner; what the values say, for the page | docs/capacity-design.md |
llmao/prompt_log.py, litellm_hooks.py, bin/llmao-prompt-log | the record, the day files and the rollup of a day; the hooks LiteLLM loads; the tool the runner spawns | docs/prompt-logging-design.md |
llmao/access_requests.py, llmao/actions.py, llmao/pruner.py | requests a person makes and an admin answers; the admin action log; daily retention | |
llmao/token_window.py | a rolling token allowance as daily buckets | |
llmao/fmt.py | figures and moments as a person reads them | |
bin/ | the admin tools run at a shell on the host | bin/README.md |
analysis/ | the prompt log's reports and content analyses, R&D outside the package; nothing in llmao/ or bin/ imports from it | docs/analysis-design.md, analysis/README.md |
hosting/ | what runs on the rentals: provision.sh, the installer, the RunPod image | hosting/README.md |
tests/ | the suite, with MockBackend and a fake transport; injected only by tests, never a runtime mode | docs/llmao-harnesses.md |
The words the pages and the fleet code share.
model parameter (qwen3-8b). A deployment is one place it is served: a vLLM server on a rental, or a provider‘s endpoint. One model may have several deployments at once; LiteLLM’s order puts our rentals first.config.yaml is loaded as APP.cfg, an EasyDict, read with dotted access. Standalone python main.py watches config.yaml for changes; production restarts the service after Puppet writes it.POST /do-* then 303 to a GET display, with a flash for status. JSON handlers use @api in api.py. Do not wrap the Quart ASGI app with Werkzeug ProxyFix.LiteLLMBackend, and every deployment write through DeploymentManager, which confirms by re-reading. The offline MockBackend lives under tests/ and is a test fixture, not a second runtime.fleet.hosts plus in-memory approvals say what should run; servers and LiteLLM deployments are derived. A deployment config intends but LiteLLM lacks is a visible skew, not a mystery, and nothing deletes an orphan unattended.Build status and backlog: docs/STATUS.md. Quickstart and the API surface: ../README.md.
What runs in this process and what each part reads or writes. The HTML and JSON handlers answer requests; the runners are the control plane and the meters; everything they learn sits on Fleet or in the memory store, where the pages read it.
Fleet is built at startup from config.yaml (intent.intended_deployments turns fleet.hosts and providers into IntendedDeployment rows) and holds the fleet state the runners and pages read. LiteLLMBackend takes the same Fleet; it and its DeploymentManager (llmao/proxy/deployments.py, which adds and deletes deployments and confirms every write by re-reading /model/info) are the only things that write deployments to LiteLLM. The lifecycle/skew logic in model_status.py is a set of pure functions: it takes a DeploymentSnapshot (frozen out of a deployment + its server by fleet.snapshot_for_status) and returns a status object, with no shared mutable state.
classDiagram class Fleet { +servers: list~VllmServer~ +deployments: list~FleetDeployment~ +models: models.yaml rows +provisioning: ProvisioningRecord +approvals: dict~host, Approval~ +litellm: LiteLLMDeployments +orphans: list~Orphan~ +vast_rentals, runpod_rentals: ProviderRentals +discovered: dict~name, Discovered~ +ready: Event +run_lifecycle() +probe_all() +place_servers() +approve_models() +model_rollup() } class FleetDeployment { +model_name, name +self_hosted +vllm: VllmServer +provider, litellm_model +litellm: tuple~LiteLLMDeployment~ +litellm_health: LiteLLMHealth +skew: list +api_base +in_litellm } class VllmServer { +model_name, name, served_name +host, address, listen_port, public_port +api_key +rental: Rental +unlisted, unlisted_passes +probe: VllmProbe +state +config_served_at, first_probed_at, first_reached_at +last_ok, fails +key_rejected, rejected_passes +kv_cache_tokens, observed_max_model_len +record_probe() } class IntendedDeployment { +key: DeploymentKey +model_name, name, origin +host, listen_port, recipe, api_key +provider, litellm_model, api_base } class Approval { +host +models +at } class Rental { +provider, id, name +host, ports, status +usd_per_hour } class VllmProbe { +url, at +reached, ok, error +served_status, max_model_len +key_rejected } class LiteLLMBackend { +deployments: DeploymentManager +memory: MemoryStore +teams, keys, metering, tiers +requests, skew, log +warm() +run_skew() +watch_outside_edits() } class DeploymentManager { +fleet +fetch_deployments() +add_deployment() +delete_deployment() +ensure_providers() +sync_selfhost() +check_config_skew() +check_health_skew() } class LiteLLMDeployments { +rows +read_at +under(key) } class DeploymentSnapshot class DeploymentStatus class ModelStatus Fleet "1" *-- "0..n" VllmServer : servers Fleet "1" *-- "0..n" FleetDeployment : deployments Fleet "1" *-- "0..n" Approval : approvals FleetDeployment "1" o-- "0..1" VllmServer : vllm VllmServer "1" o-- "0..1" Rental : placed on VllmServer "1" o-- "0..1" VllmProbe : last probe VllmServer ..> IntendedDeployment : from_intended() FleetDeployment ..> IntendedDeployment : from_intended() Fleet "1" -- "1" LiteLLMBackend : held by LiteLLMBackend "1" *-- "1" DeploymentManager : deployments DeploymentManager ..> LiteLLMDeployments : fetch_deployments() Fleet ..> LiteLLMDeployments : update_litellm_deployments() DeploymentSnapshot ..> FleetDeployment : snapshot_for_status() DeploymentSnapshot ..> VllmServer : snapshot_for_status() DeploymentSnapshot ..> DeploymentStatus : deployment_status() DeploymentStatus ..> ModelStatus : model_status()
The capacity side has its own small set, all in llmao/capacity.py and llmao/sampler.py, sharing nothing with the fleet classes but the Fleet the sampler reads its targets from:
classDiagram class MetricsSampler { +targets() +sample_once() +run() } class HourlyRollup { +record() +missed() +take_finished() +put_back() } class Hour { +hour, server, model_name +readings, busy, queueing +kv_sum, kv_peak, counters, buckets +usd_per_hour +row() } class CapacityStore { +write() / read() +write_demand() / read_demand() +demand_days_done() +mark_demand_day() / clear_demand_day() +prune() } class CapacityWriter { +write_finished() +run() } class CapacityPruner { +run() } class DemandRollup { +missing_days() +roll_up(day) +roll_up_missing() +run() } class UsageManager { +spend_log(day) } MetricsSampler --> HourlyRollup : record() HourlyRollup "1" *-- "0..n" Hour CapacityWriter --> HourlyRollup : take_finished() CapacityWriter --> CapacityStore : write() CapacityPruner --> CapacityStore : prune() DemandRollup --> UsageManager : spend_log(day) DemandRollup --> CapacityStore : write_demand(), mark_demand_day() CapacityStore --> MemoryStore : /v1/memory