@hmharness/cli 0.23.0 → 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.
@@ -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
@@ -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 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);
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: cleanTotal ? Number(((compounded.pass - fresh.pass) / cleanTotal).toFixed(3)) : null,
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(`结论 · 复利臂 ${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`));
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.23.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.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",
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
  }