feat: git-native memory layer (step 10) - #8
Merged
Merged
Conversation
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).
| if err != nil { | ||
| return "", Entry{}, err | ||
| } | ||
| data, err := os.ReadFile(p) |
| if format == "" { | ||
| format = "text" | ||
| } | ||
| info, _ := os.Stat(p) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-safeReader: list / read / keyword-search.md/.yaml/.txtby namespace; markdown frontmatter (title/description, dependency-freekey: valueparse) with first-heading fallback.00004), upsert by(namespace, key).GET /v1/memory(list/search),GET /v1/memory/entry,GET/PUT /v1/memory/facts. Traversal → 400, missing → 404.riskkernel memory list/show. Python SDK —list_memory/read_memory/list_facts/put_fact.examples/memory/README.mddocuments the format.Verification
go test -race ./...green; Python SDK suite green;vet/gofmtclean.memory list/show, list/read endpoints (frontmatter surfaced), facts PUT→GET round-trip, and a../../etc/hoststraversal 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).