meta

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 11 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 meta holds the identity primitives every domain entity carries: UUIDv7 id, DNS-1123 slug name, free-text display name, and provenance.

No I/O, no business logic — just value types and tiny pure helpers. Everything else (entity domain packages, storage, handlers) depends on this; it depends on nothing in the project.

Index

Constants

This section is empty.

Variables

View Source
var ErrStaleResourceVersion = errors.New("resource changed since it was read")

ErrStaleResourceVersion reports a conditional update whose ResourceVersion no longer matches the stored row.

View Source
var Global = Owner{Kind: OwnerOrganization}

Global is the scope every other scope sits in: a role binding there applies everywhere, and a row owned by it serves every scope.

View Source
var Validator = func() *validator.Validate {
	v := validator.New(validator.WithRequiredStructEnabled())
	if err := v.RegisterValidation("slug", isDNS1123Slug); err != nil {
		panic("meta: register slug validator: " + err.Error())
	}
	if err := v.RegisterValidation("budgetamount", isBudgetAmount); err != nil {
		panic("meta: register budgetamount validator: " + err.Error())
	}
	return v
}()

Validator is the shared go-playground/validator instance every entity package uses. Custom tags ("slug", "uuid7", ...) are registered here. Entities call Validator.Struct(...) from their Validate() methods.

Functions

func Attribute

func Attribute(attrs map[string]json.RawMessage, key string, dst any) error

Attribute decodes the attribute under key into dst; a missing key leaves dst untouched.

func FormatResourceVersion

func FormatResourceVersion(v int64) string

FormatResourceVersion renders a stored version counter as the opaque ResourceVersion string.

func FromDirectoryError

func FromDirectoryError(err error) error

FromDirectoryError maps the directory's stale-version error onto ErrStaleResourceVersion, which the control API answers with 409.

func MarshalJSONB

func MarshalJSONB(m Metadata) ([]byte, error)

MarshalJSONB renders the JSONB-stored portion of a Metadata. ID, Name, and DisplayName live in their own SQL columns, so they are intentionally excluded from the JSONB blob to avoid duplication.

func NewID

func NewID() string

NewID returns a fresh UUIDv7 string. Centralized so every entity store stamps ids the same way.

func PutAttribute

func PutAttribute(attrs map[string]json.RawMessage, key string, v any, set bool) (map[string]json.RawMessage, error)

PutAttribute stores v under key, or leaves the key out when set is false, as the relay's omitempty spec fields did.

func StaleIfNoRows

func StaleIfNoRows(n int64, err error) error

StaleIfNoRows maps a conditional upsert's affected-row count: zero rows means the stored version no longer matched.

func ToDirectory

func ToDirectory(m Metadata) directory.Metadata

ToDirectory is m as the directory stores it.

Types

type Icon

type Icon struct {
	Path string `` /* 126-byte string literal not displayed */
}

Icon describes a visual asset for a catalog entity (Provider, Host, Model). Path is relative — typically "/provider/anthropic.png" — and names a file in the catalog release's icons directory. The control listener serves the seeded catalog's file at that path.

type Metadata

type Metadata struct {
	ID          string            `` /* 231-byte string literal not displayed */
	Name        string            `` /* 220-byte string literal not displayed */
	DisplayName string            `json:"displayName,omitempty" yaml:"displayName,omitempty"  doc:"Free-text name shown in the UI. Nothing references it."`
	Description string            `json:"description,omitempty" yaml:"description,omitempty"  doc:"Free-text description of the row."`
	Owner       Owner             `` /* 184-byte string literal not displayed */
	Labels      map[string]string `` /* 138-byte string literal not displayed */
	Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"  doc:"Free-form key/value notes; never filtered on."`
	CreatedAt   time.Time         `` /* 140-byte string literal not displayed */
	UpdatedAt   time.Time         `` /* 141-byte string literal not displayed */

	// Dirty marks a row an operator has edited via the control API. Seed skips
	// dirty rows so re-seeding never clobbers operator changes (unless the run
	// is told to clear them). Server-authoritative: stamped on edit, never read
	// from manifest YAML.
	Dirty bool `` /* 168-byte string literal not displayed */

	// CatalogDetachedAt is when a catalog upgrade stopped shipping this row.
	// The row stays in place and is the operator's from then on. Server-
	// authoritative like Dirty: only the versioned catalog reseed sets or
	// clears it.
	CatalogDetachedAt *time.Time `` /* 231-byte string literal not displayed */

	// ResourceVersion is an opaque token that changes on every write to the
	// row. An update carrying it only applies while the stored row still has
	// it; an empty value updates unconditionally.
	ResourceVersion string `` /* 222-byte string literal not displayed */
}

Metadata is the identity tuple stamped on every domain row.

  • ID is the immutable primary key (UUIDv7). Server-stamped on create.
  • Name is a stable DNS-1123 slug, unique-per-kind, mutable via the id-routed update path. Used in URLs and YAML refs.
  • DisplayName is free text shown in UI. Edits are free; nothing references it.
  • Description is free text documenting the row.
  • Owner identifies provenance.
  • Labels are arbitrary k/v selectors.
  • Annotations are free-form k/v notes; never filtered or selected on.
  • CreatedAt/UpdatedAt are server-derived, read-only provenance read from the row's dedicated columns (NOT the metadata JSONB — see MarshalJSONB, which serializes only Description/Owner/Labels/ Annotations). They are omitted from YAML manifests (yaml:"-") since seed/apply must not set them; the store stamps them on read.

func FromDirectory

func FromDirectory(m directory.Metadata) Metadata

FromDirectory is the directory's metadata as the relay carries it.

func UnmarshalJSONB

func UnmarshalJSONB(id, name, displayName string, raw []byte) (Metadata, error)

UnmarshalJSONB reconstructs a Metadata from its column values plus the JSONB blob. raw may be empty (legacy rows or freshly-stamped placeholders).

func (Metadata) ExpectedVersion

func (m Metadata) ExpectedVersion() (v int64, ok bool, err error)

ExpectedVersion returns the version a conditional update must match; ok is false when ResourceVersion is unset. A value no stored row can carry is reported as ErrStaleResourceVersion.

func (Metadata) GovernedOwnerKind

func (m Metadata) GovernedOwnerKind() OwnerKind

GovernedOwnerKind is the owner kind mutation governance judges the row by. A row the catalog no longer ships is the operator's, so it is judged as user-owned, unless the organization owns it: that tier holds whatever mark the row carries.

type Owner

type Owner struct {
	Kind OwnerKind `` /* 405-byte string literal not displayed */
	ID   string    `` /* 184-byte string literal not displayed */
}

Owner describes who created / manages a row. Kind=provider requires ID; the other kinds leave ID empty.

func (Owner) AsGlobalScope added in v0.30.0

func (o Owner) AsGlobalScope() Owner

AsGlobalScope reads system, the global scope's spelling before organization, as Global, so documents written before keep naming the global scope.

func (Owner) DeploymentWide added in v0.30.0

func (o Owner) DeploymentWide() bool

DeploymentWide reports whether the owner is the deployment as a whole, system or organization, rather than a tenant or a catalog tier.

func (Owner) Holds

func (o Owner) Holds(inner Owner, teamOf func(projectID string) (teamID string, ok bool)) bool

Holds reports whether a row owned by o may serve scope inner: the system's and the organization's rows serve every scope, a scope's its own, a team's its projects. teamOf answers a project's team; ok is false when the project is unknown.

func (Owner) Tenant

func (o Owner) Tenant() bool

Tenant reports whether the owner is a user, team or project rather than the deployment itself or its catalog.

type OwnerKind

type OwnerKind string

OwnerKind enumerates provenance categories.

const (
	// OwnerSystem owns the catalog's deployment-wide rows and the relay's own (built-in roles and rate limits).
	OwnerSystem OwnerKind = "system"
	// OwnerOrganization is the deployment itself: the global scope, and the owner of the rows it holds rather than its catalog. Organization-owned rows are never catalog data. ID stays empty until a deployment holds more than one organization.
	OwnerOrganization OwnerKind = "organization"
	OwnerProvider     OwnerKind = "provider"
	OwnerHost         OwnerKind = "host"
	OwnerUser         OwnerKind = "user"
	OwnerTeam         OwnerKind = "team"
	OwnerProject      OwnerKind = "project"
)

Jump to

Keyboard shortcuts

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