binding

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package binding evaluates SkillBinding records against a skill library and produces a deterministic load-policy decision for each skill an agent declaratively attaches. It is the per-agent attachment layer introduced by the skills overhaul; see docs/architecture/skills-overhaul.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePattern

func ValidatePattern(name string) error

ValidatePattern returns an error when the binding's name uses an invalid path.Match pattern. Resolvers should call this at config-load time.

Types

type MatchKind

type MatchKind int

MatchKind describes how a binding hit a skill, used for tie-breaking and for the source attribution attached to each ResolvedBinding.

const (
	// MatchNone is the zero value used when no match was found.
	MatchNone MatchKind = iota
	// MatchExactName indicates an exact match against either Skill.Name or
	// the fully-qualified path. Exact-name matches outrank glob matches for
	// the same underlying skill.
	MatchExactName
	// MatchGlob indicates a path.Match-style glob match against the
	// fully-qualified path (parent_index_path + "/" + name) or, when
	// parent_index_path is empty, against the bare name.
	MatchGlob
	// MatchLabel indicates a label-only match: the binding has no name set
	// and only label_match is used to select skills.
	MatchLabel
)

func (MatchKind) String

func (k MatchKind) String() string

String renders the kind as a stable identifier for telemetry.

type MatchResult

type MatchResult struct {
	Matched bool
	Kind    MatchKind
	// FQN is the fully-qualified name the matcher considered for this skill,
	// useful for diagnostics. Equal to skill.Name when ParentIndexPath empty.
	FQN string
}

MatchResult captures whether a binding matched a skill and how.

func MatchBinding

func MatchBinding(b *skills.SkillBinding, s *skills.Skill) MatchResult

MatchBinding evaluates a single SkillBinding against a single Skill. The decision is deterministic and pure; no I/O.

Match precedence (within a single binding -> single skill comparison):

  1. Exact name match against Skill.Name (legacy compat).
  2. Exact name match against the FQN (parent_index_path/name).
  3. Glob match against the FQN, when the binding name contains *, ?, or [.
  4. Label-only match when Binding.Name is empty and label_match is set.

Label and version filters apply on top of any name/glob match: a binding that names a skill but whose label_match excludes it returns Matched=false.

type ResolvedBinding

type ResolvedBinding struct {
	// Skill is the resolved library entry.
	Skill *skills.Skill
	// Mode is the effective load policy after defaulting (LAZY when the
	// binding leaves Mode unset).
	Mode skills.SkillBindingMode
	// Priority is the binding's declared priority (higher wins under tight
	// budget; defaults to zero).
	Priority int32
	// MatchKind is how the binding matched this skill (exact / glob / label).
	MatchKind MatchKind
	// Source describes which input produced the binding, for telemetry:
	//   "explicit"        - bindings list, exact name
	//   "glob"            - bindings list, glob match
	//   "label"           - bindings list, label-only match
	//   "legacy_enabled"  - synthesized from EnabledSkills shim
	//   "legacy_default"  - synthesized from "all minus DisabledSkills" shim
	Source string
}

ResolvedBinding is the per-skill load decision the resolver emits.

type Resolver

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

Resolver runs binding -> skill resolution against a library.

func NewResolver

func NewResolver(src SkillSource) *Resolver

NewResolver constructs a Resolver bound to the given library.

func (*Resolver) Resolve

func (r *Resolver) Resolve(config *skills.SkillsConfig) ([]ResolvedBinding, error)

Resolve walks the SkillsConfig bindings (or the legacy shim when bindings is empty) and produces the per-skill load decision. The result is sorted by skill name for stable iteration order.

Tie-breaking for one skill matched by multiple bindings:

  1. Exact-name binding wins over glob/label binding.
  2. Among same-kind matches, higher Priority wins.
  3. Mode hierarchy ALWAYS > EAGER > LAZY breaks remaining ties.

type SkillSource

type SkillSource interface {
	List() []*skills.Skill
	Load(name string) (*skills.Skill, error)
}

SkillSource holds the library handle the resolver consults. The interface keeps the package testable without a real Library instance.

Jump to

Keyboard shortcuts

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