@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.
- package/dist/ablate-task.d.ts +12 -0
- package/dist/ablate-task.js +51 -19
- package/package.json +12 -12
package/dist/ablate-task.d.ts
CHANGED
|
@@ -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 {};
|
package/dist/ablate-task.js
CHANGED
|
@@ -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
|
|
83
|
-
|
|
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
|
-
|
|
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 (
|
|
124
|
+
if (prevCog === undefined)
|
|
116
125
|
delete process.env.HMH_NO_COGNITIVE;
|
|
117
126
|
else
|
|
118
|
-
process.env.HMH_NO_COGNITIVE =
|
|
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
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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}/${
|
|
156
|
-
write(
|
|
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.
|
|
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.
|
|
47
|
-
"@hmharness/cognitive": "0.22.
|
|
48
|
-
"@hmharness/domain-harmony": "0.22.
|
|
49
|
-
"@hmharness/domain-ops": "0.22.
|
|
50
|
-
"@hmharness/environments": "0.22.
|
|
51
|
-
"@hmharness/evaluation": "0.22.
|
|
52
|
-
"@hmharness/evolution": "0.22.
|
|
53
|
-
"@hmharness/kernel": "0.22.
|
|
54
|
-
"@hmharness/observability": "0.22.
|
|
55
|
-
"@hmharness/sandbox": "0.22.
|
|
56
|
-
"@hmharness/web": "0.22.
|
|
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
|
}
|