Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

🧠 SOBER β€” CI/CD for Agent Brains

Git, pipelines, canary deploys, and Dependabot β€” for memory. Treat your Cognee knowledge graph as a versioned, testable, revertable, deployable artifact.

License: MIT Python 3.11+ Built on Cognee memory: can't merge a regression Live demo


SOBER β€” run memory CI, retract a leaked secret, watch its subgraph dissolve

A leaked launch code fails the memory CI. brain revert forgets it β€” the retracted subgraph dissolves, evals flip πŸ”΄ β†’ 🟒, every runbook fact intact.



β–Ά Live demo Β· πŸ–₯️ Run locally Β· πŸ“„ Research note


The problem

Your agent's memory is production infrastructure. It decides what your agent knows, says, and does. Yet today it ships with none of the machinery we demand of code:

code agent memory (today)
tests βœ… ❌ nothing stops a retracted secret staying recallable
diff βœ… ❌ can't see what a re-ingest or improve() changed
bisect βœ… ❌ can't find which ingestion poisoned the brain
gate before deploy βœ… ❌ mutates in place, silently

SOBER is the missing operations layer: a brain CLI + GitHub Action that wraps a Cognee brain in the same CI/CD discipline as application code. It's DevOps for memory, not memory for DevOps.

SOBER is a self-hosted, open-source tool β€” MIT-licensed, runs entirely on local Cognee (zero-config: ladybug + LanceDB + SQLite). No cloud account required.


What it does (proven, on real Cognee + Gemini)

The whole thesis β€” a brain that can't merge a regression β€” validated end-to-end on Cognee 1.2.2 with a live Gemini model and local embeddings.

πŸ”’ 1 Β· Forbidden-knowledge tests β†’ surgical forget

A launch code BRAVO-DELTA-9917 is ingested, then retracted. The memory-CI suite proves it's gone β€” and can't come back through paraphrase probes or graph residue (this is the moment in the GIF above):

$ brain test # secret present
πŸ”΄ FAIL β€” 6/11 secret leaks through forbidden probes + shows as graph residue
$ brain revert brain__retracted # forget(node_set="retracted"), memory_only
$ brain test # after retract
🟒 PASS β€” 11/11 unrecallable across all probes Β· every runbook fact intact
$ brain diff
πŸ”΄ the retracted subgraph removed nothing else β€” every runbook fact intact

A forget-regression test β€” a guarantee no other memory tool ships. A retracted fact stays retracted, and CI proves it on every change.

πŸͺ“ 2 Β· brain bisect β€” git-bisect for memory

When an eval goes red, some ingestion batch poisoned the brain. bisect binary-searches the ingestion history to pin the culprit in O(log n) probes, then brain revert forgets just that batch.

$ brain bisect --failing-eval no-cache-flush-advice
 probe 1 prefix=8 full-set πŸ”΄ red
 probe 2 prefix=5 brain__b05 🟒 green
 probe 3 prefix=7 brain__b07 πŸ”΄ red
 probe 4 prefix=6 brain__b06 πŸ”΄ red
 β–Έ culprit: brain__b06 (4 probes Β· linear would be 8)

πŸŒ™ 3 Β· CI-gated improve() β€” the brain ships itself

cognee.improve() distills chat sessions into the graph β€” a mutation that can silently regress memory. SOBER only runs it behind a green gate:

before after outcome
🟒 green 🟒 green accepted (exit 0)
🟒 green πŸ”΄ red blocked β€” no PR opened, rollback snapshot reported (exit 1)
πŸ”΄ red β€” refused β€” never distills into a broken brain (exit 1)

The nightly Action runs this gate and, on success, opens a pull request whose body is the graph diff + before/after eval scores. A human merges to deploy the smarter brain. That's the CD half of CI/CD for agent brains.


πŸ–₯️ Live demo β€” the memory-CI control panel

A hosted web app (app.py + web/dashboard.html) lets anyone run the memory CI, retract a leaked secret and watch its subgraph dissolve, and bisect a poisoned batch β€” in a browser, with an interactive knowledge graph (drag nodes, hover to trace blast-radius). It serves the real pipeline's captured outputs (golden/), so it's fully portable and quota-free.

β–Ά Open the live app β†’ wiz-abhi-sober.hf.space Β· deploy your own to Hugging Face Spaces in minutes β†’ docs/DEPLOY.md


How it maps to Cognee

SOBER exercises the full Cognee memory lifecycle β€” every verb is load-bearing, not decorative:

SOBER capability Cognee API
Build the brain from source cognee.add(...) + cognee.cognify(...)
Query for tests (keyless, no LLM) cognee.search(query_type=SearchType.CHUNKS, datasets=family)
Snapshot / diff the graph cognee.export(format="json") β†’ {nodes, edges}
Forbidden-knowledge / forget-regression cognee.forget(dataset=..., memory_only=True)
Surgical revert (one batch) node-set β†’ own physical dataset β†’ scoped forget
CI-gated self-improvement cognee.improve(dataset, session_ids)

Architecture note β€” the brain is a family. A logical brain (brain) is the union of per-node-set physical datasets (brain__runbooks, brain__retracted, ...). Recall and snapshot span the whole family; forget(node_set) drops exactly one member. That's what makes retraction and bisect-revert surgical β€” you excise one batch without disturbing the rest. Membership is tracked deterministically in snapshots/.family.json.


πŸš€ Quickstart

# 1. install (Python 3.11+)
pip install -e .
# 2. configure β€” copy .env.example to .env and add your Gemini key
# LLM_PROVIDER=gemini LLM_MODEL=gemini/gemini-2.5-flash-lite
# EMBEDDING_PROVIDER=fastembed (local, no key, no rate limits)
# 3. build the brain from the knowledge/ corpus, then gate it
brain build # ingest knowledge/*.md + snapshot
brain ci # snapshot β†’ diff β†’ evals β†’ ci_report.md β†’ exit 0/1
brain test # quick red/green eval check
# regression workflow
brain build --include poisoned # ingest a bad batch
brain bisect --failing-eval no-cache-flush-advice
brain revert <culprit> # surgical forget

brain --help lists all commands: ingest Β· build Β· snapshot Β· diff Β· test Β· ci Β· revert Β· bisect Β· improve Β· reset.

Just want to click around? python app.py β†’ open http://localhost:7860 β€” the control panel runs on built-in sample data, no key needed.


The memory CI suite

Eval specs live in evals/*.yaml. Three kinds, each answering a question a normal test suite can't:

  • must_know β€” recall for a query MUST contain an expected fact. Catches regressions (a fact silently dropped by improve() or a re-ingest).
  • forbidden β€” recall MUST NOT contain a string, probed across paraphrases. A single hit is a leak and fails the build. This is the retracted-secret / poisoned-advice gate.
  • structure β€” deterministic assertions over the exported graph JSON (no recall, no LLM): a retracted secret must not survive as node text; no malformed cross-type edges. Keyless β€” runs in every PR with zero Gemini budget.

CI/CD (GitHub Actions)

  • brain-ci.yml β€” on a PR touching knowledge/** or evals/**: rebuild the brain from source, run the gate, and post a sticky PR comment with the graph diff + eval report. Red build blocks the merge.
  • brain-nightly.yml β€” scheduled: run the CI-gated improve(), and on success open a self-improvement PR with before/after eval scores.

πŸ“Š Positioning & evidence

Memory benchmarks (LoCoMo, LongMemEval) measure recall accuracy. SOBER measures something orthogonal and, for production, more urgent: governance β€” can you test, diff, gate, and revert an agent's memory like you do its code? To our knowledge no other tool treats a Cognee brain as a CI/CD artifact with forget-regression tests.

A small reproducible study (research/memory_ci_vs_rag.md) quantifies the gap: against a plain vector store, SOBER takes a retracted secret's leak rate from 12/12 adversarial probes β†’ 0/12, removes exactly the retracted subgraph, and keeps every runbook fact β€” deterministically, keyless, on every change.

Honest status & limitations

Built solo in the hackathon window with heavy AI pair-programming. In the interest of not overclaiming:

  • Proven live on real Cognee 1.2.2 + Gemini + fastembed (Windows): the core forbidden-knowledge β†’ forget β†’ green loop, the brain CLI, snapshot/diff/export, and all keyless evals.
  • Proven by deterministic offline harness (stubbed verdicts, no API): the bisect binary-search and the CI-gate decision logic β€” rate-limited by the Gemini free-tier daily cap during the build; the live scripts (scripts/demo_*.py) reproduce them once quota allows.
  • Auto-rollback on a regressing improve() is best-effort: today the gate blocks the change (non-zero exit β†’ no PR) and reports the pre-improve snapshot; an in-process restore_snapshot is a planned enhancement.

Roadmap

  • Cognee Cloud canary deploys β€” after a green brain ci, cognee.push() the brain to Cloud and serve() it to a share of traffic, promoting or rolling back on live feedback.
  • In-process snapshot restore so a regressing improve() auto-rolls-back instead of only blocking.
  • More eval kinds β€” semantic contradiction detection, freshness/TTL checks, per-node-set coverage gates.

AI-assistance disclosure

Per the hackathon's disclosure requirement: this project was built with Claude Code (Anthropic) as an AI pair programmer β€” scaffolding, module implementation, this README, and the demo video. All architecture decisions, the Cognee integration approach, and final review are the author's. Every claim marked "proven" was executed and verified against the real stack, not generated.

License

MIT Β· Built for The Hangover Part AI: Where's My Context? (WeMakeDevs ×ば぀ Cognee).

About

CI/CD for agent brains - test, diff, bisect, gate and revert a Cognee knowledge graph like application code.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /