@hmharness/cli 0.22.2 → 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 = [
@@ -118,6 +119,11 @@ async function runOnce(task, bare, timeoutMs) {
118
119
  process.env.HMH_NO_COGNITIVE = prev;
119
120
  }
120
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
+ }
121
127
  export async function runTaskAblation(write, home, runs, difficulty = 'easy', filter) {
122
128
  const homeDir = home();
123
129
  const pool = await poolOf(difficulty, home, filter);
@@ -125,19 +131,30 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
125
131
  let withOk = 0;
126
132
  let bareOk = 0;
127
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)
128
137
  const details = [];
129
138
  for (let r = 1; r <= runs; r++) {
130
139
  for (const t of pool) {
131
140
  total += 1;
132
141
  const a = await runOnce(t.text, false, 240_000);
133
142
  const b = await runOnce(t.text, true, 240_000);
134
- const aHit = t.check(a.output);
135
- const bHit = t.check(b.output);
136
- withOk += aHit ? 1 : 0;
137
- bareOk += bHit ? 1 : 0;
138
- details.push({ label: t.label, with: aHit, bare: bHit });
139
- const crash = a.error || b.error ? DIM(` ⚠ ${String(a.error ?? b.error).slice(0, 70)}`) : '';
140
- write(` ${t.label.padEnd(24)} 认知 ${aHit ? GREEN('✓') : RED('✗')} · 裸 ${bHit ? GREEN('✓') : RED('✗')}${crash}\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`);
141
158
  }
142
159
  }
143
160
  const record = {
@@ -145,15 +162,18 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
145
162
  type: 'terminal-task',
146
163
  difficulty,
147
164
  runs,
148
- withCognitive: { pass: withOk, total },
149
- bare: { pass: bareOk, total },
150
- 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,
151
170
  details,
152
171
  };
153
172
  await mkdir(join(homeDir, 'cognitive'), { recursive: true }).catch(() => undefined);
154
173
  await appendFile(join(homeDir, 'cognitive', 'ablation.jsonl'), JSON.stringify(record) + '\n', 'utf8').catch(() => undefined);
155
- write(`结论 · 认知层 ${withOk}/${total} vs 裸 ${bareOk}/${total} → harness 结果层净贡献 ${(record.harnessDelta * 100).toFixed(1)}%\n`);
156
- 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'));
157
177
  }
158
178
  /**
159
179
  * Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
@@ -168,8 +188,8 @@ export async function runBareCalibration(write, difficulty, probes, home, filter
168
188
  let fails = 0;
169
189
  for (let i = 0; i < probes; i++) {
170
190
  const r = await runOnce(t.text, true, 240_000);
171
- if (!t.check(r.output))
172
- 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)
173
193
  }
174
194
  const rate = Number((fails / probes).toFixed(2));
175
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.2",
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.2",
47
- "@hmharness/cognitive": "0.22.2",
48
- "@hmharness/domain-harmony": "0.22.2",
49
- "@hmharness/domain-ops": "0.22.2",
50
- "@hmharness/environments": "0.22.2",
51
- "@hmharness/evaluation": "0.22.2",
52
- "@hmharness/evolution": "0.22.2",
53
- "@hmharness/kernel": "0.22.2",
54
- "@hmharness/observability": "0.22.2",
55
- "@hmharness/sandbox": "0.22.2",
56
- "@hmharness/web": "0.22.2",
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
  }