@higher.archi/boe 1.0.7 → 1.0.9
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/errors.d.ts +48 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +63 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/evaluation/decay.d.ts +60 -0
- package/dist/core/evaluation/decay.d.ts.map +1 -0
- package/dist/core/evaluation/decay.js +111 -0
- package/dist/core/evaluation/decay.js.map +1 -0
- package/dist/core/evaluation/index.d.ts +2 -0
- package/dist/core/evaluation/index.d.ts.map +1 -1
- package/dist/core/evaluation/index.js +5 -1
- package/dist/core/evaluation/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/types/rule.d.ts +1 -0
- package/dist/core/types/rule.d.ts.map +1 -1
- package/dist/engines/backward/compiler.js +1 -1
- package/dist/engines/backward/compiler.js.map +1 -1
- package/dist/engines/bayesian/compiler.d.ts.map +1 -1
- package/dist/engines/bayesian/compiler.js +21 -9
- package/dist/engines/bayesian/compiler.js.map +1 -1
- package/dist/engines/bayesian/strategy.d.ts.map +1 -1
- package/dist/engines/bayesian/strategy.js +46 -9
- package/dist/engines/bayesian/strategy.js.map +1 -1
- package/dist/engines/bayesian/types.d.ts +16 -0
- package/dist/engines/bayesian/types.d.ts.map +1 -1
- package/dist/engines/bayesian/types.js.map +1 -1
- package/dist/engines/constraint/compiler.d.ts.map +1 -1
- package/dist/engines/constraint/compiler.js +10 -10
- package/dist/engines/constraint/compiler.js.map +1 -1
- package/dist/engines/defeasible/compiler.d.ts.map +1 -1
- package/dist/engines/defeasible/compiler.js +17 -3
- package/dist/engines/defeasible/compiler.js.map +1 -1
- package/dist/engines/defeasible/strategy.d.ts.map +1 -1
- package/dist/engines/defeasible/strategy.js +47 -2
- package/dist/engines/defeasible/strategy.js.map +1 -1
- package/dist/engines/defeasible/types.d.ts +29 -1
- package/dist/engines/defeasible/types.d.ts.map +1 -1
- package/dist/engines/defeasible/types.js.map +1 -1
- package/dist/engines/expert/compiler.d.ts.map +1 -1
- package/dist/engines/expert/compiler.js +6 -6
- package/dist/engines/expert/compiler.js.map +1 -1
- package/dist/engines/forward/compiler.d.ts.map +1 -1
- package/dist/engines/forward/compiler.js +4 -4
- package/dist/engines/forward/compiler.js.map +1 -1
- package/dist/engines/forward/strategy.d.ts.map +1 -1
- package/dist/engines/forward/strategy.js +4 -4
- package/dist/engines/forward/strategy.js.map +1 -1
- package/dist/engines/fuzzy/compiler.js +1 -1
- package/dist/engines/fuzzy/compiler.js.map +1 -1
- package/dist/engines/fuzzy/strategy.d.ts.map +1 -1
- package/dist/engines/fuzzy/strategy.js +8 -8
- package/dist/engines/fuzzy/strategy.js.map +1 -1
- package/dist/engines/monte-carlo/compiler.d.ts.map +1 -1
- package/dist/engines/monte-carlo/compiler.js +8 -8
- package/dist/engines/monte-carlo/compiler.js.map +1 -1
- package/dist/engines/monte-carlo/strategy.js +1 -1
- package/dist/engines/monte-carlo/strategy.js.map +1 -1
- package/dist/engines/pricing/compiler.d.ts.map +1 -1
- package/dist/engines/pricing/compiler.js +9 -9
- package/dist/engines/pricing/compiler.js.map +1 -1
- package/dist/engines/pricing/strategy.js +7 -6
- package/dist/engines/pricing/strategy.js.map +1 -1
- package/dist/engines/pricing/types.d.ts +2 -0
- package/dist/engines/pricing/types.d.ts.map +1 -1
- package/dist/engines/scoring/compiler.d.ts.map +1 -1
- package/dist/engines/scoring/compiler.js +24 -10
- package/dist/engines/scoring/compiler.js.map +1 -1
- package/dist/engines/scoring/strategy.d.ts.map +1 -1
- package/dist/engines/scoring/strategy.js +51 -2
- package/dist/engines/scoring/strategy.js.map +1 -1
- package/dist/engines/scoring/types.d.ts +16 -0
- package/dist/engines/scoring/types.d.ts.map +1 -1
- package/dist/engines/sequential/compiler.d.ts.map +1 -1
- package/dist/engines/sequential/compiler.js +4 -4
- package/dist/engines/sequential/compiler.js.map +1 -1
- package/dist/engines/sequential/strategy.js +1 -1
- package/dist/engines/sequential/strategy.js.map +1 -1
- package/dist/engines/state-machine/compiler.js +4 -4
- package/dist/engines/state-machine/compiler.js.map +1 -1
- package/dist/engines/state-machine/strategy.d.ts.map +1 -1
- package/dist/engines/state-machine/strategy.js +2 -1
- package/dist/engines/state-machine/strategy.js.map +1 -1
- package/dist/engines/utility/compiler.d.ts.map +1 -1
- package/dist/engines/utility/compiler.js +7 -7
- package/dist/engines/utility/compiler.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/errors.ts +69 -0
- package/src/core/evaluation/decay.ts +165 -0
- package/src/core/evaluation/index.ts +13 -0
- package/src/core/index.ts +4 -0
- package/src/core/types/rule.ts +1 -0
- package/src/engines/backward/compiler.ts +1 -1
- package/src/engines/bayesian/compiler.ts +24 -10
- package/src/engines/bayesian/strategy.ts +61 -10
- package/src/engines/bayesian/types.ts +17 -0
- package/src/engines/constraint/compiler.ts +12 -11
- package/src/engines/defeasible/compiler.ts +18 -3
- package/src/engines/defeasible/strategy.ts +62 -2
- package/src/engines/defeasible/types.ts +33 -0
- package/src/engines/expert/compiler.ts +8 -7
- package/src/engines/forward/compiler.ts +6 -5
- package/src/engines/forward/strategy.ts +6 -5
- package/src/engines/fuzzy/compiler.ts +1 -1
- package/src/engines/fuzzy/strategy.ts +9 -9
- package/src/engines/monte-carlo/compiler.ts +10 -9
- package/src/engines/monte-carlo/strategy.ts +2 -2
- package/src/engines/pricing/compiler.ts +11 -10
- package/src/engines/pricing/strategy.ts +7 -7
- package/src/engines/pricing/types.ts +2 -0
- package/src/engines/scoring/compiler.ts +27 -11
- package/src/engines/scoring/strategy.ts +67 -3
- package/src/engines/scoring/types.ts +17 -0
- package/src/engines/sequential/compiler.ts +6 -5
- package/src/engines/sequential/strategy.ts +2 -2
- package/src/engines/state-machine/compiler.ts +5 -5
- package/src/engines/state-machine/strategy.ts +3 -1
- package/src/engines/utility/compiler.ts +9 -8
- package/src/index.ts +16 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/engines/utility/compiler.ts"],"names":[],"mappings":";AAAA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../src/engines/utility/compiler.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAoIH,gDAkBC;AAMD,sDAkDC;AA5MD,qCAKoB;AAEpB,mCAUiB;AAEjB,2CAA2C;AAC3C,mBAAmB;AACnB,2CAA2C;AAE3C,SAAS,eAAe,CAAC,SAAe;IACtC,IAAI,CAAC,SAAS;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,CAAM,EAAE,EAAE,CAAC,GAAG,GAAG,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAa,EAAE,KAAW;IACrD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;IAC5B,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG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C,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACnG,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -53,5 +53,9 @@ export type { ExpertRule, ExpertRuleSet, ExpertConfig, ExplainBlock, CompiledExp
|
|
|
53
53
|
export { PricingStrategy, compilePricingRuleSet, compilePricingRule, pricingStrategy, pricingEngine, calculateFlat, calculateGraduated, calculateVolume, formatCurrency, formatNumber, formatPercent, round, calculateDiscount, applyMinMax, CURRENCIES, getCurrencyInfo } from './engines/pricing';
|
|
54
54
|
export type { CurrencyCode, CurrencyInfo, PricingRule, PricingRuleSet, PricingConfig, PricingComponent, PricingMode, PricingInput, PricingPackage, FlatPricing, GraduatedTier, GraduatedPricing, VolumeBracket, VolumePricing, Meter, MultiMeterPricing, FormulaPricing, Adjustment, DiscountAdjustment, MinimumAdjustment, MaximumAdjustment, Metric, ScenarioDefinition, ScenarioDefinitions, AttributeSchema, ProductType, ResolvedPricingConfig, CompiledPricingRuleSet, CompiledPricingRule, CompiledPricingComponent, CompiledPricingMode, CompiledAdjustment, CompiledMetric, PricingOptions, PricingResult, ScenarioComparisonResult, ScenarioResult, ComponentResult, AdjustmentResult, TierBreakdown, MeterResult, PricingSummary, CalculatorContext, TierCalculationResult } from './engines/pricing';
|
|
55
55
|
export { soundex, nysiis, caverphone2, cosineSimilarity } from './functions';
|
|
56
|
+
export { BOEError, CompilationError, RuntimeError } from './core/errors';
|
|
57
|
+
export type { ErrorContext } from './core/errors';
|
|
58
|
+
export { calculateDecayMultiplier, resolveDecayTimestamp } from './core/evaluation/decay';
|
|
59
|
+
export type { DecayCurve, DecayTimeUnit, DecayConfig, DecayInfo } from './core/evaluation/decay';
|
|
56
60
|
export * from './qfacts';
|
|
57
61
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,cAAc,QAAQ,CAAC;AAOvB,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,YAAY,EACZ,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,SAAS,EACT,WAAW,EACZ,MAAM,oBAAoB,CAAC;AA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EAAE,MAAM,aAAa,CAAC;AAG7E,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,UAAU,EACV,aAAa,EACb,WAAW,EACX,SAAS,EACV,MAAM,yBAAyB,CAAC;AAMjC,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.compileUtilityRule = exports.compileUtilityRuleSet = exports.UtilityStrategy = exports.SEMANTIC_WEIGHTS = exports.constraintStrategy = exports.compileConstraintRuleSet = exports.ConstraintStrategy = exports.stateMachineStrategy = exports.compileStateMachineDefinition = exports.compileStateMachine = exports.StateMachineStrategy = exports.monteCarloStrategy = exports.compileMonteCarloRuleSet = exports.MonteCarloStrategy = exports.SEMANTIC_LIKELIHOODS = exports.parseLikelihood = exports.bayesianStrategy = exports.compileBayesianRule = exports.compileBayesianRuleSet = exports.BayesianStrategy = exports.autoAdjustCoverage = exports.analyzeCoverage = exports.compileFuzzyVariable = exports.fuzzyStrategy = exports.compileFuzzyRuleSet = exports.FuzzyStrategy = exports.sequentialStrategy = exports.compileSequentialRuleSet = exports.SequentialStrategy = exports.scoringStrategy = exports.compileScoringRuleSet = exports.ScoringStrategy = exports.backwardStrategy = exports.compileBackwardRuleSet = exports.BackwardChainingStrategy = exports.forwardStrategy = exports.compileForwardRule = exports.compileForwardRuleSet = exports.ForwardChainingStrategy = exports.PricingEngine = exports.UtilityEngine = exports.ConstraintEngine = exports.StateMachineEngine = exports.MonteCarloEngine = exports.BayesianEngine = exports.FuzzyEngine = exports.SequentialEngine = exports.ScoringEngine = exports.BackwardEngine = exports.ForwardEngine = void 0;
|
|
33
|
-
exports.cosineSimilarity = exports.caverphone2 = exports.nysiis = exports.soundex = exports.getCurrencyInfo = exports.CURRENCIES = exports.applyMinMax = exports.calculateDiscount = exports.round = exports.formatPercent = exports.formatNumber = exports.formatCurrency = exports.calculateVolume = exports.calculateGraduated = exports.calculateFlat = exports.pricingEngine = exports.pricingStrategy = exports.compilePricingRule = exports.compilePricingRuleSet = exports.PricingStrategy = exports.buildAvailableRefs = exports.hasInterpolation = exports.interpolate = exports.compileTemplate = exports.expertStrategy = exports.compileExpertRuleSet = exports.ExpertStrategy = exports.ExpertEngine = exports.compileDefeasibleRuleSet = exports.DefeasibleEngine = exports.utilityStrategy = void 0;
|
|
33
|
+
exports.resolveDecayTimestamp = exports.calculateDecayMultiplier = exports.RuntimeError = exports.CompilationError = exports.BOEError = exports.cosineSimilarity = exports.caverphone2 = exports.nysiis = exports.soundex = exports.getCurrencyInfo = exports.CURRENCIES = exports.applyMinMax = exports.calculateDiscount = exports.round = exports.formatPercent = exports.formatNumber = exports.formatCurrency = exports.calculateVolume = exports.calculateGraduated = exports.calculateFlat = exports.pricingEngine = exports.pricingStrategy = exports.compilePricingRule = exports.compilePricingRuleSet = exports.PricingStrategy = exports.buildAvailableRefs = exports.hasInterpolation = exports.interpolate = exports.compileTemplate = exports.expertStrategy = exports.compileExpertRuleSet = exports.ExpertStrategy = exports.ExpertEngine = exports.compileDefeasibleRuleSet = exports.DefeasibleEngine = exports.utilityStrategy = void 0;
|
|
34
34
|
// ========================================
|
|
35
35
|
// Engines
|
|
36
36
|
// ========================================
|
|
@@ -169,6 +169,15 @@ Object.defineProperty(exports, "soundex", { enumerable: true, get: function () {
|
|
|
169
169
|
Object.defineProperty(exports, "nysiis", { enumerable: true, get: function () { return functions_1.nysiis; } });
|
|
170
170
|
Object.defineProperty(exports, "caverphone2", { enumerable: true, get: function () { return functions_1.caverphone2; } });
|
|
171
171
|
Object.defineProperty(exports, "cosineSimilarity", { enumerable: true, get: function () { return functions_1.cosineSimilarity; } });
|
|
172
|
+
// Typed Errors (re-exported from core for convenience)
|
|
173
|
+
var errors_1 = require("./core/errors");
|
|
174
|
+
Object.defineProperty(exports, "BOEError", { enumerable: true, get: function () { return errors_1.BOEError; } });
|
|
175
|
+
Object.defineProperty(exports, "CompilationError", { enumerable: true, get: function () { return errors_1.CompilationError; } });
|
|
176
|
+
Object.defineProperty(exports, "RuntimeError", { enumerable: true, get: function () { return errors_1.RuntimeError; } });
|
|
177
|
+
// Temporal Decay (re-exported from core for convenience)
|
|
178
|
+
var decay_1 = require("./core/evaluation/decay");
|
|
179
|
+
Object.defineProperty(exports, "calculateDecayMultiplier", { enumerable: true, get: function () { return decay_1.calculateDecayMultiplier; } });
|
|
180
|
+
Object.defineProperty(exports, "resolveDecayTimestamp", { enumerable: true, get: function () { return decay_1.resolveDecayTimestamp; } });
|
|
172
181
|
// ========================================
|
|
173
182
|
// QFacts - Probabilistic Fact Hydration
|
|
174
183
|
// ========================================
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;AAEH,2CAA2C;AAC3C,UAAU;AACV,2CAA2C;AAE3C,iEAAiE;AACjE,6CAAkD;AAAzC,wGAAA,aAAa,OAAA;AACtB,+CAAoD;AAA3C,0GAAA,cAAc,OAAA;AACvB,6CAAkD;AAAzC,wGAAA,aAAa,OAAA;AACtB,mDAAwD;AAA/C,8GAAA,gBAAgB,OAAA;AACzB,yCAA8C;AAArC,oGAAA,WAAW,OAAA;AACpB,+CAAoD;AAA3C,0GAAA,cAAc,OAAA;AACvB,qDAAyD;AAAhD,+GAAA,gBAAgB,OAAA;AACzB,yDAA6D;AAApD,mHAAA,kBAAkB,OAAA;AAC3B,mDAAwD;AAA/C,8GAAA,gBAAgB,OAAA;AACzB,6CAAkD;AAAz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cAAc,OAAA;AACd,yGAAA,eAAe,OAAA;AACf,qGAAA,WAAW,OAAA;AACX,0GAAA,gBAAgB,OAAA;AAChB,4GAAA,kBAAkB,OAAA;AAkBpB,2CAA2C;AAC3C,oEAAoE;AACpE,2CAA2C;AAE3C,iBAAiB;AACjB,6CAkB2B;AAjBzB,0GAAA,eAAe,OAAA;AACf,gHAAA,qBAAqB,OAAA;AACrB,6GAAA,kBAAkB,OAAA;AAClB,0GAAA,eAAe,OAAA;AACf,wGAAA,aAAa,OAAA;AACb,wGAAA,aAAa,OAAA;AACb,6GAAA,kBAAkB,OAAA;AAClB,0GAAA,eAAe,OAAA;AACf,yGAAA,cAAc,OAAA;AACd,uGAAA,YAAY,OAAA;AACZ,wGAAA,aAAa,OAAA;AACb,gGAAA,KAAK,OAAA;AACL,4GAAA,iBAAiB,OAAA;AACjB,sGAAA,WAAW,OAAA;AACX,qBAAqB;AACrB,qGAAA,UAAU,OAAA;AACV,0GAAA,eAAe,OAAA;AAqDjB,2CAA2C;AAC3C,oEAAoE;AACpE,2CAA2C;AAE3C,yCAA6E;AAApE,oGAAA,OAAO,OAAA;AAAE,mGAAA,MAAM,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAEvD,uDAAuD;AACvD,wCAAyE;AAAhE,kGAAA,QAAQ,OAAA;AAAE,0GAAA,gBAAgB,OAAA;AAAE,sGAAA,YAAY,OAAA;AAGjD,yDAAyD;AACzD,iDAGiC;AAF/B,iHAAA,wBAAwB,OAAA;AACxB,8GAAA,qBAAqB,OAAA;AASvB,2CAA2C;AAC3C,wCAAwC;AACxC,2CAA2C;AAE3C,2CAAyB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@higher.archi/boe",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "A multi-strategy rule engine supporting forward chaining, backward chaining, scoring, sequential, fuzzy logic, and Bayesian inference",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BOE Typed Error Hierarchy
|
|
3
|
+
*
|
|
4
|
+
* Distinguishes compilation errors (fix your ruleset) from runtime errors
|
|
5
|
+
* (fix your data or environment). Enables downstream consumers to use
|
|
6
|
+
* `instanceof` checks instead of string-parsing error messages.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type ErrorContext = {
|
|
10
|
+
engine?: string;
|
|
11
|
+
ruleId?: string;
|
|
12
|
+
ruleSetId?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Base error class for all BOE errors.
|
|
17
|
+
*
|
|
18
|
+
* Carries optional structured context (engine name, rule ID, ruleset ID)
|
|
19
|
+
* and a `phase` discriminant for catch-all handlers.
|
|
20
|
+
*/
|
|
21
|
+
export class BOEError extends Error {
|
|
22
|
+
public readonly engine?: string;
|
|
23
|
+
public readonly ruleId?: string;
|
|
24
|
+
public readonly ruleSetId?: string;
|
|
25
|
+
public readonly phase: 'compilation' | 'runtime';
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
message: string,
|
|
29
|
+
context?: ErrorContext & { phase?: 'compilation' | 'runtime' }
|
|
30
|
+
) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'BOEError';
|
|
33
|
+
this.engine = context?.engine;
|
|
34
|
+
this.ruleId = context?.ruleId;
|
|
35
|
+
this.ruleSetId = context?.ruleSetId;
|
|
36
|
+
this.phase = context?.phase ?? 'runtime';
|
|
37
|
+
Object.setPrototypeOf(this, BOEError.prototype);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Thrown during ruleset compilation.
|
|
43
|
+
*
|
|
44
|
+
* Indicates a configuration or ruleset authoring problem:
|
|
45
|
+
* invalid rule references, missing categories, malformed conditions, etc.
|
|
46
|
+
* Fix the ruleset definition to resolve.
|
|
47
|
+
*/
|
|
48
|
+
export class CompilationError extends BOEError {
|
|
49
|
+
constructor(message: string, context?: ErrorContext) {
|
|
50
|
+
super(message, { ...context, phase: 'compilation' });
|
|
51
|
+
this.name = 'CompilationError';
|
|
52
|
+
Object.setPrototypeOf(this, CompilationError.prototype);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Thrown during engine execution.
|
|
58
|
+
*
|
|
59
|
+
* Indicates a data or environment problem:
|
|
60
|
+
* missing facts, type mismatches, unresolvable references, etc.
|
|
61
|
+
* Fix the input data or engine configuration to resolve.
|
|
62
|
+
*/
|
|
63
|
+
export class RuntimeError extends BOEError {
|
|
64
|
+
constructor(message: string, context?: ErrorContext) {
|
|
65
|
+
super(message, { ...context, phase: 'runtime' });
|
|
66
|
+
this.name = 'RuntimeError';
|
|
67
|
+
Object.setPrototypeOf(this, RuntimeError.prototype);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporal Decay Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides continuous decay multipliers (0→1) that degrade a rule's
|
|
5
|
+
* contribution based on how old its underlying data is.
|
|
6
|
+
*
|
|
7
|
+
* Complementary to temporal validity (binary gate) — validity runs first,
|
|
8
|
+
* decay modifies strength continuously.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { BindingContext, Fact } from '../types';
|
|
12
|
+
|
|
13
|
+
// ========================================
|
|
14
|
+
// Types
|
|
15
|
+
// ========================================
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Decay curve shape
|
|
19
|
+
* - exponential: e^(-ln(2)/halfLife * age), smooth asymptotic decay
|
|
20
|
+
* - linear: 1 - age/maxAge, straight-line to zero
|
|
21
|
+
* - step: binary cutoff at threshold age
|
|
22
|
+
*/
|
|
23
|
+
export type DecayCurve = 'exponential' | 'linear' | 'step';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Time unit for decay calculations
|
|
27
|
+
*/
|
|
28
|
+
export type DecayTimeUnit = 'hours' | 'days' | 'weeks' | 'months';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for temporal decay
|
|
32
|
+
*/
|
|
33
|
+
export type DecayConfig = {
|
|
34
|
+
curve: DecayCurve;
|
|
35
|
+
timeUnit: DecayTimeUnit;
|
|
36
|
+
halfLife?: number; // exponential: age at which multiplier = 0.5
|
|
37
|
+
maxAge?: number; // linear: age at which multiplier = 0
|
|
38
|
+
threshold?: number; // step: binary cutoff age
|
|
39
|
+
floor?: number; // minimum multiplier (default 0)
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Decay calculation result with audit trail
|
|
44
|
+
*/
|
|
45
|
+
export type DecayInfo = {
|
|
46
|
+
multiplier: number;
|
|
47
|
+
ageInUnits: number;
|
|
48
|
+
curve: DecayCurve;
|
|
49
|
+
timestamp: string; // resolved ISO timestamp
|
|
50
|
+
fullyDecayed: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// ========================================
|
|
54
|
+
// Time Unit Conversion
|
|
55
|
+
// ========================================
|
|
56
|
+
|
|
57
|
+
const MS_PER_HOUR = 3_600_000;
|
|
58
|
+
const MS_PER_DAY = 86_400_000;
|
|
59
|
+
const MS_PER_WEEK = 604_800_000;
|
|
60
|
+
const MS_PER_MONTH = 2_592_000_000; // 30 days
|
|
61
|
+
|
|
62
|
+
function msPerUnit(unit: DecayTimeUnit): number {
|
|
63
|
+
switch (unit) {
|
|
64
|
+
case 'hours': return MS_PER_HOUR;
|
|
65
|
+
case 'days': return MS_PER_DAY;
|
|
66
|
+
case 'weeks': return MS_PER_WEEK;
|
|
67
|
+
case 'months': return MS_PER_MONTH;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ========================================
|
|
72
|
+
// Core Calculation
|
|
73
|
+
// ========================================
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Calculate a decay multiplier based on age and configuration
|
|
77
|
+
*
|
|
78
|
+
* @param dataTimestamp - When the data was collected/created
|
|
79
|
+
* @param now - Current time reference point
|
|
80
|
+
* @param config - Decay configuration
|
|
81
|
+
* @returns DecayInfo with multiplier and audit data
|
|
82
|
+
*/
|
|
83
|
+
export function calculateDecayMultiplier(
|
|
84
|
+
dataTimestamp: Date,
|
|
85
|
+
now: Date,
|
|
86
|
+
config: DecayConfig
|
|
87
|
+
): DecayInfo {
|
|
88
|
+
const ageMs = now.getTime() - dataTimestamp.getTime();
|
|
89
|
+
const ageInUnits = ageMs / msPerUnit(config.timeUnit);
|
|
90
|
+
const floor = config.floor ?? 0;
|
|
91
|
+
|
|
92
|
+
let rawMultiplier: number;
|
|
93
|
+
|
|
94
|
+
switch (config.curve) {
|
|
95
|
+
case 'exponential': {
|
|
96
|
+
const halfLife = config.halfLife ?? 1;
|
|
97
|
+
// e^(-ln(2)/halfLife * age)
|
|
98
|
+
rawMultiplier = Math.exp(-Math.LN2 / halfLife * ageInUnits);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
case 'linear': {
|
|
103
|
+
const maxAge = config.maxAge ?? 1;
|
|
104
|
+
rawMultiplier = 1 - ageInUnits / maxAge;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
case 'step': {
|
|
109
|
+
const threshold = config.threshold ?? 1;
|
|
110
|
+
rawMultiplier = ageInUnits < threshold ? 1.0 : 0.0;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Clamp to [floor, 1]
|
|
116
|
+
const multiplier = Math.max(floor, Math.min(1, rawMultiplier));
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
multiplier,
|
|
120
|
+
ageInUnits,
|
|
121
|
+
curve: config.curve,
|
|
122
|
+
timestamp: dataTimestamp.toISOString(),
|
|
123
|
+
fullyDecayed: multiplier <= floor
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resolve a decay timestamp from a $-prefixed path in the binding context
|
|
129
|
+
*
|
|
130
|
+
* @param ref - A $-prefixed path like '$inspection.date'
|
|
131
|
+
* @param context - The current binding context
|
|
132
|
+
* @returns Resolved Date, or null if path is missing/invalid
|
|
133
|
+
*/
|
|
134
|
+
export function resolveDecayTimestamp(ref: string, context: BindingContext): Date | null {
|
|
135
|
+
if (!ref.startsWith('$')) return null;
|
|
136
|
+
|
|
137
|
+
const stripped = ref.slice(1);
|
|
138
|
+
const parts = stripped.split('.');
|
|
139
|
+
const param = parts[0];
|
|
140
|
+
const path = parts.slice(1);
|
|
141
|
+
|
|
142
|
+
const fact = context[param] as Fact | undefined;
|
|
143
|
+
if (!fact) return null;
|
|
144
|
+
|
|
145
|
+
let value: any = fact.data;
|
|
146
|
+
for (const key of path) {
|
|
147
|
+
if (value === null || value === undefined) return null;
|
|
148
|
+
value = value[key];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (value === null || value === undefined) return null;
|
|
152
|
+
|
|
153
|
+
// Accept Date objects, ISO strings, or numeric timestamps
|
|
154
|
+
if (value instanceof Date) return value;
|
|
155
|
+
if (typeof value === 'string') {
|
|
156
|
+
const parsed = new Date(value);
|
|
157
|
+
return isNaN(parsed.getTime()) ? null : parsed;
|
|
158
|
+
}
|
|
159
|
+
if (typeof value === 'number') {
|
|
160
|
+
const parsed = new Date(value);
|
|
161
|
+
return isNaN(parsed.getTime()) ? null : parsed;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
@@ -18,3 +18,16 @@ export {
|
|
|
18
18
|
getRuleTemporalInfo,
|
|
19
19
|
RulesetMetadata
|
|
20
20
|
} from './temporal';
|
|
21
|
+
|
|
22
|
+
// Temporal decay utilities
|
|
23
|
+
export {
|
|
24
|
+
calculateDecayMultiplier,
|
|
25
|
+
resolveDecayTimestamp
|
|
26
|
+
} from './decay';
|
|
27
|
+
|
|
28
|
+
export type {
|
|
29
|
+
DecayCurve,
|
|
30
|
+
DecayTimeUnit,
|
|
31
|
+
DecayConfig,
|
|
32
|
+
DecayInfo
|
|
33
|
+
} from './decay';
|
package/src/core/index.ts
CHANGED
package/src/core/types/rule.ts
CHANGED
|
@@ -43,6 +43,7 @@ export type BaseRule = {
|
|
|
43
43
|
id: string; // Unique identifier (system-generated or explicit)
|
|
44
44
|
name?: string; // Optional human-readable name
|
|
45
45
|
salience?: number;
|
|
46
|
+
disabled?: boolean; // Skip this rule during compilation (default: false)
|
|
46
47
|
inputs: InputParameter[];
|
|
47
48
|
when?: Condition; // Join condition (renamed from 'where' for better readability)
|
|
48
49
|
|
|
@@ -112,7 +112,7 @@ export function compileBackwardRuleSet(ruleSet: BackwardRuleSet): CompiledBackwa
|
|
|
112
112
|
name: ruleSet.name,
|
|
113
113
|
mode: 'backward',
|
|
114
114
|
schema: ruleSet.shape ? normalizeShape(ruleSet.shape) : { type: 'object' },
|
|
115
|
-
rules: ruleSet.rules.map((rule, index) => compileBackwardRule(rule, index)),
|
|
115
|
+
rules: ruleSet.rules.filter(r => !r.disabled).map((rule, index) => compileBackwardRule(rule, index)),
|
|
116
116
|
config
|
|
117
117
|
};
|
|
118
118
|
}
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
compileCondition,
|
|
10
10
|
normalizeShape,
|
|
11
11
|
Expression,
|
|
12
|
-
parsePath
|
|
12
|
+
parsePath,
|
|
13
|
+
CompilationError
|
|
13
14
|
} from '../../core';
|
|
14
15
|
|
|
15
16
|
import {
|
|
@@ -117,7 +118,7 @@ export function parseLikelihood(value: LikelihoodValue): number {
|
|
|
117
118
|
return sign === '+' ? n : 1 / n;
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
throw new
|
|
121
|
+
throw new CompilationError(`Invalid likelihood string: ${value}`);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
// Object format
|
|
@@ -130,7 +131,7 @@ export function parseLikelihood(value: LikelihoodValue): number {
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
throw new
|
|
134
|
+
throw new CompilationError(`Invalid likelihood format: ${JSON.stringify(value)}`);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
/**
|
|
@@ -146,7 +147,7 @@ function compileLikelihoodMap(
|
|
|
146
147
|
for (const [hypothesis, value] of Object.entries(likelihood)) {
|
|
147
148
|
// Validate hypothesis exists
|
|
148
149
|
if (!hypothesisNames.has(hypothesis)) {
|
|
149
|
-
throw new
|
|
150
|
+
throw new CompilationError(
|
|
150
151
|
`Rule "${ruleId}" references unknown hypothesis "${hypothesis}". ` +
|
|
151
152
|
`Available: ${Array.from(hypothesisNames).join(', ')}`
|
|
152
153
|
);
|
|
@@ -192,7 +193,7 @@ function compilePrior(prior: PriorValue | undefined): number | any {
|
|
|
192
193
|
return compileCondition(prior as Expression);
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
throw new
|
|
196
|
+
throw new CompilationError(`Invalid prior value: ${JSON.stringify(prior)}`);
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
/**
|
|
@@ -274,7 +275,7 @@ function compileHypotheses(
|
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
default:
|
|
277
|
-
throw new
|
|
278
|
+
throw new CompilationError(`Unknown priorDefault strategy: ${priorDefault}`);
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
|
|
@@ -326,7 +327,7 @@ function validatePriorInputs(
|
|
|
326
327
|
|
|
327
328
|
for (const ref of priorRefs) {
|
|
328
329
|
if (!declaredNames.has(ref)) {
|
|
329
|
-
throw new
|
|
330
|
+
throw new CompilationError(
|
|
330
331
|
`RuleSet "${ruleSetId}": Hypothesis prior references '$${ref}' but no input declared. ` +
|
|
331
332
|
`Add: inputs: [{ name: '${ref}', type: '...' }]`
|
|
332
333
|
);
|
|
@@ -346,6 +347,17 @@ export function compileBayesianRule(
|
|
|
346
347
|
const inputs = rule.inputs.map(compileInputParameter);
|
|
347
348
|
const when = rule.when ? compileCondition(rule.when) : undefined;
|
|
348
349
|
|
|
350
|
+
// Compile decay — only pass through $-prefixed string timestamps
|
|
351
|
+
let compiledDecay: { timestamp: string; config?: any } | undefined;
|
|
352
|
+
if (rule.decay) {
|
|
353
|
+
const ts = rule.decay.timestamp;
|
|
354
|
+
if (typeof ts === 'string') {
|
|
355
|
+
compiledDecay = { timestamp: ts, config: rule.decay.config };
|
|
356
|
+
}
|
|
357
|
+
// Expression timestamps for Bayesian are not supported (would need runtime eval);
|
|
358
|
+
// only $-prefixed paths are supported
|
|
359
|
+
}
|
|
360
|
+
|
|
349
361
|
return {
|
|
350
362
|
id: rule.id,
|
|
351
363
|
name: rule.name,
|
|
@@ -354,7 +366,8 @@ export function compileBayesianRule(
|
|
|
354
366
|
index,
|
|
355
367
|
inputs,
|
|
356
368
|
when,
|
|
357
|
-
likelihood: compileLikelihoodMap(rule.likelihood, hypothesisNames, rule.id)
|
|
369
|
+
likelihood: compileLikelihoodMap(rule.likelihood, hypothesisNames, rule.id),
|
|
370
|
+
decay: compiledDecay
|
|
358
371
|
};
|
|
359
372
|
}
|
|
360
373
|
|
|
@@ -370,7 +383,8 @@ export function compileBayesianRuleSet(ruleSet: BayesianRuleSet): CompiledBayesi
|
|
|
370
383
|
const config: BayesianConfig = {
|
|
371
384
|
mode: 'bayesian',
|
|
372
385
|
threshold: ruleSet.config?.threshold,
|
|
373
|
-
priorDefault: ruleSet.config?.priorDefault ?? 'uniform'
|
|
386
|
+
priorDefault: ruleSet.config?.priorDefault ?? 'uniform',
|
|
387
|
+
decay: ruleSet.config?.decay
|
|
374
388
|
};
|
|
375
389
|
|
|
376
390
|
// Get hypothesis names for validation
|
|
@@ -385,7 +399,7 @@ export function compileBayesianRuleSet(ruleSet: BayesianRuleSet): CompiledBayesi
|
|
|
385
399
|
);
|
|
386
400
|
|
|
387
401
|
// Compile rules
|
|
388
|
-
const rules = ruleSet.rules.map((rule, index) =>
|
|
402
|
+
const rules = ruleSet.rules.filter(r => !r.disabled).map((rule, index) =>
|
|
389
403
|
compileBayesianRule(rule, index, hypothesisNames)
|
|
390
404
|
);
|
|
391
405
|
|
|
@@ -10,9 +10,16 @@ import {
|
|
|
10
10
|
evaluateCondition,
|
|
11
11
|
BindingContext,
|
|
12
12
|
CompiledPath,
|
|
13
|
-
Fact
|
|
13
|
+
Fact,
|
|
14
|
+
RuntimeError
|
|
14
15
|
} from '../../core';
|
|
15
16
|
import { IWorkingMemory } from '../../core/memory';
|
|
17
|
+
import {
|
|
18
|
+
calculateDecayMultiplier,
|
|
19
|
+
resolveDecayTimestamp,
|
|
20
|
+
DecayConfig,
|
|
21
|
+
DecayInfo
|
|
22
|
+
} from '../../core/evaluation/decay';
|
|
16
23
|
|
|
17
24
|
import {
|
|
18
25
|
CompiledBayesianRuleSet,
|
|
@@ -40,13 +47,13 @@ function isCompiledPath(value: any): value is CompiledPath {
|
|
|
40
47
|
function resolvePathValue(compiledPath: CompiledPath, context: BindingContext): any {
|
|
41
48
|
const fact = context[compiledPath.param] as Fact | undefined;
|
|
42
49
|
if (!fact) {
|
|
43
|
-
throw new
|
|
50
|
+
throw new RuntimeError(`No fact bound to '${compiledPath.param}' for prior resolution`);
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
let value: any = fact.data;
|
|
47
54
|
for (const key of compiledPath.path) {
|
|
48
55
|
if (value === undefined || value === null) {
|
|
49
|
-
throw new
|
|
56
|
+
throw new RuntimeError(`Cannot resolve path '${compiledPath.param}.${compiledPath.path.join('.')}': intermediate value is ${value}`);
|
|
50
57
|
}
|
|
51
58
|
value = value[key];
|
|
52
59
|
}
|
|
@@ -75,7 +82,7 @@ function resolvePrior(
|
|
|
75
82
|
if (isCompiledPath(prior)) {
|
|
76
83
|
const value = resolvePathValue(prior, context);
|
|
77
84
|
if (typeof value !== 'number') {
|
|
78
|
-
throw new
|
|
85
|
+
throw new RuntimeError(`Prior path '${prior.param}.${prior.path.join('.')}' must resolve to a number, got: ${typeof value}`);
|
|
79
86
|
}
|
|
80
87
|
return value;
|
|
81
88
|
}
|
|
@@ -84,12 +91,12 @@ function resolvePrior(
|
|
|
84
91
|
if (typeof prior === 'object' && prior !== null && 'op' in prior) {
|
|
85
92
|
const result = evaluateCondition(prior, context);
|
|
86
93
|
if (typeof result !== 'number') {
|
|
87
|
-
throw new
|
|
94
|
+
throw new RuntimeError(`Prior expression must evaluate to a number, got: ${typeof result}`);
|
|
88
95
|
}
|
|
89
96
|
return result;
|
|
90
97
|
}
|
|
91
98
|
|
|
92
|
-
throw new
|
|
99
|
+
throw new RuntimeError(`Invalid prior value at runtime: ${JSON.stringify(prior)}`);
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
/**
|
|
@@ -191,6 +198,8 @@ export class BayesianStrategy {
|
|
|
191
198
|
const fired: string[] = [];
|
|
192
199
|
const evidence: EvidenceEntry[] = [];
|
|
193
200
|
let thresholdExceeded: string | undefined;
|
|
201
|
+
const decayInfoMap: Record<string, DecayInfo> = {};
|
|
202
|
+
const now = new Date();
|
|
194
203
|
|
|
195
204
|
// Track which hypotheses were below threshold initially
|
|
196
205
|
// (so we can detect when they cross it)
|
|
@@ -213,20 +222,59 @@ export class BayesianStrategy {
|
|
|
213
222
|
fired.push(rule.id);
|
|
214
223
|
}
|
|
215
224
|
|
|
225
|
+
// Compute decay for this rule's evidence
|
|
226
|
+
let effectiveLikelihoods = rule.likelihood;
|
|
227
|
+
let likelihoodsBeforeDecay: CompiledLikelihoodMap | undefined;
|
|
228
|
+
let ruleDecayInfo: DecayInfo | undefined;
|
|
229
|
+
|
|
230
|
+
const ruleDecay = rule.decay;
|
|
231
|
+
const engineDecay = config.decay;
|
|
232
|
+
|
|
233
|
+
if (ruleDecay || engineDecay) {
|
|
234
|
+
const tsRef = ruleDecay?.timestamp ?? (engineDecay?.timestamp as string | undefined);
|
|
235
|
+
|
|
236
|
+
if (typeof tsRef === 'string') {
|
|
237
|
+
const dataTimestamp = resolveDecayTimestamp(tsRef, activation.facts);
|
|
238
|
+
|
|
239
|
+
if (dataTimestamp) {
|
|
240
|
+
const decayConfig: DecayConfig = {
|
|
241
|
+
...(engineDecay?.config ?? { curve: 'exponential', timeUnit: 'days' }),
|
|
242
|
+
...ruleDecay?.config
|
|
243
|
+
} as DecayConfig;
|
|
244
|
+
|
|
245
|
+
const info = calculateDecayMultiplier(dataTimestamp, now, decayConfig);
|
|
246
|
+
ruleDecayInfo = info;
|
|
247
|
+
decayInfoMap[rule.id] = info;
|
|
248
|
+
|
|
249
|
+
// Decay likelihoods toward 1.0 (neutral)
|
|
250
|
+
// decayedLikelihood = 1.0 + (originalLikelihood - 1.0) * multiplier
|
|
251
|
+
if (info.multiplier < 1.0) {
|
|
252
|
+
likelihoodsBeforeDecay = { ...rule.likelihood };
|
|
253
|
+
effectiveLikelihoods = {};
|
|
254
|
+
for (const [h, lh] of Object.entries(rule.likelihood)) {
|
|
255
|
+
effectiveLikelihoods[h] = 1.0 + (lh - 1.0) * info.multiplier;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
216
262
|
// Record evidence
|
|
217
263
|
evidence.push({
|
|
218
264
|
ruleId: rule.id,
|
|
219
265
|
ruleName: rule.name,
|
|
220
|
-
likelihoods:
|
|
266
|
+
likelihoods: effectiveLikelihoods,
|
|
267
|
+
likelihoodsBeforeDecay,
|
|
268
|
+
decayInfo: ruleDecayInfo
|
|
221
269
|
});
|
|
222
270
|
|
|
223
271
|
// Callback
|
|
224
272
|
if (onFire) {
|
|
225
|
-
onFire(rule.id, activation.facts,
|
|
273
|
+
onFire(rule.id, activation.facts, effectiveLikelihoods);
|
|
226
274
|
}
|
|
227
275
|
|
|
228
|
-
// Update posteriors with this evidence
|
|
229
|
-
posteriors = applyEvidence(posteriors,
|
|
276
|
+
// Update posteriors with this evidence (using decayed likelihoods)
|
|
277
|
+
posteriors = applyEvidence(posteriors, effectiveLikelihoods);
|
|
230
278
|
|
|
231
279
|
// Check if any hypothesis crossed the threshold (from below to above)
|
|
232
280
|
if (threshold !== undefined && thresholdExceeded === undefined) {
|
|
@@ -255,6 +303,8 @@ export class BayesianStrategy {
|
|
|
255
303
|
|
|
256
304
|
const executionTimeMs = Math.round((performance.now() - startTime) * 100) / 100;
|
|
257
305
|
|
|
306
|
+
const hasDecay = Object.keys(decayInfoMap).length > 0;
|
|
307
|
+
|
|
258
308
|
return {
|
|
259
309
|
priors: normalizedPriors,
|
|
260
310
|
posteriors,
|
|
@@ -263,6 +313,7 @@ export class BayesianStrategy {
|
|
|
263
313
|
fired,
|
|
264
314
|
evidence,
|
|
265
315
|
thresholdExceeded,
|
|
316
|
+
...(hasDecay ? { decayInfo: decayInfoMap } : {}),
|
|
266
317
|
iterations: 1,
|
|
267
318
|
executionTimeMs
|
|
268
319
|
};
|