Files
airport-wiki/concepts/knowledge-management/wiki-operations.md
T
2026-04-15 14:48:14 +08:00

187 lines
5.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Wiki 操作与自动化
created: 2026-04-13
updated: 2026-04-13
type: concept
tags: [knowledge-management, automation, ingestion, lint, event-hooks]
sources: [raw/articles/llm-wiki-v2-rohitg00.md]
---
# Wiki 操作与自动化
## 概述
原始 LLM Wiki 定义了三个基础操作:ingest(摄入)、query(查询)、lint(清理)。在规模化运营中,这三个操作需要扩展为事件驱动架构:每个事件类型触发预定义的自动化钩子,人只做 curationbookkeeping 全自动化。
本页描述扩展后的操作模型及其在本 wiki 中的实践。
源自 [LLM Wiki v2](https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2)。
---
## 三层操作模型
### Layer 1:原始来源层(Raw Sources
`raw/` 目录,保存未处理的原始文档:
- 新闻报道、白皮书、官方文档
- 每次摄入注明来源、日期、URL
### Layer 2Wiki 层(Semantic Memory
`concepts/``entities/``comparisons/` 中的页面:
- 经过处理的结构化知识
- 从 raw sources 提取、整合、标注关系
### Layer 3Schema 层(Procedural Memory
`SCHEMA.md``log.md`
- 元知识、工作流、命名规范
- 从 wiki 操作中积累的模式
---
## 事件钩子(Event Hooks
### 标准钩子矩阵
| 事件 | 自动触发动作 |
|------|-------------|
| **On new source** | 存档至 `raw/` → 运行 entity extraction → 更新 `entities/index.md` → 检查 supersession → 更新 index.md |
| **On session start** | 根据最近 `log.md` 条目加载相关上下文 |
| **On session end** | 将会话压缩为 episodic 条目写入 `log.md` |
| **On query** | 检索时检查答案是否值得写回 wikiquality score > threshold |
| **On memory write** | 检查矛盾,触发 supersession,更新 confidence |
| **On schedule**(定时) | 全量 lint、consolidation tier 检查、confidence decay、遗忘处理 |
### On New Source — 完整流程
```
收到新来源(用户提供 URL / Gist / 文件)
1. 下载并保存至 raw/articles/[slug]-[date].md
2. 自动 entity extraction
- 识别:机场名、供应商、硬件型号、系统名
- 提取 Typed Relationships
- 分配 confidence 初值(来源权威性 × 时效性)
3. 矛盾检测
- 与现有 entities 比较
- 若发现矛盾 → 触发 supersession 流程
- 旧版本 → _archive/,标记 status: stale
4. 更新目录
- 新增 entities → entities/index.md
- 新增 concepts → index.md 对应 section
- 更新 log.md
5. 通知(如有重大矛盾)
- 标记待用户审核
```
### On Session End — 压缩流程
```
会话结束信号
1. 提取本次会话的关键结论
- "新了解到 …"
- "已验证 …"
- "仍有疑问 …"
2. 写入 log.mdEpisodic Memory
条目格式:
- 日期 + session id
- 来源:本次对话
- 新知识:<压缩后的结论>
- 开放问题:<下次需验证>
3. 评估是否升级至 Semantic Memory
- 同一实体在 2+ session 中出现?
- 是 → 创建/更新 entities/ 或 concepts/ 页面
```
### On Schedule — 定期维护
```
每日/每周定时任务
1. Confidence decay
- 所有 entities/concepts 按时间衰减
- 衰减率:架构决策 0.1%/月,供应商信息 1%/月,进度信息 5%/月
2. Orphan check
- 没有入站链接的页面 → 标记 review
- 入站链接多但内容少的"薄页" → 合并或扩展
3. Broken link scan
- 检查所有 wikilink 有效性
- 检查所有 raw source 文件是否存在
4. Supersession review
- 标记为 stale > 3 个月且无访问 → 移至 _archive/
```
---
## 自动化实现方案
### 当前状态 vs 目标状态
| 操作 | 当前(手动) | 目标(自动) |
|------|-------------|-------------|
| 来源摄入 | 用户触发 | On new source hook |
| Session 摘要 | 无 | On session end → log.md |
| 矛盾检测 | 无 | On memory write → supersession |
| 定期 lint | 偶尔手动 | On schedule cron |
| 置信度衰减 | 无 | On schedule cron |
### 近期可实现步骤
1. **会话结束自动写 log**
-`hermes-agent` 中增加 post-session hook
- 自动压缩本次对话结论写入 `log.md`
2. **建立 supersession 工作流**
- ingestion 时检测矛盾
- 自动创建旧版本 archive + 链接新版本
3. **Cron 定期 lint**
- 使用 `hermes cron` 每日运行 lint 脚本
- 检测断链、orphaned pages、confidence decay
### 实施优先级
1. **P0(立即)**:建立 `_archive/` 目录 + supersession 流程
2. **P1(本周)**entity extraction 脚本(基于正则/NER
3. **P2(本月)**session end hook → log.md
4. **P3(下月)**:定时 cron lint + confidence decay
---
## 质量评分(Quality Scoring
每次 LLM 生成内容时,给出质量分数:
| 分数 | 含义 | 行动 |
|------|------|------|
| `quality > 0.9` | 高质量,直接写入 wiki | 自动写入 |
| `quality 0.70.9` | 可接受,需人工审核 | 写入草稿,待 review |
| `quality < 0.7` | 低质量,不写入 | 记录但不持久化 |
**质量维度:**
- 结构化程度(是否遵循 frontmatter 规范)
- 来源引用(是否有 `sources` 字段)
- wikilink 密度(是否有足够的交叉引用)
- 长度合理性(不过短/不过长)
- 事实一致性(与已知知识不矛盾)
---
## 相关页面
- [[memory-lifecycle]] — confidence scoring、supersession、forgetting 机制
- [[knowledge-graph]] — entity extraction、typed relationships
- [[SCHEMA]] — wiki 结构规范(Procedural Memory