Skip to content
dosermenPublic

About

MIND: cognitive layer over mem (traits/habits/ideas/insights), md as source of truth

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MIND

A local-first cognitive layer for an AI agent: traits, habits, ideas and insights stored as plain markdown files, indexed in SQLite, served over MCP. Activation gates live in code - the agent cannot sanction itself.

MIND flow

Principles

  • Markdown is the source of truth. MIND/*.md records are the store; mind.db (FTS5 + vectors) and MIND.md are derived indexes, rebuilt by sync, never edited by hand.
  • Honesty gates are enforced by code. A new trait or habit starts as a candidate; only the user can approve it (trait approve, habit approve). An idea cannot skip its state machine. A trait value change consumes the observations that triggered it.
  • One-way bridge to mem. The outer memory server is reached read-only through a pinned contract (CONTRACT.json); host-specific paths come from MIND_MEM_PY/MIND_MEM_ROOT or ignored CONTRACT.local.json. doctor mem reports drift instead of hiding it.
  • Local-first, stdlib-only. Modular mindlib package, no runtime dependencies. Optional embeddings go to a remote endpoint you configure; when it is down, search falls back to FTS and never stalls.

Quick start

git clone https://github.com/dosermen/MIND.git
cd MIND
python mind.py sync              # build mind.db from MIND/*.md
python mind.py recall "defrag"   # ranked FTS search
python mind.py profile           # compact self-block for the agent
python mind.py digest            # everything pending, one list
python -m unittest discover -s tests

For agents

Two layers, two jobs. mem stores facts and verdicts about the project (what was done, what broke, how to fix it). MIND stores everything about the people and the process: the user's questions and interests, the agent's own reasoning and mistakes, ideas. Project facts do not go here; self- observations do not go there.

Read:

  • Start of a session - profile (traits, habits, recent insights) as a compact self-block before acting.
  • The user asks off-agenda or returns to an old topic - mind_recall first: is this interest or answer already recorded?
  • Verdicts and findings still get mem recall; MIND recall is for "how have I handled this before", not for project state.

Write - one line now beats a report later:

  • You made a mistake, were corrected, or a plan failed - mind_note ID TEXT [--side up|down] on the matching trait, right in the moment; the stumble is the observation.
  • A question or interest of the user says something about them - note it on the trait it evidences; do not wait for a pattern.
  • An idea flashes - idea new immediately; heads are for working, not for storing.
  • A verdict about your own work ("do it this way, never that way") - note, not a project record.

Two same-side notes make digest remind about a value recalibration; the rule is in docs/calibration.md. Do not recall after every step - session context already holds the in-flight work.

Gates are code, not etiquette: a new trait/habit stays a candidate until the user runs trait approve / habit approve, ideas follow their state machine, veto returns rc 1 on a hard block. Do not route around a gate, and never edit a trait value by hand.

python mind.py digest - everything pending in one list (approvals, recalc reminders, ideas, contract drift). Prefer the MCP tools when the server is configured; the CLI reads the same store.

CLI

command what it does
sync [--lenient] rebuild mind.db and MIND.md from records
remember / update / forget / restore record lifecycle; TEXT starting with --- is parsed as frontmatter+body
recall QUERY hybrid ranking (default): 0.45*bm25 + 0.20*recency + 0.10*importance + 0.25*cosine; MIND_RECALL=fts → pure FTS5 0.60/0.25/0.15
note ID TEXT [--side up|down] observation on a trait, in-place; 2 same-side notes make digest remind about a value recalc
idea new/status/kill, habit approve/exception/revise, trait approve lifecycle commands, gates in code
veto ACTION [--list] evaluate hard-veto rules; rc 0 allow / 1 prohibited / 2 no action
profile, digest, list, show, link read paths
embed fill vectors from the remote endpoint (MIND_EMBED_URL), batched with resume
doctor mem [--deep] contract check against the outer memory server
serve MCP stdio server (below)

Exit codes: 0 ok, 1 validation/drift/not found, 2 hard error.

MCP server

python mind.py serve speaks newline-delimited JSON-RPC 2.0 over stdio (protocol 2024-11-05, same shape as mem.py serve). Thirteen tools: recall profile digest show list note remember update forget restore veto idea habit. Mutating tools take the same single-writer lock as the CLI; a failing tool returns an error text, the server stays up.

opencode config:

"mcp": {
  "servers": {
    "mind": {
      "type": "local",
      "command": ["python", "/path/to/MIND/mind.py", "serve"],
      "codemode": false
    }
  }
}

Recall modes

  • Default: hybrid - FTS5 ranking plus a vector-only candidate pass over mind_vec (cosine >= 0.30) with weights 0.45*bm25 + 0.20*recency + 0.10*importance + 0.25*cosine. Chosen by an A/B usefulness gate (10 queries, 12 records): hit@5 8/10 vs 5/10 for plain FTS, MRR 5.17 vs 3.83. Needs the embedding server for the query vector; when it is down, falls back to FTS.
  • Opt-out (MIND_RECALL=fts) - deterministic pure FTS5, no network.
  • Footers are honest: fts (no vectors yet), fts (remote server down), hybrid partial k/n - the mode always says what happened.

Hard veto

A setting may declare veto_rules: [{id, pattern, reason}] (regex). python mind.py veto ACTION evaluates every alive setting and reports the fact, not the opinion. Validation refuses mode: block without a veto_executor: code|hook - an LLM cannot enforce a block on its own.

Layout

mind.py          compatibility shim -> mindlib (same CLI, same imports)
mindlib/         package: core (store/lock/parser), cli, mcp, veto,
                 bridge_glue (contract + doctor); stdlib-only
mem-bridge.py    read-only JSON-RPC client to the outer mem server
CONTRACT.json    pinned contract (no host-specific paths)
CONTRACT.local.json  local mem paths, gitignored (or MIND_MEM_* env)
MIND/            records - the source of truth (tracked in git)
docs/            DESIGN.md + mind-flow.svg - architecture, gates, roadmap
tests/           unittest suite, includes a stub mem server

Status

Implemented: store and sync, entry gates, note/recalc loop, FTS and hybrid recall, embed, veto rules, MCP serve. Roadmap (background digest, habit eligible journal, resurrect, reflect, identity boost) is in DESIGN.md.

License

MIT - see LICENSE.

About

MIND: cognitive layer over mem (traits/habits/ideas/insights), md as source of truth

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages