@hmharness/cli 0.23.0 → 0.23.2
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/dist/ablate-task.d.ts +6 -0
- package/dist/ablate-task.js +47 -6
- package/dist/main.js +22 -2
- package/package.json +12 -12
package/dist/ablate-task.d.ts
CHANGED
|
@@ -23,11 +23,17 @@ export declare function runTaskAblation(write: (s: string) => void, home: () =>
|
|
|
23
23
|
*
|
|
24
24
|
* The compounding effect = compounded − fresh on the SAME tasks in the SAME
|
|
25
25
|
* home. Recorded to cognitive/ablation.jsonl (type: 'compounding').
|
|
26
|
+
*
|
|
27
|
+
* Order-effect control (--control): a SECOND isolated home runs the target
|
|
28
|
+
* pool twice with NO training in between — its second-run delta is the pure
|
|
29
|
+
* order effect (task familiarity, position). The true compounding effect =
|
|
30
|
+
* experimental delta − control delta.
|
|
26
31
|
*/
|
|
27
32
|
export declare function runCompoundExperiment(write: (s: string) => void, home: () => string, opts: {
|
|
28
33
|
targetFilter: string;
|
|
29
34
|
trainFilter: string;
|
|
30
35
|
trainCount: number;
|
|
36
|
+
control?: boolean;
|
|
31
37
|
}): Promise<void>;
|
|
32
38
|
/**
|
|
33
39
|
* Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
|
package/dist/ablate-task.js
CHANGED
|
@@ -200,14 +200,22 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
|
|
|
200
200
|
*
|
|
201
201
|
* The compounding effect = compounded − fresh on the SAME tasks in the SAME
|
|
202
202
|
* home. Recorded to cognitive/ablation.jsonl (type: 'compounding').
|
|
203
|
+
*
|
|
204
|
+
* Order-effect control (--control): a SECOND isolated home runs the target
|
|
205
|
+
* pool twice with NO training in between — its second-run delta is the pure
|
|
206
|
+
* order effect (task familiarity, position). The true compounding effect =
|
|
207
|
+
* experimental delta − control delta.
|
|
203
208
|
*/
|
|
204
209
|
export async function runCompoundExperiment(write, home, opts) {
|
|
205
210
|
const { mkdtemp, copyFile, rm } = await import('node:fs/promises');
|
|
206
211
|
const { tmpdir } = await import('node:os');
|
|
207
212
|
const realHome = home();
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
213
|
+
const mkHome = async () => {
|
|
214
|
+
const h = await mkdtemp(join(tmpdir(), 'hmh-compound-'));
|
|
215
|
+
await copyFile(join(realHome, 'config.json'), join(h, 'config.json')).catch(() => undefined);
|
|
216
|
+
return h;
|
|
217
|
+
};
|
|
218
|
+
const tempHome = await mkHome();
|
|
211
219
|
const prevHome = process.env.HMH_HOME;
|
|
212
220
|
process.env.HMH_HOME = tempHome;
|
|
213
221
|
try {
|
|
@@ -238,7 +246,34 @@ export async function runCompoundExperiment(write, home, opts) {
|
|
|
238
246
|
const trained = await runPool(trainPool);
|
|
239
247
|
write('—— 复利臂(同目标任务,带积累经验)——\n');
|
|
240
248
|
const compounded = await runPool(targets);
|
|
249
|
+
// order-effect control: SECOND isolated home, targets twice, NO training
|
|
250
|
+
let control;
|
|
251
|
+
if (opts.control) {
|
|
252
|
+
const controlHome = await mkHome();
|
|
253
|
+
process.env.HMH_HOME = controlHome;
|
|
254
|
+
try {
|
|
255
|
+
write('—— 顺序对照臂(第二个隔离家·无训练·纯顺序效应)——\n');
|
|
256
|
+
write(' [第一次]\n');
|
|
257
|
+
const cFirst = await runPool(targets);
|
|
258
|
+
write(' [第二次·无训练间隔]\n');
|
|
259
|
+
const cSecond = await runPool(targets);
|
|
260
|
+
const cClean = Math.min(cFirst.total - cFirst.crashes, cSecond.total - cSecond.crashes);
|
|
261
|
+
control = {
|
|
262
|
+
first: { pass: cFirst.pass, total: cFirst.total, crashes: cFirst.crashes },
|
|
263
|
+
second: { pass: cSecond.pass, total: cSecond.total, crashes: cSecond.crashes },
|
|
264
|
+
orderDelta: cClean ? Number(((cSecond.pass - cFirst.pass) / cClean).toFixed(3)) : null,
|
|
265
|
+
};
|
|
266
|
+
write(` 顺序效应 ${control.first.pass}/${control.first.total} → ${control.second.pass}/${control.second.total} = ${control.orderDelta === null ? 'N/A' : (control.orderDelta * 100).toFixed(1) + '%'}\n`);
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
await rm(controlHome, { recursive: true, force: true }).catch(() => undefined);
|
|
270
|
+
process.env.HMH_HOME = tempHome;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
241
273
|
const cleanTotal = Math.min(fresh.total - fresh.crashes, compounded.total - compounded.crashes);
|
|
274
|
+
const expDelta = cleanTotal ? Number(((compounded.pass - fresh.pass) / cleanTotal).toFixed(3)) : null;
|
|
275
|
+
// true compounding = experimental delta MINUS the order effect it shares
|
|
276
|
+
const netCompounding = expDelta !== null && control?.orderDelta != null ? Number((expDelta - control.orderDelta).toFixed(3)) : null;
|
|
242
277
|
const record = {
|
|
243
278
|
at: new Date().toISOString(),
|
|
244
279
|
type: 'compounding',
|
|
@@ -247,11 +282,17 @@ export async function runCompoundExperiment(write, home, opts) {
|
|
|
247
282
|
trainedCount: trained.pass,
|
|
248
283
|
fresh: { pass: fresh.pass, total: fresh.total, crashes: fresh.crashes },
|
|
249
284
|
compounded: { pass: compounded.pass, total: compounded.total, crashes: compounded.crashes },
|
|
250
|
-
compoundingDelta:
|
|
285
|
+
compoundingDelta: expDelta,
|
|
286
|
+
control,
|
|
287
|
+
netCompounding,
|
|
251
288
|
};
|
|
252
289
|
await appendFile(join(realHome, 'cognitive', 'ablation.jsonl'), JSON.stringify(record) + '\n', 'utf8').catch(() => undefined);
|
|
253
|
-
write(`结论 ·
|
|
254
|
-
|
|
290
|
+
write(`结论 · 实验 ${fresh.pass}/${fresh.total}→${compounded.pass}/${compounded.total}(Δ${expDelta === null ? 'N/A' : (expDelta * 100).toFixed(1) + '%'})`);
|
|
291
|
+
if (control)
|
|
292
|
+
write(` − 顺序效应${control.orderDelta === null ? 'N/A' : (control.orderDelta * 100).toFixed(1) + '%'} = 净复利 ${netCompounding === null ? 'N/A' : (netCompounding * 100).toFixed(1) + '%'}\n`);
|
|
293
|
+
else
|
|
294
|
+
write(' → 未控顺序效应(加 --control 分离)\n');
|
|
295
|
+
write(DIM(`(训练 ${trained.pass}/${trained.total} 过;⚡ 实验${fresh.crashes + compounded.crashes}/对照${(control?.first.crashes ?? 0) + (control?.second.crashes ?? 0)})\n`));
|
|
255
296
|
}
|
|
256
297
|
finally {
|
|
257
298
|
if (prevHome === undefined)
|
package/dist/main.js
CHANGED
|
@@ -1230,7 +1230,8 @@ flags:
|
|
|
1230
1230
|
const { homeDir: hd } = await import('@hmharness/kernel');
|
|
1231
1231
|
if (rest.includes('--compound')) {
|
|
1232
1232
|
// cross-task compounding (the v0.22.4 pivot): arms differ in
|
|
1233
|
-
// TRAINING HISTORY inside an isolated home, not in prompt content
|
|
1233
|
+
// TRAINING HISTORY inside an isolated home, not in prompt content.
|
|
1234
|
+
// --control adds a no-training second home to strip order effects.
|
|
1234
1235
|
const targetFilter = rest.find((a) => a.startsWith('--target='))?.slice(9) ?? 'cjk';
|
|
1235
1236
|
const trainFilter = rest.find((a) => a.startsWith('--trainer='))?.slice(10) ?? 'train';
|
|
1236
1237
|
const trainCount = Number(rest.find((a) => a.startsWith('--train='))?.slice(8) ?? 4);
|
|
@@ -1238,6 +1239,7 @@ flags:
|
|
|
1238
1239
|
targetFilter,
|
|
1239
1240
|
trainFilter,
|
|
1240
1241
|
trainCount: Number.isFinite(trainCount) ? Math.min(Math.max(trainCount, 1), 8) : 4,
|
|
1242
|
+
control: rest.includes('--control'),
|
|
1241
1243
|
});
|
|
1242
1244
|
return;
|
|
1243
1245
|
}
|
|
@@ -1264,8 +1266,26 @@ flags:
|
|
|
1264
1266
|
}, { home: hd, loadConfig: lc, resolveProvider: rp });
|
|
1265
1267
|
return;
|
|
1266
1268
|
}
|
|
1269
|
+
if (sub === 'calibration') {
|
|
1270
|
+
// the §26-proven valuable dimension, first-class: per-action prediction
|
|
1271
|
+
// calibration — where the harness's value actually lives (+0.4166)
|
|
1272
|
+
const { calibrationReport } = await import('@hmharness/cognitive');
|
|
1273
|
+
const r = await calibrationReport(homeDir());
|
|
1274
|
+
if (r.predictedSteps === 0) {
|
|
1275
|
+
stdout.write('(尚无带预测的轨迹——探索/迁移实验会自动记录预测)\n');
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
stdout.write(`校准报告 · ${r.predictedSteps}/${r.totalSteps} 步带预测 · 总体平均误差 ${r.overallMeanError}(可靠度 ${r.overallReliability})\n`);
|
|
1279
|
+
stdout.write(' 动作类型 预测数 平均误差 可靠度\n');
|
|
1280
|
+
for (const row of r.rows) {
|
|
1281
|
+
const bar = '█'.repeat(Math.round(row.reliability * 10)).padEnd(10, '░');
|
|
1282
|
+
stdout.write(` ${row.actionType.padEnd(24)}${String(row.predictions).padStart(4)} ${row.meanError.toFixed(3).padStart(7)} ${bar} ${row.reliability.toFixed(2)}\n`);
|
|
1283
|
+
}
|
|
1284
|
+
stdout.write(DIM(' 可靠度=1-平均误差:harness 认知层的实证价值所在(校准维+0.4166,全谱系唯一正读数)\n'));
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1267
1287
|
if (sub !== 'status') {
|
|
1268
|
-
stdout.write('用法: hmh cognitive status|world-model|diagnose|bench|drift|skills|explore|transfer|team|learn|replay|export|purge|play|ablate — 认知子系统与世界模型\n');
|
|
1288
|
+
stdout.write('用法: hmh cognitive status|world-model|diagnose|bench|calibration|drift|skills|explore|transfer|team|learn|replay|export|purge|play|ablate — 认知子系统与世界模型\n');
|
|
1269
1289
|
return;
|
|
1270
1290
|
}
|
|
1271
1291
|
const { cognitiveStatus, formatCognitiveStatus } = await import('@hmharness/cognitive');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
"build": "tsc -p tsconfig.build.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@hmharness/agent": "0.23.
|
|
47
|
-
"@hmharness/cognitive": "0.23.
|
|
48
|
-
"@hmharness/domain-harmony": "0.23.
|
|
49
|
-
"@hmharness/domain-ops": "0.23.
|
|
50
|
-
"@hmharness/environments": "0.23.
|
|
51
|
-
"@hmharness/evaluation": "0.23.
|
|
52
|
-
"@hmharness/evolution": "0.23.
|
|
53
|
-
"@hmharness/kernel": "0.23.
|
|
54
|
-
"@hmharness/observability": "0.23.
|
|
55
|
-
"@hmharness/sandbox": "0.23.
|
|
56
|
-
"@hmharness/web": "0.23.
|
|
46
|
+
"@hmharness/agent": "0.23.2",
|
|
47
|
+
"@hmharness/cognitive": "0.23.2",
|
|
48
|
+
"@hmharness/domain-harmony": "0.23.2",
|
|
49
|
+
"@hmharness/domain-ops": "0.23.2",
|
|
50
|
+
"@hmharness/environments": "0.23.2",
|
|
51
|
+
"@hmharness/evaluation": "0.23.2",
|
|
52
|
+
"@hmharness/evolution": "0.23.2",
|
|
53
|
+
"@hmharness/kernel": "0.23.2",
|
|
54
|
+
"@hmharness/observability": "0.23.2",
|
|
55
|
+
"@hmharness/sandbox": "0.23.2",
|
|
56
|
+
"@hmharness/web": "0.23.2",
|
|
57
57
|
"qrcode": "^1.5.4"
|
|
58
58
|
}
|
|
59
59
|
}
|