@hmharness/cognitive 0.23.27 → 0.23.28
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/learning-targets.d.ts +15 -0
- package/dist/learning-targets.js +45 -0
- package/package.json +2 -2
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import type { Candidate, EvalResult, LearningDataset, LearningPlan, LearningTarget } from './continual.js';
|
|
27
27
|
import type { CognitiveLedger } from './ledger.js';
|
|
28
|
+
import { type WorkflowCandidate } from './skill-compiler.js';
|
|
28
29
|
export type TargetTrainer = (plan: LearningPlan, dataset: LearningDataset) => Promise<Candidate>;
|
|
29
30
|
export type TargetEvaluator = (candidate: Candidate, holdout: LearningDataset) => Promise<EvalResult>;
|
|
30
31
|
export type TargetRollback = (candidate: Candidate) => Promise<void>;
|
|
@@ -75,3 +76,17 @@ export declare class LearningTargetRegistry {
|
|
|
75
76
|
runCycle(plan: LearningPlan, train: LearningDataset): Promise<CycleOutcome>;
|
|
76
77
|
private emit;
|
|
77
78
|
}
|
|
79
|
+
export interface SkillCandidate extends Candidate {
|
|
80
|
+
workflows: WorkflowCandidate[];
|
|
81
|
+
}
|
|
82
|
+
export declare function registerSkillTarget(registry: LearningTargetRegistry, opts: {
|
|
83
|
+
/** disjoint-from-train holdout source - the caller owns the split */
|
|
84
|
+
holdout: () => Promise<LearningDataset>;
|
|
85
|
+
mining?: {
|
|
86
|
+
minSupport?: number;
|
|
87
|
+
nMin?: number;
|
|
88
|
+
nMax?: number;
|
|
89
|
+
};
|
|
90
|
+
policy?: Partial<PromotionPolicy>;
|
|
91
|
+
lineageSource?: string;
|
|
92
|
+
}): void;
|
package/dist/learning-targets.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { evidenceThreshold } from "./continual.js";
|
|
2
|
+
import { mineWorkflows } from "./skill-compiler.js";
|
|
2
3
|
const REQUIRED_FIELDS = ['trainer', 'evaluator', 'holdout', 'promotionPolicy', 'rollback', 'lineage'];
|
|
3
4
|
/** Only vocabulary kinds are mirrored - see the module doc. */
|
|
4
5
|
const LEDGER_MAP = {
|
|
@@ -77,3 +78,47 @@ export class LearningTargetRegistry {
|
|
|
77
78
|
catch { /* the ledger must never break the cycle it observes */ }
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
function containsGram(seq, gram) {
|
|
82
|
+
outer: for (let i = 0; i + gram.length <= seq.length; i++) {
|
|
83
|
+
for (let j = 0; j < gram.length; j++)
|
|
84
|
+
if (seq[i + j] !== gram[j])
|
|
85
|
+
continue outer;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
function successSequence(t) {
|
|
91
|
+
return t.steps.filter((s) => s.outcome === 'success').map((s) => s.action.type);
|
|
92
|
+
}
|
|
93
|
+
export function registerSkillTarget(registry, opts) {
|
|
94
|
+
registry.register({
|
|
95
|
+
target: 'skill',
|
|
96
|
+
trainer: async (plan, dataset) => ({
|
|
97
|
+
id: `skill-${plan.opportunityId}-${Math.random().toString(36).slice(2, 8)}`,
|
|
98
|
+
plan,
|
|
99
|
+
createdAt: new Date().toISOString(),
|
|
100
|
+
status: 'draft',
|
|
101
|
+
workflows: mineWorkflows(dataset.trajectories, opts.mining ?? {}),
|
|
102
|
+
}),
|
|
103
|
+
evaluator: async (candidate, holdout) => {
|
|
104
|
+
const top = candidate.workflows[0];
|
|
105
|
+
const holdoutSuccesses = holdout.trajectories.filter((t) => t.metrics.success);
|
|
106
|
+
if (!top) {
|
|
107
|
+
return { candidateId: candidate.id, pass: false, metrics: { evidence: 0, holdoutSuccesses: holdoutSuccesses.length }, holdoutSize: holdout.trajectories.length };
|
|
108
|
+
}
|
|
109
|
+
const containing = holdoutSuccesses.filter((t) => containsGram(successSequence(t), top.steps)).length;
|
|
110
|
+
const evidence = holdoutSuccesses.length > 0 ? Number((containing / holdoutSuccesses.length).toFixed(3)) : 0;
|
|
111
|
+
const pass = holdoutSuccesses.length >= 2 && evidence >= 0.5;
|
|
112
|
+
return {
|
|
113
|
+
candidateId: candidate.id,
|
|
114
|
+
pass,
|
|
115
|
+
metrics: { evidence, holdoutSuccesses: holdoutSuccesses.length, workflowSupport: top.support },
|
|
116
|
+
holdoutSize: holdout.trajectories.length,
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
holdout: opts.holdout,
|
|
120
|
+
promotionPolicy: { minEvidence: 0.5, requireHoldout: true, canaryShare: 0.2, ...opts.policy },
|
|
121
|
+
rollback: async () => undefined, // skill rollback is host-side promotion bookkeeping; v0 records intent via the ledger chain
|
|
122
|
+
lineage: { registeredAt: new Date().toISOString(), version: 1, source: opts.lineageSource ?? 'skill-compiler.mineWorkflows' },
|
|
123
|
+
});
|
|
124
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cognitive",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.28",
|
|
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.28"
|
|
30
30
|
}
|
|
31
31
|
}
|