@hmharness/cli 0.22.4 → 0.23.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/dist/ablate-task.d.ts +25 -0
- package/dist/ablate-task.js +115 -0
- package/dist/main.js +18 -3
- package/package.json +12 -12
package/dist/ablate-task.d.ts
CHANGED
|
@@ -10,6 +10,31 @@ export declare function verdictOf(r: {
|
|
|
10
10
|
error?: string;
|
|
11
11
|
}, check: (out: string) => boolean): RunVerdict;
|
|
12
12
|
export declare function runTaskAblation(write: (s: string) => void, home: () => string, runs: number, difficulty?: 'easy' | 'mid' | 'hard' | 'bench', filter?: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Cross-task compounding experiment (the v0.22.4 pivot): the experience layer
|
|
15
|
+
* can only pay off AFTER tasks accumulate lessons — so the arms differ in
|
|
16
|
+
* TRAINING HISTORY, not in prompt content. Design:
|
|
17
|
+
*
|
|
18
|
+
* temp home (zero experience, config copied for providers)
|
|
19
|
+
* 1. fresh arm: run the target pool → baseline pass rate
|
|
20
|
+
* 2. training: run K training tasks (different bench slice) — each run
|
|
21
|
+
* records an insight automatically (the runner always does)
|
|
22
|
+
* 3. compounded arm: run the target pool again → post-training pass rate
|
|
23
|
+
*
|
|
24
|
+
* The compounding effect = compounded − fresh on the SAME tasks in the SAME
|
|
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.
|
|
31
|
+
*/
|
|
32
|
+
export declare function runCompoundExperiment(write: (s: string) => void, home: () => string, opts: {
|
|
33
|
+
targetFilter: string;
|
|
34
|
+
trainFilter: string;
|
|
35
|
+
trainCount: number;
|
|
36
|
+
control?: boolean;
|
|
37
|
+
}): Promise<void>;
|
|
13
38
|
/**
|
|
14
39
|
* Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
|
|
15
40
|
* claims a band is measurable, run each candidate task bare and measure its
|
package/dist/ablate-task.js
CHANGED
|
@@ -187,6 +187,121 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
|
|
|
187
187
|
write(record.harnessDelta === null ? ' → 干净对不足,无读数\n' : ` → harness 结果层净贡献 ${(record.harnessDelta * 100).toFixed(1)}%\n`);
|
|
188
188
|
write(DIM('(⚡=超时/限流/provider 错误:非模型答错,混入会污染效应估计——v0.22.2 教训)\n'));
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Cross-task compounding experiment (the v0.22.4 pivot): the experience layer
|
|
192
|
+
* can only pay off AFTER tasks accumulate lessons — so the arms differ in
|
|
193
|
+
* TRAINING HISTORY, not in prompt content. Design:
|
|
194
|
+
*
|
|
195
|
+
* temp home (zero experience, config copied for providers)
|
|
196
|
+
* 1. fresh arm: run the target pool → baseline pass rate
|
|
197
|
+
* 2. training: run K training tasks (different bench slice) — each run
|
|
198
|
+
* records an insight automatically (the runner always does)
|
|
199
|
+
* 3. compounded arm: run the target pool again → post-training pass rate
|
|
200
|
+
*
|
|
201
|
+
* The compounding effect = compounded − fresh on the SAME tasks in the SAME
|
|
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.
|
|
208
|
+
*/
|
|
209
|
+
export async function runCompoundExperiment(write, home, opts) {
|
|
210
|
+
const { mkdtemp, copyFile, rm } = await import('node:fs/promises');
|
|
211
|
+
const { tmpdir } = await import('node:os');
|
|
212
|
+
const realHome = home();
|
|
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();
|
|
219
|
+
const prevHome = process.env.HMH_HOME;
|
|
220
|
+
process.env.HMH_HOME = tempHome;
|
|
221
|
+
try {
|
|
222
|
+
// cases live in the REAL home's bench corpus; only the RUNTIME state
|
|
223
|
+
// (insights/memory) is isolated in tempHome
|
|
224
|
+
const targets = await benchPool(realHome, opts.targetFilter, 6);
|
|
225
|
+
const trainPool = await benchPool(realHome, opts.trainFilter, opts.trainCount);
|
|
226
|
+
write(`跨任务复利实验 · 目标 ${opts.targetFilter}×${targets.length} · 训练 ${opts.trainFilter}×${trainPool.length} · 隔离家 ${tempHome.slice(-12)}\n`);
|
|
227
|
+
const runPool = async (pool) => {
|
|
228
|
+
let pass = 0;
|
|
229
|
+
let crashes = 0;
|
|
230
|
+
const labels = [];
|
|
231
|
+
for (const t of pool) {
|
|
232
|
+
const r = await runOnce(t.text, false, 240_000);
|
|
233
|
+
const v = verdictOf(r, t.check);
|
|
234
|
+
if (v === 'crash')
|
|
235
|
+
crashes += 1;
|
|
236
|
+
else if (v === 'pass')
|
|
237
|
+
pass += 1;
|
|
238
|
+
labels.push(`${t.label}:${v}`);
|
|
239
|
+
write(` ${t.label.padEnd(24)} ${v === 'pass' ? GREEN('✓') : v === 'wrong' ? RED('✗') : YELLOW('⚡')}\n`);
|
|
240
|
+
}
|
|
241
|
+
return { pass, total: pool.length, crashes, labels };
|
|
242
|
+
};
|
|
243
|
+
write('—— 新鲜臂(零经验)——\n');
|
|
244
|
+
const fresh = await runPool(targets);
|
|
245
|
+
write('—— 训练期(经验自动积累 insights)——\n');
|
|
246
|
+
const trained = await runPool(trainPool);
|
|
247
|
+
write('—— 复利臂(同目标任务,带积累经验)——\n');
|
|
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
|
+
}
|
|
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;
|
|
277
|
+
const record = {
|
|
278
|
+
at: new Date().toISOString(),
|
|
279
|
+
type: 'compounding',
|
|
280
|
+
targetFilter: opts.targetFilter,
|
|
281
|
+
trainFilter: opts.trainFilter,
|
|
282
|
+
trainedCount: trained.pass,
|
|
283
|
+
fresh: { pass: fresh.pass, total: fresh.total, crashes: fresh.crashes },
|
|
284
|
+
compounded: { pass: compounded.pass, total: compounded.total, crashes: compounded.crashes },
|
|
285
|
+
compoundingDelta: expDelta,
|
|
286
|
+
control,
|
|
287
|
+
netCompounding,
|
|
288
|
+
};
|
|
289
|
+
await appendFile(join(realHome, 'cognitive', 'ablation.jsonl'), JSON.stringify(record) + '\n', 'utf8').catch(() => undefined);
|
|
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`));
|
|
296
|
+
}
|
|
297
|
+
finally {
|
|
298
|
+
if (prevHome === undefined)
|
|
299
|
+
delete process.env.HMH_HOME;
|
|
300
|
+
else
|
|
301
|
+
process.env.HMH_HOME = prevHome;
|
|
302
|
+
await rm(tempHome, { recursive: true, force: true }).catch(() => undefined);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
190
305
|
/**
|
|
191
306
|
* Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
|
|
192
307
|
* claims a band is measurable, run each candidate task bare and measure its
|
package/dist/main.js
CHANGED
|
@@ -1226,8 +1226,23 @@ flags:
|
|
|
1226
1226
|
const rounds = Number(rest.find((a) => a.startsWith('--runs='))?.slice(7) ?? 1);
|
|
1227
1227
|
const difficulty = rest.includes('--difficulty=bench') ? 'bench' : rest.includes('--difficulty=hard') ? 'hard' : rest.includes('--difficulty=mid') ? 'mid' : 'easy';
|
|
1228
1228
|
const filter = rest.find((a) => a.startsWith('--filter='))?.slice(9);
|
|
1229
|
-
const { runTaskAblation, runBareCalibration } = await import("./ablate-task.js");
|
|
1229
|
+
const { runTaskAblation, runBareCalibration, runCompoundExperiment } = await import("./ablate-task.js");
|
|
1230
1230
|
const { homeDir: hd } = await import('@hmharness/kernel');
|
|
1231
|
+
if (rest.includes('--compound')) {
|
|
1232
|
+
// cross-task compounding (the v0.22.4 pivot): arms differ in
|
|
1233
|
+
// TRAINING HISTORY inside an isolated home, not in prompt content.
|
|
1234
|
+
// --control adds a no-training second home to strip order effects.
|
|
1235
|
+
const targetFilter = rest.find((a) => a.startsWith('--target='))?.slice(9) ?? 'cjk';
|
|
1236
|
+
const trainFilter = rest.find((a) => a.startsWith('--trainer='))?.slice(10) ?? 'train';
|
|
1237
|
+
const trainCount = Number(rest.find((a) => a.startsWith('--train='))?.slice(8) ?? 4);
|
|
1238
|
+
await runCompoundExperiment((s) => stdout.write(s), hd, {
|
|
1239
|
+
targetFilter,
|
|
1240
|
+
trainFilter,
|
|
1241
|
+
trainCount: Number.isFinite(trainCount) ? Math.min(Math.max(trainCount, 1), 8) : 4,
|
|
1242
|
+
control: rest.includes('--control'),
|
|
1243
|
+
});
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1231
1246
|
if (rest.includes('--calibrate')) {
|
|
1232
1247
|
const probes = Number(rest.find((a) => a.startsWith('--probes='))?.slice(9) ?? 2);
|
|
1233
1248
|
await runBareCalibration((s) => stdout.write(s), difficulty, Number.isFinite(probes) ? Math.min(Math.max(probes, 1), 4) : 2, hd, filter);
|
|
@@ -1237,8 +1252,8 @@ flags:
|
|
|
1237
1252
|
return;
|
|
1238
1253
|
}
|
|
1239
1254
|
if (!rest.includes('--env=arc3')) {
|
|
1240
|
-
stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty
|
|
1241
|
-
stdout.write(DIM(' --
|
|
1255
|
+
stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=..] [--filter=前缀] [--calibrate] | --compound [--target=cjk --trainer=train --train=4] | --stats\n');
|
|
1256
|
+
stdout.write(DIM(' --compound: 跨任务复利(隔离家,训练前后同目标任务对照); --difficulty=bench: evolution 真实语料\n'));
|
|
1242
1257
|
return;
|
|
1243
1258
|
}
|
|
1244
1259
|
const steps = Number(rest.find((a) => a.startsWith('--steps='))?.slice(8) ?? 5);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
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.
|
|
47
|
-
"@hmharness/cognitive": "0.
|
|
48
|
-
"@hmharness/domain-harmony": "0.
|
|
49
|
-
"@hmharness/domain-ops": "0.
|
|
50
|
-
"@hmharness/environments": "0.
|
|
51
|
-
"@hmharness/evaluation": "0.
|
|
52
|
-
"@hmharness/evolution": "0.
|
|
53
|
-
"@hmharness/kernel": "0.
|
|
54
|
-
"@hmharness/observability": "0.
|
|
55
|
-
"@hmharness/sandbox": "0.
|
|
56
|
-
"@hmharness/web": "0.
|
|
46
|
+
"@hmharness/agent": "0.23.1",
|
|
47
|
+
"@hmharness/cognitive": "0.23.1",
|
|
48
|
+
"@hmharness/domain-harmony": "0.23.1",
|
|
49
|
+
"@hmharness/domain-ops": "0.23.1",
|
|
50
|
+
"@hmharness/environments": "0.23.1",
|
|
51
|
+
"@hmharness/evaluation": "0.23.1",
|
|
52
|
+
"@hmharness/evolution": "0.23.1",
|
|
53
|
+
"@hmharness/kernel": "0.23.1",
|
|
54
|
+
"@hmharness/observability": "0.23.1",
|
|
55
|
+
"@hmharness/sandbox": "0.23.1",
|
|
56
|
+
"@hmharness/web": "0.23.1",
|
|
57
57
|
"qrcode": "^1.5.4"
|
|
58
58
|
}
|
|
59
59
|
}
|