@hmharness/cognitive 0.19.5 → 0.19.6
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 +4 -2
- package/dist/analysis.js +10 -3
- package/dist/transfer-lab.d.ts +7 -0
- package/dist/transfer-lab.js +9 -2
- package/package.json +2 -2
package/dist/analysis.d.ts
CHANGED
|
@@ -58,8 +58,10 @@ export interface GoalDriftView {
|
|
|
58
58
|
recommendation: string;
|
|
59
59
|
}
|
|
60
60
|
/** GOAL-005 on live data: for every recorded trajectory that carried a goal,
|
|
61
|
-
* compare its actions against the goal's keywords and report drift.
|
|
62
|
-
|
|
61
|
+
* compare its actions against the goal's keywords and report drift.
|
|
62
|
+
* order='score' (default) ranks worst-first; order='time' is the timeline
|
|
63
|
+
* view (oldest→newest) the dashboard renders as a trend. */
|
|
64
|
+
export declare function analyzeGoalDrift(home: string, limit?: number, order?: 'score' | 'time'): Promise<GoalDriftView[]>;
|
|
63
65
|
export interface SkillCandidateView {
|
|
64
66
|
id: string;
|
|
65
67
|
name: string;
|
package/dist/analysis.js
CHANGED
|
@@ -149,8 +149,10 @@ export async function buildContextDigest(home, maxChars = 500) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
/** GOAL-005 on live data: for every recorded trajectory that carried a goal,
|
|
152
|
-
* compare its actions against the goal's keywords and report drift.
|
|
153
|
-
|
|
152
|
+
* compare its actions against the goal's keywords and report drift.
|
|
153
|
+
* order='score' (default) ranks worst-first; order='time' is the timeline
|
|
154
|
+
* view (oldest→newest) the dashboard renders as a trend. */
|
|
155
|
+
export async function analyzeGoalDrift(home, limit = 100, order = 'score') {
|
|
154
156
|
const { GoalManager } = await import("./goal.js");
|
|
155
157
|
const gm = new GoalManager();
|
|
156
158
|
const trajectories = (await loadTrajectories(home, limit)).filter((t) => t.goal?.description);
|
|
@@ -177,9 +179,14 @@ export async function analyzeGoalDrift(home, limit = 100) {
|
|
|
177
179
|
driftScore: report.driftScore,
|
|
178
180
|
signals: report.signals,
|
|
179
181
|
recommendation: report.recommendation,
|
|
182
|
+
startedAt: traj.startedAt,
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
|
-
|
|
185
|
+
if (order === 'time')
|
|
186
|
+
out.sort((a, b) => a.startedAt.localeCompare(b.startedAt));
|
|
187
|
+
else
|
|
188
|
+
out.sort((a, b) => b.driftScore - a.driftScore);
|
|
189
|
+
return out;
|
|
183
190
|
}
|
|
184
191
|
/** SK-002 on live data: mine repeated successful action runs from the
|
|
185
192
|
* trajectory store into skill CANDIDATES (promotion still requires the
|
package/dist/transfer-lab.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ export interface TransferExperimentReport {
|
|
|
38
38
|
score: number;
|
|
39
39
|
verdict: 'positive' | 'neutral' | 'negative';
|
|
40
40
|
trajectoryIds: string[];
|
|
41
|
+
/** calibration: mean Brier per arm (lower = better predicted). The seeded
|
|
42
|
+
* arm should predict overlapping actions better than the empty arm even
|
|
43
|
+
* when success rates tie — that is real carried knowledge. */
|
|
44
|
+
brierWith?: number;
|
|
45
|
+
brierWithout?: number;
|
|
46
|
+
/** positive = seeded arm better calibrated (its Brier is lower) */
|
|
47
|
+
calibrationDelta?: number;
|
|
41
48
|
}
|
|
42
49
|
export declare function runTransferExperiment(home: string, opts: {
|
|
43
50
|
sourceEnv: string;
|
package/dist/transfer-lab.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TrajectoryStore, TrajectoryRecorder } from "./index.js";
|
|
1
|
+
import { TrajectoryStore, TrajectoryRecorder, brierScore } from "./index.js";
|
|
2
2
|
import { WorldModel } from "./world-model.js";
|
|
3
3
|
import { ExplorationEngine, UcbExplorationPolicy, HypothesisRegistry } from "./exploration.js";
|
|
4
4
|
import { loadTrajectories, replayIntoWorldModel } from "./analysis.js";
|
|
@@ -47,6 +47,7 @@ async function runArm(home, makeEnv, wmSeed, runs, maxActions, envId, armLabel)
|
|
|
47
47
|
const details = [];
|
|
48
48
|
let successfulActions = 0;
|
|
49
49
|
let totalActions = 0;
|
|
50
|
+
const allSteps = [];
|
|
50
51
|
const wm = wmSeed ?? new WorldModel(envId);
|
|
51
52
|
// each run gets a FRESH environment (no cross-run state leakage) but the
|
|
52
53
|
// SAME world model — that is the "carried knowledge" being measured
|
|
@@ -58,10 +59,11 @@ async function runArm(home, makeEnv, wmSeed, runs, maxActions, envId, armLabel)
|
|
|
58
59
|
totalActions += result.actionsTaken;
|
|
59
60
|
successfulActions += result.successfulActions;
|
|
60
61
|
const traj = rec.finish(result.actionsTaken > 0);
|
|
62
|
+
allSteps.push(...traj.steps);
|
|
61
63
|
await store?.append(traj).catch(() => undefined);
|
|
62
64
|
await env.close().catch(() => undefined);
|
|
63
65
|
}
|
|
64
|
-
return { successes: successfulActions, runs, totalActions, details, wm, successfulActions };
|
|
66
|
+
return { successes: successfulActions, runs, totalActions, details, wm, successfulActions, meanBrier: brierScore(allSteps) };
|
|
65
67
|
}
|
|
66
68
|
export async function runTransferExperiment(home, opts) {
|
|
67
69
|
const runsPerArm = Math.min(Math.max(opts.runsPerArm ?? 3, 1), 10);
|
|
@@ -122,5 +124,10 @@ export async function runTransferExperiment(home, opts) {
|
|
|
122
124
|
score: transferScore(cell),
|
|
123
125
|
verdict: transferVerdict(cell),
|
|
124
126
|
trajectoryIds: [],
|
|
127
|
+
brierWith: withArm.meanBrier,
|
|
128
|
+
brierWithout: withoutArm.meanBrier,
|
|
129
|
+
calibrationDelta: withArm.meanBrier !== undefined && withoutArm.meanBrier !== undefined
|
|
130
|
+
? Number((withoutArm.meanBrier - withArm.meanBrier).toFixed(4))
|
|
131
|
+
: undefined,
|
|
125
132
|
};
|
|
126
133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cognitive",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.6",
|
|
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.19.
|
|
29
|
+
"@hmharness/kernel": "0.19.6"
|
|
30
30
|
}
|
|
31
31
|
}
|