Skip to content

feat: git-native memory layer (step 10) - #8

Merged
prashar32 merged 1 commit into
mainfrom
feat/step-10-memory
May 30, 2026
Merged

feat: git-native memory layer (step 10)#8
prashar32 merged 1 commit into
mainfrom
feat/step-10-memory

Conversation

@prashar32

Copy link
Copy Markdown
Owner

What & why

Implements the git-native memory layer (§8 step 10): a directory of markdown/YAML/text files you own (version in git, edit in your editor). RiskKernel only reads them. Retrieval is deterministic — list, read, keyword search. No embedding index / vector DB in v0.1 (off by default, per §9); semantic search is a future opt-in.

  • internal/memory — path-traversal-safe Reader: list / read / keyword-search .md/.yaml/.txt by namespace; markdown frontmatter (title/description, dependency-free key: value parse) with first-heading fallback.
  • Episodic facts — small key/value an agent accumulates during runs, in SQLite (migration 00004), upsert by (namespace, key).
  • APIGET /v1/memory (list/search), GET /v1/memory/entry, GET/PUT /v1/memory/facts. Traversal → 400, missing → 404.
  • CLIriskkernel memory list/show. Python SDKlist_memory/read_memory/list_facts/put_fact.
  • examples/memory/README.md documents the format.

Verification

  • go test -race ./... green; Python SDK suite green; vet/gofmt clean.
  • Tests: reader (list/read/search/path-traversal/missing), facts storage, HTTP endpoints, SDK stub.
  • Live: CLI memory list/show, list/read endpoints (frontmatter surfaced), facts PUT→GET round-trip, and a ../../etc/hosts traversal attempt blocked (400).

Notes

The embeddings flag exists only to make the off-by-default posture explicit; setting it logs a warning (no vector DB is built).

A directory of files the user owns and versions in git; RiskKernel only reads
them. Deterministic retrieval — no embedding index / vector DB in v0.1.

- internal/memory: path-traversal-safe Reader over a configured root —
  List/Read/keyword-Search of .md/.yaml/.txt by namespace; markdown frontmatter
  (title/description, simple key:value, no YAML dep) and first-heading fallback.
- internal/storage: episodic facts (migration 00004 memory_facts) — Put/Get/
  ListFact, upsert by (namespace, key); run_id optional attribution.
- API: GET /v1/memory (list/search), GET /v1/memory/entry, GET + PUT
  /v1/memory/facts. Path traversal -> 400; missing entry -> 404.
- CLI: riskkernel memory list/show (reads the dir directly).
- Python SDK: list_memory / read_memory / list_facts / put_fact.
- config: RISKKERNEL_MEMORY_DIR (default ./memory); RISKKERNEL_MEMORY_EMBEDDINGS
  off by default and explicitly not implemented (logs a warning if set).
- examples/memory/README.md documents the format.
- Tests: reader (list/read/search/traversal/missing), facts storage, HTTP
  endpoints, SDK stub. Verified live (CLI + endpoints + traversal block).
@prashar32
prashar32 merged commit cae4e53 into main May 30, 2026
5 checks passed
@prashar32
prashar32 deleted the feat/step-10-memory branch May 30, 2026 18:30
Comment thread internal/memory/reader.go
if err != nil {
return "", Entry{}, err
}
data, err := os.ReadFile(p)
Comment thread internal/memory/reader.go
if format == "" {
format = "text"
}
info, _ := os.Stat(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants