Deterministic memory and logic reasoning for AI agents.
- Go 100%
| internal/api | dedupe | |
| skill | change link | |
| .gitignore | git ignore | |
| go.mod | full impl | |
| go.sum | full impl | |
| LICENSE | initial commit | |
| main.go | full impl | |
| README.md | readme | |
monkey-brain
Small Go microservice for deterministic memory and logic reasoning using Prolog-style triples.
What it does
- Stores facts as
triple(subject, relation, target) - Supports rule-based inference (Horn clauses)
- Exposes HTTP endpoints on
http://localhost:7777 - Keeps in-memory Lamport-style temporal metadata for incremental updates
Endpoints
POST /learn- assert facts (array of triples)POST /forget- retract facts (single triple pattern)POST /pattern- define inference rulesPOST /ask- query facts/rules withlimit+offset
/ask responses are deduped before pagination.
Run
go run .
Server listens on:
http://localhost:7777
Quick example
Learn facts:
curl -X POST http://localhost:7777/learn \
-H "Content-Type: application/json" \
-d '[
{"subject":"alice","relation":"parent","target":"bob"},
{"subject":"bob","relation":"parent","target":"carol"}
]'
Define rules:
curl -X POST http://localhost:7777/pattern \
-H "Content-Type: application/json" \
-d '{
"name":"ancestor_base",
"conditions":[{"subject":"?A","relation":"parent","target":"?B"}],
"infers":{"subject":"?A","relation":"ancestor","target":"?B"}
}'
curl -X POST http://localhost:7777/pattern \
-H "Content-Type: application/json" \
-d '{
"name":"ancestor_recursive",
"conditions":[
{"subject":"?A","relation":"parent","target":"?B"},
{"subject":"?B","relation":"ancestor","target":"?C"}
],
"infers":{"subject":"?A","relation":"ancestor","target":"?C"}
}'
Ask:
curl -X POST http://localhost:7777/ask \
-H "Content-Type: application/json" \
-d '{"query":{"subject":"alice","relation":"ancestor","target":"?X"},"limit":50,"offset":0}'