account

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

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

func Of(org, user string) string

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

func OfKey(org, key string) string

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

func OfKind(org, user string, machine bool) string

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.

func Personal

func Personal(org string) bool

Personal reports whether an org holds per-user accounts rather than one pooled account. It is the ONE switch between the two billing shapes.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL