metadata

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0 modules, 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 metadata owns the rules for resource metadata: string key and value pairs that Agents, Sessions and Vaults carry for their applications.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLarge = errors.New("metadata exceeds 64 KiB")

ErrTooLarge reports metadata whose JSON encoding exceeds 64 KiB.

Functions

func Encode

func Encode(metadata map[string]string) ([]byte, error)

Encode returns the stored JSON object; nil metadata is stored as {}. It enforces only the 64 KiB storage bound, not Validate's rules.

func Validate

func Validate(metadata map[string]string) error

Validate applies the pinned limits of 16 pairs, 64-character keys and 512-character values, then ValidateStorable. Keys are checked in sorted order, so the reported violation is stable.

func ValidateStorable

func ValidateStorable(metadata map[string]string) error

ValidateStorable applies only the local U+0000 limit: PostgreSQL text and jsonb cannot store it, although the official service accepts it. Keys are checked in sorted order.

Types

type Kind

type Kind int

Kind names the rule a metadata map breaks.

const (
	// TooManyPairs: more than 16 pairs; Length is the pair count.
	TooManyPairs Kind = iota + 1
	// KeyTooLong: a key longer than 64 characters; Length is its length.
	KeyTooLong
	// ValueTooLong: a value longer than 512 characters; Length is its length.
	ValueTooLong
	// KeyUnstorable: a key contains U+0000.
	KeyUnstorable
	// ValueUnstorable: a value contains U+0000.
	ValueUnstorable
)

type Violation

type Violation struct {
	Kind   Kind
	Key    string
	Length int
}

Violation is the first rule a metadata map breaks. Key is empty for TooManyPairs, and Length is the counted size for the length rules.

func (*Violation) Error

func (v *Violation) Error() string

Jump to

Keyboard shortcuts

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