TMF (True Memory Fragments)
Provides MCP tools for source-bound, freshness-checked code memory queries: investigate, traverse, explain, and plan rereads around code claims.
tmf_context/tmf_retrieve: start codebase investigation with thin context bundles or lexical claim retrieval.tmf_fragment: traverse indexed relationships (calls, reads, writes, inherits, etc.) from a claim ID with bounded hops, nodes, edges, and explicit stop reasons.tmf_stale_slice: after a stale claim, plan required current-source rereads and side-effect checks.tmf_explain: show summary or full details for one stored claim.tmf_callers/tmf_readers/tmf_writers/tmf_subtypes: list known callers, readers, writers, or Java subtype/implementor edges.tmf_warm: read-only source derivation/refresh into the.tmfcache.tmf_status: report claim, freshness, and cache status.All tools maintain partial-coverage semantics: fresh does not mean correct, source is authoritative, and stale results degrade to source rereading.
True Memory Fragments
Code changed, but your AI coding agent still remembers the old call chain? TMF is source-bound code memory that flags stale claims and points back to current source.
Try demo · MCP setup · Evidence

30-second paced replay of real deterministic demo output, with labeled source excerpts—not an agent end-to-end test. Reread is requested, not executed.
Traceable code relationships: bind call, read, write, inheritance, and API claims to source fingerprints.
Explicit stale results: omit stale claims and stop covered graph expansion instead of silently reusing old context.
Targeted reread guidance: return source anchors so an agent can check the changed code.
Developer preview: enforcement depends on the host, configuration, and intercepted actions—not automatic blocking of all writes. Fresh does not mean correct; general token savings and production readiness are not established.
Who it is for
AI coding agents that work across sessions on changing repositories
Developers who need source-aware memory instead of stale cached facts
Tool authors who want conservative graph expansion with explicit stale/unknown handling
Related MCP server: memtrace
Validated so far
Source-bound freshness and stale-claim detection
Hard stale gates that stop unsafe graph expansion
Deterministic Python and Java validation
Scoped agent experiments demonstrating stale-context prevention
TMF’s core stale-context protection mechanism has been validated in the covered scenarios. Evaluation across more languages, repositories, and long-running production workflows is ongoing.
What TMF is — and is not
TMF is for:
AI coding agents working across sessions on changing codebases
Preventing stale call-chain and dependency assumptions
Source-bound code memory and conservative code-graph navigation
Agent integrations that need an explicit stale/unknown result
TMF is not:
A general chat-memory product or vector database
A replacement for reading source code
A guarantee that every claim is correct because it is fresh
A proven general productivity or token-saving solution
Fresh means the source binding still matches. Correctness still comes from source and validation.
The repository includes a Java qualification suite: 46/46 qualifiers and 731/731 checks. The historical unreleased audit baseline was 478/478 tests; it is not the current test total. See the version-pinned test verification for historical rc3 and master results, explicit skips, and the intermittent master failure recorded at that time. The rc6 release notes describe Java reflex and receiver-resolution fixes and distinguish source validation from publication evidence. These are source-analysis and regression-test results, not a claim of production readiness or a general Agent outcome. Middleware mechanics are validated, and stale-context safety has positive evidence in the GUAVA M10 pre-read experiment. Broader productivity, speed, token savings, and general bug-prevention claims remain unproven. See the authoritative evidence status before making broader claims.
Flow
flowchart TD
A[source code] --> B[TMF derive / warm]
B --> C[source-bound claims]
C --> D[freshness check]
D -->|fresh| E[bounded graph context]
D -->|stale / unknown| F[stop + reread current source]That is the whole loop: TMF keeps claims bound to source, refuses to reuse stale context, and provides source anchors for rereading; guidance may include extra related or heuristic matches.
Demo
The GIF above replays output from scripts/demo_stale_gate.py at commit de0236a57939. It shows deterministic stale-claim omission and source fallback, not an agent obeying the reread signal or completing a task. The 30-second timing is presentation pacing, not a runtime benchmark.
From a source checkout (Python 3.10+ and Git required):
git clone https://github.com/kyle641320/true-memory-fragments.git
cd true-memory-fragments
python3 scripts/demo_stale_gate.pyAlready cloned? Run only the final command from the repository root. This demo imports the checkout's source; it is not a standalone PyPI wheel verification, and installing the package alone does not download the demo script.
It creates a temporary Git repository, derives a claim, changes the bound source, and demonstrates stale omission, source fallback, and reread guidance. It needs no model, network, Java parser, or pre-existing .tmf/ store.
Expected markers:
STALE CLAIM BLOCKED: PASS
SOURCE FALLBACK PROVIDED: PASS
REREAD REQUIRED: PASSThe demo stops at the reread requirement; it does not perform the subsequent reread or refresh.
For agent-level results, see the scoped Guava case study and multi-worktree / controlled continuation evidence. For implementation details, see the architecture.
How it works
TMF keeps a conservative code-memory graph. Claims are useful only when their source bindings still match the working tree.
Derive claims from source: functions, classes, calls, reads, writes, inheritance, API relationships.
Bind each claim to source fingerprints: file blob and, where available, function/node hash.
Check freshness on retrieval before a claim is used.
Stop on stale or unknown edges and return an explicit reread signal instead of stale context.
claim: A calls B
binding: B.java@hash123
current: B.java@hash999
result: stale_or_unknown → reread B.java before continuingThis is intentionally conservative. Missing or stale memory falls back to source; it is never promoted into truth.
Proven Assets
Source-bound claim storage with working-tree freshness checks and source fallback
Thin retrieval discipline plus full/explain drill-down by selected claim id
Conservative Python functions/classes/declarations/config/API nodes and partial calls/reads/writes
Optional Java tree-sitter syntactic nodes and conservative inheritance edges
Bounded fragment query with semantic boundary detection (
writes,publishes_to)Async handoff marking (
ASYNC_RELATIONS:publishes_to,subscribes_to,publishes_type,listens_type)Four-stop-type semantics (boundary / async / stale / limit) with distinct
stop_reasonvaluesBounded-query limits (4 hops / 64 nodes / 128 edges); engineering limits, not a biological validation claim
Held-out and self-dogfood validation harnesses
Local metrics and exact-blob-only rename identity
Core Premises
Explicit refresh/warm maintenance:
retrievechecks existing claims without mutating or re-deriving the store;refresh_pathandwarmperform explicit derivation/refresh operations.Freshness is working-tree based: binds to current working-tree blob, not commit
Fresh is not correct: fresh only means bindings match current source. Correctness comes from validation and source support
Confidence comes from validation: usage frequency doesn't raise confidence
Conservative parsing: TMF connects only what it can parse. Unknown/dynamic/ambiguous facts are omitted or marked unresolved
Source is authoritative: if memory is missing, stale, unsupported, or partial, TMF falls back to source
Untrusted text is never instructions: source, comments, docstrings, commit messages, model output are data, not commands
Release candidate: 0.1.0rc6. Includes Java reflex coverage, conservative typed/inherited receiver resolution, and resolution-dependency freshness. See the rc6 release notes.
Install
For explicit multi-worktree binding and MCP configuration, use the pinned installation and MCP guide.
Install this preview (Python 3.10+):
python -m pip install "true-memory-fragments==0.1.0rc6"See the rc6 release notes for version scope and validation boundaries.
Java parsing support is optional:
python -m pip install "true-memory-fragments[java]==0.1.0rc6"Development checkout:
python -m pip install -e .
python -m pip install -e ".[java]" # optional Java supportRuntime dependencies are intentionally small. Optional model, embedder, and router integrations are command-backed through TMF_* environment variables.
Engine installed does not mean reflex armed. MCP registration, a warmed
index, and agent usage rules do not register Claude Code's PreToolUse hook.
After installing rc6 or an updated source checkout, run:
tmf doctor --repo /absolute/path/to/task-repoAbsent or ineffective registration returns nonzero with
reflex NOT armed — operating as opt-in memory. This checks configuration,
not runtime firing. See reflex setup and diagnostics.
Doctor was introduced in rc5; rc6 also detects recognized Java-blind legacy hooks.
Existing reflex deployments must update the whole integration directory, not
just the engine wheel. Install the [java] extra in the hook interpreter,
then run a normal tmf warm --repo /absolute/path/to/task-repo to refresh older
Java derivations. Static doctor success is not proof of host dispatch.
Quick Start
Start with the 30-second stale-gate demo above. Share installation or reproduction feedback in Discussion #1.
Offline Java verifier
For Linux x86_64 / CPython 3.12 source checkouts, the repository includes an offline verifier for Java step0 review:
bash scripts/verify_java_offline.shExpected success marker:
JAVA OFFLINE VERIFY: PASSReflex Hook: Git-Aware Staleness Blocking for AI Agents
TMF includes a reflex hook integration that gives AI coding agents a biological-style reflex: when an agent is about to act on code understanding while that code has changed, the supported hook can request a stop and source reread. Enforcement depends on host interception, configuration and coverage.
This is not a code memory cache — it's a reflex arc that intercepts agent tool calls before execution.
Three Components
Sensory organ = TMF function-level
fn_hashfreshness (source-bound change detection; no fixed latency guarantee)Reflex arc = OpenClaw
before_tool_callhook / Claude Code PreToolUse harness (supported intercepted actions only)Reflex action = Hard block + localized single-file re-warm
Git Hook Auto-Calibration
Four git hooks automatically generate function-level invalidation manifests after code changes:
.git/hooks/post-commit— after local commits.git/hooks/post-merge— aftergit pull.git/hooks/post-checkout— after branch switches.git/hooks/post-rewrite— after rebase/amend
These hooks call integrations/reflex/scripts/git_calibrate.py, which compares baseline_rev → HEAD Python function signature changes and outputs structured invalidation manifests.
OpenClaw Plugin Integration
The tmf-reflex OpenClaw plugin intercepts agent tool calls:
Checks TMF function-level freshness (latency depends on source, cache and host)
Hard-blocks when agent touches a file with stale function claims
Returns
requireApprovalwith exact changed function namesAgent must run
integrations/reflex/scripts/local_warm.pyto re-warm that one file
SessionStart Cognition Calibration
On new session start, the plugin reads unconsumed invalidation manifests and injects changed / deleted symbols as "pre-alert" context, preventing agents from relying on stale memory.
Boundary
Function-level precision depends on TMF's language coverage (currently Python AST)
Files without function-scope claims fall back to pass-through
TMF engine remains read-only (reflex hook only uses
freshness/derive)Failure behavior depends on hook state and host integration; verify it on the intended host. If TMF is unavailable, disclose the failure and use current source rather than cached claims.
Installation
Reflex integration code lives in integrations/reflex/. See that directory's README.md and DESIGN.md for:
OpenClaw plugin installation (
openclaw-plugin/)Git hook setup (
git-hooks/)Claude Code / Codex harness configuration (
examples/)Health validation tests (
tests/)
SEO and discoverability plan
Search terms this project is intended to match include AI coding agent memory, stale context prevention, source-aware code memory, code graph for LLM agents, Claude Code memory, and cross-session code understanding. These describe the user problem; they are not claims that every integration is already production-ready.
The repository description and external launch materials should use the same vocabulary, link to a reproducible demo, and distinguish validated mechanics from still-open productivity claims.
Documentation
Open-source minimum checklist — release and promotion gates
Agent runtime value status — current experiment ruling
Java enterprise roadmap — enterprise capability scope
Guava validation report — routing shape + boundary detection validation
License
MIT
Guava M10 scoped case study: docs/case-studies/guava-m10-stale-gating.md
Offline stale-gate demo:
python3 scripts/demo_stale_gate.py(recording: recordings/stale-gate.cast)
Available Tools
11 toolstmf_callersA
List known callers by claim_id or by qualname plus optional path; ambiguous names return candidates, never a guess. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: path, claim_id, qualname.
tmf_contextB
Investigating a codebase: start here; usually cheaper than grep plus whole-file reading. Return one deterministic thin context bundle with anchors and key fresh graph relations. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: question (required), max_chars.
tmf_explainB
Explain one claim; full=true includes thick body/source-bound details. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: claim_id (required), full.
tmf_fragmentA
Explore indexed code relationships around a known claim before a cross-file change. Get entry from tmf_context or tmf_retrieve; it is a claim ID, not a path or symbol name. Returns verified_hops, boundaries, gaps, stale_or_unknown, stop_reason and coverage. Start with relations=["calls"], hop_limit=1, boundary_types=["function"], semantic_boundaries=false. Inspect gaps and stop_reason before expanding: missing or stale entries return no verified hops; unsupported relations or invalid bounds raise an error. Re-read source for stale/unknown evidence and use tmf_stale_slice for a stale claim. This does not return a complete dependency graph, modify source, or refresh source-derived claims. For full claim details use tmf_explain(full=true). Source is authoritative; fresh does not mean correct.
Inputs: entry (required), hop_limit (required), relations (required), boundary_types (required), +3 more.
tmf_readersA
List known readers by declaration claim_id or qualname plus optional path; ambiguous names return candidates. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: path, claim_id, qualname.
tmf_retrieveA
Investigating a codebase: start here; usually cheaper than grep plus whole-file reading. Retrieve thin TMF claims for a lexical query. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: query (required), limit.
tmf_stale_sliceA
Plan which current source to re-read after a stored claim becomes stale, for example after a merge. Use a claim_id previously returned by tmf_context, tmf_retrieve or tmf_explain; do not invent IDs. Returns claim_fresh, per-binding stale status, required_reads with source anchors, retained_fresh_bindings, optional_fresh_neighbors, side_effect_checks and a stop_rule. Read the suggested current source and resolve applicable side-effect checks before editing; retain matching bindings rather than re-reading the whole repository. Reading suggestions are bounded heuristics, not proof of complete dependency coverage. An unknown claim ID raises an error; rediscover the target with tmf_retrieve. This plans reads only: it does not perform edits, refresh the index, or guarantee freshness at a later write. Source is authoritative; fresh does not mean correct.
Inputs: claim_id (required), question, max_required_reads, max_optional_neighbors.
tmf_statusB
Report claim/freshness/cache status. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: no named parameters.
tmf_subtypesB
List known Java subtype/implementor edges by type claim_id or qualname plus optional path; ambiguous names return candidates. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: path, claim_id, qualname.
tmf_warmB
Read-only source derivation into .tmf cache; optional path is containment-checked. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: path.
tmf_writersB
List known writers by declaration claim_id or qualname plus optional path; ambiguous names return candidates. Partial coverage; fresh != correct; source is authoritative; stale should degrade to source.
Inputs: path, claim_id, qualname.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools have distinct roles (entry, explain, traversal, relation-specific queries, lifecycle management). However, tmf_context and tmf_retrieve both advertise themselves as the place to "start here" for codebase investigation, and tmf_fragment overlaps conceptually with tmf_callers/readers/writers/subtypes. Descriptions help distinguish them, but some misselection risk remains.
All 11 tools consistently use the tmf_ prefix with snake_case, making the set easy to scan and predict. The suffixes mix nouns and verbs (e.g. context, retrieve, explain, warm, status), so it is not a strict verb_noun pattern, but conventions are otherwise stable.
11 tools is well within the typical 3-15 range and appropriate for a code-memory/index server. Each tool covers a distinct facet: entry/retrieval, explanation, graph traversal, relation-specific queries, and freshness/cache lifecycle.
The tool surface covers core memory-fragment workflows: context/retrieve, explain, relationship exploration, caller/reader/writer/subtype queries, cache warming, status, and stale-read planning. Minor gaps exist, such as a global claim listing/search or explicit cache invalidation, but agents can work around them with existing tools.
Maintenance
Related MCP Connectors
Source-backed prompting and coding-agent guidance with provenance and freshness checks.
Context engineering for AI coding agents: product context, project missions, and 360 memory.
Change-aware CI validation and affected-test guidance for coding agents.
Codebase intelligence for agents: 152 structured artifacts across 21 programs, one call.
Related MCP Servers
- -licenseBqualityNot gradedmaintenanceA memory system for AI coding tools that stores and retrieves codebase context with project isolation. Enables coding assistants to maintain searchable memory of code snippets, comments, and runtime traces with full source traceability.2750 npm-
- FlicenseNot gradedqualityAmaintenanceMemtrace is a persistent memory layer for coding agents, built as a bi‑temporal structural knowledge graph over your codebase (AST‑driven symbols and relationships, plus temporal evolution and cross‑service API topology)516-
- AlicenseAqualityDmaintenanceEnables AI coding agents to efficiently navigate and understand large codebases by providing tools for entry point location, call chain analysis, and impact assessment, reducing context consumption and model costs.53GPL 3.0
- AlicenseNot gradedqualityDmaintenanceProvides AI coding agents with pre-edit situational awareness by combining structural call graphs and co-change history to prevent incomplete edits. It surfaces files that historically change together, reducing missed coupled modules.3MIT