Documentation
¶
Overview ¶
Package account resolves who a request pays as — the billing account, the wallet money lands in and the gate reads out of. It is the ONE rule, shared by every serving layer (ai, commerce, cloud), so a customer can never top up one account and spend from another.
The account is derived from two facts — the org and the user — by one function, Of. The default is per-org (a company pays for what its members spend); an org on the Personal set instead holds a per-user account (a person has their own wallet). This is policy, read from the environment once, so the rule lives in data, not scattered branches.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Of ¶
Of returns the billing account for (org, user) — the value passed to the gate and the ledger:
pooled org → "org" (a company; members share one account) personal org → "org/user" (a person holds their own account) org-only caller → "org" (a service key has no user; it pays from the pool)
Empty org yields "" (the caller cannot bill — fail closed). An already-qualified "org/user" is never double-prefixed, so a resolved account round-trips.
func OfKey ¶
OfKey is Of for a caller that already holds the "org/user" composite as one string (a usage record, a resolved key). org may be empty — it is then taken from the key's prefix.
func OfKind ¶
OfKind is Of for an authenticated caller, accounting for machine identities. A machine (client-credentials / application) principal has no funded per-user account, so it always pays from the org pool — billing it "org/app" would 402 legitimate service traffic. `machine` is true for a non-human principal.
Types ¶
This section is empty.