@hmharness/cognitive 0.23.14 → 0.23.15
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/protocol.d.ts +11 -0
- package/dist/registry.d.ts +1 -0
- package/dist/registry.js +15 -1
- package/package.json +2 -2
package/dist/protocol.d.ts
CHANGED
|
@@ -84,6 +84,17 @@ export interface EnvironmentScore {
|
|
|
84
84
|
export interface Environment {
|
|
85
85
|
id: string;
|
|
86
86
|
version: string;
|
|
87
|
+
/**
|
|
88
|
+
* Snapshot semantics (review 02 doc, Snapshot/Restore v2). Every
|
|
89
|
+
* environment MUST declare what its snapshot/restore actually means:
|
|
90
|
+
* - deterministic: restore() returns the environment to the exact
|
|
91
|
+
* snapshotted state (in-memory scratch worlds)
|
|
92
|
+
* - forkable: state copies into independent branches (RLM-style)
|
|
93
|
+
* - observational: the snapshot is an OBSERVATION for audit/diff only;
|
|
94
|
+
* restore() cannot rewind the real world and must not pretend to
|
|
95
|
+
* (browsers, desktops, devices, live games)
|
|
96
|
+
*/
|
|
97
|
+
snapshotClass: 'deterministic' | 'forkable' | 'observational';
|
|
87
98
|
capabilities(): Promise<Capability[]>;
|
|
88
99
|
reset(opts?: ResetOptions): Promise<Observation>;
|
|
89
100
|
observe(): Promise<Observation>;
|
package/dist/registry.d.ts
CHANGED
package/dist/registry.js
CHANGED
|
@@ -92,6 +92,15 @@ export class EnvironmentRegistry {
|
|
|
92
92
|
if (r.outcome === 'failure' && !r.error)
|
|
93
93
|
throw new Error('failure without structured error');
|
|
94
94
|
});
|
|
95
|
+
await step('snapshot-class', async () => {
|
|
96
|
+
// Snapshot/Restore v2: every environment declares what its snapshot
|
|
97
|
+
// MEANS; observational ones must not be treated as rewindable by
|
|
98
|
+
// callers (the hash-divergence check below is advisory for them).
|
|
99
|
+
const cls = env.snapshotClass;
|
|
100
|
+
if (!['deterministic', 'forkable', 'observational'].includes(cls ?? '')) {
|
|
101
|
+
throw new Error(`snapshotClass must be declared (got ${String(cls)})`);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
95
104
|
await step('snapshot+restore', async () => {
|
|
96
105
|
const snap = await env.snapshot();
|
|
97
106
|
if (typeof snap.stateHash !== 'string' || !snap.stateHash)
|
|
@@ -99,7 +108,11 @@ export class EnvironmentRegistry {
|
|
|
99
108
|
await env.restore(snap);
|
|
100
109
|
const after = await env.snapshot();
|
|
101
110
|
if (after.stateHash !== stableHash(snap.payload) && after.stateHash !== snap.stateHash) {
|
|
102
|
-
// hash drift after immediate restore means restore is not faithful
|
|
111
|
+
// hash drift after immediate restore means restore is not faithful.
|
|
112
|
+
// For observational environments this is EXPECTED (restore is a
|
|
113
|
+
// no-op); only deterministic/forkable worlds must replay exactly.
|
|
114
|
+
if (env.snapshotClass === 'observational')
|
|
115
|
+
return;
|
|
103
116
|
failures.push('snapshot/restore: stateHash diverged right after restore');
|
|
104
117
|
}
|
|
105
118
|
});
|
|
@@ -125,6 +138,7 @@ function withTimeout(p, ms, message) {
|
|
|
125
138
|
export class MemoryEnvironment {
|
|
126
139
|
id;
|
|
127
140
|
version = '1.0.0';
|
|
141
|
+
snapshotClass = 'deterministic'; // in-memory scratch world: restore replays exactly
|
|
128
142
|
state = {};
|
|
129
143
|
stepCount = 0;
|
|
130
144
|
constructor(id = 'memory') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cognitive",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.15",
|
|
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.15"
|
|
30
30
|
}
|
|
31
31
|
}
|