control

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 95 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package control is the admin-plane HTTP API: /auth/*, CRUD across the catalog and tenancy kinds, /version, /master-key/*, /secret-keys, /reload.

Mount(r, deps) wires huma+chi onto an existing chi router and returns the huma.API. main.go constructs Deps and calls Mount.

Index

Constants

View Source
const SCIMPrefix = "/scim/v2"

SCIMPrefix is where the SCIM base URL lives on the control listener.

Variables

View Source
var ErrNoSigningKey = errors.New("control: no token signing key")

ErrNoSigningKey means the deployment has no token signing key — tokens cannot be minted until one is configured.

Functions

func CORS

func CORS(allowedOrigins ...string) func(http.Handler) http.Handler

CORS returns a middleware that handles preflight (OPTIONS) and adds the headers needed for a credentialed browser fetch from one of the allowed origins. Required because the control API is consumed by a frontend on a separate hostname (e.g. https://relay.wyolet.dev).

allowedOrigins is matched exactly against the Origin header — wildcard origins are not allowed when Access-Control-Allow-Credentials is true, per the CORS spec.

func CatalogReferences added in v0.21.0

func CatalogReferences(ctx context.Context, stores *appcatalog.Stores, kind, id string) ([]catalogprune.Ref, error)

CatalogReferences lists every row referencing the catalog row id of kind (an API singular), unscoped by caller: the rows its delete refuses on and the ones it would take a link from. The catalog prune keeps a row any of them still references, so a prune holds a row wherever an admin delete would refuse or change something else.

func ConfigJSONHandler added in v0.4.1

func ConfigJSONHandler(d Deps) http.HandlerFunc

ConfigJSONHandler serves GET /config.json at the control listener ROOT. The UI fetches ${origin}/config.json at boot — before it knows the /api prefix — so this must stay at root even though the rest of the control API mounts under /api. Static fields are marshalled per request because feature flags (auth:oidc) are settings-driven and may flip at runtime. Mirrors registerConfigJSON's body shaping.

func Mount

func Mount(r chi.Router, d Deps) huma.API

Mount installs the control-plane huma API on r and registers all operations. Returns the huma.API so the caller can attach test-only ops.

Middleware order on r (caller is responsible for wiring these onto the chi router before any operations are matched):

  1. session.Manager.Middleware — loads and saves the cookie session
  2. authenticate — admin token, then session; sets Actor in ctx

Per-operation Middlewares attached by Mount enforce RequireActor on every protected route. Public ops (/auth/login, /version) omit it.

func MountOIDCCallbackRoot added in v0.9.9

func MountOIDCCallbackRoot(r chi.Router, d Deps)

MountOIDCCallbackRoot mounts GET /auth/callback at the listener root — the conventional shape for a registered redirect URI is https://<origin>/auth/callback, not an /api-prefixed path. It runs outside the /api group where Mount installs the session middleware, so it wraps the handler in that middleware itself (Login needs scs context). The /api/auth/oidc/callback mount stays for deployments whose IdP registration predates this path.

func MountSCIM added in v0.10.8

func MountSCIM(r chi.Router, d Deps)

MountSCIM installs /scim/v2 on r, the control listener's root router. It answers 404 while auth:scim is disabled, and is not mounted at all without the stores and the catalog it reads its settings from.

func RequireActor

func RequireActor(next http.Handler) http.Handler

RequireActor blocks any request that has no Actor in context. Stacked after the authenticator chain so any credential it accepts can satisfy it.

func SecretKeyAuditRow added in v0.11.6

func SecretKeyAuditRow(action, id, name string, fields ...string) audit.Row

SecretKeyAuditRow is the audit row of a secret-keys action on data key id ("" for none), named by its scope, a KEK id, or "*" for every scope. The relay secret CLI records the same rows.

func SecretKeyErrorStatus added in v0.11.6

func SecretKeyErrorStatus(err error) int

SecretKeyErrorStatus is the HTTP status of a key ring error: a refusal the operator can act on is a 409.

Types

type AccountKey added in v0.20.0

type AccountKey struct {
	ID     string `json:"id"     doc:"Key id."`
	Name   string `json:"name"   doc:"Key slug."`
	Prefix string `json:"prefix" doc:"Leading characters of the key's plaintext, for recognising it."`
}

AccountKey names a relay key without its secret.

type AccountLimits added in v0.20.0

type AccountLimits struct {
	Lane     LimitsAccount   `json:"lane"     doc:"The account read: the lane requests run in, or a team's or project's own account."`
	Rungs    []LimitsRung    `` /* 336-byte string literal not displayed */
	Tightest *LimitsTightest `json:"tightest,omitempty" doc:"The hard limit with the least left as a share of its cap; omitted when no rung caps anything."`
}

AccountLimits is the caller half of the ladder a lane climbs, with current usage against every limit.

type AccountPolicy added in v0.20.0

type AccountPolicy struct {
	Binding                *policybinding.PolicyBinding `json:"binding" doc:"The binding that holds the account now; null when the account is unbound."`
	PreviousBindingID      string                       `` /* 146-byte string literal not displayed */
	PreviousBindingDeleted bool                         `json:"previousBindingDeleted,omitempty" doc:"True when the previous binding held only this account and was deleted."`
}

AccountPolicy is the binding an account ends up in and the one it left.

type AccountScope added in v0.20.0

type AccountScope struct {
	Kind meta.OwnerKind `json:"kind" enum:"user,team,project" doc:"Kind of the scope."`
	ID   string         `json:"id"   doc:"Id of the user, team or project."`
	Name string         `json:"name" doc:"Username of the user, or slug of the team or project; empty when the row is gone."`
}

AccountScope is the user, team or project an account sits in.

type AccountShare added in v0.20.0

type AccountShare struct {
	SharedAccount ShareAccountRef    `json:"sharedAccount" doc:"The shared account, owned by the receiver."`
	Receiver      account.ShareParty `json:"receiver"      doc:"Who the account is shared with."`
	Usage         *ShareUsage        `` /* 155-byte string literal not displayed */
}

AccountShare is one account a provider account is shared with, and what it drew.

type AccountShares added in v0.20.0

type AccountShares struct {
	Items []AccountShare `json:"items" doc:"The accounts the provider account is shared with, by name."`
	From  time.Time      `json:"from"  doc:"Start of the usage window."`
	To    time.Time      `json:"to"    doc:"End of the usage window."`
}

AccountShares lists a provider account's shares.

type AccountSummary added in v0.20.0

type AccountSummary struct {
	ID          string `json:"id"          doc:"Account id."`
	Name        string `json:"name"        doc:"Account slug."`
	DisplayName string `json:"displayName" doc:"Account display name."`
	Closed      bool   `json:"closed"      doc:"The membership the account stood for has ended: its keys are refused with account_closed."`
}

AccountSummary names an account.

type BoundPolicy added in v0.20.0

type BoundPolicy struct {
	ID   string `json:"id"   doc:"Policy id."`
	Name string `json:"name" doc:"Policy slug."`
}

BoundPolicy names the policy bound to an account.

type ControlHealth added in v0.11.1

type ControlHealth struct {
	Status              string            `json:"status" enum:"ok,degraded" doc:"Overall health verdict."`
	Backends            map[string]string `` /* 170-byte string literal not displayed */
	MasterKeyConfigured *bool             `` /* 151-byte string literal not displayed */
}

ControlHealth is the /healthz body, the same on 200 and 503.

type CounterReader added in v0.20.0

type CounterReader interface {
	Peek(ctx context.Context, cs []limits.Counter) ([]limits.Reading, error)
}

CounterReader reads counters without counting. Implemented by every limits.Limiter.

type Deps

type Deps struct {
	// HealthChecks are the backends /healthz pings, keyed by the name it reports them under. Empty reports ok with no backends.
	HealthChecks map[string]Pinger
	// MasterKeyConfigured reports whether RELAY_MASTER_KEY is set, so stored host keys can be encrypted.
	MasterKeyConfigured bool

	// Identity is the YAML-backed user store used by /auth/login.
	Identity *identity.Store

	// Users is the DB-backed user store. Login consults it before the YAML
	// fallback; the OIDC callback provisions into it. nil disables both
	// (YAML-only deployments).
	Users *user.Store

	// Sessions is the cookie-backed session manager. Login/Logout write to
	// it; the session middleware (installed by Mount) reads from it.
	Sessions *session.Manager

	// TokenSigner holds the inference-token signing key. nil (or an empty
	// signer) disables minting and revoke-by-token.
	TokenSigner *TokenSigner

	// TokenDenylist records a revoked token's jti for the data plane to
	// refuse. nil disables per-token revocation (the token-version bump
	// still works).
	TokenDenylist TokenDenylist

	// MintLimiter caps how often one user may mint an inference token.
	// nil leaves minting unmetered.
	MintLimiter MintLimiter

	// RotateTokenKey generates a fresh signing key, installs it on both
	// planes (keeping the outgoing one on the verifier) and records the new
	// ref in the auth:tokens section. Wired by the composition root, which
	// owns the secret store and the master key; nil disables the endpoint.
	RotateTokenKey func(ctx context.Context) error

	// SecretKeys manages the key ring stored secrets are sealed under. nil disables /secret-keys.
	SecretKeys SecretKeyManager

	// AdminToken is the cleartext break-glass bearer. Empty disables the
	// bypass. Validated by the authenticator chain; not used directly by
	// handlers.
	AdminToken string

	// Authz is the policy-decision interface. Handlers call
	// d.Authz.Authorize before mutations; RELAY_AUTHZ picks the impl.
	Authz authz.Authorizer

	// License is the gate for licensed features and the backing of the
	// /license endpoints. nil is a community deployment.
	License license.Service

	// Catalog is the in-memory snapshot used for slug→id resolution on
	// reads. Writes go through Stores.
	Catalog *appcatalog.Catalog

	// Stores is the bundle of typed stores used by CRUD writes.
	Stores *appcatalog.Stores

	// CatalogSync runs one catalog check for POST /catalog/sync. nil means the
	// relay doesn't follow the catalog, and the endpoint answers 409.
	CatalogSync func(ctx context.Context) (appcatalog.CheckResult, error)

	// CatalogPrune judges the detached catalog rows for POST /catalog/prune and,
	// with apply, deletes the ones nothing holds; idle 0 uses the configured
	// window. nil answers 503.
	CatalogPrune func(ctx context.Context, idle time.Duration, apply bool) (catalogprune.Report, error)

	// Plans lets a token mint or key create answer once this pod serves what it wrote; nil answers at once.
	Plans PlanWaiter

	// CookieSecure controls the Secure attribute on the session cookie.
	// Surfaced here so the OpenAPI doc can reflect deployment posture.
	CookieSecure bool

	// UsageReader serves /usage/* read-side endpoints. nil disables
	// them — useful for deployments where usage events are consumed
	// from a separate store.
	UsageReader usagelog.Reader

	// Audit receives one event per audited admin request. nil disables
	// audit capture entirely (no middleware, no rows).
	Audit *audit.Emitter

	// AuditReader serves GET /audit. nil disables the endpoint.
	AuditReader audit.Reader

	// TrustedProxies is the proxy set the audit middleware honours
	// X-Forwarded-For behind. nil records the peer address.
	TrustedProxies []*net.IPNet

	// AllowOrigins is the control API's CORS allowlist; OIDC sign-in also returns the browser to these origins.
	AllowOrigins []string

	// PayloadReader serves /payloads/* read-side endpoints (the Logs view).
	// nil disables them — e.g. minimal builds or deployments where captured
	// bodies are consumed from a separate store.
	PayloadReader payloadlog.Reader

	// Selector is the keypool circuit-breaker owner, shared with the data
	// plane. The host-key health endpoint reads per-key breaker state through
	// it. nil disables that endpoint.
	Selector *keypool.Selector

	// Adapters is the wire-shape registry; detecting a host key's account probes the key's host through it. nil answers that detection with 422.
	Adapters *adapter.Registry

	// HostHealth reads per-host runtime reachability (observed state), shared
	// with the data plane. Overlays host.Status on host reads. nil disables
	// the overlay (Status stays absent → UI shows "unknown").
	HostHealth HostHealthReader

	// PlanView returns the plan engine's current view: plan issues, the caller's accounts and their limits are read from it. nil answers the issues read with an empty list and the account reads 503.
	PlanView func() *engine.View

	// Counters reads current counts for the limits reads; the data plane's limiter. nil answers them 503.
	Counters CounterReader

	// PublicURL is the deployment's externally reachable control-plane
	// origin. Exported manifests reference the schema endpoint under it;
	// empty renders the reference relative.
	PublicURL string

	// RuntimeConfig is the public config served at GET /config.json for the
	// embedded admin UI. Zero value is fine (UI falls back to origin defaults).
	RuntimeConfig RuntimeConfig
}

Deps is the typed dependency bundle for the admin plane.

type ExcludedModel added in v0.20.0

type ExcludedModel struct {
	ReachRefusal
	Provider ReachRef        `json:"provider" doc:"The model's provider."`
	Model    ReachModelRef   `json:"model"    doc:"The model."`
	Hosts    []ReachRef      `json:"hosts"    doc:"The reached hosts that bind it."`
	Upstream []ReachUpstream `json:"upstream" doc:"Each provider account whose keys could serve it, with its tier's verdict."`
	Accounts []ReachRef      `` /* 165-byte string literal not displayed */
}

ExcludedModel is one model at a reached host the lane may not use.

type HostHealthReader added in v0.2.0

type HostHealthReader interface {
	Read(ctx context.Context, hostID string) (host.Status, bool)
	ReadAll(ctx context.Context) map[string]host.Status
}

HostHealthReader reads observed host reachability. Implemented by app/hosthealth.Recorder.

type LimitsAccount added in v0.20.0

type LimitsAccount struct {
	ID   string       `json:"id"   doc:"Account id."`
	Name string       `json:"name" doc:"Account slug."`
	Kind account.Kind `json:"kind" enum:"team,project,personal,member,service,provider" doc:"What the account is."`
}

LimitsAccount names an account on the ladder.

type LimitsBudget added in v0.20.0

type LimitsBudget struct {
	BudgetID     string        `json:"budgetId"     doc:"Budget id."`
	Name         string        `json:"name"         doc:"Budget slug."`
	Shared       bool          `` /* 176-byte string literal not displayed */
	PerLane      bool          `` /* 229-byte string literal not displayed */
	AmountUSD    string        `json:"amountUsd"    doc:"Spend cap in USD per period, as a decimal string."`
	Period       budget.Period `json:"period"       enum:"day,week,month" doc:"Calendar period the cap covers, in UTC."`
	Mode         budget.Mode   `json:"mode"         enum:"hard,alert" doc:"hard refuses requests once the cap is spent; alert only reports the overrun."`
	SpentUSD     string        `json:"spentUsd,omitempty"     doc:"USD spent in the current period, as a decimal string. Omitted when the budget is perLane."`
	RemainingUSD string        `` /* 136-byte string literal not displayed */
}

LimitsBudget is one linked budget with this period's spend.

type LimitsRateLimit added in v0.20.0

type LimitsRateLimit struct {
	RateLimitID string       `json:"rateLimitId" doc:"Rate limit id."`
	Name        string       `json:"name"        doc:"Rate limit slug."`
	Models      []string     `json:"models"      doc:"The models the link applies to, in the policy's model grammar; empty applies it to every request."`
	Shared      bool         `` /* 173-byte string literal not displayed */
	PerLane     bool         `` /* 221-byte string literal not displayed */
	Rules       []LimitsRule `json:"rules"       doc:"The rate limit's rules, in order."`
}

LimitsRateLimit is one linked rate limit with each rule's usage.

type LimitsRule added in v0.20.0

type LimitsRule struct {
	Meter     ratelimit.Meter    `json:"meter"     doc:"What the rule counts."`
	Strategy  ratelimit.Strategy `` /* 214-byte string literal not displayed */
	Amount    int64              `json:"amount"    doc:"How much of the meter the window allows."`
	Window    int64              `json:"window"    doc:"Measurement period, in whole seconds."`
	Used      *int64             `` /* 245-byte string literal not displayed */
	Remaining *int64             `json:"remaining,omitempty" doc:"amount minus used, never below zero. Omitted when the rate limit is perLane."`
}

LimitsRule is one rule with its current count.

type LimitsRung added in v0.20.0

type LimitsRung struct {
	Account    LimitsAccount     `json:"account"    doc:"The account at this rung."`
	Policy     *BoundPolicy      `json:"policy,omitempty" doc:"The policy bound to the account; omitted when none is."`
	RateLimits []LimitsRateLimit `json:"rateLimits" doc:"The rate limits the policy links, disabled ones left out."`
	Budgets    []LimitsBudget    `json:"budgets"    doc:"The budgets the policy links."`
}

LimitsRung is one account on the ladder and what its policy links.

type LimitsTightest added in v0.20.0

type LimitsTightest struct {
	AccountID string  `json:"accountId" doc:"The account whose policy links the limit."`
	Kind      string  `json:"kind"      enum:"rateLimit,budget" doc:"Whether the limit is a rate-limit rule or a budget."`
	ID        string  `json:"id"        doc:"The rate limit's or the budget's id."`
	Remaining float64 `json:"remaining" doc:"What is left: in the rule's meter for a rate limit, in USD for a budget."`
	Label     string  `json:"label"     doc:"A short sentence for display, such as \"$50 left: team cap\"."`
}

LimitsTightest points at the limit closest to refusing.

type MintLimiter added in v0.10.0

type MintLimiter interface {
	Reserve(ctx context.Context, scope string, rules []pkgratelimit.Rule) (*pkgratelimit.Reservation, error)
}

MintLimiter meters how often one user may mint a token. Satisfied by *pkg/ratelimit.Limiter; nil leaves minting unmetered.

type MyAccount added in v0.20.0

type MyAccount struct {
	Account   AccountSummary `json:"account"   doc:"The account."`
	Kind      account.Kind   `` /* 208-byte string literal not displayed */
	Scope     AccountScope   `` /* 133-byte string literal not displayed */
	Policy    *BoundPolicy   `` /* 173-byte string literal not displayed */
	Keys      []AccountKey   `json:"keys"      doc:"The user's relay keys whose default lane is this account, revoked keys left out."`
	TokenOnly bool           `` /* 191-byte string literal not displayed */
}

MyAccount is one account the signed-in user acts in or owns.

type MyContext added in v0.20.0

type MyContext struct {
	Kind        string `` /* 170-byte string literal not displayed */
	ID          string `` /* 207-byte string literal not displayed */
	Name        string `json:"name"             doc:"The caller's username for personal, else the team or project slug."`
	DisplayName string `json:"displayName"      doc:"The team or project display name; the username for personal."`
	TeamID      string `json:"teamId,omitempty" doc:"The project's team. Projects only."`
	Admin       bool   `` /* 254-byte string literal not displayed */
}

MyContext is one scope the caller may create rows in.

type PersonalAccountEffective added in v0.20.0

type PersonalAccountEffective struct {
	State   string `` /* 200-byte string literal not displayed */
	Source  string `` /* 170-byte string literal not displayed */
	GroupID string `json:"groupId,omitempty" doc:"The group that decided it, for source group."`
}

PersonalAccountEffective is a user's personal-account state and what decided it.

type Pinger added in v0.11.1

type Pinger interface {
	Ping(ctx context.Context) error
}

Pinger reports one backend's health for /healthz.

type PlanIssue added in v0.20.0

type PlanIssue struct {
	Code     string         `json:"code"     doc:"Stable snake_case diagnostic identifier, such as ref_missing or host_mismatch."`
	Message  string         `json:"message"  doc:"Human-readable explanation of what is wrong."`
	Kind     string         `json:"kind"     doc:"Kind of the object carrying the issue (e.g. key, policybinding)."`
	ID       string         `json:"id"       doc:"Id (UUIDv7) of the object carrying the issue."`
	Name     string         `json:"name"     doc:"Slug of the object; empty for derived objects that have no slug."`
	Field    string         `` /* 154-byte string literal not displayed */
	Severity string         `` /* 144-byte string literal not displayed */
	Refs     []PlanIssueRef `json:"refs"     doc:"Objects the issue implicates, such as a missing target."`
}

PlanIssue is one diagnostic produced by the plan engine for a relay object.

type PlanIssueRef added in v0.20.0

type PlanIssueRef struct {
	Kind string `json:"kind" doc:"Kind of the referenced object (e.g. policy, host)."`
	ID   string `json:"id"   doc:"Id (UUIDv7) of the referenced object; empty when the caller may not see the object."`
	Name string `` /* 129-byte string literal not displayed */
}

PlanIssueRef is a related object implicated in one plan issue.

type PlanWaiter added in v0.20.0

type PlanWaiter interface {
	AwaitOpenLane(ctx context.Context, accountID string) bool
	AwaitKey(ctx context.Context, keyHash string) bool
}

PlanWaiter waits until this pod's published plans serve a write; *plan.Holder satisfies it. A client often spends a fresh token or key the moment it gets one, and the data plane reads only the plans, which pick a write up asynchronously.

type ReachDropped added in v0.20.0

type ReachDropped struct {
	Pool       *ReachRef `` /* 142-byte string literal not displayed */
	Account    *ReachRef `json:"account,omitempty"    doc:"The account the pool lists, when the account is what is dropped."`
	Credential *ReachRef `json:"credential,omitempty" doc:"The host key the pool lists, when the key is what is dropped."`
	Code       string    `` /* 299-byte string literal not displayed */
	Reason     string    `json:"reason"               doc:"The same in words, with what to change."`
}

ReachDropped is one link that brings the lane nothing.

type ReachModelRef added in v0.20.0

type ReachModelRef struct {
	ReachRef
	Labels map[string]string `json:"labels,omitempty" doc:"The model's labels."`
}

ReachModelRef names a model.

type ReachRef added in v0.20.0

type ReachRef struct {
	ID          string `json:"id"                    doc:"Id (UUIDv7)."`
	Name        string `json:"name"                  doc:"Slug."`
	DisplayName string `json:"displayName,omitempty" doc:"Display name."`
}

ReachRef names a row the reach goes through.

type ReachRefusal added in v0.20.0

type ReachRefusal struct {
	Code   string `json:"code"           doc:"The refusal code a request would get, such as model_not_allowed or no_credentials."`
	Reason string `json:"reason"         doc:"The refusal in words, naming the rung and policy that decide it."`
	Rung   string `` /* 169-byte string literal not displayed */
}

ReachRefusal is why a model, or the whole ladder, is refused.

type ReachUpstream added in v0.20.0

type ReachUpstream struct {
	Account  ReachRef  `json:"account"            doc:"The provider account holding the keys."`
	SharedAs *ReachRef `json:"sharedAs,omitempty" doc:"The shared account the keys are reached through."`
	Policy   *ReachRef `json:"policy,omitempty"   doc:"The tier policy bound to the account; omitted when none is."`
	Allowed  bool      `json:"allowed"            doc:"Whether the account's tier lets the model through."`
	Reason   string    `json:"reason,omitempty"   doc:"Why not, when allowed is false."`
	Rung     string    `json:"rung,omitempty"     doc:"The rung that refuses, when allowed is false: account."`
}

ReachUpstream is one provider account whose keys could serve the model and what its tier says.

type ReachVia added in v0.20.0

type ReachVia struct {
	Pool    *ReachRef `` /* 127-byte string literal not displayed */
	Account *ReachRef `` /* 166-byte string literal not displayed */
}

ReachVia is one pool and account a model is reached through.

type Reachable added in v0.20.0

type Reachable struct {
	Account       *ReachRef       `` /* 131-byte string literal not displayed */
	BoundAccounts []ReachRef      `json:"boundAccounts,omitempty" doc:"For a saved policy: the accounts bound to it that the caller may read."`
	Refused       *ReachRefusal   `` /* 166-byte string literal not displayed */
	Models        []ReachedModel  `json:"models"                  doc:"Models the lane reaches, by model slug."`
	Excluded      []ExcludedModel `` /* 133-byte string literal not displayed */
	Dropped       []ReachDropped  `` /* 137-byte string literal not displayed */
}

Reachable is what a lane may use, as the request path would route it: the models it reaches and the models at its hosts it may not use.

type ReachedModel added in v0.20.0

type ReachedModel struct {
	Provider ReachRef        `json:"provider" doc:"The model's provider."`
	Model    ReachModelRef   `json:"model"    doc:"The model."`
	Hosts    []ReachRef      `json:"hosts"    doc:"Hosts serving it for the lane, in failover order."`
	Via      []ReachVia      `json:"via"      doc:"What brings it, in failover order."`
	Upstream []ReachUpstream `json:"upstream" doc:"Each provider account whose keys could serve it, with its tier's verdict."`
	Accounts []ReachRef      `json:"accounts,omitempty" doc:"For a bound policy: the bound accounts that reach it."`
}

ReachedModel is one model the lane reaches.

type RuntimeConfig added in v0.2.0

type RuntimeConfig struct {
	ControlAPIURL   string          `json:"controlApiUrl,omitempty"   doc:"Base URL of the control API; empty means /api on the UI's own origin."`
	InferenceAPIURL string          `json:"inferenceApiUrl,omitempty" doc:"Public base URL of the inference API; empty when not configured."`
	Mode            string          `json:"mode,omitempty"            enum:"oss,cloud" doc:"Deployment flavour the UI adapts to."` // "oss" | "cloud"
	Version         string          `json:"version,omitempty"         doc:"Relay build version."`
	Features        map[string]bool `` /* 151-byte string literal not displayed */
	Telemetry       *Telemetry      `json:"telemetry,omitempty"       doc:"Public client-side error reporting config."`
	DocsURL         string          `json:"docsUrl,omitempty"         doc:"Documentation link shown in the UI."`
	SupportURL      string          `json:"supportUrl,omitempty"      doc:"Support link shown in the UI."`
}

RuntimeConfig is the JSON shape the UI reads. Every field is optional and omitempty: an empty controlApiUrl tells the UI to use its own origin; an empty inferenceApiUrl has no safe origin default (UI/data-plane may differ), so the UI prompts rather than guessing. The object is additive — the UI reads keys it knows and ignores the rest.

type SCIMClientRow added in v0.10.8

type SCIMClientRow struct {
	Name        string     `json:"name"                 doc:"The client's name, stamped as the source of every user and group it provisions."`
	TokenPrefix string     `json:"tokenPrefix"          doc:"The start of the token, for telling tokens apart."`
	CreatedAt   time.Time  `json:"createdAt"            doc:"When the client was created."`
	LastUsedAt  *time.Time `json:"lastUsedAt,omitempty" doc:"When the token last authenticated, to the minute."`
	Revoked     bool       `json:"revoked"              doc:"The token was revoked and no longer authenticates."`
}

SCIMClientRow is a SCIM client as the API shows it. It is exported because huma skips the fields of an unexported embedded struct, and the create and rotate bodies embed it.

type SecretKeyManager added in v0.11.6

type SecretKeyManager interface {
	Status(ctx context.Context) (stored.KeyStatus, error)
	Rotate(ctx context.Context, scope string) (stored.DataKeyStatus, error)
	// RotateAll returns the keys it made even when it fails part-way, so they can be audited.
	RotateAll(ctx context.Context) ([]stored.DataKeyStatus, error)
	Rewrap(ctx context.Context, to string) (stored.RewrapResult, error)
	Destroy(ctx context.Context, id string, force bool) (stored.DataKeyStatus, error)
}

SecretKeyManager runs the key ring operations; *stored.Backend implements it.

type ShareAccountRef added in v0.20.0

type ShareAccountRef struct {
	ID   string `json:"id"   doc:"Id of the shared account."`
	Name string `json:"name" doc:"Slug of the shared account."`
}

ShareAccountRef names a shared account.

type ShareUsage added in v0.20.0

type ShareUsage struct {
	Requests  int64 `json:"requests"  doc:"Requests that reached an upstream through the shared account."`
	CostNanos int64 `json:"costNanos" doc:"Cost of the priced ones, in nano-USD."`
	Unpriced  int64 `json:"unpriced"  doc:"Requests with no cost, left out of costNanos."`
}

ShareUsage is the traffic one shared account sent through the real account.

type Telemetry added in v0.2.0

type Telemetry struct {
	SentryDSN   string `json:"sentryDsn,omitempty"   doc:"Public Sentry DSN the UI reports errors to."`
	Environment string `json:"environment,omitempty" doc:"Environment name attached to reported errors."`
}

Telemetry carries PUBLIC client-side telemetry config only.

type TokenDenylist added in v0.10.0

type TokenDenylist interface {
	Revoke(ctx context.Context, jti string, exp time.Time) error
}

TokenDenylist records a revoked token until its expiry, for every pod's data plane to refuse it. Satisfied by *revocation.List.

type TokenSigner added in v0.10.0

type TokenSigner struct {
	// contains filtered or unexported fields
}

TokenSigner holds the Ed25519 signing key, plus the verification half of the key a rotation retired: minting never uses that one, but a token presented for revocation may carry it. The composition root swaps the keys in when the auth:tokens section changes; an empty signer refuses to mint, which is the posture of a deployment with no master key.

func (*TokenSigner) PublicKey added in v0.10.0

func (s *TokenSigner) PublicKey() ed25519.PublicKey

PublicKey returns the verification half, or nil when no key is installed.

func (*TokenSigner) SetPreviousPublicKey added in v0.10.0

func (s *TokenSigner) SetPreviousPublicKey(pub ed25519.PublicKey)

SetPreviousPublicKey records the key a rotation retired. Call it after SetSeed, which clears it. A key of the wrong size verifies nothing, so it is left out.

func (*TokenSigner) SetSeed added in v0.10.0

func (s *TokenSigner) SetSeed(seed []byte)

SetSeed installs the signing key from its 32-byte seed. A nil seed disables minting.

type UsageFilterInput

type UsageFilterInput struct {
	Since         string   `query:"since" doc:"Relative window (e.g. \"1h\", \"24h\", \"7d\"). Default \"1h\". Ignored when from is set."`
	From          string   `query:"from" doc:"Absolute lower bound (RFC3339). Overrides since."`
	To            string   `query:"to" doc:"Absolute upper bound (RFC3339)."`
	RequestID     string   `query:"request_id" doc:"Exact match on a single request id (deep-link one event)."`
	RelayKeyHash  []string `query:"relay_key_hash,explode" doc:"Match any of the given sha256 hashes of the inbound bearer."`
	PolicyID      []string `query:"policy_id,explode" doc:"Match any of the given Policy.metadata.id values."`
	PoolID        []string `query:"pool_id,explode" doc:"Match any of the given ids of the pool the serving credential was drawn from."`
	AccountID     []string `query:"account_id,explode" doc:"Match any of the given ids of the provider account the serving credential belongs to."`
	LaneAccountID []string `` /* 176-byte string literal not displayed */
	ViaAccountID  []string `` /* 173-byte string literal not displayed */
	ProjectID     []string `query:"project_id,explode" doc:"Match any of the given Project.metadata.id values."`
	TeamID        []string `query:"team_id,explode" doc:"Match any of the given Team.metadata.id values."`
	PrincipalID   []string `query:"principal_id,explode" doc:"Match any of the given principal ids (ServiceAccount.metadata.id or user id)."`
	ModelID       []string `query:"model_id,explode" doc:"Match any of the given Model.metadata.id values."`
	HostID        []string `query:"host_id,explode" doc:"Match any of the given Host.metadata.id values."`
	Source        []string `query:"source,explode" doc:"Match any of \"pipeline\" | \"proxy\" | \"ws\" | \"batch\"."`
	FinishReason  []string `` /* 135-byte string literal not displayed */
	ErrorKind     []string `query:"error_kind,explode" doc:"Match any of the given error_kind values."`
	Refusal       []string `` /* 203-byte string literal not displayed */
	StatusMin     int      `query:"status_min" doc:"Minimum HTTP status to include."`
	StatusMax     int      `query:"status_max" doc:"Maximum HTTP status to include."`

	HostKeyID      []string `query:"host_key_id,explode" doc:"Match any of the given HostKey.metadata.id values."`
	RequestedModel []string `query:"requested_model,explode" doc:"Match any of the model strings as the caller sent them."`
	Model          []string `query:"model,explode" doc:"Match any of the given model slugs (event-time metadata.name, denormalized)."`
	Host           []string `query:"host,explode" doc:"Match any of the given host slugs (event-time metadata.name, denormalized)."`
	Policy         []string `query:"policy,explode" doc:"Match any of the given policy slugs (event-time metadata.name, denormalized)."`
	Provider       []string `query:"provider,explode" doc:"Match any of the given provider slugs (event-time, denormalized)."`
	RelayKey       []string `query:"relay_key,explode" doc:"Match any of the given relay key slugs (event-time metadata.name, denormalized)."`
	Status         []int    `query:"status,explode" doc:"Match any of these exact HTTP status codes."`
	StatusClass    string   `query:"status_class" doc:"Convenience status band: \"2xx\" | \"4xx\" | \"5xx\". Sets status_min/max."`
	Streamed       string   `query:"streamed" enum:"true,false" doc:"true = only streamed responses, false = only non-streamed."`
	Error          string   `query:"error" enum:"true,false" doc:"true = only errors (status>=400 or error_kind set), false = only successes."`
	AttemptsMin    int      `query:"attempts_min" doc:"Minimum upstream try count (failover) — finds retried requests."`
	DurationMsMin  int64    `query:"duration_ms_min" doc:"Minimum total duration in ms (slow-request filter)."`
	DurationMsMax  int64    `query:"duration_ms_max" doc:"Maximum total duration in ms."`
	TTFTMsMin      int64    `query:"ttft_ms_min" doc:"Minimum upstream time-to-first-byte (ms); excludes requests with no upstream timing."`
	TTFTMsMax      int64    `query:"ttft_ms_max" doc:"Maximum upstream time-to-first-byte (ms)."`
	Q              string   `query:"q" doc:"Free-text substring across request_id, model_id, requested_model, source."`
	Tag            []string `` /* 150-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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