execstore

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package execstore is a memory.Store backed by an external command that speaks the suga exec protocol v1 (see package extproc): every operation runs the command once, writes one JSON request line to its stdin and reads one JSON response line from its stdout.

Wire format for third-party implementations

The envelope is {"v":1,"capability":"memory","op":"<op>","args":{...}} and the answer {"ok":true,"result":{...}} or {"ok":false,"error":"..."}. The scope is always the string "user" or "project:<key>". Per op:

op "index"   args {"scope"}
             result {"lines":[{"id","title","kind","summary"}],"bytes":0}
op "get"     args {"scope","id"}
             result entry
op "write"   args {"scope","op":{"action":"add|replace|remove","id","title","body","kind","summary","applies_when"}}
             result entry; for "add" the backend derives the id from the
             title (the request id is empty); for "remove" it returns the
             entry as it was before removal, with title and body
op "search"  args {"scope","query","limit"}  (limit 0: backend default)
             result {"hits":[{"id","title","kind","snippet","updated"}]}

An entry is {"id","title","body","kind","summary","applies_when","updated"} with kind one of user, feedback, project, reference and updated an RFC 3339 time (optional). summary is the one-sentence index line description (optional; a backend that ignores it just returns an empty summary).

Ids must satisfy memory.ValidateID (lowercase a-z, 0-9, '-'). A missing entry is reported with ok=false and an error text containing "not found".

Everything the command returns is untrusted: ids and kinds are validated here, and the host wraps the store in memory.Governed, which sanitizes all text before the model sees it.

Index

Constants

View Source
const Name = "exec"

Name is the backend name reported by BackendName.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Command string
	Args    []string
	// Env holds extra KEY=VALUE entries for the child (credentials of the
	// parent environment are stripped by extproc).
	Env []string
	// Timeout bounds each call; zero means extproc.DefaultTimeout.
	Timeout time.Duration
}

Config describes the external command.

type Store

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

Store implements memory.Store (and memory.Named) over the command.

func New

func New(cfg Config) (*Store, error)

New validates cfg and returns the store. It does not run the command.

func (*Store) BackendName

func (s *Store) BackendName() string

BackendName implements memory.Named.

func (*Store) Get

func (s *Store) Get(ctx context.Context, sc memory.Scope, id string) (memory.Entry, error)

Get implements memory.Store. The returned id must equal the requested one.

func (*Store) Index

func (s *Store) Index(ctx context.Context, sc memory.Scope) (memory.Index, error)

Index implements memory.Store. Lines with an invalid id or kind are dropped.

func (*Store) Search

func (s *Store) Search(ctx context.Context, sc memory.Scope, q string, limit int) ([]memory.Hit, error)

Search implements memory.Store. Hits with an invalid id or kind are dropped.

func (*Store) Write

func (s *Store) Write(ctx context.Context, sc memory.Scope, op memory.Op) (memory.Entry, error)

Write implements memory.Store. For replace and remove the returned id must equal op.ID; for add it must be a valid id.

Jump to

Keyboard shortcuts

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