← Blog
Technical Deep Dive · May 2026

The Causal Knowledge Graph: how cachly learns from cause-and-effect

Most AI memory systems store facts. cachly stores causation — what led to what, with confidence scores.

The difference between facts and causes

Fact

“Use 127.0.0.1 instead of localhostin the ClickHouse healthcheck.”

Tells you what to do. Not when, not why.

Cause (CKG)

Using localhost causes restart loops when IPv6 is disabled, because localhost resolves to ::1which ClickHouse isn't bound to.

Tells you why — and exactly when this fix applies.

How the CKG works

Every call to learn_from_attempts() creates or strengthens a causal edge:

learn_from_attempts(
  topic       = "fix:clickhouse-healthcheck",
  outcome     = "success",
  what_worked = "Use 127.0.0.1 not localhost",
  what_failed = "localhost → ::1 on IPv6-disabled servers",
  severity    = "critical",
  tags        = ["docker", "clickhouse", "ipv6"],
)

# Creates a typed causal edge:
[condition: IPv6 disabled]
  ──causes──▶    [symptom: container restart loop]
  ──via──▶       [mechanism: localhost → ::1]
  ──fixed_by──▶  [action: use 127.0.0.1]
  confidence: 0.94

Bayesian confidence updates

Each edge has a confidence score that updates with each observation:

A fix seen 10 times with outcome: success has near-certainty. A fix tried once with outcome: partial stays marked uncertain. The Brain gets better with use.

The brain_predict tool

Before attempting a task, an agent can ask the Brain what's likely to go wrong:

brain_predict(
  context = "Deploying ClickHouse with Docker on a new Ubuntu server",
)

# Response:
{
  "predicted_failures": [
    {
      "description": "Healthcheck using localhost may fail if IPv6 is disabled",
      "probability": 0.91,
      "mitigation": "Use 127.0.0.1 + listen_host = 0.0.0.0",
      "severity": "critical",
      "based_on": 7
    },
    {
      "description": "ClickHouse OOM on low-memory hosts",
      "probability": 0.63,
      "mitigation": "Set max_server_memory_usage_to_ram_ratio = 0.8",
      "severity": "major",
      "based_on": 3
    }
  ]
}

Pre-load mitigations beforethe failure happens. That's the difference between reactive debugging and proactive deployment.

Why not just a vector database?

Vector DBs are great for “find things that look like X.” The CKG adds: “find things that cause X, or are caused byX, under what conditions.” A vector search for “healthcheck failure” returns text chunks. The CKG returns the condition, mechanism, fix, confidence, and observation count — together.

Edge types supported today: causes, fixes, requires, blocks, conflicts_with.

Using it today

The CKG is live in all Brain instances. Every learn_from_attempts call contributes to it. Every recall_best_solution and smart_recall query benefits from it. No configuration needed.

npx @cachly-dev/mcp-server@latest setup

cachly is a managed AI Brain for developers — persistent memory, team knowledge sharing, and semantic cache for Claude Code, Cursor, GitHub Copilot & Windsurf. One MCP server. 51 tools. Free tier, EU servers, no credit card.

Your AI is forgetting everything right now.

Every session starts blank. Every bug re-discovered. Every deploy procedure re-explained. cachly fixes that in 30 seconds — your AI remembers every lesson, every fix, every teammate's hard-won knowledge. Forever.

🇪🇺 EU servers · GDPR-compliant🆓 Free tier — forever, no credit card⚡ 30-second setup via npx🔌 Claude Code · Cursor · Copilot · Windsurf
CKGKnowledge GraphAI MemoryBayesianbrain_predictTechnical