feat(memory): add Klide-owned recall engine foundation - #68
Open
pierreprudh wants to merge 3 commits into
Open
Conversation
Make Klide the owner of durable Project Memory instead of introducing another memory provider. Version reviewed entries with knowledge kinds, typed source references, review state, tags, and supersession while preserving legacy Markdown compatibility. Add deterministic workspace-local search and safe entry reads as native memory_search and memory_read Harness tools. Give recall its own ReadProjectMemory capability so Transcript evidence preserves the knowledge boundary and returned provenance. Publish Draft 2020-12 entry/tool schemas, architecture and lifecycle documentation, an incremental MCP adapter roadmap, and two accessible website-ready SVG diagrams. Validated with 615 Rust tests, 810 frontend tests, a production build, JSON Schema example validation, XML validation, and diff whitespace checks.
- Worktree runs hop to the main checkout: .klide/memory is git-ignored and never copied into a linked worktree, so isolated Race/Task/Mission runs recalled an empty store. All memory commands and tools now resolve the store through the worktree's .git file back to the project that owns it. - Supersession is enforced, not just recorded: memory_write demotes the target entry's reviewState in place (surgical frontmatter edit, no re-render), and search also honors supersedes pointers from any entry. - Frontmatter injection closed: supersedes must be a valid memory id, and every free-string frontmatter value is stripped of control characters so renderer/model input can't forge the Rust-stamped reviewState. - Search is Unicode-aware: accented characters are term characters and fold with full to_lowercase, so French queries and content match. - Tool metadata no longer stamps absolute local paths into the durable Transcript; relPath identifies entries. - Unknown reviewState/kind values fail closed to stale; a non-integer schemaVersion counts as future; future entries surface as inert stale stubs instead of being silently skipped. - memory_read gates on review state: inactive entries require includeInactive and return behind a historical-evidence marker. - Read paths never create .klide/memory (Plan mode stays read-only); only memory_write does. - Legacy localStorage drafts are backfilled with the new MemoryInput fields on load. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pierreprudh
force-pushed
the
codex/memory-engine-foundation
branch
from
September 1, 2026 09:46
b5e4b0c to
0d65be4
Compare
The start-stage foot bar carried the same cycling policy note as a live conversation, but before a run exists there is nothing for a standing note to report on — it just crowded the one line of intent. Move it into the + menu as rows (shown only when the run will actually be a Goal), so the bar reads "+ · provider · model" and the note reappears in AiPanel's foot bar once the first message lands. GoalPolicyChoice gains a description clause so the rows and the note share one text source. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Klide already captures Runs, Transcripts, handoffs, and Skills, but agents had no native way to recall reviewed knowledge during a later Run. This PR makes Klide the owner of that learning layer. It does not add a third-party memory provider: Markdown remains the local source of truth, Rust owns policy and retrieval, and the future MCP surface is only an adapter for Delegate CLIs.
What ships in this foundation
handoff; entries declaring a future schema are not misinterpreted as v1.memory_searchandmemory_readHarness Tools in Plan and Goal modes.ReadProjectMemory/read_project_memorycapability so Transcript evidence never mislabels recall as a Workspace-file or Conversation-history read.Architecture
The key boundary is ownership: Kit and Missions call the Rust domain directly. A later embedded MCP server will expose these same operations to Delegates; it will not own storage, ranking, review state, or authorization.
Review lifecycle
A model can propose learning, but a draft is not durable Project Memory. Crossing
memory_writeis the acceptance boundary and Rust stamps the resultreviewed. Normal recall hides stale and superseded entries while retaining them as inspectable evidence.Schema changes
schemaVersion1; future versions are never parsed as v1kindrun,handoff,decision,convention,fact,failure, orpatternreviewStateproposed,reviewed,superseded, orstaletagssourceRefssupersedesnullMachine-readable contracts:
schemas/klide-memory-entry.schema.jsonschemas/klide-memory-tools.schema.jsonKLIDE_MEMORY_SCHEMA.mdRetrieval contract
memory_searchaccepts a query, optional kind filters, a 1–20 result cap, and an explicit inactive-memory flag. Results contain a stable id, deterministic score, matched fields, bounded excerpt, parsed entry, and provenance.memory_readresolves that id through the Workspace boundary and returns authoritative Markdown plus structured metadata.This PR intentionally does not auto-inject memory into prompts. Recall is an explicit Tool call, so its trigger, match reason, content, and evidence remain inspectable while the ranking and UX are proven.
Security and trust properties
.klide/memory/.Validation
cargo test --manifest-path src-tauri/Cargo.toml --no-fail-fast— 615 passednpm test— 62 files / 810 tests passednpm run build— production TypeScript/Vite build passedxmllint --nooutpassed for both SVG assetsgit diff --checkpassedFollow-up slices
klide mcp memorystdio adapter over the same Rust engine, with Delegate registration and conformance tests.Full rationale and sequence:
MEMORY_ENGINE.md.Review hardening (second commit)
A full review of the foundation surfaced ten correctness/trust findings; all are fixed in
fix(memory): close the recall trust gaps from review, each behind a test.flowchart LR subgraph runs ["Any Run"] K["Kit run<br/>(main checkout)"] W["Isolated run<br/>(linked worktree)"] end W -- ".git file → hop to<br/>the main checkout" --> STORE K --> STORE subgraph STORE [".klide/memory — one durable store"] R["reviewed"] X["proposed · stale · superseded<br/>unknown values fail closed"] end MW["memory_write"] -- "validates supersedes id ·<br/>demotes target in place ·<br/>sanitizes frontmatter" --> STORE R --> T["memory_search / memory_read"] X -. "includeInactive only,<br/>marked historical evidence" .-> T T -- "metadata without<br/>absolute paths" --> TR["durable Transcript"].klide/memoryis git-ignored, never copied).gitfile to the main checkoutmemory_writedemotes the target'sreviewStatein place; search also honorssupersedespointersreviewStatesupersedesheld to the id charset; all free-string values stripped of control charactersto_lowercasefoldingpath;relPathidentifies entriesreviewState/kindfailed open toreviewedstaleschemaVersionbypassed the future-schema guard; future entries silently vanishedmemory_readhad no review-state gateincludeInactiveand return behind a[historical evidence]marker.klide/memoryas a side effect (Plan mode must not write)memory_writecreatesGates:
cargo test620 ✓ ·vitest810 ✓ ·npx tsc --noEmit✓