registry

package
v0.14.4-dev.44 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package registry stores immutable, content-addressed package records and agentpack revisions under the user's agentpack home.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("registry item not found")

Functions

func CaptureProjectIfEnabled

func CaptureProjectIfEnabled(home, definitionRoot, sourceProject, sourceNode, modeName string) (Agentpack, Revision, bool, error)

CaptureProjectIfEnabled returns without opening or creating registry storage when capture is disabled.

func PendingRestore

func PendingRestore(home, directory string) (bool, error)

PendingRestore reports an interrupted restore without changing project or registry files.

func RecoverDefinition

func RecoverDefinition(home, directory string) error

RecoverDefinition is a no-op without an interrupted restore and does not create registry storage.

func ValidateChanges added in v0.14.0

func ValidateChanges(store *state.Store, changes []state.Change) error

ValidateChanges checks public records before a peer page can enter the local database.

func ValidatePeer added in v0.14.0

func ValidatePeer(node string) error

Types

type Agentpack

type Agentpack struct {
	ID        string   `json:"id"`
	Name      string   `json:"name"`
	Revisions []string `json:"revisions"`
	Heads     []string `json:"heads"`
}

type CaptureInput

type CaptureInput struct {
	ID         string
	Name       string
	Label      string
	Mode       string
	SourceNode string
	Project    string
	Manifest   []byte
	Lock       []byte
	CreatedAt  time.Time
	ParentIDs  []string
}

type Conflict added in v0.12.6

type Conflict struct {
	Heads  []string        `json:"heads"`
	Fields []ConflictField `json:"fields"`
}

type ConflictField added in v0.12.6

type ConflictField struct {
	Path   string            `json:"path"`
	Name   string            `json:"name"`
	Base   string            `json:"base"`
	Values map[string]string `json:"values"`
}

ConflictField is one value both heads changed differently. Values maps a head ID to its display text.

type DiffResult

type DiffResult struct {
	Add    []string `json:"add"`
	Update []string `json:"update"`
	Remove []string `json:"remove"`
	Mode   string   `json:"mode"`
}

type Draft

type Draft struct {
	ID             string                `json:"id"`
	Item           string                `json:"item"`
	Revision       string                `json:"revision,omitempty"`
	Node           string                `json:"node"`
	Directory      string                `json:"directory"`
	Reason         string                `json:"reason"`
	PackID         string                `json:"pack_id,omitempty"`
	FolderIdentity string                `json:"folder_identity"`
	ExpectedPins   map[string]PackagePin `json:"expected_pins"`
	NeededHolder   string                `json:"needed_holder,omitempty"`
	CreatedAt      time.Time             `json:"created_at"`
}

type DraftInput

type DraftInput struct {
	Item           string                `json:"item"`
	Revision       string                `json:"revision,omitempty"`
	Node           string                `json:"node"`
	Directory      string                `json:"directory"`
	Reason         string                `json:"reason"`
	PackID         string                `json:"pack_id,omitempty"`
	FolderIdentity string                `json:"folder_identity"`
	ExpectedPins   map[string]PackagePin `json:"expected_pins"`
	NeededHolder   string                `json:"needed_holder,omitempty"`
}

type DraftReview

type DraftReview struct {
	Draft       Draft       `json:"draft"`
	Ready       bool        `json:"ready"`
	PinsMatch   bool        `json:"pins_match"`
	FolderMatch bool        `json:"folder_match"`
	Reason      string      `json:"reason"`
	Diff        *DiffResult `json:"diff,omitempty"`
}

type DraftState

type DraftState struct {
	Reachable      bool                  `json:"reachable"`
	FolderIdentity string                `json:"folder_identity"`
	Pins           map[string]PackagePin `json:"pins"`
	CurrentDiff    *DiffResult           `json:"current_diff,omitempty"`
	MissingObjects []string              `json:"missing_objects,omitempty"`
	NeededHolder   string                `json:"needed_holder,omitempty"`
}

type Package

type Package struct {
	ID          string `json:"id"`
	Schema      int    `json:"schema,omitempty"`
	Module      string `json:"module"`
	Direct      bool   `json:"direct,omitempty"`
	Commit      string `json:"commit"`
	ContentHash string `json:"content_hash,omitempty"`
	Kind        string `json:"kind"`
	URL         string `json:"url"`
	Owner       string `json:"owner"`
	Repo        string `json:"repo"`
	Path        string `json:"path,omitempty"`
	CacheKey    string `json:"cache_key"`
	Name        string `json:"name,omitempty"`
	SourceNode  string `json:"source_node,omitempty"`
	Project     string `json:"project,omitempty"`
}

type PackagePin

type PackagePin struct {
	Commit      string `json:"commit"`
	ContentHash string `json:"content_hash,omitempty"`
	CacheKey    string `json:"cache_key"`
}

type PeerReplica

type PeerReplica struct {
	Node string `json:"node"`
	Mesh bool   `json:"mesh"`
}

type Revision

type Revision struct {
	ID                      string    `json:"id"`
	Schema                  int       `json:"schema,omitempty"`
	AgentpackID             string    `json:"agentpack_id"`
	ParentIDs               []string  `json:"parent_ids,omitempty"`
	Manifest                string    `json:"manifest"`
	Lock                    string    `json:"lock"`
	PackageIDs              []string  `json:"package_ids,omitempty"`
	SourceNode              string    `json:"source_node,omitempty"`
	Project                 string    `json:"project,omitempty"`
	CreatedAt               time.Time `json:"created_at"`
	Label                   string    `json:"label,omitempty"`
	Mode                    string    `json:"mode,omitempty"`
	NeedsLocalConfiguration bool      `json:"needs_local_configuration,omitempty"`
}

type Store

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

func New

func New(home string) (*Store, error)

New opens the Library in state.db and its local capture/restore files under registry/.

func (*Store) AgentpackDeleted added in v0.9.3

func (s *Store) AgentpackDeleted(id string) (bool, error)

AgentpackDeleted reports whether a stable agentpack ID has a local tombstone.

func (*Store) Capture

func (s *Store) Capture(input CaptureInput) (Agentpack, Revision, error)

Capture appends a content-addressed revision, creating a stable agentpack ID when absent.

func (*Store) Close added in v0.14.0

func (s *Store) Close() error

func (*Store) CollectGarbage

func (s *Store) CollectGarbage() ([]string, error)

func (*Store) Conflict added in v0.12.6

func (s *Store) Conflict(id string) (Conflict, error)

Conflict reports the first pair of heads that needs a person, or empty when there is none.

func (*Store) DeleteAgentpack

func (s *Store) DeleteAgentpack(id string) (Tombstone, error)

func (*Store) DeleteDraft

func (s *Store) DeleteDraft(id string) error

func (*Store) Diff

func (s *Store) Diff(fromID, toID string) (DiffResult, error)

Diff compares package pins and selected mode from two verified revisions.

func (*Store) EnrollOwnMachine added in v0.12.6

func (s *Store) EnrollOwnMachine(node string) error

func (*Store) EnrollPeer

func (s *Store) EnrollPeer(node string) error

func (*Store) Get

func (s *Store) Get(id string) (Agentpack, []Revision, error)

func (*Store) GetDraft

func (s *Store) GetDraft(id string) (Draft, error)

func (*Store) Heads

func (s *Store) Heads(id string) ([]string, error)

func (*Store) ImportPackages added in v0.9.3

func (s *Store) ImportPackages(packages []Package) error

ImportPackages adds indexed cache package records to the Library without associating it with a synthetic agentpack revision.

func (*Store) ListAgentpacks

func (s *Store) ListAgentpacks() ([]Agentpack, error)

ListAgentpacks returns named packs from the rebuildable index.

func (*Store) ListDrafts

func (s *Store) ListDrafts() ([]Draft, error)

func (*Store) ListPackages

func (s *Store) ListPackages() ([]Package, error)

ListPackages loads and verifies every indexed package object.

func (*Store) ListPeers

func (s *Store) ListPeers() ([]PeerReplica, error)

func (*Store) MergeHeads added in v0.12.6

func (s *Store) MergeHeads() error

MergeHeads settles every agentpack that replication left with several heads, as far as it can without a person.

func (*Store) PeerRemoved added in v0.14.1

func (s *Store) PeerRemoved(node string) (bool, error)

PeerRemoved reports whether the owner removed this peer, which automatic pairing must respect.

func (*Store) Preview

func (s *Store) Preview(id, revisionID, directory string) (Revision, DiffResult, error)

Preview exposes the redacted target snapshot; bindings are private to this machine.

func (*Store) Recover

func (s *Store) Recover(directory string) error

Recover rolls back an interrupted restore for one definition directory.

func (*Store) RemovePeer

func (s *Store) RemovePeer(node string) error

func (*Store) Rename

func (s *Store) Rename(id, name string) (Agentpack, error)

func (*Store) Resolve added in v0.12.6

func (s *Store) Resolve(id string, heads []string, choices map[string]string, node string) (Revision, error)

Resolve merges two heads using a person's choice for every conflicting field: path to the head that wins.

func (*Store) Restore

func (s *Store) Restore(id, revisionID, directory string, apply func() error) error

Restore writes the selected definition, runs apply, and restores both original files on any failure.

func (*Store) RevalidateDraft

func (s *Store) RevalidateDraft(id string, state DraftState) (DraftReview, error)

func (*Store) SaveDraft

func (s *Store) SaveDraft(input DraftInput) (Draft, error)

func (*Store) SetCapture

func (s *Store) SetCapture(directory, agentpackID string, enabled bool) error

SetCapture enables or disables automatic snapshots for one project directory.

type Tombstone

type Tombstone struct {
	ID        string    `json:"id"`
	Schema    int       `json:"schema"`
	Agentpack string    `json:"agentpack_id"`
	Revisions []string  `json:"revisions"`
	CreatedAt time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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