dsh-vibe-math 2.2.2 → 2.3.1

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.
Files changed (43) hide show
  1. package/AUDIT-CHECKLIST.md +61 -3
  2. package/README.md +119 -1
  3. package/RELEASE-NOTES-2.3.0.md +207 -0
  4. package/RELEASE-NOTES-2.3.1.md +134 -0
  5. package/audit-formal-sensitivity.mjs +333 -0
  6. package/audit-persona-sensitivity.mjs +249 -0
  7. package/audit-persona-surface.test.mjs +349 -0
  8. package/audit-v5-integrity.mjs +43 -2
  9. package/audit-v5-sensitivity.mjs +77 -6
  10. package/docs/formal-verification.md +401 -0
  11. package/docs/generate_framework_diagram_v5.mjs +22 -16
  12. package/docs/test-timing.md +79 -0
  13. package/formal-verify-v2.test.mjs +951 -0
  14. package/formal-verify-v3.test.mjs +1031 -0
  15. package/formal-verify-v4.test.mjs +882 -0
  16. package/formal-verify-v5.test.mjs +598 -0
  17. package/package.json +22 -2
  18. package/prompt-corpus-persona/persona-corpus.json +32 -0
  19. package/prompt-corpus-persona/persona-corpus.md +674 -0
  20. package/prompt-corpus-v2/formal-verify-v2.json +394 -0
  21. package/prompt-corpus-v2/formal-verify-v2.md +4250 -0
  22. package/prompt-corpus-v3/formal-verify-v3.json +382 -0
  23. package/prompt-corpus-v3/formal-verify-v3.md +3843 -0
  24. package/prompt-corpus-v4/formal-verify-v4.json +84 -0
  25. package/prompt-corpus-v4/formal-verify-v4.md +255 -0
  26. package/prompt-corpus-v5/prompt-corpus-v5.json +109 -5
  27. package/prompt-corpus-v5/prompt-corpus-v5.md +653 -109
  28. package/prompt-v5-integrity.test.mjs +1158 -984
  29. package/run-tests.mjs +99 -0
  30. package/vibe-math-v2/agent.cordis.yml +40 -2
  31. package/vibe-math-v2/vibe-math-v2.js +811 -21
  32. package/vibe-math-v2//345/256/236/347/216/260/346/226/271/346/241/210.md +218 -1
  33. package/vibe-math-v3/agent.cordis.yml +46 -2
  34. package/vibe-math-v3/vibe-math-v3.js +810 -21
  35. package/vibe-math-v3//345/256/236/347/216/260/346/226/271/346/241/210.md +104 -2
  36. package/vibe-math-v4/agent.cordis.yml +46 -4
  37. package/vibe-math-v4/vibe-math-v4.js +744 -15
  38. package/vibe-math-v4//345/256/236/347/216/260/346/226/271/346/241/210.md +255 -0
  39. package/vibe-math-v5/agent.cordis.yml +41 -5
  40. package/vibe-math-v5/vibe-math-v5.js +621 -9
  41. package/vibe-math-v5//345/256/236/347/216/260/346/226/271/346/241/210.md +131 -4
  42. package/vibe-math-v5//346/236/266/346/236/204/345/233/276.md +57 -0
  43. package//347/244/272/344/276/213/345/233/276//346/241/206/346/236/266/345/233/276-v5.svg +51 -46
@@ -181,4 +181,221 @@
181
181
  - 若判定结果介于 `0` 和 `1` 之间:更新 `a` 的正确概率为该结果,并分别向证明、证伪列表添加根据辩论得出的尽可能正确的过程/支撑信息及相应概率。
182
182
  - 辩论全程发言记录存入 `Verification_logs/` 对应日志,便于复盘与审计。
183
183
 
184
- ---
184
+ ---
185
+ ---
186
+
187
+ ## Lean 形式化验证(`formalVerify`)
188
+
189
+ > 本节实现 `docs/formal-verification.md` 中 v2/v3/v4/v5 **共用契约**;参数名、路径、
190
+ > 工具名、提示词语义、门禁规则、索引格式都与该契约一致。
191
+
192
+ **为什么要有它**:多代理交叉验证的本质是**共识**,不是**证明**。Lean 把"我认为"换成"机器已核对",
193
+ 于是验证的**审查对象**从"推导是否正确"变成**"Lean 代码是否忠实于命题原文"**(定义/对象/条件/假设/结论
194
+ 是否逐条一致)——后者人(和代理)确实审得动。注意 `passed` **不等于**命题为真:它只表示"形式化代码
195
+ 通过了内核检查",忠实性仍需 m 票审查。
196
+
197
+ ### 一、参数(四个,与其它架构同名同语义)
198
+
199
+ | 参数 | 类型 | 取值 | 默认 | 含义 |
200
+ |---|---|---|---|---|
201
+ | `formalVerify` | enum | `off` \| `encourage` \| `require` | `off` | 三档开关,见下 |
202
+ | `leanCommand` | string | 任意可执行文件名 | `lean` | 要执行的 Lean 可执行文件(例:`lake`) |
203
+ | `leanArgs` | string[] | —— | `[]` | 插在 `.lean` 文件名**之前**的附加参数(例:`["env","lean"]` 配合 `leanCommand="lake"`) |
204
+ | `leanTimeoutMs` | integer | 正整数(下限 1000) | `120000` | 单次 Lean 运行的超时上限(毫秒) |
205
+
206
+ - 四个参数都出现在:`vibe_math_set_params` 的 schema、`PARAM_SCHEMA`
207
+ (`vibe_math_setup` / `vibe_math_template` / `/vibe setup` 的参数表)、`vibe_math_status`
208
+ 与 `vibe_math_report` 的可读参数表,并随 `vibe_math_setting.json` 持久化。
209
+ - **校验规则**:`formalVerify` 非三档之一 → 回退 `off`(**绝不**回退到更强的档位:一个拼写
210
+ 错误若静默启用强制形式化,会让所有结论被门禁拦下);非正的 `leanTimeoutMs` → 删除该键并回退
211
+ 默认值;空白的 `leanCommand` → 回退 `lean`。
212
+ - **模式是动态的**:所有与档位相关的提示词文本都在**构造提示词的那一刻**由 `params.formalVerify`
213
+ 现算(`formalPromptBlock` / `formalWorkLine`),不写进任何"入职时冻结"的快照;运行中切换档位
214
+ 后,下一条提示词立即反映新模式。
215
+
216
+ ### 二、三档语义
217
+
218
+ - **`off`(默认)= 真正的无操作**:提示词里不出现任何 Lean 字样;验证流程、门禁、归档行为与
219
+ 改动前完全一致(卡片里也不写形式化行)。三个 Lean 工具**仍然注册**(注册是静态的),
220
+ 只是框架不告诉代理它们存在;人/代理主动调用时照常工作。
221
+ - **`encourage` = 鼓励但不强制**:验证提示词注入"先判断实现难度,能形式化就优先写 Lean;
222
+ 一旦 Lean 通过,你唯一需要确认的就是**忠实性**";平时工作提示词注入"顺手形式化"段落
223
+ (把常用/可能复用的对象、假设、新定义归档到全局库,写之前先 `lean_lib` 查重)。
224
+ **不设门禁**:没有任何 Lean 产物时验证照常收口。
225
+ - **`require` = 强制 + 门禁**:注入同样的文本但语气为"必须",并在"写 Verified 卡片/判定定论"
226
+ 这**唯一的收口点**加门禁——对象的形式化状态必须是 `passed`(有 Lean 产物且最近一次运行
227
+ `exitCode === 0`)或 `blocked`(代理给出了显式难度判断/阻塞原因,`note` 非空);
228
+ 否则本次裁定**不生效**:记为 `undecided`(原因 `formal-required`)、写入 `Formal/TODO.md`、
229
+ 在活动日志里公告、**不写** Verified 卡片、**不改变**对象原有的概率/权重字段
230
+ (`布尔估计` / `已解决` / `优先级` 一律保持原状),对象留在原库,可形式化后再次提议验证。
231
+ 门禁是**兜底**:正常情况下验证提示词已先告知表决者要么形式化、要么记录阻塞。
232
+
233
+ ### 三、路径布局
234
+
235
+ ```
236
+ <VibeMath 根>/
237
+ ├─ Formal/ # 全局可复用 Lean 库(跨项目,故意在项目树之外)
238
+ │ ├─ Lib/<name>.lean + Lib/Index.md # 可复用定义/对象/假设
239
+ │ └─ Proved/<name>.lean + Proved/Index.md # 已成立的命题/引理(机器已核对)
240
+ └─ Projects/<项目>/
241
+ ├─ Formal/<对象id>.lean # 该对象的形式化工作文件
242
+ ├─ Formal/Index.md # 对象 → 状态 → 文件 → 归档证明 → 运行结果 → 难度判断
243
+ ├─ Formal/TODO.md # require 模式下的「形式化待办」
244
+ └─ Verified/Lean/<对象id>.lean # 归档证明:与定论卡片同处 Verified/
245
+ ```
246
+
247
+ - 文件 id 一律过 v2 既有的 id 安全化函数 `safeId`(去分隔符、去 `..`),防止路径穿越。
248
+ - `lean_run` 只接受位于 **`<VibeMath 根>`** 之内的路径。边界是 VibeMath 根而**不是**项目根:
249
+ 全局库有意放在项目树之外,所以"爬出项目但仍留在 VibeMath 内"合法;爬出 VibeMath 根之上、
250
+ 或一个不相干的绝对路径/Windows 绝对路径,一律拒绝(`V2_INVALID_ARGUMENT`)。
251
+ 实现用纯词法规范化(`normalizeAbsPath` + `leanAbsPath`),不做文件系统访问——
252
+ 单纯的 `startsWith(root)` 挡不住 `…/Projects/../../../../etc/evil.lean`。
253
+
254
+ ### 四、对象的形式化记录与持久化
255
+
256
+ 每个对象一条 `formal` 记录:`{status: none|attempted|passed|blocked, file, proof, decision, note, run:{at,ok,exitCode,ms,stdoutTail,stderrTail}, updatedAt}`。
257
+ v2 **没有会话投影**,所以记录与待办一起持久化在 v2 自己的状态文件
258
+ `VibeMath_State/formal.json`(由既有 `readJson`/`writeJson` 读写,随 `saveAll` 落盘、`loadState`
259
+ 读回),因此 `resume` 之后门禁不会"失忆"。索引 `Formal/Index.md` 是它的人类可读镜像。
260
+
261
+ **两套 id 的对齐**:验证对象用 rId(如 `r-pGate`、`r-q1-s0`),而代理归档时给的是对象 id
262
+ (如 `pGate`)。`lean_archive` 在写归档记录的同时同步 `r-<对象id>` 的验证记录;
263
+ 门禁与提示词取记录时两个方向都认(`formalGateRecord`),避免"代理确实形式化了,门禁却仍
264
+ 按未尝试处理"的假阴性。
265
+
266
+ ### 五、三个工具
267
+
268
+ | 工具 | 作用 |
269
+ |---|---|
270
+ | `vibe_math_lean_run` | 在 `<VibeMath 根>` 内的一个 `.lean` 文件上执行工具链并原样回报:`{ok, exitCode, signal, ms, command, stdout, stderr, file}`;`target=<对象 id>` 时同时记录该对象的运行结果。**绝不向调度循环抛异常**:工具链缺失 → `LEAN_NOT_FOUND`;宿主无 `subprocess` 服务 → `NO_SUBPROCESS`;spawn 失败 → `LEAN_SPAWN_FAILED`;超时 → `LEAN_TIMEOUT` |
271
+ | `vibe_math_lean_archive` | `kind='def'` → 全局 `Formal/Lib/<name>.lean`;`kind='lemma'` → 全局 `Formal/Proved/<name>.lean`(两者都会重建对应 `Index.md`;`run:false` 可跳过执行)。`kind='proof'` → `Formal/<target>.lean`,且**该文件最近一次运行通过**时再写 `Verified/Lean/<target>.lean` 并把对象标为 `passed`,否则标为 `attempted`。`kind='blocked'` → 记录显式难度判断/阻塞原因(`note` 空 → 拒绝)并把对象标为 `blocked` |
272
+ | `vibe_math_lean_lib` | 扫描并重建三处索引(项目 `Formal/Index.md`、全局 `Lib/Index.md`、全局 `Proved/Index.md`),返回可复用库清单,供代理写新定义前查重;`refresh:false` 时只读不重建 |
273
+
274
+ 参数 schema:
275
+
276
+ | 工具 | 参数 |
277
+ |---|---|
278
+ | `lean_run` | `file`(string, 必填)、`target`(string)、`timeout_ms`(integer) |
279
+ | `lean_archive` | `kind`(enum: `def`\|`lemma`\|`proof`\|`blocked`, 必填)、`name`(string)、`target`(string)、`content`(string)、`from`(string)、`note`(string)、`run`(boolean) |
280
+ | `lean_lib` | `refresh`(boolean) |
281
+
282
+ ### 六、错误码(本节新增,全部为**可读结果**而非异常)
283
+
284
+ | 错误码 | 触发条件 |
285
+ |---|---|
286
+ | `V2_INVALID_ARGUMENT` | `file` 缺失 / 非 `.lean` / 越界路径;`kind` 非法;缺 `name`(`def`/`lemma`)或 `target`(`proof`/`blocked`);`content` 与 `from` 皆缺;`blocked` 的 `note` 为空;`from` 越界 |
287
+ | `V2_NOT_FOUND` | 目标 `.lean` 文件不存在(越界但仍在 VibeMath 内的路径也走这里) |
288
+ | `V2_WRITE_FAILED` | 归档文件写入失败 |
289
+ | `LEAN_NOT_FOUND` | `resolveExecutable(leanCommand)` 失败(宿主上没装工具链) |
290
+ | `LEAN_SPAWN_FAILED` | `subprocess.spawn` 抛错 |
291
+ | `LEAN_RUN_FAILED` | `handle.done` 拒绝 |
292
+ | `LEAN_TIMEOUT` | 运行耗时达到 `leanTimeoutMs` |
293
+ | `NO_SUBPROCESS` | 宿主没有 `subprocess` 服务 |
294
+
295
+ ### 七、提示词注入点
296
+
297
+ | 提示词 | 注入内容 |
298
+ |---|---|
299
+ | `verifierReviewPrompt(r)` | `formalPromptBlock(r.rId)`(非 off 档)+ 判定指引 |
300
+ | `verifierDebatePrompt(r, transcript)` | 同上——**辩论轮也必须带**,否则辩论阶段的代理会丢掉"审查对象已变成忠实性"这一变化 |
301
+ | `solverPrompt` / `explorerPrompt` / `rederivePrompt` | `formalWorkLine()`("顺手形式化",`off` 档为空串) |
302
+ | `vibe_math_status` / `vibe_math_report` / 卡片 / 索引 | 可读参数表、形式化记录概览、`- 形式化: <状态>` |
303
+
304
+ 对象已 `passed` 时,验证提示词改为强调**忠实性审查**("你不需要重新检查推导");
305
+ 已 `blocked` 时改为要求复核"这个阻塞判断是否成立"。
306
+
307
+ ### 八、门禁的实现位置
308
+
309
+ - **`writeVerifiedCardIfNeeded(p)`**(命题卡片)与 **`writeVerifiedProblemCardIfNeeded(q)`**
310
+ (问题卡片)——"写 Verified 卡片"的唯一收口点。返回 `{ok, deferred}`;被门禁搁置时
311
+ 调用方**不得**再做 `布尔估计` / `已解决` / `优先级` 的提升。
312
+ - **`settleVerdict(t, v)`**——验证裁定立即生效的那条路径。命题(`r.kind==='proposition'`)、
313
+ 命题证明(`'prop-proof'`,仅当 v=1)、问题解法(`'problem-solution'`,仅当 v=1)
314
+ 三条分支都在任何状态改动**之前**调用 `formalVerdictDeferred`;被搁置时直接返回,
315
+ 对象状态分毫不动。
316
+ - **`processStatusUpdates`**——概率=1 的**自动收口**路径。先申请卡片写入许可
317
+ (`writeVerifiedCardIfNeeded(p, target)` / `writeVerifiedProblemCardIfNeeded(q, true)`),
318
+ 拿到许可才写入 `布尔估计` / `已解决` / `优先级`;被搁置则整条跳过。
319
+
320
+ ### 九、回执通道(`formal` 字段)与 `defect` 语义
321
+
322
+ > 对应契约 §4、§4.1、§6.3 与 §10 的第 8–11 条。**教训**:本特性首版只在提示词里写了
323
+ > "请在回执的 formal 字段写明难度判断",框架**从不解析**它——难度判断静默消失,而套件只断言
324
+ > "那句话存在",于是 177 条断言全绿却守着一条**死通道**。措辞断言不等于行为断言。
325
+
326
+ #### 9.1 回执真的会被解析并落库
327
+
328
+ - 回执契约里出现 `formal` 字段(`formalJsonField` 注入 `verifierReviewPrompt` 与
329
+ `verifierDebatePrompt` 的 JSON 示例;`formalReplyNote()` 注入 solver/explorer 工作轮的
330
+ "顺手形式化"段落):`{"formal":{"target":"p-x","decision":"used|blocked|defect","file":"Formal/p-x.lean","note":"难度判断/阻塞原因/具体偏差"}}`。
331
+ - `absorbFormalFromReply(parsed, memberId)` 接受**顶层 `formal`** 与 **`meta.formal`** 两种位置,
332
+ 在三条解析回执的路径上都被调用:`handleVerifier`(验证者)、`handleSolver`、`handleExplorer`
333
+ (工作轮)。验证者路径里的调用**先于**裁定:`defect` 必须先把记录降级,紧随其后的
334
+ `settleVerdict` 才会在 `require` 档把本次裁定正确地记为未定论。
335
+ - `decision` 的落库:`blocked` → 记录 `blocked` + `note`;`defect` → 见 9.2;`used` → `attempted` + `file`。
336
+ - **拒绝规则**(返回 `V2_INVALID_ARGUMENT`,并在活动日志里公告,**不留下任何记录**):
337
+ `blocked`/`defect` 的 `note` 为空;缺 `target`(`safeId('')` 会返回 `anon`,绝不允许凭空造记录);
338
+ `decision` 不在三值之内。回执通道**绝不抛异常**进调度循环:一次记账失败不该吞掉一次表决。
339
+
340
+ #### 9.2 `defect`:忠实性缺陷**不是**"命题为假"
341
+
342
+ `passed` 只保证"这段 Lean 代码通过了内核检查",不保证它说的就是命题想说的。表决者逐条核对后
343
+ 发现形式化写窄了/写宽了/换了对象/漏了条件时,那是**形式化不合格**,不是命题被证伪:
344
+
345
+ - 若让表决者"发现偏差 → 投 0",框架记下的是"**该命题为假**"——用求真更严格的机制,
346
+ 反而伪造出一个错误的否定结论。
347
+ - 若只记成 `blocked`,门禁会**放行**(`blocked` 本就允许定论),等于带着一个坏形式化去定论。
348
+
349
+ 因此 `defect` 是独立的一档,**语义固定**为:
350
+
351
+ 1. **表决者**:不得投 `1` 或 `0`;给一个严格介于 0 与 1 之间的值(记为弃权),在 `Reason` 里写清偏差,
352
+ 并用回执 `formal:{decision:'defect', note:'<具体偏差>'}` 记录(`note` 必填)。
353
+ 2. **框架**(`formalDefectDowngrade`):把形式化记录**降级为 `attempted`**(无论此前是 `passed`
354
+ 还是 `blocked`)、清空 `proof`、**删除** `Verified/Lean/<id>.lean`(工作文件 `Formal/<id>.lean`
355
+ 保留,代码不丢)、`note` 记入记录与 `Formal/TODO.md`、在活动日志里公告。
356
+ 3. **`require` 档**:降级后 `formalGateOk` 为假 ⇒ 本次裁定**不定论**(`formal-required`),
357
+ 对象进入「形式化待办」。修正形式化并重新跑通后再投票。
358
+ 4. **唯一可以投 0 的情形**:表决者**独立于这份 Lean 代码**也能确定命题为假(`Reason` 必须写清独立理由)。
359
+ 提示词里因此明确写着"发现任何偏差,不要投 0",并且**不再出现**"偏离 → 0"这类指令。
360
+
361
+ #### 9.3 两套 id 必须同时同步
362
+
363
+ 验证记录以 **rId**(`r-pGate`、`r-q1-s0`)为键,而归档/索引/卡片读的可能是 **对象 id**(`pGate`)。
364
+ 回执通道(`blocked` / `defect` / `used`)通过 `putFormalBothIds` 一次写全两侧:回执点名的那个 id、
365
+ 它对应的另一侧、以及同一对象的其它验证别名(`r-<id>`、`r-<id>-s0`、`r-<id>-pf1`、`r-<id>-rf2`,
366
+ 复用 `syncVerificationTarget` 的既有扫描)。id 解析只有一处 `formalObjectIdOf`(门禁合并查询
367
+ `formalGateRecord` 也用它),**不新造第三套映射**。只写一侧的后果是静默错位:`defect` 只写到验证 id 上,
368
+ 对象记录仍是 `passed`,`formalGateRecord` 从对象侧读回 `passed`、卡片照旧写"Lean 通过"。
369
+
370
+ #### 9.4 提示词的三条硬要求
371
+
372
+ - **工具名一律写全称**:注入文本里只出现注册名 `vibe_math_lean_run` / `vibe_math_lean_archive` /
373
+ `vibe_math_lean_lib`;**不得**出现 `lean_run` / `lean_archive` / `lean_lib` 这类缩写——
374
+ 那不是注册名,代理照抄会调用一个不存在的工具(工具自己返回的 `hint` 同样算注入文本)。
375
+ - **归档可复用定义/引理前必须先跑通**:`vibe_math_lean_archive run=true` 或先 `vibe_math_lean_run`;
376
+ 跑不通的代码不得进入 `Formal/Lib` / `Formal/Proved`,否则"可复用库"会被不编译的定义污染。
377
+ - **工具链缺失时的出路必须写出来**:`LEAN_NOT_FOUND` 时把代码写下来归档,并在回执的 `note` 里写明
378
+ "宿主无 Lean 工具链"——这算显式阻塞原因,`require` 档可以据此放行,代理不会因为装不了 Lean 而卡死。
379
+
380
+ #### 9.5 人可读语料
381
+
382
+ `prompt-corpus-v2/formal-verify-v2.json` 与 `.md` 由套件落盘(契约 §10.10):框架**真正发出**的每条提示词
383
+ 原文,工作区路径归一化为 `<WS>`、VibeMath 根归一化为 `<VIBEMATH>`,因此可 diff、不泄露本机路径。
384
+ 覆盖 off 档(无任何 Lean 文字)、encourage/require 的表决初评与辩论、`passed` 后的忠实性分支、
385
+ 工作轮的「顺手形式化」段落与 formal 回执契约。套件带 `V2_CORPUS_DIR` 覆盖;当 `V2_PLUGIN` 指向
386
+ 变异副本(灵敏度探针)时语料写到临时目录,避免把变异文本写进仓库。
387
+
388
+ ### 十、测试
389
+
390
+ `formal-verify-v2.test.mjs`(仓库根):用 **mock `subprocess` 服务**(假 Lean:文件中含
391
+ `sorry` 或 `-- FAIL` 时 exit 1,否则 exit 0)跑通真实代码路径,覆盖 `off` 无操作、
392
+ 参数校验与运行中切换、`encourage` 对 review/debate/work 三类提示词的注入、
393
+ `passed` 后切忠实性措辞(并断言**不含**"偏离 → 0"、不含缩写工具名)、三个工具(绿灯/红灯/缺文件/
394
+ 越界/非 .lean/缺工具链/四种归档/索引重建、`blocked` 必须有 note)、`require` 门禁(命题与问题两条
395
+ 收口点、搁置→形式化→放行、卡片记录形式化状态、`resume` 后不遗忘、`encourage` 不设门禁),
396
+ 以及**回执通道的行为断言**(契约 §10.8/§10.9):把带 `formal:{decision:'blocked'|'defect', note}`
397
+ 的真实回执喂给框架,断言记录真的落库(`blocked` → `blocked` 且两套 id 同步;`defect` → `attempted`
398
+ + `proof` 清空 + `Verified/Lean/<id>.lean` 被删 + `Formal/TODO.md` 出现条目 + 公告),断言缺 `note`
399
+ 被 `V2_INVALID_ARGUMENT` 拒绝且不落记录,断言 `defect` 之后 `require` 档**不得定论**(无 Verified 卡片、
400
+ 命题布尔估计不变),并落盘人可读语料(§9.5)。
401
+ 套件支持 `V2_PLUGIN` 环境变量指向变异副本,供灵敏度探针使用。
@@ -44,7 +44,10 @@
44
44
  - vibe_math_set_mode {mode: manual|auto} — switch manual / auto (manual gates: 计划审批 / 裁决 / 方法晋升).
45
45
  - vibe_math_set_params {...} — tune any parameter (see vibe_math_setup; V3 additions: planningHorizon,
46
46
  plannerEnabled/plannerProvider/plannerModel/plannerPersona, planMinIntervalMs, plannerMaxFails,
47
- methodKeepIntervalMs/methodKeepEvery, methodAutoPromote, indexAutoRebuild, projectLockTimeoutMs).
47
+ methodKeepIntervalMs/methodKeepEvery, methodAutoPromote, indexAutoRebuild, projectLockTimeoutMs,
48
+ formalVerify/leanCommand/leanArgs/leanTimeoutMs — Lean 形式化验证(off = 默认不额外要求,
49
+ encourage = 按实现难度自行形式化、Lean 通过后审查对象变为忠实性,require = 同上并加结论门禁)).
50
+ - vibe_math_setup / vibe_math_save_settings / vibe_math_template — guided configuration / persist defaults / generate template.
48
51
  - vibe_math_plan {force?} — show queued plan / last plan, or force a planning round.
49
52
  - vibe_math_index — rebuild State/index.json from the Markdown knowledge base.
50
53
  - vibe_math_method_add / vibe_math_method_list — manually add / list method cards (Methods/ + global).
@@ -52,6 +55,9 @@
52
55
  - vibe_math_new_project / vibe_math_set_project / vibe_math_list_projects — per-project folders.
53
56
  - vibe_math_list_decisions / vibe_math_decide {id, action: approve|reject|override, verdict?} — resolve manual decisions.
54
57
  - vibe_math_list_agents / vibe_math_message_agent / vibe_math_interrupt_agent — inspect / steer / interrupt subagents.
58
+ - vibe_math_lean_run / vibe_math_lean_archive / vibe_math_lean_lib — Lean formal
59
+ verification (execute / archive / list the reuse library). The scheduler's child agents
60
+ use them too; they work in every mode.
55
61
 
56
62
  A /vibe slash command mirrors the main controls (/vibe start|resume|pause|abort|status|report|mode
57
63
  <auto|manual>|setup|save|add <id> <desc>|add-proposition <id> <概述>|list-propositions|methods|index|plan|lock|...).
@@ -63,6 +69,22 @@
63
69
  promoteValueThreshold auto-promote into Problems/ as "判断下述命题是否成立:<命题>" (verification
64
70
  results sync back to the source proposition); a solver-reported sub-question q_sub registers THREE
65
71
  objects (q_sub problem + judge problem + p-tmp temporary-assumption proposition) with full 来源与动机.
72
+
73
+ LEAN FORMAL VERIFICATION (formalVerify, a tunable parameter):
74
+ - 'off' (default, no extra requirement) | 'encourage' (solver/verifier agents decide by
75
+ implementation difficulty whether to formalize in Lean; once a Lean run passes, the review
76
+ subject becomes FIDELITY — do the Lean definitions/objects/conditions/assumptions/conclusion
77
+ match the proposition as stated) | 'require' (same, plus a gate: a true/false verdict is
78
+ withheld as 未定论 with reason formal-required until the object is Lean-passed or carries an
79
+ explicit, reasoned blocker record; the scheduler is never wedged by it).
80
+ - Paths: work file Formal/<id>.lean; archived proof Verified/Lean/<id>.lean; reusable
81
+ definitions VibeMath/Formal/Lib/; proved lemmas VibeMath/Formal/Proved/.
82
+ - The toolchain knobs leanCommand / leanArgs / leanTimeoutMs are tunable as well
83
+ (e.g. leanCommand='lake' with leanArgs=['env','lean']); a missing Lean binary is
84
+ reported as LEAN_NOT_FOUND and still lets the code be written and archived.
85
+ - vibe_math_status / vibe_math_report show the mode, the per-object formal status and the
86
+ formalization TODO (Formal/TODO.md). The framework never installs Lean and never judges
87
+ fidelity for you.
66
88
  When the user asks about progress, call vibe_math_report and summarize in plain language.
67
89
  suffix: Your working directory is {{cwd}}.
68
90
  text: |-
@@ -96,7 +118,10 @@
96
118
  - vibe_math_set_mode {mode: manual|auto} — switch manual / auto (manual gates: 计划审批 / 裁决 / 方法晋升).
97
119
  - vibe_math_set_params {...} — tune any parameter (see vibe_math_setup; V3 additions: planningHorizon,
98
120
  plannerEnabled/plannerProvider/plannerModel/plannerPersona, planMinIntervalMs, plannerMaxFails,
99
- methodKeepIntervalMs/methodKeepEvery, methodAutoPromote, indexAutoRebuild, projectLockTimeoutMs).
121
+ methodKeepIntervalMs/methodKeepEvery, methodAutoPromote, indexAutoRebuild, projectLockTimeoutMs,
122
+ formalVerify/leanCommand/leanArgs/leanTimeoutMs — Lean 形式化验证(off = 默认不额外要求,
123
+ encourage = 按实现难度自行形式化、Lean 通过后审查对象变为忠实性,require = 同上并加结论门禁)).
124
+ - vibe_math_setup / vibe_math_save_settings / vibe_math_template — guided configuration / persist defaults / generate template.
100
125
  - vibe_math_plan {force?} — show queued plan / last plan, or force a planning round.
101
126
  - vibe_math_index — rebuild State/index.json from the Markdown knowledge base.
102
127
  - vibe_math_method_add / vibe_math_method_list — manually add / list method cards (Methods/ + global).
@@ -104,6 +129,9 @@
104
129
  - vibe_math_new_project / vibe_math_set_project / vibe_math_list_projects — per-project folders.
105
130
  - vibe_math_list_decisions / vibe_math_decide {id, action: approve|reject|override, verdict?} — resolve manual decisions.
106
131
  - vibe_math_list_agents / vibe_math_message_agent / vibe_math_interrupt_agent — inspect / steer / interrupt subagents.
132
+ - vibe_math_lean_run / vibe_math_lean_archive / vibe_math_lean_lib — Lean formal
133
+ verification (execute / archive / list the reuse library). The scheduler's child agents
134
+ use them too; they work in every mode.
107
135
 
108
136
  A /vibe slash command mirrors the main controls (/vibe start|resume|pause|abort|status|report|mode
109
137
  <auto|manual>|setup|save|add <id> <desc>|add-proposition <id> <概述>|list-propositions|methods|index|plan|lock|...).
@@ -115,6 +143,22 @@
115
143
  promoteValueThreshold auto-promote into Problems/ as "判断下述命题是否成立:<命题>" (verification
116
144
  results sync back to the source proposition); a solver-reported sub-question q_sub registers THREE
117
145
  objects (q_sub problem + judge problem + p-tmp temporary-assumption proposition) with full 来源与动机.
146
+
147
+ LEAN FORMAL VERIFICATION (formalVerify, a tunable parameter):
148
+ - 'off' (default, no extra requirement) | 'encourage' (solver/verifier agents decide by
149
+ implementation difficulty whether to formalize in Lean; once a Lean run passes, the review
150
+ subject becomes FIDELITY — do the Lean definitions/objects/conditions/assumptions/conclusion
151
+ match the proposition as stated) | 'require' (same, plus a gate: a true/false verdict is
152
+ withheld as 未定论 with reason formal-required until the object is Lean-passed or carries an
153
+ explicit, reasoned blocker record; the scheduler is never wedged by it).
154
+ - Paths: work file Formal/<id>.lean; archived proof Verified/Lean/<id>.lean; reusable
155
+ definitions VibeMath/Formal/Lib/; proved lemmas VibeMath/Formal/Proved/.
156
+ - The toolchain knobs leanCommand / leanArgs / leanTimeoutMs are tunable as well
157
+ (e.g. leanCommand='lake' with leanArgs=['env','lean']); a missing Lean binary is
158
+ reported as LEAN_NOT_FOUND and still lets the code be written and archived.
159
+ - vibe_math_status / vibe_math_report show the mode, the per-object formal status and the
160
+ formalization TODO (Formal/TODO.md). The framework never installs Lean and never judges
161
+ fidelity for you.
118
162
  When the user asks about progress, call vibe_math_report and summarize in plain language.
119
163
 
120
164
  # ── agent-instructions ──────────────────────────────────────────────────────