agentfields

package
v0.175.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package agentfields is the one set of rules for the strings of an agent that leaves a machine or comes from another: the patterns, closed sets and bounds the cockpit's export decoder enforces, shared by the publisher that builds the optional `agents` of a remote snapshot, the hub's snapshot model that validates it, and the fleet mapping that reads it back. Everything here is fail-closed: a value that does not match is blanked (an optional field) or drops the agent (an identifying one), so a path, an environment value or prose in a field never travels or renders.

Index

Constants

View Source
const (
	KindSession = "session"
	KindRun     = "run"
)

The two kinds of agent.

View Source
const MaxTextBytes = 256

MaxTextBytes bounds a free-text field (the export decoder's maxFieldBytes).

Variables

View Source
var (
	Token      = regexp.MustCompile(`^[A-Za-z0-9._:-]{1,64}$`)
	Model      = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._:/@+\[\]-]{0,63}$`)
	TaskName   = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._/-]{0,255}$`)
	Repository = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,99}/[A-Za-z0-9._-]{1,100}$`)
)

The patterns. A token is a run or session identifier or a runtime name; a model is a token that may also hold the characters a model name uses, and never starts with a separator (so not an absolute path); a task is a task name as WB creates it (letters, digits, dots, underscores, dashes and slashes, not starting with a separator); a repository is owner/name.

View Source
var Activities = []string{"working", "blocked", "idle", "done", "unknown"}

Activities are the values of an agent's activity.

Functions

func IsTaskName

func IsTaskName(value string) bool

IsTaskName is the stricter rule the publisher and the hub apply to a task.

func IsText

func IsText(value string) bool

IsText is the export decoder's text rule: bounded and with no unsafe character.

func UnsafeRune

func UnsafeRune(character rune) bool

UnsafeRune reports whether character is a control or format character or a line or paragraph separator, which no published text may hold.

func UnsafeText

func UnsafeText(character rune) bool

UnsafeText reports whether character may not appear in a name: UnsafeRune, the replacement character, a private-use character, a space other than the ASCII one, and the characters that draw as blanks.

func Valid

func Valid(agent Agent, task func(string) bool) bool

Valid reports whether every field of agent already passes (nothing would be blanked and the agent would be kept): the hub's check, which refuses rather than repairs.

Types

type Agent

type Agent struct {
	Kind, SessionID, RunID, Runtime, Model, State, Activity, Task, Repository string
}

Agent is the strings of one agent.

func Clean

func Clean(agent Agent, task func(string) bool) (Agent, bool)

Clean applies the rules to an agent. It reports false when an identifying field fails (the kind, the state, the session or run identifier), and then the agent must be dropped; otherwise every other failing field is blanked. task is the rule for the task field: IsTaskName on the publish, hub and read sides. An empty value always passes: the field is simply absent.

Jump to

Keyboard shortcuts

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