DEV Community

Darshan K
Darshan K

Posted on

I Gave My AI a Memory Graph — Then I Let It Block My Pull Requests

(Submission for the WeMakeDevs × Cognee "Hangover Part AI" Hackathon - Best Blogs Track)

Your AI coding assistant has amnesia. I gave mine a graph memory — and then I let it fail my Pull Requests.

Last week, Cursor suggested MongoDB for the fifth time. We migrated off Mongo three months ago. I snapped, opened a terminal, and built ProjectBrain.

ProjectBrain is a persistent memory layer for your codebase, built on Cognee and the Model Context Protocol (MCP). It doesn't just remember decisions locally for my IDE. I did something weird—I wired it to a real-time visualization dashboard and gave it veto power over my entire team's PRs via GitHub Actions.

Here is how I used Cognee's lifecycle to cure Context Rot.

The 4 Memory Verbs of Cognee

Cognee operates on a distinct lifecycle. We mapped each step to an MCP tool, allowing the IDE to command the graph directly.

1. remember(): Building the Context

When we make an architectural decision, we tell Cursor to save it. ProjectBrain ingests this into Cognee, extracting entities and building graph nodes in real-time. On our dashboard, you physically see a new node pop into existence.

Cursor invoking the remember_decision tool alongside the Next.js UI spawning a new blue node

2. recall(): Fetching the Context

When we ask a new question, Cursor queries ProjectBrain. Cognee uses a hybrid search (semantic similarity + graph traversal) to find relevant past decisions. Now, when I ask about transactions, it sees the explicit link between Mongo, the Double-Charge Bug, and Postgres.

Cursor successfully referencing the Postgres decision without being prompted

3. improve() (Memify): Strengthening the Bonds

Not all memories are equal. Calling improve() in Cognee strengthens the edge weights in the knowledge graph. In our dashboard, you can see the graph edges literally shift from gray to bright cyan as feedback is reinforced.

Dashboard showing thick cyan edges representing hardened organizational decisions

4. forget(): Active Hebbian Decay

When a deprecated pattern is deleted, we tell ProjectBrain to forget it. We built an active Hebbian decay loop in our API: the nodes dissolve and fade out with a particle effect, and Cursor immediately stops hallucinating obsolete patterns.


The Climax: CI/CD God-Mode

Memory shouldn't just exist inside a single developer's IDE. If a decision is made, the entire organization needs to enforce it.

So, we built a headless CI/CD Enforcer using GitHub Actions. We wrote a secondary agent (reviewer_agent.py) that triggers on every Pull Request, parses the Git diff, and queries the same Cognee graph memory.

If a junior developer (or their AI) tries to sneak MongoDB back into the codebase, the CI agent detects the architectural violation and physically fails the pipeline.

GitHub PR failing with a red X, accompanied by a comment from the ProjectBrain bot

The Results

By combining MCP with Cognee's graph capabilities, we achieved massive context gains:

Metric Result
Cold recall latency ~180ms
Memory ingestion ~1.2s per decision
Hallucination reduction 14/15 test prompts accurate (vs 4/15 baseline)
Graph nodes at demo end 47 interconnected entities

We didn't just build a memory plugin. We built an organizational brain that enforces its own memory across the entire engineering team.

RAG gives your AI a library card. Cognee gives it a memory. ProjectBrain gives it a conscience.


Try it yourself:
Check out the open-source repo here: rushdarshan/brain
Deployed Dashboard: brain-production-3699.up.railway.app
Built for the WeMakeDevs × Cognee "Hangover Part AI" hackathon.

Top comments (1)

Collapse
 
vicchen profile image
Vic Chen

Really like the shift from "memory as retrieval" to "memory as enforcement." The part that stood out to me was wiring recall into CI instead of keeping it trapped inside one IDE session. That feels much closer to how real teams prevent context rot: decisions become operational guardrails, not just notes. I'd be curious how you handle confidence/override paths when the memory graph is stale or when architecture is intentionally changing.