@hmharness/cognitive 0.19.7 → 0.19.8
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/learning-loop.d.ts +18 -0
- package/dist/learning-loop.js +47 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface LearnOutcome {
|
|
2
|
+
opportunityId: string;
|
|
3
|
+
signal: string;
|
|
4
|
+
trained: boolean;
|
|
5
|
+
memoryEntries: string[];
|
|
6
|
+
note: 'promotion continues through the evolve bench pipeline (train/holdout gates)';
|
|
7
|
+
}
|
|
8
|
+
export interface LearnReport {
|
|
9
|
+
trajectories: number;
|
|
10
|
+
opportunities: number;
|
|
11
|
+
trained: number;
|
|
12
|
+
outcomes: LearnOutcome[];
|
|
13
|
+
}
|
|
14
|
+
/** The real trainer for memory-target opportunities: distill failing runs
|
|
15
|
+
* into semantic memory with provenance + an evolution note for retrieval. */
|
|
16
|
+
export declare function runLearningLoop(home: string, opts?: {
|
|
17
|
+
writeEvolutionNote?: (note: string) => Promise<void>;
|
|
18
|
+
}): Promise<LearnReport>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hmharness/cognitive - learning loop (blueprint M8 / CL-005 live)
|
|
3
|
+
*
|
|
4
|
+
* Closes the harness-level learning ring over REAL data:
|
|
5
|
+
* diagnose (analysis.ts, live trajectories)
|
|
6
|
+
* -> train: for memory-target opportunities, distill the failing runs
|
|
7
|
+
* into semantic memory entries (full provenance) AND an evolution
|
|
8
|
+
* memory note so the NEXT task's retrieval injection can use them
|
|
9
|
+
* -> promotion is NOT taken here: candidates flow into the existing
|
|
10
|
+
* evolve bench pipeline (train/holdout gates) — this loop never
|
|
11
|
+
* self-promotes (evaluator independence, blueprint §9).
|
|
12
|
+
*/
|
|
13
|
+
import { CognitiveMemory } from "./memory.js";
|
|
14
|
+
import { diagnoseOpportunities } from "./analysis.js";
|
|
15
|
+
/** The real trainer for memory-target opportunities: distill failing runs
|
|
16
|
+
* into semantic memory with provenance + an evolution note for retrieval. */
|
|
17
|
+
export async function runLearningLoop(home, opts = {}) {
|
|
18
|
+
const { opportunities, trajectories } = await diagnoseOpportunities(home);
|
|
19
|
+
const mem = new CognitiveMemory(home);
|
|
20
|
+
await mem.load();
|
|
21
|
+
const outcomes = [];
|
|
22
|
+
let trained = 0;
|
|
23
|
+
for (const opp of opportunities) {
|
|
24
|
+
if (!opp.suggestedTargets.includes('memory')) {
|
|
25
|
+
outcomes.push({ opportunityId: opp.id, signal: opp.signal, trained: false, memoryEntries: [], note: 'promotion continues through the evolve bench pipeline (train/holdout gates)' });
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// distill: the signal IS the lesson (deterministic; the LLM refinement
|
|
29
|
+
// layer can polish wording later — provenance is what cannot be faked)
|
|
30
|
+
const content = `[lesson] ${opp.signal} — address via ${opp.suggestedTargets.join('/')}`;
|
|
31
|
+
const entry = await mem.write({
|
|
32
|
+
layer: 'semantic',
|
|
33
|
+
content,
|
|
34
|
+
payload: { opportunityId: opp.id, evidence: opp.evidence },
|
|
35
|
+
source: 'learning-loop',
|
|
36
|
+
provenance: `opportunity:${opp.id}`,
|
|
37
|
+
confidence: Math.min(0.85, 0.5 + opp.evidence.value / 20),
|
|
38
|
+
environment: 'terminal',
|
|
39
|
+
session: 'learning-loop',
|
|
40
|
+
tags: ['lesson', ...opp.suggestedTargets],
|
|
41
|
+
});
|
|
42
|
+
await opts.writeEvolutionNote?.(content).catch(() => undefined);
|
|
43
|
+
trained += 1;
|
|
44
|
+
outcomes.push({ opportunityId: opp.id, signal: opp.signal, trained: true, memoryEntries: [entry.id], note: 'promotion continues through the evolve bench pipeline (train/holdout gates)' });
|
|
45
|
+
}
|
|
46
|
+
return { trajectories, opportunities: opportunities.length, trained, outcomes };
|
|
47
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cognitive",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.8",
|
|
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.8"
|
|
30
30
|
}
|
|
31
31
|
}
|