-
Notifications
You must be signed in to change notification settings - Fork 4
Checkpoints and Rollback
Language: English · 简体中文
LWC provides two recovery boundaries:
- a checkpoint is a named, full SQLite snapshot of one live Wiki;
- a changeset rollback is a conflict-aware inverse of only the entities touched by one committed changeset.
Choose the smallest boundary that matches the failure. Use changeset rollback for one published logical change; use a checkpoint before a broad operation whose exact inverse is not otherwise available.
Create one before:
- a broad replacement of existing Pages;
- a multi-source ingest performed outside a changeset;
- a manual recovery or migration with a large blast radius;
- an operational experiment that may require restoring the complete Wiki database.
Do not create checkpoints around every transactional command. Single mutations already commit atomically, and routine snapshots add storage without improving their safety.
lwc --scope project checkpoint create before-architecture-refresh
lwc --scope project checkpoint listCreation uses SQLite's online backup API and does not change Wiki knowledge. Names are validated as safe local identifiers. An existing checkpoint is never overwritten.
list returns checkpoints in deterministic name order with their paths and sizes.
Checkpoint commands operate on one live project or global Wiki. They reject --scope all and cannot run inside a draft changeset.
A checkpoint captures the complete canonical Wiki database at one committed point: Sources, ingest state, Pages, provenance, tags, search state, feedback, operation history, and other SQLite-backed records.
It does not copy deployment-local configuration, the generated Markdown directory, the document-graph sidecar, or the CodeGraph runtime. Those are outside wiki.db:
- current graph configuration remains in effect;
- generated Markdown is materialized after restore;
- the enabled document graph is fully reprojected from restored canonical state;
- CodeGraph remains an independent index of project source files.
lwc --scope project checkpoint restore before-architecture-refreshRestore performs these safety steps:
- opens the named checkpoint read-only and validates its schema and integrity;
- prepares and validates a private restore candidate before touching live data;
- creates a fresh
pre-restore-*checkpoint of the current live database; - obtains the live write lock and rejects the restore if live revision advanced during preparation;
- replaces the live database through SQLite backup;
- queues full document-graph projection when a graph engine is enabled;
- regenerates materialized Markdown.
The response includes the restored checkpoint and the generated safety_checkpoint. Keep that name with the incident record; it is the recovery point for the state that existed immediately before restore.
Restore waits only for canonical database replacement. Graph projection remains Work and must be watched separately.
lwc --scope project checkpoint restore before-architecture-refresh
lwc --scope project work watch <graph-work-id>
lwc --scope project lint
lwc --scope project search "known answer" --limit 5
lwc --scope project graph verifyIf graph support is disabled, restore returns no graph_work; skip only the Work and graph checks. Still verify canonical Pages, search, lint, and materialized Markdown.
Verify both absence and presence. Confirm the unwanted post-checkpoint state disappeared and the expected checkpoint state returned.
Canonical restore can succeed before a later projection fails. LWC reports these cases explicitly with details such as:
-
checkpoint_restored=true; - the source checkpoint name;
- the generated safety checkpoint;
-
graph_workwhen graph queueing succeeded; - one exact
recovery_commandor a list ofrecovery_commands.
Run those commands exactly. Do not retry the original knowledge mutations, and do not assume a generic error means the database stayed unchanged.
Typical follow-up commands are:
lwc --scope project maintenance materialize
lwc --scope project config set --graph grafeoThe graph recovery command uses the restored Wiki's scope, even when its graph setting was inherited from global configuration.
If restore cannot safely prepare or acquire a stable live revision, it returns checkpoint_restored=false. A busy conflict is retryable; a structurally invalid checkpoint is not.
Use the stable changeset ID returned by commit:
lwc --scope project changeset rollback <changeset-id>
lwc --scope project work watch <graph-work-id>
lwc --scope project graph verifyChangeset rollback is narrower than checkpoint restore. It uses a checksummed inverse patch and restores only touched entities. If a later write changed one of them, rollback returns changeset_rollback_conflict instead of overwriting newer work.
It also restores Source path heads, remapped Source IDs, Page citations, tags, and document-graph projection. Repeating the same rollback is idempotent and is the recovery path when canonical rollback succeeded but later cleanup or projection failed.
| Need | Use |
|---|---|
| Undo one committed multi-command knowledge update | Changeset rollback |
| Preserve later unrelated live writes | Changeset rollback |
| Return the entire Wiki database to an earlier point | Checkpoint restore |
| Protect a broad non-changeset ingest or migration | Checkpoint create before the operation |
| Repair only derived Markdown, search, or graph state | Maintenance or graph reprojection, not restore |
- Never edit a checkpoint database or graph sidecar manually.
- Never copy a live WAL-mode
wiki.dbfile as an ad hoc backup; usecheckpoint create. - Record the exact scope, checkpoint name, and acceptance checks before restore.
- Treat
database_busyas a concurrency signal; do not bypass the revision guard. - Keep the automatic safety checkpoint until live acceptance is complete.
- Do not use checkpoint restore to switch graph engines or deployment configuration.
Recovery is complete when:
- the chosen boundary matches the intended blast radius;
- the restore or rollback response identifies its recovery artifact;
- canonical Pages, Sources, tags, and retrieval match the expected state;
- materialized Markdown is current;
- any returned graph Work reached
succeeded; -
graph verifyreportsok=truewhen enabled; - partial-success recovery commands were executed and rechecked;
- the pre-recovery state remains available until acceptance finishes.
Next: Read-only Viewer
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 编写规范