Expand description
GET /v1/storage + GET /v1/usage — the team server’s billing-plane
surface (docs/contracts/billing-plane-v2.md, GL #463).
/v1/storage reports the hosted workspace footprint (retrieval index,
knowledge store, event log — everything the server persists under its data
root and the workspaces’ .lean-ctx state dirs). It is server-measured:
the control plane’s hourly metering_job polls it for Stripe meter events
and threshold mails, so the report carries plain numbers and no content.
Field casing is camelCase (usedBytes), matching what
lean-ctx-cloud/src/metering_job.rs and metering.rs::from_storage read.
/v1/usage is the unified usage snapshot for the account dashboard: the
savings roll-up (from the same signed-batch store as /v1/savings/summary)
plus a storage block in snake_case (used_bytes) — the spelling
metering.rs::from_usage expects for that block.
Sizing uses allocated disk blocks (st_blocks * 512) on Unix so sparse and
partially-written files bill what they actually occupy; on other platforms
it falls back to logical file length. Reports are cached for
STORAGE_CACHE_TTL per process — the walk is O(files) and the metering
job polls hourly, so 60 s keeps repeated dashboard hits cheap without
letting bills go stale.
Authorisation: both routes are gated by TeamScope::Audit
in the team auth middleware — same sensitivity class as /v1/metrics and
/v1/savings/summary, and the scope the control plane’s audit-only token
carries.
Structs§
- Storage
Cache - Cached report + when it was measured.
- Storage
Component - One measured storage component (a directory or file the server persists).
- Storage
Report - A measured (uncached) storage report.
- Storage
Roots - The measurement inputs, fixed at server startup.
Functions§
- v1_
storage GET /v1/storage—camelCase, served from the 60 s cache.- v1_
usage GET /v1/usage— savings roll-up +snake_casestorage block.