@higher.archi/boe 1.0.17 → 1.0.19
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/core/types/rule.d.ts +1 -1
- package/dist/core/types/rule.d.ts.map +1 -1
- package/dist/engines/ensemble/compiler.d.ts +13 -0
- package/dist/engines/ensemble/compiler.d.ts.map +1 -0
- package/dist/engines/ensemble/compiler.js +70 -0
- package/dist/engines/ensemble/compiler.js.map +1 -0
- package/dist/engines/ensemble/engine.d.ts +56 -0
- package/dist/engines/ensemble/engine.d.ts.map +1 -0
- package/dist/engines/ensemble/engine.js +99 -0
- package/dist/engines/ensemble/engine.js.map +1 -0
- package/dist/engines/ensemble/index.d.ts +9 -0
- package/dist/engines/ensemble/index.d.ts.map +1 -0
- package/dist/engines/ensemble/index.js +20 -0
- package/dist/engines/ensemble/index.js.map +1 -0
- package/dist/engines/ensemble/strategy.d.ts +14 -0
- package/dist/engines/ensemble/strategy.d.ts.map +1 -0
- package/dist/engines/ensemble/strategy.js +222 -0
- package/dist/engines/ensemble/strategy.js.map +1 -0
- package/dist/engines/ensemble/summary.d.ts +21 -0
- package/dist/engines/ensemble/summary.d.ts.map +1 -0
- package/dist/engines/ensemble/summary.js +50 -0
- package/dist/engines/ensemble/summary.js.map +1 -0
- package/dist/engines/ensemble/types.d.ts +89 -0
- package/dist/engines/ensemble/types.d.ts.map +1 -0
- package/dist/engines/ensemble/types.js +9 -0
- package/dist/engines/ensemble/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/promotion/index.d.ts +2 -2
- package/dist/promotion/index.d.ts.map +1 -1
- package/dist/promotion/index.js +3 -1
- package/dist/promotion/index.js.map +1 -1
- package/dist/promotion/promotion.d.ts +33 -2
- package/dist/promotion/promotion.d.ts.map +1 -1
- package/dist/promotion/promotion.js +97 -1
- package/dist/promotion/promotion.js.map +1 -1
- package/dist/promotion/types.d.ts +8 -0
- package/dist/promotion/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/types/rule.ts +1 -1
- package/src/engines/ensemble/compiler.ts +97 -0
- package/src/engines/ensemble/engine.ts +130 -0
- package/src/engines/ensemble/index.ts +34 -0
- package/src/engines/ensemble/strategy.ts +263 -0
- package/src/engines/ensemble/summary.ts +58 -0
- package/src/engines/ensemble/types.ts +137 -0
- package/src/index.ts +26 -0
- package/src/promotion/index.ts +2 -2
- package/src/promotion/promotion.ts +115 -2
- package/src/promotion/types.ts +10 -0
|
@@ -21,7 +21,7 @@ export type ValidityDuration = {
|
|
|
21
21
|
months?: number;
|
|
22
22
|
from: string;
|
|
23
23
|
};
|
|
24
|
-
export type RuleSetMode = "forward" | "scoring" | "backward" | "sequential" | "fuzzy" | "bayesian" | "monte-carlo" | "state-machine" | "constraint" | "utility" | "defeasible" | "expert" | "pricing";
|
|
24
|
+
export type RuleSetMode = "forward" | "scoring" | "backward" | "sequential" | "fuzzy" | "bayesian" | "monte-carlo" | "state-machine" | "constraint" | "utility" | "defeasible" | "expert" | "pricing" | "ensemble";
|
|
25
25
|
export type BaseRule = {
|
|
26
26
|
id: string;
|
|
27
27
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../../src/core/types/rule.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAM7C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAMF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CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensemble Engine Compiler
|
|
3
|
+
*
|
|
4
|
+
* Validates and compiles an EnsembleRuleSet into a CompiledEnsembleRuleSet.
|
|
5
|
+
*/
|
|
6
|
+
import type { TierDefinition } from '../scoring/types';
|
|
7
|
+
import type { EnsembleRuleSet, CompiledEnsembleRuleSet } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Compile an ensemble ruleset — validates members, weights, and config,
|
|
10
|
+
* then tags each member with its type for runtime dispatch.
|
|
11
|
+
*/
|
|
12
|
+
export declare function compileEnsembleRuleSet<T extends TierDefinition = TierDefinition>(ruleSet: EnsembleRuleSet<T>): CompiledEnsembleRuleSet<T>;
|
|
13
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/engines/ensemble/compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EAExB,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EAC9E,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,uBAAuB,CAAC,CAAC,CAAC,CA2E5B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ensemble Engine Compiler
|
|
4
|
+
*
|
|
5
|
+
* Validates and compiles an EnsembleRuleSet into a CompiledEnsembleRuleSet.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.compileEnsembleRuleSet = compileEnsembleRuleSet;
|
|
9
|
+
const core_1 = require("../../core");
|
|
10
|
+
/**
|
|
11
|
+
* Compile an ensemble ruleset — validates members, weights, and config,
|
|
12
|
+
* then tags each member with its type for runtime dispatch.
|
|
13
|
+
*/
|
|
14
|
+
function compileEnsembleRuleSet(ruleSet) {
|
|
15
|
+
const { members, config } = ruleSet;
|
|
16
|
+
// Members array must be non-empty
|
|
17
|
+
if (!members || members.length === 0) {
|
|
18
|
+
throw new core_1.CompilationError(`Ensemble "${ruleSet.id}": must have at least one member`);
|
|
19
|
+
}
|
|
20
|
+
// No duplicate member IDs
|
|
21
|
+
const ids = new Set();
|
|
22
|
+
for (const member of members) {
|
|
23
|
+
if (ids.has(member.id)) {
|
|
24
|
+
throw new core_1.CompilationError(`Ensemble "${ruleSet.id}": duplicate member id "${member.id}"`);
|
|
25
|
+
}
|
|
26
|
+
ids.add(member.id);
|
|
27
|
+
}
|
|
28
|
+
// All weights must be > 0
|
|
29
|
+
for (const member of members) {
|
|
30
|
+
if (member.weight <= 0) {
|
|
31
|
+
throw new core_1.CompilationError(`Ensemble "${ruleSet.id}": member "${member.id}" weight must be > 0 (got ${member.weight})`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// For weighted-average and voting: weights must sum to ~1.0
|
|
35
|
+
if (config.strategy === 'weighted-average' || config.strategy === 'voting') {
|
|
36
|
+
const total = members.reduce((sum, m) => sum + m.weight, 0);
|
|
37
|
+
if (Math.abs(total - 1.0) > 0.001) {
|
|
38
|
+
throw new core_1.CompilationError(`Ensemble "${ruleSet.id}": member weights must sum to 1.0 for strategy "${config.strategy}" (got ${total})`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// For stacking: config.stacking must be provided
|
|
42
|
+
if (config.strategy === 'stacking' && !config.stacking) {
|
|
43
|
+
throw new core_1.CompilationError(`Ensemble "${ruleSet.id}": strategy "stacking" requires config.stacking to be provided`);
|
|
44
|
+
}
|
|
45
|
+
// Tier IDs must be unique if tiers are configured
|
|
46
|
+
if (config.tiers && config.tiers.length > 0) {
|
|
47
|
+
const tierIds = new Set();
|
|
48
|
+
for (const tier of config.tiers) {
|
|
49
|
+
if (tierIds.has(tier.id)) {
|
|
50
|
+
throw new core_1.CompilationError(`Ensemble "${ruleSet.id}": duplicate tier id "${tier.id}"`);
|
|
51
|
+
}
|
|
52
|
+
tierIds.add(tier.id);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Tag each member with type
|
|
56
|
+
const compiledMembers = members.map(member => {
|
|
57
|
+
if ('ruleset' in member) {
|
|
58
|
+
return { ...member, type: 'scoring' };
|
|
59
|
+
}
|
|
60
|
+
return { ...member, type: 'custom' };
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
id: ruleSet.id,
|
|
64
|
+
name: ruleSet.name,
|
|
65
|
+
mode: 'ensemble',
|
|
66
|
+
members: compiledMembers,
|
|
67
|
+
config
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/engines/ensemble/compiler.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAeH,wDA6EC;AA1FD,qCAA8C;AAS9C;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,OAA2B;IAE3B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,kCAAkC;IAClC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,uBAAgB,CACxB,aAAa,OAAO,CAAC,EAAE,kCAAkC,CAC1D,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1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aAAa,OAAO,CAAC,EAAE,gEAAgE,CACxF,CAAC;IACJ,CAAC;IAED,kDAAkD;IAClD,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,uBAAgB,CACxB,aAAa,OAAO,CAAC,EAAE,yBAAyB,IAAI,CAAC,EAAE,GAAG,CAC3D,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,4BAA4B;IAC5B,MAAM,eAAe,GAAgC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QACxE,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;YACxB,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,SAAkB,EAAE,CAAC;QACjD,CAAC;QACD,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,QAAiB,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,eAAe;QACxB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensemble Engine
|
|
3
|
+
*
|
|
4
|
+
* Self-contained engine for multi-model score fusion.
|
|
5
|
+
* Orchestrates N member executions and fuses their results
|
|
6
|
+
* using configurable strategies.
|
|
7
|
+
*/
|
|
8
|
+
import { WorkingMemory, Fact, FactInput, FactChange } from '../../core';
|
|
9
|
+
import type { TierDefinition } from '../scoring/types';
|
|
10
|
+
import type { CompiledEnsembleRuleSet, EnsembleOptions, EnsembleResult } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Ensemble rule engine.
|
|
13
|
+
*
|
|
14
|
+
* Executes multiple member scoring rulesets (or custom executors) and fuses
|
|
15
|
+
* their results into a single composite score using configurable strategies.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const engine = new EnsembleEngine();
|
|
20
|
+
* engine.add({ type: 'Vendor', data: { revenue: 500000, compliance: true } });
|
|
21
|
+
*
|
|
22
|
+
* const result = engine.execute(compiledEnsemble);
|
|
23
|
+
* console.log(`Composite score: ${result.totalScore}`);
|
|
24
|
+
* console.log(`Agreement: ${result.agreement}`);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class EnsembleEngine {
|
|
28
|
+
private wm;
|
|
29
|
+
private strategy;
|
|
30
|
+
constructor(workingMemory?: WorkingMemory);
|
|
31
|
+
add<T = Record<string, any>>(input: FactInput<T>): Fact<T>;
|
|
32
|
+
remove(factId: string): Fact | undefined;
|
|
33
|
+
update<T = Record<string, any>>(input: FactInput<T>): Fact<T>;
|
|
34
|
+
get(factId: string): Fact | undefined;
|
|
35
|
+
getByType(type: string): Fact[];
|
|
36
|
+
getAll(): Fact[];
|
|
37
|
+
has(factId: string): boolean;
|
|
38
|
+
size(): number;
|
|
39
|
+
clear(): void;
|
|
40
|
+
getChanges(): FactChange[];
|
|
41
|
+
clearChanges(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Execute an ensemble ruleset.
|
|
44
|
+
*
|
|
45
|
+
* Collects all facts from working memory, executes each member engine
|
|
46
|
+
* with its own independent working memory, and fuses results using
|
|
47
|
+
* the configured strategy.
|
|
48
|
+
*
|
|
49
|
+
* @param ruleSet - Compiled ensemble ruleset
|
|
50
|
+
* @param options - Runtime options (reserved for future use)
|
|
51
|
+
* @returns Ensemble result with fused score and per-member breakdown
|
|
52
|
+
*/
|
|
53
|
+
execute<T extends TierDefinition = TierDefinition>(ruleSet: CompiledEnsembleRuleSet<T>, options?: EnsembleOptions): EnsembleResult<T>;
|
|
54
|
+
getWorkingMemory(): WorkingMemory;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/engines/ensemble/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,IAAI,EACJ,SAAS,EACT,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,cAAc,EACf,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO,CAAC,QAAQ,CAAmB;gBAEvB,aAAa,CAAC,EAAE,aAAa;IASzC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAI1D,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIxC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAI7D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIrC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE;IAI/B,MAAM,IAAI,IAAI,EAAE;IAIhB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI5B,IAAI,IAAI,MAAM;IAId,KAAK,IAAI,IAAI;IAIb,UAAU,IAAI,UAAU,EAAE;IAI1B,YAAY,IAAI,IAAI;IAQpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EAC/C,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,EACnC,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,CAAC,CAAC;IAUpB,gBAAgB,IAAI,aAAa;CAGlC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ensemble Engine
|
|
4
|
+
*
|
|
5
|
+
* Self-contained engine for multi-model score fusion.
|
|
6
|
+
* Orchestrates N member executions and fuses their results
|
|
7
|
+
* using configurable strategies.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EnsembleEngine = void 0;
|
|
11
|
+
const core_1 = require("../../core");
|
|
12
|
+
const strategy_1 = require("./strategy");
|
|
13
|
+
/**
|
|
14
|
+
* Ensemble rule engine.
|
|
15
|
+
*
|
|
16
|
+
* Executes multiple member scoring rulesets (or custom executors) and fuses
|
|
17
|
+
* their results into a single composite score using configurable strategies.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const engine = new EnsembleEngine();
|
|
22
|
+
* engine.add({ type: 'Vendor', data: { revenue: 500000, compliance: true } });
|
|
23
|
+
*
|
|
24
|
+
* const result = engine.execute(compiledEnsemble);
|
|
25
|
+
* console.log(`Composite score: ${result.totalScore}`);
|
|
26
|
+
* console.log(`Agreement: ${result.agreement}`);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class EnsembleEngine {
|
|
30
|
+
wm;
|
|
31
|
+
strategy;
|
|
32
|
+
constructor(workingMemory) {
|
|
33
|
+
this.wm = workingMemory ?? new core_1.WorkingMemory();
|
|
34
|
+
this.strategy = new strategy_1.EnsembleStrategy();
|
|
35
|
+
}
|
|
36
|
+
// ========================================
|
|
37
|
+
// IWorkingMemory Implementation
|
|
38
|
+
// ========================================
|
|
39
|
+
add(input) {
|
|
40
|
+
return this.wm.add(input);
|
|
41
|
+
}
|
|
42
|
+
remove(factId) {
|
|
43
|
+
return this.wm.remove(factId);
|
|
44
|
+
}
|
|
45
|
+
update(input) {
|
|
46
|
+
return this.wm.update(input);
|
|
47
|
+
}
|
|
48
|
+
get(factId) {
|
|
49
|
+
return this.wm.get(factId);
|
|
50
|
+
}
|
|
51
|
+
getByType(type) {
|
|
52
|
+
return this.wm.getByType(type);
|
|
53
|
+
}
|
|
54
|
+
getAll() {
|
|
55
|
+
return this.wm.getAll();
|
|
56
|
+
}
|
|
57
|
+
has(factId) {
|
|
58
|
+
return this.wm.has(factId);
|
|
59
|
+
}
|
|
60
|
+
size() {
|
|
61
|
+
return this.wm.size();
|
|
62
|
+
}
|
|
63
|
+
clear() {
|
|
64
|
+
this.wm.clear();
|
|
65
|
+
}
|
|
66
|
+
getChanges() {
|
|
67
|
+
return this.wm.getChanges();
|
|
68
|
+
}
|
|
69
|
+
clearChanges() {
|
|
70
|
+
this.wm.clearChanges();
|
|
71
|
+
}
|
|
72
|
+
// ========================================
|
|
73
|
+
// Engine Execution
|
|
74
|
+
// ========================================
|
|
75
|
+
/**
|
|
76
|
+
* Execute an ensemble ruleset.
|
|
77
|
+
*
|
|
78
|
+
* Collects all facts from working memory, executes each member engine
|
|
79
|
+
* with its own independent working memory, and fuses results using
|
|
80
|
+
* the configured strategy.
|
|
81
|
+
*
|
|
82
|
+
* @param ruleSet - Compiled ensemble ruleset
|
|
83
|
+
* @param options - Runtime options (reserved for future use)
|
|
84
|
+
* @returns Ensemble result with fused score and per-member breakdown
|
|
85
|
+
*/
|
|
86
|
+
execute(ruleSet, options = {}) {
|
|
87
|
+
// Collect all facts from WM as FactInput[] so each sub-engine gets its own fresh WM
|
|
88
|
+
const facts = this.wm.getAll().map(f => ({ type: f.type, data: f.data, id: f.id }));
|
|
89
|
+
return this.strategy.run(ruleSet, facts, options);
|
|
90
|
+
}
|
|
91
|
+
// ========================================
|
|
92
|
+
// Utility Methods
|
|
93
|
+
// ========================================
|
|
94
|
+
getWorkingMemory() {
|
|
95
|
+
return this.wm;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.EnsembleEngine = EnsembleEngine;
|
|
99
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../src/engines/ensemble/engine.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,qCAKoB;AAUpB,yCAA8C;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,MAAa,cAAc;IACjB,EAAE,CAAgB;IAClB,QAAQ,CAAmB;IAEnC,YAAY,aAA6B;QACvC,IAAI,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,oBAAa,EAAE,CAAC;QAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAgB,EAAE,CAAC;IACzC,CAAC;IAED,2CAA2C;IAC3C,gCAAgC;IAChC,2CAA2C;IAE3C,GAAG,CAA0B,KAAmB;QAC9C,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,MAAc;QACnB,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAA0B,KAAmB;QACjD,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,EAAE,CAAC,SAAS,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oreExtractor, ConfidenceExtractor, ScoringMemberDef, CustomMemberDef, EnsembleMemberDef, StackingConfig, EnsembleConfig, EnsembleRuleSet, CompiledEnsembleMember, CompiledEnsembleRuleSet, EnsembleOptions, MemberResult, EnsembleResult, EnsembleSummaryOptions } from './types';
|
|
5
|
+
export { compileEnsembleRuleSet } from './compiler';
|
|
6
|
+
export { EnsembleStrategy, ensembleStrategy } from './strategy';
|
|
7
|
+
export { EnsembleEngine } from './engine';
|
|
8
|
+
export { summarizeEnsemble } from './summary';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engines/ensemble/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGhE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ensemble Engine — Multi-Model Score Fusion
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.summarizeEnsemble = exports.EnsembleEngine = exports.ensembleStrategy = exports.EnsembleStrategy = exports.compileEnsembleRuleSet = void 0;
|
|
7
|
+
// Compiler
|
|
8
|
+
var compiler_1 = require("./compiler");
|
|
9
|
+
Object.defineProperty(exports, "compileEnsembleRuleSet", { enumerable: true, get: function () { return compiler_1.compileEnsembleRuleSet; } });
|
|
10
|
+
// Strategy
|
|
11
|
+
var strategy_1 = require("./strategy");
|
|
12
|
+
Object.defineProperty(exports, "EnsembleStrategy", { enumerable: true, get: function () { return strategy_1.EnsembleStrategy; } });
|
|
13
|
+
Object.defineProperty(exports, "ensembleStrategy", { enumerable: true, get: function () { return strategy_1.ensembleStrategy; } });
|
|
14
|
+
// Engine
|
|
15
|
+
var engine_1 = require("./engine");
|
|
16
|
+
Object.defineProperty(exports, "EnsembleEngine", { enumerable: true, get: function () { return engine_1.EnsembleEngine; } });
|
|
17
|
+
// Summary
|
|
18
|
+
var summary_1 = require("./summary");
|
|
19
|
+
Object.defineProperty(exports, "summarizeEnsemble", { enumerable: true, get: function () { return summary_1.summarizeEnsemble; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engines/ensemble/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAqBH,WAAW;AACX,uCAAoD;AAA3C,kHAAA,sBAAsB,OAAA;AAE/B,WAAW;AACX,uCAAgE;AAAvD,4GAAA,gBAAgB,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAE3C,SAAS;AACT,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AAEvB,UAAU;AACV,qCAA8C;AAArC,4GAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensemble Engine Strategy
|
|
3
|
+
*
|
|
4
|
+
* Executes N member engines and fuses their results using configurable
|
|
5
|
+
* fusion strategies (weighted-average, median, min, max, voting, stacking).
|
|
6
|
+
*/
|
|
7
|
+
import type { TierDefinition } from '../scoring/types';
|
|
8
|
+
import type { FactInput } from '../../core';
|
|
9
|
+
import type { CompiledEnsembleRuleSet, EnsembleOptions, EnsembleResult } from './types';
|
|
10
|
+
export declare class EnsembleStrategy {
|
|
11
|
+
run<T extends TierDefinition = TierDefinition>(ruleSet: CompiledEnsembleRuleSet<T>, facts: FactInput[], _options: EnsembleOptions): EnsembleResult<T>;
|
|
12
|
+
}
|
|
13
|
+
export declare const ensembleStrategy: EnsembleStrategy;
|
|
14
|
+
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/engines/ensemble/strategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAoB,cAAc,EAAgB,MAAM,kBAAkB,CAAC;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,cAAc,EAEf,MAAM,SAAS,CAAC;AAqBjB,qBAAa,gBAAgB;IAC3B,GAAG,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EAC3C,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,EACnC,KAAK,EAAE,SAAS,EAAE,EAClB,QAAQ,EAAE,eAAe,GACxB,cAAc,CAAC,CAAC,CAAC;CA2LrB;AAiCD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ensemble Engine Strategy
|
|
4
|
+
*
|
|
5
|
+
* Executes N member engines and fuses their results using configurable
|
|
6
|
+
* fusion strategies (weighted-average, median, min, max, voting, stacking).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ensembleStrategy = exports.EnsembleStrategy = void 0;
|
|
10
|
+
const engine_1 = require("../scoring/engine");
|
|
11
|
+
// ========================================
|
|
12
|
+
// Output Bounds (reused from scoring)
|
|
13
|
+
// ========================================
|
|
14
|
+
function resolveOutputBounds(bounds) {
|
|
15
|
+
if (typeof bounds === 'object')
|
|
16
|
+
return bounds;
|
|
17
|
+
switch (bounds) {
|
|
18
|
+
case 'percentage': return { min: 0, max: 100 };
|
|
19
|
+
case 'points': return { min: 0, max: 1000 };
|
|
20
|
+
case 'rating': return { min: 0, max: 10 };
|
|
21
|
+
case 'stars': return { min: 0, max: 5 };
|
|
22
|
+
case 'normalized': return { min: 0, max: 1 };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// ========================================
|
|
26
|
+
// Strategy
|
|
27
|
+
// ========================================
|
|
28
|
+
class EnsembleStrategy {
|
|
29
|
+
run(ruleSet, facts, _options) {
|
|
30
|
+
const startTime = performance.now();
|
|
31
|
+
const { members, config } = ruleSet;
|
|
32
|
+
// 1. Execute all members
|
|
33
|
+
const memberResults = [];
|
|
34
|
+
const allFired = [];
|
|
35
|
+
for (const member of members) {
|
|
36
|
+
const memberStart = performance.now();
|
|
37
|
+
let score;
|
|
38
|
+
let confidence;
|
|
39
|
+
if (member.type === 'scoring') {
|
|
40
|
+
const engine = new engine_1.ScoringEngine();
|
|
41
|
+
for (const fact of facts) {
|
|
42
|
+
engine.add(fact);
|
|
43
|
+
}
|
|
44
|
+
const result = engine.execute(member.ruleset, member.options);
|
|
45
|
+
score = result.totalScore;
|
|
46
|
+
confidence = result.confidence;
|
|
47
|
+
// Collect fired rules
|
|
48
|
+
for (const ruleId of result.fired) {
|
|
49
|
+
if (!allFired.includes(ruleId)) {
|
|
50
|
+
allFired.push(ruleId);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const result = member.execute(facts);
|
|
56
|
+
score = member.extractScore(result);
|
|
57
|
+
confidence = member.extractConfidence ? member.extractConfidence(result) : 1.0;
|
|
58
|
+
}
|
|
59
|
+
const memberTime = Math.round((performance.now() - memberStart) * 100) / 100;
|
|
60
|
+
memberResults.push({
|
|
61
|
+
memberId: member.id,
|
|
62
|
+
memberName: member.name,
|
|
63
|
+
score,
|
|
64
|
+
confidence,
|
|
65
|
+
weight: member.weight,
|
|
66
|
+
weightedScore: score * member.weight,
|
|
67
|
+
executionTimeMs: memberTime
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// 2. Fuse by strategy
|
|
71
|
+
let fusedScore;
|
|
72
|
+
let fusedConfidence;
|
|
73
|
+
switch (config.strategy) {
|
|
74
|
+
case 'weighted-average': {
|
|
75
|
+
fusedScore = memberResults.reduce((sum, m) => sum + m.score * m.weight, 0);
|
|
76
|
+
fusedConfidence = memberResults.reduce((sum, m) => sum + m.confidence * m.weight, 0);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case 'median': {
|
|
80
|
+
const sortedScores = [...memberResults].sort((a, b) => a.score - b.score);
|
|
81
|
+
const sortedConfidences = [...memberResults].sort((a, b) => a.confidence - b.confidence);
|
|
82
|
+
const mid = Math.floor(sortedScores.length / 2);
|
|
83
|
+
if (sortedScores.length % 2 === 0) {
|
|
84
|
+
fusedScore = (sortedScores[mid - 1].score + sortedScores[mid].score) / 2;
|
|
85
|
+
fusedConfidence = (sortedConfidences[mid - 1].confidence + sortedConfidences[mid].confidence) / 2;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
fusedScore = sortedScores[mid].score;
|
|
89
|
+
fusedConfidence = sortedConfidences[mid].confidence;
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 'min': {
|
|
94
|
+
let minIdx = 0;
|
|
95
|
+
for (let i = 1; i < memberResults.length; i++) {
|
|
96
|
+
if (memberResults[i].score < memberResults[minIdx].score) {
|
|
97
|
+
minIdx = i;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
fusedScore = memberResults[minIdx].score;
|
|
101
|
+
fusedConfidence = memberResults[minIdx].confidence;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case 'max': {
|
|
105
|
+
let maxIdx = 0;
|
|
106
|
+
for (let i = 1; i < memberResults.length; i++) {
|
|
107
|
+
if (memberResults[i].score > memberResults[maxIdx].score) {
|
|
108
|
+
maxIdx = i;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
fusedScore = memberResults[maxIdx].score;
|
|
112
|
+
fusedConfidence = memberResults[maxIdx].confidence;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case 'voting': {
|
|
116
|
+
let winnerIdx = 0;
|
|
117
|
+
let maxProduct = memberResults[0].confidence * memberResults[0].weight;
|
|
118
|
+
for (let i = 1; i < memberResults.length; i++) {
|
|
119
|
+
const product = memberResults[i].confidence * memberResults[i].weight;
|
|
120
|
+
if (product > maxProduct) {
|
|
121
|
+
maxProduct = product;
|
|
122
|
+
winnerIdx = i;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
fusedScore = memberResults[winnerIdx].score;
|
|
126
|
+
fusedConfidence = memberResults[winnerIdx].confidence;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case 'stacking': {
|
|
130
|
+
const stackingConfig = config.stacking;
|
|
131
|
+
const stackEngine = new engine_1.ScoringEngine();
|
|
132
|
+
// Add member scores as facts
|
|
133
|
+
for (const mr of memberResults) {
|
|
134
|
+
stackEngine.add({
|
|
135
|
+
type: 'EnsembleMemberScore',
|
|
136
|
+
data: {
|
|
137
|
+
memberId: mr.memberId,
|
|
138
|
+
score: mr.score,
|
|
139
|
+
confidence: mr.confidence
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const stackResult = stackEngine.execute(stackingConfig.ruleset, stackingConfig.options);
|
|
144
|
+
fusedScore = stackResult.totalScore;
|
|
145
|
+
fusedConfidence = stackResult.confidence;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// 3. Compute agreement: 1 - (stddev / (range / 2)), clamped to [0, 1]
|
|
150
|
+
const scores = memberResults.map(m => m.score);
|
|
151
|
+
const agreement = computeAgreement(scores, config.outputBounds);
|
|
152
|
+
// 4. Apply output bounds
|
|
153
|
+
if (config.outputBounds) {
|
|
154
|
+
const bounds = resolveOutputBounds(config.outputBounds);
|
|
155
|
+
fusedScore = Math.max(bounds.min, Math.min(bounds.max, fusedScore));
|
|
156
|
+
}
|
|
157
|
+
// 5. Match tier
|
|
158
|
+
let tier;
|
|
159
|
+
if (config.tiers && config.tiers.length > 0) {
|
|
160
|
+
const resolveThreshold = (t) => t === '-Infinity' ? Number.NEGATIVE_INFINITY : t;
|
|
161
|
+
const sortedTiers = [...config.tiers].sort((a, b) => resolveThreshold(b.threshold) - resolveThreshold(a.threshold));
|
|
162
|
+
for (const tierDef of sortedTiers) {
|
|
163
|
+
const threshold = resolveThreshold(tierDef.threshold);
|
|
164
|
+
if (fusedScore >= threshold) {
|
|
165
|
+
tier = {
|
|
166
|
+
...tierDef,
|
|
167
|
+
threshold
|
|
168
|
+
};
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// 6. Build contributions map
|
|
174
|
+
const contributions = {};
|
|
175
|
+
for (const mr of memberResults) {
|
|
176
|
+
contributions[mr.memberId] = mr.score;
|
|
177
|
+
}
|
|
178
|
+
const executionTimeMs = Math.round((performance.now() - startTime) * 100) / 100;
|
|
179
|
+
return {
|
|
180
|
+
totalScore: fusedScore,
|
|
181
|
+
confidence: fusedConfidence,
|
|
182
|
+
tier,
|
|
183
|
+
strategy: config.strategy,
|
|
184
|
+
memberResults,
|
|
185
|
+
agreement,
|
|
186
|
+
fired: allFired,
|
|
187
|
+
contributions,
|
|
188
|
+
executionTimeMs
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.EnsembleStrategy = EnsembleStrategy;
|
|
193
|
+
// ========================================
|
|
194
|
+
// Agreement Calculation
|
|
195
|
+
// ========================================
|
|
196
|
+
function computeAgreement(scores, outputBounds) {
|
|
197
|
+
if (scores.length <= 1)
|
|
198
|
+
return 1;
|
|
199
|
+
// Compute stddev
|
|
200
|
+
const mean = scores.reduce((sum, s) => sum + s, 0) / scores.length;
|
|
201
|
+
const variance = scores.reduce((sum, s) => sum + (s - mean) ** 2, 0) / scores.length;
|
|
202
|
+
const stddev = Math.sqrt(variance);
|
|
203
|
+
// Determine range
|
|
204
|
+
let range;
|
|
205
|
+
if (outputBounds) {
|
|
206
|
+
const bounds = resolveOutputBounds(outputBounds);
|
|
207
|
+
range = bounds.max - bounds.min;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const minScore = Math.min(...scores);
|
|
211
|
+
const maxScore = Math.max(...scores);
|
|
212
|
+
range = maxScore - minScore;
|
|
213
|
+
}
|
|
214
|
+
// Avoid division by zero — all scores identical
|
|
215
|
+
if (range === 0)
|
|
216
|
+
return 1;
|
|
217
|
+
const halfRange = range / 2;
|
|
218
|
+
return Math.max(0, Math.min(1, 1 - (stddev / halfRange)));
|
|
219
|
+
}
|
|
220
|
+
// Export a singleton instance for convenience
|
|
221
|
+
exports.ensembleStrategy = new EnsembleStrategy();
|
|
222
|
+
//# sourceMappingURL=strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../src/engines/ensemble/strategy.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,8CAAkD;AAWlD,2CAA2C;AAC3C,sCAAsC;AACtC,2CAA2C;AAE3C,SAAS,mBAAmB,CAAC,MAAoB;IAC/C,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC9C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,YAAY,CAAC,CAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QAChD,KAAK,QAAQ,CAAC,CAAM,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QACjD,KAAK,QAAQ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KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,gDAAgD;IAChD,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE1B,MAAM,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,8CAA8C;AACjC,QAAA,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensemble Summary
|
|
3
|
+
*
|
|
4
|
+
* Generates human-readable summary strings from ensemble results.
|
|
5
|
+
*/
|
|
6
|
+
import type { EnsembleResult, EnsembleSummaryOptions } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Generate a human-readable summary string from an EnsembleResult.
|
|
9
|
+
*
|
|
10
|
+
* @param result - The ensemble result to summarize
|
|
11
|
+
* @param options - Optional display settings
|
|
12
|
+
* @returns Formatted multi-line summary string
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const result = engine.execute(compiledEnsemble);
|
|
17
|
+
* console.log(summarizeEnsemble(result));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function summarizeEnsemble(result: EnsembleResult, options?: EnsembleSummaryOptions): string;
|
|
21
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/engines/ensemble/summary.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAiCR"}
|