Release/v1.5.0#27
Merged
Merged
Conversation
…ntext.served - Add `learning.store_queries: bool` (default true) to LearningSection in kimetsu-core/config.rs with `#[serde(default = "default_true")]` so pre-v1.5 project.toml files load cleanly and gain the field on upgrade. - Extend backward-compat test (pre_v0_8_config_without_embedder_loads_with_default) to assert `learning.store_queries` defaults to true. - Extract pure `build_served_event_payload(ServedEventArgs)` builder in kimetsu-cli so the hook payload logic is unit-testable; add 6 tests. - When `store_queries=true`, include raw `"query"` text in the `context.served` telemetry payload alongside the existing `query_hash`. - Parse `session_id` from the UserPromptSubmit hook JSON (Change B) and include it in the payload when present; absent for Codex/plain-text hosts. - Config loaded best-effort from ProjectPaths; any error falls through to safe default (true) so telemetry never breaks the hook. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t events - New `kimetsu_brain::dropped_capsule` module: rolling JSON sidecar keyed by project cache dir. Stores up to 200 dropped memory ids from the last 2 hours. Pure functions `prune_window` + `match_and_remove` are clock-free and fully unit-tested (8 tests). I/O is best-effort: errors are swallowed. - `brain_context_hook` (kimetsu-cli): after retrieval, capture the top-10 excluded memory capsules (expansion_handle starting with "memory:") to the sidecar via `dropped_capsule::append_dropped`. Best-effort, post telemetry event emission. - `project::emit_regret_for_cited_memories(workspace, &events)`: scans an event slice for `memory.cited` entries; for each one, checks the sidecar via `dropped_capsule::take_if_dropped`; if found, emits a `retrieval.regret` event (memory_id, dropped_at, cited_at) and removes the entry. Fully best-effort — citation recording is never disrupted. - `pipeline::run_coding` (kimetsu-agent): call `emit_regret_for_cited_memories` after `projector::apply_events` so the trace is already projected before the regret sweep. - Cross-process design: both the hook process (CLI) and the pipeline/MCP process derive the same cache dir from the repo root via `user_cache_dir_for`, so they share the sidecar without coordination. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Implements the v1.5 "kimetsu pays for itself" story (DP-1 design): - `crates/kimetsu-brain/src/roi.rs`: new module with per-kind calibrated constants (failure_pattern=1500, command=400, convention=300, fact=500, preference=200), pure `estimate_savings`, full-window `roi_report`, and per-session `session_roi` used by the Stop hook. Built-in price table for Claude 3/4 and GPT-4/5 families with longest-prefix matching. - `crates/kimetsu-core/src/config.rs`: adds `[model] price_per_mtok: Option<f64>` with `#[serde(default)]` for backward compatibility; adds `pre_v1_5_config_without_price_per_mtok_loads_with_none` and `price_per_mtok_round_trips` tests. - `crates/kimetsu-cli/src/main.rs`: adds `BrainCommand::Roi(RoiArgs)` with `--window <7d|30d|all>` and `--json`; stop hook appends a savings sentence when ≥1 citation in the session (zero citations = silence). - `docs/ROI-METHODOLOGY.md`: public methodology doc with formula, constant table, Terminal-Bench sanity anchor, and honest limitations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t ON) Adds compress_for_render(summary, max_sentences) to kimetsu-brain/context.rs: strips [tags:...] / (context:...) annotations, caps at 3 sentences while preserving the "scope:kind - " prefix memory summaries carry. Ranking inputs, stored DB text, and eval/bench retrieval paths are untouched — this runs purely at render time (after retrieval + reranking). Config: BrokerSection gains compress_capsules (default true) and session_dedupe (default true, see story 2.3 below) with #[serde(default)] backward-compat and round-trip tests. Render sites wired (3): (a) brain_context_hook (UserPromptSubmit) in kimetsu-cli/main.rs (b) proactive PreToolUse/PostToolUse hook in kimetsu-cli/main.rs (c) brain_context_tool MCP response in kimetsu-chat/mcp_server.rs Bench (story 2.1 measurement): brain_bench_single now computes raw_tokens_mean and rendered_tokens_mean per combo and per case, written into combo JSON and the summary.md table. Tests: CFR-1..9 in context.rs including the >=25% reduction gate on a representative long memory (8 sentences, >60 tokens). feat(brain): v1.5 story 2.3 — session-scoped cross-turn capsule dedupe Audit findings: - The UserPromptSubmit hook runs as a fresh process per prompt with no cross-turn memory — it had NO session dedupe before this change. The same top-ranked capsule could be re-injected on every prompt in a session. - The proactive PreToolUse/PostToolUse hooks DO have per-session dedupe via proactive_state's surfaced_memory_ids + mark_surfaced. That mechanism only covers proactive injections, not the main context hook. - RunRecallLedger in kimetsu-agent provides cross-stage dedupe within one autonomous run, but it's in-memory only (not persisted) and not available to the stateless hook processes. - session_id is already extracted from the hook payload (Change B from the telemetry story) so the sidecar path is immediately available. Fix: brain_context_hook now loads the proactive-state sidecar (keyed by session_id) and applies dedupe_filter — a pure function added to proactive_state.rs — before rendering. Soft policy: if dedupe would empty the injection, the full ranked set is injected anyway. New proactive_state::dedupe_filter is a pure (handles, state) → Vec<usize> function with DD-1..6 unit tests covering: unsurfaced pass-through, surfaced filter, dont-empty soft policy, empty-handle pass-through, mixed, roundtrip. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…MCP context Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add kimetsu_brain_cite to the MCP server so primary Claude Code usage (not just agent runs) can emit memory.cited events. Each citation trains the retrieval objective so future queries surface that memory sooner. Changes: - KIMETSU_MCP_INSTRUCTIONS: add step (3) directing Claude to call cite when a retrieved memory materially helped - tool_definitions(): expose kimetsu_brain_cite with memory_id + note - is_privileged_write_tool: gate cite behind mcp_write_tools_enabled - call_tool dispatch: route to kimetsu_brain_cite() - kimetsu_brain_cite(): calls project::record_mcp_citation, returns JSON - 3 tests: listed-with-self-tuning, write-gated, writes-memory_citations row Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…+ citations (Part B) Build a personal eval set by joining context.served events (with raw query) to memory_citations via session_id exact match or ±30min time window. Deduplicates by query text, counts noise entries, tracks oldest/newest ts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nd coverage (Part B) Add BrainCommand::Tune with --status, --apply, --revert, --cost-weight flags. brain_tune() prints positive eval cases, noise count, oldest/newest ts, coverage by memory kind, and readiness verdict. Sweep/revert are stubs (Part C). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… I/O (Part C) 80-combo sweep space (4 lex × 5 sem × 4 reranker ids), compute_objective(), train_holdout_split() (deterministic 80/20), select_winner(), append/latest tune history (JSON file in .kimetsu/). 8 pure-function tests, all green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ut guard (Part C) Replace stubs with real brain_tune_sweep: sweeps 80 combos (lex × sem × rr) using NoopEmbedder for FTS-only eval (no model download required). Holdout guard requires ≥0.01 improvement before recommending apply. Reranker changes are recommended-only (never auto-written). brain_tune_revert restores last tune-history.json entry. Adds integration tests for dry-run and --status. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- project.rs: slice::from_ref instead of clone for apply_events arg - tune.rs: fix doc list over-indentation, remove stray items-after-test-module - main.rs: sort_by_key(Reverse) instead of sort_by for kind coverage Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The sweep was pinned to NoopEmbedder, so on embeddings builds tune would evaluate FTS-only retrieval — semantic-floor values could not differentiate and reranker scores were unrepresentative. Resolve the embedder exactly like production retrieval (open_embedder_for); lean builds still degrade to Noop with an explicit note in the output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rseded events Schema v2→v3: add superseded_by TEXT column + index on memories table. All retrieval paths (FTS, ANN, latest-recency, list/export, dedup checks) exclude superseded rows alongside invalidated ones. ANN reconcile extended to drop superseded rowids; on_supersede delegates to on_invalidate. consolidate.rs: cosine helper, union-find clustering, survivor scoring (usefulness_score × recency rank), apply_merge emitting memory.superseded events and reassigning citations, run_consolidation (dry-run + apply). Projector arm apply_memory_superseded stamps superseded_by, deletes FTS row, and removes from HNSW index. Full test coverage including integration tests and migration-upgrade assertions updated to target v3. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Story 3.2: `kimetsu brain consolidate [--dry-run] [--threshold 0.92] [--yes]` drives run_consolidation; with --distill finds loose clusters via find_distill_clusters and feeds each to the configured distiller, creating memory_proposals for review. distiller.rs gains make_provider_for_resolved to share provider construction without duplication. Story 3.3: `kimetsu brain triage [--score-floor 0.2] [--age-days 30]` lists fading memories (usefulness_score < floor AND age > cutoff) with interactive per-item [k]eep / [p]rune / [s]kip loop (triage_interactive_loop is generic over BufRead+Write for testability); --prune-all --yes for batch non-interactive mode. Pruning reuses existing invalidate_memory machinery. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add pure `redact_context_suffix` / `redact_tags_prefix` / `apply_export_redaction` functions to kimetsu-brain::project, update `export_memories` signature with `redact` + `redact_tags` bool params, thread them through the CLI `BrainExportArgs` struct. Redacted exports round-trip through `import_memories` dedup correctly because `normalize_memory_text` normalises the stripped lesson body deterministically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add BridgeTarget::Cursor and BridgeTarget::GeminiCli to kimetsu-chat::bridge with all required seams: enum, parse, as_str, plugin_install_inner, plugin_status_inner, plugin_uninstall_inner, bridge_export_skill, and new write_cursor_mcp_config / write_gemini_settings / merge_gemini_md helpers with matching uninstall variants. Cursor writes .cursor/mcp.json (type: "stdio") and .cursor/rules/kimetsu-brain/rule.md (alwaysApply: true frontmatter); no hooks. Gemini CLI writes .gemini/settings.json (mcpServers without type field) and merges GEMINI.md with begin/end markers. Both paths cover workspace + global scope. Adds 20+ bridge tests and updates resolve_setup_hosts / detect_present_hosts in kimetsu-cli for auto-detection. Also threads --redact / --redact-tags CLI args through BrainExportArgs → brain_export. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add a new `test-embeddings` CI job that compiles and runs the full workspace test suite with `--features embeddings` on ubuntu-latest (30 min timeout). Caches ~/.cache/huggingface and .fastembed_cache to avoid re-downloading model weights on every run. The existing `test` matrix already pulls in the embeddings code paths via feature-unification, but this job pins an explicit embeddings-flavored build slice and its own cache key. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- CHANGELOG.md: new v1.5.0 "pays for itself" section above v1.0.0 with ADDED/CHANGED/FIXED entries for all six stories (telemetry, ROI ledger, token budget, self-tuning, consolidation, reach). Cursor/Gemini CLI installers carry explicit "not verified on live hosts" honesty note. - README.md: add kimetsu brain roi + brain tune to quickstart block; extend host list to include Cursor and Gemini CLI. - docs/HOW-KIMETSU-WORKS.md: §6a adds ROI ledger, §6a adds consolidate/triage/tune sub-sections; §7 MCP table adds kimetsu_brain_cite; §10 config block gains learning.store_queries, broker.compress_capsules, broker.session_dedupe. - docs/INSTALL.md: add cursor + gemini-cli to host wiring block with the "not verified on live hosts" honesty paragraph. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Five corrections: sidecar filename is dropped-recent.json; the semantic floor default is -1.0 AUTO (HOW-KIMETSU-WORKS was stale at 0.0); the tune sweep field is broker.min_lexical_coverage (no min_fts_coverage exists); INSTALL's host-integration count is six, not four; --redact-tags works standalone (CHANGELOG claimed it required --redact; the CLI doc comment made the same false claim). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…event payload Enrich `memory.superseded` events with `use_count_delta` and `score_delta` (the member's contribution at merge time). Extend `apply_memory_superseded` to accumulate those deltas onto the survivor row and reassign the member's citations via a shared `reassign_citations_projection` helper. Remove the direct-UPDATE duplication from `apply_merge` so both the live consolidation path and `rebuild_in_place` replay go through the identical projector arm — eliminating the stat/citation drift on `brain rebuild`. Adds failing test `consolidation_is_rebuild_safe` that verifies member use_count_delta (2) and citation attribution survive a full `rebuild_in_place`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ytics, and user-brain dedup Fix 2: add `AND m.superseded_by IS NULL` to `search_memories_in_conn` so superseded memories never appear in `memory search` results. Fix 4: add `AND superseded_by IS NULL` to `list_memories_top` (both scope branches), `prune_low_usefulness` (both scope branches), and the analytics `top_useful`/`prune_candidates` queries — superseded rows no longer pollute memory top or prune candidate lists. Fix 5: add `AND superseded_by IS NULL` to the `add_user_memory` dedup query so a normalized text that matches only a superseded row creates a fresh active row instead of collapsing onto the dead one. Each fix is covered by a new failing-first test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…back mode When fewer than 30 cited cases are available, the sweep uses the committed fixture file (relative-only mode). In that mode MRR≡0 for every combo so the objective degenerates to pure token-minimisation; applying the resulting floors could write recall-harming values to project.toml. Guard: if `using_personal == false` and `--apply` is requested, print a clear refusal message and return without writing project.toml or tune-history.json. The dry-run output in fixture mode also now carries a one-line caveat about the relative-only nature of the sweep. Adds test `fix3_apply_in_fixture_mode_leaves_config_untouched` verifying project.toml mtime and tune-history.json are unchanged after --apply in fixture mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.