@hmharness/cli 0.22.1 → 0.22.3

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.
@@ -1,3 +1,14 @@
1
+ /** A run's outcome, signal-separated: a crash (timeout/rate-limit/provider)
2
+ * is INFRASTRUCTURE noise, not the model answering wrong — mixing them
3
+ * poisons the effect estimate (the -8.3% artifact). Crash = the run did
4
+ * not complete (r.ok === false) regardless of whether a partial onFinal
5
+ * reply exists — a timed-out arm is a crash even when it had replied. */
6
+ type RunVerdict = 'pass' | 'wrong' | 'crash';
7
+ export declare function verdictOf(r: {
8
+ ok: boolean;
9
+ output: string;
10
+ error?: string;
11
+ }, check: (out: string) => boolean): RunVerdict;
1
12
  export declare function runTaskAblation(write: (s: string) => void, home: () => string, runs: number, difficulty?: 'easy' | 'mid' | 'hard' | 'bench', filter?: string): Promise<void>;
2
13
  /**
3
14
  * Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
@@ -6,3 +17,4 @@ export declare function runTaskAblation(write: (s: string) => void, home: () =>
6
17
  * failure — the author's intuition about difficulty is not the instrument.
7
18
  */
8
19
  export declare function runBareCalibration(write: (s: string) => void, difficulty: 'easy' | 'mid' | 'hard' | 'bench', probes: number, home: () => string, filter?: string): Promise<void>;
20
+ export {};
@@ -21,6 +21,7 @@ import { join } from 'node:path';
21
21
  const GREEN = (s) => `\x1b[32m${s}\x1b[0m`;
22
22
  const RED = (s) => `\x1b[31m${s}\x1b[0m`;
23
23
  const DIM = (s) => `\x1b[2m${s}\x1b[0m`;
24
+ const YELLOW = (s) => `\x1b[33m${s}\x1b[0m`;
24
25
  const bySubstring = (expect) => (output) => output.includes(expect);
25
26
  /** deterministic, verifiable mini-tasks (exact substring must appear) */
26
27
  const TASKS = [
@@ -89,7 +90,7 @@ async function runOnce(task, bare, timeoutMs) {
89
90
  const { runAgentTask, buildRegistry } = await import('@hmharness/agent');
90
91
  const { loadConfig } = await import('@hmharness/kernel');
91
92
  const { reg } = await buildRegistry({ mcp: false });
92
- const result = await Promise.race([
93
+ await Promise.race([
93
94
  runAgentTask({
94
95
  task,
95
96
  registry: reg,
@@ -103,9 +104,14 @@ async function runOnce(task, bare, timeoutMs) {
103
104
  throw err;
104
105
  return undefined;
105
106
  });
106
- void result;
107
107
  return { ok: true, output: finalText };
108
108
  }
109
+ catch (err) {
110
+ // a crashed run is a FAILED run (honest reading): record it and keep the
111
+ // ablation alive — one transient provider 400 must not kill the whole
112
+ // experiment and lose every arm's data
113
+ return { ok: false, output: finalText, error: String(err).slice(0, 120) };
114
+ }
109
115
  finally {
110
116
  if (prev === undefined)
111
117
  delete process.env.HMH_NO_COGNITIVE;
@@ -113,6 +119,11 @@ async function runOnce(task, bare, timeoutMs) {
113
119
  process.env.HMH_NO_COGNITIVE = prev;
114
120
  }
115
121
  }
122
+ export function verdictOf(r, check) {
123
+ if (!r.ok)
124
+ return 'crash'; // run died (timeout / rate-limit / provider error)
125
+ return check(r.output) ? 'pass' : 'wrong';
126
+ }
116
127
  export async function runTaskAblation(write, home, runs, difficulty = 'easy', filter) {
117
128
  const homeDir = home();
118
129
  const pool = await poolOf(difficulty, home, filter);
@@ -120,18 +131,30 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
120
131
  let withOk = 0;
121
132
  let bareOk = 0;
122
133
  let total = 0;
134
+ let withCrash = 0;
135
+ let bareCrash = 0;
136
+ let cleanPairs = 0; // pairs where BOTH arms produced a reply (model-vs-model)
123
137
  const details = [];
124
138
  for (let r = 1; r <= runs; r++) {
125
139
  for (const t of pool) {
126
140
  total += 1;
127
141
  const a = await runOnce(t.text, false, 240_000);
128
142
  const b = await runOnce(t.text, true, 240_000);
129
- const aHit = t.check(a.output);
130
- const bHit = t.check(b.output);
131
- withOk += aHit ? 1 : 0;
132
- bareOk += bHit ? 1 : 0;
133
- details.push({ label: t.label, with: aHit, bare: bHit });
134
- write(` ${t.label.padEnd(24)} 认知 ${aHit ? GREEN('✓') : RED('✗')} · 裸 ${bHit ? GREEN('✓') : RED('✗')}\n`);
143
+ const av = verdictOf(a, t.check);
144
+ const bv = verdictOf(b, t.check);
145
+ if (av === 'crash')
146
+ withCrash += 1;
147
+ if (bv === 'crash')
148
+ bareCrash += 1;
149
+ if (av !== 'crash' && bv !== 'crash') {
150
+ cleanPairs += 1;
151
+ withOk += av === 'pass' ? 1 : 0;
152
+ bareOk += bv === 'pass' ? 1 : 0;
153
+ }
154
+ details.push({ label: t.label, with: av, bare: bv });
155
+ const mark = (v) => (v === 'pass' ? GREEN('✓') : v === 'wrong' ? RED('✗') : YELLOW('⚡'));
156
+ const note = av === 'crash' || bv === 'crash' ? DIM(` ⚡ ${String(a.error ?? b.error).slice(0, 60)}`) : '';
157
+ write(` ${t.label.padEnd(24)} 认知 ${mark(av)} · 裸 ${mark(bv)}${note}\n`);
135
158
  }
136
159
  }
137
160
  const record = {
@@ -139,15 +162,18 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
139
162
  type: 'terminal-task',
140
163
  difficulty,
141
164
  runs,
142
- withCognitive: { pass: withOk, total },
143
- bare: { pass: bareOk, total },
144
- harnessDelta: Number(((withOk - bareOk) / total).toFixed(3)),
165
+ // clean stats: only pairs where both arms answered (model-vs-model)
166
+ withCognitive: { pass: withOk, total: cleanPairs },
167
+ bare: { pass: bareOk, total: cleanPairs },
168
+ crashes: { withArm: withCrash, bareArm: bareCrash },
169
+ harnessDelta: cleanPairs ? Number(((withOk - bareOk) / cleanPairs).toFixed(3)) : null,
145
170
  details,
146
171
  };
147
172
  await mkdir(join(homeDir, 'cognitive'), { recursive: true }).catch(() => undefined);
148
173
  await appendFile(join(homeDir, 'cognitive', 'ablation.jsonl'), JSON.stringify(record) + '\n', 'utf8').catch(() => undefined);
149
- write(`结论 · 认知层 ${withOk}/${total} vs 裸 ${bareOk}/${total} → harness 结果层净贡献 ${(record.harnessDelta * 100).toFixed(1)}%\n`);
150
- write(DIM('(ARC 域测上限=诚实零;本域测工作范围=模型胜任区的结果增益)\n'));
174
+ write(`结论 · 认知层 ${withOk}/${cleanPairs} vs 裸 ${bareOk}/${cleanPairs}(干净对 ${cleanPairs}/${total},⚡基础设施中断 认知${withCrash}/裸${bareCrash} 已剔除)`);
175
+ write(record.harnessDelta === null ? ' → 干净对不足,无读数\n' : ` → harness 结果层净贡献 ${(record.harnessDelta * 100).toFixed(1)}%\n`);
176
+ write(DIM('(⚡=超时/限流/provider 错误:非模型答错,混入会污染效应估计——v0.22.2 教训)\n'));
151
177
  }
152
178
  /**
153
179
  * Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
@@ -162,8 +188,8 @@ export async function runBareCalibration(write, difficulty, probes, home, filter
162
188
  let fails = 0;
163
189
  for (let i = 0; i < probes; i++) {
164
190
  const r = await runOnce(t.text, true, 240_000);
165
- if (!t.check(r.output))
166
- fails += 1;
191
+ if (!r.ok || !t.check(r.output))
192
+ fails += 1; // a crashed probe counts as a bare failure (infrastructure, not model-competence — note it in the band reading)
167
193
  }
168
194
  const rate = Number((fails / probes).toFixed(2));
169
195
  const band = rate === 0 ? '地板(剔除)' : rate >= 1 ? '天花板(剔除)' : rate >= 0.2 && rate <= 0.8 ? '可测带 ✓' : '边缘';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.22.1",
3
+ "version": "0.22.3",
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.22.1",
47
- "@hmharness/cognitive": "0.22.1",
48
- "@hmharness/domain-harmony": "0.22.1",
49
- "@hmharness/domain-ops": "0.22.1",
50
- "@hmharness/environments": "0.22.1",
51
- "@hmharness/evaluation": "0.22.1",
52
- "@hmharness/evolution": "0.22.1",
53
- "@hmharness/kernel": "0.22.1",
54
- "@hmharness/observability": "0.22.1",
55
- "@hmharness/sandbox": "0.22.1",
56
- "@hmharness/web": "0.22.1",
46
+ "@hmharness/agent": "0.22.3",
47
+ "@hmharness/cognitive": "0.22.3",
48
+ "@hmharness/domain-harmony": "0.22.3",
49
+ "@hmharness/domain-ops": "0.22.3",
50
+ "@hmharness/environments": "0.22.3",
51
+ "@hmharness/evaluation": "0.22.3",
52
+ "@hmharness/evolution": "0.22.3",
53
+ "@hmharness/kernel": "0.22.3",
54
+ "@hmharness/observability": "0.22.3",
55
+ "@hmharness/sandbox": "0.22.3",
56
+ "@hmharness/web": "0.22.3",
57
57
  "qrcode": "^1.5.4"
58
58
  }
59
59
  }