@hmharness/cli 0.22.4 → 0.23.0
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 +19 -0
- package/dist/ablate-task.js +74 -0
- package/dist/main.js +16 -3
- package/package.json +12 -12
package/dist/ablate-task.d.ts
CHANGED
|
@@ -10,6 +10,25 @@ 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
|
+
export declare function runCompoundExperiment(write: (s: string) => void, home: () => string, opts: {
|
|
28
|
+
targetFilter: string;
|
|
29
|
+
trainFilter: string;
|
|
30
|
+
trainCount: number;
|
|
31
|
+
}): Promise<void>;
|
|
13
32
|
/**
|
|
14
33
|
* Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
|
|
15
34
|
* claims a band is measurable, run each candidate task bare and measure its
|
package/dist/ablate-task.js
CHANGED
|
@@ -187,6 +187,80 @@ 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
|
+
export async function runCompoundExperiment(write, home, opts) {
|
|
205
|
+
const { mkdtemp, copyFile, rm } = await import('node:fs/promises');
|
|
206
|
+
const { tmpdir } = await import('node:os');
|
|
207
|
+
const realHome = home();
|
|
208
|
+
const tempHome = await mkdtemp(join(tmpdir(), 'hmh-compound-'));
|
|
209
|
+
// providers/config so the agent can actually run inside the temp home
|
|
210
|
+
await copyFile(join(realHome, 'config.json'), join(tempHome, 'config.json')).catch(() => undefined);
|
|
211
|
+
const prevHome = process.env.HMH_HOME;
|
|
212
|
+
process.env.HMH_HOME = tempHome;
|
|
213
|
+
try {
|
|
214
|
+
// cases live in the REAL home's bench corpus; only the RUNTIME state
|
|
215
|
+
// (insights/memory) is isolated in tempHome
|
|
216
|
+
const targets = await benchPool(realHome, opts.targetFilter, 6);
|
|
217
|
+
const trainPool = await benchPool(realHome, opts.trainFilter, opts.trainCount);
|
|
218
|
+
write(`跨任务复利实验 · 目标 ${opts.targetFilter}×${targets.length} · 训练 ${opts.trainFilter}×${trainPool.length} · 隔离家 ${tempHome.slice(-12)}\n`);
|
|
219
|
+
const runPool = async (pool) => {
|
|
220
|
+
let pass = 0;
|
|
221
|
+
let crashes = 0;
|
|
222
|
+
const labels = [];
|
|
223
|
+
for (const t of pool) {
|
|
224
|
+
const r = await runOnce(t.text, false, 240_000);
|
|
225
|
+
const v = verdictOf(r, t.check);
|
|
226
|
+
if (v === 'crash')
|
|
227
|
+
crashes += 1;
|
|
228
|
+
else if (v === 'pass')
|
|
229
|
+
pass += 1;
|
|
230
|
+
labels.push(`${t.label}:${v}`);
|
|
231
|
+
write(` ${t.label.padEnd(24)} ${v === 'pass' ? GREEN('✓') : v === 'wrong' ? RED('✗') : YELLOW('⚡')}\n`);
|
|
232
|
+
}
|
|
233
|
+
return { pass, total: pool.length, crashes, labels };
|
|
234
|
+
};
|
|
235
|
+
write('—— 新鲜臂(零经验)——\n');
|
|
236
|
+
const fresh = await runPool(targets);
|
|
237
|
+
write('—— 训练期(经验自动积累 insights)——\n');
|
|
238
|
+
const trained = await runPool(trainPool);
|
|
239
|
+
write('—— 复利臂(同目标任务,带积累经验)——\n');
|
|
240
|
+
const compounded = await runPool(targets);
|
|
241
|
+
const cleanTotal = Math.min(fresh.total - fresh.crashes, compounded.total - compounded.crashes);
|
|
242
|
+
const record = {
|
|
243
|
+
at: new Date().toISOString(),
|
|
244
|
+
type: 'compounding',
|
|
245
|
+
targetFilter: opts.targetFilter,
|
|
246
|
+
trainFilter: opts.trainFilter,
|
|
247
|
+
trainedCount: trained.pass,
|
|
248
|
+
fresh: { pass: fresh.pass, total: fresh.total, crashes: fresh.crashes },
|
|
249
|
+
compounded: { pass: compounded.pass, total: compounded.total, crashes: compounded.crashes },
|
|
250
|
+
compoundingDelta: cleanTotal ? Number(((compounded.pass - fresh.pass) / cleanTotal).toFixed(3)) : null,
|
|
251
|
+
};
|
|
252
|
+
await appendFile(join(realHome, 'cognitive', 'ablation.jsonl'), JSON.stringify(record) + '\n', 'utf8').catch(() => undefined);
|
|
253
|
+
write(`结论 · 复利臂 ${compounded.pass}/${compounded.total} vs 新鲜臂 ${fresh.pass}/${fresh.total} → 跨任务复利效应 ${record.compoundingDelta === null ? 'N/A' : (record.compoundingDelta * 100).toFixed(1) + '%'}\n`);
|
|
254
|
+
write(DIM(`(训练 ${trained.pass}/${trained.total} 过;⚡ 认知${fresh.crashes + compounded.crashes};同一隔离家内前后对照=复利效应的干净测量)\n`));
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
if (prevHome === undefined)
|
|
258
|
+
delete process.env.HMH_HOME;
|
|
259
|
+
else
|
|
260
|
+
process.env.HMH_HOME = prevHome;
|
|
261
|
+
await rm(tempHome, { recursive: true, force: true }).catch(() => undefined);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
190
264
|
/**
|
|
191
265
|
* Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
|
|
192
266
|
* claims a band is measurable, run each candidate task bare and measure its
|
package/dist/main.js
CHANGED
|
@@ -1226,8 +1226,21 @@ 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
|
+
const targetFilter = rest.find((a) => a.startsWith('--target='))?.slice(9) ?? 'cjk';
|
|
1235
|
+
const trainFilter = rest.find((a) => a.startsWith('--trainer='))?.slice(10) ?? 'train';
|
|
1236
|
+
const trainCount = Number(rest.find((a) => a.startsWith('--train='))?.slice(8) ?? 4);
|
|
1237
|
+
await runCompoundExperiment((s) => stdout.write(s), hd, {
|
|
1238
|
+
targetFilter,
|
|
1239
|
+
trainFilter,
|
|
1240
|
+
trainCount: Number.isFinite(trainCount) ? Math.min(Math.max(trainCount, 1), 8) : 4,
|
|
1241
|
+
});
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1231
1244
|
if (rest.includes('--calibrate')) {
|
|
1232
1245
|
const probes = Number(rest.find((a) => a.startsWith('--probes='))?.slice(9) ?? 2);
|
|
1233
1246
|
await runBareCalibration((s) => stdout.write(s), difficulty, Number.isFinite(probes) ? Math.min(Math.max(probes, 1), 4) : 2, hd, filter);
|
|
@@ -1237,8 +1250,8 @@ flags:
|
|
|
1237
1250
|
return;
|
|
1238
1251
|
}
|
|
1239
1252
|
if (!rest.includes('--env=arc3')) {
|
|
1240
|
-
stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty
|
|
1241
|
-
stdout.write(DIM(' --
|
|
1253
|
+
stdout.write('用法: hmh cognitive ablate --env=arc3 [--steps=N] | --task [--runs=N] [--difficulty=..] [--filter=前缀] [--calibrate] | --compound [--target=cjk --trainer=train --train=4] | --stats\n');
|
|
1254
|
+
stdout.write(DIM(' --compound: 跨任务复利(隔离家,训练前后同目标任务对照); --difficulty=bench: evolution 真实语料\n'));
|
|
1242
1255
|
return;
|
|
1243
1256
|
}
|
|
1244
1257
|
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.0",
|
|
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.0",
|
|
47
|
+
"@hmharness/cognitive": "0.23.0",
|
|
48
|
+
"@hmharness/domain-harmony": "0.23.0",
|
|
49
|
+
"@hmharness/domain-ops": "0.23.0",
|
|
50
|
+
"@hmharness/environments": "0.23.0",
|
|
51
|
+
"@hmharness/evaluation": "0.23.0",
|
|
52
|
+
"@hmharness/evolution": "0.23.0",
|
|
53
|
+
"@hmharness/kernel": "0.23.0",
|
|
54
|
+
"@hmharness/observability": "0.23.0",
|
|
55
|
+
"@hmharness/sandbox": "0.23.0",
|
|
56
|
+
"@hmharness/web": "0.23.0",
|
|
57
57
|
"qrcode": "^1.5.4"
|
|
58
58
|
}
|
|
59
59
|
}
|