@agent-e/core 1.1.2 → 1.1.3

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/index.js CHANGED
@@ -2576,6 +2576,10 @@ var ALL_PRINCIPLES = [
2576
2576
  var Simulator = class {
2577
2577
  constructor() {
2578
2578
  this.diagnoser = new Diagnoser(ALL_PRINCIPLES);
2579
+ // Cache beforeViolations for the *current* tick only (one entry max).
2580
+ // Using a Map here is intentional but the cache must be bounded — we only
2581
+ // care about the tick that is currently being evaluated, so we evict any
2582
+ // entries whose key differs from the incoming tick.
2579
2583
  this.beforeViolationsCache = /* @__PURE__ */ new Map();
2580
2584
  }
2581
2585
  /**
@@ -2600,6 +2604,9 @@ var Simulator = class {
2600
2604
  const mean = this.averageMetrics(outcomes);
2601
2605
  const netImprovement = this.checkImprovement(currentMetrics, p50, action);
2602
2606
  const tick = currentMetrics.tick;
2607
+ if (this.beforeViolationsCache.size > 0 && !this.beforeViolationsCache.has(tick)) {
2608
+ this.beforeViolationsCache.clear();
2609
+ }
2603
2610
  let beforeViolations = this.beforeViolationsCache.get(tick);
2604
2611
  if (!beforeViolations) {
2605
2612
  beforeViolations = new Set(