Skip to content

feat: proactive recall, selectable embedding model, full MCP control (v0.8.0)#8

Merged
RodCor merged 1 commit into
mainfrom
feat/v0.8-proactive-recall
May 31, 2026
Merged

feat: proactive recall, selectable embedding model, full MCP control (v0.8.0)#8
RodCor merged 1 commit into
mainfrom
feat/v0.8-proactive-recall

Conversation

@RodCor

@RodCor RodCor commented May 31, 2026

Copy link
Copy Markdown
Owner

Summary

Makes the brain proactive and gives the agent (and user) full control over it from inside Claude Code / Codex.

Proactive recall (mid-work)

The brain now surfaces a relevant memory while the agent works, not just on prompt — the way a memory "comes to you" rather than you fetching it. New PreToolUse / PostToolUse hooks (matcher Bash):

  • after a failed Bash command → surface a matching failure_pattern / command fix;
  • before a risky Bash command → warn from a matching failure_pattern;
  • on a repeated failing command (loop) → lower the score floor and bypass the throttle.

Discipline keeps it near-zero-cost: lexical-FTS-only (no embedding-model load), high score floor (0.45; loop 0.35), one capsule, per-session dedupe, and a refractory throttle. Silent (zero tokens) when nothing qualifies. Wired into both Claude Code (.claude/settings.json) and Codex (.codex/hooks.json); opt out with kimetsu plugin install --no-proactive (or proactive:false over MCP). Per-session state lives in <repo>/.kimetsu/proactive/<session_id>.json, GC'd after 7 days.

Selectable embedding model

  • New [embedder] table in project.toml (precedence: KIMETSU_BRAIN_EMBEDDER env > config > default).
  • kimetsu brain model list / model set <id> + MCP kimetsu_brain_model_list / kimetsu_brain_model_set. model set re-embeds the corpus with the new model via a fresh, uncached embedder (reindex_all_with_embedder), independent of the process's cached default. Curated built-ins: bge-small-en-v1.5 (default), bge-m3, jina-v2-base-code.

Full MCP control surface

New tools so an agent can manage the brain without leaving the harness: kimetsu_brain_model_list / _model_set, _reindex, _memory_search (FTS), _conflict_resolve, _prune, _config_show. _memory_list and _memory_proposals gained limit/offset pagination. (21 → 28 tools.)

Fix: test isolation (+ a latent production bug)

discover_repo_root runs git rev-parse --show-toplevel. On a machine whose $HOME is itself a git repo, temp project roots created under AppData//tmp climbed to $HOME, so parallel tests shared one brain.db + project.lockand the benchmark harness would init a fixture's brain at that ancestor, leaking fixture memories into the enclosing repo. New kimetsu_core::paths::git_init_boundary gives each fixture/test root its own git boundary (also a real correctness fix for bench). Plain cargo test is now hermetic with no env overrides.

Verification

  • cargo test (plain, no TMP / KIMETSU_USER_BRAIN overrides): agent 86, brain 106, chat 51, core 8, cli 18 + 7 smoke, e2e 8, 3 ignored — 0 failures.
  • cargo check --features embeddings typechecks; cargo fmt clean.
  • New unit tests: embedder resolution, proactive_state (dedupe/refractory/loop), capsule_matches_kind, search_memories pagination, retrieve_proactive kind filtering, reindex_all_with_embedder, config round-trip, and a Codex proactive-hook wiring + --no-proactive opt-out test.
  • Manual: proactive hooks (failure → inject, dedupe → silent, PreTool warn, non-Bash/success → silent), model list/set, and an MCP JSON-RPC smoke of all 7 new tools.

Bumps workspace + path-dep versions to 0.8.0; CHANGELOG.md and docs/HOW-KIMETSU-WORKS.md updated.

🤖 Generated with Claude Code

…(v0.8.0)

Make the brain proactive and give the agent (and user) full control over
it from inside Claude Code / Codex.

Proactive recall (mid-work):
  * New PreToolUse / PostToolUse Bash hooks surface a memory while the
    agent works: a fix after a failed command, a warning before a risky
    command, and a stronger nudge on a repeated/looping failure.
  * Lexical-FTS-only retrieval (no embedding-model load), high score
    floor (0.45; loop 0.35), one capsule, per-session dedupe + refractory
    throttle. ~0 token cost (silent when nothing qualifies). Wired into
    both harnesses with matcher "Bash"; opt out with --no-proactive.
  * Per-session state in <repo>/.kimetsu/proactive/<session_id>.json,
    GC'd after 7 days (new crates/kimetsu-cli/src/proactive_state.rs).

Selectable embedding model:
  * New [embedder] table in project.toml (env > config > default).
  * kimetsu brain model list|set, plus MCP kimetsu_brain_model_list /
    _model_set. model_set re-embeds the corpus with the new model via a
    fresh, uncached embedder (reindex_all_with_embedder) — independent of
    the process's cached default.

Full MCP control surface:
  * New tools: model_list/_set, reindex, memory_search (FTS), conflict_
    resolve, prune, config_show. Pagination (limit/offset) on memory_list
    and proposals.

Fix: test isolation. discover_repo_root runs `git rev-parse`, so on a
machine whose $HOME is a git repo, temp project roots climbed to $HOME
and parallel tests shared one brain.db + project.lock (and the bench
harness would leak fixture memories into the enclosing repo). New
kimetsu_core::paths::git_init_boundary gives each fixture/test root its
own git boundary; plain `cargo test` is now hermetic.

Bumps workspace + path-dep versions to 0.8.0; CHANGELOG + HOW-KIMETSU-
WORKS updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@RodCor
RodCor merged commit 6692fa4 into main May 31, 2026
10 checks passed
@RodCor
RodCor deleted the feat/v0.8-proactive-recall branch May 31, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant