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/platform/storage/factory.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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.
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.
type MemoryBackend ¶
type MemoryBackend interface {
SyncIn(ctx context.Context) error
SyncOut(ctx context.Context) error
}
MemoryBackend syncs the persistent memory directory with a remote. The local backend is a no-op; the git backend pulls on run start and commits + pushes when a fact changes. Both directions are best-effort: an error is returned for tests/telemetry but callers log and continue - a sync failure never aborts the agent run. SyncIn is idempotent and runs at most once per process.
func NewMemoryBackend ¶
func NewMemoryBackend(cfg *config.Config) 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.