Skip to content

Knowledge Base

The knowledge base (KB) generator turns a workspace’s memory graph into a set of linked markdown articles:

  • one index article,
  • one community article per cluster of related memories, and
  • one entity article for each of the most-connected nodes (“god nodes”).

Articles cite the memories they summarize. You can read them through the API, browse them in a built-in HTML viewer, or export them as an Obsidian-compatible vault. The KB generator is part of core MemoryLayer.

How Generation Works

  1. Graph analysis runs community detection, centrality, and bridge detection over the workspace’s association graph (see Graph Analysis).
  2. Community articles. For each community, up to max_communities, the configured LLM writes a title and summary in one call from a bounded set of member memories. Summaries cite members with numbered references ([m1], [m2], …). Communities smaller than MEMORYLAYER_KB_MIN_COMMUNITY_SIZE (default 2) are skipped. Without an LLM, a deterministic fallback summary is used.
  3. Entity articles. For each god node, up to max_god_nodes, the generator writes an entity deep-dive.
  4. Rendering produces Obsidian-flavoured markdown with [[wikilinks]] between articles. Community articles include a mermaid topology diagram showing which clusters they bridge to. A diagram that fails validation is left out rather than rendered broken.
  5. Integrity checks. A citation lint and a link-integrity sweep record how well each article is grounded and how many links resolve.

Incremental Regeneration

Generation is incremental unless you pass regenerate: true:

  • If the workspace has not changed since the last successful run (its change watermark matches), the whole run is skipped.
  • New communities are matched to previous ones (MEMORYLAYER_KB_COMMUNITY_MATCH_THRESHOLD, default 0.5). Articles whose content hash has not changed are reused instead of being summarized again.
  • Articles that no longer correspond to anything are garbage-collected.

API

Method & PathDescription
POST /v1/knowledgebase/generateGenerate or refresh the KB
GET /v1/knowledgebaseKB metadata (404 until the first generation)
GET /v1/knowledgebase/articlesList articles (article_type = index, community, or entity; limit 100; offset)
GET /v1/knowledgebase/articles/{article_id}One article. IDs look like index, community-3, or entity-<slug>.
GET /v1/knowledgebase/exportDownload a zip vault: index.md, communities/*.md, entities/*.md
GET /v1/knowledgebase/graphThe cached graph analysis. include_central_nodes=false returns communities only.
GET /v1/knowledgebase/graph/communities/{community_id}One community
GET /kb/{workspace_id}A server-rendered HTML viewer for browsing articles (a development convenience)

Generation requires knowledgebase:write. The read endpoints require knowledgebase:read.

Generate Options

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/knowledgebase/generate" \
-H "Content-Type: application/json" \
-d '{"workspace_id": "my-project", "max_communities": 50, "max_god_nodes": 20}'
FieldDefaultDescription
workspace_id / context_idcaller’sScope of the generated KB
max_communities50Community articles to write (1–500)
max_god_nodes20Entity articles to write (0–200)
include_rpgfalseInclude Repository Planning Graph code nodes
regeneratefalseIgnore the watermark and cached articles and rebuild everything
backgroundfalseQueue a kb_update task and return the current metadata immediately

SDKs

kb = await client.kb.generate(max_communities=30, max_god_nodes=10)
articles = await client.kb.list_articles(article_type="community")
vault_zip = await client.kb.export_vault()
await client.kb.generate({ maxCommunities: 30 });
const vault = await client.kb.exportVault();

The Go SDK exposes the same surface as client.Kb (Generate, ListArticles, GetArticle, ExportVault, GetGraphAnalysis, GetCommunity). The SDKs do not expose the background flag.

Coverage and Grounding

A KB that covers a third of a workspace should not look the same as one that covers all of it. The Knowledgebase metadata and the index article therefore report corpus coverage:

KeyMeaning
coverage_ratioShare of graph memories that made it into at least one article
coverage_covered / coverage_graph_nodes / coverage_uncoveredThe underlying counts
coverage_dropped_small_communitiesMemories dropped because their community was below the minimum size
coverage_dropped_capped_communitiesMemories dropped by the max_communities cap

Each community article also records its citation coverage (the share of summary sentences that carry at least one citation), cited_member_count, and invalid_citation_count.

Open Knowledge Format Front Matter

Articles carry YAML front matter aligned with Open Knowledge Format (OKF) v0.1:

  • Index. okf_version: "0.1".
  • Community articles. type: community, title, description, timestamp, member_count, cohesion, citation_coverage.
  • Entity articles. type: entity, title, description, timestamp, connection_count.

When the data exists, community and entity articles also carry trust and provenance fields:

FieldMeaning
confidenceMean importance of member memories
tagsUp to 12 tags
source_count, sourcesSource documents behind the members (up to 8 IDs)
contradicted_byHow many members are in an unresolved contradiction

Configuration

Env varDefaultDescription
MEMORYLAYER_KB_MIN_COMMUNITY_SIZE2Smallest community that gets an article
MEMORYLAYER_KB_COMMUNITY_MAX_MEMBERS40Members passed to a summary
MEMORYLAYER_KB_SUMMARY_BUDGET_CHARS10000Character budget for a summary’s member context
MEMORYLAYER_KB_SUMMARY_MAX_TOKENS8192Token cap for one summary call
MEMORYLAYER_KB_COMMUNITY_MATCH_THRESHOLD0.5How closely a new community must match an old one to reuse its article
MEMORYLAYER_KB_GRAPH_DENSIFY_ENABLEDfalseAdd similarity edges before community detection (tuned with the MEMORYLAYER_KB_DENSIFY_* settings; preview with POST /v1/graph/densify-preview)