clearai-dsh 0.5.2 → 0.5.3

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/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@ All notable changes to this project are recorded here. The format follows [Keep
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.5.3] — 2026-10-10
8
+
9
+ **及时构建本体、保存阶段事实,并接入原生 todo 进度。**
10
+
11
+ ### Fixed
12
+
13
+ - `Frame` 可在一次调用中提交概念、关系、实体与假设断言,先完成整体校验再写入文件。实际检验假设的计划必须引用存在的对象并包含有效的结构化断言,避免长期执行却没有图结构。
14
+ - 达到门槛且经过 L3 或更高独立评估的阶段事实可在目标结束前保存;中断后,新会话仍能恢复本体、实体和已验证事实。后续反证标记对应事实待复核,保留原范围及证据。
15
+ - 明确由 `AdvancePlan` 派发独立评估,避免主代理另外安排一轮重复审计。
16
+
17
+ ### Changed
18
+
19
+ - 删除输入框旁失效的计划跳转芯片。计划进度同步至 DSH 原生 todo,保留现有原生 goal;作废步骤不计为完成,新轮次后恢复真实计划状态。
20
+ - 假设来源保持开放,不强制假设数量。阶段升格必须有真实实体、有效断言、独立证据及无未决关键反证。
21
+
22
+ ### Migration and validation
23
+
24
+ - 沿用 STATE_VERSION 21 和已有账本事件,不改写历史账本。新增内核选项 `ontologyFeedback`、`nativeTodoProgress`,ClearAI 预设启用,独立直接挂载内核时默认关闭。
25
+ - 完整本机工程套件通过,真实宿主与客户端无跳过;安装包逐文件核对通过。隔离界面确认原生 goal 与 todo 展示,旧跳转芯片已移除。
26
+ - 合成 DeepSeek 工程探针验证了空图建模、独立核验、结案前事实保存和新会话读取。这是机制回归,不代表长任务收益或成本验收通过;对照长测结论仍待完成。
27
+ - 本版为正式功能更新;手动安装可指定 `clearai-dsh@0.5.3`。
28
+
7
29
  ## [0.5.2] — 2026-10-10
8
30
 
9
31
  **知识的适用范围、跨会话复检与可靠审计闭环。**
package/README.md CHANGED
@@ -22,8 +22,8 @@ ClearAI is an **ontology discovery and exploration platform**, built on two core
22
22
 
23
23
  ```bash
24
24
  # Install (npm package, prebuilt — no build step, no allowBuilds prompt)
25
- dsh plugin --profile web add clearai-dsh@0.5.2
26
- # or in the app: Plugins → Add plugin → clearai-dsh@0.5.2
25
+ dsh plugin --profile web add clearai-dsh@0.5.3
26
+ # or in the app: Plugins → Add plugin → clearai-dsh@0.5.3
27
27
  ```
28
28
 
29
29
  Restart `dsh web`, then pick **ClearAI** in the preset picker at the top of a new session. That is the whole setup. [Full install notes ↓](#install-and-use)
@@ -86,12 +86,12 @@ ClearAI does **not** claim recursive self-improvement. It provides the epistemic
86
86
 
87
87
  **Recommended — install it in the app, with the version pinned:**
88
88
 
89
- In the sidebar open **Plugins → Add plugin**, enter `clearai-dsh@0.5.2`, and install. That is DSH's own plugin manager: it hands what you type to pnpm, checks that the package declares a bundle and is compatible with this host, and applies it live. (The Settings page **插件列表 / Plugins** is the read-only inventory — installing happens on the sidebar's Plugins page.)
89
+ In the sidebar open **Plugins → Add plugin**, enter `clearai-dsh@0.5.3`, and install. That is DSH's own plugin manager: it hands what you type to pnpm, checks that the package declares a bundle and is compatible with this host, and applies it live. (The Settings page **插件列表 / Plugins** is the read-only inventory — installing happens on the sidebar's Plugins page.)
90
90
 
91
91
  **Or from a terminal — the same install:**
92
92
 
93
93
  ```bash
94
- dsh plugin --profile web add clearai-dsh@0.5.2
94
+ dsh plugin --profile web add clearai-dsh@0.5.3
95
95
  ```
96
96
 
97
97
  This installs the prebuilt package from the npm registry. Nothing is compiled on your machine, so there is no `allowBuilds` grant to approve — the plugin is ready the moment the command returns.
package/README.zh-CN.md CHANGED
@@ -22,8 +22,8 @@ ClearAI 是一个**本体发现与探索平台**,核心由两个概念支撑
22
22
 
23
23
  ```bash
24
24
  # 安装(npm 包,预构建——无需构建步骤,不会触发 allowBuilds 授权)
25
- dsh plugin --profile web add clearai-dsh@0.5.2
26
- # 或在应用里:侧栏「插件」→ 添加插件 → clearai-dsh@0.5.2
25
+ dsh plugin --profile web add clearai-dsh@0.5.3
26
+ # 或在应用里:侧栏「插件」→ 添加插件 → clearai-dsh@0.5.3
27
27
  ```
28
28
 
29
29
  重启 `dsh web`,在新建会话顶部的模式选择器里选 **ClearAI** 即可。这就是全部步骤。[完整安装说明 ↓](#安装与使用)
@@ -86,12 +86,12 @@ ClearAI **不**声称递归自我改进。它提供的是自我改进系统所
86
86
 
87
87
  **推荐——在应用里装,并把版本钉住:**
88
88
 
89
- 侧栏打开**「插件」→ 添加插件**,填 `clearai-dsh@0.5.2`,安装。这就是 DSH 自己的插件管理器:它把你填的东西交给 pnpm,校验这个包声明了组合包、与当前宿主兼容,然后当场生效。(设置里的**插件列表**是**只读清单**;安装入口在侧栏那个「插件」页。)
89
+ 侧栏打开**「插件」→ 添加插件**,填 `clearai-dsh@0.5.3`,安装。这就是 DSH 自己的插件管理器:它把你填的东西交给 pnpm,校验这个包声明了组合包、与当前宿主兼容,然后当场生效。(设置里的**插件列表**是**只读清单**;安装入口在侧栏那个「插件」页。)
90
90
 
91
91
  **或者开终端——同一次安装:**
92
92
 
93
93
  ```bash
94
- dsh plugin --profile web add clearai-dsh@0.5.2
94
+ dsh plugin --profile web add clearai-dsh@0.5.3
95
95
  ```
96
96
 
97
97
  从 npm registry 装预构建产物。本机不跑任何编译,因此不需要批准 `allowBuilds` 授权——命令返回时插件就已经可用。
package/lib/client.js CHANGED
@@ -261,8 +261,6 @@ window.__ModuleLoader__.load({
261
261
  .clearai-btn[data-tone="warn"]{border-color:var(--dsw-alias-state-warn-primary)}
262
262
  /* 工具行里的控制(控制归工具行):照原生那一行的形状——无边框、次级文字色、悬浮才出底。
263
263
  刻意不做成我们自己那种药丸:它坐在原生「完全权限」旁边,长得像原生才不突兀。 */
264
- .clearai-toolctl{box-sizing:border-box;display:inline-flex;align-items:center;gap:2px;padding:2px 6px;border:0;border-radius:4px;background:transparent;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;cursor:pointer}
265
- .clearai-toolctl:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
266
264
  .clearai-chip{box-sizing:border-box;display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border:.5px solid var(--dsw-alias-border-l4);border-radius:999px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);font-size:11px;line-height:16px;cursor:pointer}
267
265
  .clearai-chip:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
268
266
  .clearai-tag{display:inline-block;padding:0 6px;border:.5px solid var(--dsw-alias-border-l3);border-radius:999px;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:16px;white-space:nowrap}
@@ -2230,94 +2228,6 @@ window.__ModuleLoader__.load({
2230
2228
  * 为什么要有它:工具行是要抢地盘的地方(两个字面项能占掉整行近三成,
2231
2229
  * 窄窗口下会把发送键挤到第二行)。图标能省一半宽度,而它指向的正是「世界树」那一页。
2232
2230
  */
2233
- function PlanGlyph() {
2234
- return h(
2235
- 'svg',
2236
- { width: 12, height: 12, viewBox: '0 0 12 12', 'aria-hidden': 'true', style: { flex: '0 0 auto', display: 'block' } },
2237
- h('path', { d: 'M3 2.2 V10.2', stroke: 'currentColor', strokeWidth: 1.2, fill: 'none', strokeLinecap: 'round' }),
2238
- h('path', { d: 'M3 5.2 H8.4', stroke: 'currentColor', strokeWidth: 1.2, fill: 'none', strokeLinecap: 'round' }),
2239
- h('circle', { cx: 3, cy: 2.2, r: 1.5, fill: 'currentColor' }),
2240
- h('circle', { cx: 3, cy: 9.4, r: 1.4, fill: 'none', stroke: 'currentColor', strokeWidth: 1.1 }),
2241
- h('circle', { cx: 9.2, cy: 5.2, r: 1.4, fill: 'none', stroke: 'currentColor', strokeWidth: 1.1 }),
2242
- )
2243
- }
2244
-
2245
- /**
2246
- * 计划芯片:坐在原生 plan 座位上的那一格。
2247
- *
2248
- * 只说**计划**这一件事(进度、受阻、待确认),不重复状态条已经说过的话——
2249
- * 一个事实只在一块面上说,是这个面板与原生 dock 之间的分工。
2250
- * 没有计划时渲染 `null`:座位保持空着,而不是显一个「什么都没有」的假控件。
2251
- * 它也不造第二个动词:推进的唯一动词是 `AdvancePlan`,那属于模型,不属于界面;
2252
- * 这一格能做的只有一件——把右栏的「世界树」打开。
2253
- */
2254
- function PlanChip(props) {
2255
- const data = typeof props.useProjection === 'function' ? props.useProjection('clearai') : undefined
2256
- const plan = data === null || data === undefined ? null : data.plan
2257
- if (plan === null || plan === undefined) return null
2258
- const total = plan.totalCount ?? 0
2259
- const done = plan.advancedCount ?? 0
2260
- /**
2261
- * 说人话:内部 id(`p-xxxx`)不进这一格——它对人没有信息量,只让芯片变长;
2262
- * 状态优先于数字(等人确认 / 受阻 / 已收尾都是**要人注意**的那一类)。
2263
- */
2264
- /**
2265
- * 一格只放**一个符号**:进度。要人注意的事不换符号,只换颜色。
2266
- *
2267
- * 这条工具行上的格子只承担**可点、且只有我们知道**的两句:
2268
- * 待处理 N(人门计数,点了开世界树)· 续跑停着(为什么停,人是可以处置的)。
2269
- * 「已达成 · 100%」那一类与原生目标提示说的是同一件事,不在这里重复。
2270
- */
2271
- const inboxCount = Array.isArray(data?.needYou) ? data.needYou.length : 0
2272
- const blocked = plan.blocked !== null && plan.blocked !== undefined
2273
- const attention = blocked
2274
- /**
2275
- * 符号**恒定是进度**(形状稳定才学得会):要人注意不在符号上换字,
2276
- * 而是换颜色(与世界树同一条规矩:形状说状态,别让人去猜一个 '?')。
2277
- * 「待处理 N」就在这一格(`waiting`):门开着是**事实面**上最要紧的一句,
2278
- * 而它可点——点一下开世界树,那里才看得到要裁什么。
2279
- */
2280
- /**
2281
- * 符号说**探索到了哪**:调研时是「板块 已厘清/总数」,求解时是「问题 当前/总数 · 待检验假设 N 个」;
2282
- * 没列问题也没列板块的目标(旧会话、单问题)退回步数 `N/M`。
2283
- */
2284
- const exploration = data?.exploration ?? null
2285
- const areas = Array.isArray(exploration?.areas) ? exploration.areas : []
2286
- const declared = (Array.isArray(exploration?.questions) ? exploration.questions : []).filter((question) => !question.implicit)
2287
- const current = (Array.isArray(exploration?.questions) ? exploration.questions : []).find((question) => question.id === exploration?.current) ?? null
2288
- const emergent = declared.filter((question) => question.status === 'emergent').length
2289
- const examining = current === null ? 0 : (current.counts?.examining ?? 0)
2290
- const symbol =
2291
- areas.length > 0
2292
- ? `${t('板块 ')}${areas.filter((area) => area.state === 'clear').length}/${areas.length}${emergent > 0 ? `${t(' · ')}${emergent}${t(' 个问题待您决定')}` : ''}`
2293
- : declared.length > 0 && current !== null
2294
- ? `${t('问题 ')}${declared.indexOf(current) + 1}/${declared.length}${t(' · 待检验假设 ')}${examining}${t(' 个')}`
2295
- : `${done}/${total}`
2296
- const brief = typeof plan.brief === 'string' && plan.brief.trim() !== '' ? plan.brief.trim() : null
2297
- const meaning = blocked ? t('计划受阻,待人工处理') : plan.status === 'closed' ? `${t('计划已收尾(')}${done}/${total}${t(' 步)')}` : `${t('计划已交付 ')}${done}/${total}${t(' 步')}`
2298
- /**
2299
- * 等人时**只说一句**:先「待处理 N」(人门计数),没有门才说续跑停着的原因。
2300
- * 两者是同一根轴(为什么在等人)⇒ 一格只放一个,不并列。
2301
- */
2302
- const waiting = inboxCount > 0 ? `${t('待处理 ')}${inboxCount}` : null
2303
- const attentionNow = attention || waiting !== null
2304
- return h(
2305
- 'button',
2306
- {
2307
- type: 'button',
2308
- className: 'clearai-toolctl',
2309
- disabled: props.locked === true,
2310
- title: `${meaning}${waiting === null ? '' : ` · ${waiting}`} · ${plan.id}${brief === null ? '' : ` · ${brief}`}${t('(点击打开探索货架)')}`,
2311
- 'aria-label': `${meaning}${waiting === null ? '' : ` · ${waiting}`}${t('(点击打开探索货架)')}`,
2312
- // 「要人注意」用与世界树同一族的琥珀(同一套主题令牌,不新造颜色)。
2313
- style: attentionNow ? { color: 'rgb(var(--dsw-color-warning, 245 158 11))', fontWeight: 600 } : undefined,
2314
- onClick: () => props.openExplore?.(),
2315
- },
2316
- h(PlanGlyph, null),
2317
- h('span', { style: { minWidth: 14, textAlign: 'center' } }, symbol),
2318
- waiting === null ? null : h('span', { style: { marginLeft: 6, fontSize: 11.5 } }, waiting),
2319
- )
2320
- }
2321
2231
 
2322
2232
  /**
2323
2233
  * 一步的**人话**名字:`do` 是模型写的那句「做什么」,截短了放进一行。
@@ -3066,29 +2976,8 @@ window.__ModuleLoader__.load({
3066
2976
  h(LocalizedExplore, { ...props, openSpectator, openPreview: openPreviewFor(props), send: sendFor(props), openFacts: () => openPanel(props, 'clearai-facts') }),
3067
2977
  )
3068
2978
  occupy('conversation.view', () => ({ id: 'clearai-facts', order: 20, label: t('本体') }), (props) => h(LocalizedFacts, { ...props, openSpectator, openPreview: openPreviewFor(props), send: sendFor(props), openExplore: () => openPanel(props, 'clearai-explore') }))
3069
- /**
3070
- * **计划面坐在原生 plan 那个座位上**。
3071
- *
3072
- * 为什么是这个座位:DSH 把「计划」这件事的控件固定在 composer 工具行的
3073
- * `conversation.input.plan` 上(`dsh-client-ui-plan` 的「Plan ×」),而它只在
3074
- * `plan/mode` 投影存在时才渲染——我们的预设不挂 `plan-mode`(计划是我们自己的事实,
3075
- * 不是每回合的策略),所以那个座位在本模式下**一直空着**:位置在,没人说话。
3076
- * 把自己的计划面放进去,就是「同一个位置、两种预设各自的计划面」,而不是另起一块浮层。
3077
- *
3078
- * 两条实现约束(读原生实现量出来的,不是猜的):
3079
- * · 这个座位是 `single`:同 priority 再注册会**直接抛错**(核心的报错原文是
3080
- * 「register at a different priority to shadow it (lowest renders)」),
3081
- * 所以必须给一个更低的 priority 才遮蔽得住;
3082
- * · 遮蔽的代价是零——原生那个 occupant 在本模式下本来 `return null`。
3083
- * 而我们只在**当前会话是本预设**时占座(`occupy`),会话切走就还给它。
3084
- */
3085
- occupy('conversation.input.plan', { priority: -1 }, (props) => h(PlanChip, { ...props, openExplore: () => openPanel(props, 'clearai-explore') }))
3086
- // 输入框下方的常驻派生条(运行态卡在人这一侧的对应物)
3087
- /**
3088
- * **输入框下那一条不再注册**:它说的话(阶段 / 完成度 / 当前步)与原生目标提示、
3089
- * 与工具行那颗计划 chip 重复 ✗,却**独占一行把输入框顶上去** ✗。
3090
- * 唯一可点、且只有我们知道的那件事(「待处理 N」)已经并进计划 chip(同一行,一点直达探索货架)。
3091
- */
2979
+ // Plan progress uses DSH's native todo dock; no composer chip or shadow plan slot.
2980
+
3092
2981
  ctx.effect(() => sessions.list.subscribe(() => {
3093
2982
  for (const sync of seats) sync()
3094
2983
  }), t('clearai-loop: 席位跟着会话预设进出'))
@@ -3107,7 +2996,7 @@ window.__ModuleLoader__.load({
3107
2996
  * 真的跑一遍渲染路径(捕 undefined 字段访问这类只有渲染时才炸的错)。
3108
2997
  * 仍然不是给别的包用的接口。
3109
2998
  */
3110
- exports.__components = { PlanChip, WorldTree, ExploreView, AnswerCards, QuestionBox, NextBox, EmergentActions, GraphBand, GraphInspector, NeedYou, TreeDetail, Atlas, AtlasHeader, ConclusionList, ConclusionRow, ConclusionDetail, StationBar, TrustTimeline, ClearAIMark, LOOP_LABEL, EntityCard, KnowledgeFlowBox, KnowledgeItemRow, SettledLine, CountMarks }
2999
+ exports.__components = { WorldTree, ExploreView, AnswerCards, QuestionBox, NextBox, EmergentActions, GraphBand, GraphInspector, NeedYou, TreeDetail, Atlas, AtlasHeader, ConclusionList, ConclusionRow, ConclusionDetail, StationBar, TrustTimeline, ClearAIMark, LOOP_LABEL, EntityCard, KnowledgeFlowBox, KnowledgeItemRow, SettledLine, CountMarks }
3111
3000
  /**
3112
3001
  * 测试缝之三:命题那一列的**派生**是纯函数(分组、处境、来路、证据链),
3113
3002
  * 渲染本身没法在没浏览器的地方细究——把它导出去,让测试直接断言派生结果。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clearai-dsh",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "ClearAI: an ontology-first DSH agent preset — evidence-checked research that grows into a domain ontology.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -183,6 +183,8 @@
183
183
  requireCriteriaVerdict: true
184
184
  # 停止检查:achieved 结案要按问题写结论;仍在考察中的候选与开着的未解释项须写进「尚未确定的事项」。
185
185
  requireAnswers: true
186
+ ontologyFeedback: true
187
+ nativeTodoProgress: true
186
188
  # deny_rules 十条里可移植的九条(路径越狱那条不搬:宿主沙箱已经拥有它,ClearAI 自己也说「不重复」)
187
189
  bashDenyRules: true
188
190
  # 独立评估者:spawn = fresh context(fork 会继承历史,做的人与判的人就分不开了)
@@ -200,6 +200,8 @@
200
200
  requireCriteriaVerdict: true
201
201
  # 停止检查:achieved 结案要按问题写结论;仍在考察中的候选与开着的未解释项须写进「尚未确定的事项」。
202
202
  requireAnswers: true
203
+ ontologyFeedback: true
204
+ nativeTodoProgress: true
203
205
  # deny_rules 十条里可移植的九条(路径越狱那条不搬:宿主沙箱已经拥有它,ClearAI 自己也说「不重复」)
204
206
  bashDenyRules: true
205
207
  # 独立评估者:spawn = fresh context(fork 会继承历史,做的人与判的人就分不开了)
@@ -19,6 +19,7 @@
19
19
  * P5 什么都不删 → 状态是可重放的投影;refine/void/superseded 的旧值都在
20
20
  */
21
21
 
22
+ import { createTodoMirror } from './native-todos.js'
22
23
  import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
23
24
  import { tmpdir } from 'node:os'
24
25
 
@@ -228,6 +229,8 @@ export const CONFIG_KEYS = [
228
229
  'contributions',
229
230
  'applicabilityFeedback',
230
231
  'negativeWriteback',
232
+ 'ontologyFeedback',
233
+ 'nativeTodoProgress',
231
234
  ]
232
235
 
233
236
  /**
@@ -331,6 +334,8 @@ export function apply(ctx, config = {}) {
331
334
  // Native experimental variants; published ClearAI keeps both enabled.
332
335
  applicabilityFeedback: config.applicabilityFeedback !== false,
333
336
  negativeWriteback: config.negativeWriteback !== false,
337
+ ontologyFeedback: config.ontologyFeedback === true,
338
+ nativeTodoProgress: config.nativeTodoProgress === true,
334
339
  /**
335
340
  * 连拦阈值:同一件事连续冲闸这么多次没过,计划置 blocked、停下等人。
336
341
  * **它不是预算**:它管的是证据质量,
@@ -739,7 +744,7 @@ export function apply(ctx, config = {}) {
739
744
  */
740
745
  if (typeof cwd !== 'string' || cwd === '') {
741
746
  result.missing.push(artifact)
742
- continue
747
+ continue
743
748
  }
744
749
  const absolute = isAbsolute(artifact) ? artifact : resolvePath(cwd, artifact)
745
750
  let stat = null
@@ -750,7 +755,7 @@ export function apply(ctx, config = {}) {
750
755
  }
751
756
  if (stat === null) {
752
757
  result.missing.push(artifact)
753
- continue
758
+ continue
754
759
  }
755
760
  if (stat.isDirectory()) {
756
761
  let files = 0
@@ -771,11 +776,11 @@ export function apply(ctx, config = {}) {
771
776
  // 目录在读数期间变化时,仍如实说明它不能作为物证。
772
777
  }
773
778
  result.directories.push(tr(`${artifact}(目录不是物证,含 ${files} 个文件、${bytes} 字节)`, `${artifact} (a directory is not evidence; it holds ${files} files, ${bytes} bytes)`))
774
- continue
779
+ continue
775
780
  }
776
781
  if (stat.size === 0) {
777
782
  result.empty.push(tr(`${artifact}(空文件)`, `${artifact} (empty file)`))
778
- continue
783
+ continue
779
784
  }
780
785
  const lower = artifact.toLowerCase()
781
786
  if (lower.endsWith('.json')) {
@@ -1108,7 +1113,7 @@ export function apply(ctx, config = {}) {
1108
1113
  const plain = item.trim()
1109
1114
  // 旧形状:一整段散文。**不丢**,但把它按"还没有结构"如实标注,而不是硬塞成三格。
1110
1115
  if (plain !== '') shortfalls.push({ criterion: tr('未结构化(旧式裁决)', 'unstructured (legacy verdict)'), what: plain.slice(0, 400), missing: '' })
1111
- continue
1116
+ continue
1112
1117
  }
1113
1118
  if (item === null || typeof item !== 'object') continue
1114
1119
  const criterion = String(item.criterion ?? '').trim()
@@ -1408,12 +1413,12 @@ export function apply(ctx, config = {}) {
1408
1413
  const cardPath = writeAuditCard(sessionId, audit.step, card)
1409
1414
  mutations.push({ t: 'audit/settled', id: audit.id, step: audit.step, verdict: cardPath === null ? 'unknown' : recovered.verdict.holds, holds: cardPath === null ? 'unknown' : recovered.verdict.holds, rechecks: recovered.verdict.rechecks, reuse: recovered.verdict.reuse, results: recovered.verdict.results, anomalies: recovered.verdict.anomalies, basis: recovered.verdict.basis, shortfalls: cardPath === null ? ['card_persist_failed'] : recovered.verdict.shortfalls, card_path: cardPath, digest: audit.digest ?? null })
1410
1415
  lines.push(tr(`${audit.step}:裁决从子会话日志取回(交付成立:${recovered.verdict.holds})`, `${audit.step}: verdict recovered from the child session log (holds: ${recovered.verdict.holds})`))
1411
- continue
1416
+ continue
1412
1417
  }
1413
1418
  if (recovered !== null && recovered.ok !== true) {
1414
1419
  mutations.push({ t: 'audit/settled', id: audit.id, step: audit.step, verdict: 'unknown', basis: tr(`评估者已结束,但未正常完成(${recovered.stopReason})。`, `The evaluator ended but did not complete normally (${recovered.stopReason}).`), shortfalls: ['audit_incomplete'], card_path: null, digest: audit.digest ?? null })
1415
1420
  lines.push(tr(`${audit.step}:评估者已结束、未正常完成(记为 unknown)`, `${audit.step}: the evaluator ended without completing (recorded as unknown)`))
1416
- continue
1421
+ continue
1417
1422
  }
1418
1423
  mutations.push({ t: 'audit/settled', id: audit.id, step: audit.step, verdict: 'unknown', basis: tr('评估者已结束(宿主目录报告),但其结论未能从子会话日志取回。', 'The evaluator ended (per the host catalog), but its conclusion could not be recovered from the child session log.'), shortfalls: ['auditor_ended_uncollected'], card_path: null, digest: audit.digest ?? null })
1419
1424
  lines.push(tr(`${audit.step}:评估者已结束、结论未取回(记为 unknown)`, `${audit.step}: the evaluator ended and its conclusion was not recovered (recorded as unknown)`))
@@ -2069,7 +2074,7 @@ export function apply(ctx, config = {}) {
2069
2074
  mutations.push({ t: 'fact/bounded', fact: fact.id, verdict: fit.verdict, reasons: fit.reasons, hypothesis: refuter?.id ?? null, basis: clip(basis, 300) })
2070
2075
  markFactBounded(sessionCwd(sessionId), fact, { verdict: fit.verdict, reasons: fit.reasons, basis: clip(basis, 300) })
2071
2076
  notes.push(tr(`${fact.id}:推翻它的检验${where},事实在原范围内保持成立,这处边界已记下`, `${fact.id}: the refuting test was ${where}; the fact still holds within its scope, and this boundary is recorded`))
2072
- continue
2077
+ continue
2073
2078
  }
2074
2079
  const scopeNote =
2075
2080
  fit.verdict === 'undeclared'
@@ -2089,7 +2094,7 @@ export function apply(ctx, config = {}) {
2089
2094
  if (asked.ok !== true || (!chose(asked, 'factRetract') && !chose(asked, 'factKeep'))) {
2090
2095
  const why = asked.ok === true ? tr('没选', 'no choice made') : unanswered(asked)
2091
2096
  notes.push(tr(`${fact.id} 待人复核(${why})`, `${fact.id} awaits review by a person (${why})`) + blockNativeGoal(exec.agent, BLOCK_CODES.needsHuman, tr(`事实 ${fact.id} 出现了推翻证据,等人决定撤回还是维持。`, `Fact ${fact.id} met refuting evidence; waiting for a person to retract or keep it.`)))
2092
- continue
2097
+ continue
2093
2098
  }
2094
2099
  const review = { decision: chose(asked, 'factRetract') ? 'retracted' : 'kept', reason: asked.note }
2095
2100
  mutations.push({ t: 'fact/reviewed', fact: fact.id, decision: review.decision, reason: review.reason, by: 'user' })
@@ -2506,6 +2511,8 @@ export function apply(ctx, config = {}) {
2506
2511
  * 工具结果出去之前,把这一拍的变更折一遍、写负向条目:这一拍之后会话若就此中断,条目也已在盘上。
2507
2512
  * 写不出来不影响工具结果。
2508
2513
  */
2514
+ const syncNativeTodos = createTodoMirror({ session: id => ctx.get('sessions')?.get?.(id), isChild: isSpawnedChild, warn: message => ctx.logger?.warn?.(message) })
2515
+
2509
2516
  function afterTool(exec, value) {
2510
2517
  const mutations = Array.isArray(value?.mutations) ? value.mutations : []
2511
2518
  if (mutations.length === 0) return value
@@ -2514,7 +2521,10 @@ export function apply(ctx, config = {}) {
2514
2521
  const hostService = host()
2515
2522
  if (hostService === undefined) return value
2516
2523
  const preview = previewOf(hostService, sessionId, mutations)
2517
- if (preview !== null) writeBack(sessionId, preview.state, preview.derived ?? null)
2524
+ if (preview !== null) {
2525
+ writeBack(sessionId, preview.state, preview.derived ?? null)
2526
+ if (CFG.nativeTodoProgress) syncNativeTodos(sessionId, preview.state)
2527
+ }
2518
2528
  } catch (error) {
2519
2529
  ctx.logger?.warn?.(`clearai kernel: 负向条目回写失败 ${String(error?.message ?? error).slice(0, 160)}`)
2520
2530
  }
@@ -2723,6 +2733,7 @@ export function apply(ctx, config = {}) {
2723
2733
  properties: {
2724
2734
  concepts: { type: 'array', items: { type: 'object' }, description: '{id, label, gloss, kind: category|measure|phenomenon, unit?}' },
2725
2735
  relations: { type: 'array', items: { type: 'object' }, description: '{id, label, kind: affects|measures|defines|manifests_as, domain?, range, shape?, check?}' },
2736
+ entities: { type: 'array', items: { type: 'object' }, description: '{id, type, label, basis, provenance: {kind: named, ref}}; definitions and assertions may be submitted together' },
2726
2737
  },
2727
2738
  additionalProperties: false,
2728
2739
  },
@@ -2801,6 +2812,18 @@ export function apply(ctx, config = {}) {
2801
2812
  * 只改判据的修订若把缺省读成空清单,已被支持的判断会一起落成「已替换」,
2802
2813
  * 而替换是终态,按原文补登也回不来。要撤掉判断就显式列出留下的那几条。
2803
2814
  */
2815
+ const ontologyFiles = []
2816
+ for (const [branch, list] of [['concepts', args.ontology?.concepts], ['relations', args.ontology?.relations], ['entities', args.ontology?.entities]]) {
2817
+ for (const item of Array.isArray(list) ? list : []) {
2818
+ const id = String(item?.id ?? '').trim()
2819
+ const rel = `clear/ontology/${branch}/${id}.json`
2820
+ const problems = id === '' ? [tr('要有 id(就是文件名)', 'needs an id (the file name)')] : typeof hostService.domain?.checkFile === 'function' ? hostService.domain.checkFile(rel, item) : []
2821
+ if (problems.length > 0) return fail('ontology_rejected', tr(`本体条目 ${rel} 不能写入:\n${problems.map((line) => `- ${line}`).join('\n')}`, `Ontology entry ${rel} cannot be written:\n${problems.map((line) => `- ${line}`).join('\n')}`))
2822
+ ontologyFiles.push({ branch, id, rel, data: item })
2823
+ }
2824
+ }
2825
+ const ontologyDraft = ontologyFiles.length ? { t: 'workspace/synced', changes: ontologyFiles.map(file => ({ path: file.rel, data: file.data, digest: contentDigest(JSON.stringify(file.data)) })) } : null
2826
+ const assertionMutations = [...mutations, ...(ontologyDraft ? [ontologyDraft] : [])]
2804
2827
  const carried = args.hypotheses === undefined && state.goal !== null && state.goal.status === 'open'
2805
2828
  const hypotheses = Array.isArray(args.hypotheses)
2806
2829
  ? args.hypotheses
@@ -2819,7 +2842,8 @@ export function apply(ctx, config = {}) {
2819
2842
  } catch {
2820
2843
  knownRows = []
2821
2844
  }
2822
- const ontologyEntries = [...(Array.isArray(state.entities) ? state.entities : []), ...(Array.isArray(state.lexicon?.terms) ? state.lexicon.terms : [])]
2845
+ const ontologyState = previewOf(hostService, sessionId, assertionMutations)?.state ?? state
2846
+ const ontologyEntries = [...(ontologyState.entities ?? []), ...(ontologyState.lexicon?.terms ?? []), ...(ontologyState.lexicon?.predicates ?? [])]
2823
2847
  const openGoal = state.goal !== null && state.goal.status === 'open' ? state.goal : null
2824
2848
  const conditionsNow = normalizeScope({ conditions: args.conditions })?.conditions ?? openGoal?.conditions ?? {}
2825
2849
  /** 名称或别名完全相同的,直接认作那个实体或概念的 id;相似的只提示。 */
@@ -2863,7 +2887,7 @@ export function apply(ctx, config = {}) {
2863
2887
  if (judge === null) return fail('domain_unavailable', tr('这一层的宿主没有提供领域判据(domain facade):无法校验断言。请检查宿主半与预设是否同版本。', 'The host did not provide the domain facade, so assertions cannot be checked. Check that the host half and the preset are the same version.'))
2864
2888
  // `legacy`:迁移期一次性放行「主体还没登记」这条(`Frame` 的 `legacy:true`)——
2865
2889
  // 旧会话的断言主体在登记实例这条路存在之前就写下了,不该因为补上了机制而追溯失败。
2866
- const problems = judge.validateAssertions(sessionId, hypothesis.assertions, { legacy, mutations })
2890
+ const problems = judge.validateAssertions(sessionId, hypothesis.assertions, { legacy, mutations: assertionMutations })
2867
2891
  if (problems.length > 0) {
2868
2892
  return fail('assertions_rejected', tr(`这条假设的断言不能成立(先在 clear/ontology/ 下写好用到的概念、关系与主体实体文件,或改断言):\n${problems.map((item) => `- ${item}`).join('\n')}`, `This judgment's assertions do not hold (first write the concepts, relations and subject entity files they use under clear/ontology/, or change the assertions):\n${problems.map((item) => `- ${item}`).join('\n')}`))
2869
2893
  }
@@ -2971,16 +2995,7 @@ export function apply(ctx, config = {}) {
2971
2995
  * **本体随立题写入**(`ontology`):逐个文件用宿主半的 `domain.checkFile` 校验,全部过了才写盘。
2972
2996
  * 为什么放进 Frame:模型要另写文件时,本体总被排到最后、最后没写;立题时写,预测和候选才有出处。
2973
2997
  */
2974
- const ontologyFiles = []
2975
- for (const [branch, list] of [['concepts', args.ontology?.concepts], ['relations', args.ontology?.relations]]) {
2976
- for (const item of Array.isArray(list) ? list : []) {
2977
- const id = String(item?.id ?? '').trim()
2978
- const rel = `clear/ontology/${branch}/${id}.json`
2979
- const problems = id === '' ? [tr('要有 id(就是文件名)', 'needs an id (the file name)')] : typeof hostService.domain?.checkFile === 'function' ? hostService.domain.checkFile(rel, item) : []
2980
- if (problems.length > 0) return fail('ontology_rejected', tr(`本体条目 ${rel} 不能写入:\n${problems.map((line) => `- ${line}`).join('\n')}`, `Ontology entry ${rel} cannot be written:\n${problems.map((line) => `- ${line}`).join('\n')}`))
2981
- ontologyFiles.push({ branch, id, rel, data: item })
2982
- }
2983
- }
2998
+
2984
2999
  for (const file of ontologyFiles) {
2985
3000
  const target = sessionFile(sessionId, 'clear', 'ontology', file.branch, `${file.id}.json`)
2986
3001
  if (target === null) return fail('workspace_unavailable', tr('这一刻拿不到会话的工作目录,本体条目没有写入。', 'The session workspace is unavailable right now; the ontology entries were not written.'))
@@ -3045,6 +3060,7 @@ export function apply(ctx, config = {}) {
3045
3060
  const claim = hypothesis.claim.trim()
3046
3061
  const carried = idByClaim.get(claimKey(claim))
3047
3062
  if (carried !== undefined) reused.add(carried)
3063
+ const hAbout = canonicalAbout(mergeAbout(hypothesis.about, CFG.ontologyFeedback ? (hypothesis.assertions ?? []).flatMap(a => [a.subject?.id, a.subject?.type, a.predicate, ...(a.object?.kind === 'instance' ? [a.object.value] : [])]).filter(Boolean) : []))
3048
3064
  const given = typeof hypothesis.name === 'string' ? hypothesis.name.trim() : ''
3049
3065
  const kept = carried === undefined ? '' : String(existing.find((item) => item.id === carried)?.name ?? '')
3050
3066
  return {
@@ -3062,7 +3078,7 @@ export function apply(ctx, config = {}) {
3062
3078
  ...(typeof hypothesis.question === 'string' && hypothesis.question.trim() !== '' ? { question: hypothesis.question.trim() } : {}),
3063
3079
  /** 适用范围(在哪里成立),与推翻条件分开;没写就在升格时取立题的 conditions。 */
3064
3080
  ...(normalizeScope(hypothesis.scope) !== null ? { scope: normalizeScope(hypothesis.scope) } : {}),
3065
- ...(canonicalAbout(hypothesis.about).length > 0 ? { about: canonicalAbout(hypothesis.about) } : {}),
3081
+ ...(hAbout.length > 0 ? { about: hAbout } : {}),
3066
3082
  ...(usesOf(hypothesis).length > 0 ? { uses: usesOf(hypothesis) } : {}),
3067
3083
  version: index + 1,
3068
3084
  }
@@ -3536,99 +3552,7 @@ export function apply(ctx, config = {}) {
3536
3552
  }
3537
3553
  }
3538
3554
  }
3539
- const threshold = levelIndexOf(goal.promote_at_level)
3540
- const promoted = []
3541
- /** 升格时第三道校验没过的判断:不升格,回执里写清卡在哪。 */
3542
- const held = []
3543
- for (const hypothesis of derived.hypotheses) {
3544
- /**
3545
- * 只升格**这个目标**的判断,且每条只升格一次:上一个目标的判断状态仍是 alive,
3546
- * 不挡的话下一次结案会把它再写一遍(同一条结论两个事实文件)。
3547
- */
3548
- if (typeof hypothesis.goal === 'string' && hypothesis.goal !== goal.id) continue
3549
- if ((state.facts ?? []).some((fact) => fact.hypothesis === hypothesis.id)) continue
3550
- if (hypothesis.status !== 'alive' && hypothesis.status !== 'proposed') continue
3551
- if (hypothesis.refutations > 0) continue
3552
- const atClose = judged.get(hypothesis.id)
3553
- if (atClose?.verdict === 'refute') continue
3554
- const reached = levelIndexOf(hypothesis.supportedLevel) >= threshold
3555
- if (!reached && atClose?.verdict !== 'support') continue
3556
- const factLevel = reached ? hypothesis.supportedLevel : goal.promote_at_level
3557
- const assertions = Array.isArray(hypothesis.assertions) ? hypothesis.assertions : null
3558
- /**
3559
- * **第三道校验(升格时)**:断言涉及的谓词、类型、主体此刻都要在本体文件里成立。
3560
- * 平时跨文件的问题只提示(模型改一组文件时中间态必然不一致);写进长期知识这一刻不行。
3561
- */
3562
- if (assertions !== null && assertions.length > 0) {
3563
- let problems = []
3564
- try {
3565
- problems = hostService.domain?.validateAssertions?.(sessionId, assertions, { mutations }) ?? []
3566
- } catch (error) {
3567
- problems = [tr(`校验这一刻做不了:${String(error?.message ?? error).slice(0, 160)}`, `Could not check right now: ${String(error?.message ?? error).slice(0, 160)}`)]
3568
- }
3569
- if (problems.length > 0) {
3570
- held.push(`${quote(handleOf(hypothesis))}${tr(':', ': ')}${problems.map(String).join(tr(';', '; '))}`)
3571
- continue
3572
- }
3573
- }
3574
- const factId = `f-${Math.random().toString(36).slice(2, 8)}`
3575
- const evidence = evidenceFor(state, hypothesis.id)
3576
- .filter((item) => item.verdict === 'support')
3577
- .map((item) => item.id)
3578
- if (atClose?.verdict === 'support') evidence.push(atClose.evidence)
3579
- /**
3580
- * 升格这一刻它用到的词条的含义指纹:之后谁改了定义,这条事实就知道要复核。
3581
- * 「用到」= 断言引用的,加上主张与边界原文里按词面提到的(模型很少写断言,见 fingerprintDefinitions)。
3582
- */
3583
- let definitions = null
3584
- try {
3585
- const aboutIds = mergeAbout(hypothesis.about, goal.about)
3586
- const entityTypes = (state.entities ?? []).filter((entity) => aboutIds.includes(entity.id)).map((entity) => entity.type)
3587
- const said = `${hypothesis.claim ?? ''}\n${hypothesis.refute_when ?? ''}\n${[...aboutIds, ...entityTypes].join(' ')}`
3588
- const found = hostService.domain?.definitions?.(sessionId, assertions ?? [], mutations, said) ?? null
3589
- definitions = found !== null && Object.keys(found).length > 0 ? found : null
3590
- } catch {
3591
- definitions = null
3592
- }
3593
- /**
3594
- * **适用范围与推翻条件分开存**:范围取判断自己写的,缺的维度用立题的 conditions 补;
3595
- * 都没有就如实是 null(「范围未声明」)。推翻条件另存在 `refute_when`。
3596
- */
3597
- const scopeSpec = mergeScope(hypothesis.scope, { conditions: goal.conditions ?? {} })
3598
- const scope = scopeSpec === null ? null : tr(scopeText(scopeSpec, 'zh'), scopeText(scopeSpec, 'en'))
3599
- /** 涉及的实体或量:判断自己写的加上立题的,文件查找按它们取到这条事实。 */
3600
- const about = mergeAbout(hypothesis.about, goal.about)
3601
- const evidenceRecords = [...state.evidence, ...mutations.filter((item) => item.t === 'evidence/recorded')].filter((item) => evidence.includes(item.id))
3602
- const record = { id: factId, goal: goal.id, hypothesis: hypothesis.id, text: hypothesis.claim, about, scope, scope_spec: scopeSpec, refute_when: hypothesis.refute_when ?? null, level: factLevel ?? null, evidence, evidence_records: evidenceRecords, assertions, definitions, ...(typeof hypothesis.use === 'string' ? { use: hypothesis.use, calculation: calculationSnapshot(sessionId, hypothesis.use) } : {}) }
3603
- const path = persistFact(sessionId, record)
3604
- /**
3605
- * 事实带上**适用范围**(`scope` 是给人读的一行,`scope_spec` 是可比较的形状)与**推翻条件**:
3606
- * 没有范围的事实,下一轮无从判断是否适用。它们与出处(证据 id)、等级一起进事实库与货架。
3607
- */
3608
- mutations.push({
3609
- t: 'fact/promoted',
3610
- id: factId,
3611
- goal: goal.id,
3612
- /**
3613
- * **身份与内容一起定型**:`hypothesis` 是产出它的那条假设(按 id 关联,
3614
- * 措辞改了也认得出),`assertions` 是这条事实的类型化内容(没写就是 null)。
3615
- * 断言只在**升格这一刻**落地——旧事实不会被回溯改写。
3616
- */
3617
- hypothesis: hypothesis.id,
3618
- text: hypothesis.claim,
3619
- about,
3620
- scope,
3621
- scope_spec: scopeSpec,
3622
- refute_when: hypothesis.refute_when ?? null,
3623
- level: factLevel ?? null,
3624
- evidence,
3625
- assertions,
3626
- definitions,
3627
- ...(typeof hypothesis.use === 'string' ? { use: hypothesis.use } : {}),
3628
- path,
3629
- })
3630
- promoted.push({ id: factId, claim: hypothesis.claim })
3631
- }
3555
+ const { promoted, held } = promoteFacts(hostService, sessionId, state, derived, goal, judged, mutations)
3632
3556
  /** 评估者判为支持的经验写成文件;别的如实说出来,不写。 */
3633
3557
  const lessonVerdicts = new Map((audit.lessons ?? []).map((item) => [item.lesson, item]))
3634
3558
  const keptLessons = []
@@ -3678,6 +3602,106 @@ export function apply(ctx, config = {}) {
3678
3602
  * 每个会话每一拍把这个目录同步进自己的账(`workspace/synced`),于是别的会话升格的事实
3679
3603
  * 在这里也是「已知」,复核结论(撤回 / 维持)也写在同一个文件上。
3680
3604
  */
3605
+ function promoteFacts(hostService, sessionId, state, derived, goal, judged, mutations, { partial = false, eligible = new Set() } = {}) {
3606
+ const threshold = levelIndexOf(goal.promote_at_level)
3607
+ const promoted = []
3608
+ /** 升格时第三道校验没过的判断:不升格,回执里写清卡在哪。 */
3609
+ const held = []
3610
+ for (const hypothesis of derived.hypotheses) {
3611
+ /**
3612
+ * 只升格**这个目标**的判断,且每条只升格一次:上一个目标的判断状态仍是 alive,
3613
+ * 不挡的话下一次结案会把它再写一遍(同一条结论两个事实文件)。
3614
+ */
3615
+ if (typeof hypothesis.goal === 'string' && hypothesis.goal !== goal.id) continue
3616
+ if ((state.facts ?? []).some((fact) => fact.hypothesis === hypothesis.id)) continue
3617
+ if (hypothesis.status !== 'alive' && hypothesis.status !== 'proposed') continue
3618
+ if (hypothesis.refutations > 0) continue
3619
+ const atClose = judged.get(hypothesis.id)
3620
+ if (partial && ((hypothesis.unlanded?.length ?? 0) > 0 || !eligible.has(hypothesis.id) || !(hypothesis.assertions?.length) ||
3621
+ !evidenceFor(state, hypothesis.id).some(e => e.verdict === 'support' && e.evaluator === 'independent' && levelIndexOf(e.level) >= Math.max(3, threshold)))) continue
3622
+ if (atClose?.verdict === 'refute') continue
3623
+ const reached = levelIndexOf(hypothesis.supportedLevel) >= threshold
3624
+ if (!reached && atClose?.verdict !== 'support') continue
3625
+ const factLevel = reached ? hypothesis.supportedLevel : goal.promote_at_level
3626
+ const assertions = Array.isArray(hypothesis.assertions) ? hypothesis.assertions : null
3627
+ /**
3628
+ * **第三道校验(升格时)**:断言涉及的谓词、类型、主体此刻都要在本体文件里成立。
3629
+ * 平时跨文件的问题只提示(模型改一组文件时中间态必然不一致);写进长期知识这一刻不行。
3630
+ */
3631
+ if (assertions !== null && assertions.length > 0) {
3632
+ let problems = []
3633
+ try {
3634
+ problems = hostService.domain?.validateAssertions?.(sessionId, assertions, { mutations }) ?? ['domain unavailable']
3635
+ } catch (error) {
3636
+ problems = [tr(`校验这一刻做不了:${String(error?.message ?? error).slice(0, 160)}`, `Could not check right now: ${String(error?.message ?? error).slice(0, 160)}`)]
3637
+ }
3638
+ if (problems.length > 0) {
3639
+ held.push(`${quote(handleOf(hypothesis))}${tr(':', ': ')}${problems.map(String).join(tr(';', '; '))}`)
3640
+ continue
3641
+ }
3642
+ }
3643
+ const factId = `f-${Math.random().toString(36).slice(2, 8)}`
3644
+ const evidence = evidenceFor(state, hypothesis.id)
3645
+ .filter((item) => item.verdict === 'support')
3646
+ .map((item) => item.id)
3647
+ if (atClose?.verdict === 'support') evidence.push(atClose.evidence)
3648
+ /**
3649
+ * 升格这一刻它用到的词条的含义指纹:之后谁改了定义,这条事实就知道要复核。
3650
+ * 「用到」= 断言引用的,加上主张与边界原文里按词面提到的(模型很少写断言,见 fingerprintDefinitions)。
3651
+ */
3652
+ let definitions = null
3653
+ try {
3654
+ const aboutIds = mergeAbout(hypothesis.about, goal.about)
3655
+ const entityTypes = (state.entities ?? []).filter((entity) => aboutIds.includes(entity.id)).map((entity) => entity.type)
3656
+ const said = `${hypothesis.claim ?? ''}\n${hypothesis.refute_when ?? ''}\n${[...aboutIds, ...entityTypes].join(' ')}`
3657
+ const found = hostService.domain?.definitions?.(sessionId, assertions ?? [], mutations, said) ?? null
3658
+ definitions = found !== null && Object.keys(found).length > 0 ? found : null
3659
+ } catch {
3660
+ definitions = null
3661
+ }
3662
+ /**
3663
+ * **适用范围与推翻条件分开存**:范围取判断自己写的,缺的维度用立题的 conditions 补;
3664
+ * 都没有就如实是 null(「范围未声明」)。推翻条件另存在 `refute_when`。
3665
+ */
3666
+ const scopeSpec = mergeScope(hypothesis.scope, { conditions: goal.conditions ?? {} })
3667
+ const scope = scopeSpec === null ? null : tr(scopeText(scopeSpec, 'zh'), scopeText(scopeSpec, 'en'))
3668
+ /** 涉及的实体或量:判断自己写的加上立题的,文件查找按它们取到这条事实。 */
3669
+ const about = mergeAbout(hypothesis.about, goal.about)
3670
+ const evidenceRecords = [...state.evidence, ...mutations.filter((item) => item.t === 'evidence/recorded')].filter((item) => evidence.includes(item.id))
3671
+ const record = { id: factId, goal: goal.id, hypothesis: hypothesis.id, text: hypothesis.claim, about, scope, scope_spec: scopeSpec, refute_when: hypothesis.refute_when ?? null, level: factLevel ?? null, evidence, evidence_records: evidenceRecords, assertions, definitions, ...(typeof hypothesis.use === 'string' ? { use: hypothesis.use, calculation: calculationSnapshot(sessionId, hypothesis.use) } : {}) }
3672
+ const path = persistFact(sessionId, record)
3673
+ if (path === null) { held.push(`${handleOf(hypothesis)}: fact persistence failed`); continue }
3674
+ /**
3675
+ * 事实带上**适用范围**(`scope` 是给人读的一行,`scope_spec` 是可比较的形状)与**推翻条件**:
3676
+ * 没有范围的事实,下一轮无从判断是否适用。它们与出处(证据 id)、等级一起进事实库与货架。
3677
+ */
3678
+ mutations.push({
3679
+ t: 'fact/promoted',
3680
+ id: factId,
3681
+ goal: goal.id,
3682
+ /**
3683
+ * **身份与内容一起定型**:`hypothesis` 是产出它的那条假设(按 id 关联,
3684
+ * 措辞改了也认得出),`assertions` 是这条事实的类型化内容(没写就是 null)。
3685
+ * 断言只在**升格这一刻**落地——旧事实不会被回溯改写。
3686
+ */
3687
+ hypothesis: hypothesis.id,
3688
+ text: hypothesis.claim,
3689
+ about,
3690
+ scope,
3691
+ scope_spec: scopeSpec,
3692
+ refute_when: hypothesis.refute_when ?? null,
3693
+ level: factLevel ?? null,
3694
+ evidence,
3695
+ assertions,
3696
+ definitions,
3697
+ ...(typeof hypothesis.use === 'string' ? { use: hypothesis.use } : {}),
3698
+ path,
3699
+ })
3700
+ promoted.push({ id: factId, claim: hypothesis.claim })
3701
+ }
3702
+ return { promoted, held }
3703
+ }
3704
+
3681
3705
  function persistFact(sessionId, record) {
3682
3706
  const file = sessionFile(sessionId, 'clear', 'knowledge', 'facts', `${record.id}.json`)
3683
3707
  if (file === null) return null
@@ -3863,6 +3887,17 @@ export function apply(ctx, config = {}) {
3863
3887
  function writeBack(sessionId, state, derived) {
3864
3888
  if (isSpawnedChild(sessionId) || !CFG.negativeWriteback) return []
3865
3889
  if (state === null || state === undefined) return []
3890
+ if (CFG.ontologyFeedback) for (const hypothesis of derived?.hypotheses ?? []) {
3891
+ if (!hypothesis.refutations) continue
3892
+ for (const saved of state.facts ?? []) {
3893
+ if (saved.hypothesis !== hypothesis.id) continue
3894
+ const fact = findFact(sessionId, state, saved.id)
3895
+ const scope = mergeScope(hypothesis.scope, { conditions: state.goal?.conditions ?? {} })
3896
+ if (!fact || ['out_of_scope', 'out_of_range'].includes(compareScope(fact.scope_spec, scope).verdict)) continue
3897
+ const evidence = evidenceFor(state, hypothesis.id).filter(e => e.verdict === 'refute').at(-1)
3898
+ persistRechecks(sessionId, fact, [{ kind: 'hypothesis_refuted', source: evidence?.id ?? hypothesis.id, detail: hypothesis.claim, evidence: evidence?.refs?.[0] ?? null }])
3899
+ }
3900
+ }
3866
3901
  const written = []
3867
3902
  for (const item of negativeItems(state, derived, { session: sessionId })) {
3868
3903
  if (['unresolved', 'defect', 'escalated'].includes(item.status)) for (const id of item.touches ?? []) {
@@ -3945,6 +3980,22 @@ export function apply(ctx, config = {}) {
3945
3980
  }
3946
3981
 
3947
3982
 
3983
+ function groundingProblem(state, tested = [], hostService, sessionId, mutations) {
3984
+ if (!CFG.ontologyFeedback || tested.length === 0) return null
3985
+ const known = new Set([...(state.entities ?? []), ...(state.lexicon?.terms ?? []), ...(state.lexicon?.predicates ?? [])].map(row => row.id))
3986
+ const hypotheses = (state.hypotheses ?? []).filter(row => tested.includes(row.id))
3987
+ const missing = mergeAbout(state.goal?.about, ...hypotheses.map(row => row.about)).filter(id => !known.has(id))
3988
+ const untyped = hypotheses.filter(row => !row.assertions?.length).map(handleOf)
3989
+ for (const hypothesis of hypotheses.filter(row => row.assertions?.length)) {
3990
+ const problems = hostService.domain?.validateAssertions?.(sessionId, hypothesis.assertions, { mutations }) ?? ['domain unavailable']
3991
+ if (problems.length) untyped.push(`${handleOf(hypothesis)}: ${problems.join('; ')}`)
3992
+ }
3993
+ if (!missing.length && !untyped.length) return null
3994
+ return fail('ontology_grounding_required', tr(
3995
+ `检验前补齐本次实际使用的图引用。未登记 id:${missing.join(', ') || '无'};缺少 assertions 的判断:${untyped.join(', ') || '无'}。用一次 Frame 修订提交 ontology.concepts / relations / entities 和假设 assertions,也可先写 clear/ontology/ 下的文件。只定义当前对象、单位和检验谓词;候选关系仍是假设,不写成已证实的实体关系。无需额外假设或完整领域图。`,
3996
+ `Ground the graph references used by this test. Unknown ids: ${missing.join(', ') || 'none'}; judgments missing assertions: ${untyped.join(', ') || 'none'}. Submit ontology.concepts / relations / entities and hypothesis assertions together in one Frame revision, or write clear/ontology/ files first. Define only the current objects, units and test predicates; candidate relations remain hypotheses, not established entity relations. No extra hypotheses or full domain graph required.`))
3997
+ }
3998
+
3948
3999
  defineTool({
3949
4000
  name: 'CreatePlan',
3950
4001
  description:
@@ -3960,7 +4011,7 @@ export function apply(ctx, config = {}) {
3960
4011
  },
3961
4012
  output: CARD_OUTPUT,
3962
4013
  async execute(args, exec) {
3963
- const call = open(exec)
4014
+ const call = open(exec, { sync: true })
3964
4015
  if (call.ok !== true) return call.response
3965
4016
  const { hostService, sessionId, state, mutations } = call
3966
4017
  const done = finish(hostService, sessionId, mutations)
@@ -3973,6 +4024,8 @@ export function apply(ctx, config = {}) {
3973
4024
  if (resolved.ok !== true) return fail('unknown_hypothesis', tr(`步骤 ${step.id} 声明的判断「${resolved.wanted}」对不上任何一条已登记的判断。`, `Step ${step.id} names the judgment "${resolved.wanted}", which matches no registered judgment. `) + hypothesisMenu(state.hypotheses))
3974
4025
  resolvedTests.set(step.id, resolved.tests)
3975
4026
  }
4027
+ const grounding = groundingProblem(state, [...resolvedTests.values()].flatMap(tests => tests?.hypotheses ?? []), hostService, sessionId, mutations)
4028
+ if (grounding) return grounding
3976
4029
  const resolvedExtras = new Map()
3977
4030
  for (const step of args.steps) {
3978
4031
  const resolved = resolveStepExtras(state, step)
@@ -4026,7 +4079,7 @@ export function apply(ctx, config = {}) {
4026
4079
  },
4027
4080
  output: CARD_OUTPUT,
4028
4081
  async execute(args, exec) {
4029
- const call = open(exec)
4082
+ const call = open(exec, { sync: true })
4030
4083
  if (call.ok !== true) return call.response
4031
4084
  const { hostService, sessionId, state, mutations } = call
4032
4085
  const done = finish(hostService, sessionId, mutations)
@@ -4040,6 +4093,8 @@ export function apply(ctx, config = {}) {
4040
4093
  if (plan.steps.some((step) => step.id === args.step.id)) return fail('duplicate_step', tr(`步骤 id 已存在:${args.step.id}`, `Step id already exists: ${args.step.id}`))
4041
4094
  const resolved = resolveTests(state.hypotheses, args.step.tests)
4042
4095
  if (resolved.ok !== true) return fail('unknown_hypothesis', tr(`步骤 ${args.step.id} 声明的判断「${resolved.wanted}」对不上任何一条已登记的判断。`, `Step ${args.step.id} names the judgment "${resolved.wanted}", which matches no registered judgment. `) + hypothesisMenu(state.hypotheses))
4096
+ const grounding = groundingProblem(state, resolved.tests?.hypotheses ?? [], hostService, sessionId, mutations)
4097
+ if (grounding) return grounding
4043
4098
  const extras = resolveStepExtras(state, args.step)
4044
4099
  if (extras.ok !== true) return fail(extras.code, extras.message)
4045
4100
  const amended = { id: args.step.id, do: args.step.do, artifacts: args.step.artifacts ?? [], done_criteria: args.step.done_criteria, tests: resolved.tests, ...(typeof args.step.expect === 'string' && args.step.expect.trim() !== '' ? { expect: args.step.expect.trim() } : {}), ...extras.extra }
@@ -4163,7 +4218,7 @@ export function apply(ctx, config = {}) {
4163
4218
  },
4164
4219
  output: CARD_OUTPUT,
4165
4220
  async execute(args, exec) {
4166
- const call = open(exec)
4221
+ const call = open(exec, { sync: true })
4167
4222
  if (call.ok !== true) return call.response
4168
4223
  const { hostService, sessionId, state, mutations } = call
4169
4224
  const done = finish(hostService, sessionId, mutations)
@@ -4187,6 +4242,8 @@ export function apply(ctx, config = {}) {
4187
4242
  mutations.length > 0 ? { mutations } : {},
4188
4243
  )
4189
4244
  }
4245
+ const grounding = groundingProblem(state, step.tests?.hypotheses ?? [], hostService, sessionId, mutations)
4246
+ if (grounding) return grounding
4190
4247
  const level = step.tests?.level ?? null
4191
4248
  const levelIndex = levelIndexOf(level)
4192
4249
 
@@ -4463,6 +4520,16 @@ export function apply(ctx, config = {}) {
4463
4520
  }
4464
4521
  mutations.push({ t: 'step/advanced', plan: plan.id, step: step.id, evidence: evidenceIds, evaluator, basis, refs: originInfo.paths, origins: originInfo.origins })
4465
4522
  mutations.push({ t: 'block/cleared', plan: plan.id, step: step.id })
4523
+ let partialNote = ''
4524
+ if (CFG.ontologyFeedback && evaluator === 'independent' && auditCardPath && !isSpawnedChild(sessionId)) {
4525
+ const preview = previewOf(hostService, sessionId, mutations)
4526
+ const current = preview?.state
4527
+ if (current?.goal?.status === 'open' && !(current.anomalies ?? []).some(a => ['open', 'escalated'].includes(a.status) && a.matters !== 'no')) {
4528
+ const saved = promoteFacts(hostService, sessionId, current, preview.derived, current.goal, new Map(), mutations, { partial: true, eligible: new Set(results.filter(r => r.verdict === 'support').map(r => r.hypothesis)) })
4529
+ if (saved.promoted.length) partialNote = tr(`\n阶段事实已保存到实体图与 clear/knowledge/facts/:${saved.promoted.map(f => f.id).join(', ')};目标仍开放。`, `\nPartial facts saved in the entity graph and clear/knowledge/facts/: ${saved.promoted.map(f => f.id).join(', ')}; the goal remains open.`)
4530
+ if (saved.held.length) partialNote += `\n${saved.held.join('; ')}`
4531
+ }
4532
+ }
4466
4533
  const outcome = results.length === 0 ? '' : `\n${tr('结果:', 'Results: ')}${results.map((item) => `${quote(handleById(state, item.hypothesis))}${tr('', ' ')}${verdictWord(item.verdict)}`).join(tr(';', '; '))}${tr('。', '.')}`
4467
4534
  const refuted = results.some((item) => item.verdict === 'refute')
4468
4535
  const factReview = refuted
@@ -4483,7 +4550,7 @@ export function apply(ctx, config = {}) {
4483
4550
  blocked: false,
4484
4551
  message:
4485
4552
  tr(`第 ${step.ordinal} 步(${step.id})已交付(${evaluator === 'independent' ? '独立评估者判的' : '你自己判的,依据已记下'})。收下的观测:${gate.confirmed.map((item) => item.ref).join(', ') || '(无)'}。`, `Step ${step.ordinal} (${step.id}) delivered (${evaluator === 'independent' ? 'judged by the independent evaluator' : 'judged by you; the basis is recorded'}). Observations accepted: ${gate.confirmed.map((item) => item.ref).join(', ') || '(none)'}.`) +
4486
- outcome +
4553
+ outcome + partialNote +
4487
4554
  expectationNote(step, opened, foundByEvaluator) +
4488
4555
  (refuted ? tr('\n推翻也是有价值的结果:它和支持一样记进证据,判断的状态由证据算。', '\nA refutation is a valuable result too: it is recorded as evidence just like support, and the judgment status is computed from the evidence.') : '') +
4489
4556
  factReview +
@@ -4874,6 +4941,7 @@ export function apply(ctx, config = {}) {
4874
4941
  const hostService = host()
4875
4942
  const state = hostService === undefined ? null : hostService.state(sessionId)
4876
4943
  const owned = state !== null && hasState(state)
4944
+ if (CFG.nativeTodoProgress && exec.name === 'todo_write' && state !== null && activePlanOf(state) !== null && !isSpawnedChild(sessionId)) return { kind: 'deny', reason: tr('当前计划的 todo 进度由系统自动同步。用 AdvancePlan 交付、RevisePlan 修改步骤;核验通过后才显示完成。', 'The current plan is mirrored to native todos automatically. Deliver with AdvancePlan or edit with RevisePlan; completion is displayed only after acceptance.') }
4877
4945
  const rawArgs = exec.arguments ?? {}
4878
4946
  let args = rawArgs
4879
4947
  if (typeof rawArgs === 'string') {
@@ -4906,7 +4974,7 @@ export function apply(ctx, config = {}) {
4906
4974
  if (suspect !== null) {
4907
4975
  return {
4908
4976
  kind: 'deny',
4909
- reason: tr(`${suspect} 由系统所有,做的人不能写(clear/evidence、clear/knowledge/facts、clear/knowledge/lessons、clear/knowledge/negatives、clear/goals、clear/ontology 的 SCHEMA.json 与货架)。事实与经验只由独立评估之后的结案写,负向条目由系统从账本生成;本体请写在 clear/ontology/concepts、relations、entities 下。`, `${suspect} is owned by the system and the worker cannot write it (clear/evidence, clear/knowledge/facts, clear/knowledge/lessons, clear/knowledge/negatives, clear/goals, and SCHEMA.json and the shelf in clear/ontology). Facts and lessons are written only when a goal concludes after independent evaluation, and negative items are generated by the system from the ledger; write the ontology under clear/ontology/concepts, relations and entities.`),
4977
+ reason: tr(`${suspect} 由系统所有,做的人不能写(clear/evidence、clear/knowledge/facts、clear/knowledge/lessons、clear/knowledge/negatives、clear/goals、clear/ontology 的 SCHEMA.json 与货架)。事实由系统在独立核验达级后写入(阶段交付或结案),经验在结案审查后写入,负向条目由系统从账本生成;本体请写在 clear/ontology/concepts、relations、entities 下。`, `${suspect} is owned by the system and the worker cannot write it (clear/evidence, clear/knowledge/facts, clear/knowledge/lessons, clear/knowledge/negatives, clear/goals, and SCHEMA.json and the shelf in clear/ontology). Facts are written by the system after qualifying independent evaluation (at step delivery or goal conclusion); lessons are written after conclusion review, and negative items are generated by the system from the ledger; write the ontology under clear/ontology/concepts, relations and entities.`),
4910
4978
  }
4911
4979
  }
4912
4980
  if (writing && hostService !== undefined) {
@@ -5086,6 +5154,7 @@ export function apply(ctx, config = {}) {
5086
5154
  try {
5087
5155
  const preview = factMutations.length > 0 ? previewOf(hostService, sessionId, factMutations) : null
5088
5156
  writeBack(sessionId, preview?.state ?? hostService.state(sessionId), preview?.derived ?? hostService.derive(sessionId))
5157
+ if (CFG.nativeTodoProgress) syncNativeTodos(sessionId, preview?.state ?? hostService.state(sessionId))
5089
5158
  } catch (error) {
5090
5159
  ctx.logger?.warn?.(`clearai: 负向条目回写失败 ${String(error?.message ?? error).slice(0, 160)}`)
5091
5160
  }
@@ -0,0 +1,35 @@
1
+ /** Native todo is a display of the ledger, never a second completion authority. */
2
+ export function planTodos(state, language = 'zh') {
3
+ const plans = (state?.plans ?? []).filter(plan => !state.goal || plan.goal === state.goal.id)
4
+ const plan = plans.find(plan => plan.status === 'active') ?? plans.at(-1)
5
+ if (!plan) return null
6
+ const open = plan.steps.find(step => step.status === 'open')
7
+ const active = plan.status === 'active' && !plan.blocked && (!state.goal || state.goal.status === 'open')
8
+ return plan.steps.filter(step => step.status !== 'void').map((step, index) => ({
9
+ content: `${index + 1}. ${String(step.do).length > 160 ? String(step.do).slice(0, 160) + '…' : step.do}${plan.blocked?.step === step.id ? (language === 'en' ? ' — blocked: ' : ' · 受阻:') + String(plan.blocked.reason ?? '').slice(0, 100) : ''}`,
10
+ status: step.status === 'advanced' ? 'completed' : active && step === open ? 'in_progress' : 'pending',
11
+ }))
12
+ }
13
+
14
+ export function createTodoMirror({ session, isChild = () => false, warn = () => {} }) {
15
+ const written = new Map()
16
+ return (id, state) => {
17
+ if (isChild(id)) return
18
+ const todos = planTodos(state, state?.language)
19
+ // No ClearAI plan: keep an unrelated native todo list intact.
20
+ if (todos === null && !written.has(id)) return
21
+ try {
22
+ const target = session(id)
23
+ if (typeof target?.append !== 'function') return
24
+ const events = target.snapshotEvents?.() ?? target.ownEvents?.() ?? []
25
+ const boundary = events.findLast?.(event => event.type === 'turn/start' || event.type === 'todo/write')
26
+ const value = JSON.stringify(todos ?? [])
27
+ if (boundary?.type === 'todo/write' && JSON.stringify(boundary.data.todos) === value) return
28
+ const turn = events.findLast?.(event => event.type === 'turn/start')?.data?.turn ?? 0
29
+ // Fallback for hosts that expose append but not their event snapshot.
30
+ if (!boundary && written.get(id) === `${turn}:${value}`) return
31
+ target.append('todo/write', { todos: todos ?? [] })
32
+ written.set(id, `${turn}:${value}`)
33
+ } catch (error) { warn(`clearai: native todo sync failed: ${error.message}`) }
34
+ }
35
+ }
@@ -44,9 +44,12 @@ You are ClearAI's research partner, helping a person get one question clear insi
44
44
 
45
45
  - **立题**:多步的活先 \`Frame\`:\`headline\` 一句话目标(≤120 字),\`done_criteria\` 第三方能清点;\`about\` 写涉及的实体或量的 id,\`conditions\` 写本次的条件(产线、时段、工况)。
46
46
  - **取用**:已有知识在 \`clear/knowledge/\`(facts、lessons、negatives)与 \`clear/ontology/\`。立题会告诉你相关条目有几条、在哪,先读再定判断;用到的写进判断的 \`uses\`,系统当场判定是否适用。初步排除可以重验;待核验、定义已变的先复检(\`retests\`)。
47
+ - **最小本体**:知识以本体与实体图为骨架。读材料时即可建立实际用到的对象、指标和口径;开始检验前,\`about\` 必须对应真实概念、关系或实体 id,被检验假设用 \`assertions\` 引用它们。可在一次 \`Frame\` 同时提交 \`ontology.concepts\`、\`relations\`、\`entities\` 和断言。实体带出处,度量带单位与口径;未知关系只作为候选断言,不直接写成已确认实体关系。无需完整领域图,也无需额外凑假设。
47
48
  - **假设**:一句主张加推翻条件,只说一件事;在哪里成立写 \`scope\`(数值范围须写单位,文字边界保持未知)。推理要用的本体(度量的口径与单位、读数如何核对、量之间如何影响)写进 \`ontology\` 或 \`clear/ontology/\`。实际计划执行的不可撤销动作写进 \`irreversible\`,禁止事项与只读检查不填这里;没有这类动作写空数组。
48
49
  - **计算或实验**:先读材料、摸清现状再立计划(\`CreatePlan\`),每步写各候选的 \`predictions\`;预测都一样的一步区分不了候选。并行交给原生 \`subagent\`,各路线声明不同的产物路径。\`AdvancePlan\` 是唯一的完成动作:判断被支持、被推翻还是说不清都算完成,结果另记为证据。改计划走 \`RevisePlan\`。
50
+ - **交付粒度**:一次小核算及其结果表通常就是一个步骤。计划进度自动同步到原生 todo,无需另调 todo_write。L3/L4 的独立评估由 \`AdvancePlan\` 自动派发;不要另立“审计步骤”、手派审计子代理或先造审计报告。\`tests.hypotheses\` 和 \`predictions.hypothesis\` 只引用已登记假设;单假设也可检验,不为填预测另造反面候选。未声明 tests 的步骤不填 results。
49
51
  - **按证据调整**:与预测或本体不符的读数写进 \`anomalies\` 或用 \`Anomaly\` 登记,去处只有解释、写明理由排除、交给人;测量或方法缺陷标 \`defect\`。
52
+ - **及时回灌**:达到升格等级、通过独立核验且没有未决关键异常的结构化判断,系统在 \`AdvancePlan\` 保存为带范围、出处的阶段事实并挂图,不用等目标结案。支持、反驳和缺陷都连接同一批真实对象;反驳只在检验范围内有效,不生成普遍逆命题。后续反证令已有事实待复核。经验仍写 \`lessons\`,涉及的对象和关系写 \`about\`;不要只留长篇报告。
50
53
  - **等级只决定谁来判**:L2 你自判;L3(可重跑)、L4(不可重复或外部)由独立评估者判,L4 还须人批准。L3 只用于答案依赖的证据。
51
54
  - **结案**:先 \`ClosePlan\` 再 \`Conclude\`。还在考察的候选与开着的未解释项,检验掉或写进尚未确定的事项并说明影响;没被证据碰过的判断记成没看过(\`unjudged\`)。最终直接采用的已有知识写进答案的 \`uses\`;会改变下次做法的写进 \`lessons\`;做不下去就 \`abandoned\`。被推翻的判断与未解的反常由系统留下,什么都不删。`,
52
55
  en: `# The loop
@@ -55,9 +58,12 @@ Meet a problem → retrieve existing knowledge and check that it applies → pro
55
58
 
56
59
  - **Framing**: multi-step work starts with \`Frame\`: \`headline\` is the goal in one sentence, \`done_criteria\` countable by a third party; \`about\` gives the ids of the entities or quantities involved, \`conditions\` this run's conditions (line, period, operating point).
57
60
  - **Retrieve**: existing knowledge lives in \`clear/knowledge/\` (facts, lessons, negatives) and \`clear/ontology/\`. Framing tells you how many related items exist and where; read them before settling the judgments, and list those you rely on in the judgment's \`uses\`; the system checks on the spot whether they apply. A preliminary exclusion may be re-tested; re-test items pending re-check or with changed definitions first (\`retests\`).
61
+ - **Minimal ontology**: knowledge is organized around the ontology and entity graph. While reading, define the objects, measures and meanings you actually use. Before testing, \`about\` must resolve to real concept, relation or entity ids, and tested hypotheses link to them through \`assertions\`. Submit \`ontology.concepts\`, \`relations\`, \`entities\` and assertions together in one \`Frame\`. Entities need provenance; measures need units and definitions. Unknown relations stay candidate assertions, never established entity relations. No full domain graph or extra hypotheses required.
58
62
  - **Hypotheses**: a one-sentence claim plus a refutation condition, one thing each; where it holds goes in \`scope\` (numeric ranges need units; text boundaries remain unknown). Write the ontology reasoning needs (a measure's definition and unit, how a reading is checked, how quantities affect one another) in \`ontology\` or under \`clear/ontology/\`. Declare planned actions that cannot be undone in \`irreversible\`; prohibitions and read-only checks do not belong there. Use an empty array when no such actions are planned.
59
63
  - **Compute or experiment**: read the material and see where things stand before planning (\`CreatePlan\`); each step gives \`predictions\` per candidate, and a step where they all predict the same cannot tell them apart. Run parallel work through the native \`subagent\`, each route declaring different output paths. \`AdvancePlan\` is the only completion action: whether the judgments were supported, refuted or left unclear, the step is complete, and results are recorded separately as evidence. Change the plan through \`RevisePlan\`.
64
+ - **Delivery size**: one small computation and its result table usually form one step. Plan progress is mirrored to native todos automatically; no separate todo_write call is needed. \`AdvancePlan\` automatically dispatches the independent L3/L4 evaluator; do not add an audit step, manually dispatch an audit subagent, or manufacture an audit report. \`tests.hypotheses\` and \`predictions.hypothesis\` refer only to registered hypotheses. A single hypothesis can be tested without inventing an opposite candidate for the prediction fields. Steps without tests take no results.
60
65
  - **Adjust on the evidence**: a reading that contradicts a prediction or the ontology goes in \`anomalies\` or is recorded with \`Anomaly\`; its only destinations are explained, ruled out with a stated reason, or handed to a person; mark a measurement or method defect with \`defect\`.
66
+ - **Write back promptly**: structured judgments that reach the promotion level, pass independent review and have no unresolved material anomalies are saved by \`AdvancePlan\` as scoped, sourced partial facts on the graph, before goal closure. Support, refutations and defects attach to the same real objects; a refutation is scoped and does not create a universal inverse claim. Later counterevidence leaves existing facts pending review. Put reusable methods in \`lessons\` with the relevant object and relation ids in \`about\`; a long report alone is insufficient.
61
67
  - **The level only decides who judges**: L2 you judge yourself; L3 (re-runnable) and L4 (unrepeatable or external) are judged by an independent evaluator, and L4 also needs a person's release. Use L3 only for evidence the answer depends on.
62
68
  - **Conclude**: \`ClosePlan\`, then \`Conclude\`. Candidates still being examined and open unexplained items are tested away or written into the open points with their effect; judgments no evidence touched are recorded as not looked at (\`unjudged\`). Put what would change next time's approach in \`lessons\`; if you cannot go on, use \`abandoned\`. Refuted judgments and unresolved anomalies are kept by the system; nothing is deleted.`,
63
69
  },