Skip to content

v4.2.0 — failover · telemetry · Insights · KG hygiene · quality bar

Choose a tag to compare

@kevintseng kevintseng released this 10 May 13:59
· 1624 commits to main since this release

MeMesh v4.2.0 — local memory layer for Claude Code & MCP coding agents. Universal AI memory (one SQLite file, no Docker, no cloud required).


Install / Upgrade

Option A — Claude Code plugin (recommended for Claude Code users):

/plugin marketplace add PCIRCLE-AI/memesh-llm-memory
/plugin install memesh@pcircle-memesh

Existing v4.1.7 plugin users: re-running /plugin install memesh@pcircle-memesh upgrades in place. v4.1.6 and earlier should re-add the marketplace first via the marketplace add command above (the marketplace identifier was renamed in v4.1.7).

Option B — npm global (works with any MCP-compatible client):

npm install -g @pcircle/memesh@4.2.0
memesh install-hooks       # wires up Claude Code hooks
memesh doctor              # verifies setup is green

Verify after install: memesh doctor should report Overall: PASS with Skills + hooks integrity: PASS.


A combined release covering recall-path simplification, cross-provider LLM failover, end-to-end LLM telemetry, the new Insights / Analytics dashboard surfaces, KG-connectivity work, and a type-safety + lint cleanup pass (0 lint warnings, 0 executable any in src/). +6k LOC, +46 tests (938 → 984 passing). Highlights below grouped per Keep-a-Changelog convention.

Added

  • Cross-provider LLM failover (src/core/llm-client.ts + config.ts) — new optional llmFallbacks: LLMConfig[] config field walked in order when the primary llm provider fails with auth / rate-limit / upstream / network errors. A 400-class bad-request stops the chain (the prompt itself is broken). Per-attempt telemetry surfaces via opts.onAttempt; secret-shaped tokens (sk-*, Bearer *) are redacted before reaching telemetry. Wired into all 5 Smart-Mode flows (dreamer, pattern-detector, consolidator, auto-tagger, failure-analyzer). Also exposed via the dashboard's POST /v1/config endpoint with mirrored apiKey masking on GET responses.
  • Persistent LLM telemetry (src/core/llm-telemetry.ts + llm_telemetry SQLite table) — every callLLM attempt (primary + each fallback tried) writes one row with {flow, provider, model, project, attempt_index, status, latency_ms, error_class, error_message, fallback_used}. New memesh telemetry [--window N] CLI command renders a per-flow scorecard. Prompt and response bodies are intentionally NOT persisted — the schema stays narrow to avoid a new privacy boundary.
  • Dashboard Insights tab (dashboard/src/components/InsightsTab.tsx) — surfaces the dreamer's pending / applied / rejected proposals with one-click accept/reject, replacing the CLI-only memesh dream list. New first-tab landing for fresh users. Backed by GET/POST /v1/dream/proposals[/:id][/accept|reject] endpoints.
  • Dashboard Insights banner (dashboard/src/components/InsightsBanner.tsx) — slim cross-tab nudge appearing when pending proposals > 0. Click navigates to Insights tab; × dismisses for the current session (re-surfaces next session). Hidden when current tab is already Insights.
  • Dashboard Analytics LLM telemetry panel (dashboard/src/components/LlmTelemetryPanel.tsx) — per-flow scorecard with success rate, fallback usage warning, median latency, provider breakdown, and error-class chips. 7d / 30d / 90d window pills. Color-coded left border by success rate (green ≥90%, yellow ≥50%, red <50%). Backed by GET /v1/telemetry?window=N.
  • Dashboard PatternCard (dashboard/src/components/PatternCard.tsx) — distinct visual treatment for pattern_emergent proposals (amber accent, severity surfacing) so emerging patterns read differently from weekly recap digests. Wired through a new kind field on ProposalSummary that listProposals now returns.
  • Stop-hook dream auto-trigger (scripts/hooks/session-summary.js:maybeTriggerDream) — after every coding session, if the project has ≥10 episodic entities and the project's last dream pass was >24h ago, spawn a detached memesh dream run --max-llm-calls 2 --window-days 14 so the Insights tab populates without the user knowing the CLI exists. Per-project state in ~/.memesh/dream-history.json; per-run logs under ~/.memesh/dream-runs/<project>-<ts>.log.
  • Heuristic KG relation backfill (src/core/kg-backfill.ts + new memesh kg backfill-relations CLI) — non-LLM connector for orphan entities. Two rules: tag co-occurrence (related-to for entities sharing ≥2 topical tags after a strict allow-list filter) and project clustering (belongs-to-project linking orphan lessons / decisions / bug-fixes to the most recent release / feature in the same project). Conservative filter excludes auto-capture noise (session_end, auto_saved, commit, completed, lesson, etc.) to prevent cartesian-edge explosion on dense lesson clusters.
  • Optional digest validator (src/core/digest-validator.ts + --validate CLI flag on memesh dream run) — second LLM pass that cross-checks a proposed digest's claims against source observations. Returns pass | soften | reject. Soften writes the proposal with a validation_warnings array attached; reject skips the proposal entirely. Default off because it doubles per-proposal LLM cost. Validator's own LLM calls land in telemetry under flow=digest_validator.
  • summarizes / evidence_for relations on accepted dream proposals (src/core/dreamer.ts:applyProposal) — accepting a digest now creates one summarizes edge per source entity (digest → source). Patterns get evidence_for (source → pattern). Without these edges, accepted digests showed as graph orphans even though they conceptually summarize their sources.
  • Dashboard roadmap tree + mindmap toggle (ProjectRoadmap.tsx) — vertical timeline tree visualization (default) with a mindmap toggle for radial dendrogram view. Roadmap milestones now require a PM-anchorable entity (release / feature / decision / plan / architecture / bug_fix / lesson_learned / etc.) — date-range fallback labels for activity-only weeks have been retired.
  • created_at timestamp on dashboard memory rows — every row in Browse / Manage now displays its absolute timestamp in YYYY-MM-DD HH:mm form alongside the relative-time badge.

Changed

  • Recall is now strictly LLM-free. The query-expander module has been retired (src/core/query-expander.ts and its 17 tests removed). recallEnhanced is single-pass FTS5 + sqlite-vec. Verified at 95.40% R@5 / 97.60% R@10 / MRR 0.8899 on LongMemEval-S Mode A — identical to the previously published baseline at every per-question-type breakdown. Mean per-query latency holds at ~18ms. Recall has been documented as FTS5-only on the hot path for several releases; the query-expander module is now removed so source matches docs exactly.
  • Dashboard graph tab card overflow fixed — type-filter row converted from flexWrap: 'wrap' to flexWrap: 'nowrap' + overflowX: 'auto' (a horizontal scroll strip) so the canvas is no longer pushed below the viewport on a 1440x900 screen. CANVAS_HEIGHT reduced 500 → 440. Canvas width measurement switched to getBoundingClientRect minus card horizontal padding (24px) so sub-pixel layout never produces a horizontal scrollbar on the card itself.
  • Dashboard "dream" terminology replaced with user-friendly framing — across 11 locales, "consolidate + dream compression" became "weekly recap + pattern detection". Same engineering work, less metaphorical naming.
  • Dashboard Insights is now the default landing tab for fresh users (was Lessons). Existing users' last-tab persistence still wins.
  • CLI memesh dream summary preserves the full error reason. The previous s.reason.split(':')[0] collapsed multi-segment provider errors (e.g. "LLM call failed: provider error: 401") into the leading fragment, losing the error class. Full reason is now grouped and printed.
  • Doc-sync for the query-expander retire — README + 4 locale parities (de / vi / th / pt) + ARCHITECTURE.md + API_REFERENCE.md + dashboard i18n's settings.llmOptional.smartFeatures (11 locales) all updated. Smart Mode benefits now described as auto-tagging + failure analysis + consolidate + dream, not "LLM query expansion (~97% recall)".
  • Type-safety pass across src/ — eliminated all 60 executable any instances in shipping code. Express handlers now use typed Request<P, ResB, ReqB> generics; catch (err: any) replaced with instanceof Error narrowing; SQLite metadata payloads typed as Record<string, unknown>. Pattern is uniform and PR-review enforces it going forward.
  • Lint health — resolved every standing warning. npm run lint reports 0 errors and 0 warnings at v4.2.0. ESLint flat config now codifies the hook silent-failure pattern ('no-empty': ['warn', { allowEmptyCatch: true }]) so legitimate hook code passes while genuine empty blocks still surface.
  • Native i18n translations for v4.2.0 dashboard surfaces — 8 locales (ja, ko, pt-BR, fr, de, vi, es, th) now have native translations for Insights / banner / telemetry / pattern keys. Previously these locales carried English placeholders to satisfy the parity test.

Fixed

  • /v1/config GET response masks llmFallbacks[].apiKey. Mirrors the existing llm.apiKey masking pattern. The llmFallbacks field is new in v4.2.0; the masking landed before any release tagged this code path. Verified end-to-end with a placeholder key.
  • /v1/config POST body schema accepts llmFallbacks. Previously ConfigBody.strip() silently dropped the field, so the dashboard had no way to configure a fallback chain.
  • PatternCard cosmetic fixes (InsightsTab.tsx):
    • busyId race on rapid accept clicks — replaced scalar busyId with Set<number> so two concurrent accepts don't stomp each other's button-disabled state.
    • digest_observations_preview === '(empty)' no longer renders as (empty)….
    • Filter chips have aria-pressed, expand toggle has aria-expanded (accessibility).
    • Status-badge color falls back to neutral gray on unknown future status values.
    • Removed dead-code response-shape unwrap (Array.isArray(data) ? data : ...).

Security

  • API-key paths in fallback chains are masked on every dashboard config response (see Fixed).

Tests

  • 938 → 984 vitest tests (+46) across 63 files, +6k LOC. New test files: tests/core/llm-client.test.ts (failover decision tree, 23 cases), tests/core/llm-telemetry.test.ts (persistence + summarise, 4 cases), tests/core/kg-backfill.test.ts (heuristic contract, 19 cases), tests/core/digest-validator.test.ts (pass / soften / reject + sanitiser integration, 13 cases), tests/hooks/dream-auto-trigger.test.ts (gate + throttle + spawn, 5 cases). 3 independent LongMemEval-S Mode A regression runs confirm 95.40% R@5 unchanged.

Migration

  • A new llm_telemetry SQLite table is created on first openDatabase() after upgrade (idempotent CREATE TABLE IF NOT EXISTS). No data is migrated — telemetry starts fresh.
  • Existing dream_proposals rows are unaffected. New proposals from applyProposal now also write summarizes / evidence_for edges, but historical proposals' graph connectivity is unchanged. Run memesh kg backfill-relations to retroactively connect the high-signal long tail.
  • Dashboard build artifact (dashboard/dist/index.html) grows from 333 kB → 370 kB (gzip 84 kB → 90 kB) — the four new tabs / panels / cards landed inline.

Known limitations

  • Windows dream-auto-trigger.test.ts "all gates pass" scenario is skipped. Hook completes but dream-history.json is not updated when MEMESH_DIR is propagated through execFileSync to a child Node process. Functionality verified on macOS + Linux. The other four gate scenarios (LLM gate, activity gate, throttle gate, prefix-collision) all pass on Windows. v4.2.0 ships with stderr-trace instrumentation behind the MEMESH_DREAM_TRIGGER_DEBUG=1 env flag so the failing gate can be identified from the first [memesh dream-trigger] exit reason=… line on a Windows runner.

Verification

  • npx tsc --noEmit clean
  • npm run lint — 0 errors / 0 warnings
  • npm test — 984/984 passing (63 test files)
  • memesh doctor — Overall: PASS (13/13)
  • LongMemEval-S Mode A — R@5 95.40% / R@10 97.60% / MRR 0.8899 (baseline preserved across 3 independent runs)

Full Diff

v4.1.7 → v4.2.0 diff · Merged via PR #43