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
- Graph analysis runs community detection, centrality, and bridge detection over the workspace’s association graph (see Graph Analysis).
- 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 thanMEMORYLAYER_KB_MIN_COMMUNITY_SIZE(default 2) are skipped. Without an LLM, a deterministic fallback summary is used. - Entity articles. For each god node, up to
max_god_nodes, the generator writes an entity deep-dive. - 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. - 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 & Path | Description |
|---|---|
POST /v1/knowledgebase/generate | Generate or refresh the KB |
GET /v1/knowledgebase | KB metadata (404 until the first generation) |
GET /v1/knowledgebase/articles | List 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/export | Download a zip vault: index.md, communities/*.md, entities/*.md |
GET /v1/knowledgebase/graph | The 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
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}'| Field | Default | Description |
|---|---|---|
workspace_id / context_id | caller’s | Scope of the generated KB |
max_communities | 50 | Community articles to write (1–500) |
max_god_nodes | 20 | Entity articles to write (0–200) |
include_rpg | false | Include Repository Planning Graph code nodes |
regenerate | false | Ignore the watermark and cached articles and rebuild everything |
background | false | Queue 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:
| Key | Meaning |
|---|---|
coverage_ratio | Share of graph memories that made it into at least one article |
coverage_covered / coverage_graph_nodes / coverage_uncovered | The underlying counts |
coverage_dropped_small_communities | Memories dropped because their community was below the minimum size |
coverage_dropped_capped_communities | Memories 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:
| Field | Meaning |
|---|---|
confidence | Mean importance of member memories |
tags | Up to 12 tags |
source_count, sources | Source documents behind the members (up to 8 IDs) |
contradicted_by | How many members are in an unresolved contradiction |
Configuration
| Env var | Default | Description |
|---|---|---|
MEMORYLAYER_KB_MIN_COMMUNITY_SIZE | 2 | Smallest community that gets an article |
MEMORYLAYER_KB_COMMUNITY_MAX_MEMBERS | 40 | Members passed to a summary |
MEMORYLAYER_KB_SUMMARY_BUDGET_CHARS | 10000 | Character budget for a summary’s member context |
MEMORYLAYER_KB_SUMMARY_MAX_TOKENS | 8192 | Token cap for one summary call |
MEMORYLAYER_KB_COMMUNITY_MATCH_THRESHOLD | 0.5 | How closely a new community must match an old one to reuse its article |
MEMORYLAYER_KB_GRAPH_DENSIFY_ENABLED | false | Add similarity edges before community detection (tuned with the MEMORYLAYER_KB_DENSIFY_* settings; preview with POST /v1/graph/densify-preview) |