Files
magpie/internal/memory/main_test.go
T
yetone 4f0c587306 memory: a store of what agents learn about the user, shared by every agent
The first part of the memory layer: internal/memory keeps memories in
memory.json (lastgood + atomic writes under a file lock; a file that can't
be read is unknown and never written over). Each memory has a scope
(global, project:<git remote key>, agent:<id>), a kind (profile,
preference, rule, reference, fact, procedure, episode), free tags, an
origin and a status. Saving the same text in the same scope merges into
the memory already there; an agent's save never changes the kind or why
of a memory the user wrote or pinned.

A project is keyed by its origin remote, so every clone and worktree of a
repository shares its memories. Search is word-matched with CJK split
into characters and pairs. The digest agents will be given is published
on demand (a user's change, or once a day), never at an agent's save, so
instructions don't change mid-session; its text names no app or vendor.

Nothing uses the package yet: the MCP server, the Library's digest and
the GUI come next.

Run (on mote): go test -tags nogui ./internal/memory, -race -count=3,
TZ=Asia/Shanghai; go vet for darwin, linux, windows; gofmt -l clean.
Broken by hand: an agent's save allowed to change a user's memory
(TestUsersMemoryNotChangedByAnAgentsSave red) and a digest computed live
instead of published (TestDigestChangesOnlyWhenPublished red).
2026-11-10 03:25:44 +08:00

11 lines
203 B
Go

package memory
import (
"testing"
"github.com/yetone/magpie/internal/testenv"
)
// The tests run in a home of their own, never the user's real files.
func TestMain(m *testing.M) { testenv.Main(m) }