-
Notifications
You must be signed in to change notification settings - Fork 4
Document Knowledge Graph
Language: English · 简体中文
The document knowledge graph—also called the memory graph—connects current Wiki Pages and immutable Sources. It answers structural questions that lexical search cannot answer directly: what cites this evidence, which Pages are linked, whether one concept reaches another, and what may be affected by a dependency change.
SQLite remains the canonical store. The graph is a rebuildable projection of current documents and relationships; it is never a second source of truth.
LWC projects:
- one node for every current Page (
page:<slug>); - one node for every current Source (
source:<id>); -
LINKS_TOedges extracted from[[wiki-links]]; -
CITESedges from Page citations; - explicit, audited semantic relations.
Old Source revisions remain immutable in SQLite. The graph follows the current tracked-path head and current Page bodies.
Use the document graph for:
- unknown topology or relationship discovery;
- immediate incoming or outgoing neighbors;
- a shortest typed path between two nodes;
- reverse dependency impact;
- structurally related Page ranking;
- support, contradiction, refinement, supersession, causality, or dependency claims that require an explicit audit trail.
Use search, page show, or source show for a direct lookup. Graph traversal adds no value when one known document already answers the question.
Graph storage is disabled by default. Enabling or switching an engine changes project configuration and projection state, so an Agent must obtain consent first.
Grafeo is the embedded default recommendation:
lwc --scope project config set --graph grafeo
lwc --scope project work watch <work-id>
lwc --scope project graph status
lwc --scope project graph verifyUse surrealdb only when project policy has selected it:
lwc --scope project config set --graph surrealdbThe configuration response may return a Work. Completion means that Work reached succeeded and graph verify returned ok=true; queued or running is not completion.
Never switch or disable engines while graph Work is active. Do not copy, edit, or delete LWC-owned graph sidecars.
Start with the smallest operation that answers the question:
lwc graph overview --limit 10
lwc graph node page:projection-policy
lwc graph neighbors page:projection-policy --direction outgoing --limit 100
lwc graph path page:implementation page:policy --max-depth 6 --limit 200
lwc graph explore page:policy --direction both --depth 2 --limit 100-
overviewsummarizes counts and hubs. -
noderesolves one identifier and reports bounded degree metadata. -
neighborsreturns immediate typed neighbors. -
pathexplains a shortest typed route. -
exploretraverses a bounded neighborhood; omit the identifier only for a representative macro view.
Use repeatable --edge-type filters when only specific relationships matter. Keep limits and depth explicit for automation.
lwc graph related customer-membership --limit 20related ranks Pages only when structural evidence exists. It combines bidirectional Wiki links, shared Source citations, and Adamic–Adar common-neighbor evidence; Page-kind affinity only refines those candidates. The response exposes each signal so an Agent can explain the ranking.
This is structural relevance, not semantic truth. Open the returned Page and inspect its evidence before relying on a claim.
lwc graph impact page:policy --max-depth 4 --limit 100impact walks reverse dependencies and classifies affected nodes for hard action or review. Treat it as a bounded change-review aid, not proof that every returned node must change.
Automatic edges represent only citations and Wiki links. Strong claims must be written explicitly using one supported type:
SUPPORTSCONTRADICTSREFINESSUPERSEDESCAUSESDEPENDS_ON
Create or replace one relation:
lwc graph relation set page:implementation DEPENDS_ON page:policy \
--provenance source-grounded \
--source 12 \
--reason "Source 12 states the required policy" \
--confidence 0.95Inspect and retract it:
lwc graph relation list --from page:implementation --limit 100
lwc graph relation retract page:implementation DEPENDS_ON page:policy \
--reason "The dependency was superseded"Every explicit relation requires concise provenance, a reason, and confidence. A source-grounded relation must cite every supporting Source ID. Reasons are durable content: never place secrets or private reasoning in them.
Page and Source mutations queue document-granular Work when the graph is enabled. Follow the returned Work rather than assuming the write command completed projection:
lwc work status <work-id>
lwc work watch <work-id>Canonical search and reads remain available while projection is pending or failed. If verification reports missing, mismatched, or stale documents, repair through supported configuration, Work, checkpoint, or changeset recovery flows; never modify the sidecar directly.
Changesets use isolated draft Work and graph state. A committed changeset projects live documents, while discard removes only that draft's derived state.
The document graph is ready when:
- configuration reports the intended engine and scope;
- every relevant Work reached
succeeded; -
graph statusreports the expected current documents; -
graph verifyreturnsok=truewith no missing, mismatched, or stale entries; - explicit relations have supported types and complete audit metadata;
- traversal used bounded depth, limits, and filters appropriate to the question.
Next: Code graph
LWC Wiki
- Home · 首页
- Project overview · 项目简介
- Basic concepts · 基本概念
- Use cases · 应用场景
- Installation and upgrades · 安装与升级
- Quick start · 快速开始
- Persistent memory · 持久记忆体系
- Agent workflow and memory policy · Agent 工作流与主动记忆策略
- Sources and ingestion · 来源与知识整合
- Wiki pages and provenance · Wiki 页面与来源证明
- Search and context · 搜索与上下文载入
- Document knowledge graph · 文档知识图(记忆图网)
- Code graph · 代码图
- Word graph · 词图
- Tags and strong context · 标签与强上下文
- Document conversion · 文档转换
-
MCP server and
lwc_explore· MCP 服务与lwc_explore - Skills, Hooks, and Instructions · Skills、Hooks 与 Instructions
- AgentTarget installation · AgentTarget 安装与集成
- Changesets · Changeset 原子变更
- Work system · Work 任务系统
- Checkpoints and rollback · Checkpoint、恢复与回滚
- Read-only Viewer · 只读可视化界面
- Architecture overview · 总体架构
- Storage and data model · 存储与数据模型
- Retrieval and indexing · 检索与索引设计
- Graph projection and performance · 图投影与性能设计
- MCP, Hooks, and AgentTarget design · MCP、Hook 与 AgentTarget 设计
- Safety and trust boundaries · 安全模型与信任边界
- Maintenance and diagnostics · 维护与诊断
- Troubleshooting and FAQ · 故障排查与常见问题
- Migration and compatibility · 迁移与版本兼容
- Support and issue reporting · 获取帮助与问题反馈
- CLI and configuration reference · CLI 与配置参考
- JSON output and error contract · JSON 输出与错误契约
- Limits and glossary · 系统限制与术语表
- Contributing and development · 贡献与开发指南
- Testing and release process · 测试与发布流程
- Wiki style guide · Wiki 编写规范