registry

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MPL-2.0 Imports: 8 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 registry persists REST-registered agents (operational key + TCP target).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadACLDefault   = errors.New("acl default must be public or deny")
	ErrDenyNeedsAID    = errors.New("acl deny entry requires aid")
	ErrBadACLAID       = errors.New("acl entry has bad aid")
	ErrJoinNeedsSecret = errors.New("acl join password requires secret")
	ErrNamedNoSecret   = errors.New("acl named allow entry cannot have secret")
	ErrDupJoinPassword = errors.New("acl allows only one join password")
	ErrDupACLAID       = errors.New("acl aid already listed")
	ErrACLBothLists    = errors.New("acl aid cannot be in allow and deny")
)

Functions

This section is empty.

Types

type ACLDefault added in v0.3.2

type ACLDefault string

ACLDefault is the fallback when neither deny nor allow matches.

const (
	ACLDefaultPublic ACLDefault = "public"
	ACLDefaultDeny   ACLDefault = "deny"
)

type ACLEntry added in v0.3.2

type ACLEntry struct {
	ID        string `json:"id"`
	AID       string `json:"aid,omitempty"`
	Secret    string `json:"secret,omitempty"`
	ExpiresAt int64  `json:"expires_at,omitempty"`
	MaxUses   int    `json:"max_uses,omitempty"`
	BindOnUse bool   `json:"bind_on_use,omitempty"`
}

ACLEntry is one allow/deny rule. Empty AID + Secret is the single join password (allow only). Named AID entries do not carry a secret. BindOnUse is stored but unused.

type ACLPolicy added in v0.3.2

type ACLPolicy struct {
	Default ACLDefault `json:"default,omitempty"`
	Paid    bool       `json:"paid,omitempty"` // reserved; not a third default
	Deny    []ACLEntry `json:"deny,omitempty"`
	Allow   []ACLEntry `json:"allow,omitempty"`
}

ACLPolicy is the per-agent access policy. Decision order is fixed: deny hit → reject; else allow hit → permit; else Paid+auth (later); else Default.

func (*ACLPolicy) Allows added in v0.3.2

func (p *ACLPolicy) Allows(remote a2al.Address, secret string) bool

Allows reports whether remote may use service_tcp. secret is the join password from AccessToken; ignored unless an allow entry has Secret set.

func (*ACLPolicy) Validate added in v0.3.2

func (p *ACLPolicy) Validate() error

Validate checks policy constraints. Empty/nil policy is valid (public).

type Entry

type Entry struct {
	AID            a2al.Address
	ServiceTCP     string
	OpPriv         ed25519.PrivateKey
	DelegationCBOR []byte
	Seq            uint64
	// Services lists published service payloads for auto-renewal (user-facing name for DHT topics).
	Services []ServiceRecord
	// Profile holds user-supplied overrides for the RecType 0x02 sovereign record.
	// Nil means use inferred values from Services only.
	Profile *ProfileOverride
	// DemoActive records that the built-in demo HTTP server is running for this agent.
	// Set by demo start; cleared by demo stop. On daemon restart, any entry with
	// DemoActive=true is recovered by re-starting the demo server automatically.
	DemoActive bool
	// ACL is the local data-plane policy for service_tcp. Nil means public.
	ACL *ACLPolicy
}

Entry is one registered application agent (not the node identity).

type ProfileOverride added in v0.2.0

type ProfileOverride struct {
	Name       string         `json:"name,omitempty"`
	Brief      string         `json:"brief,omitempty"`
	Protocols  []string       `json:"protocols,omitempty"`
	Skills     []string       `json:"skills,omitempty"`
	CardHash   []byte         `json:"card_hash,omitempty"`
	Modalities []string       `json:"modalities,omitempty"`
	Meta       map[string]any `json:"meta,omitempty"`
}

ProfileOverride holds user-supplied agent profile fields. Non-zero fields take precedence over values inferred from Services when assembling the RecType 0x02 sovereign record payload.

type Registry

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

Registry is a file-backed map of agent AID → registration.

func Load

func Load(path string) (*Registry, error)

Load reads agents.json; missing file is OK.

func New

func New(path string) *Registry

New returns an empty registry; call Load to populate from disk.

func (*Registry) Delete

func (r *Registry) Delete(aid a2al.Address) error

Delete removes an agent; no-op if missing.

func (*Registry) Get

func (r *Registry) Get(aid a2al.Address) *Entry

Get returns a copy-safe view (caller must not mutate OpPriv).

func (*Registry) List

func (r *Registry) List() []*Entry

List returns all entries (for GET /agents).

func (*Registry) Put

func (r *Registry) Put(e *Entry) error

Put adds or replaces an entry (in-memory + Save).

func (*Registry) Save

func (r *Registry) Save() error

Save writes agents.json atomically.

type ServiceRecord

type ServiceRecord struct {
	Topic     string         `json:"topic"`
	Name      string         `json:"name,omitempty"`
	Protocols []string       `json:"protocols,omitempty"`
	Tags      []string       `json:"tags,omitempty"`
	Brief     string         `json:"brief,omitempty"`
	Meta      map[string]any `json:"meta,omitempty"`
	TTL       uint32         `json:"ttl,omitempty"`
}

ServiceRecord persists a published service (full payload) for auto-renewal. JSON key is "services" to align with user-facing terminology.

Jump to

Keyboard shortcuts

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