Skip to content

Memory wiki: durable knowledge vault with provenance and Obsidian-friendly export #3329

Description

@houko

Problem

librefang-memory is a SQLite + vector substrate. It is good at "find me the K nearest snippets to this query", weak at "give me a navigable, durable knowledge base I can also open in Obsidian and edit by hand."

Long-running agents accumulate facts (project conventions, people, recurring decisions, how systems are wired). Today these facts live as opaque memory rows that only the agent can introspect. The user cannot:

  • See what the agent thinks it knows.
  • Edit / correct a wrong fact directly.
  • Carry the knowledge to another tool (Obsidian, Logseq, plain markdown viewer).
  • See provenance — when did the agent learn this, from which conversation, on whose claim.

Reference: openclaw

extensions/memory-wiki is a persistent wiki compiler that produces:

  • A markdown vault at ~/.openclaw/wiki/<vault> with deterministic indexes (index.md, per-topic pages, backlinks).
  • Provenance metadata on every claim (source conversation, source turn, source channel, capture timestamp).
  • Optional Obsidian-friendly render mode (vault structure, frontmatter, [[wiki-link]] syntax) vs native mode (plain markdown, no Obsidian assumptions).
  • Three modes:
    • isolated (default): own vault, own ingest, no dependency on the active-memory plugin.
    • bridge: reads public artifacts from memory-core through documented seams.
    • unsafe-local: explicit same-machine escape hatch for private local paths (e.g. point at an existing Obsidian vault).

When active-memory exposes shared recall, agents can memory_search with corpus=all to span both stores in one pass, then fall back to wiki_search / wiki_get for wiki-specific ranking and provenance.

Proposed approach

  1. New crate librefang-memory-wiki (or a feature-gated module under librefang-memory).

  2. Compiler pipeline:

    • Subscribe to memory events (memory_store writes that pass a "durable" filter — ignore ephemeral session scratch).
    • Group by topic (LLM-assisted topic extraction in a follow-up; v1 can use explicit topic tags).
    • Render to <vault>/<topic>.md with frontmatter (provenance, created, updated, claims: []).
    • Maintain index.md and a _meta/backlinks.json deterministically.
  3. Tools:

    • wiki_get(topic) — return the rendered page.
    • wiki_search(query) — full-text + vector hybrid over the vault.
    • wiki_write(topic, body, provenance) — controlled write with the same prompt-injection scan as skills.
    • memory_search(corpus = "all" | "kv" | "wiki") — extend existing recall to span both.
  4. Config:

    [memory_wiki]
    enabled = false                            # default off
    mode = "isolated"                          # isolated | bridge | unsafe_local
    vault_path = "~/.librefang/wiki/main"
    render_mode = "native"                     # native | obsidian
    ingest_filter = "tagged"                   # tagged | all
  5. Backups / hand-edit safety:

    • Never overwrite a page whose mtime is newer than the last compiler run without prompting.
    • Compiler reads back hand-edits before re-rendering so user edits survive.

Acceptance criteria

  • Crate scaffold + enabled = false default, no behavior change for existing users.
  • isolated mode end-to-end: an agent calls wiki_write, the page lands at <vault>/<topic>.md, wiki_get returns it, wiki_search finds it.
  • Provenance frontmatter populated on every write.
  • Hand-edit detection: edit a page externally, run the compiler, verify the edit is preserved.
  • obsidian render mode produces [[wiki-link]] syntax and parses cleanly in Obsidian.
  • Documented as off by default in the changelog with a "how to enable" runbook.
  • Integration test: 5 memory_store calls with topic tags produce 5 wiki pages with correct backlinks.

This is a P2 / longer-horizon feature. Skill workshop (#3328) and the prompt-build hook (#3326) should land first; this benefits from both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/memorySQLite memory substratedifficulty/hard1 day+, requires understanding multiple cratesenhancementNew feature or requestfeature-parityPorted from OpenFanghas-prA pull request has been linked to this issueneeds-rfcRequires an RFC before implementationseverity/mediumBug or limitation with workaround / partial impact

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions