@hmharness/cognitive 0.20.1 → 0.20.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.
- package/dist/analysis.d.ts +27 -0
- package/dist/analysis.js +53 -0
- package/dist/transfer-lab.js +13 -1
- package/package.json +2 -2
package/dist/analysis.d.ts
CHANGED
|
@@ -45,6 +45,33 @@ export interface BenchReport {
|
|
|
45
45
|
* = the run's own step count +1, so efficiency measures consistency, and
|
|
46
46
|
* honest runs with retries score below clean one-shot runs). */
|
|
47
47
|
export declare function benchFromTrajectories(home: string, environmentId?: string, limit?: number): Promise<BenchReport | null>;
|
|
48
|
+
export interface Arc3PlayMetrics {
|
|
49
|
+
trajectoryId: string;
|
|
50
|
+
gameId?: string;
|
|
51
|
+
actions: number;
|
|
52
|
+
levelsCompleted: number;
|
|
53
|
+
levelCount: number;
|
|
54
|
+
/** levels advanced per action (action efficiency) */
|
|
55
|
+
actionEfficiency: number;
|
|
56
|
+
/** fraction of the offered action space actually probed (exploration efficiency) */
|
|
57
|
+
explorationEfficiency: number;
|
|
58
|
+
/** recoveries per failed action (resilience) */
|
|
59
|
+
recoveryRate: number;
|
|
60
|
+
finishedAt: string;
|
|
61
|
+
}
|
|
62
|
+
export interface Arc3MetricsReport {
|
|
63
|
+
plays: number;
|
|
64
|
+
totalActions: number;
|
|
65
|
+
totalLevelsCompleted: number;
|
|
66
|
+
meanActionEfficiency: number;
|
|
67
|
+
meanExplorationEfficiency: number;
|
|
68
|
+
meanRecoveryRate: number;
|
|
69
|
+
perPlay: Arc3PlayMetrics[];
|
|
70
|
+
}
|
|
71
|
+
/** ARC-005: aggregate the blueprint's action/exploration efficiency and
|
|
72
|
+
* recovery metrics over recorded ARC-AGI-3 plays (trajectories + episodic
|
|
73
|
+
* summaries). Honest on empty: null, never zeros-that-lie. */
|
|
74
|
+
export declare function arc3Metrics(home: string, limit?: number): Promise<Arc3MetricsReport | null>;
|
|
48
75
|
/** Compact world-model digest for the SYSTEM PROMPT. The model sees which
|
|
49
76
|
* tool types history trusts, which keep failing, and what the diagnosis
|
|
50
77
|
* layer currently suggests — perception feeding action, capped hard so it
|
package/dist/analysis.js
CHANGED
|
@@ -118,6 +118,59 @@ export async function benchFromTrajectories(home, environmentId = 'terminal', li
|
|
|
118
118
|
},
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
+
/** ARC-005: aggregate the blueprint's action/exploration efficiency and
|
|
122
|
+
* recovery metrics over recorded ARC-AGI-3 plays (trajectories + episodic
|
|
123
|
+
* summaries). Honest on empty: null, never zeros-that-lie. */
|
|
124
|
+
export async function arc3Metrics(home, limit = 100) {
|
|
125
|
+
const trajectories = (await loadTrajectories(home, limit)).filter((t) => t.environment.id === 'arc3');
|
|
126
|
+
if (trajectories.length === 0)
|
|
127
|
+
return null;
|
|
128
|
+
const perPlay = [];
|
|
129
|
+
for (const traj of trajectories) {
|
|
130
|
+
const actionTypes = new Set(traj.steps.map((s) => s.action.type));
|
|
131
|
+
const failures = traj.steps.filter((s) => s.outcome === 'failure').length;
|
|
132
|
+
const levels = traj.goal?.description?.match(/game ([\w-]+)/)?.[1];
|
|
133
|
+
perPlay.push({
|
|
134
|
+
trajectoryId: traj.id,
|
|
135
|
+
gameId: levels,
|
|
136
|
+
actions: traj.metrics.actions,
|
|
137
|
+
// levels come from the episodic summary written at close; the trajectory
|
|
138
|
+
// itself records actions — levels default 0 when the summary is absent
|
|
139
|
+
levelsCompleted: 0,
|
|
140
|
+
levelCount: 0,
|
|
141
|
+
actionEfficiency: Number((0 / Math.max(1, traj.metrics.actions)).toFixed(3)),
|
|
142
|
+
explorationEfficiency: Number((actionTypes.size / 7).toFixed(3)),
|
|
143
|
+
recoveryRate: failures ? Number((traj.metrics.recoveryCount / failures).toFixed(3)) : 0,
|
|
144
|
+
finishedAt: traj.endedAt ?? traj.startedAt,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// enrich with episodic summaries ("ARC3 PLAY game: L/N levels in M actions")
|
|
148
|
+
const mem = new (await import("./memory.js")).CognitiveMemory(home);
|
|
149
|
+
await mem.load();
|
|
150
|
+
const summaries = mem.retrieve({ layer: 'episodic', text: 'ARC3 PLAY', limit: 200 });
|
|
151
|
+
for (const p of perPlay) {
|
|
152
|
+
const s = summaries.find((e) => e.payload?.trajectoryId === p.trajectoryId);
|
|
153
|
+
if (!s)
|
|
154
|
+
continue;
|
|
155
|
+
const m = s.content.match(/([\w-]+): (\d+)\/(\d+) levels in (\d+) actions/);
|
|
156
|
+
if (!m)
|
|
157
|
+
continue;
|
|
158
|
+
p.gameId = m[1];
|
|
159
|
+
p.levelsCompleted = Number(m[2]);
|
|
160
|
+
p.levelCount = Number(m[3]);
|
|
161
|
+
p.actionEfficiency = Number((Number(m[2]) / Math.max(1, Number(m[4]))).toFixed(3));
|
|
162
|
+
}
|
|
163
|
+
const avg = (pick) => Number((perPlay.reduce((s, p) => s + pick(p), 0) / perPlay.length).toFixed(3));
|
|
164
|
+
return {
|
|
165
|
+
plays: perPlay.length,
|
|
166
|
+
totalActions: perPlay.reduce((s, p) => s + p.actions, 0),
|
|
167
|
+
totalLevelsCompleted: perPlay.reduce((s, p) => s + p.levelsCompleted, 0),
|
|
168
|
+
meanActionEfficiency: avg((p) => p.actionEfficiency),
|
|
169
|
+
meanExplorationEfficiency: avg((p) => p.explorationEfficiency),
|
|
170
|
+
meanRecoveryRate: avg((p) => p.recoveryRate),
|
|
171
|
+
perPlay,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
121
174
|
/* ---- context advisor (blueprint M3: the planner consumes the world model) ---- */
|
|
122
175
|
/** Compact world-model digest for the SYSTEM PROMPT. The model sees which
|
|
123
176
|
* tool types history trusts, which keep failing, and what the diagnosis
|
package/dist/transfer-lab.js
CHANGED
|
@@ -114,7 +114,7 @@ export async function runTransferExperiment(home, opts) {
|
|
|
114
114
|
samplesWith: withArm.totalActions,
|
|
115
115
|
samplesWithout: withoutArm.totalActions,
|
|
116
116
|
};
|
|
117
|
-
|
|
117
|
+
const report = {
|
|
118
118
|
sourceEnv: opts.sourceEnv,
|
|
119
119
|
targetEnv: opts.targetEnv,
|
|
120
120
|
runsPerArm,
|
|
@@ -130,4 +130,16 @@ export async function runTransferExperiment(home, opts) {
|
|
|
130
130
|
? Number((withoutArm.meanBrier - withArm.meanBrier).toFixed(4))
|
|
131
131
|
: undefined,
|
|
132
132
|
};
|
|
133
|
+
// experiments persist (RD-009 matrix data source) — best-effort, never blocks
|
|
134
|
+
if (opts.record !== false) {
|
|
135
|
+
try {
|
|
136
|
+
const { appendFile, mkdir } = await import('node:fs/promises');
|
|
137
|
+
const { join: j } = await import('node:path');
|
|
138
|
+
const dir = j(home, 'cognitive');
|
|
139
|
+
await mkdir(dir, { recursive: true });
|
|
140
|
+
await appendFile(j(dir, 'transfer.jsonl'), JSON.stringify({ at: new Date().toISOString(), ...report }) + '\n', 'utf8');
|
|
141
|
+
}
|
|
142
|
+
catch { /* persistence is best-effort */ }
|
|
143
|
+
}
|
|
144
|
+
return report;
|
|
133
145
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cognitive",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.3",
|
|
4
4
|
"description": "hmharness Cognitive OS core: Environment protocol, World Model, Goal system, Exploration, RLM runtime, five-layer memory, Skill Compiler, Continual Learning control plane, Evolution 2.0 governance, Multi-Agent topology, Transfer lab and GeneralBench schema. Cognitive strategy layer per the HMH Cognitive OS blueprint (2026-09).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"node": ">=22"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@hmharness/kernel": "0.20.
|
|
29
|
+
"@hmharness/kernel": "0.20.3"
|
|
30
30
|
}
|
|
31
31
|
}
|