memory

package
v0.163.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package memory provides pluggable sync backends for the agent's persistent memory directory (the fact-files + MEMORY.md index shipped in #670). The backend is selected by memory.backend.type: "local" (default) is a no-op; "git" clones/pulls the directory on run start and commits/pushes it back when a fact changes. The factory here mirrors internal/infra/storage/factory.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryBackend

func NewMemoryBackend(cfg *config.Config) domain.MemoryBackend

NewMemoryBackend selects a memory backend from config, mirroring storage.NewStorage. The git backend is used only when memory is enabled, the backend type is git, and a repo is configured; otherwise the local no-op backend is returned so behavior is unchanged. Validation (config.Validate) already rejects a git backend without a repo when memory is enabled; the guard here is defensive so a partial/legacy config degrades to local rather than constructing a broken git backend.

Types

type GitBackend

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

GitBackend syncs the memory directory with a git remote. It shells out to the git CLI (mirroring the exec.Command("git", ...) style in internal/services/ gitdiff) and inherits the ambient environment unchanged, so auth uses the user's default git/ssh config (ssh-agent, credential helper, GIT_* env). Every command runs under a per-operation timeout so a misconfigured remote ends the command instead of hanging on a credential prompt.

All operations are best-effort: they return an error for tests/telemetry, but callers log and continue - a sync failure never aborts the agent run.

func NewGitBackend

func NewGitBackend(cfg *config.Config) *GitBackend

NewGitBackend constructs a git-backed memory sync. It warns once if the repo URL embeds credentials (they persist in .git/config) - ssh or a credential helper is preferred.

func (*GitBackend) SyncIn

func (b *GitBackend) SyncIn(ctx context.Context) error

SyncIn pulls the memory directory from the remote, cloning it (or initializing a repo in place) on first run. It runs at most once per process and only when on_start is "pull".

func (*GitBackend) SyncOut

func (b *GitBackend) SyncOut(ctx context.Context) error

SyncOut commits and pushes the memory directory, but only when it has changes. It is safe to call repeatedly (the git status check gates the commit).

type LocalBackend

type LocalBackend struct{}

LocalBackend is the default no-op memory backend. Memory lives only on the local disk, so there is nothing to sync in or out - this preserves the pre-#683 behavior exactly.

func NewLocalBackend

func NewLocalBackend() *LocalBackend

NewLocalBackend returns the no-op backend.

func (LocalBackend) SyncIn

SyncIn is a no-op.

func (LocalBackend) SyncOut

func (LocalBackend) SyncOut(context.Context) error

SyncOut is a no-op.

Jump to

Keyboard shortcuts

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