contextprofile

package
v0.28.8 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 12 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 contextprofile stores the owner's named contexts and their pins. It owns persistence, revision checks and backups; resolution and tool enforcement belong to the host.

Index

Constants

View Source
const LifetimeUntilUnpinned = "until-unpinned"

LifetimeUntilUnpinned is the only pin lifetime so far: stored, it survives a restart.

View Source
const ScopeConversation = "conversation"

ScopeConversation is the only pin scope so far: the embedded agent's or a local Nanite seat's conversation.

Variables

View Source
var (
	ErrNotFound = errors.New("context not found")
	ErrConflict = errors.New("context changed; read its current revision before writing")
	ErrInvalid  = errors.New("invalid context")
)
View Source
var ErrPinned = errors.New("context is pinned; unpin it first or delete with force")

ErrPinned refuses deleting a context that a live pin names, unless forced.

Functions

This section is empty.

Types

type Backup

type Backup struct {
	Record
	ArchivedAt string `json:"archived_at"`
	Reason     string `json:"reason"`
}

Backup is the exact previous definition, including the revision used to replace it.

type Lifetime added in v0.28.6

type Lifetime struct {
	Kind string `json:"kind"`
}

type Pin added in v0.28.6

type Pin struct {
	ID        string   `json:"id"`
	Context   string   `json:"context"`
	Scope     Scope    `json:"scope"`
	Lifetime  Lifetime `json:"lifetime"`
	Origin    string   `json:"origin"`
	CreatedAt string   `json:"created_at"`
}

Pin makes a saved context active in a scope. A pin names the context, so an edit of the context applies from the next turn.

type Record

type Record struct {
	steer.Preset
	Revision  string `json:"revision"`
	UpdatedAt string `json:"updated_at"`
}

Record keeps the authored definition separate from any resolved context.

type Scope added in v0.28.6

type Scope struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
}

type Store

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

func Open

func Open(ctx context.Context, db *sql.DB) (*Store, error)

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, name, revision, reason string, force bool) error

Delete removes a context. A context a pin names is refused with ErrPinned unless force, which removes its pins in the same transaction.

func (*Store) Get

func (s *Store) Get(ctx context.Context, name string) (Record, error)

func (*Store) History

func (s *Store) History(ctx context.Context, name string) ([]Backup, error)

History returns superseded and deleted definitions, newest first. Restoring one uses Put with the current revision; backups never bypass optimistic concurrency.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]Record, error)

func (*Store) Pin added in v0.28.6

func (s *Store) Pin(ctx context.Context, name string, scope Scope) (Pin, error)

Pin pins an existing context to a scope, replacing the scope's earlier pin.

func (*Store) PinFor added in v0.28.6

func (s *Store) PinFor(ctx context.Context, scope Scope) (*Pin, error)

PinFor is the scope's pin, or nil when it has none.

func (*Store) Put

func (s *Store) Put(ctx context.Context, p steer.Preset, revision, reason string) (Record, error)

Put creates only when revision is empty, or replaces exactly that revision. Replacements back up the previous record in the same transaction. A stale writer cannot overwrite a newer edit, even after deletion and recreation.

func (*Store) Unpin added in v0.28.6

func (s *Store) Unpin(ctx context.Context, id string) error

Unpin removes a pin by id.

Jump to

Keyboard shortcuts

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