@higher.archi/boe 1.0.27 → 1.0.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/engines/decay/compiler.d.ts +11 -0
- package/dist/engines/decay/compiler.d.ts.map +1 -0
- package/dist/engines/decay/compiler.js +216 -0
- package/dist/engines/decay/compiler.js.map +1 -0
- package/dist/engines/decay/engine.d.ts +48 -0
- package/dist/engines/decay/engine.d.ts.map +1 -0
- package/dist/engines/decay/engine.js +90 -0
- package/dist/engines/decay/engine.js.map +1 -0
- package/dist/engines/decay/index.d.ts +9 -0
- package/dist/engines/decay/index.d.ts.map +1 -0
- package/dist/engines/decay/index.js +21 -0
- package/dist/engines/decay/index.js.map +1 -0
- package/dist/engines/decay/strategy.d.ts +19 -0
- package/dist/engines/decay/strategy.d.ts.map +1 -0
- package/dist/engines/decay/strategy.js +284 -0
- package/dist/engines/decay/strategy.js.map +1 -0
- package/dist/engines/decay/types.d.ts +148 -0
- package/dist/engines/decay/types.d.ts.map +1 -0
- package/dist/engines/decay/types.js +39 -0
- package/dist/engines/decay/types.js.map +1 -0
- package/dist/engines/negotiation/compiler.d.ts +11 -0
- package/dist/engines/negotiation/compiler.d.ts.map +1 -0
- package/dist/engines/negotiation/compiler.js +177 -0
- package/dist/engines/negotiation/compiler.js.map +1 -0
- package/dist/engines/negotiation/engine.d.ts +46 -0
- package/dist/engines/negotiation/engine.d.ts.map +1 -0
- package/dist/engines/negotiation/engine.js +88 -0
- package/dist/engines/negotiation/engine.js.map +1 -0
- package/dist/engines/negotiation/index.d.ts +8 -0
- package/dist/engines/negotiation/index.d.ts.map +1 -0
- package/dist/engines/negotiation/index.js +17 -0
- package/dist/engines/negotiation/index.js.map +1 -0
- package/dist/engines/negotiation/strategy.d.ts +18 -0
- package/dist/engines/negotiation/strategy.d.ts.map +1 -0
- package/dist/engines/negotiation/strategy.js +439 -0
- package/dist/engines/negotiation/strategy.js.map +1 -0
- package/dist/engines/negotiation/types.d.ts +179 -0
- package/dist/engines/negotiation/types.d.ts.map +1 -0
- package/dist/engines/negotiation/types.js +10 -0
- package/dist/engines/negotiation/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/engines/decay/compiler.ts +276 -0
- package/src/engines/decay/engine.ts +119 -0
- package/src/engines/decay/index.ts +42 -0
- package/src/engines/decay/strategy.ts +400 -0
- package/src/engines/decay/types.ts +221 -0
- package/src/engines/negotiation/compiler.ts +229 -0
- package/src/engines/negotiation/engine.ts +117 -0
- package/src/engines/negotiation/index.ts +42 -0
- package/src/engines/negotiation/strategy.ts +587 -0
- package/src/engines/negotiation/types.ts +244 -0
- package/src/index.ts +68 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decay Engine Compiler
|
|
3
|
+
*
|
|
4
|
+
* Validates decay rulesets and resolves defaults.
|
|
5
|
+
*/
|
|
6
|
+
import type { DecayRuleSet, CompiledDecayRuleSet } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Compile and validate a decay ruleset.
|
|
9
|
+
*/
|
|
10
|
+
export declare function compileDecayRuleSet(ruleSet: DecayRuleSet): CompiledDecayRuleSet;
|
|
11
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../src/engines/decay/compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EAQrB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,YAAY,GACpB,oBAAoB,CA0BtB"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Decay Engine Compiler
|
|
4
|
+
*
|
|
5
|
+
* Validates decay rulesets and resolves defaults.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.compileDecayRuleSet = compileDecayRuleSet;
|
|
9
|
+
const errors_1 = require("../../core/errors");
|
|
10
|
+
const types_1 = require("../utility/types");
|
|
11
|
+
const types_2 = require("./types");
|
|
12
|
+
/**
|
|
13
|
+
* Compile and validate a decay ruleset.
|
|
14
|
+
*/
|
|
15
|
+
function compileDecayRuleSet(ruleSet) {
|
|
16
|
+
if (!ruleSet.id) {
|
|
17
|
+
throw new errors_1.CompilationError('Decay ruleset requires an id');
|
|
18
|
+
}
|
|
19
|
+
if (ruleSet.mode !== 'decay') {
|
|
20
|
+
throw new errors_1.CompilationError(`Expected mode 'decay', got '${ruleSet.mode}'`);
|
|
21
|
+
}
|
|
22
|
+
if (!ruleSet.entityType || ruleSet.entityType.trim() === '') {
|
|
23
|
+
throw new errors_1.CompilationError('entityType is required and must be non-empty');
|
|
24
|
+
}
|
|
25
|
+
const entityIdField = ruleSet.entityIdField ?? 'id';
|
|
26
|
+
const urgencyThresholds = resolveUrgencyThresholds(ruleSet.urgencyThresholds);
|
|
27
|
+
switch (ruleSet.strategy) {
|
|
28
|
+
case 'single-dimension':
|
|
29
|
+
return compileSingleDimension(ruleSet, entityIdField, urgencyThresholds);
|
|
30
|
+
case 'multi-dimension':
|
|
31
|
+
return compileMultiDimension(ruleSet, entityIdField, urgencyThresholds);
|
|
32
|
+
case 'event-driven':
|
|
33
|
+
return compileEventDriven(ruleSet, entityIdField, urgencyThresholds);
|
|
34
|
+
default:
|
|
35
|
+
throw new errors_1.CompilationError(`Unknown decay strategy: '${ruleSet.strategy}'`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// ========================================
|
|
39
|
+
// Strategy-Specific Compilers
|
|
40
|
+
// ========================================
|
|
41
|
+
function compileSingleDimension(ruleSet, entityIdField, urgencyThresholds) {
|
|
42
|
+
const dimension = ruleSet.dimension;
|
|
43
|
+
if (!dimension) {
|
|
44
|
+
throw new errors_1.CompilationError('Single-dimension strategy requires a dimension');
|
|
45
|
+
}
|
|
46
|
+
validateDimension(dimension);
|
|
47
|
+
return {
|
|
48
|
+
id: ruleSet.id,
|
|
49
|
+
name: ruleSet.name,
|
|
50
|
+
mode: 'decay',
|
|
51
|
+
strategy: 'single-dimension',
|
|
52
|
+
entityType: ruleSet.entityType,
|
|
53
|
+
entityIdField,
|
|
54
|
+
urgencyThresholds,
|
|
55
|
+
dimension: compileDimension(dimension, 1.0)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function compileMultiDimension(ruleSet, entityIdField, urgencyThresholds) {
|
|
59
|
+
const { dimensions } = ruleSet;
|
|
60
|
+
if (!dimensions || !Array.isArray(dimensions) || dimensions.length === 0) {
|
|
61
|
+
throw new errors_1.CompilationError('Multi-dimension strategy requires at least one dimension');
|
|
62
|
+
}
|
|
63
|
+
validateDimensionIds(dimensions);
|
|
64
|
+
for (const dim of dimensions) {
|
|
65
|
+
validateDimension(dim);
|
|
66
|
+
}
|
|
67
|
+
const compiledDimensions = compileDimensions(dimensions);
|
|
68
|
+
return {
|
|
69
|
+
id: ruleSet.id,
|
|
70
|
+
name: ruleSet.name,
|
|
71
|
+
mode: 'decay',
|
|
72
|
+
strategy: 'multi-dimension',
|
|
73
|
+
entityType: ruleSet.entityType,
|
|
74
|
+
entityIdField,
|
|
75
|
+
urgencyThresholds,
|
|
76
|
+
dimensions: compiledDimensions,
|
|
77
|
+
aggregation: ruleSet.aggregation ?? 'weighted-average'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function compileEventDriven(ruleSet, entityIdField, urgencyThresholds) {
|
|
81
|
+
const { dimensions, reEngagementRules } = ruleSet;
|
|
82
|
+
if (!dimensions || !Array.isArray(dimensions) || dimensions.length === 0) {
|
|
83
|
+
throw new errors_1.CompilationError('Event-driven strategy requires at least one dimension');
|
|
84
|
+
}
|
|
85
|
+
validateDimensionIds(dimensions);
|
|
86
|
+
for (const dim of dimensions) {
|
|
87
|
+
validateDimension(dim);
|
|
88
|
+
}
|
|
89
|
+
if (!reEngagementRules || !Array.isArray(reEngagementRules) || reEngagementRules.length === 0) {
|
|
90
|
+
throw new errors_1.CompilationError('Event-driven strategy requires at least one re-engagement rule');
|
|
91
|
+
}
|
|
92
|
+
validateReEngagementRules(reEngagementRules);
|
|
93
|
+
const compiledDimensions = compileDimensions(dimensions);
|
|
94
|
+
return {
|
|
95
|
+
id: ruleSet.id,
|
|
96
|
+
name: ruleSet.name,
|
|
97
|
+
mode: 'decay',
|
|
98
|
+
strategy: 'event-driven',
|
|
99
|
+
entityType: ruleSet.entityType,
|
|
100
|
+
entityIdField,
|
|
101
|
+
urgencyThresholds,
|
|
102
|
+
dimensions: compiledDimensions,
|
|
103
|
+
aggregation: ruleSet.aggregation ?? 'weighted-average',
|
|
104
|
+
reEngagementRules
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// ========================================
|
|
108
|
+
// Validation Helpers
|
|
109
|
+
// ========================================
|
|
110
|
+
function validateDimension(dim) {
|
|
111
|
+
if (!dim.id) {
|
|
112
|
+
throw new errors_1.CompilationError('Each dimension requires an id');
|
|
113
|
+
}
|
|
114
|
+
if (!dim.timestampField) {
|
|
115
|
+
throw new errors_1.CompilationError(`Dimension '${dim.id}' requires a timestampField`);
|
|
116
|
+
}
|
|
117
|
+
switch (dim.curve) {
|
|
118
|
+
case 'exponential':
|
|
119
|
+
if (dim.halfLife === undefined || dim.halfLife <= 0) {
|
|
120
|
+
throw new errors_1.CompilationError(`Dimension '${dim.id}' with exponential curve requires a positive halfLife`);
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case 'linear':
|
|
124
|
+
if (dim.maxAge === undefined || dim.maxAge <= 0) {
|
|
125
|
+
throw new errors_1.CompilationError(`Dimension '${dim.id}' with linear curve requires a positive maxAge`);
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case 'step':
|
|
129
|
+
if (dim.threshold === undefined || dim.threshold <= 0) {
|
|
130
|
+
throw new errors_1.CompilationError(`Dimension '${dim.id}' with step curve requires a positive threshold`);
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
throw new errors_1.CompilationError(`Dimension '${dim.id}' has unknown curve: '${dim.curve}'`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function validateDimensionIds(dimensions) {
|
|
138
|
+
const ids = new Set();
|
|
139
|
+
for (const dim of dimensions) {
|
|
140
|
+
if (!dim.id) {
|
|
141
|
+
throw new errors_1.CompilationError('Each dimension requires an id');
|
|
142
|
+
}
|
|
143
|
+
if (ids.has(dim.id)) {
|
|
144
|
+
throw new errors_1.CompilationError(`Duplicate dimension id: '${dim.id}'`);
|
|
145
|
+
}
|
|
146
|
+
ids.add(dim.id);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function validateReEngagementRules(rules) {
|
|
150
|
+
const ids = new Set();
|
|
151
|
+
for (const rule of rules) {
|
|
152
|
+
if (!rule.id) {
|
|
153
|
+
throw new errors_1.CompilationError('Each re-engagement rule requires an id');
|
|
154
|
+
}
|
|
155
|
+
if (ids.has(rule.id)) {
|
|
156
|
+
throw new errors_1.CompilationError(`Duplicate re-engagement rule id: '${rule.id}'`);
|
|
157
|
+
}
|
|
158
|
+
ids.add(rule.id);
|
|
159
|
+
if (!rule.eventType || rule.eventType.trim() === '') {
|
|
160
|
+
throw new errors_1.CompilationError(`Re-engagement rule '${rule.id}' requires a non-empty eventType`);
|
|
161
|
+
}
|
|
162
|
+
const validEffects = ['reset', 'boost', 'extend'];
|
|
163
|
+
if (!validEffects.includes(rule.effect)) {
|
|
164
|
+
throw new errors_1.CompilationError(`Re-engagement rule '${rule.id}' has invalid effect: '${rule.effect}'`);
|
|
165
|
+
}
|
|
166
|
+
if (rule.effect === 'boost' && (rule.boostAmount === undefined || rule.boostAmount <= 0)) {
|
|
167
|
+
throw new errors_1.CompilationError(`Re-engagement rule '${rule.id}' with boost effect requires a positive boostAmount`);
|
|
168
|
+
}
|
|
169
|
+
if (rule.effect === 'extend' && (rule.extensionDays === undefined || rule.extensionDays <= 0)) {
|
|
170
|
+
throw new errors_1.CompilationError(`Re-engagement rule '${rule.id}' with extend effect requires a positive extensionDays`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// ========================================
|
|
175
|
+
// Compilation Helpers
|
|
176
|
+
// ========================================
|
|
177
|
+
function compileDimension(dim, weight) {
|
|
178
|
+
return {
|
|
179
|
+
id: dim.id,
|
|
180
|
+
name: dim.name,
|
|
181
|
+
timestampField: dim.timestampField,
|
|
182
|
+
curve: dim.curve,
|
|
183
|
+
timeUnit: dim.timeUnit,
|
|
184
|
+
halfLife: dim.halfLife,
|
|
185
|
+
maxAge: dim.maxAge,
|
|
186
|
+
threshold: dim.threshold,
|
|
187
|
+
floor: dim.floor,
|
|
188
|
+
weight
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function compileDimensions(dimensions) {
|
|
192
|
+
// Resolve semantic weights to numeric
|
|
193
|
+
const resolved = dimensions.map(dim => {
|
|
194
|
+
let weight;
|
|
195
|
+
if ((0, types_1.isSemanticPriority)(dim.weight)) {
|
|
196
|
+
weight = types_1.SEMANTIC_PRIORITY_VALUES[dim.weight];
|
|
197
|
+
}
|
|
198
|
+
else if (typeof dim.weight === 'number') {
|
|
199
|
+
weight = dim.weight;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
throw new errors_1.CompilationError(`Invalid weight for dimension '${dim.id}': '${dim.weight}'`);
|
|
203
|
+
}
|
|
204
|
+
return { dim, weight };
|
|
205
|
+
});
|
|
206
|
+
// Normalize weights to sum to 1.0
|
|
207
|
+
const totalWeight = resolved.reduce((sum, r) => sum + r.weight, 0);
|
|
208
|
+
if (totalWeight === 0) {
|
|
209
|
+
throw new errors_1.CompilationError('Dimension weights must not all be zero');
|
|
210
|
+
}
|
|
211
|
+
return resolved.map(r => compileDimension(r.dim, r.weight / totalWeight));
|
|
212
|
+
}
|
|
213
|
+
function resolveUrgencyThresholds(overrides) {
|
|
214
|
+
return { ...types_2.URGENCY_THRESHOLDS, ...overrides };
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/engines/decay/compiler.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAqBH,kDA4BC;AA/CD,8CAAqD;AACrD,4CAAuG;AAavG,mCAA6C;AAE7C;;GAEG;AACH,SAAgB,mBAAmB,CACjC,OAAqB;IAErB,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,yBAAgB,CAAC,8BAA8B,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,yBAAgB,CAAC,+BAA+B,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC5D,MAAM,IAAI,yBAAgB,CAAC,8CAA8C,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC;IACpD,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE9E,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,kBAAkB;YACrB,OAAO,sBAAsB,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;QAC3E,KAAK,iBAAiB;YACpB,OAAO,qBAAqB,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;QAC1E,KAA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8C,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC/E,IAAI,MAAc,CAAC;QACnB,IAAI,IAAA,0BAAkB,EAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,MAAM,GAAG,gCAAwB,CAAC,GAAG,CAAC,MAA0B,CAAC,CAAC;QACpE,CAAC;aAAM,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,yBAAgB,CAAC,iCAAiC,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,kCAAkC;IAClC,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnE,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,yBAAgB,CAAC,wCAAwC,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,wBAAwB,CAC/B,SAAgD;IAEhD,OAAO,EAAE,GAAG,0BAAkB,EAAE,GAAG,SAAS,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decay Engine
|
|
3
|
+
*
|
|
4
|
+
* Temporal decay engine that computes freshness scores for entities based
|
|
5
|
+
* on how recently their data was updated. Supports single-dimension,
|
|
6
|
+
* multi-dimension, and event-driven decay strategies.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const engine = new DecayEngine();
|
|
11
|
+
* engine.add({ type: 'Lead', data: { id: 'l1', lastContact: '2024-01-15' } });
|
|
12
|
+
* engine.add({ type: 'Lead', data: { id: 'l2', lastContact: '2024-03-01' } });
|
|
13
|
+
*
|
|
14
|
+
* const result = engine.execute(compiledDecay);
|
|
15
|
+
* console.log(result.entities[0]); // { entityId: 'l1', compositeFreshness: 0.42, urgencyTier: 'medium', ... }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { WorkingMemory, Fact, FactInput, FactChange } from '../../core';
|
|
19
|
+
import type { CompiledDecayRuleSet, DecayOptions, DecayResult } from './types';
|
|
20
|
+
export declare class DecayEngine {
|
|
21
|
+
private wm;
|
|
22
|
+
private strategy;
|
|
23
|
+
constructor(workingMemory?: WorkingMemory);
|
|
24
|
+
add<T = Record<string, any>>(input: FactInput<T>): Fact<T>;
|
|
25
|
+
remove(factId: string): Fact | undefined;
|
|
26
|
+
update<T = Record<string, any>>(input: FactInput<T>): Fact<T>;
|
|
27
|
+
get(factId: string): Fact | undefined;
|
|
28
|
+
getByType(type: string): Fact[];
|
|
29
|
+
getAll(): Fact[];
|
|
30
|
+
has(factId: string): boolean;
|
|
31
|
+
size(): number;
|
|
32
|
+
clear(): void;
|
|
33
|
+
getChanges(): FactChange[];
|
|
34
|
+
clearChanges(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Execute a decay ruleset.
|
|
37
|
+
*
|
|
38
|
+
* Computes freshness scores for all entities of the configured type
|
|
39
|
+
* and maps each to an urgency tier.
|
|
40
|
+
*
|
|
41
|
+
* @param ruleSet - Compiled decay ruleset
|
|
42
|
+
* @param options - Runtime options (asOf date, onEntity callback)
|
|
43
|
+
* @returns Decay result with per-entity freshness and tier distribution
|
|
44
|
+
*/
|
|
45
|
+
execute(ruleSet: CompiledDecayRuleSet, options?: DecayOptions): DecayResult;
|
|
46
|
+
getWorkingMemory(): WorkingMemory;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/engines/decay/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,aAAa,EACb,IAAI,EACJ,SAAS,EACT,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAIjB,qBAAa,WAAW;IACtB,OAAO,CAAC,EAAE,CAAgB;IAC1B,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,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,oBAAoB,EAC7B,OAAO,GAAE,YAAiB,GACzB,WAAW;IAQd,gBAAgB,IAAI,aAAa;CAGlC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Decay Engine
|
|
4
|
+
*
|
|
5
|
+
* Temporal decay engine that computes freshness scores for entities based
|
|
6
|
+
* on how recently their data was updated. Supports single-dimension,
|
|
7
|
+
* multi-dimension, and event-driven decay strategies.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const engine = new DecayEngine();
|
|
12
|
+
* engine.add({ type: 'Lead', data: { id: 'l1', lastContact: '2024-01-15' } });
|
|
13
|
+
* engine.add({ type: 'Lead', data: { id: 'l2', lastContact: '2024-03-01' } });
|
|
14
|
+
*
|
|
15
|
+
* const result = engine.execute(compiledDecay);
|
|
16
|
+
* console.log(result.entities[0]); // { entityId: 'l1', compositeFreshness: 0.42, urgencyTier: 'medium', ... }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.DecayEngine = void 0;
|
|
21
|
+
const core_1 = require("../../core");
|
|
22
|
+
const strategy_1 = require("./strategy");
|
|
23
|
+
class DecayEngine {
|
|
24
|
+
wm;
|
|
25
|
+
strategy;
|
|
26
|
+
constructor(workingMemory) {
|
|
27
|
+
this.wm = workingMemory ?? new core_1.WorkingMemory();
|
|
28
|
+
this.strategy = new strategy_1.DecayExecutor();
|
|
29
|
+
}
|
|
30
|
+
// ========================================
|
|
31
|
+
// IWorkingMemory Implementation
|
|
32
|
+
// ========================================
|
|
33
|
+
add(input) {
|
|
34
|
+
return this.wm.add(input);
|
|
35
|
+
}
|
|
36
|
+
remove(factId) {
|
|
37
|
+
return this.wm.remove(factId);
|
|
38
|
+
}
|
|
39
|
+
update(input) {
|
|
40
|
+
return this.wm.update(input);
|
|
41
|
+
}
|
|
42
|
+
get(factId) {
|
|
43
|
+
return this.wm.get(factId);
|
|
44
|
+
}
|
|
45
|
+
getByType(type) {
|
|
46
|
+
return this.wm.getByType(type);
|
|
47
|
+
}
|
|
48
|
+
getAll() {
|
|
49
|
+
return this.wm.getAll();
|
|
50
|
+
}
|
|
51
|
+
has(factId) {
|
|
52
|
+
return this.wm.has(factId);
|
|
53
|
+
}
|
|
54
|
+
size() {
|
|
55
|
+
return this.wm.size();
|
|
56
|
+
}
|
|
57
|
+
clear() {
|
|
58
|
+
this.wm.clear();
|
|
59
|
+
}
|
|
60
|
+
getChanges() {
|
|
61
|
+
return this.wm.getChanges();
|
|
62
|
+
}
|
|
63
|
+
clearChanges() {
|
|
64
|
+
this.wm.clearChanges();
|
|
65
|
+
}
|
|
66
|
+
// ========================================
|
|
67
|
+
// Engine Execution
|
|
68
|
+
// ========================================
|
|
69
|
+
/**
|
|
70
|
+
* Execute a decay ruleset.
|
|
71
|
+
*
|
|
72
|
+
* Computes freshness scores for all entities of the configured type
|
|
73
|
+
* and maps each to an urgency tier.
|
|
74
|
+
*
|
|
75
|
+
* @param ruleSet - Compiled decay ruleset
|
|
76
|
+
* @param options - Runtime options (asOf date, onEntity callback)
|
|
77
|
+
* @returns Decay result with per-entity freshness and tier distribution
|
|
78
|
+
*/
|
|
79
|
+
execute(ruleSet, options = {}) {
|
|
80
|
+
return this.strategy.run(ruleSet, this.wm, options);
|
|
81
|
+
}
|
|
82
|
+
// ========================================
|
|
83
|
+
// Utility Methods
|
|
84
|
+
// ========================================
|
|
85
|
+
getWorkingMemory() {
|
|
86
|
+
return this.wm;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.DecayEngine = DecayEngine;
|
|
90
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../src/engines/decay/engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,qCAKoB;AAQpB,yCAA2C;AAE3C,MA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,CAAC;IAED,2CAA2C;IAC3C,mBAAmB;IACnB,2CAA2C;IAE3C;;;;;;;;;OASG;IACH,OAAO,CACL,OAA6B,EAC7B,UAAwB,EAAE;QAE1B,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,kCAqFC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decay Engine -- Temporal Freshness Scoring
|
|
3
|
+
*/
|
|
4
|
+
export type { DecayStrategy, UrgencyTier, ReEngagementEffect, DecayAggregation, DecayDimension, CompiledDecayDimension, ReEngagementRule, SingleDimensionDecayRuleSet, MultiDimensionDecayRuleSet, EventDrivenDecayRuleSet, DecayRuleSet, CompiledSingleDimensionDecayRuleSet, CompiledMultiDimensionDecayRuleSet, CompiledEventDrivenDecayRuleSet, CompiledDecayRuleSet, DimensionDecayResult, ReEngagementEvent, EntityDecayResult, DecayResult, DecayOptions } from './types';
|
|
5
|
+
export { URGENCY_THRESHOLDS, resolveUrgencyTier } from './types';
|
|
6
|
+
export { compileDecayRuleSet } from './compiler';
|
|
7
|
+
export { DecayExecutor, decayStrategy } from './strategy';
|
|
8
|
+
export { DecayEngine } from './engine';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engines/decay/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,YAAY,EACZ,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,EAC/B,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Decay Engine -- Temporal Freshness Scoring
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DecayEngine = exports.decayStrategy = exports.DecayExecutor = exports.compileDecayRuleSet = exports.resolveUrgencyTier = exports.URGENCY_THRESHOLDS = void 0;
|
|
7
|
+
// Constants & utilities
|
|
8
|
+
var types_1 = require("./types");
|
|
9
|
+
Object.defineProperty(exports, "URGENCY_THRESHOLDS", { enumerable: true, get: function () { return types_1.URGENCY_THRESHOLDS; } });
|
|
10
|
+
Object.defineProperty(exports, "resolveUrgencyTier", { enumerable: true, get: function () { return types_1.resolveUrgencyTier; } });
|
|
11
|
+
// Compiler
|
|
12
|
+
var compiler_1 = require("./compiler");
|
|
13
|
+
Object.defineProperty(exports, "compileDecayRuleSet", { enumerable: true, get: function () { return compiler_1.compileDecayRuleSet; } });
|
|
14
|
+
// Strategy
|
|
15
|
+
var strategy_1 = require("./strategy");
|
|
16
|
+
Object.defineProperty(exports, "DecayExecutor", { enumerable: true, get: function () { return strategy_1.DecayExecutor; } });
|
|
17
|
+
Object.defineProperty(exports, "decayStrategy", { enumerable: true, get: function () { return strategy_1.decayStrategy; } });
|
|
18
|
+
// Engine
|
|
19
|
+
var engine_1 = require("./engine");
|
|
20
|
+
Object.defineProperty(exports, "DecayEngine", { enumerable: true, get: function () { return engine_1.DecayEngine; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engines/decay/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA0BH,wBAAwB;AACxB,iCAGiB;AAFf,2GAAA,kBAAkB,OAAA;AAClB,2GAAA,kBAAkB,OAAA;AAGpB,WAAW;AACX,uCAAiD;AAAxC,+GAAA,mBAAmB,OAAA;AAE5B,WAAW;AACX,uCAA0D;AAAjD,yGAAA,aAAa,OAAA;AAAE,yGAAA,aAAa,OAAA;AAErC,SAAS;AACT,mCAAuC;AAA9B,qGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decay Engine Strategy
|
|
3
|
+
*
|
|
4
|
+
* Core execution logic for all decay strategies:
|
|
5
|
+
* - single-dimension: One temporal axis evaluated per entity
|
|
6
|
+
* - multi-dimension: Multiple temporal axes aggregated into a composite score
|
|
7
|
+
* - event-driven: Multi-dimension with re-engagement events that reset/boost/extend decay
|
|
8
|
+
*/
|
|
9
|
+
import type { IWorkingMemory } from '../../core';
|
|
10
|
+
import type { CompiledDecayRuleSet, DecayOptions, DecayResult } from './types';
|
|
11
|
+
export declare class DecayExecutor {
|
|
12
|
+
run(ruleSet: CompiledDecayRuleSet, wm: IWorkingMemory, options?: DecayOptions): DecayResult;
|
|
13
|
+
private runSingleDimension;
|
|
14
|
+
private runMultiDimension;
|
|
15
|
+
private runEventDriven;
|
|
16
|
+
}
|
|
17
|
+
/** Singleton instance */
|
|
18
|
+
export declare const decayStrategy: DecayExecutor;
|
|
19
|
+
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../src/engines/decay/strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,YAAY,CAAC;AAIvD,OAAO,KAAK,EACV,oBAAoB,EAKpB,YAAY,EACZ,WAAW,EAMZ,MAAM,SAAS,CAAC;AAKjB,qBAAa,aAAa;IACxB,GAAG,CACD,OAAO,EAAE,oBAAoB,EAC7B,EAAE,EAAE,cAAc,EAClB,OAAO,GAAE,YAAiB,GACzB,WAAW;IA+Cd,OAAO,CAAC,kBAAkB;IAoC1B,OAAO,CAAC,iBAAiB;IA4CzB,OAAO,CAAC,cAAc;CA0IvB;AAiGD,yBAAyB;AACzB,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|