maestro-flow 0.4.15 → 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/maestro/SKILL.md +17 -17
- package/.agents/skills/maestro-plan/SKILL.md +10 -9
- package/.agents/skills/maestro-ralph/SKILL.md +21 -17
- package/.agents/skills/maestro-ralph-execute/SKILL.md +54 -71
- package/.agents/skills/manage-knowledge-audit/SKILL.md +90 -0
- package/.agy/skills/maestro/SKILL.md +17 -17
- package/.agy/skills/maestro-plan/SKILL.md +10 -9
- package/.agy/skills/maestro-ralph/SKILL.md +21 -17
- package/.agy/skills/maestro-ralph-execute/SKILL.md +54 -71
- package/.agy/skills/manage-knowledge-audit/SKILL.md +90 -0
- package/.claude/commands/maestro-plan.md +10 -9
- package/.claude/commands/maestro-ralph-execute.md +54 -71
- package/.claude/commands/maestro-ralph.md +21 -17
- package/.claude/commands/maestro.md +17 -17
- package/.claude/commands/manage-knowledge-audit.md +88 -0
- package/dist/src/cli.js +1 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/font-guide.d.ts +13 -0
- package/dist/src/commands/font-guide.d.ts.map +1 -0
- package/dist/src/commands/font-guide.js +114 -0
- package/dist/src/commands/font-guide.js.map +1 -0
- package/dist/src/commands/install.d.ts.map +1 -1
- package/dist/src/commands/install.js +5 -0
- package/dist/src/commands/install.js.map +1 -1
- package/dist/src/commands/ralph.d.ts +6 -0
- package/dist/src/commands/ralph.d.ts.map +1 -0
- package/dist/src/commands/ralph.js +133 -0
- package/dist/src/commands/ralph.js.map +1 -0
- package/dist/src/core/manifest.d.ts +2 -0
- package/dist/src/core/manifest.d.ts.map +1 -1
- package/dist/src/core/manifest.js.map +1 -1
- package/dist/src/hooks/statusline.d.ts.map +1 -1
- package/dist/src/hooks/statusline.js +189 -81
- package/dist/src/hooks/statusline.js.map +1 -1
- package/dist/src/ralph/cmd-check.d.ts +9 -0
- package/dist/src/ralph/cmd-check.d.ts.map +1 -0
- package/dist/src/ralph/cmd-check.js +53 -0
- package/dist/src/ralph/cmd-check.js.map +1 -0
- package/dist/src/ralph/cmd-complete.d.ts +10 -0
- package/dist/src/ralph/cmd-complete.d.ts.map +1 -0
- package/dist/src/ralph/cmd-complete.js +91 -0
- package/dist/src/ralph/cmd-complete.js.map +1 -0
- package/dist/src/ralph/cmd-next.d.ts +5 -0
- package/dist/src/ralph/cmd-next.d.ts.map +1 -0
- package/dist/src/ralph/cmd-next.js +158 -0
- package/dist/src/ralph/cmd-next.js.map +1 -0
- package/dist/src/ralph/cmd-session.d.ts +5 -0
- package/dist/src/ralph/cmd-session.d.ts.map +1 -0
- package/dist/src/ralph/cmd-session.js +52 -0
- package/dist/src/ralph/cmd-session.js.map +1 -0
- package/dist/src/ralph/cmd-skills.d.ts +6 -0
- package/dist/src/ralph/cmd-skills.d.ts.map +1 -0
- package/dist/src/ralph/cmd-skills.js +55 -0
- package/dist/src/ralph/cmd-skills.js.map +1 -0
- package/dist/src/ralph/skill-resolver.d.ts +40 -0
- package/dist/src/ralph/skill-resolver.d.ts.map +1 -0
- package/dist/src/ralph/skill-resolver.js +162 -0
- package/dist/src/ralph/skill-resolver.js.map +1 -0
- package/dist/src/ralph/skill-scanner.d.ts +15 -0
- package/dist/src/ralph/skill-scanner.d.ts.map +1 -0
- package/dist/src/ralph/skill-scanner.js +122 -0
- package/dist/src/ralph/skill-scanner.js.map +1 -0
- package/dist/src/ralph/status-checker.d.ts +7 -0
- package/dist/src/ralph/status-checker.d.ts.map +1 -0
- package/dist/src/ralph/status-checker.js +139 -0
- package/dist/src/ralph/status-checker.js.map +1 -0
- package/dist/src/ralph/status-schema.d.ts +94 -0
- package/dist/src/ralph/status-schema.d.ts.map +1 -0
- package/dist/src/ralph/status-schema.js +9 -0
- package/dist/src/ralph/status-schema.js.map +1 -0
- package/dist/src/ralph/status-store.d.ts +20 -0
- package/dist/src/ralph/status-store.d.ts.map +1 -0
- package/dist/src/ralph/status-store.js +70 -0
- package/dist/src/ralph/status-store.js.map +1 -0
- package/dist/src/tui/install-ui/ExecutionView.d.ts.map +1 -1
- package/dist/src/tui/install-ui/ExecutionView.js +1 -0
- package/dist/src/tui/install-ui/ExecutionView.js.map +1 -1
- package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallExecution.js +2 -0
- package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
- package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallFlow.js +28 -14
- package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
- package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
- package/dist/src/tui/install-ui/InstallResult.js +1 -1
- package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
- package/dist/src/utils/update-notices.js +12 -0
- package/dist/src/utils/update-notices.js.map +1 -1
- package/package.json +1 -1
- package/workflows/knowledge-audit.md +358 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
# Knowledge Audit Workflow
|
|
2
|
+
|
|
3
|
+
审查 spec / knowhow / artifact 三大知识存储,识别矛盾、失效、老化、孤儿,通过 keep/deprecate/delete 三态决策淘汰。
|
|
4
|
+
|
|
5
|
+
与 `harvest.md` 对称:harvest 写入知识 → knowledge-audit 清理知识。与 `harvest --prune`(Stage 9)的区别:prune 做物理 GC(孤儿指针、格式损坏),audit 做语义审查(逻辑矛盾、生命周期决策)。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- `.workflow/` 已初始化(`.workflow/state.json` 存在)
|
|
12
|
+
- 至少一个目标存储有内容:
|
|
13
|
+
- `spec`: `.workflow/specs/*.md` 含 `<spec-entry>`
|
|
14
|
+
- `knowhow`: `maestro wiki list` 非空
|
|
15
|
+
- `artifact`: `.workflow/.{analysis,brainstorm,debug,lite-plan,lite-fix}/` 或 `state.json.artifacts[]` 非空
|
|
16
|
+
- 推荐:`harvest-log.jsonl` 存在(用于追溯 artifact 是否已抽取)
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Argument Shape
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
/manage-knowledge-audit --scope all → 全量审查三存储(交互式)
|
|
24
|
+
/manage-knowledge-audit --scope spec --level P0 → 仅扫 spec 的 P0 问题
|
|
25
|
+
/manage-knowledge-audit --scope artifact --timeline T2,T3 → 仅查 milestone 失效与时间倒挂
|
|
26
|
+
/manage-knowledge-audit --scope all --since 2026-03-01 → 增量审查
|
|
27
|
+
/manage-knowledge-audit --scope spec --milestone M2 → 限定 milestone 上下文
|
|
28
|
+
/manage-knowledge-audit --scope all --report → 仅出报告不动盘
|
|
29
|
+
/manage-knowledge-audit --scope all --dry-run → 完整预演含交互
|
|
30
|
+
/manage-knowledge-audit --scope artifact --purge → 物理擦除(需双重确认)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| Flag | Effect |
|
|
34
|
+
|------|--------|
|
|
35
|
+
| `--scope <type>` | **必选** spec / knowhow / artifact / all |
|
|
36
|
+
| `--level <P0\|P1\|P2>` | 仅展示该优先级(默认 all)|
|
|
37
|
+
| `--timeline <T1..T6>` | 仅运行指定时间线检测(逗号分隔)|
|
|
38
|
+
| `--since <YYYY-MM-DD>` | 仅审查该日期后修改的条目(增量模式)|
|
|
39
|
+
| `--milestone <name>` | 限定到某 milestone 上下文 |
|
|
40
|
+
| `--include-archive` | 把 `artifact_archive[]` 也纳入扫描 |
|
|
41
|
+
| `--interactive` | 三态决策交互(默认开启,除非 `--report`)|
|
|
42
|
+
| `--mark` | 非交互:仅注入 warning 标记,不删 |
|
|
43
|
+
| `--delete` | 非交互:自动软删(移 `.trash/`)|
|
|
44
|
+
| `--purge` | **危险** 物理擦除 artifact,需 `[y/N]` 二次确认 |
|
|
45
|
+
| `--dry-run` | 全流程预演,不写盘 |
|
|
46
|
+
| `--report` | 仅生成报告到 `.workflow/.knowledge-audit/` |
|
|
47
|
+
|
|
48
|
+
互斥规则:`--purge` 不可与 `--dry-run` 同用;`--purge` 仅对 `--scope artifact|all` 生效。
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Stage 1: parse_input
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
验证 .workflow/ 存在(否则 E001)。解析参数:
|
|
56
|
+
scope: spec | knowhow | artifact | all (E002 若缺失/非法)
|
|
57
|
+
level: P0 | P1 | P2 | all(默认 all)
|
|
58
|
+
mode: interactive(默认)| mark | delete | purge | dry-run | report
|
|
59
|
+
filters: timeline[], since, milestone, include_archive
|
|
60
|
+
|
|
61
|
+
互斥校验:
|
|
62
|
+
--purge + --dry-run → E003
|
|
63
|
+
--purge + scope != artifact|all → E004
|
|
64
|
+
--report → 强制覆盖 mode 为 read-only
|
|
65
|
+
初始化 .workflow/.knowledge-audit/ 目录。
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Stage 2: load_three_stores
|
|
71
|
+
|
|
72
|
+
按 scope 加载,建立统一对象池:
|
|
73
|
+
|
|
74
|
+
### 2a. Spec 加载
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
glob .workflow/specs/*.md
|
|
78
|
+
解析每个 <spec-entry category=... keywords=... date=... [id=...] [status=...] [supersedes=...]> 块
|
|
79
|
+
→ SpecEntry { id?, file, line, category, keywords[], date, status?, supersedes?, content }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
未来 schema 升级后 `id` / `status` / `supersedes` 为一等字段;当前未升级时按 `hash(file+title+date)` 生成 fallback id。
|
|
83
|
+
|
|
84
|
+
### 2b. Knowhow 加载
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
maestro wiki list --json → entries[]
|
|
88
|
+
读 .workflow/knowhow/*.md → 解析 frontmatter
|
|
89
|
+
合并: KnowhowEntry { slug, type, title, tags[], created_at, last_accessed?, content, code_refs[] }
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 2c. Artifact 加载
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
读 .workflow/state.json → artifacts[], artifact_archive[](若 --include-archive), milestones[]
|
|
96
|
+
glob .workflow/.{analysis,brainstorm,debug,lite-plan,lite-fix}/*/
|
|
97
|
+
合并: Artifact { id, type, path, milestone?, created_at, completed_at?, mtime, harvested? }
|
|
98
|
+
harvested 通过 join .workflow/harvest/harvest-log.jsonl 的 source_id 字段确定
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 2d. since/milestone 过滤
|
|
102
|
+
|
|
103
|
+
应用 `--since` 与 `--milestone` 收敛集合。
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Stage 3: build_timeline_index
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
read state.json.milestones[] → { id: {status: active|completed|abandoned, started_at, ended_at?} }
|
|
111
|
+
for each entry (spec / knowhow / artifact):
|
|
112
|
+
age = today - entry.date_or_mtime
|
|
113
|
+
enclosing_milestone = find_milestone_at(entry.date_or_mtime)
|
|
114
|
+
enclosing_status = milestones[enclosing_milestone].status
|
|
115
|
+
// 用于 F 类(时间线)检测
|
|
116
|
+
build supersedes_graph: SpecEntry.supersedes → 有向图
|
|
117
|
+
build reverse_ref_graph: artifact ← session/spec/wiki 引用反向边
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Stage 4: scenario_detection
|
|
123
|
+
|
|
124
|
+
**并行运行 8 类 detector,按优先级聚合 `AuditFinding[]`。**
|
|
125
|
+
|
|
126
|
+
### A. 显性矛盾(Spec)
|
|
127
|
+
|
|
128
|
+
| 子类型 | 检测算法 | 优先级 |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| 行为禁忌冲突 | 同 keywords 簇内 LLM 极性对比(MUST DO vs MUST NOT) | P0 |
|
|
131
|
+
| 阈值冲突 | 正则抽数值 + 关键词聚类,比较区间是否冲突 | P0 |
|
|
132
|
+
| 命名规范冲突 | LLM 聚类 "naming convention" 规则查异 | P1 |
|
|
133
|
+
|
|
134
|
+
### B. 隐性矛盾(Spec)
|
|
135
|
+
|
|
136
|
+
| 子类型 | 检测算法 | 优先级 |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| 跨域权衡 | 抽 security/debug/perf 关键词,交叉对抗推理 | P1 |
|
|
139
|
+
| 全局 vs 局部 | arch 文件规则 vs coding 局部规则的范围检测 | P1 |
|
|
140
|
+
| 传递性死锁 | 构建前置/后置条件图,检测环路 | P0 |
|
|
141
|
+
| 错误处理分歧 | 提取 throw/Result/Either 策略一致性 | P1 |
|
|
142
|
+
|
|
143
|
+
### C. 失效老化(Spec / Knowhow)
|
|
144
|
+
|
|
145
|
+
| 子类型 | 检测算法 | 优先级 |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| 幽灵代码引用 | 抽 spec/knowhow 中的代码路径,`fs.exists` 校验 | P0 |
|
|
148
|
+
| 依赖版本过期 | 抽提及的库名,对照 `package.json`,LLM 判失效 | P1 |
|
|
149
|
+
| 外部配置违背 | 对照 `tsconfig.json` / `.eslintrc` / `biome.json` | P2 |
|
|
150
|
+
| 静默推翻 | date 排序找出未标 supersedes 的相反条目 | P0 |
|
|
151
|
+
|
|
152
|
+
### D. 元数据质量(Spec / Knowhow)
|
|
153
|
+
|
|
154
|
+
| 子类型 | 检测算法 | 优先级 |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| 标签错位 | LLM 评估 keywords 与正文语义相关度 | P2 |
|
|
157
|
+
| 分类错位 | 内容 vs 文件归属语义判定 | P2 |
|
|
158
|
+
| 假规范 | LLM 评估是否可转化为具体 check(actionable)| P2 |
|
|
159
|
+
| 悬空 supersedes | 图遍历,目标 ID 不存在 | P0 |
|
|
160
|
+
| 循环 supersedes | DFS 检测环 | P0 |
|
|
161
|
+
| 状态倒挂 | active 条目依赖 deprecated 条目 | P1 |
|
|
162
|
+
|
|
163
|
+
### E. Maestro 特化(Spec)
|
|
164
|
+
|
|
165
|
+
| 子类型 | 检测算法 | 优先级 |
|
|
166
|
+
|---|---|---|
|
|
167
|
+
| 项目宪法背离 | 加载 `workflows/impeccable/PRODUCT.md` 作真理对照 | P0 |
|
|
168
|
+
| TUI 原则碰撞 | 检测 "鼠标/hover" 等违反 keyboard sovereignty 的关键词 | P1 |
|
|
169
|
+
| 标签碎片化 | 统计 keywords 频次为 1 的孤儿标签 | P2 |
|
|
170
|
+
|
|
171
|
+
### F. 时间线产物(Artifact)
|
|
172
|
+
|
|
173
|
+
| 子类型 | 触发条件 | 检测算法 | 优先级 |
|
|
174
|
+
|---|---|---|---|
|
|
175
|
+
| **T1 时间陈旧** | artifact.mtime > 90 天 且 harvested | mtime + harvest-log join | P1 |
|
|
176
|
+
| **T2 milestone 失效** | enclosing_milestone.status ∈ {abandoned, superseded} | state.json 时间线交叉 | P0 |
|
|
177
|
+
| **T3 时间倒挂** | artifact.mtime > parent_session.ended_at | session 元数据对比 | P1 |
|
|
178
|
+
| **T4 孤儿** | reverse_ref_graph 无入边,且 harvest-log 无记录 | 反向引用集为空 | P1 |
|
|
179
|
+
| **T5 跨 milestone 漂移** | 同主题 artifact 在 M1/M2/M3 都有,无 supersedes 链 | keywords 聚类 + date 排序 | P2 |
|
|
180
|
+
| **T6 archive 派生** | source_ref ∈ artifact_archive[] | join state.json.archive | P1 |
|
|
181
|
+
|
|
182
|
+
### G. Knowhow 特有
|
|
183
|
+
|
|
184
|
+
| 子类型 | 检测算法 | 优先级 |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| wiki 引用代码不存在 | 抽 code_refs,磁盘校验 | P1 |
|
|
187
|
+
| 与新 spec 矛盾 | 向量相似 >0.85 后 LLM 矛盾判定 | P0 |
|
|
188
|
+
| 长期无访问冷门 | last_accessed > 90 天 | P2 |
|
|
189
|
+
| digest 漂移 | digest.created_at < 引用的原始 entry.mtime | P1 |
|
|
190
|
+
|
|
191
|
+
### H. Artifact 特有
|
|
192
|
+
|
|
193
|
+
| 子类型 | 检测算法 | 优先级 |
|
|
194
|
+
|---|---|---|
|
|
195
|
+
| 已 graduate 但磁盘残留 | state.json.artifact_archive[].path 在磁盘仍存在 | P1 |
|
|
196
|
+
| milestone abandoned 未清 | milestone.status=abandoned 且 artifact 未归档 | P0 |
|
|
197
|
+
| 长期未引且无 harvest | T4 子集,age > 180 天 | P1 |
|
|
198
|
+
| accumulated_context 重复 spec | state.json.accumulated_context vs spec 语义查重 >70% | P2 |
|
|
199
|
+
|
|
200
|
+
每个 detector 返回:
|
|
201
|
+
```
|
|
202
|
+
AuditFinding {
|
|
203
|
+
id: "AUD-{8 hex}",
|
|
204
|
+
store: "spec" | "knowhow" | "artifact",
|
|
205
|
+
category: "A" | "B" | ... | "H",
|
|
206
|
+
subtype: string,
|
|
207
|
+
priority: "P0" | "P1" | "P2",
|
|
208
|
+
target: { file, line?, entry_id? },
|
|
209
|
+
evidence: string,
|
|
210
|
+
recommended_action: "keep" | "deprecate" | "delete" | "purge",
|
|
211
|
+
related_findings: [ids],
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
按 P0 → P1 → P2 排序,过滤 `--level`。
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Stage 5: interactive_triage
|
|
220
|
+
|
|
221
|
+
若 `--report` → 跳过。
|
|
222
|
+
若 `--mark|--delete|--purge` → 非交互应用 recommended_action。
|
|
223
|
+
否则按 finding 顺序展示三态面板:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
[!] Conflict Detected (P0 - Ghost Code Reference)
|
|
227
|
+
Store: spec
|
|
228
|
+
Location: .workflow/specs/coding-conventions.md:42
|
|
229
|
+
Evidence: References non-existent file 'src/auth/legacy-token.ts'
|
|
230
|
+
Recommendation: [d]eprecate
|
|
231
|
+
|
|
232
|
+
Action? [k]eep / [d]eprecate / [D]elete / [s]kip / [a]ll-keep / [q]uit
|
|
233
|
+
> _
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**子分支拦截:**
|
|
237
|
+
|
|
238
|
+
| 条件 | 二次确认 |
|
|
239
|
+
|---|---|
|
|
240
|
+
| `[D]elete` 一个 artifact 且 harvest-log 无该 artifact | `This artifact has NO harvest records. Run /manage-harvest first? [Y/n]` |
|
|
241
|
+
| `--purge` 任意 artifact | `WARNING: --purge will permanently destroy {path} from disk. Type the artifact id to confirm:` |
|
|
242
|
+
| `[D]elete` 一个被其他 spec `supersedes` 引用的条目 | `This spec is referenced by N supersedes chains. Deleting will dangle them. Continue? [y/N]` |
|
|
243
|
+
|
|
244
|
+
`[a]ll-keep` 仅作用于当前 finding 的 subtype(不跨子类型)。
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Stage 6: backup
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
mkdir .workflow/.trash/knowledge-audit-{ISO_timestamp}/
|
|
252
|
+
for finding in actionable_findings:
|
|
253
|
+
cp target.file → .trash/{timestamp}/{original_relative_path}
|
|
254
|
+
也备份 state.json → .trash/{timestamp}/state.json.bak
|
|
255
|
+
若任一备份失败 → E005,禁止 Stage 7
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Stage 7: apply_actions
|
|
261
|
+
|
|
262
|
+
| Action | 实施 |
|
|
263
|
+
|---|---|
|
|
264
|
+
| `keep` | 写 `audit-log.jsonl` 一条 ignore 记录(防止下次重复 flag)|
|
|
265
|
+
| `deprecate` (spec) | Edit 目标文件,把 `<spec-entry ...>` 改为 `<spec-entry ... status="deprecated">` |
|
|
266
|
+
| `deprecate` (knowhow) | `maestro wiki edit <slug>` 注入 `status: deprecated` frontmatter |
|
|
267
|
+
| `deprecate` (artifact) | 更新 state.json.artifacts[].status = "deprecated" |
|
|
268
|
+
| `delete` (spec) | Edit 移除整个 `<spec-entry>` 块 |
|
|
269
|
+
| `delete` (knowhow) | `maestro wiki delete <slug>` |
|
|
270
|
+
| `delete` (artifact) | mv artifact_dir → `.workflow/.trash/{timestamp}/` + state.json 移入 `artifact_archive[]` |
|
|
271
|
+
| `purge` (artifact only) | `rm -rf` 物理路径 + state.json 完全移除条目 |
|
|
272
|
+
|
|
273
|
+
**变更 state.json 时**:先写 `state.json.backup-audit-{timestamp}`,再写新版本,re-read 验证 artifacts 计数符合预期。
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Stage 8: report
|
|
278
|
+
|
|
279
|
+
写 `.workflow/.knowledge-audit/audit-report-{date}.md`:
|
|
280
|
+
|
|
281
|
+
```markdown
|
|
282
|
+
# Knowledge Audit Report — {date}
|
|
283
|
+
|
|
284
|
+
## Scope
|
|
285
|
+
- Scope: {spec|knowhow|artifact|all}
|
|
286
|
+
- Filters: {level, timeline, since, milestone}
|
|
287
|
+
|
|
288
|
+
## Detection Summary
|
|
289
|
+
- Total findings: {N} ({P0_count} P0 / {P1_count} P1 / {P2_count} P2)
|
|
290
|
+
- By store: spec {N} / knowhow {N} / artifact {N}
|
|
291
|
+
- By category: A{N} B{N} C{N} D{N} E{N} F{N} G{N} H{N}
|
|
292
|
+
|
|
293
|
+
## Actions Applied
|
|
294
|
+
| # | Store | Category | Subtype | Target | Action | Status |
|
|
295
|
+
|---|-------|----------|---------|--------|--------|--------|
|
|
296
|
+
| 1 | spec | C-ghost | code-ref| coding-conventions.md:42 | deprecate | OK |
|
|
297
|
+
| 2 | artifact | F-T2 | milestone-dead | .workflow/.analysis/ANL-003/ | delete | OK |
|
|
298
|
+
|
|
299
|
+
## Skipped (kept by user)
|
|
300
|
+
| Finding | Reason |
|
|
301
|
+
|---------|--------|
|
|
302
|
+
| AUD-abc | User chose keep — marked as ignored |
|
|
303
|
+
|
|
304
|
+
## Backup
|
|
305
|
+
- Tarball: .workflow/.trash/knowledge-audit-{timestamp}/
|
|
306
|
+
- state.json backup: state.json.backup-audit-{timestamp}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
同时追加结构化条目到 `.workflow/.knowledge-audit/audit-log.jsonl`:
|
|
310
|
+
|
|
311
|
+
```json
|
|
312
|
+
{
|
|
313
|
+
"audit_id": "AUD-{timestamp}",
|
|
314
|
+
"finding_id": "AUD-{8 hex}",
|
|
315
|
+
"store": "spec",
|
|
316
|
+
"category": "C",
|
|
317
|
+
"subtype": "ghost-code-ref",
|
|
318
|
+
"priority": "P0",
|
|
319
|
+
"target": {"file": "...", "line": 42, "entry_id": "..."},
|
|
320
|
+
"action": "deprecate",
|
|
321
|
+
"applied_at": "<ISO>",
|
|
322
|
+
"backup_path": "..."
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
显示摘要:
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
=== AUDIT COMPLETE ===
|
|
330
|
+
Scope: all
|
|
331
|
+
|
|
332
|
+
Findings: 28 total (5 P0 / 12 P1 / 11 P2)
|
|
333
|
+
Spec: 8 deprecated, 2 deleted, 3 kept
|
|
334
|
+
Knowhow: 4 deprecated, 1 deleted, 2 kept
|
|
335
|
+
Artifact: 3 deleted (2 to .trash, 1 purged), 5 kept
|
|
336
|
+
|
|
337
|
+
Report: .workflow/.knowledge-audit/audit-report-2026-05-22.md
|
|
338
|
+
Backup: .workflow/.trash/knowledge-audit-20260522T154500/
|
|
339
|
+
|
|
340
|
+
Next:
|
|
341
|
+
→ 抢救未抽取 artifact: /manage-harvest <ids>
|
|
342
|
+
→ 验证现状: /spec-load --role implement
|
|
343
|
+
→ 复审 wiki 状态: maestro wiki list --status deprecated
|
|
344
|
+
→ 周期巡检 (建议): milestone 结束时跑 --scope all --report
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
### Safety invariants
|
|
350
|
+
|
|
351
|
+
1. **Deprecate over delete** — 文本存储默认注入 `status=deprecated` 而非物理移除,保留历史上下文
|
|
352
|
+
2. **Backup before mutate** — Stage 6 失败则禁止 Stage 7;state.json 原子写(备份 → 写新 → re-read 校验)
|
|
353
|
+
3. **Purge restricted** — `--purge` 仅限 artifact scope;spec/knowhow 永不物理删除(最多 delete 到 `.trash/`)
|
|
354
|
+
4. **Double confirmation** — `--purge` 需 flag + 交互输入 artifact id 双重确认
|
|
355
|
+
5. **Rescue before delete** — 删 artifact 前若 harvest-log 无记录,强制提示先跑 `/manage-harvest`
|
|
356
|
+
6. **No dedup re-run** — audit 不做"是否重复"判断(harvest 负责),只做"是否矛盾/失效/老化"
|
|
357
|
+
7. **Graceful degradation** — LLM detector 不可用时跳过 B/G 类语义场景,A/D/F 类正则+图算法仍可执行
|
|
358
|
+
8. **Idempotent** — 同一存储状态下重跑 `--dry-run` 必须输出一致的 finding 集
|