Knowledge Management & Wiki
Relevant source files
The following files were used as context for generating this wiki page:
The Knowledge Management System (KMS) and Wiki module provide a structured environment for curating domain-specific knowledge, independent of raw document ingestion. While standard RAG retrieves evidence from unstructured files, this system enables the creation of verified claims, entity relationships, and curated articles. These high-fidelity sources are integrated into the chat pipeline to provide structured, authoritative answers with explicit status and confidence tracking.
The system is split into two primary paradigms: the Wiki, which focuses on compiled knowledge with entities and cross-referenced claims, and the KMS, which provides user-curated documentation entries. Both subsystems support full-text search (FTS), versioning, and asynchronous compilation workflows triggered by document ingestion or manual promotion of user memories.
Sources: specs/wire-wiki-chat/SPEC.md:7-13, specs/kms-content-search-rag/SPEC.md:7-13
System Architecture & Data Flow
The Knowledge Management and Wiki systems operate through a multi-stage pipeline involving retrieval, compilation, and UI presentation.
Knowledge Retrieval Pipeline
During a chat interaction, the RAG engine prioritizes Wiki and KMS knowledge. The WikiRetrievalService performs FTS-based claim searches and predicate-aware relation lookups. If enabled, KMS entries are retrieved in parallel. This structured evidence is then formatted into a specialized context block for the LLM.
The diagram shows how the system routes queries through specialized retrieval services before falling back to raw document RAG.
Sources: specs/wire-wiki-chat/SPEC.md:120-132, specs/kms-content-search-rag/SPEC.md:65-80
Compilation Workflow
Knowledge is added to the system through "Compilation Jobs." These are enqueued by various triggers:
- Ingest: Automatically triggered when a new document is indexed.
- Query: On-the-fly compilation during chat.
- Manual: User-initiated promotion of a Memory or a manual recompile of a vault.
Sources: backend/app/services/wiki_store.py:101-114, backend/app/api/routes/wiki.py:730-745
Data Models
Wiki Schema
The Wiki system is built around four primary entities: Pages, Claims, Entities, and Relations.
| Entity | Description | Key Fields |
|---|---|---|
| WikiPage | The top-level container for a topic. | slug, title, page_type, markdown, status, version |
| WikiClaim | Discrete factual assertions extracted or manually added. | claim_text, subject, predicate, object, confidence, status |
| WikiEntity | Identified unique concepts or objects. | canonical_name, entity_type, aliases_json, description |
| WikiRelation | Predicate-aware links between entities. | subject_entity_id, predicate, object_entity_id, confidence |
Sources: backend/app/services/wiki_store.py:19-99, frontend/src/lib/api.ts:896-965
KMS Schema
The KMS focuses on documentation entries that can be linked to specific files or created manually.
| Field | Type | Description |
|---|---|---|
id | Integer | Unique identifier for the entry. |
vault_id | Integer | Scopes the entry to a specific vault. |
slug | String | URL-friendly unique identifier. |
title | String | Display title of the knowledge entry. |
body | String | The full content of the entry. |
status | Enum | draft, published, or archived. |
Sources: frontend/src/lib/api.ts:1120-1135, specs/kms-content-search-rag/SPEC.md:38-42
API Implementation
The backend provides vault-scoped REST endpoints for managing knowledge. All endpoints are protected by require_wiki_enabled or require_kms_enabled master switches.
Wiki Management Endpoints
Endpoints are defined in backend/app/api/routes/wiki.py and enforce vault-level read/write policies.
GET /wiki/pages: Lists wiki pages with optional filtering bypage_typeorstatus.POST /wiki/pages: Creates a new page. Automatically normalizes the slug from the title.PUT /wiki/pages/{page_id}: Updates a page. Implements Optimistic Locking using anexpected_versionparameter.GET /wiki/events: An SSE stream that emits events when wiki compile jobs reach a terminal state.
Sources: backend/app/api/routes/wiki.py:112-195, backend/app/api/routes/wiki.py:537-545
Knowledge Promotion
The promote_memory_to_wiki endpoint allows converting durable user memories into structured wiki knowledge.
@router.post("/wiki/promote-memory")
async def promote_memory_to_wiki(
request: PromoteMemoryRequest,
db: sqlite3.Connection = Depends(get_db),
user: dict = Depends(get_current_active_user),
_csrf_token: str = Depends(csrf_protect),
):
await _require_vault_write(user, request.vault_id)
store = WikiStore(db)
compiler = WikiCompiler(db, store)
result = compiler.promote_memory(...)
return result
Sources: backend/app/api/routes/wiki.py:488-518
Frontend Integration
The Wiki is integrated into the application through a dedicated management page and the chat interface.
Wiki Management UI
The management interface (WikiPage.tsx) provides a three-pane layout:
- Navigation/Toolbar: Search, filtering by page type, and access to specialized panels (Lint, Jobs, Activity).
- Page List: A searchable list of all pages in the active vault.
- Detail/Overlay: Displays page content, claims, entities, and version history.
Sources: frontend/src/pages/WikiPage.tsx:75-150
Chat Citations (W# and K#)
Wiki and KMS evidence are surfaced as distinct citation types in chat.
- [W#]: Indigo chips for Wiki claims.
- [K#]: Emerald chips for KMS entries.
The frontend uses the parseSSEStream function to handle incoming wiki_used and kms_used arrays from the backend, triggering specific callbacks to render evidence cards.
Sources: specs/wire-wiki-chat/SPEC.md:134-140, frontend/src/lib/api.ts:745-775
Verification and Linting
To maintain knowledge integrity, the system includes a WikiLinter and automated status tracking.
Wiki Linting
The linter identifies structural or factual issues within the wiki:
- Contradiction: Claims that conflict with each other.
- Stale: Knowledge that hasn't been updated after source documents changed.
- Orphan: Claims or entities not linked to any page.
- Weak Provenance: Claims missing verifiable source quotes.
Sources: backend/app/services/wiki_store.py:117-129, frontend/src/lib/api.ts:1015-1025
Status Management
Claims and pages use a priority-based status system. For claims, the claim_status takes precedence over page_status. Statuses include:
active/verified: Verified and ready for RAG.needs_review: Flagged for human verification (often after LLM curator extraction).stale/superseded: The underlying source document has been updated or deleted.
Sources: specs/wire-wiki-chat/SPEC.md:142-147, backend/app/api/routes/wiki.py:380-410
Conclusion
The Knowledge Management & Wiki system transforms the RAG pipeline from simple document retrieval into a structured knowledge base. By supporting manual curation, entity relationship tracking, and automated linting, the project ensures that chat interactions are grounded in verified, high-fidelity information.
Sources: specs/wire-wiki-chat/SPEC.md:15-20