@higher.archi/boe 1.0.23 → 1.0.25
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/prediction/compiler.d.ts +11 -0
- package/dist/engines/prediction/compiler.d.ts.map +1 -0
- package/dist/engines/prediction/compiler.js +153 -0
- package/dist/engines/prediction/compiler.js.map +1 -0
- package/dist/engines/prediction/engine.d.ts +49 -0
- package/dist/engines/prediction/engine.d.ts.map +1 -0
- package/dist/engines/prediction/engine.js +91 -0
- package/dist/engines/prediction/engine.js.map +1 -0
- package/dist/engines/prediction/index.d.ts +9 -0
- package/dist/engines/prediction/index.d.ts.map +1 -0
- package/dist/engines/prediction/index.js +25 -0
- package/dist/engines/prediction/index.js.map +1 -0
- package/dist/engines/prediction/strategy.d.ts +20 -0
- package/dist/engines/prediction/strategy.d.ts.map +1 -0
- package/dist/engines/prediction/strategy.js +441 -0
- package/dist/engines/prediction/strategy.js.map +1 -0
- package/dist/engines/prediction/types.d.ts +150 -0
- package/dist/engines/prediction/types.d.ts.map +1 -0
- package/dist/engines/prediction/types.js +59 -0
- package/dist/engines/prediction/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/types/rule.ts +1 -1
- package/src/engines/prediction/compiler.ts +186 -0
- package/src/engines/prediction/engine.ts +120 -0
- package/src/engines/prediction/index.ts +49 -0
- package/src/engines/prediction/strategy.ts +573 -0
- package/src/engines/prediction/types.ts +236 -0
- package/src/index.ts +39 -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" | "ensemble" | "ranking";
|
|
24
|
+
export type RuleSetMode = "forward" | "scoring" | "backward" | "sequential" | "fuzzy" | "bayesian" | "monte-carlo" | "state-machine" | "constraint" | "utility" | "defeasible" | "expert" | "pricing" | "ensemble" | "ranking" | "prediction";
|
|
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;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAMF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,eAAe,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../../src/core/types/rule.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,iBAA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CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAMF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAMF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,sBAAsB,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,iBAAiB,CAAC;IAGzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prediction Engine Compiler
|
|
3
|
+
*
|
|
4
|
+
* Validates prediction rulesets and resolves defaults.
|
|
5
|
+
*/
|
|
6
|
+
import type { PredictionRuleSet, CompiledPredictionRuleSet } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Compile and validate a prediction ruleset.
|
|
9
|
+
*/
|
|
10
|
+
export declare function compilePredictionRuleSet(ruleSet: PredictionRuleSet): CompiledPredictionRuleSet;
|
|
11
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/engines/prediction/compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,iBAAiB,EACjB,yBAAyB,EAI1B,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,iBAAiB,GACzB,yBAAyB,CA0E3B"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prediction Engine Compiler
|
|
4
|
+
*
|
|
5
|
+
* Validates prediction rulesets and resolves defaults.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.compilePredictionRuleSet = compilePredictionRuleSet;
|
|
9
|
+
const errors_1 = require("../../core/errors");
|
|
10
|
+
const types_1 = require("./types");
|
|
11
|
+
/**
|
|
12
|
+
* Compile and validate a prediction ruleset.
|
|
13
|
+
*/
|
|
14
|
+
function compilePredictionRuleSet(ruleSet) {
|
|
15
|
+
// ---- Common validation ----
|
|
16
|
+
if (!ruleSet.id) {
|
|
17
|
+
throw new errors_1.CompilationError('Prediction ruleset requires an id');
|
|
18
|
+
}
|
|
19
|
+
if (ruleSet.mode !== 'prediction') {
|
|
20
|
+
throw new errors_1.CompilationError(`Expected mode 'prediction', got '${ruleSet.mode}'`);
|
|
21
|
+
}
|
|
22
|
+
if (!ruleSet.snapshotType || ruleSet.snapshotType.trim() === '') {
|
|
23
|
+
throw new errors_1.CompilationError('snapshotType is required and must be non-empty');
|
|
24
|
+
}
|
|
25
|
+
// Fields validation
|
|
26
|
+
if (!ruleSet.fields) {
|
|
27
|
+
throw new errors_1.CompilationError('fields mapping is required');
|
|
28
|
+
}
|
|
29
|
+
if (!ruleSet.fields.entityId || typeof ruleSet.fields.entityId !== 'string' || ruleSet.fields.entityId.trim() === '') {
|
|
30
|
+
throw new errors_1.CompilationError('fields.entityId is required and must be a non-empty string');
|
|
31
|
+
}
|
|
32
|
+
if (!ruleSet.fields.score || typeof ruleSet.fields.score !== 'string' || ruleSet.fields.score.trim() === '') {
|
|
33
|
+
throw new errors_1.CompilationError('fields.score is required and must be a non-empty string');
|
|
34
|
+
}
|
|
35
|
+
if (!ruleSet.fields.timestamp || typeof ruleSet.fields.timestamp !== 'string' || ruleSet.fields.timestamp.trim() === '') {
|
|
36
|
+
throw new errors_1.CompilationError('fields.timestamp is required and must be a non-empty string');
|
|
37
|
+
}
|
|
38
|
+
// Horizon
|
|
39
|
+
let horizonMs;
|
|
40
|
+
if ((0, types_1.isHorizonPreset)(ruleSet.horizon)) {
|
|
41
|
+
horizonMs = types_1.HORIZON_PRESET_VALUES[ruleSet.horizon];
|
|
42
|
+
}
|
|
43
|
+
else if (typeof ruleSet.horizon === 'number') {
|
|
44
|
+
if (ruleSet.horizon <= 0) {
|
|
45
|
+
throw new errors_1.CompilationError('horizon must be a positive number (milliseconds)');
|
|
46
|
+
}
|
|
47
|
+
horizonMs = ruleSet.horizon;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw new errors_1.CompilationError(`Invalid horizon: '${ruleSet.horizon}'`);
|
|
51
|
+
}
|
|
52
|
+
// Thresholds
|
|
53
|
+
const thresholds = ruleSet.thresholds ?? [];
|
|
54
|
+
if (thresholds.length > 0) {
|
|
55
|
+
const thresholdIds = new Set();
|
|
56
|
+
for (const t of thresholds) {
|
|
57
|
+
if (!t.id) {
|
|
58
|
+
throw new errors_1.CompilationError('Each threshold requires an id');
|
|
59
|
+
}
|
|
60
|
+
if (thresholdIds.has(t.id)) {
|
|
61
|
+
throw new errors_1.CompilationError(`Duplicate threshold id: '${t.id}'`);
|
|
62
|
+
}
|
|
63
|
+
thresholdIds.add(t.id);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// defaultTrend
|
|
67
|
+
if (ruleSet.defaultTrend !== undefined && typeof ruleSet.defaultTrend !== 'number') {
|
|
68
|
+
throw new errors_1.CompilationError('defaultTrend must be a number (score units per month)');
|
|
69
|
+
}
|
|
70
|
+
// ---- Strategy-specific ----
|
|
71
|
+
switch (ruleSet.strategy) {
|
|
72
|
+
case 'linear-regression':
|
|
73
|
+
return compileLinearRegression(ruleSet, horizonMs, thresholds);
|
|
74
|
+
case 'exponential-smoothing':
|
|
75
|
+
return compileExponentialSmoothing(ruleSet, horizonMs, thresholds);
|
|
76
|
+
case 'weighted-moving-average':
|
|
77
|
+
return compileWeightedMovingAverage(ruleSet, horizonMs, thresholds);
|
|
78
|
+
default:
|
|
79
|
+
throw new errors_1.CompilationError(`Unknown prediction strategy: '${ruleSet.strategy}'`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function compileLinearRegression(ruleSet, horizonMs, thresholds) {
|
|
83
|
+
const stableThreshold = ruleSet.config?.stableThreshold ?? 0.001;
|
|
84
|
+
if (stableThreshold < 0) {
|
|
85
|
+
throw new errors_1.CompilationError('stableThreshold must be non-negative');
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
id: ruleSet.id,
|
|
89
|
+
name: ruleSet.name,
|
|
90
|
+
mode: 'prediction',
|
|
91
|
+
strategy: 'linear-regression',
|
|
92
|
+
snapshotType: ruleSet.snapshotType,
|
|
93
|
+
fields: ruleSet.fields,
|
|
94
|
+
horizonMs,
|
|
95
|
+
thresholds: thresholds,
|
|
96
|
+
defaultTrend: ruleSet.defaultTrend,
|
|
97
|
+
config: { stableThreshold }
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function compileExponentialSmoothing(ruleSet, horizonMs, thresholds) {
|
|
101
|
+
let alpha;
|
|
102
|
+
let beta;
|
|
103
|
+
const smoothing = ruleSet.config?.smoothing ?? 'balanced';
|
|
104
|
+
if ((0, types_1.isSmoothingPreset)(smoothing)) {
|
|
105
|
+
const preset = types_1.SMOOTHING_PRESET_VALUES[smoothing];
|
|
106
|
+
alpha = preset.alpha;
|
|
107
|
+
beta = preset.beta;
|
|
108
|
+
}
|
|
109
|
+
else if (typeof smoothing === 'object' && smoothing !== null) {
|
|
110
|
+
alpha = smoothing.alpha;
|
|
111
|
+
beta = smoothing.beta;
|
|
112
|
+
if (typeof alpha !== 'number' || alpha <= 0 || alpha > 1) {
|
|
113
|
+
throw new errors_1.CompilationError('smoothing.alpha must be a number in (0, 1]');
|
|
114
|
+
}
|
|
115
|
+
if (typeof beta !== 'number' || beta <= 0 || beta > 1) {
|
|
116
|
+
throw new errors_1.CompilationError('smoothing.beta must be a number in (0, 1]');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new errors_1.CompilationError(`Invalid smoothing value: '${smoothing}'`);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
id: ruleSet.id,
|
|
124
|
+
name: ruleSet.name,
|
|
125
|
+
mode: 'prediction',
|
|
126
|
+
strategy: 'exponential-smoothing',
|
|
127
|
+
snapshotType: ruleSet.snapshotType,
|
|
128
|
+
fields: ruleSet.fields,
|
|
129
|
+
horizonMs,
|
|
130
|
+
thresholds: thresholds,
|
|
131
|
+
defaultTrend: ruleSet.defaultTrend,
|
|
132
|
+
config: { alpha, beta }
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function compileWeightedMovingAverage(ruleSet, horizonMs, thresholds) {
|
|
136
|
+
const window = ruleSet.config?.window ?? 5;
|
|
137
|
+
if (!Number.isInteger(window) || window < 2) {
|
|
138
|
+
throw new errors_1.CompilationError('window must be a positive integer >= 2');
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
id: ruleSet.id,
|
|
142
|
+
name: ruleSet.name,
|
|
143
|
+
mode: 'prediction',
|
|
144
|
+
strategy: 'weighted-moving-average',
|
|
145
|
+
snapshotType: ruleSet.snapshotType,
|
|
146
|
+
fields: ruleSet.fields,
|
|
147
|
+
horizonMs,
|
|
148
|
+
thresholds: thresholds,
|
|
149
|
+
defaultTrend: ruleSet.defaultTrend,
|
|
150
|
+
config: { window }
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/engines/prediction/compiler.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAgBH,4DA4EC;AA1FD,8CAAqD;AASrD,mCAA6G;AAE7G;;GAEG;AACH,SAAgB,wBAAwB,CACtC,OAA0B;IAE1B,8BAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,yBAAgB,CAAC,mCAAmC,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAClC,MAAM,IAAI,yBAAgB,CAAC,oCAAoC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAClF,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAChE,MAAM,IAAI,yBAAgB,CAAC,gDAAgD,CAAC,CAAC;IAC/E,CAAC;IAED,oBAAoB;IACpB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,yBAAgB,CAAC,4BAA4B,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrH,MAAM,IAAI,yBAAgB,CAAC,4DAA4D,CAAC,CAA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N,MAAM,IAAI,yBAAgB,CAAC,6BAA6B,SAAS,GAAG,CAAC,CAAC;IACxE,CAAC;IAED,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,uBAAuB;QACjC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS;QACT,UAAU,EAAE,UAAiB;QAC7B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;KACxB,CAAC;AACJ,CAAC;AAED,SAAS,4BAA4B,CACnC,OAAoE,EACpE,SAAiB,EACjB,UAAgD;IAEhD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,yBAAgB,CAAC,wCAAwC,CAAC,CAAC;IACvE,CAAC;IAED,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,yBAAyB;QACnC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS;QACT,UAAU,EAAE,UAAiB;QAC7B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,MAAM,EAAE,EAAE,MAAM,EAAE;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prediction Engine
|
|
3
|
+
*
|
|
4
|
+
* Trajectory forecasting engine that takes historical score snapshots,
|
|
5
|
+
* fits a model, and projects forward. Supports linear regression,
|
|
6
|
+
* exponential smoothing, and weighted moving average strategies.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const engine = new PredictionEngine();
|
|
11
|
+
* engine.add({ type: 'VendorScore', data: { vendorId: 'acme', totalScore: 520, evaluatedAt: '2025-09-01' } });
|
|
12
|
+
* engine.add({ type: 'VendorScore', data: { vendorId: 'acme', totalScore: 580, evaluatedAt: '2025-12-01' } });
|
|
13
|
+
* engine.add({ type: 'VendorScore', data: { vendorId: 'acme', totalScore: 640, evaluatedAt: '2026-03-01' } });
|
|
14
|
+
*
|
|
15
|
+
* const result = engine.execute(compiledRuleset);
|
|
16
|
+
* console.log(result.predictions[0]); // { entityId: 'acme', trend: 'rising', trendSlope: 20, ... }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { WorkingMemory, Fact, FactInput, FactChange } from '../../core';
|
|
20
|
+
import type { CompiledPredictionRuleSet, PredictionOptions, PredictionResult } from './types';
|
|
21
|
+
export declare class PredictionEngine {
|
|
22
|
+
private wm;
|
|
23
|
+
private strategy;
|
|
24
|
+
constructor(workingMemory?: WorkingMemory);
|
|
25
|
+
add<T = Record<string, any>>(input: FactInput<T>): Fact<T>;
|
|
26
|
+
remove(factId: string): Fact | undefined;
|
|
27
|
+
update<T = Record<string, any>>(input: FactInput<T>): Fact<T>;
|
|
28
|
+
get(factId: string): Fact | undefined;
|
|
29
|
+
getByType(type: string): Fact[];
|
|
30
|
+
getAll(): Fact[];
|
|
31
|
+
has(factId: string): boolean;
|
|
32
|
+
size(): number;
|
|
33
|
+
clear(): void;
|
|
34
|
+
getChanges(): FactChange[];
|
|
35
|
+
clearChanges(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Execute a prediction ruleset.
|
|
38
|
+
*
|
|
39
|
+
* Groups all snapshots of the configured type by entity,
|
|
40
|
+
* fits a trajectory model, and projects forward to the horizon.
|
|
41
|
+
*
|
|
42
|
+
* @param ruleSet - Compiled prediction ruleset
|
|
43
|
+
* @param options - Runtime options (onPredict callback, asOf for testing)
|
|
44
|
+
* @returns Prediction result with forecasts per entity
|
|
45
|
+
*/
|
|
46
|
+
execute(ruleSet: CompiledPredictionRuleSet, options?: PredictionOptions): PredictionResult;
|
|
47
|
+
getWorkingMemory(): WorkingMemory;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/engines/prediction/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,aAAa,EACb,IAAI,EACJ,SAAS,EACT,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAIjB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO,CAAC,QAAQ,CAAqB;gBAEzB,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;;;;;;;;;OASG;IACH,OAAO,CACL,OAAO,EAAE,yBAAyB,EAClC,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB;IAQnB,gBAAgB,IAAI,aAAa;CAGlC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prediction Engine
|
|
4
|
+
*
|
|
5
|
+
* Trajectory forecasting engine that takes historical score snapshots,
|
|
6
|
+
* fits a model, and projects forward. Supports linear regression,
|
|
7
|
+
* exponential smoothing, and weighted moving average strategies.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const engine = new PredictionEngine();
|
|
12
|
+
* engine.add({ type: 'VendorScore', data: { vendorId: 'acme', totalScore: 520, evaluatedAt: '2025-09-01' } });
|
|
13
|
+
* engine.add({ type: 'VendorScore', data: { vendorId: 'acme', totalScore: 580, evaluatedAt: '2025-12-01' } });
|
|
14
|
+
* engine.add({ type: 'VendorScore', data: { vendorId: 'acme', totalScore: 640, evaluatedAt: '2026-03-01' } });
|
|
15
|
+
*
|
|
16
|
+
* const result = engine.execute(compiledRuleset);
|
|
17
|
+
* console.log(result.predictions[0]); // { entityId: 'acme', trend: 'rising', trendSlope: 20, ... }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.PredictionEngine = void 0;
|
|
22
|
+
const core_1 = require("../../core");
|
|
23
|
+
const strategy_1 = require("./strategy");
|
|
24
|
+
class PredictionEngine {
|
|
25
|
+
wm;
|
|
26
|
+
strategy;
|
|
27
|
+
constructor(workingMemory) {
|
|
28
|
+
this.wm = workingMemory ?? new core_1.WorkingMemory();
|
|
29
|
+
this.strategy = new strategy_1.PredictionExecutor();
|
|
30
|
+
}
|
|
31
|
+
// ========================================
|
|
32
|
+
// IWorkingMemory Implementation
|
|
33
|
+
// ========================================
|
|
34
|
+
add(input) {
|
|
35
|
+
return this.wm.add(input);
|
|
36
|
+
}
|
|
37
|
+
remove(factId) {
|
|
38
|
+
return this.wm.remove(factId);
|
|
39
|
+
}
|
|
40
|
+
update(input) {
|
|
41
|
+
return this.wm.update(input);
|
|
42
|
+
}
|
|
43
|
+
get(factId) {
|
|
44
|
+
return this.wm.get(factId);
|
|
45
|
+
}
|
|
46
|
+
getByType(type) {
|
|
47
|
+
return this.wm.getByType(type);
|
|
48
|
+
}
|
|
49
|
+
getAll() {
|
|
50
|
+
return this.wm.getAll();
|
|
51
|
+
}
|
|
52
|
+
has(factId) {
|
|
53
|
+
return this.wm.has(factId);
|
|
54
|
+
}
|
|
55
|
+
size() {
|
|
56
|
+
return this.wm.size();
|
|
57
|
+
}
|
|
58
|
+
clear() {
|
|
59
|
+
this.wm.clear();
|
|
60
|
+
}
|
|
61
|
+
getChanges() {
|
|
62
|
+
return this.wm.getChanges();
|
|
63
|
+
}
|
|
64
|
+
clearChanges() {
|
|
65
|
+
this.wm.clearChanges();
|
|
66
|
+
}
|
|
67
|
+
// ========================================
|
|
68
|
+
// Engine Execution
|
|
69
|
+
// ========================================
|
|
70
|
+
/**
|
|
71
|
+
* Execute a prediction ruleset.
|
|
72
|
+
*
|
|
73
|
+
* Groups all snapshots of the configured type by entity,
|
|
74
|
+
* fits a trajectory model, and projects forward to the horizon.
|
|
75
|
+
*
|
|
76
|
+
* @param ruleSet - Compiled prediction ruleset
|
|
77
|
+
* @param options - Runtime options (onPredict callback, asOf for testing)
|
|
78
|
+
* @returns Prediction result with forecasts per entity
|
|
79
|
+
*/
|
|
80
|
+
execute(ruleSet, options = {}) {
|
|
81
|
+
return this.strategy.run(ruleSet, this.wm, options);
|
|
82
|
+
}
|
|
83
|
+
// ========================================
|
|
84
|
+
// Utility Methods
|
|
85
|
+
// ========================================
|
|
86
|
+
getWorkingMemory() {
|
|
87
|
+
return this.wm;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.PredictionEngine = PredictionEngine;
|
|
91
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../src/engines/prediction/engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,qCAKoB;AAQpB,yCAAgD;AAEhD,MAAa,gBAAgB;IACnB,EAAE,CAAgB;IAClB,QAAQ,CAAqB;IAErC,YAAY,aAA6B;QACvC,IAAI,CAAC,EAAE,GAAG,aAAa,IAAI,IAAI,oBAAa,EAAE,CAAC;QAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,6BAAkB,EAAE,CAAC;IAC3C,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,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC;IAED,YAAY;QACV,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC;IACzB,CAAC;IAED,2CAA2C;IAC3C,mBAAmB;IACnB,2CAA2C;IAE3C;;;;;;;;;OASG;IACH,OAAO,CACL,OAAkC,EAClC,UAA6B,EAAE;QAE/B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,2CAA2C;IAC3C,kBAAkB;IAClB,2CAA2C;IAE3C,gBAAgB;QACd,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF;AArFD,4CAqFC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prediction Engine — Trajectory Forecasting
|
|
3
|
+
*/
|
|
4
|
+
export type { PredictionStrategy, TrendDirection, SmoothingPreset, HorizonPreset, ConfidenceBracket, FieldMapping, ThresholdDefinition, LinearRegressionConfig, ExponentialSmoothingConfig, WeightedMovingAverageConfig, LinearRegressionRuleSet, ExponentialSmoothingRuleSet, WeightedMovingAverageRuleSet, PredictionRuleSet, CompiledLinearRegressionRuleSet, CompiledExponentialSmoothingRuleSet, CompiledWeightedMovingAverageRuleSet, CompiledPredictionRuleSet, ThresholdCrossing, Forecast, EntityPrediction, PredictionResult, PredictionOptions } from './types';
|
|
5
|
+
export { SMOOTHING_PRESET_VALUES, HORIZON_PRESET_VALUES, isSmoothingPreset, isHorizonPreset, resolveConfidenceBracket, resolveTrendDirection } from './types';
|
|
6
|
+
export { compilePredictionRuleSet } from './compiler';
|
|
7
|
+
export { PredictionExecutor, predictionStrategy } from './strategy';
|
|
8
|
+
export { PredictionEngine } from './engine';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engines/prediction/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC5B,iBAAiB,EACjB,+BAA+B,EAC/B,mCAAmC,EACnC,oCAAoC,EACpC,yBAAyB,EACzB,iBAAiB,EACjB,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAGtD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prediction Engine — Trajectory Forecasting
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PredictionEngine = exports.predictionStrategy = exports.PredictionExecutor = exports.compilePredictionRuleSet = exports.resolveTrendDirection = exports.resolveConfidenceBracket = exports.isHorizonPreset = exports.isSmoothingPreset = exports.HORIZON_PRESET_VALUES = exports.SMOOTHING_PRESET_VALUES = void 0;
|
|
7
|
+
// Constants & utilities
|
|
8
|
+
var types_1 = require("./types");
|
|
9
|
+
Object.defineProperty(exports, "SMOOTHING_PRESET_VALUES", { enumerable: true, get: function () { return types_1.SMOOTHING_PRESET_VALUES; } });
|
|
10
|
+
Object.defineProperty(exports, "HORIZON_PRESET_VALUES", { enumerable: true, get: function () { return types_1.HORIZON_PRESET_VALUES; } });
|
|
11
|
+
Object.defineProperty(exports, "isSmoothingPreset", { enumerable: true, get: function () { return types_1.isSmoothingPreset; } });
|
|
12
|
+
Object.defineProperty(exports, "isHorizonPreset", { enumerable: true, get: function () { return types_1.isHorizonPreset; } });
|
|
13
|
+
Object.defineProperty(exports, "resolveConfidenceBracket", { enumerable: true, get: function () { return types_1.resolveConfidenceBracket; } });
|
|
14
|
+
Object.defineProperty(exports, "resolveTrendDirection", { enumerable: true, get: function () { return types_1.resolveTrendDirection; } });
|
|
15
|
+
// Compiler
|
|
16
|
+
var compiler_1 = require("./compiler");
|
|
17
|
+
Object.defineProperty(exports, "compilePredictionRuleSet", { enumerable: true, get: function () { return compiler_1.compilePredictionRuleSet; } });
|
|
18
|
+
// Strategy
|
|
19
|
+
var strategy_1 = require("./strategy");
|
|
20
|
+
Object.defineProperty(exports, "PredictionExecutor", { enumerable: true, get: function () { return strategy_1.PredictionExecutor; } });
|
|
21
|
+
Object.defineProperty(exports, "predictionStrategy", { enumerable: true, get: function () { return strategy_1.predictionStrategy; } });
|
|
22
|
+
// Engine
|
|
23
|
+
var engine_1 = require("./engine");
|
|
24
|
+
Object.defineProperty(exports, "PredictionEngine", { enumerable: true, get: function () { return engine_1.PredictionEngine; } });
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engines/prediction/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA6BH,wBAAwB;AACxB,iCAOiB;AANf,gHAAA,uBAAuB,OAAA;AACvB,8GAAA,qBAAqB,OAAA;AACrB,0GAAA,iBAAiB,OAAA;AACjB,wGAAA,eAAe,OAAA;AACf,iHAAA,wBAAwB,OAAA;AACxB,8GAAA,qBAAqB,OAAA;AAGvB,WAAW;AACX,uCAAsD;AAA7C,oHAAA,wBAAwB,OAAA;AAEjC,WAAW;AACX,uCAAoE;AAA3D,8GAAA,kBAAkB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAE/C,SAAS;AACT,mCAA4C;AAAnC,0GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prediction Engine Strategy
|
|
3
|
+
*
|
|
4
|
+
* Core execution logic for all prediction strategies:
|
|
5
|
+
* - linear-regression: Least-squares line fit with R² confidence
|
|
6
|
+
* - exponential-smoothing: Holt's double exponential (level + trend)
|
|
7
|
+
* - weighted-moving-average: Rolling window with recency weighting
|
|
8
|
+
*/
|
|
9
|
+
import type { IWorkingMemory } from '../../core';
|
|
10
|
+
import type { CompiledPredictionRuleSet, PredictionOptions, PredictionResult } from './types';
|
|
11
|
+
export declare class PredictionExecutor {
|
|
12
|
+
run(ruleSet: CompiledPredictionRuleSet, wm: IWorkingMemory, options?: PredictionOptions): PredictionResult;
|
|
13
|
+
private runLinearRegression;
|
|
14
|
+
private runExponentialSmoothing;
|
|
15
|
+
private runWeightedMovingAverage;
|
|
16
|
+
private buildSinglePointPrediction;
|
|
17
|
+
}
|
|
18
|
+
/** Singleton instance */
|
|
19
|
+
export declare const predictionStrategy: PredictionExecutor;
|
|
20
|
+
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/engines/prediction/strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,YAAY,CAAC;AAEvD,OAAO,KAAK,EACV,yBAAyB,EAIzB,iBAAiB,EACjB,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AAajB,qBAAa,kBAAkB;IAC7B,GAAG,CACD,OAAO,EAAE,yBAAyB,EAClC,EAAE,EAAE,cAAc,EAClB,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB;IAyDnB,OAAO,CAAC,mBAAmB;IAwH3B,OAAO,CAAC,uBAAuB;IAwH/B,OAAO,CAAC,wBAAwB;IAqFhC,OAAO,CAAC,0BAA0B;CA0CnC;AA4GD,yBAAyB;AACzB,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
|