clearai-dsh 0.5.0 → 0.5.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.
- package/CHANGELOG.md +28 -0
- package/README.md +36 -11
- package/README.zh-CN.md +36 -11
- package/lib/client.js +574 -205
- package/lib/fold.js +165 -4
- package/lib/knowledge-view.js +60 -26
- package/package.json +1 -1
- package/presets/clearai/agent.cordis.yml +6 -1
- package/presets/clearai/clearai.patch.yml +6 -1
- package/presets/clearai/plugins/clearai-kernel.js +367 -52
- package/presets/clearai/plugins/prompts.js +26 -24
- package/presets/clearai/skills/clearai-loop/SKILL.md +1 -1
|
@@ -212,6 +212,8 @@ export const CONFIG_KEYS = [
|
|
|
212
212
|
'minHypotheses',
|
|
213
213
|
'requireCriteriaVerdict',
|
|
214
214
|
'requireLandedEntities',
|
|
215
|
+
'requireMeasures',
|
|
216
|
+
'requireAnswers',
|
|
215
217
|
'bashDenyRules',
|
|
216
218
|
'auditProvider',
|
|
217
219
|
'auditTimeoutMs',
|
|
@@ -338,6 +340,18 @@ export function apply(ctx, config = {}) {
|
|
|
338
340
|
* 出口两条:给主体写实体文件(`clear/ontology/entities/<id>.json`),或把断言从判断上拿掉 / 如实 abandoned。
|
|
339
341
|
*/
|
|
340
342
|
requireLandedEntities: config.requireLandedEntities === true,
|
|
343
|
+
/**
|
|
344
|
+
* **测量门**(立题;机制缺省关,preset 里开):首次立题时,本体里至少有一个度量,而且每个度量都有一条
|
|
345
|
+
* 「测量」关系写明由什么测量、读数如何核对(`check`)。真跑里唯一一条错误事实,正是把设定值回读
|
|
346
|
+
* 当成了釜温;卡上提醒了几十次「先写本体」也没有用。
|
|
347
|
+
*/
|
|
348
|
+
requireMeasures: config.requireMeasures === true,
|
|
349
|
+
/**
|
|
350
|
+
* **结论门**(结案;机制缺省关,preset 里开):`achieved` 要按问题给出结论四部分,而且每个还在考察、
|
|
351
|
+
* 从没得到支持的候选与每条开着的未解释项,都写进「尚未确定的事项」并说明它若成立答案会怎样变。
|
|
352
|
+
* 只查写没写,不判写得对不对(对不对由结案评估者核)。
|
|
353
|
+
*/
|
|
354
|
+
requireAnswers: config.requireAnswers === true,
|
|
341
355
|
bashDenyRules: config.bashDenyRules !== false,
|
|
342
356
|
auditProvider: config.auditProvider ?? 'spawn',
|
|
343
357
|
auditTimeoutMs: config.auditTimeoutMs ?? 240000,
|
|
@@ -405,7 +419,9 @@ export function apply(ctx, config = {}) {
|
|
|
405
419
|
const what = String(item?.what ?? '').trim()
|
|
406
420
|
if (what === '') continue
|
|
407
421
|
const anchor = String(item?.anchor ?? '').trim()
|
|
408
|
-
|
|
422
|
+
/** 涉及哪些量、候选假设或已升格的事实(id):点名事实的,那条事实回到「待核验」;结案时据此清点。 */
|
|
423
|
+
const touches = (Array.isArray(item?.touches) ? item.touches : []).map((ref) => String(ref ?? '').trim().slice(0, 80)).filter((ref) => ref !== '').slice(0, 12)
|
|
424
|
+
opened.push(landFact(sessionId, { t: 'anomaly/opened', id: `u-${Math.random().toString(36).slice(2, 8)}`, what: what.slice(0, 400), ...(anchor === '' ? {} : { anchor: anchor.slice(0, 80) }), ...(touches.length === 0 ? {} : { touches }), step, by }))
|
|
409
425
|
}
|
|
410
426
|
return opened
|
|
411
427
|
}
|
|
@@ -415,7 +431,7 @@ export function apply(ctx, config = {}) {
|
|
|
415
431
|
const lines = []
|
|
416
432
|
if (found.length > 0) lines.push(tr(`评估者看到 ${found.length} 处没登记的异常,已记成未解释项挂在卡上:${found.map((item) => clip(item.what, 80)).join(';')}。先弄清它们,再往下走。`, `The evaluator saw ${found.length} anomaly(ies) you did not record; they are now unexplained items on the card: ${found.map((item) => clip(item.what, 80)).join('; ')}. Sort them out before moving on.`))
|
|
417
433
|
if (opened.length > 0) lines.push(tr(`登记了 ${opened.length} 条未解释(${opened.map((item) => item.id).join('、')}):它们挂在卡上,直到被解释、写明理由排除、或交给人(Anomaly)。`, `${opened.length} unexplained item(s) recorded (${opened.map((item) => item.id).join(', ')}): they stay on the card until explained, ruled out with a reason, or handed to a person (Anomaly).`))
|
|
418
|
-
else if (typeof step?.expect === 'string' && step.expect !== '') lines.push(tr(
|
|
434
|
+
else if (typeof step?.expect === 'string' && step.expect !== '') lines.push(tr(`这一步的预测是「${clip(step.expect, 80)}」。结果与预测不符时,用 Anomaly 登记,不要强行解释。`, `This step expected "${clip(step.expect, 80)}". If the result does not match, record it with Anomaly; do not explain it away.`))
|
|
419
435
|
return lines.length === 0 ? '' : `\n${lines.join('\n')}`
|
|
420
436
|
}
|
|
421
437
|
|
|
@@ -520,6 +536,32 @@ export function apply(ctx, config = {}) {
|
|
|
520
536
|
return { ok: true, tests: { hypotheses: ids, level: normalizeLevel(tests.level) } }
|
|
521
537
|
}
|
|
522
538
|
|
|
539
|
+
/**
|
|
540
|
+
* 步骤的 `serves` 与按候选写的 `predictions`:判断名换成 id,问题 id 要真有。
|
|
541
|
+
* 返回 `{ ok, extra }`(extra 直接并进步骤),或 `{ ok: false, code, message }`。
|
|
542
|
+
*/
|
|
543
|
+
function resolveStepExtras(state, step) {
|
|
544
|
+
const extra = {}
|
|
545
|
+
const serves = String(step?.serves ?? '').trim()
|
|
546
|
+
if (serves !== '') {
|
|
547
|
+
const homes = [...(state.goal?.questions ?? []), ...(state.goal?.areas ?? [])].map((item) => item.id)
|
|
548
|
+
if (!homes.includes(serves)) return { ok: false, code: 'question_unknown', message: tr(`步骤 ${step.id} 的 serves「${serves}」不是当前目标里的问题或板块。可选:${homes.join('、') || '(目标还没有列问题:不写 serves 即归整个目标)'}`, `Step ${step.id} serves "${serves}", which is not a question or area of the current goal. Options: ${homes.join(', ') || '(the goal lists no questions: omit serves to attach to the whole goal)'}`) }
|
|
549
|
+
extra.serves = serves
|
|
550
|
+
}
|
|
551
|
+
if (Array.isArray(step?.predictions) && step.predictions.length > 0) {
|
|
552
|
+
const predictions = []
|
|
553
|
+
for (const item of step.predictions) {
|
|
554
|
+
const expect = String(item?.expect ?? '').trim()
|
|
555
|
+
if (expect === '') continue
|
|
556
|
+
const found = matchHypothesis(state.hypotheses, item?.hypothesis)
|
|
557
|
+
if (found === null) return { ok: false, code: 'unknown_hypothesis', message: tr(`步骤 ${step.id} 的预测指向的判断「${String(item?.hypothesis ?? '')}」对不上任何一条已登记的判断。`, `A prediction of step ${step.id} names the judgment "${String(item?.hypothesis ?? '')}", which matches no registered judgment. `) + hypothesisMenu(state.hypotheses) }
|
|
558
|
+
predictions.push({ hypothesis: found.id, expect: expect.slice(0, 300) })
|
|
559
|
+
}
|
|
560
|
+
if (predictions.length > 0) extra.predictions = predictions
|
|
561
|
+
}
|
|
562
|
+
return { ok: true, extra }
|
|
563
|
+
}
|
|
564
|
+
|
|
523
565
|
/** 一个已登记步骤检验的判断 id(兼容旧账本的单条写法)。 */
|
|
524
566
|
function testedBy(step) {
|
|
525
567
|
const tests = step?.tests
|
|
@@ -1866,16 +1908,26 @@ export function apply(ctx, config = {}) {
|
|
|
1866
1908
|
|
|
1867
1909
|
/** 问人时的选项文字(按会话语言给);答案两种语言都认。 */
|
|
1868
1910
|
const CHOICES = {
|
|
1911
|
+
releaseYes: ['批准此次交付', 'Approve this delivery'],
|
|
1912
|
+
releaseNo: ['暂不批准', 'Not now'],
|
|
1913
|
+
releaseCommand: ['批准执行此命令', 'Approve this command'],
|
|
1914
|
+
stallContinue: ['按缺口继续修改', 'Let it fix the gaps'],
|
|
1915
|
+
stallVoid: ['作废此步骤', 'Void this step'],
|
|
1916
|
+
factRetract: ['撤回此事实', 'Retract this fact'],
|
|
1917
|
+
factKeep: ['维持原事实', 'Keep the fact'],
|
|
1918
|
+
}
|
|
1919
|
+
/** 0.5.1 前的选项文字:旧剧本(`--answers`)与旧会话里人已选过的答案照样认。 */
|
|
1920
|
+
const LEGACY_CHOICES = {
|
|
1869
1921
|
releaseYes: ['放行这次交付', 'Release this delivery'],
|
|
1870
|
-
releaseNo: ['先不放行'
|
|
1922
|
+
releaseNo: ['先不放行'],
|
|
1871
1923
|
releaseCommand: ['放行这条命令', 'Release this command'],
|
|
1872
|
-
stallContinue: ['让它按缺口再改'
|
|
1873
|
-
stallVoid: ['作废这一步'
|
|
1874
|
-
factRetract: ['撤回这条事实'
|
|
1875
|
-
factKeep: [
|
|
1924
|
+
stallContinue: ['让它按缺口再改'],
|
|
1925
|
+
stallVoid: ['作废这一步'],
|
|
1926
|
+
factRetract: ['撤回这条事实'],
|
|
1927
|
+
factKeep: [],
|
|
1876
1928
|
}
|
|
1877
1929
|
const choiceLabel = (key) => tr(...CHOICES[key])
|
|
1878
|
-
const chose = (asked, key) => CHOICES[key].includes(asked?.choice)
|
|
1930
|
+
const chose = (asked, key) => CHOICES[key].includes(asked?.choice) || LEGACY_CHOICES[key].includes(asked?.choice)
|
|
1879
1931
|
/** 没问到人的原因,一句人话。 */
|
|
1880
1932
|
const unanswered = (asked) => (asked.reason === 'cancelled' ? tr('人把问题撤下了', 'the person withdrew the question') : tr('没有人能回答', 'nobody can answer'))
|
|
1881
1933
|
|
|
@@ -1887,8 +1939,8 @@ export function apply(ctx, config = {}) {
|
|
|
1887
1939
|
async function escalateBlocked(exec, plan, step, attempts, reason, mutations) {
|
|
1888
1940
|
const asked = await askHuman(exec, {
|
|
1889
1941
|
id: `blocked-${plan.id}-${step.id}`,
|
|
1890
|
-
header: tr('
|
|
1891
|
-
question: tr(`步骤 ${step.id}(${clip(step.do, 60)})连续 ${attempts}
|
|
1942
|
+
header: tr('此步骤受阻', 'This step is stuck'),
|
|
1943
|
+
question: tr(`步骤 ${step.id}(${clip(step.do, 60)})连续 ${attempts} 次未通过:${clip(reason, 200)}。请选择处理方式。`, `Step ${step.id} (${clip(step.do, 60)}) failed ${attempts} times in a row: ${clip(reason, 200)}. What should happen?`),
|
|
1892
1944
|
options: [
|
|
1893
1945
|
{ label: choiceLabel('stallContinue'), description: tr('模型按缺口改判据或换做法后再交;你可以补一句方向。', 'The model revises the criteria or the approach against the gaps and delivers again; you can add a hint.') },
|
|
1894
1946
|
{ label: choiceLabel('stallVoid'), description: tr('这一步不做了,带原因作废(记录保留)。', 'Drop this step and void it with a reason (the record stays).') },
|
|
@@ -1935,8 +1987,8 @@ export function apply(ctx, config = {}) {
|
|
|
1935
1987
|
for (const fact of open) {
|
|
1936
1988
|
const asked = await askHuman(exec, {
|
|
1937
1989
|
id: `fact-${fact.id}`,
|
|
1938
|
-
header: tr('
|
|
1939
|
-
question: tr(`「${clip(fact.text, 120)}
|
|
1990
|
+
header: tr('已确立的结论出现推翻证据', 'An established conclusion was refuted'),
|
|
1991
|
+
question: tr(`「${clip(fact.text, 120)}」出现推翻证据:${clip(basis, 200)}。请选择撤回此事实,或判定本次证据不可靠并维持原事实。`, `Refuting evidence arrived for "${clip(fact.text, 120)}": ${clip(basis, 200)}. Retract it, or judge this evidence unreliable and keep the fact?`),
|
|
1940
1992
|
options: [
|
|
1941
1993
|
{ label: choiceLabel('factRetract'), description: tr('它不再算已确立的结论(记录保留)。', 'It no longer counts as an established conclusion (the record stays).') },
|
|
1942
1994
|
{ label: choiceLabel('factKeep'), description: tr('这次证据不可靠,事实保留;推翻证据照样留在账上。', 'This evidence is unreliable and the fact stays; the refuting evidence stays on record too.') },
|
|
@@ -2057,6 +2109,46 @@ export function apply(ctx, config = {}) {
|
|
|
2057
2109
|
const LESSONS_REL = ['clear', 'knowledge', 'lessons']
|
|
2058
2110
|
/** 经验的四类(与 `domain-language.js` 的 `LESSON_KINDS` 同值):坑、要先核的、会骗人的捷径、先验。 */
|
|
2059
2111
|
const LESSON_KINDS = ['trap', 'check', 'shortcut', 'prior']
|
|
2112
|
+
/** 工作方式(与 `fold.js` 读的同值):广度调研 / 定向求解 / 先调研后求解。 */
|
|
2113
|
+
const FRAME_MODES = ['survey', 'solve', 'survey_then_solve']
|
|
2114
|
+
/** 问题的三种状态(与 `fold.js` 同值):在回答 / 新发现待决定 / 暂缓。 */
|
|
2115
|
+
const QUESTION_STATUS = ['open', 'emergent', 'parked']
|
|
2116
|
+
|
|
2117
|
+
/**
|
|
2118
|
+
* **测量门槛**(`CFG.requireMeasures`):首次立题时,本体里(已有文件 + 这次随立题写的)
|
|
2119
|
+
* 至少要有一个度量概念,且每个度量概念都是某条 `measures` 关系的 range、这条关系写了 `check`。
|
|
2120
|
+
*
|
|
2121
|
+
* 为什么要求:真跑里唯一一条错误事实,来自"控制器回读值被当成釜温"——缺的正是"哪个仪表测哪个量、
|
|
2122
|
+
* 怎么核对"这一条。只要求把测量说清,不要求编造对手假设。返回缺什么的说明;齐了返回 null。
|
|
2123
|
+
*/
|
|
2124
|
+
function unmeasured(state, ontologyFiles) {
|
|
2125
|
+
const entries = { concepts: new Map(), relations: new Map() }
|
|
2126
|
+
for (const [path, file] of Object.entries(state?.workspace?.files ?? {})) {
|
|
2127
|
+
const hit = /^clear\/ontology\/(concepts|relations)\/(?:.+\/)?([^/]+)\.json$/.exec(path)
|
|
2128
|
+
if (hit === null || file?.data === null || typeof file?.data !== 'object') continue
|
|
2129
|
+
entries[hit[1]].set(String(file.data.id ?? hit[2]), file.data)
|
|
2130
|
+
}
|
|
2131
|
+
for (const file of ontologyFiles) entries[file.branch].set(file.id, { ...file.data, id: file.id })
|
|
2132
|
+
const measures = [...entries.concepts.values()].filter((concept) => concept.kind === 'measure').map((concept) => String(concept.id))
|
|
2133
|
+
if (measures.length === 0) {
|
|
2134
|
+
return tr(
|
|
2135
|
+
'首次立题要在 `ontology` 里写出答案涉及的量:至少一个度量概念(`kind: "measure"`),并为每个度量写一条 `measures` 关系(domain 是仪表或方法,range 是这个量,`check` 写怎样核对读数确实是这个量)。\n本体不是收尾时补的:候选假设与预测要从它出发。',
|
|
2136
|
+
'The first Frame must write the quantities the answer involves in `ontology`: at least one measure concept (`kind: "measure"`), and for each measure a `measures` relation (domain = instrument or method, range = the quantity, `check` = how to confirm the reading really is that quantity).\nThe ontology is not an afterthought: candidates and predictions start from it.',
|
|
2137
|
+
)
|
|
2138
|
+
}
|
|
2139
|
+
const rangeOf = (relation) => (typeof relation.range === 'string' ? relation.range : String(relation.range?.term ?? relation.range?.id ?? ''))
|
|
2140
|
+
const covered = new Set(
|
|
2141
|
+
[...entries.relations.values()]
|
|
2142
|
+
.filter((relation) => relation.kind === 'measures' && String(relation.check ?? '').trim() !== '')
|
|
2143
|
+
.map(rangeOf),
|
|
2144
|
+
)
|
|
2145
|
+
const missing = measures.filter((id) => !covered.has(id))
|
|
2146
|
+
if (missing.length === 0) return null
|
|
2147
|
+
return tr(
|
|
2148
|
+
`这些度量还没有写测量方式:${missing.join('、')}。\n每个度量要有一条 \`measures\` 关系(domain 是仪表或方法,range 是这个量,\`check\` 写怎样核对读数确实是这个量,例如「与参考探头比对」)。读数是不是那个量,是事实能否成立的前提。`,
|
|
2149
|
+
`These measures have no measurement method yet: ${missing.join(', ')}.\nEach measure needs a \`measures\` relation (domain = instrument or method, range = the quantity, \`check\` = how to confirm the reading really is that quantity, e.g. "compare against the reference probe"). Whether a reading is that quantity is a precondition for any fact built on it.`,
|
|
2150
|
+
)
|
|
2151
|
+
}
|
|
2060
2152
|
const ONTOLOGY_REL = ['clear', 'ontology']
|
|
2061
2153
|
const ONTOLOGY_BRANCH_DIRS = ['concepts', 'relations', 'entities']
|
|
2062
2154
|
/** 读面有界(与 `domain-language.js` 的 `WORKSPACE_LIMITS` 同值):超出的如实报成读不成,不静默截断。 */
|
|
@@ -2373,7 +2465,7 @@ export function apply(ctx, config = {}) {
|
|
|
2373
2465
|
defineTool({
|
|
2374
2466
|
name: 'Frame',
|
|
2375
2467
|
description:
|
|
2376
|
-
'立约或修订:往当前原生 goal 上挂一份「怎样算回答了」的判据(done_criteria)与候选判断(每条一句话主张 + 一句「什么结果会推翻它」)。没有原生 goal 时会建一个,目标那一句话(headline)就是它的说法;续跑、暂停由原生 goal 管。修订必须带 reason,版本 +1,旧值全部留痕;改判据文本要带一份独立裁决。不可逆的动作写进 irreversible(
|
|
2468
|
+
'立约或修订:往当前原生 goal 上挂一份「怎样算回答了」的判据(done_criteria)与候选判断(每条一句话主张 + 一句「什么结果会推翻它」)。没有原生 goal 时会建一个,目标那一句话(headline)就是它的说法;续跑、暂停由原生 goal 管。修订必须带 reason,版本 +1,旧值全部留痕;改判据文本要带一份独立裁决。不可逆的动作写进 irreversible(匹配的命令执行前须经人工批准)。同一时间只开一个目标;它跨计划存在,一张 Plan 只承载它的一个阶段。',
|
|
2377
2469
|
parameters: {
|
|
2378
2470
|
type: 'object',
|
|
2379
2471
|
properties: {
|
|
@@ -2394,7 +2486,7 @@ export function apply(ctx, config = {}) {
|
|
|
2394
2486
|
promote_at_level: { type: 'string', enum: MODEL_LEVELS, description: '升格门槛(默认 L3)' },
|
|
2395
2487
|
irreversible: {
|
|
2396
2488
|
type: 'array',
|
|
2397
|
-
description: '不可逆的动作:做了就收不回、或结果不可重复的那几件(跑中试、下单、发出去的消息……)。每件写一句说明和它的命令特征(命令里一定会出现的一段原文)
|
|
2489
|
+
description: '不可逆的动作:做了就收不回、或结果不可重复的那几件(跑中试、下单、发出去的消息……)。每件写一句说明和它的命令特征(命令里一定会出现的一段原文)。匹配的命令执行前须经人工批准。修订目标时不传 = 不变',
|
|
2398
2490
|
items: {
|
|
2399
2491
|
type: 'object',
|
|
2400
2492
|
properties: {
|
|
@@ -2405,6 +2497,36 @@ export function apply(ctx, config = {}) {
|
|
|
2405
2497
|
additionalProperties: false,
|
|
2406
2498
|
},
|
|
2407
2499
|
},
|
|
2500
|
+
mode: { type: 'string', enum: FRAME_MODES, description: '工作方式:survey = 广度调研(先铺调研板块,摸清后再看值得深入的问题);solve = 定向求解(问题下列出候选假设,用能区分它们的检验逐个排除);survey_then_solve = 先调研后求解。修订时不传 = 不变' },
|
|
2501
|
+
questions: {
|
|
2502
|
+
type: 'array',
|
|
2503
|
+
description: '要回答的问题(可选;一个目标可以有几个,不写就把整个目标当一个问题)。调研中新发现的问题写成 status="emergent" 并挂到板块(area)下;人决定深入就改成 open,决定暂缓就改成 parked。修订时不传 = 不变,传了就是完整清单',
|
|
2504
|
+
items: {
|
|
2505
|
+
type: 'object',
|
|
2506
|
+
properties: {
|
|
2507
|
+
id: { type: 'string', description: '短 id(如 q1),判断的 question 与步骤的 serves 用它' },
|
|
2508
|
+
text: { type: 'string', description: '一句话问题' },
|
|
2509
|
+
status: { type: 'string', enum: QUESTION_STATUS, description: 'open = 在回答;emergent = 新发现、待决定;parked = 暂缓(结案时列入尚未确定的事项)' },
|
|
2510
|
+
area: { type: 'string', description: '可选:属于哪个调研板块(板块 id)' },
|
|
2511
|
+
},
|
|
2512
|
+
required: ['id', 'text'],
|
|
2513
|
+
additionalProperties: false,
|
|
2514
|
+
},
|
|
2515
|
+
},
|
|
2516
|
+
areas: {
|
|
2517
|
+
type: 'array',
|
|
2518
|
+
description: '调研板块(广度调研用;如技术路线、主要企业、成本结构)。修订时不传 = 不变,传了就是完整清单',
|
|
2519
|
+
items: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' } }, required: ['id', 'name'], additionalProperties: false },
|
|
2520
|
+
},
|
|
2521
|
+
ontology: {
|
|
2522
|
+
type: 'object',
|
|
2523
|
+
description: '本体条目,由系统校验后写进 clear/ontology/(内容与文件同形,字段见 clear/ontology/SCHEMA.json)。立题时先写清相关的量:度量(kind=measure,gloss 写口径,unit 写单位)由什么测量、读数如何核对(kind=measures 的关系,domain 是仪表或来源,range 是被测的度量,check 写核对办法);量之间如何相互影响(kind=affects 的关系,shape 写大致形状)。同 id 的文件会被替换',
|
|
2524
|
+
properties: {
|
|
2525
|
+
concepts: { type: 'array', items: { type: 'object' }, description: '概念:{id, label, gloss, kind: category|measure|phenomenon, unit?}' },
|
|
2526
|
+
relations: { type: 'array', items: { type: 'object' }, description: '关系:{id, label, kind: affects|measures|defines|manifests_as, domain?, range, shape?(affects), check?(measures)}' },
|
|
2527
|
+
},
|
|
2528
|
+
additionalProperties: false,
|
|
2529
|
+
},
|
|
2408
2530
|
hypotheses: {
|
|
2409
2531
|
type: 'array',
|
|
2410
2532
|
description:
|
|
@@ -2414,6 +2536,8 @@ export function apply(ctx, config = {}) {
|
|
|
2414
2536
|
properties: {
|
|
2415
2537
|
name: { type: 'string', description: '短名,十二个汉字或二十来个字母以内,你自己起(如「python3 能跑」)。之后说起这条判断、在别的工具里引用它,都用这个名字' },
|
|
2416
2538
|
claim: { type: 'string' },
|
|
2539
|
+
question: { type: 'string', description: '可选:属于哪个问题或调研板块(id);不写就归第一个问题' },
|
|
2540
|
+
from: { type: 'string', description: '可选:由本体里哪条关系提出(关系 id,如有形状的 affects 关系);说不出来源就写「直觉」' },
|
|
2417
2541
|
refute_when: { type: 'string' },
|
|
2418
2542
|
retests: {
|
|
2419
2543
|
type: 'string',
|
|
@@ -2476,7 +2600,7 @@ export function apply(ctx, config = {}) {
|
|
|
2476
2600
|
: carried
|
|
2477
2601
|
? state.hypotheses
|
|
2478
2602
|
.filter((item) => item.goal === state.goal.id && item.status !== 'superseded')
|
|
2479
|
-
.map((item) => ({ claim: item.claim, refute_when: item.refute_when, ...(item.name ? { name: item.name } : {}), ...(item.retests ? { retests: item.retests } : {}), ...(Array.isArray(item.assertions) ? { assertions: item.assertions } : {}) }))
|
|
2603
|
+
.map((item) => ({ claim: item.claim, refute_when: item.refute_when, ...(item.name ? { name: item.name } : {}), ...(item.retests ? { retests: item.retests } : {}), ...(Array.isArray(item.assertions) ? { assertions: item.assertions } : {}), ...(item.question ? { question: item.question } : {}), ...(item.from ? { from: item.from } : {}) }))
|
|
2480
2604
|
: []
|
|
2481
2605
|
const names = hypotheses.map((hypothesis) => (typeof hypothesis?.name === 'string' ? hypothesis.name.trim() : '')).filter((name) => name !== '')
|
|
2482
2606
|
if (new Set(names).size !== names.length) return fail('hypothesis_name_duplicate', tr('两条判断用了同一个短名:短名是用来区分判断的,换一个。', 'Two judgments share a short name; short names tell judgments apart, so pick another.'))
|
|
@@ -2590,6 +2714,44 @@ export function apply(ctx, config = {}) {
|
|
|
2590
2714
|
if (Array.isArray(args.irreversible) && irreversible.length !== args.irreversible.length) {
|
|
2591
2715
|
return fail('irreversible_invalid', tr('每件不可逆动作都要有一句说明(action)和命令特征(command,至少 3 个字符,是这类命令里一定出现的一段原文)。', 'Each irreversible action needs a one-line description (action) and a command signature (command, at least 3 characters of text that always appears in such a command).'))
|
|
2592
2716
|
}
|
|
2717
|
+
/**
|
|
2718
|
+
* **问题与板块**:修订时不传 = 不变(与判断同一条纪律)。id 不许重复;判断的 `question`
|
|
2719
|
+
* 要指向这一版里存在的问题或板块,写错了当场说清可选的有哪些。
|
|
2720
|
+
*/
|
|
2721
|
+
const questions = Array.isArray(args.questions) ? args.questions.map((item) => ({ id: String(item?.id ?? '').trim(), text: String(item?.text ?? '').trim(), status: QUESTION_STATUS.includes(item?.status) ? item.status : 'open', ...(typeof item?.area === 'string' && item.area.trim() !== '' ? { area: item.area.trim() } : {}) })) : null
|
|
2722
|
+
const areas = Array.isArray(args.areas) ? args.areas.map((item) => ({ id: String(item?.id ?? '').trim(), name: String(item?.name ?? '').trim() })) : null
|
|
2723
|
+
if ((questions ?? []).some((item) => item.id === '' || item.text === '') || (areas ?? []).some((item) => item.id === '' || item.name === '')) return fail('questions_invalid', tr('每个问题要有 id 与一句话(text);每个板块要有 id 与名字(name)。', 'Each question needs an id and one sentence (text); each area needs an id and a name.'))
|
|
2724
|
+
const homeIds = [...(questions ?? (isRevision ? (state.goal.questions ?? []) : [])), ...(areas ?? (isRevision ? (state.goal.areas ?? []) : []))].map((item) => item.id)
|
|
2725
|
+
if (new Set(homeIds).size !== homeIds.length) return fail('questions_duplicate', tr('问题与板块的 id 不能重复。', 'Question and area ids must be unique.'))
|
|
2726
|
+
const strayHome = hypotheses.find((hypothesis) => typeof hypothesis?.question === 'string' && hypothesis.question.trim() !== '' && !homeIds.includes(hypothesis.question.trim()))
|
|
2727
|
+
if (strayHome !== undefined) return fail('question_unknown', tr(`判断「${handleOf(strayHome)}」的 question「${strayHome.question}」不是这一版里的问题或板块。可选:${homeIds.join('、') || '(还没有问题或板块:先在 questions / areas 里写)'}`, `Judgment "${handleOf(strayHome)}" has question "${strayHome.question}", which is not a question or area in this version. Options: ${homeIds.join(', ') || '(none yet: write them in questions / areas first)'}`))
|
|
2728
|
+
/**
|
|
2729
|
+
* **本体随立题写入**(`ontology`):逐个文件用宿主半的 `domain.checkFile` 校验,全部过了才写盘。
|
|
2730
|
+
* 为什么放进 Frame:模型要另写文件时,本体总被排到最后、最后没写;立题时写,预测和候选才有出处。
|
|
2731
|
+
*/
|
|
2732
|
+
const ontologyFiles = []
|
|
2733
|
+
for (const [branch, list] of [['concepts', args.ontology?.concepts], ['relations', args.ontology?.relations]]) {
|
|
2734
|
+
for (const item of Array.isArray(list) ? list : []) {
|
|
2735
|
+
const id = String(item?.id ?? '').trim()
|
|
2736
|
+
const rel = `clear/ontology/${branch}/${id}.json`
|
|
2737
|
+
const problems = id === '' ? [tr('要有 id(就是文件名)', 'needs an id (the file name)')] : typeof hostService.domain?.checkFile === 'function' ? hostService.domain.checkFile(rel, item) : []
|
|
2738
|
+
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')}`))
|
|
2739
|
+
ontologyFiles.push({ branch, id, rel, data: item })
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
if (CFG.requireMeasures && !isRevision && !legacy) {
|
|
2743
|
+
const missing = unmeasured(state, ontologyFiles)
|
|
2744
|
+
if (missing !== null) return fail('measures_required', missing)
|
|
2745
|
+
}
|
|
2746
|
+
for (const file of ontologyFiles) {
|
|
2747
|
+
const target = sessionFile(sessionId, 'clear', 'ontology', file.branch, `${file.id}.json`)
|
|
2748
|
+
if (target === null) return fail('workspace_unavailable', tr('这一刻拿不到会话的工作目录,本体条目没有写入。', 'The session workspace is unavailable right now; the ontology entries were not written.'))
|
|
2749
|
+
writeTextFile(target, `${JSON.stringify({ ...file.data, id: file.id }, null, 2)}\n`)
|
|
2750
|
+
}
|
|
2751
|
+
if (ontologyFiles.length > 0) {
|
|
2752
|
+
const synced = syncWorkspace(sessionId, state)
|
|
2753
|
+
if (synced !== null) mutations.push(synced)
|
|
2754
|
+
}
|
|
2593
2755
|
/**
|
|
2594
2756
|
* **修订不许给同一句话发新身份。**
|
|
2595
2757
|
*
|
|
@@ -2622,6 +2784,8 @@ export function apply(ctx, config = {}) {
|
|
|
2622
2784
|
...(typeof hypothesis.retests === 'string' && hypothesis.retests.trim() !== '' ? { retests: hypothesis.retests.trim() } : {}),
|
|
2623
2785
|
/** 断言随假设落账;没写就是 null(加法,不是门槛)。 */
|
|
2624
2786
|
assertions: Array.isArray(hypothesis.assertions) ? hypothesis.assertions : null,
|
|
2787
|
+
...(typeof hypothesis.question === 'string' && hypothesis.question.trim() !== '' ? { question: hypothesis.question.trim() } : {}),
|
|
2788
|
+
...(typeof hypothesis.from === 'string' && hypothesis.from.trim() !== '' ? { from: hypothesis.from.trim().slice(0, 80) } : {}),
|
|
2625
2789
|
version: index + 1,
|
|
2626
2790
|
}
|
|
2627
2791
|
})
|
|
@@ -2639,6 +2803,9 @@ export function apply(ctx, config = {}) {
|
|
|
2639
2803
|
revision,
|
|
2640
2804
|
reason: isRevision ? String(args.reason).trim() : null,
|
|
2641
2805
|
hypotheses: nextHypotheses,
|
|
2806
|
+
...(FRAME_MODES.includes(args.mode) ? { mode: args.mode } : {}),
|
|
2807
|
+
...(questions !== null ? { questions } : {}),
|
|
2808
|
+
...(areas !== null ? { areas } : {}),
|
|
2642
2809
|
})
|
|
2643
2810
|
for (const dropped of existing) {
|
|
2644
2811
|
if (reused.has(dropped.id)) continue
|
|
@@ -2650,7 +2817,7 @@ export function apply(ctx, config = {}) {
|
|
|
2650
2817
|
ok: true,
|
|
2651
2818
|
code: isRevision ? 'goal_revised' : 'goal_set',
|
|
2652
2819
|
message:
|
|
2653
|
-
tr(`${isRevision ? `目标已修订(第 ${revision} 版)` : '目标已立'},${carried ? '判断沿用上一版,' : ''}登记了 ${hypotheses.length} 条判断${nextHypotheses.length === 0 ? '' : `:${nextHypotheses.map((item) => `「${handleOf(item)}」`).join('、')}`}
|
|
2820
|
+
tr(`${isRevision ? `目标已修订(第 ${revision} 版)` : '目标已立'},${carried ? '判断沿用上一版,' : ''}登记了 ${hypotheses.length} 条判断${nextHypotheses.length === 0 ? '' : `:${nextHypotheses.map((item) => `「${handleOf(item)}」`).join('、')}`}。${ontologyFiles.length > 0 ? `写入本体条目 ${ontologyFiles.length} 个。` : ''}`, `${isRevision ? `Goal revised (version ${revision})` : 'Goal set'}; ${carried ? 'judgments carried over from the last version; ' : ''}${hypotheses.length} judgment(s) registered${nextHypotheses.length === 0 ? '' : `: ${nextHypotheses.map((item) => `"${handleOf(item)}"`).join(', ')}`}.${ontologyFiles.length > 0 ? ` ${ontologyFiles.length} ontology entr${ontologyFiles.length === 1 ? 'y' : 'ies'} written.` : ''}`) +
|
|
2654
2821
|
// 原生 goal 上那一句给人看:用目标的一句话,不写 id。
|
|
2655
2822
|
attachNativeGoal(exec.agent, clip(headline === '' ? String(args.claim ?? '') : headline, 120)),
|
|
2656
2823
|
})
|
|
@@ -2677,6 +2844,78 @@ export function apply(ctx, config = {}) {
|
|
|
2677
2844
|
}
|
|
2678
2845
|
|
|
2679
2846
|
/** 交给结案评估者的那一段:待核的经验,编号 L1……,判法写在一起。 */
|
|
2847
|
+
/** 结论四部分的唯一形状:结论 / 依据 / 尚未确定的事项(各写涉及什么、对答案的影响)/ 待您决策。 */
|
|
2848
|
+
function normalizeAnswers(raw) {
|
|
2849
|
+
if (!Array.isArray(raw)) return []
|
|
2850
|
+
const lines = (list, width) => (Array.isArray(list) ? list : []).map((item) => String(item ?? '').trim().slice(0, width)).filter((item) => item !== '')
|
|
2851
|
+
return raw
|
|
2852
|
+
.map((item) => ({
|
|
2853
|
+
question: String(item?.question ?? '').trim(),
|
|
2854
|
+
conclusion: String(item?.conclusion ?? '').trim().slice(0, 600),
|
|
2855
|
+
basis: lines(item?.basis, 300).slice(0, 12),
|
|
2856
|
+
open: (Array.isArray(item?.open) ? item.open : [])
|
|
2857
|
+
.map((entry) => ({ about: lines(entry?.about, 80).slice(0, 8), effect: String(entry?.effect ?? '').trim().slice(0, 300) }))
|
|
2858
|
+
.filter((entry) => entry.effect !== '')
|
|
2859
|
+
.slice(0, 12),
|
|
2860
|
+
decide: lines(item?.decide, 300).slice(0, 6),
|
|
2861
|
+
...(typeof item?.unanswered === 'string' && item.unanswered.trim() !== '' ? { unanswered: item.unanswered.trim().slice(0, 300) } : {}),
|
|
2862
|
+
}))
|
|
2863
|
+
.filter((item) => item.conclusion !== '' || item.unanswered !== undefined)
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
/**
|
|
2867
|
+
* **停止检查**(`CFG.requireAnswers`,只在 achieved 时):决策稳健了才结案。
|
|
2868
|
+
*
|
|
2869
|
+
* 只查有没有写,不判断写得对不对(与「产物存在且格式正确」同类):
|
|
2870
|
+
* · 每个在回答的问题都有结论,或写明 `unanswered` 的原因;
|
|
2871
|
+
* · 还在考察中、从未得到支持的候选,还开着的未解释项,都要出现在某条结论的
|
|
2872
|
+
* 「尚未确定的事项」里(`open[].about` 写它的 id 或短名),并写明若它成立答案会如何改变。
|
|
2873
|
+
*
|
|
2874
|
+
* 为什么:真跑里漂移被量化、登记成未解释项,答案仍按设定温度交付并以 achieved 结案。
|
|
2875
|
+
* 返回缺项清单(每行一项);齐了返回空数组。
|
|
2876
|
+
*/
|
|
2877
|
+
function unsettledForAnswers(state, derived, answers) {
|
|
2878
|
+
const goal = state.goal
|
|
2879
|
+
const exploration = derived?.exploration ?? null
|
|
2880
|
+
const missing = []
|
|
2881
|
+
const declared = (goal.questions ?? []).filter((question) => question.status === 'open')
|
|
2882
|
+
const implicit = (goal.questions ?? []).length === 0 && (goal.areas ?? []).length === 0
|
|
2883
|
+
const answered = (id) => answers.some((answer) => answer.question === id) || (implicit && answers.length > 0)
|
|
2884
|
+
if (implicit && answers.length === 0) missing.push(tr('目标还没有结论:`answers` 至少写一条(结论 / 依据 / 尚未确定的事项 / 待您决策)。', 'The goal has no conclusion yet: write at least one entry in `answers` (conclusion / basis / open points / decisions for the user).'))
|
|
2885
|
+
for (const question of declared) if (!answered(question.id)) missing.push(tr(`问题 ${question.id}「${clip(question.text, 60)}」没有结论:写结论,或用 \`unanswered\` 写明为何未能回答。`, `Question ${question.id} "${clip(question.text, 60)}" has no conclusion: write one, or say why it could not be answered in \`unanswered\`.`))
|
|
2886
|
+
const about = new Set(answers.flatMap((answer) => answer.open.flatMap((entry) => entry.about)))
|
|
2887
|
+
for (const question of exploration?.questions ?? []) {
|
|
2888
|
+
for (const candidate of question.candidates ?? []) {
|
|
2889
|
+
if (candidate.state !== 'examining' || candidate.supportedLevel !== null) continue
|
|
2890
|
+
if (about.has(candidate.id) || about.has(candidate.name)) continue
|
|
2891
|
+
missing.push(tr(`候选假设「${candidate.name}」仍在考察中、未得到支持:写进「尚未确定的事项」(about 写「${candidate.name}」),说明若它成立答案会如何改变;或先检验它。`, `Candidate hypothesis "${candidate.name}" is still being examined and has no support: put it in the open points (about: "${candidate.name}") and say how the answer would change if it holds; or test it first.`))
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
for (const anomaly of (state.anomalies ?? []).filter((item) => item?.status === 'open')) {
|
|
2895
|
+
if (about.has(anomaly.id)) continue
|
|
2896
|
+
missing.push(tr(`未解释项 ${anomaly.id}「${clip(anomaly.what, 60)}」还开着:写进「尚未确定的事项」(about 写 ${anomaly.id}),说明它对答案的影响,或答案已据此改写;也可以先用 Anomaly 给它一个去处。`, `Unexplained item ${anomaly.id} "${clip(anomaly.what, 60)}" is still open: put it in the open points (about: ${anomaly.id}) and say how it affects the answer, or that the answer was rewritten for it; or resolve it first with Anomaly.`))
|
|
2897
|
+
}
|
|
2898
|
+
for (const question of (goal.questions ?? []).filter((item) => item.status === 'emergent' || item.status === 'parked')) {
|
|
2899
|
+
if (about.has(question.id) || answered(question.id)) continue
|
|
2900
|
+
missing.push(tr(`问题 ${question.id}「${clip(question.text, 60)}」${question.status === 'parked' ? '已暂缓' : '待决定'}:写进「尚未确定的事项」(about 写 ${question.id})。`, `Question ${question.id} "${clip(question.text, 60)}" is ${question.status === 'parked' ? 'parked' : 'awaiting a decision'}: put it in the open points (about: ${question.id}).`))
|
|
2901
|
+
}
|
|
2902
|
+
return missing
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
/** 交给结案评估者读的结论四部分(核它与记录是否一致)。 */
|
|
2906
|
+
function answersBrief(answers) {
|
|
2907
|
+
if (answers.length === 0) return []
|
|
2908
|
+
return [
|
|
2909
|
+
tr('# 结论(做的人按问题写的四部分;请核它与记录是否一致,依据是否真在记录里)', '# Conclusions (written by the worker per question; check they match the record and that the basis is really in it)'),
|
|
2910
|
+
...answers.flatMap((answer) => [
|
|
2911
|
+
`## ${answer.question || tr('目标', 'goal')}:${answer.conclusion || tr(`未回答(${answer.unanswered})`, `unanswered (${answer.unanswered})`)}`,
|
|
2912
|
+
...answer.basis.map((line) => tr(`- 依据:${line}`, `- basis: ${line}`)),
|
|
2913
|
+
...answer.open.map((entry) => tr(`- 尚未确定(${entry.about.join('、') || '—'}):${entry.effect}`, `- open (${entry.about.join(', ') || '—'}): ${entry.effect}`)),
|
|
2914
|
+
...answer.decide.map((line) => tr(`- 待您决策:${line}`, `- for the user to decide: ${line}`)),
|
|
2915
|
+
]),
|
|
2916
|
+
]
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2680
2919
|
function lessonBrief(lessons) {
|
|
2681
2920
|
if (lessons.length === 0) return []
|
|
2682
2921
|
const kindWord = { trap: tr('坑', 'trap'), check: tr('要核的', 'check'), shortcut: tr('会骗人的捷径', 'misleading shortcut'), prior: tr('先验', 'prior') }
|
|
@@ -2693,12 +2932,32 @@ export function apply(ctx, config = {}) {
|
|
|
2693
2932
|
defineTool({
|
|
2694
2933
|
name: 'Conclude',
|
|
2695
2934
|
description:
|
|
2696
|
-
'结案:交目标验收——这是完成目标的唯一路径(原生「完成目标」会被拒)。系统**无条件**派独立评估者,拿目标判据与转写忠实度逐条核对;判据达成才结案为 achieved:原生 goal
|
|
2935
|
+
'结案:交目标验收——这是完成目标的唯一路径(原生「完成目标」会被拒)。系统**无条件**派独立评估者,拿目标判据与转写忠实度逐条核对;判据达成才结案为 achieved:原生 goal 置为完成;评估者同时逐条判尚在考察中的判断,判为支持的(或中途已达门槛的)升格为事实;各步收下的产物声明为交付卡片;随结案提议的经验(`lessons`)由评估者逐条核,支持的写进 clear/knowledge/lessons/。否则目标保持开放并回注缺口。**顺序**:achieved 之前必须先把计划收尾(`ClosePlan`)。放弃(`abandoned`)不受此限:原生 goal 置为阻塞,写明原因,由人决定结束。',
|
|
2697
2936
|
parameters: {
|
|
2698
2937
|
type: 'object',
|
|
2699
2938
|
properties: {
|
|
2700
2939
|
outcome: { type: 'string', enum: ['achieved', 'abandoned'], description: 'achieved=判据已达成;abandoned=如实说清阻塞后放弃' },
|
|
2701
2940
|
note: { type: 'string', description: '结案说明' },
|
|
2941
|
+
answers: {
|
|
2942
|
+
type: 'array',
|
|
2943
|
+
description: '结论(achieved 时按问题各写一条;目标没列问题就写一条):结论 / 依据 / 尚未确定的事项 / 待您决策。中间判断与过程不写进来。还在考察中、未得到支持的候选假设,还开着的未解释项,都要写进「尚未确定的事项」并说明若它成立答案会如何改变',
|
|
2944
|
+
items: {
|
|
2945
|
+
type: 'object',
|
|
2946
|
+
properties: {
|
|
2947
|
+
question: { type: 'string', description: '哪个问题(id);目标没列问题时可省略' },
|
|
2948
|
+
conclusion: { type: 'string', description: '结论:一两句话,带数值与适用条件' },
|
|
2949
|
+
basis: { type: 'array', items: { type: 'string' }, description: '依据:每个已采纳、已排除的候选假设或已核验的读数各一行,注明对应的实验或来源' },
|
|
2950
|
+
open: {
|
|
2951
|
+
type: 'array',
|
|
2952
|
+
description: '尚未确定的事项:每项写涉及什么(about:候选假设短名、未解释项 id 或问题 id)与对结论的影响(effect:若它成立,结论如何改变)',
|
|
2953
|
+
items: { type: 'object', properties: { about: { type: 'array', items: { type: 'string' } }, effect: { type: 'string' } }, required: ['effect'], additionalProperties: false },
|
|
2954
|
+
},
|
|
2955
|
+
decide: { type: 'array', items: { type: 'string' }, description: '待您决策:需要人决定的事项(例如是否先复测再放大)' },
|
|
2956
|
+
unanswered: { type: 'string', description: '未能回答时写明原因(此时 conclusion 可省略)' },
|
|
2957
|
+
},
|
|
2958
|
+
additionalProperties: false,
|
|
2959
|
+
},
|
|
2960
|
+
},
|
|
2702
2961
|
lessons: {
|
|
2703
2962
|
type: 'array',
|
|
2704
2963
|
maxItems: 5,
|
|
@@ -2706,7 +2965,7 @@ export function apply(ctx, config = {}) {
|
|
|
2706
2965
|
items: {
|
|
2707
2966
|
type: 'object',
|
|
2708
2967
|
properties: {
|
|
2709
|
-
text: { type: 'string', description: '一句话,下次怎么做(
|
|
2968
|
+
text: { type: 'string', description: '一句话,下次怎么做(「这类装置的关键读数先用独立来源核一次」)' },
|
|
2710
2969
|
kind: { type: 'string', enum: LESSON_KINDS, description: 'trap=会踩的坑;check=要先核的读数或假设;shortcut=省事但会骗人的做法;prior=对这类体系的先验(例如「两个因素常常耦合,先做斜向扫描」)' },
|
|
2711
2970
|
about: { type: 'array', items: { type: 'string' }, description: '涉及的装置、量或概念(短名,用来下次匹配)' },
|
|
2712
2971
|
evidence: { type: 'string', description: '这次记录里哪处表明了它(步骤、文件)' },
|
|
@@ -2808,6 +3067,17 @@ export function apply(ctx, config = {}) {
|
|
|
2808
3067
|
)
|
|
2809
3068
|
}
|
|
2810
3069
|
}
|
|
3070
|
+
const answers = normalizeAnswers(args.answers)
|
|
3071
|
+
if (CFG.requireAnswers) {
|
|
3072
|
+
const missing = unsettledForAnswers(state, derived, answers)
|
|
3073
|
+
if (missing.length > 0) {
|
|
3074
|
+
return fail(
|
|
3075
|
+
'answers_incomplete',
|
|
3076
|
+
tr(`结论还不完整,不能以 achieved 结案(只检查是否写了,不判断写得对不对):\n${missing.map((line) => `- ${line}`).join('\n')}\n探索到结论不再改变为止:未排除的可能与未解释的读数,要么检验掉,要么在结论里写明它们的影响。`, `The conclusion is incomplete and cannot close as achieved (this only checks that things are written, not whether they are right):\n${missing.map((line) => `- ${line}`).join('\n')}\nExplore until the conclusion stops changing: possibilities not ruled out and unexplained readings are either tested away or written into the conclusion with their effect.`),
|
|
3077
|
+
{ mutations },
|
|
3078
|
+
)
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
2811
3081
|
const unfinished = plan === null ? [] : plan.steps.filter((step) => step.status === 'open')
|
|
2812
3082
|
const syntheticStep = {
|
|
2813
3083
|
id: `goal:${goal.id}`,
|
|
@@ -2823,7 +3093,7 @@ export function apply(ctx, config = {}) {
|
|
|
2823
3093
|
...state.evidence.map((item) => ({ ref: `evidence:${item.id}`, bytes: 0, digest: `verdict=${item.verdict}` })),
|
|
2824
3094
|
...derived.hypotheses.map((item) => ({ ref: `hypothesis:${item.id}`, bytes: 0, digest: `${item.status}/支持到${item.supportedLevel ?? '—'}` })),
|
|
2825
3095
|
],
|
|
2826
|
-
extra: lessonBrief(proposedLessons),
|
|
3096
|
+
extra: [...answersBrief(answers), ...lessonBrief(proposedLessons)],
|
|
2827
3097
|
}
|
|
2828
3098
|
const audit = await runEvaluator(sessionId, exec.agent, plan, syntheticStep, gate, 'goal_audit', exec.signal)
|
|
2829
3099
|
mutations.push(...audit.mutations)
|
|
@@ -2931,7 +3201,7 @@ export function apply(ctx, config = {}) {
|
|
|
2931
3201
|
(hypothesis) =>
|
|
2932
3202
|
!judged.has(hypothesis.id) && (hypothesis.supportedLevel === null || hypothesis.supportedLevel === undefined) && (hypothesis.refutations ?? 0) === 0 && (hypothesis.inconclusive ?? 0) === 0,
|
|
2933
3203
|
)
|
|
2934
|
-
mutations.push({ t: 'goal/closed', id: goal.id, status: 'achieved', verdict: 'support', note: args.note ?? null, unjudged: untouched.map((hypothesis) => hypothesis.id) })
|
|
3204
|
+
mutations.push({ t: 'goal/closed', id: goal.id, status: 'achieved', verdict: 'support', note: args.note ?? null, unjudged: untouched.map((hypothesis) => hypothesis.id), ...(answers.length > 0 ? { answers } : {}) })
|
|
2935
3205
|
const continuationNote = completeNativeGoal(exec.agent)
|
|
2936
3206
|
/** 这个目标下各步经准入收下的产物(按路径去重),结案时一次声明成交付卡片。 */
|
|
2937
3207
|
const delivered = []
|
|
@@ -3120,14 +3390,20 @@ export function apply(ctx, config = {}) {
|
|
|
3120
3390
|
items: { type: 'string' },
|
|
3121
3391
|
description: '这一步检验哪几条判断:填判断的短名(也认主张原文)。一次观测同时判几条竞争的判断时(比较那一步),把它们都列上',
|
|
3122
3392
|
},
|
|
3123
|
-
level: { type: 'string', enum: MODEL_LEVELS, description: 'L2 = 自判(你写结果与依据);L3 = 独立评估(系统派评估者判);L4 =
|
|
3393
|
+
level: { type: 'string', enum: MODEL_LEVELS, description: 'L2 = 自判(你写结果与依据);L3 = 独立评估(系统派评估者判);L4 = 人工批准(不可重复或来自外部的证据,须先经人工批准)' },
|
|
3124
3394
|
},
|
|
3125
3395
|
required: ['hypotheses', 'level'],
|
|
3126
3396
|
additionalProperties: false,
|
|
3127
3397
|
},
|
|
3128
3398
|
expect: {
|
|
3129
3399
|
type: 'string',
|
|
3130
|
-
description: '
|
|
3400
|
+
description: '可选,执行前填写:这一步预计观察到什么(尽量给出数值或方向),以及预测的来源(本体中的哪条关系 / 哪条经验 / 哪条判断,或注明为直觉)。事先写下,预测落空时才能被发现',
|
|
3401
|
+
},
|
|
3402
|
+
serves: { type: 'string', description: '可选:这一步服务哪个问题或调研板块(id);不写即归当前问题' },
|
|
3403
|
+
predictions: {
|
|
3404
|
+
type: 'array',
|
|
3405
|
+
description: '可选,动手前写:按候选假设分别写预测(若「X」成立,预计看到什么)。各候选预测相同的一步区分不了它们,应改选能区分的检验',
|
|
3406
|
+
items: { type: 'object', properties: { hypothesis: { type: 'string', description: '判断的短名(也认 id)' }, expect: { type: 'string', description: '若它成立,预计看到什么(尽量给数或方向)' } }, required: ['hypothesis', 'expect'], additionalProperties: false },
|
|
3131
3407
|
},
|
|
3132
3408
|
},
|
|
3133
3409
|
required: ['id', 'do', 'done_criteria'],
|
|
@@ -3138,7 +3414,7 @@ export function apply(ctx, config = {}) {
|
|
|
3138
3414
|
defineTool({
|
|
3139
3415
|
name: 'CreatePlan',
|
|
3140
3416
|
description:
|
|
3141
|
-
'立约:把复杂任务立成一份计划。每步一句话说清做什么(do)、以何物为证(artifacts)、以及判定标准(done_criteria,在结果出现之前写下)
|
|
3417
|
+
'立约:把复杂任务立成一份计划。每步一句话说清做什么(do)、以何物为证(artifacts)、以及判定标准(done_criteria,在结果出现之前写下);可带预测(expect:预计观察到什么,以及预测的来源)。检验判断的步骤用 tests:{hypotheses, level} 声明验哪几条、什么等级(比较竞争路线的那一步,把竞争的几条都列上)。最多 25 步。约立起便锁定:局部挫折改当前步,不要推倒重来。',
|
|
3142
3418
|
parameters: {
|
|
3143
3419
|
type: 'object',
|
|
3144
3420
|
properties: {
|
|
@@ -3163,6 +3439,12 @@ export function apply(ctx, config = {}) {
|
|
|
3163
3439
|
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))
|
|
3164
3440
|
resolvedTests.set(step.id, resolved.tests)
|
|
3165
3441
|
}
|
|
3442
|
+
const resolvedExtras = new Map()
|
|
3443
|
+
for (const step of args.steps) {
|
|
3444
|
+
const resolved = resolveStepExtras(state, step)
|
|
3445
|
+
if (resolved.ok !== true) return fail(resolved.code, resolved.message)
|
|
3446
|
+
resolvedExtras.set(step.id, resolved.extra)
|
|
3447
|
+
}
|
|
3166
3448
|
const warnings = []
|
|
3167
3449
|
if (typeof args.brief !== 'string' || args.brief.length < CFG.minBriefChars) warnings.push(tr(`brief 偏短(建议 ≥${CFG.minBriefChars} 字),它是给人读的计划说明`, `brief is short (suggested ≥${CFG.minBriefChars} characters); it is the plan description people read`))
|
|
3168
3450
|
const goal = state.goal !== null && state.goal.status === 'open' ? state.goal : null
|
|
@@ -3174,7 +3456,7 @@ export function apply(ctx, config = {}) {
|
|
|
3174
3456
|
goal: goal?.id ?? null,
|
|
3175
3457
|
phase_id: goal?.id ?? null,
|
|
3176
3458
|
brief,
|
|
3177
|
-
steps: args.steps.map((step) => ({ id: step.id, do: step.do, artifacts: step.artifacts ?? [], done_criteria: step.done_criteria, tests: resolvedTests.get(step.id) ?? null, ...(typeof step.expect === 'string' && step.expect.trim() !== '' ? { expect: step.expect.trim() } : {}) })),
|
|
3459
|
+
steps: args.steps.map((step) => ({ id: step.id, do: step.do, artifacts: step.artifacts ?? [], done_criteria: step.done_criteria, tests: resolvedTests.get(step.id) ?? null, ...(typeof step.expect === 'string' && step.expect.trim() !== '' ? { expect: step.expect.trim() } : {}), ...resolvedExtras.get(step.id) })),
|
|
3178
3460
|
})
|
|
3179
3461
|
return done({
|
|
3180
3462
|
ok: true,
|
|
@@ -3193,14 +3475,15 @@ export function apply(ctx, config = {}) {
|
|
|
3193
3475
|
defineTool({
|
|
3194
3476
|
name: 'RevisePlan',
|
|
3195
3477
|
description:
|
|
3196
|
-
'改当前计划,不动进度(返回 progress_changed=false),四种动作:`action="expect"`
|
|
3478
|
+
'改当前计划,不动进度(返回 progress_changed=false),四种动作:`action="expect"` 为尚未执行的步骤写下预测(给 `step_id` 与 `expect`,或按候选假设给 `predictions`;须在执行前写,预测落空时才能被发现);`action="add"` 补一步(漏了活就补上,给 `step`);`action="refine"` 精化一步的判定标准(给 `step_id` 与新的 `done_criteria`,旧判据留在日志里);`action="void"` 带因作废一步(给 `step_id` 与 `reason`:发现某步本不该存在就作废并说明缘由——作废留痕光明正大,为凑完成而造证是大忌;已交付的步不能作废)。',
|
|
3197
3479
|
parameters: {
|
|
3198
3480
|
type: 'object',
|
|
3199
3481
|
properties: {
|
|
3200
|
-
action: { type: 'string', enum: ['expect', 'add', 'refine', 'void'], description: 'expect
|
|
3482
|
+
action: { type: 'string', enum: ['expect', 'add', 'refine', 'void'], description: 'expect=写预测;add=补一步;refine=改判据;void=带因作废' },
|
|
3201
3483
|
step: { ...STEP_SCHEMA, description: 'action=add:新步' },
|
|
3202
3484
|
step_id: { type: 'string', description: 'action=expect / refine / void:哪一步' },
|
|
3203
|
-
expect: { type: 'string', description: 'action=expect
|
|
3485
|
+
expect: { type: 'string', description: 'action=expect:预计观察到什么,以及预测的来源(关系 / 经验 / 判断,或直觉)' },
|
|
3486
|
+
predictions: { ...STEP_SCHEMA.properties.predictions, description: 'action=expect,可选:按候选假设分别写预测;与 expect 二者至少给一个' },
|
|
3204
3487
|
done_criteria: { type: 'string', description: 'action=refine:新的判定标准' },
|
|
3205
3488
|
reason: { type: 'string', description: '为什么改(action=void 必填)' },
|
|
3206
3489
|
},
|
|
@@ -3223,7 +3506,9 @@ export function apply(ctx, config = {}) {
|
|
|
3223
3506
|
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}`))
|
|
3224
3507
|
const resolved = resolveTests(state.hypotheses, args.step.tests)
|
|
3225
3508
|
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))
|
|
3226
|
-
const
|
|
3509
|
+
const extras = resolveStepExtras(state, args.step)
|
|
3510
|
+
if (extras.ok !== true) return fail(extras.code, extras.message)
|
|
3511
|
+
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 }
|
|
3227
3512
|
mutations.push({ t: 'plan/amended', plan: plan.id, step: amended })
|
|
3228
3513
|
if (plan.blocked !== undefined) mutations.push({ t: 'block/cleared', plan: plan.id, step: plan.blocked.step })
|
|
3229
3514
|
return done({ ok: true, code: 'plan_amended', progress_changed: false, message: tr(`已补一步 ${args.step.id}(进度不变)。`, `Added step ${args.step.id} (progress unchanged).`) })
|
|
@@ -3232,11 +3517,14 @@ export function apply(ctx, config = {}) {
|
|
|
3232
3517
|
const step = plan.steps.find((item) => item.id === args.step_id)
|
|
3233
3518
|
if (step === undefined) return fail('unknown_step', tr(`没有这一步:${args.step_id}`, `No such step: ${args.step_id}`))
|
|
3234
3519
|
if (args.action === 'expect') {
|
|
3235
|
-
if (step.status !== 'open') return fail('step_settled', tr(`步骤 ${step.id}
|
|
3520
|
+
if (step.status !== 'open') return fail('step_settled', tr(`步骤 ${step.id} 已结束(${step.status}):预测须在执行前写下。`, `Step ${step.id} is settled (${step.status}); expectations are written before acting.`))
|
|
3236
3521
|
const expect = String(args.expect ?? '').trim()
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3522
|
+
const extras = resolveStepExtras(state, { id: step.id, predictions: args.predictions })
|
|
3523
|
+
if (extras.ok !== true) return fail(extras.code, extras.message)
|
|
3524
|
+
const predictions = extras.extra.predictions ?? []
|
|
3525
|
+
if (expect.length < 4 && predictions.length === 0) return fail('expect_required', tr('预测不能为空:写明预计观察到什么及其来源;或按候选假设分别填写 predictions。', 'The expectation cannot be empty: say what you expect to see and where that comes from, or write predictions per candidate hypothesis.'))
|
|
3526
|
+
mutations.push({ t: 'step/expected', plan: plan.id, step: step.id, ...(expect.length >= 4 ? { expect } : {}), ...(predictions.length > 0 ? { predictions } : {}) })
|
|
3527
|
+
return done({ ok: true, code: 'step_expected', progress_changed: false, message: tr(`步骤 ${step.id} 的预测已记录。交付时将结果与之对照,不符之处写入 AdvancePlan 的 anomalies。`, `Expectation recorded for step ${step.id}. When you deliver, compare the result with it: whatever does not match goes in AdvancePlan's anomalies.`) })
|
|
3240
3528
|
}
|
|
3241
3529
|
if (args.action === 'refine') {
|
|
3242
3530
|
if (step.status !== 'open') return fail('step_settled', tr(`步骤 ${step.id} 已落定(${step.status}),判据不再可改。`, `Step ${step.id} is settled (${step.status}); its criteria can no longer change.`))
|
|
@@ -3305,7 +3593,7 @@ export function apply(ctx, config = {}) {
|
|
|
3305
3593
|
defineTool({
|
|
3306
3594
|
name: 'AdvancePlan',
|
|
3307
3595
|
description:
|
|
3308
|
-
'交付一步(唯一完成动词)
|
|
3596
|
+
'交付一步(唯一完成动词):把观测交上来。系统先做观测准入——声明的产物存在、非空、结构合法;准入只看收不收,不做裁决。交付成立这一步就完成——它检验的判断被支持、被推翻还是说不清,**都算完成**,结果单独记成证据。结果与预测不符之处写进 anomalies。L2(自判)由你给 basis(交付成立的依据,必须能被复查)与 results(这一步检验的每条判断各一格);L3 以上两项都由系统派独立评估者判,你写 results 会被拒绝。没有物证,就还没有完成——没有手动标记这回事。',
|
|
3309
3597
|
parameters: {
|
|
3310
3598
|
type: 'object',
|
|
3311
3599
|
properties: {
|
|
@@ -3317,10 +3605,10 @@ export function apply(ctx, config = {}) {
|
|
|
3317
3605
|
},
|
|
3318
3606
|
anomalies: {
|
|
3319
3607
|
type: 'array',
|
|
3320
|
-
description: '
|
|
3321
|
-
items: { type: 'object', properties: { what: { type: 'string', description: '
|
|
3608
|
+
description: '未解释:这一步结果中与预测或本体不符之处、无法解释的读数(每条一句,写明何处不符)。它们挂在卡上,直到被解释、写明理由排除、或交给人(用 Anomaly 工具)。不要强行解释',
|
|
3609
|
+
items: { type: 'object', properties: { what: { type: 'string', description: '何处不符:预测为何、实际为何' }, anchor: { type: 'string', description: '可选:在哪个实体或装置上(实体 id 或名字)' }, touches: { type: 'array', items: { type: 'string' }, description: '可选:涉及的量(概念 id)、候选假设(判断 id)或已确立的事实(事实 id)。点名事实的,该事实回到「待核验」;结案时,涉及答案的未解释项须在「尚未确定的事项」中写明影响' } }, required: ['what'], additionalProperties: false },
|
|
3322
3610
|
},
|
|
3323
|
-
basis: { type: 'string', description: '
|
|
3611
|
+
basis: { type: 'string', description: '交付成立的依据:引用了哪个产物里的哪个事实(必须可复查)。仅自判(L2)由你写' },
|
|
3324
3612
|
results: {
|
|
3325
3613
|
type: 'array',
|
|
3326
3614
|
description: '仅自判(L2):这一步检验的每条判断各一格,对照它的推翻条件读结果:没碰到推翻条件是「支持」,碰到了是「推翻」,这次观测区分不了是「不确定」。推翻和不确定都不妨碍这一步完成',
|
|
@@ -3454,8 +3742,8 @@ export function apply(ctx, config = {}) {
|
|
|
3454
3742
|
if (releaseTarget !== null && !releaseTarget.released) {
|
|
3455
3743
|
const asked = await askHuman(exec, {
|
|
3456
3744
|
id: `release-${step.id}`,
|
|
3457
|
-
header: tr('L4
|
|
3458
|
-
question: tr(`步骤 ${step.id}(${clip(step.do, 60)})
|
|
3745
|
+
header: tr('L4 须经人工批准', 'L4 needs approval'),
|
|
3746
|
+
question: tr(`步骤 ${step.id}(${clip(step.do, 60)})属于 L4:新产生的、不可重复或来自外部的证据。是否批准此次交付?`, `Step ${step.id} (${clip(step.do, 60)}) is L4: new, unrepeatable or external evidence. Release this delivery?`),
|
|
3459
3747
|
detail: tr(`判据:${step.done_criteria}`, `Criteria: ${step.done_criteria}`),
|
|
3460
3748
|
options: [
|
|
3461
3749
|
{ label: choiceLabel('releaseYes'), description: tr('交给独立评估者判。', 'Hand it to the independent evaluator.') },
|
|
@@ -3466,8 +3754,8 @@ export function apply(ctx, config = {}) {
|
|
|
3466
3754
|
const why = asked.ok !== true ? unanswered(asked) : tr(`人选了「${asked.choice ?? '没选'}」${asked.note === null ? '' : `:${asked.note}`}`, `the person chose "${asked.choice ?? 'nothing'}"${asked.note === null ? '' : `: ${asked.note}`}`)
|
|
3467
3755
|
return fail(
|
|
3468
3756
|
'human_release_missing',
|
|
3469
|
-
tr(`L4
|
|
3470
|
-
(asked.ok === true ? '' : blockNativeGoal(exec.agent, BLOCK_CODES.needsHuman, tr(`步骤 ${step.id} 是 L4
|
|
3757
|
+
tr(`L4 的交付须经人工批准,本次未获批准(${why})。等级是事实的属性,批准是人的行为,不能推断。`, `An L4 delivery needs a person to release it, and this one was not released (${why}). The level is a property of the fact; release is a person's act and cannot be inferred. `) +
|
|
3758
|
+
(asked.ok === true ? '' : blockNativeGoal(exec.agent, BLOCK_CODES.needsHuman, tr(`步骤 ${step.id} 是 L4,等待人工批准。`, `Step ${step.id} is L4 and waits for a person to release it.`))),
|
|
3471
3759
|
mutations.length > 0 ? { mutations } : {},
|
|
3472
3760
|
)
|
|
3473
3761
|
}
|
|
@@ -3552,7 +3840,7 @@ export function apply(ctx, config = {}) {
|
|
|
3552
3840
|
}
|
|
3553
3841
|
} else {
|
|
3554
3842
|
if (typeof args.basis !== 'string' || args.basis.trim().length < 8) {
|
|
3555
|
-
return fail('basis_required', tr(`${level ?? '未声明等级'}
|
|
3843
|
+
return fail('basis_required', tr(`${level ?? '未声明等级'} 的交付由你自己判:写清交付成立的依据(basis)——引用了哪个产物里的哪个事实,必须能被复查。`, `At ${level ?? 'an undeclared level'} you judge the delivery yourself: write why it holds (basis), citing which fact in which output, so it can be checked.`))
|
|
3556
3844
|
}
|
|
3557
3845
|
const given = Array.isArray(args.results) ? args.results : []
|
|
3558
3846
|
const byId = new Map()
|
|
@@ -3674,16 +3962,17 @@ export function apply(ctx, config = {}) {
|
|
|
3674
3962
|
defineTool({
|
|
3675
3963
|
name: 'Anomaly',
|
|
3676
3964
|
description:
|
|
3677
|
-
'未解释项(反常)
|
|
3965
|
+
'未解释项(反常):与预测或本体不符的观测、无法解释的读数。`action="open"` 登记一条(给 `what`,可选 `anchor`);`action="resolve"` 给它一个去处(给 `id`、`outcome` 与 `reason`):explained = 被一条判断、关系或新查到的原因解释了(`by` 写是哪条);ruled_out = 写明理由排除(比如证实是录入错误);escalated = 交给人。不要为了让卡干净而排除:评估者会核排除的理由。',
|
|
3678
3966
|
parameters: {
|
|
3679
3967
|
type: 'object',
|
|
3680
3968
|
properties: {
|
|
3681
3969
|
action: { type: 'string', enum: ['open', 'resolve'] },
|
|
3682
|
-
what: { type: 'string', description: 'action=open
|
|
3970
|
+
what: { type: 'string', description: 'action=open:何处不符——预测为何、实际为何' },
|
|
3683
3971
|
anchor: { type: 'string', description: 'action=open,可选:在哪个实体或装置上' },
|
|
3972
|
+
touches: { type: 'array', items: { type: 'string' }, description: 'action=open,可选:涉及的量(概念 id)、候选假设(判断 id)或已确立的事实(事实 id)。点名事实的,该事实回到「待核验」' },
|
|
3684
3973
|
id: { type: 'string', description: 'action=resolve:哪一条(u-… 的 id)' },
|
|
3685
3974
|
outcome: { type: 'string', enum: ANOMALY_OUTCOMES, description: 'explained=已解释;ruled_out=排除;escalated=交给人' },
|
|
3686
|
-
reason: { type: 'string', description: 'action=resolve
|
|
3975
|
+
reason: { type: 'string', description: 'action=resolve:依据(解释是什么 / 为何可以排除 / 需要人决定什么)' },
|
|
3687
3976
|
by: { type: 'string', description: 'action=resolve,可选:解释它的那条判断、关系或事实' },
|
|
3688
3977
|
},
|
|
3689
3978
|
required: ['action'],
|
|
@@ -3696,8 +3985,8 @@ export function apply(ctx, config = {}) {
|
|
|
3696
3985
|
const { hostService, sessionId, state, mutations } = call
|
|
3697
3986
|
const done = finish(hostService, sessionId, mutations)
|
|
3698
3987
|
if (args.action === 'open') {
|
|
3699
|
-
const opened = openAnomalies(sessionId, [{ what: args.what, anchor: args.anchor }], { step: firstOpenStep(activePlanOf(state))?.id ?? null, by: 'model' })
|
|
3700
|
-
if (opened.length === 0) return fail('what_required', tr('
|
|
3988
|
+
const opened = openAnomalies(sessionId, [{ what: args.what, anchor: args.anchor, touches: args.touches }], { step: firstOpenStep(activePlanOf(state))?.id ?? null, by: 'model' })
|
|
3989
|
+
if (opened.length === 0) return fail('what_required', tr('要写何处不符:预测为何、实际为何。', 'Say what does not fit: what was expected and what was seen.'))
|
|
3701
3990
|
mutations.push(...opened)
|
|
3702
3991
|
return done({ ok: true, code: 'anomaly_opened', message: tr(`已登记未解释 ${opened[0].id}。它挂在卡上,直到被解释、排除或交给人。`, `Unexplained item ${opened[0].id} recorded. It stays on the card until explained, ruled out or handed to a person.`) })
|
|
3703
3992
|
}
|
|
@@ -3708,7 +3997,7 @@ export function apply(ctx, config = {}) {
|
|
|
3708
3997
|
if (target === undefined) return fail('unknown_anomaly', tr(`没有这条开着的未解释:${wanted || '(没给 id)'}。开着的:${known.map((item) => `${item.id}(${clip(item.what, 30)})`).join('、') || '(没有)'}`, `No open unexplained item ${wanted || '(no id given)'}. Open ones: ${known.map((item) => `${item.id} (${clip(item.what, 30)})`).join(', ') || '(none)'}`))
|
|
3709
3998
|
if (!ANOMALY_OUTCOMES.includes(args.outcome)) return fail('outcome_required', tr('outcome 只能是 explained / ruled_out / escalated。', 'outcome must be explained, ruled_out or escalated.'))
|
|
3710
3999
|
const reason = String(args.reason ?? '').trim()
|
|
3711
|
-
if (reason.length < 4) return fail('reason_required', tr('
|
|
4000
|
+
if (reason.length < 4) return fail('reason_required', tr('须写明依据:解释是什么、为何可以排除,或需要人决定什么。', 'Say on what grounds: the explanation, why it can be ruled out, or what a person must decide.'))
|
|
3712
4001
|
const by = String(args.by ?? '').trim()
|
|
3713
4002
|
mutations.push({ t: 'anomaly/resolved', id: target.id, outcome: args.outcome, reason: reason.slice(0, 600), ...(by === '' ? {} : { by: by.slice(0, 120) }) })
|
|
3714
4003
|
const word = { explained: tr('已解释', 'explained'), ruled_out: tr('已排除', 'ruled out'), escalated: tr('交给人', 'handed to a person') }[args.outcome]
|
|
@@ -3975,8 +4264,8 @@ export function apply(ctx, config = {}) {
|
|
|
3975
4264
|
const step = firstOpenStep(plan)
|
|
3976
4265
|
const asked = await askHuman(exec, {
|
|
3977
4266
|
id: `release-cmd-${String(exec.callId ?? Date.now().toString(36))}`,
|
|
3978
|
-
header: tr('
|
|
3979
|
-
question: tr(
|
|
4267
|
+
header: tr('不可逆动作须经人工批准', 'Irreversible action needs approval'),
|
|
4268
|
+
question: tr(`此命令属于已声明的不可逆动作「${clip(action.action, 60)}」。是否批准执行?`, `This command is a declared irreversible action ("${clip(action.action, 60)}"). Release it?`),
|
|
3980
4269
|
detail: clip(command, 300),
|
|
3981
4270
|
options: [
|
|
3982
4271
|
{ label: choiceLabel('releaseCommand'), description: tr('让它执行。', 'Let it run.') },
|
|
@@ -3991,8 +4280,8 @@ export function apply(ctx, config = {}) {
|
|
|
3991
4280
|
return {
|
|
3992
4281
|
kind: 'deny',
|
|
3993
4282
|
reason:
|
|
3994
|
-
tr(`「${action.action}
|
|
3995
|
-
(asked.ok === true ? '' : blockNativeGoal(exec.agent, BLOCK_CODES.needsHuman, tr(`不可逆动作「${action.action}
|
|
4283
|
+
tr(`「${action.action}」是不可逆动作,本次未获批准(${why})。不要改写命令以绕过此限制:等待人工批准,或修改计划。`, `"${action.action}" is irreversible and was not released this time (${why}). Do not rewrite the command to get around this: wait for a person, or change the plan.`) +
|
|
4284
|
+
(asked.ok === true ? '' : blockNativeGoal(exec.agent, BLOCK_CODES.needsHuman, tr(`不可逆动作「${action.action}」等待人工批准。`, `The irreversible action "${action.action}" waits for a person to release it.`))),
|
|
3996
4285
|
}
|
|
3997
4286
|
}
|
|
3998
4287
|
|
|
@@ -4303,6 +4592,10 @@ export function apply(ctx, config = {}) {
|
|
|
4303
4592
|
'tests.hypotheses': 'Which judgments this step tests: their short names (claim text also works). When one observation decides several competing judgments (a comparison step), list them all',
|
|
4304
4593
|
'tests.level': 'L2 = self-judged (you write the results and basis); L3 = independent evaluation (the system dispatches an evaluator); L4 = released by a person (unrepeatable or external evidence, a person first)',
|
|
4305
4594
|
expect: 'Optional, written before acting: what you expect this step to show (a number or a direction if you can), and where the expectation comes from (which ontology relation, lesson or judgment, or plainly intuition). Written down, a miss becomes visible',
|
|
4595
|
+
serves: 'Optional: which question or survey area this step serves (id); defaults to the current question',
|
|
4596
|
+
predictions: 'Optional, written before acting: a prediction per candidate hypothesis (if "X" holds, what this step should show). A step where all candidates predict the same cannot tell them apart; choose a test that can',
|
|
4597
|
+
'predictions.items.hypothesis': 'Short name of the judgment (id also works)',
|
|
4598
|
+
'predictions.items.expect': 'If it holds, what you expect to see (a number or a direction if you can)',
|
|
4306
4599
|
}
|
|
4307
4600
|
const prefixed = (prefix, table) => Object.fromEntries(Object.entries(table).map(([key, value]) => [`${prefix}${key}`, value]))
|
|
4308
4601
|
const TOOL_TEXT_EN = {
|
|
@@ -4326,6 +4619,18 @@ export function apply(ctx, config = {}) {
|
|
|
4326
4619
|
'hypotheses.items.name': 'Short name, within about 12 CJK characters or 20-odd letters, chosen by you (e.g. "python3 runs"). Use this name whenever you mention or reference the judgment in other tools',
|
|
4327
4620
|
'hypotheses.items.retests': 'Which fact already in long-term knowledge this judgment re-tests: the fact id (the file name in clear/knowledge/facts/<id>.json). Copy that fact\'s original statement as the claim and test it again on new data; do not write "it is refuted" as the claim. When this judgment is refuted, the system asks a person on the spot whether to retract or keep that fact, including facts left by other sessions',
|
|
4328
4621
|
'hypotheses.items.assertions': 'Assertions: subject, predicate, object (ids from the domain vocabulary)',
|
|
4622
|
+
'hypotheses.items.question': 'Optional: which question or survey area it belongs to (id); defaults to the first question',
|
|
4623
|
+
'hypotheses.items.from': 'Optional: which ontology relation proposed it (relation id, e.g. an affects relation with a shape); if there is no such source, write "intuition"',
|
|
4624
|
+
mode: 'Way of working: survey = broad survey (lay out survey areas, then pick the questions worth pursuing); solve = targeted solving (list candidate hypotheses under a question and eliminate them with tests that tell them apart); survey_then_solve = survey first, then solve. Omitted on revision = unchanged',
|
|
4625
|
+
questions: 'Questions to answer (optional; a goal may have several; if none, the whole goal is one question). A question found during a survey is written with status="emergent" under its area; when a person decides to pursue it, it becomes open, and parked when deferred. Omitted on revision = unchanged; given = the full list',
|
|
4626
|
+
'questions.items.id': 'Short id (e.g. q1), used by a judgment\'s question and a step\'s serves',
|
|
4627
|
+
'questions.items.text': 'The question, in one sentence',
|
|
4628
|
+
'questions.items.status': 'open = being answered; emergent = newly found, awaiting a decision; parked = deferred (listed as an open point at conclusion)',
|
|
4629
|
+
'questions.items.area': 'Optional: which survey area it belongs to (area id)',
|
|
4630
|
+
areas: 'Survey areas (for a broad survey; e.g. technology routes, main companies, cost structure). Omitted on revision = unchanged; given = the full list',
|
|
4631
|
+
ontology: 'Ontology entries, checked by the system and written to clear/ontology/ (same shape as the files; fields in clear/ontology/SCHEMA.json). When framing, first state the quantities involved: each measure (kind=measure, gloss = its definition, unit) and how it is measured and how a reading is checked (a kind=measures relation: domain = the instrument or source, range = the measure, check = how to confirm the reading); and how the quantities affect each other (kind=affects relations, shape = rough shape). A file with the same id is replaced',
|
|
4632
|
+
'ontology.concepts': 'Concepts: {id, label, gloss, kind: category|measure|phenomenon, unit?}',
|
|
4633
|
+
'ontology.relations': 'Relations: {id, label, kind: affects|measures|defines|manifests_as, domain?, range, shape? (affects), check? (measures)}',
|
|
4329
4634
|
reason: 'Required when revising the goal: one sentence on why (not needed the first time)',
|
|
4330
4635
|
},
|
|
4331
4636
|
},
|
|
@@ -4334,9 +4639,16 @@ export function apply(ctx, config = {}) {
|
|
|
4334
4639
|
'Conclude: hand the goal in for acceptance. This is the only way to complete a goal (the native "complete goal" is refused). The system **always** dispatches an independent evaluator to check the goal criteria and transcription fidelity item by item; only when the criteria are met does the goal conclude as achieved: the native goal is marked complete; the evaluator also judges each live judgment, and those it supports (or that already reached the threshold) are promoted to facts; and the outputs accepted by each step are declared as a deliverables card; lessons proposed with the conclusion (`lessons`) are checked one by one, and supported ones are written to clear/knowledge/lessons/. Otherwise the goal stays open and the gaps come back. **Order**: before achieved, close the plan first (`ClosePlan`). Abandoning (`abandoned`) is not limited by this: the native goal is marked blocked with the reason, and a person decides whether to end it.',
|
|
4335
4640
|
params: {
|
|
4336
4641
|
outcome: 'achieved = criteria met; abandoned = give up after stating the blocker honestly',
|
|
4642
|
+
answers: 'Conclusions (on achieved, one per question; one in total if the goal lists no questions): conclusion / basis / open points / decisions for the user. Intermediate judgments and process stay out. Candidate hypotheses still being examined without support, and open unexplained items, must go in the open points with how the conclusion would change if they hold',
|
|
4643
|
+
'answers.items.question': 'Which question (id); may be omitted when the goal lists no questions',
|
|
4644
|
+
'answers.items.conclusion': 'Conclusion: one or two sentences with values and the conditions under which they hold',
|
|
4645
|
+
'answers.items.basis': 'Basis: one line per adopted or excluded candidate hypothesis or verified reading, naming the experiment or source',
|
|
4646
|
+
'answers.items.open': 'Open points: what each concerns (about: candidate short names, unexplained item ids or question ids) and its effect on the conclusion (effect: if it holds, how the conclusion changes)',
|
|
4647
|
+
'answers.items.decide': 'For the user to decide (e.g. whether to re-test before scaling up)',
|
|
4648
|
+
'answers.items.unanswered': 'If it could not be answered, why (conclusion may then be omitted)',
|
|
4337
4649
|
note: 'Conclusion note',
|
|
4338
4650
|
lessons: 'Lessons (optional, checked only on achieved): what this run found that changes how to work next time in a similar setting, not a restatement of this run\'s conclusion. The evaluator checks each against the record; supported ones are written to clear/knowledge/lessons/, and later sessions see them when framing and planning',
|
|
4339
|
-
'lessons.items.text': 'One sentence on what to do next time ("check this rig\'s
|
|
4651
|
+
'lessons.items.text': 'One sentence on what to do next time ("check this kind of rig\'s key readings against an independent source first")',
|
|
4340
4652
|
'lessons.items.kind': 'trap = a pitfall; check = a reading or assumption to check first; shortcut = a convenient method that misleads; prior = a prior about this kind of system (e.g. "two factors are often coupled; scan diagonally first")',
|
|
4341
4653
|
'lessons.items.about': 'The equipment, quantities or concepts involved (short names, used to match next time)',
|
|
4342
4654
|
'lessons.items.evidence': 'Where in this run\'s record it showed (step, file)',
|
|
@@ -4357,6 +4669,7 @@ export function apply(ctx, config = {}) {
|
|
|
4357
4669
|
params: {
|
|
4358
4670
|
action: 'expect = write the expectation; add = add a step; refine = change the criterion; void = void with a reason',
|
|
4359
4671
|
expect: 'action=expect: what you expect to see, and where it comes from (relation / lesson / judgment, or intuition)',
|
|
4672
|
+
predictions: 'action=expect, optional: a prediction per candidate hypothesis; give expect, predictions, or both',
|
|
4360
4673
|
step: 'action=add: the new step',
|
|
4361
4674
|
...prefixed('step.', STEP_TEXT_EN),
|
|
4362
4675
|
step_id: 'action=expect / refine / void: which step',
|
|
@@ -4377,6 +4690,7 @@ export function apply(ctx, config = {}) {
|
|
|
4377
4690
|
anomalies: 'Unexplained: where this step\'s result does not fit the expectation or the ontology, or a reading that makes no sense (one sentence each, saying what does not fit). They stay on the card until explained, ruled out with a reason, or handed to a person (with the Anomaly tool). Do not explain them away',
|
|
4378
4691
|
'anomalies.items.what': 'What does not fit: what was expected, what was seen',
|
|
4379
4692
|
'anomalies.items.anchor': 'Optional: on which entity or device (entity id or name)',
|
|
4693
|
+
'anomalies.items.touches': 'Optional: the quantities (concept ids), candidate hypotheses (judgment ids) or established facts (fact ids) it concerns. A named fact goes back to "pending re-check"; at conclusion, open items touching the answer must be written into its open points with their effect',
|
|
4380
4694
|
basis: 'Why the delivery holds: which fact in which output (must be checkable). Written by you only at L2 (self-judged)',
|
|
4381
4695
|
results:
|
|
4382
4696
|
'L2 (self-judged) only: one entry per judgment this step tests, read against its refutation condition: not met is support, met is refute, and if this observation cannot tell, inconclusive. Refute and inconclusive do not stop the step from completing',
|
|
@@ -4391,6 +4705,7 @@ export function apply(ctx, config = {}) {
|
|
|
4391
4705
|
params: {
|
|
4392
4706
|
what: 'action=open: what does not fit: what was expected, what was seen',
|
|
4393
4707
|
anchor: 'action=open, optional: on which entity or device',
|
|
4708
|
+
touches: 'action=open, optional: the quantities (concept ids), candidate hypotheses (judgment ids) or established facts (fact ids) it concerns. A named fact goes back to "pending re-check"',
|
|
4394
4709
|
id: 'action=resolve: which one (the u-… id)',
|
|
4395
4710
|
outcome: 'explained / ruled_out / escalated (to a person)',
|
|
4396
4711
|
reason: 'action=resolve: on what grounds (the explanation, why it can be ruled out, what a person must decide)',
|