@hmharness/cognitive 0.19.5 → 0.19.7

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.
@@ -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
- export declare function analyzeGoalDrift(home: string, limit?: number): Promise<GoalDriftView[]>;
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
- export async function analyzeGoalDrift(home, limit = 100) {
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
- return out.sort((a, b) => b.driftScore - a.driftScore);
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
@@ -89,6 +89,8 @@ export declare class AgentTopology {
89
89
  private seq;
90
90
  constructor(spec: TopologySpec, blackboard: SharedBlackboard);
91
91
  view(): AgentNode[];
92
+ /** grow the running topology with a new node of a role (live spawns) */
93
+ addNode(role: AgentRoleName): AgentNode;
92
94
  board(): SharedBlackboard;
93
95
  start(id: string): void;
94
96
  /** MA-007. Liveness signal; stale agents are visible to the supervisor. */
@@ -38,6 +38,15 @@ export class AgentTopology {
38
38
  view() {
39
39
  return [...this.nodes.values()];
40
40
  }
41
+ /** grow the running topology with a new node of a role (live spawns) */
42
+ addNode(role) {
43
+ const contract = ROLE_CONTRACTS[role];
44
+ const id = `${role}-${++this.seq}`;
45
+ const node = { id, role, status: 'pending', contract };
46
+ this.nodes.set(id, node);
47
+ this.spec.nodes.push(contract);
48
+ return node;
49
+ }
41
50
  board() {
42
51
  return JSON.parse(JSON.stringify(this.blackboard));
43
52
  }
@@ -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;
@@ -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.5",
3
+ "version": "0.19.7",
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.5"
29
+ "@hmharness/kernel": "0.19.7"
30
30
  }
31
31
  }