world-model-mcp
World Model MCP is a temporal knowledge graph server that provides long-term memory, constraint enforcement, and learning capabilities for AI coding agents across sessions.
Knowledge Graph Query & Recording
query_fact— Search for facts about APIs, functions, and classes to prevent hallucinationsrecord_event— Log development events (file edits, test runs, tool calls) with reasoning chainsrecord_decision/get_decision_log— Capture agent proposals and human responses as structured decision tracesseed_project— Scan a codebase to auto-populate the knowledge graph
Constraint Management
get_constraints— Retrieve project-specific rules (linting, architecture, API contracts, style)get_agents_md_constraints— Parse declarative constraints from AGENTS.md, CLAUDE.md, etc.export_claude_md— Auto-generate a CLAUDE.md from learned constraints and decisionspromote_constraint— Propagate a constraint from one project to all othersingest_pr_reviews— Convert GitHub PR review comments into learned constraints
Change Validation & Risk Assessment
validate_change— Pre-execution validation against constraints and linterspredict_regression— Score regression risk based on past bugs and violationssimulate_change— Project the blast radius of a proposed changepredict_test_failures— Surface tests likely to fail for edited filesget_co_edit_suggestions— Identify files historically edited alongside a given fileget_context_for_action— Pre-action bundle combining constraints, bugs, decisions, and risk score
Learning from Corrections
record_correction— Teach the system from user edits so patterns persist across sessionsrecord_test_outcome— Record test results and link failures to recent code changesget_related_bugs— Find previously fixed bugs in a file
Contradiction Detection & Resolution
find_contradictions— Detect conflicting facts in the knowledge graphresolve_contradiction— Pick a winner using strategies:auto,keep_higher_confidence,keep_most_recent,keep_most_sources,supersede_a/b, ormanual
Memory Health & Compaction Survival
get_injection_context— Return a compact bundle for re-injection after context window compactionrecord_compaction_audit/get_compaction_audit— Track what was remembered across compaction boundariesget_health_report— Diagnose orphans, stale facts, contradictions, and decay candidatesrecall_transcript_range— Retrieve session transcript lines to trace a fact back to its origin
Multi-Project Search
search_global— Search entities and facts across all registered projects
Integrates with ESLint to provide linting validation for JavaScript/TypeScript code, detecting violations and suggesting fixes.
Integrates with GitHub to ingest pull request review comments and convert team feedback into constraints for future code editing.
Integrates with Ruff to provide linting validation for Python code, detecting violations and suggesting fixes.
World Model MCP
Coding agents remain blind to the codebase they operate on. They infer structure late, reduce it to prompts, and ignore it when decisions are made in real time — repeating the same mistakes, hallucinating APIs that don't exist, and forgetting learned constraints the moment context compacts.
World Model MCP is the memory-graph infrastructure that closes that gap. A temporal knowledge graph that validates code changes against learned constraints at the edit boundary, re-injects relevant context after compaction, tracks contradictions with confidence-weighted resolution, adversarially verifies retrievals via an independent Coach LLM, and runs across Claude Code, Cursor, Codex, pi, OpenClaw, Hermes Agent, Continue, GitHub Copilot Chat, Cline, and Windsurf.
Status: v0.13.0 — 30 MCP tools, 27 CLI subcommands, 817 tests, pre-registered SWE-bench Verified repeat-mistake benchmark with a multi-seed replication appendix, a v0.8.1 contradiction-resolution benchmark at 100.0% on the
autostrategy, AND a v0.12.12 Coach-Player benchmark at 100.0% across 12 hand-labeled pairs. v0.13.0 (2026-07-12) ships an opt-in tamper-evident audit log: every fact / constraint / event / decision write chains into an append-only log; every 1024 entries a Merkle epoch closes with a hybrid Ed25519 + SLH-DSA-SHA2-128f (FIPS 205) signature so external compliance auditors can independently verify no history rewriting has occurred. Two new MCP tools —prove_entry_inclusionandget_audit_log_head— expose the read-side proof APIs. Enable withWORLD_MODEL_AUDIT_LOG=on. Full threat model, key management, and auditor workflow in docs/AUDIT_LOG.md. Reference verifier ships in Python (this repo) and TypeScript (world-model-mcp-verifier). Ed25519 viacryptography, SLH-DSA viapyspx(pure Python, no C dependencies). Storage overhead ~3 MB per project per year for a median deployment. v0.12.14 (2026-07-11) shipped an FTS5 metacharacter sanitizer inknowledge_graph.py— raw-then-sanitized retry so intentional FTS5 operator syntax (Legacy OR async) that internal callers use still works while user queries containing?,*, and other metacharacters no longer crashquery_factorfind_contradictions. Bug found via the new TypeScript SDK's first integration test on 2026-07-10. Same release shipped a Contributor License Agreement workflow (CLA.md+contributor-assistant/github-action) to preserve future relicensing options — the project stays MIT. v0.12.13 (2026-07-07) adds two follow-ups sourced from prior threads: an OpenAI-compatible Coach backend (WORLD_MODEL_VERIFICATION_BACKEND=openai-compatible— points Coach at OpenRouter / Ollama / vLLM / any OpenAI-shape endpoint without a proxy) and adoctorextension that scans~/.copilot/logs/*.logfor the two silent-failure signatures documented in copilot-cli #4001. v0.12.12 (2026-07-07) shipped Coach-Player adversarial verification (verify_retrievaltool + 12-pair hand-labeled benchmark), a pattern ported from the maintainer's earliery=cproject. v0.12.0 (2026-07-06) was the breadth+depth umbrella release: nine substantive changes across new adapter coverage (Copilot / Cline / Windsurf / Continue --global), consumer wiring for the v0.11.1 content-type schema plus governance schema additions (influence_state/expires_at), and a diagnostic + spec-readiness pass (world-model doctor, MCP 2026-07-28 audit). Adapter roster now covers ten runtimes. v0.11.0 (2026-07-02) is a depth release. v0.10 (2026-07-01) extended the harness-neutral memory story from four runtimes to seven with the OpenClaw / Hermes / Continue adapters; v0.11.0 solves real problems for the users we now have rather than adding more runtimes. Four things ship: (A)autocontradiction-resolution strategy rewrite — folds inconfirmerawareness, per-evidence-type decay, distinct-source-tool counting, and tie-detection; benchmark jumps from 77.1% to 100.0% on the same 105-pair × 19-category dataset. (B) Hermes nativeMemoryProviderplugin — intercepts writes at Hermes' routing layer rather than only surfacing tools, closing the architectural gap the v0.10 MCP adapter could not, motivated by Hermes #47349. (C) content-type routing schema field (rule/fact/procedure) — nullable and additive, enables MemoryProvider implementations to route writes by content shape, not just by tool call. (D) dogfooding case study — publishes what the fact graph captured about the world-model-mcp codebase itself (3 learned constraints with real violation counts, 1 realbug_fixreflection, 608 facts, 600 entities) AND what it did not capture (emptyevents/decisions/sessionstables). Pushing on that anomaly surfaced the actual root cause:setup_commandwrote unquoted$CLAUDE_PROJECT_DIRin every generated hook command, so any user whose project path contains a space silently got zero hook captures. The bug was shipped since v0.7.3; the fix ships in this release with a regression test. Reproducibility contract:python scripts/dogfooding_snapshot.pyregenerates the cited numbers byte-for-byte from the shipped DB. v0.10.1 was a doc-honesty patch (stale Zenodo DOI reference corrected). v0.9.2 shipped the multi-seed replication appendix per pre-registeredSEED_PLAN.md: on the 17-instance subset, load-bearing replication count is 0 of 7, mean paired delta across two seeds is +0.24 per instance with bootstrap 95 percent CI [0.00, 0.47]. The v0.9 +10.2 pts headline reads as a single-trial upper bound; the wedge claims (lifecycle-hook capture, per-fact provenance, per-evidence-type decay, PreToolUse defer) survive the multi-seed update because they are architectural, not empirical. Full appendix and per-instance results inbenchmarks/repeat-mistake/RESULTS.md. v0.9.1 restored the embedded telemetry token after a release-mechanics miss in v0.9.0. v0.9.0 shipped the empirical wedge proof. v0.8.1 expanded the contradiction-resolution benchmark to 105 pairs across 19 categories. v0.8.0 added domain-aware confidence decay with per-evidence-type TTL, per-item provenance fieldssource_toolandconfirmer, slash command write operations, and aconfirmerparameter onresolve_contradiction. Antigravity adapter held pending aTransformCompactionHookin the SDK. v0.7.6 added the/world-modelslash command andstatus-watchTUI widget. v0.7.5 added the Codex CLI adapter. v0.7.0 introduced PostCompact auto-injection, thedeferenforcement tier, confidence-weighted contradiction resolution, and a compaction audit log. Contributions welcome.
mcp-name: io.github.SaravananJaichandar/world-model-mcp
Numbers
Benchmark | Score | Details |
+10.2 pts (67.3% → 77.6% on 49 paired instances) | Pre-registered, Claude Code 2.1.177 headless, Zenodo DOI 10.5281/zenodo.21076824. Within-domain +15.0 pts, cross-domain +6.9 pts with zero regressions. Multi-seed appendix documents single-trial upper bound honestly. | |
100.0% on | 105 pairs × 19 categories, deterministic (no LLM). Shipped since v0.11.0. | |
100.0% exact match | 12 hand-labeled pairs (4 grounded, 4 partial, 4 hallucinated). Layer 3 adversarial verification via independent Coach LLM. Shipped since v0.12.12. |
The SWE-bench number is the load-bearing empirical claim. The other two are internal correctness benchmarks for shipped components. Reproducibility scripts in each benchmark directory or the linked repo.
Related MCP server: NervusDB MCP Server
Tamper-evident audit log (v0.13, opt-in)
For compliance-track deployments where the audit trail must be cryptographically verifiable (SOC2, HIPAA, FISMA):
export WORLD_MODEL_AUDIT_LOG=on
world-model # start server as usualEvery fact, constraint, event, and decision write chains into an append-only log. Every 1024 entries (env-tunable), an epoch closes with a Merkle root signed by a hybrid Ed25519 + SLH-DSA-SHA2-128f signature (both FIPS-approved; both required for verification). Compliance auditors call prove_entry_inclusion(row_id) via MCP, load the operator's public keys from <db_path>/keys/public_keys.json, and run the reference verifier locally — no round trip needed for verification.
Full threat model, key management, auditor workflow: docs/AUDIT_LOG.md
Reference verifier (Python + TypeScript):
world-model-mcp-verifierrepoStorage overhead: ~3 MB per project per year for a median deployment
Non-opt-in path is unchanged: no schema, no keys, no crypto imports if
WORLD_MODEL_AUDIT_LOGis unset
The audit log is deliberately opt-in. If your deployment does not have a cryptographic-audit requirement, leave it off — the log adds storage, one hash per write, and crypto dependencies. None of that is worth paying for if nobody in your stack is going to audit the log.
If world-model-mcp helped you, star the repo or open an issue with what worked or didn't. I read every one and the feedback shapes what ships next.
What It Does
World Model MCP creates a temporal knowledge graph of your codebase that learns from every coding session to:
Prevent Hallucinations -- Validates API/function references against known entities before use
Stop Repeated Mistakes -- Learns constraints from corrections, applies them in future sessions
Reduce Regressions -- Tracks bug fixes and warns when changes touch critical regions
Survive Compaction -- Re-injects top constraints and recent facts after the agent's context window resets
Resolve Contradictions -- Picks a winner between conflicting facts using confidence, recency, or source count
Think of it as a long-term memory layer that runs alongside Claude Code, Cursor, Codex, pi, OpenClaw, Hermes Agent, Continue, GitHub Copilot Chat, Cline, Windsurf, or any MCP-aware coding agent.
See it working
Three cloneable starter repos show world-model-mcp wired into a real Python (FastAPI + SQLAlchemy) project across the three highest-adoption MCP runtimes. Each ships 5 seeded constraints, 1 bug-fix reflection, and a WHAT_TO_TRY.md with concrete workflows. Fork one, pip install, and see the memory layer catch a constraint violation on the first edit.
Starter | Runtime | Config shape | Automatic enforcement |
Claude Code CLI |
| Yes (4 lifecycle hook events) | |
Cursor Editor |
| Yes (3 lifecycle hook events) | |
VS Code + Copilot Chat |
| No — Copilot Chat lacks lifecycle hooks; memory queryable via MCP tool calls only |
All three point at the same .claude/world-model/ DB path, so installing multiple starters (or all three) on one repo produces a shared fact graph across runtimes.
What's new in v0.12.13
OpenAI-compatible Coach backend.
verify_retrieval(v0.12.12's adversarial verification tool) can now route Coach calls through any OpenAI-shape endpoint — OpenRouter, Ollama, vLLM, LiteLLM, or a self-hosted deployment — without going through a proxy. SetWORLD_MODEL_VERIFICATION_BACKEND=openai-compatibleandWORLD_MODEL_VERIFICATION_BASE_URL=https://openrouter.ai/api/v1(or your endpoint of choice); the Coach client is built viaAsyncOpenAI(base_url=...)and dispatches throughchat.completions.createwith the system prompt in the messages list (OpenAI convention). API key priority: explicitWORLD_MODEL_VERIFICATION_API_KEY→OPENROUTER_API_KEY→OPENAI_API_KEY→ a placeholder for local endpoints that don't authenticate. New optional[openai]extra shipsopenai>=1.0. Backward compat: default backend staysanthropic; existing installs and the v0.12.12 baseline are unaffected.doctorCopilot log-signature scan. Newcheck_copilot_hook_signaturescheck parses~/.copilot/logs/*.logfor the two documented failure modes from copilot-cli #4001: PowerShellParserError(Copilot running bash-shaped commands through PowerShell on Windows) and/.claude/...path resolution (Copilot not exporting$CLAUDE_PROJECT_DIR; hooks run from cwd/). SKIPs gracefully when Copilot isn't installed. Reports the two signature counts separately so users can tell which of the two Copilot-side bugs is affecting them. Does NOT fix them — the fix has to come from Copilot — but separates "my hook wrapper is broken" from "the runtime is running my hook wrong."
What's new in v0.12.12
Coach-Player adversarial verification (
verify_retrieval). New MCP tool that runs an independent Coach LLM call against a candidate answer plus supplied source facts and returns a confidence band (HIGH / MEDIUM / LOW) with itemized verified + unverified claim lists and per-claim source pointers. Coach lives in its own module (world_model_server/verification.py) with its own prompt — no state shared with extraction or reasoning models. That's the adversarial part: Coach doesn't know how the answer was produced, only what the facts say. Contract: never raises. Every failure mode (no API key, empty answer, no facts, Coach LLM error, malformed Coach response) returns a LOW-confidence result witherrorpopulated. Cheap default:verification_modeldefaults to Haiku 4.5 (~$0.001 per verify call), env-configurable viaWORLD_MODEL_VERIFICATION_MODEL.12-pair hand-labeled benchmark (
benchmarks/coach-player/). 4 grounded, 4 partial, 4 hallucinated pairs plus a runner that reports hallucination catch rate, false positive rate, MEDIUM band correctness, and overall exact match. Ship-floor policy: false positive rate ≤10% is enforced (non-zero exit); hallucination catch ≥95% is aspirational at N=12 and gets enforced oncepairs.jsonexpands to ≥30 pairs. Full run costs ~$0.03 at Haiku 4.5 pricing.Exposed on both MCP + Hermes surfaces. MCP
list_toolsgainsverify_retrieval(27 → 28 tools); Hermes surfaced tool count 7 → 8 with the same tool schema.Pattern origin. Ported from the maintainer's earlier
y=cproject (Coach-Player adversarial cooperation between a Player synthesizer and a Coach verifier). world-model-mcp is the first MCP server to ship it as a first-class tool with a benchmark harness.
What's new in v0.12.0
world-model doctorcommand (v0.12.1). Eight diagnostic checks including.claude/settings.jsonshell-quoting (the pre-v0.11.0 unquoted-$CLAUDE_PROJECT_DIRbug pattern the dogfooding investigation surfaced), hook script presence,.mcp.jsonregistration, world-model DB directory + staleevents_queue.jsonl, and Claude Code hook-error history filtered bysettings.jsonmtime.--jsonfor machine-readable output;--fixfor safe auto-rewrites. Would have caught the v0.11.0 shell-quoting bug automatically instead of via manual investigation.influence_state+expires_aton Fact (v0.12.2). Two nullable additive fields.influence_state(observed/pending_review/approved/blocked) separates storage from influence on planning — a fact can be stored as evidence without being trusted by planners, or blocked from planning while still visible to audit.expires_atcomplements the continuouslast_decay_aterosion with hard drop-dead timestamps for compliance retention and ephemeral credentials. Migration mirrors the v0.11.1 pattern: NULL-default ALTER, index, no backfill, idempotent.Universal content-type routing consumers (v0.12.3). Closes the write- and consumer-side loop opened by v0.11.1. That patch added
content_typeto the model and table but never wired a consumer — worse,create_factsilently dropped the field on write. v0.12.3 fixes both:create_factpersists all three v0.11.1/v0.12.2 new fields,query_factshydrates them on read, andquery_factsaccepts acontent_typefilter.get_injection_contextis now routing-aware: rules always inject at PostCompact / UserPromptSubmit / SessionStart under a dedicated "## Rules (always active)" section; facts (or NULL) fill remaining slots; procedures are excluded from auto-injection entirely and reachable only via explicitquery_fact(content_type='procedure').GitHub Copilot Chat adapter (v0.12.4,
install-copilot). Merges into.vscode/mcp.jsonper workspace. Copilot Chat uses top-level"servers"(not"mcpServers"like every other adapter world-model ships — silently registers nothing if wrong). Merge semantics: absent → write; existing → preserve other servers; existingworld-model→ skip unless--force; malformed / wrong-shape JSON → refuse and leave the file untouched.install-continue --globalconfig-merge path (v0.12.5). Merges into~/.continue/config.yaml'smcpServersLIST (Continue's schema — distinct from Hermes' mcp_servers-mapping and from Claude Code / Cursor / Copilot / Cline / Windsurf's mcpServers-mapping).ruamel.yamlround-trip preserves comments, blank lines, and key ordering.Cline adapter (v0.12.6,
install-cline). Merges into~/.cline/mcp.json. Cline uses themcpServersmapping shape — same as Cursor / Claude Code.Windsurf adapter (v0.12.7,
install-windsurf). Merges into~/.codeium/windsurf/mcp_config.json. SamemcpServersmapping shape as Cline; only the default path differs.Hermes lifecycle hooks (v0.12.9). Layers the five optional hooks (
sync_turn,on_pre_compress,prefetch,on_session_end,on_memory_write) on top of the v0.11.0 MemoryProvider ABC.on_pre_compressreturns a compact injection bundle that honors the v0.12.3 content-type routing — rules always inject, procedures never do. Best-effort contract: exceptions caught, safe default returned; a broken hook must never crash the Hermes loop.MCP 2026-07-28 spec readiness scaffolding (v0.12.11). Non-behavior-changing observability + public audit against the MCP 2026-07-28 specification (Release Candidate). Ships
world_model_server.spec_readiness.READINESS_STATE(machine-readable audit matrix locked to five row states),extract_meta/log_meta_if_presentobservability helpers wired intoserver.py:call_tool, anddocs/MCP_2026_SPEC_READINESS.mdpublic audit doc. Backward compatibility with the 2025-03-26 spec preserved unconditionally.Adapter matrix now covers ten runtimes: Claude Code, Cursor, Codex, Hermes, Continue (per-project +
--global), OpenClaw, pi, GitHub Copilot Chat, Cline, Windsurf.Deferred per roadmap-gated conditionals: OpenClaw TypeScript plugin (v0.12.8, no adoption signal within 5 days of v0.10) and Antigravity CLI adapter (v0.12.10, SDK still lacks
TransformCompactionHookthrough v1.0.16).
What's new in v0.11.0
autocontradiction-resolution strategy rewrite (v0.11.0 A). Folds inconfirmerawareness, per-evidence-type decay, distinct-source-tool counting, and tie-detection. Lifts the v0.8.1 contradiction-resolution benchmark'sautoscore from 77.1% → 100.0% on the same 105-pair × 19-category dataset. Overall benchmark accuracy across four canonical strategies + the decayed strategy rises from 78.2% to 83.7%. Non-auto strategies unchanged. Thekeep_higher_confidence_decayedstrategy is promoted from benchmark-only to a first-class option inpick_winner. Full detail inbenchmarks/contradictions-200/.Hermes native
MemoryProviderplugin +install-hermes-providerCLI (v0.11.0 B). Python plugin implementing Hermes'agent/memory_provider.pyABC (initialize,get_tool_schemas,handle_tool_call,get_config_schema,save_config). Intercepts writes at Hermes' routing layer rather than only surfacing tools — the architectural distinction the v0.10 MCP adapter could not close. Motivated by the Hermes #47349 exchange where @TechFlipsi surfaced that adding another MCP-registered store doesn't fix "the agent still defaults to writingMEMORY.md" — only a MemoryProvider does. Ships asworld_model_server/hermes_memory_provider/in the wheel;install-hermes-providercopies the plugin to<hermes_home>/plugins/memory/world-model/. Seven surfaced tools (query_fact,get_constraints,get_injection_context,record_event,record_correction,find_contradictions,resolve_contradiction) — trimmed from the 27 exposed via MCP to keep Hermes' tool namespace focused. Optional Hermes lifecycle hooks (sync_turn,on_pre_compress,prefetch,on_session_end) tracked as v0.12.Content-type routing schema field (v0.11.1). Nullable
content_type: Optional[Literal["rule", "fact", "procedure"]]on theFactmodel and the facts table. Additive-only migration; existing rows keep NULL and continue to work. Distinct fromevidence_type(which describes where the fact came from) —content_typedescribes what shape of content the fact carries, so a MemoryProvider can route writes intelligently (rules → always-inject, facts → search-on-demand, procedures → skills store) instead of dumping everything into one destination. Sourced from the Hermes #47349 architectural framing. Consumers (query filters, MemoryProvider write routing) are v0.11.x follow-ups; this ships the schema, tests, and migration only.Dogfooding case study (v0.11.2) — surfaced a real shipped bug that was fixed in the same release. Publishes what the fact graph actually captured about the world-model-mcp codebase in
.claude/world-model/: 3 learned constraints with real violation counts (includingcheck-twine-before-tagandtag-before-upload, both derived from real release-mechanics incidents matching the v0.9.1 telemetry-token miss and the v0.10.1 tagging lesson), 1 bug_fix reflection citing a real bug inworld_model_server/knowledge_graph.py:120-135, 608 facts (607 from the seeder + the one bug_fix), 600 entities. Honest about what was NOT captured (emptyevents/decisions/sessionstables). Pushing on that anomaly hard enough surfaced the actual root cause:setup_commandwrote unquoted$CLAUDE_PROJECT_DIRin every generated hook command, so any user whose project path contains a space (macOS defaults like~/Documents/, corporate paths, or the maintainer's ownclaude context graph/world-model-mcp) has been silently failing every hook invocation since v0.7.3 shipped hooks. The fix ships in this release — two-line shell-quoting change insetup_command+ regression test. This is the exact kind of latent bug that dogfooding is supposed to catch, and it did. Reproducibility contract:python scripts/dogfooding_snapshot.py --db-path .claude/world-modelregenerates the committed JSON byte-for-byte, and drift-protection tests fail if the writeup and the snapshot diverge. Seecase-studies/v011-dogfooding/.What is unchanged. All v0.10.x code paths: the 27 MCP tools reported by adapters (no new server-side tools in v0.11), the SWE-bench Verified benchmark and its multi-seed appendix, the seven-runtime adapter coverage (Claude Code + Cursor + Codex + pi + OpenClaw + Hermes Agent + Continue), the Zenodo preprint (paper unchanged since v0.9.2; no new Zenodo version). v0.11 is a depth release — better contradiction-resolution intelligence, a second Hermes integration path, a schema axis for future routing work, and honest evidence for the dogfooding claim. Test count grew from 417 (v0.10) to 457 (+21 for the Hermes MemoryProvider plugin, +10 for the content-type schema, +9 for the case-study drift protection).
What's new in v0.10.0
Three new adapters in one release: OpenClaw, Hermes Agent, Continue. All three verified end-to-end against real installations of the target runtime:
OpenClaw —
install-openclawmerges into~/.openclaw/openclaw.json. Verified against OpenClaw2026.6.11 (e085fa1)on macOS:openclaw mcp probe world-modelreports 27 tools discovered. Root cause of the first-attempt "MCP error -32000: Connection closed" surfaced and fixed during E2E: OpenClaw's process spawn does not inherit shell PATH, so--command python3fails while an absolute path works. The CLI now defaultscommandtosys.executable(absolute) and rejects relative--pythonoverrides as a hard error. Documented as an install-time gotcha in the adapter README.Hermes Agent —
install-hermesmerges into~/.hermes/config.yamlundermcp_servers.world-model. Usesruamel.yamlround-trip mode to preserve every comment and blank line in Hermes' heavily-commented 1327-line reference config. A regression test (test_f2_install_hermes_preserves_comments_and_blank_lines) locks this down after a pre-E2Epyyaml.safe_dumpimplementation stripped ~1170 lines of documentation. Verified against Hermes Agentv0.17.0 (2026.6.19)on macOS:hermes mcp test world-modelreports 27 tools discovered. Hermes' built-in memory (character-capped, no auto-decay per Hermes docs) is complemented additively by world-model-mcp's provenance + decay schema. Requires the[hermes]optional extra (pip install "world-model-mcp[hermes]") soruamel.yamlis available.Continue —
install-continuewrites a standalone<project>/.continue/mcpServers/world-model.yamlfollowing Continue's documented per-server-file pattern. No config merge needed. CLI-side E2E: the exact stdio spawn Continue would perform returns 27 tools via a livetools/listroundtrip. Last-mile "does Continue's LLM see them in agent mode" verification requires a live VS Code / JetBrains session. Reprioritized after the SpaceX/Cursor acquisition to serve teams standardizing on OSS-neutral coding-agent workflows.
Absolute-path posture across all v0.10 adapters. OpenClaw's PATH-spawn issue was caught first, but the same absolute-path default applies to Hermes and Continue as a precaution. Every new install command defaults
commandtosys.executableand rejects relative--pythonoverrides. Users who hand-edit config files are directed to$(which python3)in both READMEs.Cross-runtime shared memory. All v0.10 adapters (and every prior adapter) default
WORLD_MODEL_DB_PATHto.claude/world-model— a relative path resolved against the client's working directory. This means a project that runs in multiple clients (e.g., Claude Code + Continue + OpenClaw) shares one SQLite fact graph across all of them. For user-wide shared memory regardless of CWD, override with an absolute--db-path. The differentiator against ClawMem (which does cross-runtime memory with a plain key-value SQLite vault) is depth: per-fact provenance, per-evidence-type decay half-lives, PreToolUse defer enforcement.What is unchanged. All v0.9.2 code paths: the 26 base MCP tools (v0.10 adds no new server-side tools; the "27 tools" count reported by adapters includes
resolve_contradictionwhich shipped in v0.8.0), the SWE-bench Verified benchmark, the multi-seed replication appendix, the wedge claims. v0.10 is an adapter-surface release, not a schema-or-benchmark release. Test count grew from 375 (v0.9.2) to 417 with the three new adapter test suites; every baseline test still passes.Test breakdown. 375 baseline + 14 OpenClaw + 16 Hermes + 12 Continue = 417 tests. Every adapter's test suite includes: bundled-file validity, dry-run behavior, first-install writes with absolute-path defaults, idempotence (refuse to overwrite without
--force),--forceoverwrite, relative---pythonrejection, parent-directory creation, malformed-config-file handling, and subparser-registration regression coverage.
What's new in v0.9.2
Multi-seed replication appendix shipped per
SEED_PLAN.md. The v0.9 paper's primary limitation was single-trial design. v0.9.2 ships the multi-seed test that SEED_PLAN.md (locked 2026-06-25) committed to running. The result is published verbatim per the pre-registered acceptance criteria.Honest update to the v0.9 headline. On the 17-instance pre-registered subset, baseline pass rate swung +41 percentage points between seed 1 and seed 2 with no methodology change. Load-bearing replication is 0 of 7 instances. Mean paired delta across both seeds is +0.24 per instance with bootstrap 95 percent CI [0.00, 0.47]. The v0.9 +10.2 pts paired delta should be read as a single-trial upper bound; the replicated effect size is small, possibly nonzero.
What is unchanged: all v0.9.1 code, the 26 MCP tools, the 19 CLI subcommands, the 375 tests, the wedge claims at the architectural level (lifecycle-hook capture, per-fact provenance, per-evidence-type decay, PreToolUse defer). Architectural claims do not depend on the empirical effect size and survive the multi-seed update.
Documentation diffs:
benchmarks/repeat-mistake/RESULTS.mdadds a "Multi-seed replication appendix (v0.9.2 update)".benchmarks/repeat-mistake/paper.mdadds Appendix A with the same content.benchmarks/repeat-mistake/paper.pdfis regenerated.benchmarks/repeat-mistake/SEED_PLAN.mdadds a status update (the locked plan above is unchanged). Raw seed-2 artifacts (baseline_progress_seed2.jsonl,treatment_progress_seed2_treatment.jsonl, predictions, results, and themulti_seed_summary_seed2.jsonfrommulti_seed_aggregate.py) committed.The methodology discipline held. Pre-registration prevented goalpost-moving. The honest update is published per the locked SEED_PLAN.md acceptance criteria. This is what pre-registration is for.
What's new in v0.9.0
Repeat-mistake benchmark on SWE-bench Verified — the central wedge proof. 50 SWE-bench Verified tasks across django, sympy, matplotlib, scikit-learn, and sphinx, run as a paired baseline-vs-treatment comparison. Methodology was locked at
benchmarks/repeat-mistake/DESIGN.mdon 2026-06-17 (before the data existed) so the result cannot be accused of goalpost-moving.Headline results — Subset 1 (within-domain: django + sympy) baseline 15/20 = 75.0 percent, treatment 18/20 = 90.0 percent, delta +15.0 pts with 4 FAIL to PASS flips and 1 regression. Subset 2 (cross-domain: matplotlib + scikit-learn + sphinx) baseline 18/29 = 62.1 percent, treatment 20/29 = 69.0 percent, delta +6.9 pts with 2 flips and zero regressions. Combined paired result across 49 instances: 33/49 to 38/49, delta +10.2 pts.
Cross-domain transfer isolated cleanly — the Subset 2 treatment arm loaded ONLY the 4 Subset 1 constraints (django and sympy directives), holding out the 11 Subset 2 constraints to test whether learning from one repo family generalizes to a different one. Two cross-domain flips with plausible mechanistic explanations grounded in the loaded constraints. Sphinx-9461 is the strongest case: a sympy classmethod constraint transferred to a sphinx classmethod-wrapper unwrapping bug.
Honest caveats embedded in RESULTS.md — seven explicit limitations including single-trial design, constraint-failure overlap on Subset 1, the small cross-domain transfer rate, one dropped instance due to an upstream SWE-bench pip flag issue, and judge-model self-reference risk. Stated verbatim rather than hidden in an appendix.
Full reproducibility artifacts — every progress JSONL, predictions JSON, results JSONL, classification JSONL, constraints JSON, and harness report JSON committed in
benchmarks/repeat-mistake/. Locked judge prompts infailure_classifier.pyandlearning_hook.py. Total agent cost across both arms was approximately 90 USD on a Claude Code subscription.
What's new in v0.8.1
Contradiction-resolution benchmark expansion -- the v0.7.4 24-pair benchmark grew to 105 hand-curated pairs across 19 categories. Six new categories exercise the v0.8.0 schema specifically:
source_tool_corroboration,confirmer_overrides_pending,decay_advantage_session_vs_source,decay_advantage_stale_session,evidence_type_user_correction,settled_beats_higher_confidence. Deterministic runner atbenchmarks/contradictions-200/run.py; full per-strategy + per-category breakdown atbenchmarks/contradictions-200/RESULTS.md.Honest framing on the numbers: the new dataset is harder than v0.7.4's 24-pair set because the new categories deliberately test schema awareness (confirmer, evidence_type, decay) rather than raw confidence ranking. Headline numbers:
keep_most_sources99.0%,keep_higher_confidence81.0%,auto77.1%,keep_higher_confidence_decayed90.5% (on the 21 pairs where evidence_type is present), overall 78.2% across all strategies. The original 24-pair v0.7.4 93.5% number is preserved unchanged atbenchmarks/contradictions/and is not invalidated; it tested a different (smaller, easier) corpus.The wedge benchmark is v0.9: "does the learning loop measurably reduce repeated coding-agent mistakes on a public task corpus?" The contradiction-resolution work in this release is internal schema-correctness validation. The empirical artifact that maps to the published essay framing — the learning loop is the durable layer — lands in v0.9 with a SWE-bench-style repeat-mistake benchmark.
What's new in v0.8.0
Domain-aware confidence decay -- new
world_model_server/decay.pymodule with exponential half-life decay perevidence_type. Half-lives: source_code 365d, test 180d, session 14d, user_correction 730d, bug_fix 365d. Decay applies on read (no background task), so the nextquery_factcall returns the time-corrected confidence. Settled facts (canonicalstatus, or any fact withconfirmer != NULL) never auto-transition. Synthesized facts that decay below 0.2 confidence and corroborated facts that decay below 0.1 confidence auto-supersede on read, surfacing rot to the next compaction injection.Per-item provenance fields on facts -- three additive columns (
source_tool TEXT,confirmer TEXT,last_decay_at TIMESTAMP), all NULL-defaulted, no backfill.source_toolrecords which tool wrote the fact (e.g.claude_code,codex,cursor,pi,user).confirmerrecords who confirmed it, distinct from the asserter; NULL means pending, non-NULL means settled. Both are exposed on theFactmodel and propagated throughcreate_fact. Honors the public commitment to Patdolitse (anthropics/claude-code#47023) and ferhimedamine (openai/codex#19195).Slash command write operations -- two new subcommands.
/world-model resolve <id>marks a contradiction as resolved (manual; for confidence-weighted picking use theresolve_contradictionMCP tool)./world-model forget <id>setsinvalid_aton a fact (preserved in the audit log; current-only reads skip it from then on). Both are idempotent and report cleanly on unknown ids. Help text now lists both alongside the read-only subcommands shipped in v0.7.6.resolve_contradictionacceptsconfirmer-- when aconfirmerargument is provided to the MCP tool or its underlyingresolvefunction, the winning fact gets itsconfirmercolumn stamped with that value. This is the spec primitive that distinguishes "the asserter says X" from "X is confirmed by Y" per the working group sketch.Antigravity adapter held for the third consecutive release. The 2026-06-13 re-verification found
OnCompactionHookdeclared asInspectHookin the SDK with noTransformCompactionHookand noadditional_contextreturn field. The load-bearing memory-injection contract still does not exist in the SDK.
What's new in v0.7.6
In-agent
/world-modelslash command -- typed by the user inside the agent harness, surfaces the world model state without leaving the chat. Read-only in v0.7.6 (status,contradictions,recent,help); write operations (resolve,forget) land in v0.8. Works across Claude Code, Cursor, Codex, and pi by interceptingUserPromptSubmitin the existinginject_helper. ReturnsadditionalContextin the strict camelCase shape Codex enforces (deny_unknown_fields), so the same wire-up serves all four harnesses without a per-harness branch.world-model status-watchTUI widget -- terminal pane that runs alongside the agent and refreshes every 5 seconds. Shows constraints (total, severity=error, severity=warning), unresolved contradictions, facts (canonical / synthesized / superseded), and last compaction time. Built on therichlibrary already in the dependency tree; falls back to a plain-text one-shot dump whenrichis not installed.Antigravity CLI adapter intentionally NOT shipped in this release -- the re-verification on 2026-06-13 against
google-antigravity/antigravity-sdk-pythonHEAD surfaced an architectural gap:OnCompactionHookis declared as anInspectHook(read-only, non-blocking) with noadditional_contextreturn field and noTransformCompactionHooksubclass. The load-bearing memory-injection contract does not exist in the SDK today. v0.7.6 ships without Antigravity rather than against a contract that cannot do the work.
What's new in v0.7.5
Codex CLI adapter -- new
install-codexCLI subcommand appends a[mcp_servers.world_model]block plus PreToolUse, PostToolUse, PostCompact, and SessionStart hooks to~/.codex/config.toml. The bundled snippet was verified againstopenai/codex@mainat v0.138.0-alpha (server name uses underscore to dodge the tool-name hyphen-strip incodex-rs/codex-mcp/src/mcp/mod.rs; hook output sticks to camelCase withdeny_unknown_fieldscompliance). Schema regression tests intests/test_v075_features.pylock the contract down. See adapters/codex/README.md.Dual-shape payload normalization in
hook_helperandinject_helper-- both helpers now accept either Claude Code's payload shape (event,project_dir) or Codex's (hook_event_name,cwd), so the same Python code drives all four adapters (Claude Code, Cursor, pi, Codex).Antigravity CLI adapter intentionally NOT shipped this release -- the Antigravity API surface is still settling (six 1.0.x releases in three weeks, the
urlfield for HTTP MCP servers landed June 3, hook JSON event-name casing remains undocumented). Targeting June 25 for that adapter after the API stabilizes. Detailed reasoning in the v0.7.5 RELEASE_NOTES entry.
What's new in v0.7.4
AGENTS.md /
.agents/skills/constraint reader -- world-model-mcp now reads declarative project conventions fromAGENTS.md,CLAUDE.md,GEMINI.md, and.agents/skills/*.mdfiles and mixes them into PreToolUse enforcement alongside the SQLite-backed constraints. Supports structured fence blocks (```constraintand YAML frontmatter) and heuristic imperative-sentence extraction for prose-style AGENTS.md files. New MCP tool:get_agents_md_constraints. (anthropics/claude-code#6235 has 4,000+ thumbs-up for AGENTS.md as the cross-agent format.)Self-hosted Claude Managed Agents deployment guide -- Anthropic's official position: "Memory is not yet supported in self-hosted sessions." world-model-mcp fills that gap. New guide at
docs/deployment/managed-agents-self-hosted.md, with a Modal quickstart you can deploy in under five minutes.Reproducible contradiction-resolution benchmark -- 24-pair dataset at
benchmarks/contradictions/dataset.jsonl, runner atbenchmarks/contradictions/run.py, results atbenchmarks/contradictions/RESULTS.md. Headline: 93.5% overall accuracy, 100% onkeep_higher_confidenceandkeep_most_sources, with documented honest weaknesses on tie-handling and small confidence gaps. Re-run withpython benchmarks/contradictions/run.py. CI workflow guards regressions.
What's new in v0.7.3
world-model demo-- one command to see every primitive working. Initializes the knowledge graph, seeds reproducible demo data viascripts/demo_seed.py, then exercises each primitive (PreToolUse enforcement, contradiction detection, PostCompact injection, audit log) with real outputs. New users can see the value without writing any code.Opt-in telemetry -- off by default, prompted once during
world-model setup, inspectable withworld-model telemetry --status, disabled withworld-model telemetry --disable. No file paths, no code, no identifiers tied to a person. See Privacy and Security for the exact payload.pi adapter -- new
adapters/pi/package. world-model-mcp now plugs into earendil-works/pi via pi's extension API (tool_call-> PreToolUse,context-> auto-injection,session_compact-> audit log). Install withworld-model install-pi.
What v0.7.0 introduced (still active)
PostCompact / UserPromptSubmit auto-injection -- when the agent's context is compacted, the hook automatically splices the top constraints and recent canonical facts back into the next turn. Configurable, fails open.
deferenforcement tier -- PreToolUse now classifies recurring warning-level violations asdefer, which pauses headless agents (with graceful fallback toaskon older clients) instead of either hard-denying or silently passing through.Confidence-weighted contradiction resolution -- the new
resolve_contradictiontool picks a winner usingkeep_higher_confidence,keep_most_recent,keep_most_sources, orauto. The loser is marked superseded.Compaction audit log -- every PostCompact event writes a row with pre/post token counts and what was re-injected. Query with the
audit-compactionsCLI or export to JSONL.Cursor adapter -- harness-neutral hooks under
adapters/cursor/. Same Python helpers, different manifest format.Streamable HTTP transport (v0.7.2) --
WORLD_MODEL_TRANSPORT=httpso the same 25 MCP tools work behind an MCP tunnel for Claude Managed Agents with self-hosted sandboxes. See docs/deployment/mcp-tunnel.md.
Quick Start
Option 1: Desktop Extension (one-click for Claude Desktop)
Download the latest .mcpb from Releases and drag it into Claude Desktop. Auto-installs hooks, MCP server config, and dependencies.
Option 2: pip install (Claude Code CLI / IDE plugins)
# 1. Install the package
pip install world-model-mcp
# 2. Setup in your project (auto-seeds the knowledge graph from existing code)
cd /path/to/your/project
python -m world_model_server.cli setup
# 3. Restart Claude Code
# Done! The world model is pre-populated and activeYou can also re-seed or seed manually at any time:
# Seed from existing codebase
world-model seed
# Re-seed with force (re-processes already seeded files)
world-model seed --forceOption 3: HTTP transport for remote / MCP-tunnel deployment
For Claude Managed Agents with self-hosted sandboxes, or any deployment where the MCP server lives behind a firewall and the agent reaches it from Anthropic-side infrastructure, run world-model-mcp in HTTP mode.
pip install 'world-model-mcp[http]'
export WORLD_MODEL_TRANSPORT=http
export WORLD_MODEL_HTTP_PORT=8765
python -m world_model_server.serverOr use the bundled image:
docker compose up -d # Dockerfile.http + persistent volume
curl http://127.0.0.1:8765/healthz # {"status":"ok","version":"0.7.2"}Full walkthrough including Anthropic MCP tunnels setup: docs/deployment/mcp-tunnel.md.
Stdio remains the default transport for Claude Code, Cursor, and .mcpb
installs. Nothing changes for those flows.
Option 4: Run the guided demo (no Claude Code required)
To see every primitive working with real outputs from a real SQLite database before committing to a full install:
pip install world-model-mcp
cd /tmp/wm-test && mkdir -p wm-test && cd wm-test
world-model demoThe demo initializes a knowledge graph, seeds reproducible data, and exercises PreToolUse enforcement, contradiction detection, the PostCompact injection bundle, and the compaction audit log -- with the actual JSON outputs. Re-runs are idempotent.
Option 5: Run inside pi (experimental)
For users of earendil-works/pi:
pip install world-model-mcp # the Python helpers
world-model install-pi # writes adapters/world-model-pi/
pi install local:./adapters/world-model-piThe pi adapter wires the same hook_helper and inject_helper you'd use from Claude Code into pi's tool_call, context, and session_compact events. See adapters/pi/README.md.
Option 6: Run inside Codex CLI (experimental)
For users of OpenAI's Codex CLI:
pip install world-model-mcp # the Python helpers
python -m world_model_server.cli install-codex
# (appends [mcp_servers.world_model] + hook blocks to ~/.codex/config.toml)
# Restart codex; verify with: codex mcp list--dry-run prints what would be appended without writing; --force re-appends even if the adapter marker is already present. The bundled snippet uses world_model (underscore) as the MCP server name to dodge Codex's silent hyphen-strip in its tool-name sanitizer. Hook output is camelCase with deny_unknown_fields compliance against Codex's strict Rust schema; the contract is locked down by tests in tests/test_v075_features.py. See adapters/codex/README.md.
Option 7: Run inside OpenClaw (experimental, v0.10)
For users of OpenClaw, the local-first personal AI assistant that routes across WhatsApp, Telegram, Slack, and Discord:
pip install world-model-mcp
python -m world_model_server.cli setup
python -m world_model_server.cli install-openclaw
# Verify: openclaw mcp probe world-model (should report 27 tools)install-openclaw merges an mcp.servers.world-model entry into ~/.openclaw/openclaw.json while preserving all other keys in the config file. It defaults the command field to sys.executable (absolute path to the interpreter running the CLI) — necessary because OpenClaw's process spawn does not inherit shell PATH; a bare python3 fails probe with MCP error -32000: Connection closed. Flags: --force (overwrite existing entry), --dry-run (print without writing), --python <abs-path> (override interpreter), --db-path <path> (override WORLD_MODEL_DB_PATH, default .claude/world-model). Relative --python values are rejected as a hard error.
Pure additive integration — OpenClaw ships no native memory layer, so all 27 world-model tools become available to OpenClaw agent turns without capability overlap. Verified end-to-end against OpenClaw 2026.6.11 (e085fa1) on macOS on 2026-07-01. MCP-registration only in v0.10; a TypeScript plugin bundle for typed lifecycle hooks (before_prompt_build, before_tool_call, before_compaction, session_start, ...) is on the v0.10.x roadmap. See adapters/openclaw/README.md.
Option 8: Run inside Hermes Agent (experimental, v0.10)
For users of NousResearch's Hermes Agent:
pip install "world-model-mcp[hermes]" # the [hermes] extra pulls ruamel.yaml
python -m world_model_server.cli setup
python -m world_model_server.cli install-hermes
# From inside a Hermes session: /reload-mcp (loads the new server without restarting)install-hermes merges an mcp_servers.world-model block into ~/.hermes/config.yaml while preserving all other keys — including every comment and blank line in Hermes' heavily-commented 1327-line reference config, via ruamel.yaml round-trip mode. Defaults the command field to sys.executable (absolute path). Flags: --force, --dry-run, --python <abs-path>, --db-path <path>. Relative --python values are rejected as a hard error.
Hermes ships its own bounded memory system (MEMORY.md + USER.md, character-capped, no auto-decay per Hermes docs). world-model-mcp adds the temporal fact graph with per-fact provenance, per-evidence-type decay, and confidence-weighted contradiction resolution on top — additive, not overlapping. The overlap with the exclusive MemoryProvider plugin slot (currently held by ClawMem for many users) is documented in adapters/hermes/README.md. Verified end-to-end against Hermes v0.17.0 (2026.6.19) on macOS: hermes mcp test world-model reports 27 tools. MCP-registration is the v0.10 track; a native MemoryProvider plugin is on the v0.10+ roadmap and ships only if MCP-route adoption warrants.
Option 9: Run inside Continue (experimental, v0.10)
For users of Continue, the OSS coding-agent extension for VS Code and JetBrains (largest OSS coding-agent extension not tied to a platform vendor — reprioritized after the SpaceX/Cursor acquisition):
pip install world-model-mcp
python -m world_model_server.cli setup
python -m world_model_server.cli install-continue
# Reload the Continue extension. In agent mode, world-model tools appear under the "world-model" server.install-continue writes a standalone <project>/.continue/mcpServers/world-model.yaml following Continue's per-server-file pattern. No config merge is needed because Continue's own docs use one YAML per MCP server in that directory. Defaults the command field to sys.executable (absolute path); rejects relative --python overrides. Flags: --force, --dry-run, --project-dir <path>, --python <abs-path>, --db-path <path>. Continue watches .continue/mcpServers/ in newer builds, so auto-discovery should pick up the new server; if not, reload the extension. MCP tools are available only in Continue's agent mode. See adapters/continue/README.md.
What Gets Installed
your-project/
├── .mcp.json # MCP server configuration
├── .claude/
│ ├── settings.json # Hook configuration
│ ├── hooks/ # Compiled TypeScript hooks
│ └── world-model/ # SQLite databases (~155 KB)Features
1. Hallucination Prevention
Before:
// Claude invents an API that doesn't exist
const user = await User.findByEmail(email); // This method doesn't existAfter:
// Claude checks the world model first
const user = await User.findOne({ email }); // Verified to existGoal: Reduce non-existent API references by validating against the knowledge graph
2. Learning from Corrections
Session 1: User corrects Claude
// Claude writes:
console.log('debug info');
// User corrects to:
logger.debug('debug info');
// World model learns: "Use logger.debug() not console.log()"Session 2: Claude uses the learned pattern
// Claude automatically writes:
logger.debug('debug info'); // No correction neededGoal: Learned patterns persist across sessions and prevent repeat violations
3. Regression Prevention
// Week 1: Bug fixed (null check added)
if (user && user.email) { ... }
// Week 2: Refactoring
// World model warns: "This line preserves a critical bug fix"
// Claude preserves the null check
// Result: Bug not re-introducedGoal: Detect potential regressions before code execution
How It Works
Architecture
┌──────────────────────────────────────────────────────────┐
│ Claude Code + Hooks │
│ Captures: file edits, tool calls, user corrections │
└──────────────────────────────────────────────────────────┘
|
v
┌──────────────────────────────────────────────────────────┐
│ MCP Server (Python) │
│ - 22 MCP tools for querying/recording/predicting │
│ - LLM-powered entity extraction (Claude Haiku) │
│ - External linter integration (ESLint, Pylint, Ruff) │
└──────────────────────────────────────────────────────────┘
|
v
┌──────────────────────────────────────────────────────────┐
│ Knowledge Graph (SQLite + FTS5) │
│ - entities.db: APIs, functions, classes │
│ - facts.db: Temporal assertions with evidence │
│ - relationships.db: Entity dependency graph │
│ - constraints.db: Learned rules from corrections │
│ - sessions.db: Session history and outcomes │
│ - events.db: Activity log with reasoning chains │
└──────────────────────────────────────────────────────────┘Key Concepts
Temporal Facts: Every fact has
validAtandinvalidAttimestamps"Function X existed from 2024-01-15 to 2024-03-20"
Query: "What was true on March 1st?"
Evidence Chains: Every assertion traces back to source
Fact -> Session -> Event -> Source Code Location
Constraint Learning: Pattern recognition from user corrections
Automatic rule type inference (linting, architecture, testing)
Severity detection (error, warning, info)
Example generation for future reference
Dual Validation: Combines two validation sources
World model constraints (learned from user)
External linters (ESLint, Pylint, Ruff)
MCP Tools
Twenty-two MCP tools available to Claude Code:
1. query_fact
Check if APIs/functions exist before using them
result = query_fact(
query="Does User.findByEmail exist?",
entity_type="function"
)
# Returns: {exists: bool, confidence: float, facts: [...]}2. record_event
Capture development activity with reasoning chains
record_event(
event_type="file_edit",
file_path="src/api/auth.ts",
reasoning="Added JWT authentication middleware"
)3. validate_change
Pre-execution validation against constraints and linters
result = validate_change(
file_path="src/api/auth.ts",
proposed_content="..."
)
# Returns: {safe: bool, violations: [...], suggestions: [...]}4. get_constraints
Retrieve project-specific rules for a file
constraints = get_constraints(
file_path="src/**/*.ts",
constraint_types=["linting", "architecture"]
)5. record_correction
Learn from user edits (HIGH PRIORITY)
record_correction(
claude_action={...},
user_correction={...},
reasoning="Use logger.debug instead of console.log"
)6. get_related_bugs
Regression risk assessment
result = get_related_bugs(
file_path="src/api/auth.ts",
change_description="refactoring authentication logic"
)
# Returns: {bugs: [...], risk_score: float, critical_regions: [...]}7. seed_project
Scan the codebase and populate the knowledge graph with entities and relationships
result = seed_project(
project_dir=".",
force=False
)
# Returns: {files_seeded: int, entities_created: int, relationships_created: int}8. ingest_pr_reviews
Pull GitHub PR review comments and convert team feedback into constraints
result = ingest_pr_reviews(
repo="owner/repo", # Auto-detected from git remote if omitted
count=10
)
# Returns: {prs_scanned: int, constraints_created: int, constraints_updated: int}Documentation
QUICKSTART.md - 5-minute setup guide
CONTRIBUTING.md - Contribution guidelines
RELEASE_NOTES.md - Version history and features
Testing
# Run tests
pytest
# With coverage
pytest --cov=world_model_server --cov-report=html186 tests covering knowledge graph CRUD, FTS5 search, constraint management, bug tracking, auto-seeding, PR review ingestion, decision traces, outcome linkage, trajectory learning, prediction layer, memory health, contradiction detection, transcript pointers, project identity, and PreToolUse enforcement. See tests/ for details.
Configuration
Environment Variables
# Database location (default: ./.claude/world-model/)
export WORLD_MODEL_DB_PATH="/custom/path"
# Anthropic API key (optional - enables LLM extraction)
# IMPORTANT: Never commit this! Use .env file (see .env.example)
export ANTHROPIC_API_KEY="your-api-key-here"
# Model selection
export WORLD_MODEL_EXTRACTION_MODEL="claude-3-haiku-20240307" # Fast
export WORLD_MODEL_REASONING_MODEL="claude-3-5-sonnet-20241022" # Accurate
# Debug mode
export WORLD_MODEL_DEBUG=1Note: Create a .env file in your project root (see .env.example) - it's automatically ignored by git.
Customizing Hooks
Edit .claude/settings.json to customize which tools trigger world model hooks:
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write|Bash",
"hooks": [...]
}]
}
}Language Support
Currently Supported:
TypeScript / JavaScript
Python
Coming Soon:
Go, Rust, Java, C++
Extensible Architecture: Easy to add new language parsers (see CONTRIBUTING.md)
Privacy and Security
Local-First: All knowledge graph data stays on your machine.
Optional LLM: Works without API key (uses regex patterns as fallback).
Encrypted Storage: SQLite databases are local files (encrypt your disk for security).
Telemetry (opt-in, off by default)
v0.7.3 added anonymous usage telemetry. It is:
Off by default. You have to explicitly opt in.
Asked once during
world-model setup, with a cleary/Nprompt.Inspectable:
world-model telemetry --statusshows the exact JSON payload that would be sent.Disable any time with
world-model telemetry --disable, or globally withWORLD_MODEL_TELEMETRY_DISABLE=1.Skipped in non-TTY environments (CI, scripts) so it never blocks an automated setup.
What we send (only if you opt in):
Field | Example | Why |
|
| Which lifecycle step ran |
|
| Which release you're on |
| random UUID at | Distinguish installs without identifying users |
| unix timestamp | When the event fired |
What we never send: file paths, file contents, rule names, hostnames, IP addresses, API keys, decision-trace text, fact text, or anything else that could identify a person or leak business logic. The full payload schema lives in world_model_server/telemetry.py.
Where it goes: opt-in events are posted to a dedicated private GitHub repo (SaravananJaichandar/world-model-telemetry) as plain issues. There is no third-party analytics service, no cookie, no fingerprint. The PAT embedded in the client is scoped to that one repo with Issues: write only.
API Key Usage (only if you provide ANTHROPIC_API_KEY)
Entity extraction from code changes
Constraint inference from corrections
Never sends: Credentials, secrets, PII
Security Best Practices
Never commit
.envfilesUse
.env.exampleas templateStore API keys in environment variables or
.envfiles onlyThe
.gitignoreautomatically excludes sensitive files
Roadmap
v0.2.x
Auto-seeding: knowledge graph populates from existing codebase on setup
PR Review Intelligence: ingest GitHub review comments as constraints
Relationship tracking: import and dependency graph between entities
Multi-language support: Python, TypeScript/JavaScript, Solidity, Go, Rust
CLI query command for knowledge graph lookups
40 tests, 8 MCP tools
v0.3.0
Module-level matching: query by module name finds the file and its contents
Incremental re-seeding: only re-process files changed since last seed
Fuzzy entity matching: approximate name search for typos and abbreviations
Query caching: in-memory cache with TTL for repeated lookups
Java support: complete multi-language coverage
MCP server pipeline validation on real projects
v0.4.0
Outcome linkage: test failures linked to code changes with facts
Trajectory learning: co-edit patterns tracked across sessions
Decision trace capture: structured log of agent proposals and human corrections
Cross-project entity search with project registry
5 new MCP tools (13 total), 104 tests
v0.5.0
Regression prediction, "what if" simulation, test failure prediction
Multi-project knowledge transfer, memory health, fact TTL/decay
get_context_for_action pre-edit bundle, constraint violation tracking, find_contradictions
20 MCP tools, 151 tests
v0.6.0 — Enforcement, Provenance, Identity
PreToolUse constraint enforcement hook: deny hard violations at the edit boundary
Indexed transcript pointers: hydrate any fact back to source conversation
Project identity decoupling: stable UUID across directory renames
Content-hash deduplication for facts and constraints
Auto-generate CLAUDE.md from the knowledge graph
BetaAbstractMemoryTool subclass for Anthropic SDK integration
Desktop Extension (.mcpb) packaging for Claude Desktop
22 MCP tools, 13 CLI subcommands, 186 tests
v0.7.0 — Auto-injection, defer tier, contradiction resolution, harness adapters
PostCompact and UserPromptSubmit auto-injection: re-emit top constraints and recent facts after context loss
deferenforcement tier in PreToolUse: pause headless agents on recurring warning-level violations, with graceful fallback toaskConfidence-weighted contradiction resolution: pick a winner using confidence, recency, or source count, with an
autostrategyCompaction audit log: query and export what was remembered across each compaction boundary
Cursor adapter package
25 MCP tools, 14 CLI subcommands, 220 tests
v0.7.2 — Streamable HTTP transport
HTTP transport mode for remote / MCP-tunnel deployment
/healthz endpoint, Dockerfile.http, docker-compose.yml
docs/deployment/mcp-tunnel.md walkthrough for Claude Managed Agents
236 tests
v0.7.3 — Onboarding, telemetry, pi adapter
world-model demoguided tour for first-time usersOpt-in anonymous telemetry, off by default, inspectable
pi-package adapter (
adapters/pi/,install-piCLI)17 CLI subcommands, 256 tests
v0.7.4 (Current) — Interop, deployment, benchmark
AGENTS.md /
.agents/skills/constraint reader (new MCP tool:get_agents_md_constraints)Self-hosted Claude Managed Agents deployment guide + Modal quickstart
Reproducible contradiction-resolution benchmark (24-pair dataset, CI workflow, RESULTS.md)
26 MCP tools, 17 CLI subcommands, 283 tests
v0.7.5
Codex CLI adapter (
install-codex, shipped 2026-06-05)
v0.7.6
In-agent
/world-modelslash command (read-only: status, contradictions, recent, help)world-model status-watchTUI status widget
v0.8.0
Decay + provenance schema:
source_tool,confirmer,last_decay_atcolumns on facts. Per-evidence-type TTL with domain-aware half-lives (source_code 365d, test 180d, session 14d, user_correction 730d, bug_fix 365d).Slash command write operations (
/world-model resolve <id>,/world-model forget <id>).resolve_contradictionacceptsconfirmerto stamp the winning fact as settled.
v0.8.1
Expanded contradiction-resolution benchmark: 24 → 105 pairs across 19 categories, including 6 new categories that test the v0.8.0 schema (decay, provenance, confirmer).
Honest per-strategy + per-category RESULTS.md with the v0.7.4 number preserved as baseline.
v0.9 (Shipped 2026-06-24) — Repeat-mistake benchmark on SWE-bench Verified
Pre-registered SWE-bench Verified benchmark. The empirical test of the central wedge: does the learning loop measurably reduce repeated agent mistakes on a public task corpus? Methodology locked in
benchmarks/repeat-mistake/DESIGN.mdon 2026-06-17, a week before the benchmark ran. Pre-registered hypothesis, interpretation thresholds, judge prompts, and SWE-bench Pro 7-category failure taxonomy. No goalpost-moving.Result: +10.2 pts combined paired delta across 49 SWE-bench Verified instances (baseline 33/49 = 67.3% → treatment 38/49 = 77.6%). Within-domain delta +15.0 pts on django + sympy. Cross-domain delta +6.9 pts on matplotlib + scikit-learn + sphinx with zero observed regressions on 18 baseline passes. 6 FAIL-to-PASS flips, 1 regression. Full per-task tables, mechanistic analysis of the cross-domain flips, and seven explicit limitations in
benchmarks/repeat-mistake/RESULTS.md.Pre-registered paper preprint with DOI: 10.5281/zenodo.20834508. CC-BY 4.0. PDF and markdown source at
benchmarks/repeat-mistake/paper.pdf/paper.md.Constraint extraction pipeline grounded in the SWE-bench Pro 7-category failure taxonomy (arXiv:2509.16941). Locked classifier and extractor prompts in
failure_classifier.pyandlearning_hook.py.All raw artifacts committed (per-task progress, predictions, scores, classifications, constraints, harness reports) so the benchmark is reproducible from a fresh checkout.
v0.9.1 patch: restored embedded telemetry token after a release-mechanics miss in v0.9.0 (no methodology change; benchmark numbers unchanged).
v0.9.2 (Shipped 2026-06-30) — Multi-seed replication appendix
Pre-registered 17-instance multi-seed test per
benchmarks/repeat-mistake/SEED_PLAN.md(locked 2026-06-25). Outcome: load-bearing replication 0 of 7; mean paired delta across two seeds is +0.24 per instance, bootstrap 95 percent CI [0.00, 0.47]. The v0.9 +10.2 pts headline was substantially attributable to an unlucky baseline draw. Honest update published per the pre-registered acceptance criteria. Appendix inRESULTS.mdandpaper.md. Zenodo record updated to version 2.
v0.10 (Shipped 2026-07-01) — Three new adapters
OpenClaw adapter (MCP registration) +
install-openclawCLI. Registers world-model-mcp as an MCP server inside OpenClaw viapython -m world_model_server.cli install-openclaw. Pure additive since OpenClaw ships no native memory layer. Verified end-to-end against OpenClaw2026.6.11 (e085fa1)on macOS on 2026-07-01:openclaw mcp probe world-modelreports 27 tools discovered. Seeadapters/openclaw/.Hermes Agent adapter (MCP registration) +
install-hermesCLI. Registers world-model-mcp as an external MCP server inside Hermes Agent. Usesruamel.yamlround-trip mode to preserve every comment and blank line in the 1327-line referenceconfig.yaml. Verified end-to-end against Hermes Agentv0.17.0 (2026.6.19)on macOS on 2026-07-01:hermes mcp test world-modelreports 27 tools discovered. Seeadapters/hermes/.Continue adapter (MCP registration) +
install-continueCLI. Registers world-model-mcp as an MCP tool source inside Continue (VS Code + JetBrains). CLI-side E2E verified: the exact stdio spawn Continue would perform returns 27 tools via a livetools/listroundtrip. Seeadapters/continue/.v0.10.1: fixed a stale Zenodo DOI reference (concept vs. version DOI) across README badge, roadmap link,
paper.md, andpaper.pdf. No code changes.
v0.11 (Shipped 2026-07-02) — Depth after breadth
Depth release. v0.10 expanded surface area to seven runtimes; v0.11 solves real problems for the users we now have. Two signals shaped it: Hermes #47349 (2026-07-01) surfaced the write-side routing gap (MCP surfaces tools but the agent still chooses the destination); and the auto strategy on the v0.8.1 contradiction-resolution benchmark still scored 77.1% because it did not fully consume the confirmer + decay-awareness fields shipped in v0.8.0.
v0.11.0 A:
autostrategy rewrite forresolve_contradiction. Folds inconfirmerawareness, per-evidence-type decay, distinct-source-tool counting, and tie-detection. Lifts the v0.8.1 contradiction-resolution benchmark'sautoscore from 77.1% to 100.0% on the same 105-pair × 19-category dataset. Overall benchmark accuracy across four canonical strategies + the decayed strategy rises from 78.2% to 83.7%. Seebenchmarks/contradictions-200/.v0.11.0 B: Hermes native
MemoryProviderplugin +install-hermes-providerCLI. Python plugin implementing Hermes'agent/memory_provider.pyABC (initialize,get_tool_schemas,handle_tool_call,get_config_schema,save_config). Intercepts writes at Hermes' routing layer rather than only surfacing tools — the architectural distinction MCP alone cannot close. Priority was bumped from "conditional on MCP adoption" after #47349 demonstrated real user demand for write-side interception. Ships asworld_model_server/hermes_memory_provider/in the wheel;install-hermes-providercopies the plugin into<hermes_home>/plugins/memory/world-model/. Seeadapters/hermes-memory-provider/.v0.11.1: Content-type routing schema field. Nullable
content_typeon the Fact model and the facts table, distinguishingrule(always-inject),fact(search-on-demand), andprocedure(multi-step workflow). Additive-only migration; existing rows keep NULL and continue to work. Enables the v0.11.0 B MemoryProvider (and future providers) to route writes intelligently instead of dumping everything into one store. Sourced from Hermes #47349 architectural framing.v0.11.2: Dogfooding case study. Publishes what the fact graph actually captured about the world-model-mcp codebase in
.claude/world-model/: 3 learned constraints with real violation counts (including two release-mechanics rules that map directly to the v0.9.1 telemetry-token miss and the v0.10.1 tagging lesson), 1 bug_fix reflection, 608 facts, 600 entities. Honest about what was NOT captured (empty events / decisions / sessions tables). Reproducibility contract:python scripts/dogfooding_snapshot.pyregenerates the committed JSON byte-for-byte. Seecase-studies/v011-dogfooding/.
v0.12 (Shipped 2026-07-06 / 2026-07-07) — Breadth + depth + adversarial verification
Nine substantive changes in the v0.12.0 umbrella release plus the v0.12.12 adversarial-verification follow-up. Two roadmap items (v0.12.8 OpenClaw TS plugin, v0.12.10 Antigravity CLI adapter) deferred per their roadmap-gated conditionals.
v0.12.1:
world-model doctorcommand. Eight diagnostic checks,--json,--fix. Sourced directly from the v0.11.2 dogfooding trace.v0.12.2:
influence_state+expires_atschema additions. Storage-vs-planning-influence separation + hard drop-dead expiry, both additive nullable fields.v0.12.3: universal content-type routing consumers. Closes the write- and consumer-side loop opened by v0.11.1.
create_factpersistscontent_type;query_factsaccepts acontent_typefilter;get_injection_contextsplits rules / facts / procedures into three routed pools.v0.12.4: GitHub Copilot Chat adapter (
install-copilot). Merges into.vscode/mcp.jsonwith careful handling of the"servers"vs"mcpServers"divergence unique to Copilot Chat.v0.12.5:
install-continue --globalconfig-merge path. ruamel.yaml round-trip preserves comments in~/.continue/config.yaml.v0.12.6: Cline adapter (
install-cline). Merges into~/.cline/mcp.json.v0.12.7: Windsurf adapter (
install-windsurf). Merges into~/.codeium/windsurf/mcp_config.json.v0.12.9: Hermes lifecycle hooks. Five optional hooks (
sync_turn,on_pre_compress,prefetch,on_session_end,on_memory_write) on top of the v0.11.0 MemoryProvider ABC.v0.12.11: MCP 2026-07-28 spec readiness scaffolding. Non-behavior-changing observability + public audit; five-row
READINESS_STATEmatrix locked and tested.v0.12.12: Coach-Player adversarial verification.
verify_retrievalMCP tool + isolated Coach implementation + 12-pair hand-labeled benchmark. Pattern ported from the maintainer's earliery=cproject.v0.12.8: OpenClaw TypeScript plugin bundle — DEFERRED. Roadmap-gated on adoption signal; no explicit user ask within five days of v0.10.
v0.12.10: Antigravity CLI adapter — DEFERRED. SDK still lacks
TransformCompactionHookthrough v1.0.16.
v0.13+ (Backlog)
Near-term:
Copilot CLI Windows shim in doctor (v0.12.13 candidate). Extend
doctor --fixto detect Copilot-target runtimes and rewrite unwrapped hook commands tobash -c '...'shape withcwd-from-stdin fallback. Sourced from copilot-cli #4001.Expand Coach-Player benchmark to ≥30 pairs. Once labeled set grows, the 95% hallucination-catch floor becomes enforceable (currently aspirational at N=12).
answer_with_verificationend-to-end wrapper tool. Combinesquery_fact→ synthesize →verify_retrievalinto a single MCP call for callers who want the whole pipeline in one shot.
Medium-term — waits for signal:
Citation polarity on retrieved facts (
supporting/refuting/neutral). Requires retrieval caller to know intent, which the schema layer doesn't control. Revisit when a specific integrator commits to instrumenting the annotation.OpenClaw TypeScript plugin bundle — moved from v0.12.8 to medium-term. Revisit when adoption signal warrants a TypeScript surface.
Antigravity CLI adapter. Blocked pending
TransformCompactionHookin the SDK. Unblocks whenever the SDK ships it.Full 2026-07-28 MCP spec compliance — HTTP header emission (
Mcp-Method,Mcp-Name),server/discover,InputRequiredResult. v0.12.11 shipped the observability scaffolding; full compliance lands after the final spec ships on 2026-07-28.
Long-term — v1.0 territory, expensive:
Full-corpus multi-seed replication of the SWE-bench Verified benchmark: all 49 paired instances at 3-5 seeds each. The v0.9.2 update covers a 17-instance subset only. Cost is ~60 hours agent time; the honest bounds from v0.9.2 are already published, so the marginal empirical gain is smaller than the operational cost. Save for a v1.0 push.
Head-to-head benchmarks against other memory layers (mem0, Letta, Zep, piia-engram, ClawMem). Competitive-positioning value only; do it once, and only once the differentiators are stable enough that the head-to-head numbers are worth locking in.
Explicit failure-mode-similarity scoring to predict when cross-domain transfer will succeed. Research-heavy; needs the multi-seed data as a precondition.
Larger task counts per repo; broader corpus coverage beyond the 50-task subset.
Contributing
Contributions are welcome. See CONTRIBUTING.md for:
Development setup
Coding standards
Adding language support
Writing tests
Submitting PRs
Areas where help is needed:
Language parsers (Go, Rust, Java, C++)
Performance optimization
Documentation improvements
Real-world testing feedback
Stats
Project Size:
~4,800 lines of code
13 Python modules
3 TypeScript hook implementations
Storage Efficiency:
Empty database: ~155 KB
Per entity: ~500 bytes
Per fact: ~800 bytes
License
MIT License - Free for commercial and personal use
Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/SaravananJaichandar/world-model-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server