@hmharness/cli 0.22.2 → 0.22.4

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 = [
@@ -79,11 +80,19 @@ async function poolOf(difficulty, home, filter) {
79
80
  * harness output was merely verbose. Same instrument, same reading.)
80
81
  */
81
82
  async function runOnce(task, bare, timeoutMs) {
82
- const prev = process.env.HMH_NO_COGNITIVE;
83
- if (bare)
83
+ const prevCog = process.env.HMH_NO_COGNITIVE;
84
+ const prevCtx = process.env.HMH_NO_CONTEXT;
85
+ if (bare) {
86
+ // full ablation: strip the tool-reliability digest AND the experience
87
+ // layer (memory + task-relevant lessons) — v0.22.3 showed the digest
88
+ // alone has no effect; the live hypothesis is the value lives in lessons
84
89
  process.env.HMH_NO_COGNITIVE = '1';
85
- else
90
+ process.env.HMH_NO_CONTEXT = '1';
91
+ }
92
+ else {
86
93
  delete process.env.HMH_NO_COGNITIVE;
94
+ delete process.env.HMH_NO_CONTEXT;
95
+ }
87
96
  let finalText = '';
88
97
  try {
89
98
  const { runAgentTask, buildRegistry } = await import('@hmharness/agent');
@@ -112,12 +121,21 @@ async function runOnce(task, bare, timeoutMs) {
112
121
  return { ok: false, output: finalText, error: String(err).slice(0, 120) };
113
122
  }
114
123
  finally {
115
- if (prev === undefined)
124
+ if (prevCog === undefined)
116
125
  delete process.env.HMH_NO_COGNITIVE;
117
126
  else
118
- process.env.HMH_NO_COGNITIVE = prev;
127
+ process.env.HMH_NO_COGNITIVE = prevCog;
128
+ if (prevCtx === undefined)
129
+ delete process.env.HMH_NO_CONTEXT;
130
+ else
131
+ process.env.HMH_NO_CONTEXT = prevCtx;
119
132
  }
120
133
  }
134
+ export function verdictOf(r, check) {
135
+ if (!r.ok)
136
+ return 'crash'; // run died (timeout / rate-limit / provider error)
137
+ return check(r.output) ? 'pass' : 'wrong';
138
+ }
121
139
  export async function runTaskAblation(write, home, runs, difficulty = 'easy', filter) {
122
140
  const homeDir = home();
123
141
  const pool = await poolOf(difficulty, home, filter);
@@ -125,19 +143,30 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
125
143
  let withOk = 0;
126
144
  let bareOk = 0;
127
145
  let total = 0;
146
+ let withCrash = 0;
147
+ let bareCrash = 0;
148
+ let cleanPairs = 0; // pairs where BOTH arms produced a reply (model-vs-model)
128
149
  const details = [];
129
150
  for (let r = 1; r <= runs; r++) {
130
151
  for (const t of pool) {
131
152
  total += 1;
132
153
  const a = await runOnce(t.text, false, 240_000);
133
154
  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`);
155
+ const av = verdictOf(a, t.check);
156
+ const bv = verdictOf(b, t.check);
157
+ if (av === 'crash')
158
+ withCrash += 1;
159
+ if (bv === 'crash')
160
+ bareCrash += 1;
161
+ if (av !== 'crash' && bv !== 'crash') {
162
+ cleanPairs += 1;
163
+ withOk += av === 'pass' ? 1 : 0;
164
+ bareOk += bv === 'pass' ? 1 : 0;
165
+ }
166
+ details.push({ label: t.label, with: av, bare: bv });
167
+ const mark = (v) => (v === 'pass' ? GREEN('✓') : v === 'wrong' ? RED('✗') : YELLOW('⚡'));
168
+ const note = av === 'crash' || bv === 'crash' ? DIM(` ⚡ ${String(a.error ?? b.error).slice(0, 60)}`) : '';
169
+ write(` ${t.label.padEnd(24)} 认知 ${mark(av)} · 裸 ${mark(bv)}${note}\n`);
141
170
  }
142
171
  }
143
172
  const record = {
@@ -145,15 +174,18 @@ export async function runTaskAblation(write, home, runs, difficulty = 'easy', fi
145
174
  type: 'terminal-task',
146
175
  difficulty,
147
176
  runs,
148
- withCognitive: { pass: withOk, total },
149
- bare: { pass: bareOk, total },
150
- harnessDelta: Number(((withOk - bareOk) / total).toFixed(3)),
177
+ // clean stats: only pairs where both arms answered (model-vs-model)
178
+ withCognitive: { pass: withOk, total: cleanPairs },
179
+ bare: { pass: bareOk, total: cleanPairs },
180
+ crashes: { withArm: withCrash, bareArm: bareCrash },
181
+ harnessDelta: cleanPairs ? Number(((withOk - bareOk) / cleanPairs).toFixed(3)) : null,
151
182
  details,
152
183
  };
153
184
  await mkdir(join(homeDir, 'cognitive'), { recursive: true }).catch(() => undefined);
154
185
  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'));
186
+ write(`结论 · 认知层 ${withOk}/${cleanPairs} vs 裸 ${bareOk}/${cleanPairs}(干净对 ${cleanPairs}/${total},⚡基础设施中断 认知${withCrash}/裸${bareCrash} 已剔除)`);
187
+ write(record.harnessDelta === null ? ' → 干净对不足,无读数\n' : ` → harness 结果层净贡献 ${(record.harnessDelta * 100).toFixed(1)}%\n`);
188
+ write(DIM('(⚡=超时/限流/provider 错误:非模型答错,混入会污染效应估计——v0.22.2 教训)\n'));
157
189
  }
158
190
  /**
159
191
  * Bare-arm calibration (the v0.21.3 lesson, implemented): BEFORE an ablation
@@ -168,8 +200,8 @@ export async function runBareCalibration(write, difficulty, probes, home, filter
168
200
  let fails = 0;
169
201
  for (let i = 0; i < probes; i++) {
170
202
  const r = await runOnce(t.text, true, 240_000);
171
- if (!t.check(r.output))
172
- fails += 1;
203
+ if (!r.ok || !t.check(r.output))
204
+ fails += 1; // a crashed probe counts as a bare failure (infrastructure, not model-competence — note it in the band reading)
173
205
  }
174
206
  const rate = Number((fails / probes).toFixed(2));
175
207
  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.4",
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.4",
47
+ "@hmharness/cognitive": "0.22.4",
48
+ "@hmharness/domain-harmony": "0.22.4",
49
+ "@hmharness/domain-ops": "0.22.4",
50
+ "@hmharness/environments": "0.22.4",
51
+ "@hmharness/evaluation": "0.22.4",
52
+ "@hmharness/evolution": "0.22.4",
53
+ "@hmharness/kernel": "0.22.4",
54
+ "@hmharness/observability": "0.22.4",
55
+ "@hmharness/sandbox": "0.22.4",
56
+ "@hmharness/web": "0.22.4",
57
57
  "qrcode": "^1.5.4"
58
58
  }
59
59
  }