RFC(memory): transform Evolve to .md-first procedural memory system (moat = trajectory-mined guidelines)
Summary
Proposing a transformation of Evolve from its current vector-DB-centric architecture (Milvus/pgvector + opaque indexes) to an .md-first agentic memory system, with asymmetric investment: deep architectural work on the guidelines track (our differentiator), and commodity treatment of the facts track (table stakes that every memory system already does).
๐ Full proposal: design_doc/transform_evolve.md (566 lines โ prior-art survey, paradigm comparison, phased roadmap, retrieval flow + outcome-signal strategy + OpenClaw pattern absorption, ~25 open questions). Permalink at commit 12a3f8b: stable link.
Adjacent prior thinking: #256 (dreaming / offline consolidation) is in the same conceptual neighborhood.
Why now
- Opaque storage. Memories live in proprietary vector indexes. Humans can't read, diff, edit, PR-review, or roll back.
- Operational burden. Milvus/pgvector are infrastructure we maintain.
- Industry drift. Claude Code (CLAUDE.md + auto memory), OpenAI Codex memories, MemU (~13kโ
), Memsearch, OpenClaw โ all have moved toward
.md-first designs. We're fighting the grain. - MemU and OpenClaw specifically validate the market thesis. MemU has ~13kโ and 92.09% on Locomo; OpenClaw is production-grade with a sophisticated promotion-gate pipeline. We need to ship.
The moat thesis (the keystone โ needs team agreement)
Evolve's differentiator is the guidelines track, not the facts track.
- Facts are commodity. Mem0, Zep, Letta, Codex memories, Claude auto memory, MemU, OpenClaw all do declarative knowledge well.
- Guidelines are uniquely Evolve. We mine procedural rules from agent trajectories with outcome context: "in situation X, calling tool A then tool B succeeded; A alone failed." The output is
trigger+implementation_steps+category(strategy/recovery/optimization) โ how to do things, learned from what worked and what didn't. No surveyed competitor produces this at trajectory-mining depth.
If the team agrees: asymmetric investment is justified โ guidelines deserve architectural depth; facts can be minimum-viable.
If the team disagrees: the recommendation below changes substantially. This is the first decision to make.
Recommended direction
Both tracks land on .md files as source of truth (no shadow content vector index). Vector infra retired. Seven moat-specific features on the guidelines track:
- Trigger-keyed directory layout.
guidelines/{namespace}/{category}/{trigger-slug}.mdโ the filesystem is the lookup index. NOT the recognition index โ see (5). - Authority split โ
authoritative/(team-curated, PR-reviewed) vsgenerated/(extraction-pipeline output). Single tier on facts. - Outcome metadata as a first-class field โ signal-source-aware, confidence-weighted. Six signal sources including OpenClaw-borrowed implicit usage signals (recall frequency, query diversity).
unknownis first-class. Cold-start handled via category-based priors. Full schema in ยง7.1.1. - Situational linking (A-MEM-inspired). Generated guidelines link to situationally adjacent ones via YAML frontmatter โ solves trigger-slug collisions without forcing a brittle canonical normalizer.
- Trigger-only embedding index (Day-1 critical). Tiny embedding index over
trigger + category + short description(~3โ12 MB total, ~10โ50ร smaller than Paradigm B's "embed every chunk of every fact") makes recognition tractable. MemU-style dual mode: cheap embedding kNN for hot-path; LLM-as-router fallback for high-stakes calls. - Proactive sidecar (MemU-inspired).
EvolveWatchersubscribes to Phoenix spans live, surfaces relevant guidelines mid-session as triggering situations unfold. - Pre-compaction extraction flush (OpenClaw-inspired). When a host (Claude Code, Codex) signals impending context compaction, Evolve runs a silent extraction turn before trajectory detail collapses into a generic summary. Each plugin needs a small hook for the compaction signal.
Canonical injection flow (three steps): recognize (feature 5 โ embedding kNN over triggers) โ lookup (feature 1 โ filesystem path resolution) โ rank (feature 3 โ outcome-weighted score). Each step has a different cost profile and a different acceleration structure.
Facts get pure files + categorization-and-grep retrieval. Add a shadow vector index later only if telemetry justifies it.
Phased roadmap (high level)
| Phase | Goal | Duration |
|---|---|---|
| 0 | Lock the moat thesis + outcome-metadata schema (no code) | 3โ5 days |
| 1 | New MarkdownEntityBackend with shadow writes (DB still source of truth) |
2โ3 weeks |
| 2 | Outcome metadata + guideline extraction upgrade + telemetry (incl. implicit usage signals) | 2โ3 weeks |
| 3 | Cutover: read from MD, retire Milvus/pgvector; trigger-only embedding index live | 2โ3 weeks |
| 4 | Authority split for guidelines + promotion workflow + pre-compaction flush hooks | 2โ4 weeks |
| 5 | Situational linking + proactive sidecar (EvolveWatcher) |
2โ4 weeks |
Total: ~3โ4 months of focused work.
Decisions needed from the team
Please weigh in on:
- Moat thesis โ do you agree guidelines (not facts) is the differentiator? Keystone โ everything else depends on this.
- Authority split โ adopt
authoritative/vsgenerated/on the guidelines track? - Outcome-metadata schema โ concrete fields proposal in ยง7.1.1; needs sign-off before Phase 1.
- Episodic vs procedural naming โ guidelines as
trigger+implementation_steps+categorylook more procedural (CoALA's third type) than episodic. - Benchmark commitment โ adopt Locomo as table-stakes, design a procedural-task benchmark for our differentiator?
BaseEntityBackendfuture โ keep unified facade or fork persistence per track?- Recognition strategy โ pure embedding kNN, LLM-as-router, or MemU-style dual mode?
- Pre-compaction flush โ which plugins (Claude/Codex/Bob/Claw) ship with the hook in Phase 4?
Honest open questions / risks
BaseEntityBackendis type-agnostic today; this proposal forks it.- Conflict resolution must split per track (the guideline-side merger needs to reason about outcome evidence).
- Migration plan needs sequencing detail โ OpenClaw's
rem-backfill --stage-short-term --rollbackis a concrete template (ยง8.4). - Telemetry gap: we lack data on which guidelines/facts are actually retrieved and used. Phase 2 closes this and feeds the implicit-usage-signal layer.
- Failure modes per paradigm need explicit handling (file watcher dies, LLM rewrites garbage, multi-worker write races).
- Cold-start ranking for newly-extracted guidelines with zero observations โ see ยง7.1.1.
- Temporal validity / contradiction tracking โ OpenClaw's
memory-wikiplugin is existence proof this is implementable on plain MD.
Full open-questions section in the doc covers ~25+ specific questions across architecture, extraction, retrieval, ops, and strategy.
Asks
- ๐ Read the doc at the link above.
- โ Push back on the moat thesis if you disagree โ that's the decision that matters most.
- ๐ฌ Comment on the schema proposal (ยง7.1, ยง7.1.1) so we can lock it before any code is written.
Update โ RFC sharpened on two pillars (commit eb50680)
Two questions from review surfaced real holes in the original framing. Both are now addressed in the doc; issue body above has been updated to reflect them.
1. Recognition vs lookup โ the trigger-only embedding index is Day-1, not deferred
Original framing said "filesystem IS the trigger index." That's only half right. The filesystem hierarchy handles lookup (trigger-slug โ guideline file, O(1)) but it doesn't handle recognition (free-form task description โ which triggers apply?). For the realistic injection case where the agent sends "user is retrying a failed payment" rather than auth_failed_401, recognition is the actually-hard part.
Fix: a tiny embedding index over trigger + category + short description only โ not over guideline content. Sizing: ~500โ2000 entries ร 1536 dims โ 3โ12 MB, in-memory or SQLite-VSS, ~10โ50ร smaller than Paradigm B's "embed every chunk of every fact." This preserves the radical-simplification message on facts while answering the realistic injection question honestly.
The canonical injection flow is now three steps:
task description
โ STEP 1: RECOGNITION (embedding kNN over triggers โ feature 5)
โ STEP 2: LOOKUP (filesystem path resolution โ feature 1)
โ STEP 3: RANK (outcome-weighted score โ feature 3)
โ top-K injected
Each step has a different cost profile and a different acceleration structure.
2. Outcome signals are rarely binary โ outcome_evidence schema rewritten
Original framing used naive success_count / failure_count. That implied binary ground truth most trajectories don't have. New ยง7.1.1 covers:
- Five signal sources ranked by confidence ร coverage ร cost: explicit feedback (very high / low / free), tool errors (high / med-high / free), trajectory shape (med / high / free), reply patterns (med / med / cheap-LLM), LLM-judge (med-low / 100% / expensive).
unknownas first-class state โ a guideline withunknown=50, failures=0is unmeasured, not fine; very different fromfailures=10.- Confidence-weighted scoring, not raw counts.
- Cold-start priors by category: recovery starts at 0.5, strategy at 0.6, LLM-extracted at 0.4 โ refines as observations accumulate.
- Phase 2 build order: tool-signals โ shape-patterns โ reply-patterns โ LLM-judge โ explicit feedback. Coverage projection after first two alone: 50โ70% of trajectories have some signal.
What didn't change
The recommendation is intact โ Paradigm A for guidelines, Paradigm A for facts, vector infra retired, asymmetric investment per ยง1.1 moat thesis. The two updates make the design more honest about how it actually works, not different in spirit.
Update โ OpenClaw patterns absorbed (commit 12a3f8b)
Reviewed OpenClaw memory โ production-grade .md-first system with several patterns directly applicable here. Three concrete additions:
1. New signal source: implicit usage signals (ยง7.1.1, sixth row)
OpenClaw promotes guidelines from short-term to durable storage based on recall frequency ร query diversity ร retrieval-then-no-correction patterns โ not explicit outcome tagging. These are zero-cost (free byproduct of retrieval telemetry we already need for ยง8.3) and complementary to explicit outcome signals: a guideline can be frequently retrieved + correlated with success (high explicit + high implicit), frequently retrieved but never followed by success (high implicit / low explicit โ guideline is wrong but situationally salient), or rarely retrieved despite explicit success (low implicit โ trigger-recognition step is failing). Three different patterns, three different fixes.
This adds depth to the moat without new infrastructure.
2. New feature: pre-compaction extraction flush (ยง7.1 feature 7)
Long agent sessions trigger context compaction. Without explicit handling, valuable trajectory detail collapses into a generic summary before Evolve's extraction pipeline ever sees it. OpenClaw runs a silent turn before compaction reminding the agent to save important state. Adapted for Evolve: when a plugin (Claude Code / Codex / Bob / Claw) signals impending compaction, request a silent extraction turn โ Evolve runs targeted fact/guideline extraction over the recent trajectory window before it gets blurred.
This is a hot-path safeguard sitting alongside the proactive sidecar (feature 6). Roadmap: Phase 4, since both touch plugin contracts.
3. Validations & references
- Disk-as-truth principle ("the model only 'remembers' what gets saved to disk") โ strong philosophical alignment, cited in ยง3.6.
- Pluggable indexing backends (SQLite/QMD/Honcho/LanceDB over plain MD) โ validates our SQLite-VSS choice for the trigger-only embedding index.
memory-wikiplugin with contradiction tracking + freshness tracking โ existence proof that the temporal-validity question (ยง8.1) is implementable on plain MD without inheriting graph-DB infra.- Grounded backfill with
rem-backfill --stage-short-term+--rollbackโ concrete template for our migration plan (ยง8.4).
What didn't change
The recommendation is intact โ Paradigm A for guidelines, Paradigm A for facts, vector infra retired, asymmetric investment per ยง1.1 moat thesis. OpenClaw's memories are user-facts/preferences/observations free-form; not trajectory-mined procedural rules. Our moat still holds, and we picked up valuable patterns without compromising it.
Doc is now 566 lines.
Update โ Implementation plan approved + landed (commit `b96f3f4`)
The full Paradigm-A implementation plan is now in `design_doc/implementation_plan.md` (632 lines).
Three rounds of adversarial Codex review were applied during plan-mode:
| Round | Findings addressed |
|---|---|
| 1 | Hybrid recognition (vs trigger-only); telemetry hot-path isolation; ULID stable-id filenames |
| 2 | Phase 4 stable-id consistency; post-cutover rollback freshness; RRF instead of alpha-blend; durable metrics for gates; derived-state index recovery |
| 3 | Storage-diagram contract leak; namespace high-watermark manifest; durable outbox for legacy dual-write; unit-weight RRF |
Twelve findings total. Each one is tagged in the plan's risks table (ยง13) with its mitigation. Mechanical invariants where possible (e.g. `md_high_watermark == applied_namespace_generation`, `legacy_rollback_safe == True`) โ not aspirational tests.
Next: starting Phase 0 (schema lock + spike, 3โ5 days, no production code).
Update โ Phase 0 complete (commit `5aeeb58`)
Schema lock + typed backend spike landed. All pre-commit hooks (mypy, ruff, secrets, large-file) passed; 31 new tests + 243 existing tests green.
Delivered:
- `altk_evolve/schema/outcome_evidence.py` โ Pydantic models for the moat feature: 6 signal sources, 3-valued OutcomeKind, AggregatedOutcome with bucketed counters, category-based cold-start priors.
- `altk_evolve/schema/guidelines.py` โ extended with optional `outcome_evidence` and `related` fields. Backwards-compatible.
- `design_doc/markdown_schema.md` โ locked frontmatter contract. Filename = ULID stable_id for ALL phases (closes Codex rounds 1โ3 slug-collision findings). Authority + category encoded in path; identity stays in filename.
- `altk_evolve/config/markdown.py` + `altk_evolve/backend/markdown.py` โ typed skeleton conforming to `BaseEntityBackend`. All 12 abstract methods stubbed with NotImplementedError pointing at Phase 1.
- 14 + 17 = 31 unit tests covering schema validation, cold-start priors, serialization round-trip, abstract contract conformance, settings type rejection.
Deferred to team kick-off: the ยง6 decision log (moat thesis, authority split, recognition strategy, benchmark commitment, BaseEntityBackend future, compaction-flush plugin ownership) โ those are team decisions, not unilateral encodings.
Next: starting Phase 1 โ MarkdownEntityBackend real implementation with shadow-write (~2โ3 weeks of work, multi-commit).
Update โ Phase 1 substrate complete
The MarkdownEntityBackend substrate is functionally landed. All commits on `file-based-memory`:
| Commit | Scope |
|---|---|
| `1ae61cf` | YAML frontmatter serialization + ULID generator (32 tests) |
| `a4284a7` | MarkdownEntityBackend full implementation (37 tests) |
| `5678265` | EvolveClient factory + EvolveConfig.backend = "markdown" (8 tests) |
| `3d58db6` | DualWriteBackend shadow-write wrapper (10 tests) |
| `07696e6` | evolve backend dual-write-verify CLI (6 tests) |
Test posture:
- 93 net new tests across Phase 1
- 319 unit tests pass total (no regressions)
- mypy, ruff check, ruff format, large-file, secret detection โ all green pre-commit
What's working end-to-end:
- `EVOLVE_BACKEND=markdown` selects the new backend
- One file per entity at `{data_dir}/{type}/{namespace}/{ULID}.md` with YAML frontmatter
- Atomic writes (temp + os.replace), per-namespace fcntl.flock + threading.RLock
- `_active_data` pattern: search-during-update sees uncommitted writes (matches filesystem.py)
- Conflict resolution integration via inherited `update_entities` template method
- `EVOLVE_BACKEND_SHADOW=filesystem` (or any other backend) enables dual-write; primary failure propagates, shadow failure is logged + counted, never blocks
- `evolve backend dual-write-verify
` reports drift via content-signature comparison (not ID, since backends assign IDs independently)
Phase 1 exit criteria status:
- โ All 12 `BaseEntityBackend` abstract methods implemented and tested
- โ Shadow-write wrapper with best-effort failure handling
- โ `dual-write-verify` CLI command operational
- โณ Full Phoenix sync E2E (LLM-bound; deferred to manual-run or separate CI lane)
- โณ 7-day nightly drift-check in dev environment (operations work, scheduled for after team kickoff)
Next: ready to start Phase 2 (outcome metadata + extraction pipeline upgrade + telemetry), pending team review of the substrate. The ยง6 decision-log questions from `transform_evolve.md` are still open and should be answered before Phase 2's per-track conflict-resolution split goes in.