@hmharness/cognitive 0.23.32 → 0.23.34
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/world-model.d.ts +16 -0
- package/dist/world-model.js +53 -0
- package/package.json +2 -2
package/dist/world-model.d.ts
CHANGED
|
@@ -192,4 +192,20 @@ export declare class WorldModel {
|
|
|
192
192
|
meanError: number | undefined;
|
|
193
193
|
};
|
|
194
194
|
get transitionsStore(): TransitionStore;
|
|
195
|
+
/** WM checkpoint: a serializable snapshot that fromCheckpoint() can restore
|
|
196
|
+
* exactly — the state, the rolling accuracy counters, and the transitions
|
|
197
|
+
* (the replay/revision evidence, capped to the most recent N). */
|
|
198
|
+
checkpoint(maxTransitions?: number): string;
|
|
199
|
+
static fromCheckpoint(json: string): WorldModel;
|
|
200
|
+
/** Stale-belief detection (0.30): beliefs whose last confirming evidence is
|
|
201
|
+
* older than the threshold are flagged — a long-running session should
|
|
202
|
+
* distrust them for planning until fresh evidence reconfirms. A belief
|
|
203
|
+
* never confirmed (no lastConfirmedAt) is flagged only when the model has
|
|
204
|
+
* been running (version > 1), so fresh models don't false-alarm. */
|
|
205
|
+
staleBeliefs(maxAgeMs: number, now?: Date): Array<{
|
|
206
|
+
id: string;
|
|
207
|
+
claim: string;
|
|
208
|
+
lastConfirmedAt?: string;
|
|
209
|
+
ageMs: number;
|
|
210
|
+
}>;
|
|
195
211
|
}
|
package/dist/world-model.js
CHANGED
|
@@ -299,4 +299,57 @@ export class WorldModel {
|
|
|
299
299
|
get transitionsStore() {
|
|
300
300
|
return this.transitions;
|
|
301
301
|
}
|
|
302
|
+
/* -------- Long-running sessions (weekly pack 0.30 P2 infrastructure) -------- */
|
|
303
|
+
/** WM checkpoint: a serializable snapshot that fromCheckpoint() can restore
|
|
304
|
+
* exactly — the state, the rolling accuracy counters, and the transitions
|
|
305
|
+
* (the replay/revision evidence, capped to the most recent N). */
|
|
306
|
+
checkpoint(maxTransitions = 1000) {
|
|
307
|
+
return JSON.stringify({
|
|
308
|
+
kind: 'hmharness-world-model-checkpoint',
|
|
309
|
+
version: 1,
|
|
310
|
+
state: this.state,
|
|
311
|
+
deltaChecked: this.deltaChecked,
|
|
312
|
+
deltaHits: this.deltaHits,
|
|
313
|
+
seq: this.seq,
|
|
314
|
+
predictions: [...this.predictions.values()].slice(-200),
|
|
315
|
+
transitions: this.transitions.all().slice(-maxTransitions),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
static fromCheckpoint(json) {
|
|
319
|
+
const j = JSON.parse(json);
|
|
320
|
+
if (j.kind !== 'hmharness-world-model-checkpoint')
|
|
321
|
+
throw new Error('not a world-model checkpoint');
|
|
322
|
+
const wm = new WorldModel(j.state.environmentId);
|
|
323
|
+
wm.state = j.state;
|
|
324
|
+
wm.deltaChecked = j.deltaChecked;
|
|
325
|
+
wm.deltaHits = j.deltaHits;
|
|
326
|
+
wm.seq = j.seq;
|
|
327
|
+
for (const p of j.predictions ?? [])
|
|
328
|
+
wm.predictions.set(p.id, p);
|
|
329
|
+
for (const t of j.transitions ?? [])
|
|
330
|
+
wm.transitions.append(t);
|
|
331
|
+
return wm;
|
|
332
|
+
}
|
|
333
|
+
/** Stale-belief detection (0.30): beliefs whose last confirming evidence is
|
|
334
|
+
* older than the threshold are flagged — a long-running session should
|
|
335
|
+
* distrust them for planning until fresh evidence reconfirms. A belief
|
|
336
|
+
* never confirmed (no lastConfirmedAt) is flagged only when the model has
|
|
337
|
+
* been running (version > 1), so fresh models don't false-alarm. */
|
|
338
|
+
staleBeliefs(maxAgeMs, now = new Date()) {
|
|
339
|
+
if (this.state.version <= 1)
|
|
340
|
+
return [];
|
|
341
|
+
const nowMs = now.getTime();
|
|
342
|
+
return this.state.beliefs
|
|
343
|
+
.filter((b) => {
|
|
344
|
+
if (!b.lastConfirmedAt)
|
|
345
|
+
return true; // never confirmed = stale by definition (after warm-up)
|
|
346
|
+
return nowMs - new Date(b.lastConfirmedAt).getTime() >= maxAgeMs;
|
|
347
|
+
})
|
|
348
|
+
.map((b) => ({
|
|
349
|
+
id: b.id,
|
|
350
|
+
claim: b.claim,
|
|
351
|
+
...(b.lastConfirmedAt ? { lastConfirmedAt: b.lastConfirmedAt } : {}),
|
|
352
|
+
ageMs: b.lastConfirmedAt ? nowMs - new Date(b.lastConfirmedAt).getTime() : Infinity,
|
|
353
|
+
}));
|
|
354
|
+
}
|
|
302
355
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cognitive",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.34",
|
|
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.23.
|
|
29
|
+
"@hmharness/kernel": "0.23.34"
|
|
30
30
|
}
|
|
31
31
|
}
|