@hmharness/cognitive 0.23.30 → 0.23.31
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/abstract-actions.d.ts +23 -0
- package/dist/abstract-actions.js +54 -0
- package/dist/skill-compiler.d.ts +17 -0
- package/dist/skill-compiler.js +57 -0
- package/package.json +2 -2
|
@@ -44,3 +44,26 @@ export interface TransferMatrixCell {
|
|
|
44
44
|
* - 'evidence' requires a supplied TransferExperimentReport-shaped record
|
|
45
45
|
* - the diagonal is 'same-env', not transfer */
|
|
46
46
|
export declare function transferMatrix(experiments: Array<Pick<import('./transfer-lab.ts').TransferExperimentReport, 'sourceEnv' | 'targetEnv' | 'score' | 'verdict' | 'runsPerArm' | 'calibrationDelta'>>): TransferMatrixCell[][];
|
|
47
|
+
export interface EnvironmentIR {
|
|
48
|
+
environment: TransferEnvironmentId;
|
|
49
|
+
/** state variables the environment's observations expose */
|
|
50
|
+
stateKeys: string[];
|
|
51
|
+
/** what an observation carries in this environment */
|
|
52
|
+
observationKinds: string[];
|
|
53
|
+
/** what VERIFICATION means here (empty = verification not yet modeled) */
|
|
54
|
+
verificationOps: string[];
|
|
55
|
+
}
|
|
56
|
+
export declare const ENVIRONMENT_IR: Record<TransferEnvironmentId, EnvironmentIR>;
|
|
57
|
+
export interface TransferReadiness {
|
|
58
|
+
target: TransferEnvironmentId;
|
|
59
|
+
ready: boolean;
|
|
60
|
+
/** abstract verbs the procedure needs that the target env cannot express */
|
|
61
|
+
missingVerbs: string[];
|
|
62
|
+
/** verify-steps the target env cannot check (verificationOps empty or verb unmapped) */
|
|
63
|
+
verificationBlockers: string[];
|
|
64
|
+
/** target-env literals that DO cover the procedure's verbs (the binding surface) */
|
|
65
|
+
bindings: Record<string, string[]>;
|
|
66
|
+
}
|
|
67
|
+
/** Can a skill's abstract-verb procedure execute AND verify in the target?
|
|
68
|
+
* Bindings come from the explicit literal tables - nothing inferred. */
|
|
69
|
+
export declare function transferReadiness(abstractProcedure: string[], target: TransferEnvironmentId): TransferReadiness;
|
package/dist/abstract-actions.js
CHANGED
|
@@ -103,3 +103,57 @@ export function transferMatrix(experiments) {
|
|
|
103
103
|
};
|
|
104
104
|
}));
|
|
105
105
|
}
|
|
106
|
+
export const ENVIRONMENT_IR = {
|
|
107
|
+
terminal: {
|
|
108
|
+
environment: 'terminal',
|
|
109
|
+
stateKeys: ['cwd', 'files', 'exitCode', 'stdoutTail'],
|
|
110
|
+
observationKinds: ['command-output', 'fs-listing'],
|
|
111
|
+
verificationOps: ['exit-code-zero', 'output-contains', 'file-exists'],
|
|
112
|
+
},
|
|
113
|
+
harmonyos: {
|
|
114
|
+
environment: 'harmonyos',
|
|
115
|
+
stateKeys: ['device', 'installedHaps', 'buildStatus', 'signingProfile'],
|
|
116
|
+
observationKinds: ['hdc-output', 'hilog', 'build-log'],
|
|
117
|
+
verificationOps: ['build-successful', 'device-test-pass', 'hap-installed'],
|
|
118
|
+
},
|
|
119
|
+
browser: {
|
|
120
|
+
environment: 'browser',
|
|
121
|
+
stateKeys: ['tabs', 'activeUrl', 'pageText', 'selection'],
|
|
122
|
+
observationKinds: ['page-read', 'tabs-list'],
|
|
123
|
+
verificationOps: ['url-matches', 'text-present', 'element-visible'],
|
|
124
|
+
},
|
|
125
|
+
desktop: {
|
|
126
|
+
environment: 'desktop',
|
|
127
|
+
stateKeys: ['windows', 'focusedWindow', 'screen'],
|
|
128
|
+
observationKinds: ['screenshot', 'window-list'],
|
|
129
|
+
verificationOps: ['pixel-region-match', 'window-titled'],
|
|
130
|
+
},
|
|
131
|
+
arc3: {
|
|
132
|
+
environment: 'arc3',
|
|
133
|
+
stateKeys: ['grid', 'score', 'movesLeft'],
|
|
134
|
+
observationKinds: ['rendered-frame', 'scorecard'],
|
|
135
|
+
verificationOps: ['score-improved'],
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
/** Can a skill's abstract-verb procedure execute AND verify in the target?
|
|
139
|
+
* Bindings come from the explicit literal tables - nothing inferred. */
|
|
140
|
+
export function transferReadiness(abstractProcedure, target) {
|
|
141
|
+
const targetVerbs = new Set(environmentAbstractActions(target));
|
|
142
|
+
const ir = ENVIRONMENT_IR[target];
|
|
143
|
+
const literalsFor = (verb) => Object.entries(ABSTRACT_ACTION_MAP)
|
|
144
|
+
.filter(([lit, v]) => v === verb && LITERAL_ENVIRONMENT[lit] === target)
|
|
145
|
+
.map(([lit]) => lit);
|
|
146
|
+
const missingVerbs = [];
|
|
147
|
+
const bindings = {};
|
|
148
|
+
for (const verb of abstractProcedure) {
|
|
149
|
+
const lits = literalsFor(verb);
|
|
150
|
+
bindings[verb] = lits;
|
|
151
|
+
if (lits.length === 0 && !targetVerbs.has(verb))
|
|
152
|
+
missingVerbs.push(verb);
|
|
153
|
+
}
|
|
154
|
+
const verificationBlockers = [];
|
|
155
|
+
if (abstractProcedure.includes('verify') && ir.verificationOps.length === 0) {
|
|
156
|
+
verificationBlockers.push('target has no modeled verification ops');
|
|
157
|
+
}
|
|
158
|
+
return { target, ready: missingVerbs.length === 0 && verificationBlockers.length === 0, missingVerbs, verificationBlockers, bindings };
|
|
159
|
+
}
|
package/dist/skill-compiler.d.ts
CHANGED
|
@@ -87,6 +87,23 @@ export declare function toSkillSpecV2(candidate: WorkflowCandidate, opts?: {
|
|
|
87
87
|
provenance?: string;
|
|
88
88
|
environmentScope?: string[];
|
|
89
89
|
}): SkillSpecV2;
|
|
90
|
+
export interface DerivedCounterexample {
|
|
91
|
+
description: string;
|
|
92
|
+
source: string;
|
|
93
|
+
}
|
|
94
|
+
export declare function deriveCounterexamples(candidate: WorkflowCandidate, holdout: CognitiveTrajectory[], opts?: {
|
|
95
|
+
cap?: number;
|
|
96
|
+
}): DerivedCounterexample[];
|
|
97
|
+
export interface SkillIR {
|
|
98
|
+
skillId: string;
|
|
99
|
+
/** procedure steps as abstract verbs; unmapped positions keep the literal */
|
|
100
|
+
abstractProcedure: string[];
|
|
101
|
+
/** indexes into abstractProcedure the map could not translate */
|
|
102
|
+
unmapped: number[];
|
|
103
|
+
environmentScope: string[];
|
|
104
|
+
provenance: string;
|
|
105
|
+
}
|
|
106
|
+
export declare function toSkillIR(skill: SkillSpecV2, map: Record<string, string>): SkillIR;
|
|
90
107
|
/** The benchmark surface the compiler verifies against — implemented by
|
|
91
108
|
* the environments/bench packages; kept as an interface for independence
|
|
92
109
|
* (evaluator independence rule: the compiler never grades its own work). */
|
package/dist/skill-compiler.js
CHANGED
|
@@ -34,6 +34,63 @@ export function toSkillSpecV2(candidate, opts = {}) {
|
|
|
34
34
|
environmentScope: opts.environmentScope ?? [candidate.environmentId],
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
export function deriveCounterexamples(candidate, holdout, opts = {}) {
|
|
38
|
+
const cap = opts.cap ?? 10;
|
|
39
|
+
const gram = candidate.steps;
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const traj of holdout) {
|
|
43
|
+
if (!traj.metrics.success)
|
|
44
|
+
continue;
|
|
45
|
+
const seq = traj.steps.filter((s) => s.outcome === 'success').map((s) => s.action.type);
|
|
46
|
+
const setSeq = new Set(seq);
|
|
47
|
+
const gramPresent = gram.every((g) => setSeq.has(g));
|
|
48
|
+
if (!gramPresent)
|
|
49
|
+
continue; // coverage-axis miss: different work, no signal for the trigger
|
|
50
|
+
// steps all present but NOT contiguous: the trigger's contiguity assumption fails here
|
|
51
|
+
let contiguous = false;
|
|
52
|
+
outer: for (let i = 0; i + gram.length <= seq.length; i++) {
|
|
53
|
+
for (let j = 0; j < gram.length; j++)
|
|
54
|
+
if (seq[i + j] !== gram[j])
|
|
55
|
+
continue outer;
|
|
56
|
+
contiguous = true;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
if (contiguous)
|
|
60
|
+
continue;
|
|
61
|
+
const shape = seq.join('|');
|
|
62
|
+
if (seen.has(shape))
|
|
63
|
+
continue;
|
|
64
|
+
seen.add(shape);
|
|
65
|
+
out.push({
|
|
66
|
+
description: `steps present but sequence diverges: [${seq.slice(0, 8).join(' → ')}${seq.length > 8 ? ' …' : ''}] - strict contiguity must not be the only trigger`,
|
|
67
|
+
source: `holdout ${traj.id}`,
|
|
68
|
+
});
|
|
69
|
+
if (out.length >= cap)
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
export function toSkillIR(skill, map) {
|
|
75
|
+
const abstractProcedure = [];
|
|
76
|
+
const unmapped = [];
|
|
77
|
+
skill.procedure.forEach((step, i) => {
|
|
78
|
+
const a = map[step.ref];
|
|
79
|
+
if (a)
|
|
80
|
+
abstractProcedure.push(a);
|
|
81
|
+
else {
|
|
82
|
+
abstractProcedure.push(step.ref);
|
|
83
|
+
unmapped.push(i);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
skillId: skill.id,
|
|
88
|
+
abstractProcedure,
|
|
89
|
+
unmapped,
|
|
90
|
+
environmentScope: skill.environmentScope ?? [],
|
|
91
|
+
provenance: skill.provenance ?? '',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
37
94
|
export class SkillCompiler {
|
|
38
95
|
skills = new Map();
|
|
39
96
|
lastVerification = new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cognitive",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.31",
|
|
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.31"
|
|
30
30
|
}
|
|
31
31
|
}
|