memory

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BridgeStart = "<!-- JACU MEMORY START -->"
	BridgeEnd   = "<!-- JACU MEMORY END -->"
)
View Source
const (
	SaveToolName   = "jacu_memory_save"
	RecallToolName = "jacu_memory_recall"
)

Variables

View Source
var (
	ErrBridgeChecksumMismatch = errors.New("JACU memory bridge checksum mismatch")
	ErrBridgeChecksumMissing  = errors.New("JACU memory bridge checksum missing")
	ErrBridgeMalformed        = errors.New("JACU memory bridge region is malformed")
	ErrBridgeSecretContent    = errors.New("JACU memory bridge contains secret content")
)

Functions

func RegisterTool

func RegisterTool(server *mcp.Server, root string)

func RenderAgentsBridge

func RenderAgentsBridge(records []Record) ([]byte, string, error)

RenderAgentsBridge returns the complete managed region and its source hash. The source hash covers normalized active conventions, not timestamps.

func RunRecall added in v0.4.0

func RunRecall(ctx context.Context, root string, in RecallInput) capabilityruntime.Result

func RunSave added in v0.4.0

func RunSave(ctx context.Context, root string, in Input) capabilityruntime.Result

Types

type BackendMetrics

type BackendMetrics struct {
	CorpusRecords  int
	RecallAt3      float64
	RecallMeasured bool
}

type BridgeResult

type BridgeResult struct {
	Status      BridgeStatus `json:"status"`
	SourceHash  string       `json:"source_hash"`
	RecordCount int          `json:"record_count"`
	Changed     bool         `json:"changed"`
}

func SyncAgentsFile

func SyncAgentsFile(path string, records []Record) (BridgeResult, error)

SyncAgentsFile appends or replaces only the managed memory region. A region whose checksum cannot be verified is never rewritten.

func SyncProjectAgents

func SyncProjectAgents(store Store, projectID, agentsPath string) (BridgeResult, error)

SyncProjectAgents renders all current project conventions through the same normal memory flow used by the save tool.

type BridgeStatus

type BridgeStatus string
const (
	BridgeCreated   BridgeStatus = "created"
	BridgeAppended  BridgeStatus = "appended"
	BridgeUpdated   BridgeStatus = "updated"
	BridgeUnchanged BridgeStatus = "unchanged"
)

type Input

type Input struct {
	ProjectID  string   `json:"project_id"`
	Kind       string   `json:"kind"`
	Title      string   `json:"title"`
	Body       string   `json:"body"`
	Evidence   []string `json:"evidence,omitempty"`
	Source     string   `json:"source"`
	Supersedes string   `json:"supersedes,omitempty"`
}

type Lint

type Lint struct {
	Level   string `json:"level"`
	Rule    string `json:"rule"`
	Message string `json:"message"`
	Field   string `json:"field,omitempty"`
}

type MemoryBackend

type MemoryBackend string

MemoryBackend names the storage strategy selected by the documented trigger. BackendFTS5 is a future migration target; this package still ships JSON only.

const (
	BackendJSON MemoryBackend = "json"
	BackendFTS5 MemoryBackend = "fts5"
)

func SelectMemoryBackend

func SelectMemoryBackend(metrics BackendMetrics) MemoryBackend

SelectMemoryBackend is deliberately a pure policy decision. Unknown recall is not a failure measurement and therefore cannot trigger a dependency.

type RecallInput

type RecallInput struct {
	ProjectID         string   `json:"project_id"`
	Query             string   `json:"query,omitempty"`
	Kinds             []string `json:"kinds,omitempty"`
	IncludeSuperseded bool     `json:"include_superseded,omitempty"`
	K                 int      `json:"k,omitempty"`
}

type RecallResult

type RecallResult struct {
	Results []Scored `json:"results"`
}

type Record

type Record struct {
	MemoryID     string   `json:"memory_id"`
	ProjectID    string   `json:"project_id"`
	Kind         string   `json:"kind"`
	Title        string   `json:"title"`
	Body         string   `json:"body"`
	Evidence     []string `json:"evidence"`
	Source       string   `json:"source"`
	Status       string   `json:"status"`
	SupersededBy string   `json:"superseded_by"`
	CreatedAt    string   `json:"created_at"`
	UpdatedAt    string   `json:"updated_at"`
}

func PromoteDerivedToConvention

func PromoteDerivedToConvention(store Store, id string, evalPassed bool, now time.Time) (Record, error)

PromoteDerivedToConvention uses only the caller's already-computed eval outcome. It does not inspect eval content or invent a clock value.

type SaveResult

type SaveResult struct {
	MemoryID string `json:"memory_id"`
	Record   Record `json:"record"`
	Lints    []Lint `json:"lints"`
}

type Scored

type Scored struct {
	Record Record
	Score  int
}

type SearchQuery

type SearchQuery struct {
	ProjectID         string
	Query             string
	Kinds             []string
	IncludeSuperseded bool
	K                 int
}

type Store

type Store interface {
	Save(rec Record, supersedes string) error
	Get(id string) (Record, bool)
	Search(q SearchQuery) []Scored
}

func NewFileStore

func NewFileStore(root string) Store

Jump to

Keyboard shortcuts

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