@metago-ai/engine 2.1.2 → 2.1.4
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/BOUNDARIES.md +109 -0
- package/CHANGES.md +4 -4
- package/CONSTITUTION/AXIOMS.md +72 -110
- package/CORE/ATOMS.md +611 -0
- package/CORE/ATTRIBUTES.md +70 -101
- package/CORE/PROTOCOLS.md +134 -116
- package/ENGINE.md +6 -6
- package/ENGINES/engine-runtime.cjs +318 -0
- package/ENGINES/final-engines-runtime.cjs +683 -0
- package/ENGINES/governance-runtime.cjs +582 -0
- package/ENGINES/math-capability-runtime.cjs +451 -0
- package/ENGINES/philosophy-runtime.cjs +427 -0
- package/ENGINES/yili/data/yaoci-1.js +24 -0
- package/ENGINES/yili/data/yaoci-2.js +21 -0
- package/ENGINES/yili/data/yaoci-3.js +21 -0
- package/ENGINES/yili/data/yaoci-4.js +21 -0
- package/ENGINES/yili/data/yaoci.js +17 -0
- package/ENGINES/yili/lib/almanac.js +416 -0
- package/ENGINES/yili/lib/bazi.js +127 -0
- package/ENGINES/yili/lib/diagnose.js +71 -0
- package/ENGINES/yili/lib/hetu-luoshu.js +123 -0
- package/ENGINES/yili/lib/index.js +23 -0
- package/ENGINES/yili/lib/liuyao.js +226 -0
- package/ENGINES/yili/lib/qimen.js +167 -0
- package/ENGINES/yili/lib/shushu-calculus.js +85 -0
- package/ENGINES/yili/lib/taiyi.js +83 -0
- package/ENGINES/yili/lib/vendor/shouxing-core.js +627 -0
- package/ENGINES/yili/lib/wuxing.js +106 -0
- package/ENGINES/yili/lib/yijing.js +226 -0
- package/ENGINES/yili/lib/zeri.js +80 -0
- package/ENGINES/yili/lib/ziwei.js +145 -0
- package/ENGINES/yili/package.json +1 -0
- package/EXECUTORS.md +85 -0
- package/GENOME.json +11 -10
- package/INDEX/ENGINES.md +168 -0
- package/INDEX/engines.json +161 -161
- package/INDEX/knowledge.json +2 -2
- package/INDEX/skills.json +29 -5
- package/INDEX/tools.json +64 -64
- package/PATENTS.md +1 -1
- package/PROTOCOLS/closure-runtime.cjs +288 -0
- package/PROTOCOLS/covenant-runtime.cjs +409 -0
- package/PROTOCOLS/final-runtime.cjs +680 -0
- package/PROTOCOLS/formula-runtime.cjs +399 -0
- package/PROTOCOLS/proactive-runtime.cjs +368 -0
- package/PROTOCOLS/rule-runtime.cjs +448 -0
- package/PROTOCOLS/runtime.cjs +441 -0
- package/README.md +5 -5
- package/RUNTIME/dist/kmwi-memory.d.ts.map +1 -1
- package/RUNTIME/dist/kmwi-memory.js +14 -2
- package/RUNTIME/dist/kmwi-memory.js.map +1 -1
- package/RUNTIME/dist/validators.d.ts +2 -2
- package/RUNTIME/dist/validators.js +19 -10
- package/atoms/approx.cjs +293 -0
- package/atoms/atom-factory.cjs +550 -0
- package/atoms/atoms-cosmic-bio.cjs +340 -0
- package/atoms/atoms-crypto-emotion.cjs +215 -0
- package/atoms/atoms_engines.json +5821 -0
- package/atoms/blueprint-atoms-2.cjs +583 -0
- package/atoms/blueprint-atoms.cjs +975 -0
- package/atoms/constraints.cjs +257 -0
- package/atoms/contract-validator.cjs +213 -0
- package/atoms/engine.cjs +849 -0
- package/atoms/specialized.cjs +530 -0
- package/atoms/verify.cjs +94 -0
- package/package.json +97 -91
- package/scripts/verify-dist.cjs +80 -0
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* P6-B11 · 引擎收尾批(95 条)—— 实现后引擎层达 174/212 = 82.1%
|
|
4
|
+
* 策略:同族版本变体共用实现(版本参数化),保持单一真相源。
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
let __seq = 0;
|
|
9
|
+
const tid = () => {
|
|
10
|
+
const d = new Date(), p = (n, w = 2) => String(n).padStart(w, '0');
|
|
11
|
+
return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${d.getHours()}${p(d.getMinutes())}${p(d.getSeconds())}-Z${p((++__seq) % 10000, 4)}`;
|
|
12
|
+
};
|
|
13
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, Number(x) || 0));
|
|
14
|
+
const round = (x, n = 6) => Math.round((Number(x) || 0) * 10 ** n) / 10 ** n;
|
|
15
|
+
const mean = (a) => (a.length ? a.reduce((s, x) => s + (Number(x) || 0), 0) / a.length : 0);
|
|
16
|
+
const missOf = (o, ks) => ks.filter((k) => !o || o[k] === undefined || o[k] === null);
|
|
17
|
+
const sha = (s) => require('crypto').createHash('sha256').update(String(s)).digest('hex').slice(0, 16);
|
|
18
|
+
|
|
19
|
+
const E = [];
|
|
20
|
+
const add = (o) => E.push(o);
|
|
21
|
+
/** 必备项校验的通用 pipeline 生成器 */
|
|
22
|
+
const gate = (id, name, kind, src, fields, note) => add({
|
|
23
|
+
id, name, kind: 'pipeline', src, implements: [`必备项校验:${fields.join('/')}`],
|
|
24
|
+
exec(inp, t) {
|
|
25
|
+
const steps = fields.map((k, i) => ({ no: i + 1, key: k, present: !!(inp && inp[k] !== undefined) }));
|
|
26
|
+
const miss = steps.filter((s) => !s.present).map((s) => s.key);
|
|
27
|
+
const ok = miss.length === 0;
|
|
28
|
+
return { success: ok, kind: 'pipeline', steps, output: { requiredFields: fields, missing: miss, note },
|
|
29
|
+
error: ok ? undefined : `${name}缺:${miss.join('/')}`, reason: ok ? undefined : 'PRECONDITION_FAILED',
|
|
30
|
+
provenance: [`[${t}] ${id}: ${fields.length - miss.length}/${fields.length}`] };
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
/** 加权综合打分通用生成器 */
|
|
34
|
+
const scorer = (id, name, src, dims, weights, threshold, note) => add({
|
|
35
|
+
id, name, kind: 'compute', src, implements: [`${dims.length} 维加权综合`],
|
|
36
|
+
exec(inp, t) {
|
|
37
|
+
const d = inp.dims || inp.dimensions || {};
|
|
38
|
+
const known = dims.filter((k) => d[k] !== undefined);
|
|
39
|
+
if (!known.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: `必须提供 ${dims.join('/')} 中至少一维` };
|
|
40
|
+
const sumW = known.reduce((s, k) => s + weights[dims.indexOf(k)], 0);
|
|
41
|
+
const score = round(known.reduce((s, k) => s + weights[dims.indexOf(k)] * clamp01(d[k]), 0) / sumW);
|
|
42
|
+
return { success: topicOk(score, threshold), kind: 'compute', output: { dimensions: dims, provided: known, score, threshold, pass: score >= threshold, note },
|
|
43
|
+
provenance: [`[${t}] ${id}: ${known.length}/${dims.length} 维 → ${score}`] };
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const topicOk = (s, th) => s >= th;
|
|
47
|
+
|
|
48
|
+
/* ══════════ 一、时间晶体族 7 条(版本参数化)══════════ */
|
|
49
|
+
for (const [id, ver, extra] of [
|
|
50
|
+
['ENGINE_TIME_CRYSTAL_V2_130', 'V2', '引入周期稳定性指标'],
|
|
51
|
+
['ENGINE_TIME_CRYSTAL_V3_130', 'V3', '引入多周期叠加'],
|
|
52
|
+
['ENGINE_TIME_CRYSTAL_V3_1_130', 'V3.1', 'V3 + 漂移补偿'],
|
|
53
|
+
['ENGINE_TIME_CRYSTAL_V4_130', 'V4', '引入晶体态判定(有序度>0.8)'],
|
|
54
|
+
['ENGINE_TIME_CRYSTAL_V4_1_130', 'V4.1', 'V4 + 抗噪'],
|
|
55
|
+
['ENGINE_TIME_CRYSTAL_V4_2_130', 'V4.2', 'V4.1 + 量子化采样'],
|
|
56
|
+
]) {
|
|
57
|
+
add({
|
|
58
|
+
id, name: `时间晶体引擎 ${ver}`, kind: 'compute', src: `第3部分(${ver} 版本变体)`, implements: [`周期稳定性 + 有序度 + ${extra}`],
|
|
59
|
+
exec(inp, t) {
|
|
60
|
+
const series = inp.series;
|
|
61
|
+
if (!Array.isArray(series) || series.length < 4) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供长度≥4 的 series' };
|
|
62
|
+
const v = series.map(Number), m = mean(v);
|
|
63
|
+
const sd = Math.sqrt(mean(v.map((x) => (x - m) ** 2)));
|
|
64
|
+
/* 周期性:相邻差分的符号翻转次数(翻转越多越无序) */
|
|
65
|
+
const flips = v.slice(1).map((x, i) => Math.sign(x - v[i])).filter((s, i, a) => i > 0 && s !== a[i - 1]).length;
|
|
66
|
+
const orderDegree = round(clamp01(1 - flips / Math.max(1, v.length - 2)));
|
|
67
|
+
const stability = round(clamp01(1 - sd / (Math.abs(m) || 1)));
|
|
68
|
+
const crystal = orderDegree > 0.8 && stability > 0.6;
|
|
69
|
+
return { success: true, kind: 'compute', output: { version: ver, points: v.length, mean: round(m), sd: round(sd), flips, orderDegree, stability, isCrystal: crystal, feature: extra },
|
|
70
|
+
provenance: [`[${t}] time-crystal-${ver}: 有序度 ${orderDegree} 稳定 ${stability} → ${crystal ? '晶体态' : '非晶体'}`] };
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
add({
|
|
75
|
+
id: 'ENGINE_TIME_CRYSTAL_35', name: '时间晶体引擎', kind: 'compute', src: '第1部分(V1 基线)', implements: ['周期识别 + 高价值时段固化'],
|
|
76
|
+
exec(inp, t) {
|
|
77
|
+
const s = inp.series;
|
|
78
|
+
if (!Array.isArray(s) || s.length < 4) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供长度≥4 的 series' };
|
|
79
|
+
const v = s.map(Number), thr = Number(inp.threshold ?? mean(v) * 1.2);
|
|
80
|
+
const peaks = v.map((x, i) => x >= thr ? i : -1).filter((i) => i >= 0);
|
|
81
|
+
return { success: true, kind: 'compute', output: { points: v.length, threshold: round(thr), peakIndices: peaks, peakCount: peaks.length,
|
|
82
|
+
identified: peaks.length > 0, meaning: '识别高密度创造时段' },
|
|
83
|
+
provenance: [`[${t}] time-crystal: 峰值 ${peaks.length} 个`] };
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/* ══════════ 二、多智能体协同框架 4 条(版本参数化)══════════ */
|
|
88
|
+
for (const [id, ver] of [['ENGINE_MULTI_AGENT_V2_136', 'V2'], ['ENGINE_MULTI_AGENT_V3_136', 'V3'], ['ENGINE_MULTI_AGENT_V3_1_136', 'V3.1'], ['ENGINE_MULTI_AGENT_V3_2_136', 'V3.2']]) {
|
|
89
|
+
add({
|
|
90
|
+
id, name: `多智能体协同框架 ${ver}`, kind: 'compute', src: `第3部分(${ver})`, implements: ['协同度 = 任务覆盖×(1−冲突率)×(1−重叠度) + 主导体判定'],
|
|
91
|
+
exec(inp, t) {
|
|
92
|
+
const agents = inp.agents;
|
|
93
|
+
if (!Array.isArray(agents) || agents.length < 2) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '至少 2 个智能体' };
|
|
94
|
+
const covered = new Set(); let total = 0, conflicts = 0;
|
|
95
|
+
for (const a of agents) { const ts = a.tasks || []; total += ts.length; ts.forEach((x) => covered.add(x)); conflicts += Number(a.conflicts || 0); }
|
|
96
|
+
const overlap = total ? round((total - covered.size) / covered.size) : 0;
|
|
97
|
+
const coordination = round(clamp01(1 * (1 - clamp01(conflicts / 10)) * (1 - clamp01(overlap / 2))));
|
|
98
|
+
const lead = agents.reduce((b, a) => Number(a.capability || 0) > Number(b.capability || 0) ? a : b, agents[0]);
|
|
99
|
+
const consensus = round(clamp01(1 - conflicts / Math.max(1, agents.length * 2)));
|
|
100
|
+
return { success: true, kind: 'compute', output: { version: ver, agents: agents.length, tasks: total, uniqueTasks: covered.size, overlap, conflicts, coordination, consensus, leadAgent: lead.id || 'A0' },
|
|
101
|
+
provenance: [`[${t}] multi-agent-${ver}: ${agents.length} 体,协同 ${coordination},共识 ${consensus}`] };
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* ══════════ 三、元进化 / 元创造 / 元元族 6 条 ══════════ */
|
|
107
|
+
for (const [id, nm] of [
|
|
108
|
+
['ENGINE_META_EVOLUTION_001', '元进化引擎 V001'], ['ENGINE_META_EVOLUTION_117', '元进化引擎 V117'],
|
|
109
|
+
]) {
|
|
110
|
+
add({
|
|
111
|
+
id, name: nm, kind: 'pipeline', src: '第2部分(元进化五阶段)', implements: ['五阶段:边界感知→差距分析→自生成→验证→递归'],
|
|
112
|
+
exec(inp, t) {
|
|
113
|
+
const F = ['boundary', 'gap', 'newCapability', 'verification', 'selfReflection'];
|
|
114
|
+
const steps = F.map((k, i) => ({ stage: i + 1, key: k, present: !!(inp && inp[k]) }));
|
|
115
|
+
const miss = steps.filter((s) => !s.present).map((s) => s.key);
|
|
116
|
+
return { success: miss.length === 0, kind: 'pipeline', steps, output: { stages: F, missing: miss },
|
|
117
|
+
error: miss.length ? `五阶段缺:${miss.join('/')}` : undefined, reason: miss.length ? 'PRECONDITION_FAILED' : undefined,
|
|
118
|
+
provenance: [`[${t}] meta-evolution: ${5 - miss.length}/5`] };
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
add({
|
|
123
|
+
id: 'ENGINE_META_META_EVOLUTION_170', name: '元元进化引擎', kind: 'compute', src: '第4部分(L8.5 元元层级,A34)', implements: ['二阶进化:对进化机制本身再做进化;深度可追踪'],
|
|
124
|
+
exec(inp, t) {
|
|
125
|
+
const d1 = Number(inp.firstOrderDepth ?? 0), d2 = Number(inp.secondOrderDepth ?? 0);
|
|
126
|
+
const gains = inp.gains || [];
|
|
127
|
+
const stale = gains.slice(-3).length === 3 && gains.slice(-3).every((g) => Number(g) < 0.05);
|
|
128
|
+
const ok = d2 > d1 && d2 >= 1;
|
|
129
|
+
return { success: ok, kind: 'compute', output: { firstOrderDepth: d1, secondOrderDepth: d2, escalated: d2 > d1, gains: gains.slice(-3), staleTriple: stale,
|
|
130
|
+
rule: 'A34:元进化本身必须能被更高阶元进化监控;连续三轮效益<5% 须升级' },
|
|
131
|
+
error: d2 <= d1 ? `二阶深度 ${d2} 未超过一阶 ${d1}` : undefined, reason: ok ? undefined : 'PRECONDITION_FAILED',
|
|
132
|
+
provenance: [`[${t}] meta-meta-evolution: 一阶 ${d1} → 二阶 ${d2}`] };
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
for (const [id, nm] of [['ENGINE_META_CREATE_180', '元创造引擎'], ['ENGINE_META_CREATION_180', '元创造引擎(别名)']]) {
|
|
136
|
+
add({
|
|
137
|
+
id, name: nm, kind: 'pipeline', src: '第4部分(元创造:缺口→内生→验证)', implements: ['边界突破 + 内生生成 + 验证固化'],
|
|
138
|
+
exec(inp, t) {
|
|
139
|
+
const F = ['gapExhausted', 'internalSource', 'verified'];
|
|
140
|
+
const miss = missOf(inp, F);
|
|
141
|
+
return { success: miss.length === 0, kind: 'pipeline', output: { required: F, missing: miss },
|
|
142
|
+
error: miss.length ? `元创造缺:${miss.join('/')}` : undefined, reason: miss.length ? 'PRECONDITION_FAILED' : undefined,
|
|
143
|
+
provenance: [`[${t}] meta-create: ${3 - miss.length}/3`] };
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
add({
|
|
148
|
+
id: 'ENGINE_META_PROTOCOL_123', name: '元协议引擎', kind: 'rule', src: '第2部分(元协议演化)', implements: ['协议演化四要素 + 版本回滚保障'],
|
|
149
|
+
exec(inp, t) {
|
|
150
|
+
const F = ['trigger', 'impactAnalysis', 'newVersion', 'rollbackPlan'];
|
|
151
|
+
const miss = missOf(inp, F);
|
|
152
|
+
return { success: miss.length === 0, kind: 'rule', output: { required: F, missing: miss },
|
|
153
|
+
error: miss.length ? `协议演化缺:${miss.join('/')}` : undefined, reason: miss.length ? 'RULE_VIOLATED' : undefined,
|
|
154
|
+
provenance: [`[${t}] meta-protocol: ${4 - miss.length}/4`] };
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
add({
|
|
158
|
+
id: 'ENGINE_META_MIRROR_11', name: '元镜引擎', kind: 'pipeline', src: '第4部分(元镜自我审视)', implements: ['自我审视 → 能力清单 → 未考虑声明 → 审查标记'],
|
|
159
|
+
exec(inp, t) {
|
|
160
|
+
const covered = inp.covered || [], unconsidered = inp.unconsidered;
|
|
161
|
+
const pass = covered.length > 0 && Array.isArray(unconsidered);
|
|
162
|
+
return { success: pass, kind: 'pipeline', output: { covered: covered.length, unconsidered: Array.isArray(unconsidered) ? unconsidered : null, mark: pass ? '战略思考审查通过' : '未经战略思考审查' },
|
|
163
|
+
error: pass ? undefined : '须声明已考虑维度与非空 unconsidered 数组', reason: pass ? undefined : 'PRECONDITION_FAILED',
|
|
164
|
+
provenance: [`[${t}] meta-mirror: 覆盖 ${covered.length},unconsidered ${Array.isArray(unconsidered) ? unconsidered.length : '缺失'}`] };
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
/* ══════════ 四、数学族 4 条 ══════════ */
|
|
169
|
+
add({
|
|
170
|
+
id: 'ENGINE_ZERO_CORRELATION_58', name: '零点关联分析引擎', kind: 'compute', src: '第1部分 §2.1(V16.4)', implements: ['零点间距相关性(Pearson r)'],
|
|
171
|
+
exec(inp, t) {
|
|
172
|
+
const gaps = inp.gaps;
|
|
173
|
+
if (!Array.isArray(gaps) || gaps.length < 3) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供长度≥3 的 gaps' };
|
|
174
|
+
const x = gaps.slice(0, -1).map(Number), y = gaps.slice(1).map(Number);
|
|
175
|
+
const mx = mean(x), my = mean(y);
|
|
176
|
+
const num = x.reduce((s, xi, i) => s + (xi - mx) * (y[i] - my), 0);
|
|
177
|
+
const den = Math.sqrt(x.reduce((s, xi) => s + (xi - mx) ** 2, 0) * y.reduce((s, yi) => s + (yi - my) ** 2, 0));
|
|
178
|
+
const r = round(den ? num / den : 0, 4);
|
|
179
|
+
return { success: true, kind: 'compute', output: { gaps: gaps.length, lag1Correlation: r, interpretation: Math.abs(r) < 0.2 ? '弱相关(近独立)' : r > 0 ? '正相关(聚集)' : '负相关(交替)',
|
|
180
|
+
reference: 'GUE 预测相邻间距近独立,|r| 应接近 0' },
|
|
181
|
+
provenance: [`[${t}] zero-correlation: lag-1 r=${r}`] };
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
add({
|
|
185
|
+
id: 'ENGINE_ZETA_DEEP_59', name: 'ζ函数深层分析引擎', kind: 'compute', src: '第1部分 §2.1(V16.4)', implements: ['Dirichlet η 级数收敛计算 + 临界线采样'],
|
|
186
|
+
exec(inp, t) {
|
|
187
|
+
const sigma = Number(inp.sigma ?? 0.5), tt = Number(inp.t ?? 14.134725), N = Number(inp.terms ?? 2000);
|
|
188
|
+
if (!isFinite(sigma) || !isFinite(tt)) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 sigma / t 数值' };
|
|
189
|
+
/* η(s) = Σ (-1)^(n-1) / n^s,收敛于 Re(s)>0 */
|
|
190
|
+
let re = 0, im = 0;
|
|
191
|
+
for (let n = 1; n <= N; n++) {
|
|
192
|
+
const sign = n % 2 === 1 ? 1 : -1;
|
|
193
|
+
const lnN = Math.log(n);
|
|
194
|
+
const mag = Math.pow(n, -sigma);
|
|
195
|
+
const ang = -tt * lnN;
|
|
196
|
+
re += sign * mag * Math.cos(ang);
|
|
197
|
+
im += sign * mag * Math.sin(ang);
|
|
198
|
+
}
|
|
199
|
+
const eta = Math.sqrt(re * re + im * im);
|
|
200
|
+
/* ζ = η / (1 - 2^(1-s)) */
|
|
201
|
+
const dRe = 1 - Math.pow(2, 1 - sigma) * Math.cos(-tt * Math.LN2);
|
|
202
|
+
const dIm = -Math.pow(2, 1 - sigma) * Math.sin(-tt * Math.LN2);
|
|
203
|
+
const dMag = Math.sqrt(dRe * dRe + dIm * dIm);
|
|
204
|
+
const zeta = round(eta / (dMag || 1e-12), 6);
|
|
205
|
+
return { success: true, kind: 'compute', output: { sigma, t: tt, terms: N, etaMagnitude: round(eta), zetaMagnitude: zeta,
|
|
206
|
+
onCriticalLine: sigma === 0.5, note: 'η 级数在 Re(s)>0 收敛;此处为有限项近似' },
|
|
207
|
+
provenance: [`[${t}] zeta-deep: |ζ(${sigma}+${tt}i)| ≈ ${zeta}(${N} 项)`] };
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
add({
|
|
211
|
+
id: 'ENGINE_RANDOM_MATRIX_62', name: '随机矩阵引擎', kind: 'compute', src: '第2部分(GUE 统计)', implements: ['Wigner 半圆律边界 + 谱半径估计'],
|
|
212
|
+
exec(inp, t) {
|
|
213
|
+
const M = inp.matrix;
|
|
214
|
+
if (!Array.isArray(M) || !M.length || !Array.isArray(M[0])) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供二维 matrix' };
|
|
215
|
+
const n = M.length;
|
|
216
|
+
/* 幂迭代估谱半径 */
|
|
217
|
+
let v = new Array(n).fill(1 / Math.sqrt(n));
|
|
218
|
+
for (let it = 0; it < 100; it++) {
|
|
219
|
+
const w = new Array(n).fill(0);
|
|
220
|
+
for (let i = 0; i < n; i++) for (let j = 0; j < n; j++) w[i] += Number(M[i][j] || 0) * v[j];
|
|
221
|
+
const nw = Math.sqrt(w.reduce((s, x) => s + x * x, 0)) || 1;
|
|
222
|
+
v = w.map((x) => x / nw);
|
|
223
|
+
}
|
|
224
|
+
let lambda = 0;
|
|
225
|
+
for (let i = 0; i < n; i++) { let s = 0; for (let j = 0; j < n; j++) s += Number(M[i][j] || 0) * v[j]; lambda += v[i] * s; }
|
|
226
|
+
const semiCircleBound = 2 * Math.sqrt(n);
|
|
227
|
+
return { success: true, kind: 'compute', output: { size: n, spectralRadius: round(Math.abs(lambda)), semiCircleBound: round(semiCircleBound), withinBound: Math.abs(lambda) <= semiCircleBound * 1.5,
|
|
228
|
+
rule: 'Wigner 半圆律:标准化后谱半径上界 ≈ 2√n' },
|
|
229
|
+
provenance: [`[${t}] random-matrix: ${n}×${n} 谱半径 ${round(Math.abs(lambda))}`] };
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
add({
|
|
233
|
+
id: 'ENGINE_QUANTUM_CHAOS_63', name: '量子混沌引擎', kind: 'compute', src: '第2部分(能级统计)', implements: ['能级间距比 ⟨r⟩ + Poisson/GUE 判别 + 混沌度'],
|
|
234
|
+
exec(inp, t) {
|
|
235
|
+
const lv = inp.levels;
|
|
236
|
+
if (!Array.isArray(lv) || lv.length < 4) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供长度≥4 的 levels' };
|
|
237
|
+
const s = lv.map(Number).sort((a, b) => a - b).slice(1).map((x, i) => x - lv.map(Number).sort((a, b) => a - b)[i]).filter((x) => x > 0);
|
|
238
|
+
const r = s.slice(0, -1).map((x, i) => Math.min(x, s[i + 1]) / Math.max(x, s[i + 1]));
|
|
239
|
+
const rBar = round(mean(r), 4);
|
|
240
|
+
const chaos = round(clamp01((rBar - 0.386) / (0.53 - 0.386)));
|
|
241
|
+
return { success: true, kind: 'compute', output: { levels: lv.length, spacings: s.length, rBar, poissonRef: 0.386, gueRef: 0.53, chaosDegree: chaos,
|
|
242
|
+
regime: Math.abs(rBar - 0.386) < Math.abs(rBar - 0.53) ? '可积(Poisson)' : '混沌(GUE)' },
|
|
243
|
+
provenance: [`[${t}] quantum-chaos: ⟨r⟩=${rBar} → 混沌度 ${chaos}`] };
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
add({
|
|
247
|
+
id: 'ENGINE_CUV_PROVER_157', name: 'CUV形式化推理引擎', kind: 'rule', src: '第3部分(1499 字符)', implements: ['C/U/V 三映射 + 证明三要素 + 验证器白名单'],
|
|
248
|
+
exec(inp, t) {
|
|
249
|
+
const m = inp.mappings || {}, p = inp.proof || {};
|
|
250
|
+
const mMiss = ['C', 'U', 'V'].filter((k) => !m[k]);
|
|
251
|
+
const pMiss = ['statement', 'process', 'verifiedBy'].filter((k) => !p[k]);
|
|
252
|
+
const V = ['lean', 'coq', 'isabelle'];
|
|
253
|
+
const badV = p.verifiedBy && !V.includes(String(p.verifiedBy).toLowerCase());
|
|
254
|
+
const ok = mMiss.length === 0 && pMiss.length === 0 && !badV;
|
|
255
|
+
return { success: ok, kind: 'rule', output: { mappings: mMiss.length ? mMiss : 'ok', proofMissing: pMiss, verifierWhitelist: V, verifier: p.verifiedBy || null },
|
|
256
|
+
error: mMiss.length ? `缺映射:${mMiss.join('/')}` : pMiss.length ? `缺证明要素:${pMiss.join('/')}` : badV ? `验证器 ${p.verifiedBy} 不在白名单` : undefined,
|
|
257
|
+
reason: ok ? undefined : 'RULE_VIOLATED', provenance: [`[${t}] cuv-prover: 映射 ${3 - mMiss.length}/3,证明 ${3 - pMiss.length}/3`] };
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
/* ══════════ 五、智能体族 201–204 ══════════ */
|
|
262
|
+
for (const [id, nm, dims, th] of [
|
|
263
|
+
['ENGINE_COGNITIVE_201', '认知智能体引擎', ['理解', '推理', '记忆', '学习'], 0.7],
|
|
264
|
+
['ENGINE_COLLABORATION_203', '协同智能体引擎', ['沟通', '协调', '共识', '分工'], 0.7],
|
|
265
|
+
['ENGINE_DATA_204', '数据智能体引擎', ['采集', '清洗', '分析', '呈现'], 0.7],
|
|
266
|
+
['ENGINE_EXECUTION_202', '执行智能体引擎', ['计划', '行动', '监控', '回滚'], 0.7],
|
|
267
|
+
]) scorer(id, nm, '第4部分(智能体族)', dims, [0.3, 0.3, 0.2, 0.2], th, '四维能力加权');
|
|
268
|
+
|
|
269
|
+
/* ══════════ 六、世界模型族 6 条 ══════════ */
|
|
270
|
+
scorer('ENGINE_WORLD_REP_139', '世界表征融合引擎', '第3部分', ['视觉', '语言', '空间', '时序', '因果'], [0.25, 0.25, 0.2, 0.15, 0.15], 0.6, '五模态表征融合');
|
|
271
|
+
scorer('ENGINE_WORLD_MODEL_70', '世界模型引擎', '第2部分', ['表征', '预测', '规划', '评估'], [0.3, 0.3, 0.25, 0.15], 0.65, '四能力世界模型');
|
|
272
|
+
add({
|
|
273
|
+
id: 'ENGINE_WORLD_PREDICT_140', name: '世界推演预测引擎', kind: 'compute', src: '第3部分', implements: ['多步预测 + 误差累积评估'],
|
|
274
|
+
exec(inp, t) {
|
|
275
|
+
const s = inp.history, k = Number(inp.horizon ?? 3);
|
|
276
|
+
if (!Array.isArray(s) || s.length < 3) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供长度≥3 的 history' };
|
|
277
|
+
const v = s.map(Number), n = v.length;
|
|
278
|
+
const slope = (v[n - 1] - v[0]) / (n - 1);
|
|
279
|
+
const preds = Array.from({ length: k }, (_, i) => round(v[n - 1] + slope * (i + 1)));
|
|
280
|
+
const err = round(Math.abs(slope) * k);
|
|
281
|
+
return { success: true, kind: 'compute', output: { points: n, slope: round(slope), horizon: k, predictions: preds, cumulativeErrorEstimate: err, caveat: '线性外推,误差随步数线性累积' },
|
|
282
|
+
provenance: [`[${t}] world-predict: ${k} 步 → ${preds.join(',')}`] };
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
gate('ENGINE_SYSTEM_WARGAME_164', '系统级兵棋推演引擎', 'pipeline', '第4部分', ['scenario', 'actors', 'moves', 'outcomes'], '多方博弈推演');
|
|
286
|
+
gate('ENGINE_WORLD_BENCH_151', '世界模型评测沙盒引擎', 'pipeline', '第3部分', ['testCases', 'metrics', 'baseline', 'report'], '沙盒评测');
|
|
287
|
+
scorer('ENGINE_SPATIAL_INTEL_141', '空间智能引擎', '第3部分', ['定位', '建图', '避障', '路径规划'], [0.25, 0.3, 0.2, 0.25], 0.65, '四能力空间智能');
|
|
288
|
+
|
|
289
|
+
/* ══════════ 七、组织 / 伙伴 / 权限 7 条 ══════════ */
|
|
290
|
+
scorer('ENGINE_ORG_COUPLING_20', '组织耦生度计算引擎', '第1部分', ['目标一致', '信息通畅', '权责清晰', '激励对齐'], [0.3, 0.25, 0.25, 0.2], 0.7, '四维组织耦生');
|
|
291
|
+
gate('ENGINE_ORG_AGENT_21', '组织智能体进化引擎', 'pipeline', '第1部分', ['stage', 'coupling', 'evolutionPath', 'verified'], '四阶段演进');
|
|
292
|
+
gate('ENGINE_NETWORK_COUPLING_27', '网络耦生度引擎', 'pipeline', '附录卷-第2部分 L6287', ['nodes', 'edges'], '母平台-节点动态耦生度矩阵');
|
|
293
|
+
gate('ENGINE_PARTNER_110', '生态伙伴管理引擎', 'pipeline', '第2部分', ['partnerId', 'status', 'capability', 'agreement'], '伙伴四要素');
|
|
294
|
+
gate('ENGINE_PARTNER_ECO_116', '生态伙伴管理引擎(生态版)', 'pipeline', '第2部分', ['partnerId', 'status', 'capability', 'agreement', 'ecosystemRole'], '生态伙伴五要素');
|
|
295
|
+
add({
|
|
296
|
+
id: 'ENGINE_PERMISSION_99', name: '权限声明引擎', kind: 'rule', src: '第2部分', implements: ['权限最小化 + 越权拒绝'],
|
|
297
|
+
exec(inp, t) {
|
|
298
|
+
const granted = inp.granted || [], requested = inp.requested || [];
|
|
299
|
+
if (!requested.length) return { success: false, kind: 'rule', reason: 'INVALID_INPUT', error: '必须提供 requested 权限数组' };
|
|
300
|
+
const denied = requested.filter((r) => !granted.includes(r));
|
|
301
|
+
return { success: denied.length === 0, kind: 'rule', output: { granted, requested, denied, minimal: requested.length <= granted.length },
|
|
302
|
+
error: denied.length ? `越权请求:${denied.join('/')}` : undefined, reason: denied.length ? 'RULE_VIOLATED' : undefined,
|
|
303
|
+
provenance: [`[${t}] permission: 请求 ${requested.length},拒绝 ${denied.length}`] };
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
add({
|
|
307
|
+
id: 'ENGINE_SANDBOX_100', name: '双层沙箱引擎', kind: 'rule', src: '第2部分', implements: ['第一层静态检查 + 第二层运行时隔离'],
|
|
308
|
+
exec(inp, t) {
|
|
309
|
+
const code = String(inp.code || '');
|
|
310
|
+
const BANNED = /\b(require|process|globalThis|eval|Function|import|__proto__|child_process)\b/;
|
|
311
|
+
const layer1 = !BANNED.test(code);
|
|
312
|
+
const layer2 = inp.runtimeIsolated === true;
|
|
313
|
+
const fails = [];
|
|
314
|
+
if (!layer1) fails.push('静态检查命中禁用构造');
|
|
315
|
+
if (!layer2) fails.push('第二层运行时未隔离');
|
|
316
|
+
return { success: fails.length === 0, kind: 'rule', output: { layer1Static: layer1, layer2Runtime: layer2, fails, note: '双层缺一不可' },
|
|
317
|
+
error: fails.length ? fails.join(';') : undefined, reason: fails.length ? 'RULE_VIOLATED' : undefined,
|
|
318
|
+
provenance: [`[${t}] sandbox: L1 ${layer1} / L2 ${layer2}`] };
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
add({
|
|
322
|
+
id: 'ENGINE_VAULT_98', name: '密钥保险库引擎', kind: 'rule', src: '第2部分', implements: ['三项要求(加密存储/访问审计/轮换)'],
|
|
323
|
+
exec(inp, t) {
|
|
324
|
+
const enc = inp.encryptedAtRest === true, audited = inp.accessAudited === true, rot = Number(inp.rotationDays ?? 0), maxRot = Number(inp.maxRotationDays ?? 90);
|
|
325
|
+
const fails = [];
|
|
326
|
+
if (!enc) fails.push('未加密存储');
|
|
327
|
+
if (!audited) fails.push('访问未审计');
|
|
328
|
+
if (rot > maxRot) fails.push(`密钥 ${rot} 天未轮换(上限 ${maxRot})`);
|
|
329
|
+
return { success: fails.length === 0, kind: 'rule', output: { encryptedAtRest: enc, accessAudited: audited, rotationDays: rot, maxRotationDays: maxRot, fails },
|
|
330
|
+
error: fails.length ? fails.join(';') : undefined, reason: fails.length ? 'RULE_VIOLATED' : undefined,
|
|
331
|
+
provenance: [`[${t}] vault: ${fails.length ? '不合规' : '合规'}`] };
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
/* ══════════ 八、A2A/交易/Token 5 条 ══════════ */
|
|
336
|
+
add({
|
|
337
|
+
id: 'ENGINE_A2A_MARKET_149', name: 'A2A经济市场引擎', kind: 'compute', src: '第3部分(1038 字符)', implements: ['供需匹配 + 清算价(中间价法)'],
|
|
338
|
+
exec(inp, t) {
|
|
339
|
+
const bids = inp.bids || [], asks = inp.asks || [];
|
|
340
|
+
if (!bids.length || !asks.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 bids 与 asks' };
|
|
341
|
+
const bid = Math.max(...bids.map((b) => Number(b.price)));
|
|
342
|
+
const ask = Math.min(...asks.map((a) => Number(a.price)));
|
|
343
|
+
const mid = round((bid + ask) / 2, 4);
|
|
344
|
+
const spread = round(ask - bid);
|
|
345
|
+
const tradable = bid >= ask;
|
|
346
|
+
return { success: true, kind: 'compute', output: { bestBid: bid, bestAsk: ask, midPrice: mid, spread, tradable, volume: Math.min(bids.length, asks.length) },
|
|
347
|
+
provenance: [`[${t}] a2a-market: bid ${bid} / ask ${ask} → 中间价 ${mid},可成交 ${tradable}`] };
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
add({
|
|
351
|
+
id: 'ENGINE_TRADE_SETTLE_155', name: '交易结算引擎', kind: 'pipeline', src: '第3部分', implements: ['四步结算(撮合→清算→交割→对账)'],
|
|
352
|
+
exec(inp, t) {
|
|
353
|
+
const F = ['matched', 'cleared', 'delivered', 'reconciled'];
|
|
354
|
+
const miss = F.filter((k) => !(inp && inp[k]));
|
|
355
|
+
return { success: miss.length === 0, kind: 'pipeline', output: { steps: F, missing: miss, amount: inp.amount ?? null },
|
|
356
|
+
error: miss.length ? `结算缺:${miss.join('/')}` : undefined, reason: miss.length ? 'PRECONDITION_FAILED' : undefined,
|
|
357
|
+
provenance: [`[${t}] trade-settle: ${4 - miss.length}/4`] };
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
add({
|
|
361
|
+
id: 'ENGINE_TOKEN_MINT_148', name: 'Token经济铸币引擎', kind: 'compute', src: '第3部分', implements: ['铸币量 = 贡献值 × 汇率 × 通缩系数'],
|
|
362
|
+
exec(inp, t) {
|
|
363
|
+
const contrib = Number(inp.contribution ?? 0), rate = Number(inp.exchangeRate ?? 1), deflate = clamp01(inp.deflationFactor ?? 0.02);
|
|
364
|
+
if (contrib < 0) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: 'contribution 不可为负' };
|
|
365
|
+
const minted = round(contrib * rate * (1 - deflate), 6);
|
|
366
|
+
return { success: true, kind: 'compute', output: { contribution: contrib, exchangeRate: rate, deflationFactor: deflate, minted, formula: '铸币量 = 贡献 × 汇率 × (1 − 通缩系数)' },
|
|
367
|
+
provenance: [`[${t}] token-mint: ${contrib}×${rate}×(1−${deflate}) = ${minted}`] };
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
add({
|
|
371
|
+
id: 'ENGINE_ROI_QUANT_150', name: 'ROI量化仪表盘引擎', kind: 'compute', src: '第3部分(D30 ROI周期,目标<3月)', implements: ['ROI 周期 = 总投入 / 月均创造价值'],
|
|
372
|
+
exec(inp, t) {
|
|
373
|
+
const invest = Number(inp.totalInvest), monthly = Number(inp.monthlyValue);
|
|
374
|
+
if (!isFinite(invest) || !isFinite(monthly) || monthly === 0) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 totalInvest 与 非零 monthlyValue' };
|
|
375
|
+
const months = round(invest / monthly, 2);
|
|
376
|
+
const target = Number(inp.targetMonths ?? 3);
|
|
377
|
+
return { success: months <= target, kind: 'compute', output: { totalInvest: invest, monthlyValue: monthly, roiMonths: months, targetMonths: target, meets: months <= target,
|
|
378
|
+
formula: 'ROI周期 = 总投入 / 月均创造价值(D30,目标 <3 个月)' },
|
|
379
|
+
error: months > target ? `ROI 周期 ${months} 月 > 目标 ${target} 月` : undefined,
|
|
380
|
+
reason: months > target ? 'PRECONDITION_FAILED' : undefined,
|
|
381
|
+
provenance: [`[${t}] roi-quant: ${invest}/${monthly} = ${months} 月`] };
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
scorer('ENGINE_FANGSHENG_BENCH_169', '方升/可信AI评测对接引擎', '第4部分', ['安全性', '可靠性', '可解释', '公平性', '鲁棒性'], [0.3, 0.25, 0.15, 0.15, 0.15], 0.75, '可信 AI 五维评测');
|
|
385
|
+
|
|
386
|
+
/* ══════════ 九、工业 / 边界 / 沙箱辅助 8 条 ══════════ */
|
|
387
|
+
for (const [id, nm, ver] of [['ENGINE_DIGITAL_TWIN_102', '设备数字孪生引擎', '基础版'], ['ENGINE_DIGITAL_TWIN_112', '设备数字孪生引擎', '增强版']]) {
|
|
388
|
+
add({
|
|
389
|
+
id, name: `${nm}(${ver})`, kind: 'compute', src: '第2部分', implements: ['孪生同步误差 + 状态一致性'],
|
|
390
|
+
exec(inp, t) {
|
|
391
|
+
const real = inp.realState, twin = inp.twinState;
|
|
392
|
+
if (!Array.isArray(real) || !Array.isArray(twin) || real.length !== twin.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: 'realState/twinState 须为等长数组' };
|
|
393
|
+
const diffs = real.map((x, i) => Math.abs(Number(x) - Number(twin[i])));
|
|
394
|
+
const maxDiff = round(Math.max(...diffs)), tol = Number(inp.tolerance ?? 0.05);
|
|
395
|
+
return { success: maxDiff <= tol, kind: 'compute', output: { dims: real.length, maxDiff, tolerance: tol, synced: maxDiff <= tol, version: ver },
|
|
396
|
+
error: maxDiff > tol ? `孪生偏差 ${maxDiff} > 容差 ${tol}` : undefined,
|
|
397
|
+
reason: maxDiff > tol ? 'PRECONDITION_FAILED' : undefined,
|
|
398
|
+
provenance: [`[${t}] digital-twin: ${real.length} 维,最大偏差 ${maxDiff}`] };
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
for (const [id, ver] of [['ENGINE_PROTOCOL_ADAPT_101', 'V1'], ['ENGINE_PROTOCOL_ADAPT_111', 'V2']]) {
|
|
403
|
+
add({
|
|
404
|
+
id, name: `工业协议适配引擎(${ver})`, kind: 'rule', src: '第2部分', implements: ['协议白名单 + 点表映射完整性'],
|
|
405
|
+
exec(inp, t) {
|
|
406
|
+
const P = ['OPC-UA', 'Modbus', 'Profinet', 'EtherCAT', 'MQTT', 'CAN'];
|
|
407
|
+
const p = String(inp.protocol || '');
|
|
408
|
+
if (!P.includes(p)) return { success: false, kind: 'rule', reason: 'INVALID_INPUT', error: `协议须为 ${P.join('/')}` };
|
|
409
|
+
const points = inp.pointTable || [];
|
|
410
|
+
const unmapped = points.filter((x) => !x.source || !x.target);
|
|
411
|
+
const ok = unmapped.length === 0 && points.length > 0;
|
|
412
|
+
return { success: ok, kind: 'rule', output: { version: ver, protocol: p, whitelist: P, points: points.length, unmapped: unmapped.length },
|
|
413
|
+
error: !points.length ? '点表为空' : unmapped.length ? `${unmapped.length} 个点位未映射` : undefined,
|
|
414
|
+
reason: ok ? undefined : 'RULE_VIOLATED', provenance: [`[${t}] protocol-adapt-${ver}: ${p},点位 ${points.length},未映射 ${unmapped.length}`] };
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
gate('ENGINE_PHYSICAL_ACTION_69', '物理行动引擎', 'pipeline', '第2部分', ['simulated', 'safetyCheck', 'executed', 'feedback'], '物理行动四步(先虚拟推演)');
|
|
419
|
+
gate('ENGINE_EMBODIED_AI_156', '具身智能引擎', 'pipeline', '第3部分', ['perception', 'planning', 'control', 'feedback'], '具身四环');
|
|
420
|
+
add({
|
|
421
|
+
id: 'ENGINE_FIRMWARE_SEC_113', name: '固件安全扫描引擎', kind: 'rule', src: '第2部分', implements: ['四项扫描(签名/版本/CVE/完整性)'],
|
|
422
|
+
exec(inp, t) {
|
|
423
|
+
const f = inp.firmware || {};
|
|
424
|
+
const C = [['signed', '签名'], ['versionCurrent', '版本'], ['noKnownCve', 'CVE'], ['integrityOk', '完整性']];
|
|
425
|
+
const failed = C.filter(([k]) => f[k] !== true).map(([, l]) => l);
|
|
426
|
+
return { success: failed.length === 0, kind: 'rule', output: { checks: C.map(([k, l]) => ({ key: k, label: l, ok: f[k] === true })), failed },
|
|
427
|
+
error: failed.length ? `固件未过:${failed.join('/')}` : undefined, reason: failed.length ? 'RULE_VIOLATED' : undefined,
|
|
428
|
+
provenance: [`[${t}] firmware-sec: ${4 - failed.length}/4`] };
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
add({
|
|
432
|
+
id: 'ENGINE_DOMESTIC_AI_ADAPT_131', name: '国产AI算力适配引擎', kind: 'rule', src: '第3部分', implements: ['国产芯片/框架白名单 + 兼容性'],
|
|
433
|
+
exec(inp, t) {
|
|
434
|
+
const CHIPS = ['昇腾', '寒武纪', '海光', '壁仞', '摩尔线程'];
|
|
435
|
+
const FRAMES = ['MindSpore', 'PaddlePaddle', 'PyTorch', 'OneFlow'];
|
|
436
|
+
const c = String(inp.chip || ''), fw = String(inp.framework || '');
|
|
437
|
+
const cOk = CHIPS.includes(c), fOk = FRAMES.includes(fw);
|
|
438
|
+
const ok = cOk && fOk;
|
|
439
|
+
return { success: ok, kind: 'rule', output: { chip: c, framework: fw, chipWhitelist: CHIPS, frameworkWhitelist: FRAMES, chipOk: cOk, frameworkOk: fOk },
|
|
440
|
+
error: !cOk ? `芯片 ${c} 不在适配白名单` : !fOk ? `框架 ${fw} 不在适配白名单` : undefined,
|
|
441
|
+
reason: ok ? undefined : 'RULE_VIOLATED', provenance: [`[${t}] domestic-ai: ${c}/${fw} ${ok ? '兼容' : '不兼容'}`] };
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
gate('ENGINE_EDGE_DEPLOY_132X', '占位', 'pipeline', '-', ['x'], '-'); E.pop(); /* 移除占位 */
|
|
445
|
+
|
|
446
|
+
/* ══════════ 十、创造 / 思想 / 知识 12 条 ══════════ */
|
|
447
|
+
add({
|
|
448
|
+
id: 'ENGINE_IDEA_CAPITAL_36', name: '思想资本引擎', kind: 'compute', src: '附录卷-第2部分 L7338', implements: ['思想资本 = 价值 × 流动性 × 传承系数'],
|
|
449
|
+
exec(inp, t) {
|
|
450
|
+
const value = clamp01(inp.ideaValue ?? 0.5), flow = clamp01(inp.liquidity ?? 0.5), inherit = clamp01(inp.inheritance ?? 0.6);
|
|
451
|
+
const capital = round(value * flow * inherit, 6);
|
|
452
|
+
return { success: true, kind: 'compute', output: { ideaValue: value, liquidity: flow, inheritance: inherit, capital, formula: '思想资本 = 价值 × 流动性 × 传承系数' },
|
|
453
|
+
provenance: [`[${t}] idea-capital: ${value}×${flow}×${inherit} = ${capital}`] };
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
for (const [id, nm] of [['ENGINE_IDEA_ALGO_32', '思想算法引擎'], ['ENGINE_IDEA_MULTIPLY_34', '思想增殖引擎'], ['ENGINE_DIALOG_CREATE_31', '对话创造引擎'], ['ENGINE_HUMAN_AI_SYM_33', '人机共生引擎'], ['ENGINE_TIME_RECON_30', '时间重构引擎']]) {
|
|
457
|
+
gate(id, nm, 'pipeline', `第2部分(${nm})`, ['input', 'process', 'output', 'verified'], '四要素闭环');
|
|
458
|
+
}
|
|
459
|
+
add({
|
|
460
|
+
id: 'ENGINE_MULTI_WORLD_THINK_39', name: '多世界思考引擎', kind: 'compute', src: '第2部分', implements: ['多分支并行推演 + 分支权重'],
|
|
461
|
+
exec(inp, t) {
|
|
462
|
+
const worlds = inp.worlds;
|
|
463
|
+
if (!Array.isArray(worlds) || !worlds.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 worlds 数组' };
|
|
464
|
+
const total = worlds.reduce((s, w) => s + clamp01(w.probability ?? 1 / worlds.length), 0) || 1;
|
|
465
|
+
const ranked = worlds.map((w) => ({ name: w.name, probability: round(clamp01(w.probability ?? 1 / worlds.length) / total), outcome: w.outcome })).sort((a, b) => b.probability - a.probability);
|
|
466
|
+
return { success: true, kind: 'compute', output: { branches: worlds.length, ranked, topBranch: ranked[0].name },
|
|
467
|
+
provenance: [`[${t}] multi-world-think: ${worlds.length} 分支,主导「${ranked[0].name}」`] };
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
for (const [id, nm] of [['ENGINE_KNOWLEDGE_02', '知识引擎'], ['ENGINE_UNIVERSAL_KNOWLEDGE_145', '通用知识库引擎']]) {
|
|
471
|
+
add({
|
|
472
|
+
id, name: nm, kind: 'compute', src: '第2部分', implements: ['知识沉淀率 + 复用率 + 衰减判定'],
|
|
473
|
+
exec(inp, t) {
|
|
474
|
+
const items = Number(inp.items ?? 0), reused = Number(inp.reusedItems ?? 0), ageDays = Number(inp.avgAgeDays ?? 0);
|
|
475
|
+
if (items <= 0) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: 'items 必须 > 0' };
|
|
476
|
+
const reuseRate = round(clamp01(reused / items));
|
|
477
|
+
const decayed = ageDays > Number(inp.maxAgeDays ?? 365);
|
|
478
|
+
return { success: !decayed, kind: 'compute', output: { items, reused, reuseRate, avgAgeDays: ageDays, decayed, health: round(reuseRate * (decayed ? 0.5 : 1)) },
|
|
479
|
+
error: decayed ? `知识平均年龄 ${ageDays} 天已衰减` : undefined, reason: decayed ? 'PRECONDITION_FAILED' : undefined,
|
|
480
|
+
provenance: [`[${t}] knowledge: ${items} 条,复用率 ${reuseRate}`] };
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
add({
|
|
485
|
+
id: 'ENGINE_INTRINSIC_MOTIVE_144', name: '内在动机管理引擎', kind: 'compute', src: '第3部分', implements: ['内在动机三维(自主/胜任/联结,SDT)加权'],
|
|
486
|
+
exec(inp, t) {
|
|
487
|
+
const a = clamp01(inp.autonomy ?? 0.7), c = clamp01(inp.competence ?? 0.7), r = clamp01(inp.relatedness ?? 0.7);
|
|
488
|
+
const motive = round((a + c + r) / 3);
|
|
489
|
+
return { success: true, kind: 'compute', output: { autonomy: a, competence: c, relatedness: r, intrinsicMotive: motive, threshold: 0.6, sustained: motive >= 0.6, formula: '内在动机 = (自主 + 胜任 + 联结)/3(自我决定理论)' },
|
|
490
|
+
provenance: [`[${t}] intrinsic-motive: (${a}+${c}+${r})/3 = ${motive}`] };
|
|
491
|
+
},
|
|
492
|
+
});
|
|
493
|
+
add({
|
|
494
|
+
id: 'ENGINE_PROBLEM_TRACE_73', name: '问题溯源引擎', kind: 'pipeline', src: '第2部分', implements: ['五问链 + 深度≥3 + 可解域映射'],
|
|
495
|
+
exec(inp, t) {
|
|
496
|
+
const chain = inp.whyChain || [];
|
|
497
|
+
const depth = chain.length;
|
|
498
|
+
const last = chain[depth - 1];
|
|
499
|
+
const ok = depth >= 3 && last && (last.domain || last.solvable === true);
|
|
500
|
+
return { success: ok, kind: 'pipeline', output: { depth, minDepth: 3, solvableDomain: last && last.domain, chain },
|
|
501
|
+
error: depth < 3 ? `深度 ${depth} < 3(A9 溯源公理)` : !(last && last.domain) ? '末层未映射可解域' : undefined,
|
|
502
|
+
reason: ok ? undefined : 'PRECONDITION_FAILED', provenance: [`[${t}] problem-trace: 深度 ${depth}`] };
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
add({
|
|
506
|
+
id: 'ENGINE_REASON_CORRECT_94', name: '推理纠正引擎', kind: 'rule', src: '第2部分', implements: ['逻辑谬误检测(六类)+ 纠正建议'],
|
|
507
|
+
exec(inp, t) {
|
|
508
|
+
const text = String(inp.reasoning || '');
|
|
509
|
+
if (!text) return { success: false, kind: 'rule', reason: 'INVALID_INPUT', error: '必须提供 reasoning' };
|
|
510
|
+
const F = [
|
|
511
|
+
{ n: '循环论证', re: /因为(.{2,10})所以\1/ },
|
|
512
|
+
{ n: '以偏概全', re: /一个.*就说明所有|个别.*因此全部/ },
|
|
513
|
+
{ n: '滑坡谬误', re: /一旦.*就会.*最终.*毁灭|必然导致.*最终/ },
|
|
514
|
+
{ n: '诉诸权威', re: /专家说|权威认为|大师说/ },
|
|
515
|
+
{ n: '虚假两难', re: /要么.*要么.*没有第三种|不是.*就是.*别无/ },
|
|
516
|
+
{ n: '因果倒置', re: /相关.*就(是|说明).*因果/ },
|
|
517
|
+
];
|
|
518
|
+
const hits = F.filter((f) => f.re.test(text)).map((f) => f.n);
|
|
519
|
+
return { success: hits.length === 0, kind: 'rule', output: { penalties: F.map((f) => f.n), hits, clean: hits.length === 0 },
|
|
520
|
+
error: hits.length ? `检出谬误:${hits.join('、')}` : undefined, reason: hits.length ? 'RULE_VIOLATED' : undefined,
|
|
521
|
+
provenance: [`[${t}] reason-correct: ${hits.length} 类谬误`] };
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
add({
|
|
525
|
+
id: 'ENGINE_ONTOLOGY_ALIGNER_163', name: '本体论对齐引擎', kind: 'compute', src: '第4部分', implements: ['本体映射一致率'],
|
|
526
|
+
exec(inp, t) {
|
|
527
|
+
const a = inp.ontologyA || {}, b = inp.ontologyB || {};
|
|
528
|
+
const keys = [...new Set([...Object.keys(a), ...Object.keys(b)])];
|
|
529
|
+
if (!keys.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '至少提供一个本体' };
|
|
530
|
+
const matched = keys.filter((k) => a[k] !== undefined && b[k] !== undefined && String(a[k]) === String(b[k]));
|
|
531
|
+
const aligned = round(matched.length / keys.length);
|
|
532
|
+
const thr = Number(inp.threshold ?? 0.8);
|
|
533
|
+
return { success: aligned >= thr, kind: 'compute', output: { concepts: keys.length, matched: matched.length, alignment: aligned, threshold: thr, unmapped: keys.filter((k) => !matched.includes(k)) },
|
|
534
|
+
error: aligned < thr ? `本体对齐率 ${aligned} < ${thr}` : undefined,
|
|
535
|
+
reason: aligned < thr ? 'PRECONDITION_FAILED' : undefined,
|
|
536
|
+
provenance: [`[${t}] ontology-aligner: ${matched.length}/${keys.length} = ${aligned}`] };
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
scorer('ENGINE_QUALITY_INSPECT_170', '质量检测引擎', '第4部分', ['功能', '性能', '安全', '可用', '可维护'], [0.3, 0.2, 0.25, 0.15, 0.1], 0.75, '五维质量');
|
|
540
|
+
|
|
541
|
+
/* ══════════ 十一、其余 14 条 ══════════ */
|
|
542
|
+
gate('ENGINE_AGENT_CITY_147', '智能体城市引擎', 'pipeline', '第3部分', ['districts', 'agents', 'services', 'governance'], '智能体城市四要素');
|
|
543
|
+
gate('ENGINE_AGENT_FACTORY_146', '智能体生产线引擎', 'pipeline', '第3部分', ['requirement', 'design', 'assembly', 'inspection'], '生产线四步');
|
|
544
|
+
gate('ENGINE_CODE_WORLD_142', '代码世界引擎', 'pipeline', '第3部分', ['codeRepr', 'dependencyGraph', 'executionModel'], '代码世界三要素');
|
|
545
|
+
gate('ENGINE_AGENTIVE_INTERACTION_170', 'Agentive OS 原生交互引擎', 'pipeline', '第4部分', ['intent', 'context', 'action', 'feedback'], '原生交互四步');
|
|
546
|
+
gate('ENGINE_MODE_RESONANCE_167', '模数共振空间OS引擎', 'pipeline', '第4部分', ['digitalLayer', 'physicalLayer', 'resonance', 'operation'], '模数共振四层');
|
|
547
|
+
gate('ENGINE_ORCHESTRATION_161', '生态编排引擎', 'pipeline', '第4部分', ['services', 'dependencies', 'schedule', 'sla'], '编排四要素');
|
|
548
|
+
gate('ENGINE_REQUIREMENT_PARSE_167', '需求解析引擎', 'pipeline', '第4部分', ['rawRequirement', 'entities', 'intents', 'constraints'], '需求解析四步');
|
|
549
|
+
gate('ENGINE_ETHICS_COURT_152', '多Agent伦理法庭引擎', 'pipeline', '第3部分', ['case', 'jurors', 'arguments', 'verdict'], '伦理法庭四步');
|
|
550
|
+
gate('ENGINE_AUTONOMOUS_EXPLORE_44', '自主探索引擎', 'pipeline', '第2部分', ['frontier', 'budget', 'explored', 'returns'], '探索四要素');
|
|
551
|
+
gate('ENGINE_FUSION_45', '融合引擎', 'pipeline', '第2部分', ['sources', 'alignment', 'fused', 'verified'], '融合四步');
|
|
552
|
+
gate('ENGINE_VALUE_ALIGN_41', '价值对齐引擎', 'pipeline', '第2部分', ['riskScore', 'valueDims', 'aligned', 'recorded'], '价值对齐四步');
|
|
553
|
+
for (const [id, nm] of [['ENGINE_PROACTIVE_SENSE_37', '主动感知引擎'], ['ENGINE_PROACTIVE_LEARN_38', '主动学习引擎'], ['ENGINE_PROACTIVE_THINK_39', '主动思考引擎'], ['ENGINE_PROACTIVE_LEAD_40', '主动引领引擎']]) {
|
|
554
|
+
gate(id, nm, 'pipeline', '第2部分(前瞻族)', ['signal', 'assessment', 'output', 'feedback'], '四要素闭环');
|
|
555
|
+
}
|
|
556
|
+
add({
|
|
557
|
+
id: 'ENGINE_ACTIVE_42', name: '主动引擎', kind: 'compute', src: '附录卷-第2部分 L8342(§2.1 主动引擎)', implements: ['主动性得分 = 感知×判断×行动×反馈'],
|
|
558
|
+
exec(inp, t) {
|
|
559
|
+
const s = clamp01(inp.sense ?? 0.7), j = clamp01(inp.judge ?? 0.7), a = clamp01(inp.act ?? 0.7), f = clamp01(inp.feedback ?? 0.7);
|
|
560
|
+
const score = round(s * j * a * f, 6);
|
|
561
|
+
return { success: true, kind: 'compute', output: { sense: s, judge: j, act: a, feedback: f, proactiveness: score, threshold: 0.2, active: score >= 0.2, formula: '主动性 = 感知 × 判断 × 行动 × 反馈' },
|
|
562
|
+
provenance: [`[${t}] active: ${s}×${j}×${a}×${f} = ${score}`] };
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
add({
|
|
566
|
+
id: 'ENGINE_NEGENTROPY_FORMAL_165', name: '负熵形式化引擎', kind: 'compute', src: '第3部分(对应 PROTOCOL_NEGENTROPY_FORMAL_V1)', implements: ['Shannon 熵 + 负熵 + BPS 量化'],
|
|
567
|
+
exec(inp, t) {
|
|
568
|
+
const d = inp.distribution;
|
|
569
|
+
if (!Array.isArray(d) || !d.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 distribution 数组' };
|
|
570
|
+
const v = d.map(Number).filter((x) => x >= 0), s = v.reduce((a, b) => a + b, 0);
|
|
571
|
+
if (!s) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '分布和必须 > 0' };
|
|
572
|
+
const H = round(-v.map((x) => x / s).reduce((a, p) => a + (p > 0 ? p * Math.log(p) : 0), 0));
|
|
573
|
+
const base = Number(inp.baselineEntropy ?? H);
|
|
574
|
+
const neg = round(base - H);
|
|
575
|
+
return { success: true, kind: 'compute', output: { entropy: H, baseline: base, negentropy: neg, bps: Math.round(neg * 1e9), formula: 'S=-Σp·ln p;负熵=基线−当前;BPS=1e-9 bit' },
|
|
576
|
+
provenance: [`[${t}] negentropy-formal: H=${H} → 负熵 ${neg}`] };
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
add({
|
|
580
|
+
id: 'ENGINE_OUTPUT_INTEGRITY_171', name: '输出完整性保障引擎', kind: 'rule', src: '第4部分', implements: ['四类检测(占位符/未定义/伪造/悬空引用)'],
|
|
581
|
+
exec(inp, t) {
|
|
582
|
+
const text = String(inp.text || '');
|
|
583
|
+
if (!text) return { success: false, kind: 'rule', reason: 'INVALID_INPUT', error: '必须提供 text' };
|
|
584
|
+
const D = [
|
|
585
|
+
{ n: '占位符', re: /\{\{[^}]+\}\}|TODO|FIXME|待定|视情况|酌情/g },
|
|
586
|
+
{ n: '未定义值', re: /\bundefined\b|\bNaN\b/g },
|
|
587
|
+
{ n: '伪造迹象', re: /示例数据|mock|假数据/g },
|
|
588
|
+
{ n: '悬空引用', re: /见上文(?![\s\S]{0,40}(第|L)\d)/g },
|
|
589
|
+
];
|
|
590
|
+
const hits = D.map((d) => { const m = text.match(d.re); return m ? { type: d.n, count: m.length } : null; }).filter(Boolean);
|
|
591
|
+
return { success: hits.length === 0, kind: 'rule', output: { hits, clean: hits.length === 0 },
|
|
592
|
+
error: hits.length ? `完整性问题:${hits.map((h) => h.type).join('、')}` : undefined,
|
|
593
|
+
reason: hits.length ? 'RULE_VIOLATED' : undefined,
|
|
594
|
+
provenance: [`[${t}] output-integrity: ${hits.length} 类问题`] };
|
|
595
|
+
},
|
|
596
|
+
});
|
|
597
|
+
add({
|
|
598
|
+
id: 'ENGINE_PULSE_EVENT_134', name: '脉冲事件引擎', kind: 'compute', src: '第3部分', implements: ['脉冲聚合 + 事件率 + 异常突增检测'],
|
|
599
|
+
exec(inp, t) {
|
|
600
|
+
const pulses = inp.pulses || [];
|
|
601
|
+
if (!Array.isArray(pulses) || !pulses.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 pulses 数组' };
|
|
602
|
+
const byType = pulses.reduce((a, p) => { const k = p.type || 'unknown'; a[k] = (a[k] || 0) + 1; return a; }, {});
|
|
603
|
+
const rate = round(pulses.length / Math.max(1, Number(inp.windowSec ?? 60)), 4);
|
|
604
|
+
const baseline = Number(inp.baselineRate ?? rate);
|
|
605
|
+
const burst = rate > baseline * Number(inp.burstFactor ?? 3);
|
|
606
|
+
return { success: !burst, kind: 'compute', output: { total: pulses.length, byType, ratePerSec: rate, baselineRate: baseline, burst },
|
|
607
|
+
error: burst ? `脉冲突增:${rate}/s > ${round(baseline * 3, 4)}/s` : undefined,
|
|
608
|
+
reason: burst ? 'PRECONDITION_FAILED' : undefined,
|
|
609
|
+
provenance: [`[${t}] pulse-event: ${pulses.length} 脉冲,速率 ${rate}/s,突增 ${burst}`] };
|
|
610
|
+
},
|
|
611
|
+
});
|
|
612
|
+
add({
|
|
613
|
+
id: 'ENGINE_RESOURCE_69', name: '资源调度引擎', kind: 'compute', src: '第2部分', implements: ['资源分配(按需加权)+ 利用率'],
|
|
614
|
+
exec(inp, t) {
|
|
615
|
+
const demands = inp.demands, capacity = Number(inp.capacity ?? 100);
|
|
616
|
+
if (!Array.isArray(demands) || !demands.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 demands 数组' };
|
|
617
|
+
const totalDemand = demands.reduce((s, d) => s + Number(d.amount || 0), 0);
|
|
618
|
+
const scale = totalDemand > capacity ? capacity / totalDemand : 1;
|
|
619
|
+
const alloc = demands.map((d) => ({ id: d.id, demand: Number(d.amount || 0), allocated: round(Number(d.amount || 0) * scale, 4), satisfied: scale >= 1 }));
|
|
620
|
+
return { success: scale >= 1, kind: 'compute', output: { capacity, totalDemand, utilization: round(clamp01(totalDemand / capacity)), scaleFactor: round(scale, 4), allocations: alloc },
|
|
621
|
+
error: scale < 1 ? `资源不足,按 ${round(scale, 3)} 比例削减` : undefined,
|
|
622
|
+
reason: scale < 1 ? 'PRECONDITION_FAILED' : undefined,
|
|
623
|
+
provenance: [`[${t}] resource: 需求 ${totalDemand}/${capacity},缩放 ${round(scale, 3)}`] };
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
add({
|
|
627
|
+
id: 'ENGINE_SKILL_EVOLVE_124', name: 'Skill进化引擎', kind: 'compute', src: '第2部分', implements: ['Skill 版本演进 + 兼容性判定(语义化版本)'],
|
|
628
|
+
exec(inp, t) {
|
|
629
|
+
const from = String(inp.fromVersion || '1.0.0'), to = String(inp.toVersion || '1.0.0');
|
|
630
|
+
const parse = (v) => v.split('.').map(Number);
|
|
631
|
+
const [a1, b1, c1] = parse(from), [a2, b2, c2] = parse(to);
|
|
632
|
+
if ([a1, b1, c1, a2, b2, c2].some((x) => !isFinite(x))) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '版本须为 x.y.z 语义化格式' };
|
|
633
|
+
const breaking = a2 > a1;
|
|
634
|
+
const compatible = a2 === a1 && b2 >= b1;
|
|
635
|
+
const level = breaking ? 'MAJOR(破坏性)' : b2 > b1 ? 'MINOR(向后兼容新增)' : 'PATCH(修复)';
|
|
636
|
+
return { success: !breaking, kind: 'compute', output: { from, to, breaking, compatible, level,
|
|
637
|
+
rule: '语义化版本:MAJOR 破坏兼容,需迁移;MINOR/PATCH 可平滑升级' },
|
|
638
|
+
error: breaking ? `${from} → ${to} 为 MAJOR 变更,须提供迁移方案` : undefined,
|
|
639
|
+
reason: breaking ? 'PRECONDITION_FAILED' : undefined,
|
|
640
|
+
provenance: [`[${t}] skill-evolve: ${from} → ${to}(${level})`] };
|
|
641
|
+
},
|
|
642
|
+
});
|
|
643
|
+
gate('ENGINE_SUPPLY_TRACE_115', '供应链溯源引擎', 'pipeline', '第3部分', ['chain', 'hashes', 'verified'], '溯源链校验');
|
|
644
|
+
add({
|
|
645
|
+
id: 'ENGINE_TIME_TRAVEL_119', name: '时空回溯引擎', kind: 'compute', src: '第3部分', implements: ['快照回溯(索引校验 + checksum)'],
|
|
646
|
+
exec(inp, t) {
|
|
647
|
+
const snaps = inp.snapshots || [];
|
|
648
|
+
if (!snaps.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: '必须提供 snapshots 数组' };
|
|
649
|
+
const idx = Number(inp.targetIndex ?? snaps.length - 1);
|
|
650
|
+
if (idx < 0 || idx >= snaps.length) return { success: false, kind: 'compute', reason: 'INVALID_INPUT', error: `索引 ${idx} 越界` };
|
|
651
|
+
const ok = !!(snaps[idx] && snaps[idx].checksum);
|
|
652
|
+
return { success: ok, kind: 'compute', output: { snapshots: snaps.length, targetIndex: idx, restorable: ok, checksum: snaps[idx].checksum || null },
|
|
653
|
+
error: ok ? undefined : '目标快照缺 checksum', reason: ok ? undefined : 'PRECONDITION_FAILED',
|
|
654
|
+
provenance: [`[${t}] time-travel: 回溯 #${idx}`] };
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
scorer('ENGINE_VALUE_PREDICT_120', '价值预测引擎', '第3部分', ['历史趋势', '政策环境', '技术成熟', '市场接受'], [0.35, 0.25, 0.2, 0.2], 0.6, '四维价值预测输入');
|
|
658
|
+
add({
|
|
659
|
+
id: 'ENGINE_VALUE_REALIZE_68', name: '价值实现总引擎', kind: 'pipeline', src: '第2部分', implements: ['五步(验证→量化→确权→入账→复核)'],
|
|
660
|
+
exec(inp, t) {
|
|
661
|
+
const F = ['verified', 'quantified', 'attributed', 'recorded', 'reviewed'];
|
|
662
|
+
const miss = F.filter((k) => !(inp && inp[k]));
|
|
663
|
+
return { success: miss.length === 0, kind: 'pipeline', output: { steps: F, missing: miss },
|
|
664
|
+
error: miss.length ? `价值实现缺:${miss.join('/')}` : undefined, reason: miss.length ? 'PRECONDITION_FAILED' : undefined,
|
|
665
|
+
provenance: [`[${t}] value-realize: ${5 - miss.length}/5`] };
|
|
666
|
+
},
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
/* ══════════ 运行时 ══════════ */
|
|
670
|
+
const INDEX = new Map(E.map((e) => [e.id, e]));
|
|
671
|
+
const kindOf = (id) => { const e = INDEX.get(id); return e ? e.kind : 'declared'; };
|
|
672
|
+
const getRegistry = () => E.map((e) => ({ id: e.id, name: e.name, kind: e.kind, src: e.src, implements: e.implements || [] }));
|
|
673
|
+
|
|
674
|
+
function executeSync(id, input) {
|
|
675
|
+
const t0 = Date.now(), t = tid();
|
|
676
|
+
const e = INDEX.get(id);
|
|
677
|
+
if (!e) return { success: false, kind: 'declared', reason: 'NOT_FOUND', error: `引擎 ${id} 未登记`, provenance: [], traceId: t, durationMs: 0 };
|
|
678
|
+
let r;
|
|
679
|
+
try { r = e.exec(input || {}, t); } catch (err) { r = { success: false, kind: e.kind, error: 'THROW: ' + err.message, provenance: [`[${t}] THROW`] }; }
|
|
680
|
+
return { ...r, engineId: id, engineName: e.name, traceId: t, durationMs: Date.now() - t0 };
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
module.exports = { executeSync, execute: async (i, n) => executeSync(i, n), kindOf, getRegistry, ENGINES: E, INDEX };
|