Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

cairn-mem

Latest version: v0.18.0

Overview

Last scanned
26 Nov 2026
Published
26 Nov 2026
PyPI package Publisher: knightbcn
0 Stars
1 Forks
24 Versions
2.7K Downloads
Python Repo language

Scan summary

cairn-mem was last scanned on 26 Nov 2026 at version 0.18.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 24 versions; the latest 2 were published within 7 days (20–26 Nov 2026).
  • Findings: No rules fired in version 0.18.0.
  • Downloads: 2,718 downloads.

Versions

24 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.18.0 LATEST 26 Nov 2026 No rules fired
0.17.0 20 Nov 2026 No rules fired
0.16.0 18 Nov 2026 No rules fired
0.15.1 17 Nov 2026 Not shown
0.15.0 17 Nov 2026 Not shown

No rules fired in 0.18.0

Findings

Findings for v0.18.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.18.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

PyPI Python CI License: MIT Dependencies: 0

Install · Quickstart · Agents · How it works · Benchmarks · Commands

An agent finishes a session, and the next one starts from zero. You explain again why the auth flow works that way, which migration is risky, and why the team uses that commit convention.

Cairn keeps that context in .cairn/events.jsonl, inside the repository. Each entry is a short decision, convention, gotcha or fact, with the reason behind it. A new session loads a compact summary and searches the rest when it needs it.

$ cairn save --kind decision --topic storage/fts5 \
    --title "Use FTS5, not embeddings" \
    --body "BM25 over SQLite is enough for 10k memories" \
    --why "The internal query stays under 6 ms"
7a5a07d26632

$ cairn search "fts5"
7a5a07d26632  decision  Use FTS5, not embeddings — BM25 over SQLite is enough for 10k memories

There is no daemon, no server and no extra binary. Python 3.10 or newer and the standard library are enough.

Why cairn

  • Memory you can review. It is plain JSONL in the repo, so shared memory changes go through a pull request like any other change.
  • Explicit, not magic. The agent writes what it learned and why. No model decides what to keep, and there are no embeddings or hidden pipeline.
  • Portable. A CLI for any harness with a shell, plus an MCP server for clients that speak the protocol.
  • Fast where it matters. A search through 10k memories takes a few milliseconds over MCP.
  • Local by default. Nothing leaves the machine unless you run cairn init --share.
  • Deterministic. The same store and the same query give the same ranking. Nothing depends on a model or a network call.

Install

uv tool install cairn-mem     # or: pipx install cairn-mem

# development
pip install -e ".[dev]"

Cairn needs Python 3.10+ and no third-party runtime dependencies. The dev extra only adds pytest and ruff. It also needs SQLite with FTS5, which ships with the usual CPython builds on Linux, macOS and Windows.

Upgrade
uv tool upgrade cairn-mem     # or: pipx upgrade cairn-mem
pip install -U cairn-mem      # a plain pip install

Every package manager replaces the installed version in place; there is no uninstall step. Cairn has no self-update command on purpose: it would need network access and would have to guess which install to replace. cairn doctor reports when two cairn binaries are on PATH.

Quickstart

Create the store for the current repository:

cairn init                 # .cairn/ here, local-only
cairn init --share         # version events.jsonl so the team shares memory

Save something worth keeping:

cairn save \
  --kind gotcha \
  --topic auth/redirect \
  --title "OAuth callback must match exactly" \
  --body "redirect_uri is compared byte for byte; trailing slashes fail" \
  --why "Spent two hours debugging a 400 from the provider" \
  --anchor src/auth.py

--anchor stores a hash of an existing file. If the file changes later, the memory is flagged for review instead of quietly going stale.

Find it again:

cairn search "oauth redirect"                # id, kind, topic, title, snippet, stale flag
cairn get a1b2c3d4e5f6                       # full memory, including the reason
cairn check                                  # memories whose anchor file changed
cairn session save --summary "## Goal ..."   # long recap, kept out of MEMORY.md
cairn save --kind convention --title "Commits in LF" --body "every repo" --personal
                                             # knowledge shared by every repo

search covers the project and your personal scope at once and tags each result with scope ([personal] in text). Add --project or --personal to restrict it to one scope.

Anything you would otherwise repeat in the next session belongs here. Task state, logs and chat transcripts do not.

Use it from your agent

MCP

One process, eight tools (save, search, get, context, save_session, archive, session_list, session_get), JSON-RPC over stdio:

{
  "mcpServers": {
    "cairn": { "command": "cairn", "args": ["mcp"] }
  }
}

The server keeps the SQLite index open, so a tool call costs a few milliseconds instead of paying Python startup every time. save and save_session accept "scope": "personal". search takes "scope": "project" | "personal" | "all" (the default is all). context returns MEMORY.md plus the project's last session recap, so a new session starts where the previous one stopped. session_list and session_get reach older recaps without touching the current context, and archive retires a memory that no longer applies.

Any other harness

cairn setup claude-code writes .mcp.json, appends the snippet to CLAUDE.md, and installs the measured Stop hook as .claude/hooks/cairn_stop.py, registering it in .claude/settings.json; cairn setup opencode writes opencode.json (mcp.servers.cairn), AGENTS.md and the measured Stop hook (.opencode/plugins/cairn-stop/index.ts: one prompt per session when a turn ends without a save). Both merge into an existing config, keep their own other keys, and are idempotent. Use --dir <path> to configure another root. If CLAUDE.md already imports @AGENTS.md, setup claude-code skips the snippet (and removes a block an older setup left there), so Claude does not read the rules twice. The Claude Code hook pairs SessionStart with Stop, and its setup adds .cairn-nudge/ to the root .gitignore.

For anything else, copy the snippet from docs/AGENT_SNIPPET.md into your AGENTS.md or CLAUDE.md. The agent reads MEMORY.md at the start of a task, searches before writing, and saves only what is worth keeping. If the harness cannot run cairn, cairn export --out MEMORIA.md writes the same knowledge as plain Markdown.

How it works

agent ── MCP or shell ──> cairn ──> .cairn/events.jsonl     (truth, append-only)
                                    ├── .cairn/sessions.jsonl (long recaps)
                                    ├── cairn.db            (derived, FTS5)
                                    └── MEMORY.md           (L0, <= 3000 chars)

MEMORY.md is the compact summary an agent reads at startup. It is built round-robin across kinds, so a noisy kind cannot push the others out of the budget. Each line shows the topic key when the entry has one.

Level What Size
L0 .cairn/MEMORY.md, loaded at startup ≤ 3000 characters
L1 cairn search "<terms>" about 50 tokens per result
L2 cairn get <id> full entry, body ≤ 500 characters

Search covers the title, body, reason, topic key and anchor path, so storage/fts5 or src/auth.py find the entry without remembering the title.

Only events.jsonl is the source of truth. cairn.db is rebuilt automatically when it is missing or out of date. MEMORY.md is regenerated by save, archive, rebuild or cairn render. sessions.jsonl is append-only and local: session recaps are continuity, not curated memory.

An entry can point to a file with --anchor. Cairn stores a hash of that file and flags the entry with ⚠ review when the file changes. Stale entries are never deleted or hidden automatically. cairn archive <id> is the explicit way to retire one. Saving with the same topic supersedes the previous entry, so the list stays current.

What it stores

Four kinds, with a title of at most 200 characters and a body of at most 500:

Kind Use it for
decision A choice and its reason: storage, architecture, a library
convention How this repo does things: naming, commits, structure
gotcha A trap that cost time, such as a platform quirk or an API failure
fact Stable context that is not obvious from the code

Cairn refuses text that looks like a secret, such as cloud keys, private keys, JWTs, password = ... or URLs with credentials. It does not redact them silently.

How it compares

Memory tools usually keep entries in a local database and let a model decide what to save. That works until you need to review the memory, share it with a teammate, or explain why the agent believes something.

Database-backed memory tools cairn-mem
Storage Local database, outside the repo .cairn/events.jsonl, plain text
Review Open the database Read the diff in a pull request
Sharing Export and import git clone, or local-only by default
Who writes Often an LLM extracts a summary The agent writes what it learned, with a reason
Output Varies with the model Deterministic ranking, no model in the loop
Runtime A server or a separate binary Python standard library

Commands

Command Purpose
cairn init [--share] Create .cairn/; --share versions events.jsonl
cairn save Store a decision, convention, gotcha or fact (--keywords adds synonyms for search)
cairn search "terms" Ranked active memories from project and personal scope (--project/--personal)
cairn get <id> Full memory
cairn archive <id> Stop returning a memory (either scope)
cairn topics List active topic_keys with their count
cairn history <topic> Every version of a topic_key, with its status
cairn check [--personal] List memories whose anchor changed
cairn render [--personal] Regenerate and print MEMORY.md
cairn rebuild [--personal] Rebuild the index from events.jsonl
cairn session save\|list\|get [--personal] Session recaps, separate from curated memory
cairn import legacy --db <path> [--dry-run] Migrate observations from another SQLite store
cairn doctor [--personal] Check SQLite/FTS5, JSONL lines, DB sync, L0 budget, stale anchors, .gitignore and duplicate installs
cairn setup claude-code\|opencode [--dir <path>] Write the MCP config, the rules snippet and the measured Stop hook (Claude Code settings + hook file; OpenCode plugin)
cairn export [--personal] [--sessions N] [--out <path>] Dump active memory (and recaps) as Markdown for a harness without cairn
cairn mcp Serve MCP over stdio

--json is available on save, search, get, check, topics, history, session, doctor and import for agent consumption. --personal selects the personal scope on save, search, rebuild, render, check, session and doctor; search also takes --project. search spans both scopes by default, and get and archive check both stores.

The CLI, doctor and setup speak English. Set CAIRN_LANG=es for Spanish. The agent-facing surface (L0 and MCP) is English only, so a tool error does not change language with your environment.

Benchmarks

Windows 11, 10k memories, idle CPU, 2026-11-04. CLI numbers include Python startup. MCP numbers are in-process tool calls. You can see all measurements:

Operation p95
cairn search via CLI (project + personal) 309.3 ms
cairn save via CLI, summary render included 329.6 ms
search via MCP tool call 6.6 ms
save via MCP tool call 17.9 ms
context via MCP tool call 12.4 ms
Internal FTS5 query 4.5 ms

Retrieval precision@3 on the bundled golden set is 30/30. A small paired test, 8 tasks run twice, went from 0/16 correct answers and 26,826 tokens without memory to 16/16 and 20,982 tokens with it. The sample is too small to prove much, but the direction was consistent (details).

Migrating from another memory store

cairn import legacy --db <path> --dry-run   # counts without writing
cairn import legacy --db <path>             # project rows to .cairn/, global rows to ~/.cairn

Running it again is a no-op, because ids are derived from the source observation id.

Design choices

Saving is explicit. No model decides what to keep, and nothing calls an LLM, so the same store and query produce the same ranking.

Memory stays local unless you run cairn init --share. Internal context does not leave the machine by default.

The JSONL format and anchor hashes work the same on Linux, macOS and Windows. Anchor hashes normalize CRLF to LF. CI runs the suite on all three systems and on Python 3.10 and 3.14.

New capabilities need a measurement that justifies them. hits, decay, embeddings and passive capture stay in the backlog until a benchmark or a real user shows a gap (PLAN.md).

Development

pip install -e ".[dev]"
pytest -q
ruff check src tests bench
python bench/bench_mcp.py --reps 20

See PLAN.md for milestones, docs/DESIGN.md for the design and docs/DECISIONS.md for the reasoning behind each trade-off.

Contributing

Issues and pull requests are welcome. Keep changes small, add a test for behavior changes, and run pytest -q plus ruff check src tests bench before opening a PR. The PR template lists the full checklist, and AGENTS.md documents the project conventions.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases cairn-mem

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Vulnerability Insights

Compromised Claude Code extensions (versions 2.1.312 & 2.1.313) in Cursor try to install a backdoor

CVE

Java4Shell (CVE-2026-114938): Easy to Crash, Hard to Exploit — Less Than 0.12% of JVMs Estimated at Risk of RCE

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229