@agent-e/core 1.5.1 → 1.5.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @agent-e/core
2
2
 
3
- Autonomous economic balancer SDK. 60 built-in principles, 5-stage pipeline, zero dependencies.
3
+ Autonomous economic balancer SDK. 60 built-in principles, 5-stage pipeline, zero dependencies. Works with any digital economy.
4
4
 
5
5
  ## Install
6
6
 
@@ -13,43 +13,43 @@ npm install @agent-e/core
13
13
  ```typescript
14
14
  import { AgentE } from '@agent-e/core';
15
15
 
16
- const adapter = {
17
- getState: () => ({
18
- tick: currentTick,
19
- currencies: ['gold', 'gems'],
20
- agentBalances: {
21
- player1: { gold: 100, gems: 50 },
22
- player2: { gold: 200, gems: 10 },
23
- },
24
- agentRoles: { /* id role */ },
25
- agentInventories: { /* id → { resource → qty } */ },
26
- marketPrices: {
27
- gold: { sword: 10, potion: 5 },
28
- gems: { sword: 2, potion: 1 },
16
+ const agent = new AgentE({
17
+ adapter: {
18
+ getState: () => ({
19
+ tick: currentTick,
20
+ currencies: ['currency_a', 'currency_b'],
21
+ systems: ['system_1', 'system_2'],
22
+ agentBalances: {
23
+ agent_001: { currency_a: 500, currency_b: 20 },
24
+ agent_002: { currency_a: 120, currency_b: 80 },
25
+ },
26
+ agentRoles: { agent_001: 'role_a', agent_002: 'role_b' },
27
+ marketPrices: {
28
+ currency_a: { resource_x: 10, resource_y: 25 },
29
+ },
30
+ agentSatisfaction: { agent_001: 72, agent_002: 85 },
31
+ poolSizes: { main_pool: { currency_a: 5000 } },
32
+ roles: ['role_a', 'role_b'],
33
+ resources: ['resource_x', 'resource_y'],
34
+ recentTransactions: [],
35
+ }),
36
+ setParam: async (param, value, scope) => {
37
+ applyToYourEconomy(param, value, scope);
29
38
  },
30
- agentSatisfaction: { /* id → 0-100 */ },
31
- poolSizes: { rewardPool: { gold: 500, gems: 100 } },
32
- roles: ['warrior', 'mage'],
33
- resources: ['sword', 'potion'],
34
- recentTransactions: [],
35
- }),
36
- setParam: async (param, value, currency) => {
37
- // currency tells you which economy to adjust
38
- applyToYourEconomy(param, value, currency);
39
39
  },
40
- };
41
-
42
- const agent = new AgentE({
43
- adapter,
44
- mode: 'advisor', // or 'autonomous'
40
+ parameters: [
41
+ { key: 'your_fee_param', type: 'fee', flowImpact: 'friction', scope: { system: 'system_1' } },
42
+ { key: 'your_reward_param', type: 'reward', flowImpact: 'faucet', scope: { system: 'system_2' } },
43
+ ],
44
+ mode: 'advisor',
45
45
  });
46
46
 
47
- agent.connect(adapter).start();
48
-
49
- // Call once per tick in your loop:
47
+ agent.start();
50
48
  await agent.tick();
51
49
  ```
52
50
 
51
+ **Replace the placeholder names with YOUR economy's actual names.** See the root README for real-world examples (game, DeFi, marketplace).
52
+
53
53
  ## The 5-Stage Pipeline
54
54
 
55
55
  1. **Observer** — Translates raw state into 40+ metrics at 3 resolutions (fine/medium/coarse)
@@ -58,54 +58,75 @@ await agent.tick();
58
58
  4. **Planner** — Lag-aware, cooldown-aware planning with rollback conditions
59
59
  5. **Executor** — Applies actions and monitors for rollback triggers
60
60
 
61
- ## Multi-Currency Support
61
+ ## Parameter Registry
62
62
 
63
- AgentE tracks each currency independently. Every currency gets its own:
64
- - Supply, net flow, velocity, inflation rate
65
- - Gini coefficient, median/mean balance, wealth distribution
66
- - Faucet/sink volumes, pool sizes
67
- - Price index, arbitrage index
63
+ Register your parameters with semantic types and flow impacts:
68
64
 
69
- When a principle detects an issue, the violation tells you which currency
70
- is unhealthy and the suggested action is scoped to that currency.
65
+ ```typescript
66
+ parameters: [
67
+ // key: whatever YOU call it
68
+ // type: what kind of lever is it?
69
+ // flowImpact: what does it do to currency flow?
70
+ // scope: where in your economy does it live?
71
+
72
+ { key: 'my_fee', type: 'fee', flowImpact: 'friction', scope: { system: 'trading' } },
73
+ { key: 'my_reward', type: 'reward', flowImpact: 'faucet', scope: { system: 'engagement' } },
74
+ { key: 'my_rate', type: 'rate', flowImpact: 'sink', scope: { system: 'burning' } },
75
+ { key: 'my_yield', type: 'yield', flowImpact: 'faucet', scope: { system: 'staking', currency: 'currency_b' } },
76
+ { key: 'my_cut', type: 'fee', flowImpact: 'sink', scope: { system: 'platform', tags: ['operator'] } },
77
+ ]
78
+ ```
71
79
 
72
- ## Modes
80
+ Principles say "decrease `fee` in `trading`" — the registry resolves to `my_fee`. Your names stay yours.
73
81
 
74
- | Mode | Behavior |
75
- |------|----------|
76
- | `autonomous` | Full pipeline — executes parameter changes automatically |
77
- | `advisor` | Full pipeline but stops before execution — emits recommendations via `onDecision` |
82
+ ### Semantic Types
78
83
 
79
- ## 60 Principles
84
+ | Type | What it means |
85
+ |------|--------------|
86
+ | `cost` | Something participants pay to do an action |
87
+ | `fee` | A percentage or flat charge on transactions |
88
+ | `reward` | Something participants receive for an action |
89
+ | `yield` | Passive income from holding or staking |
90
+ | `rate` | A speed or frequency multiplier |
91
+ | `multiplier` | A scaling factor |
92
+ | `threshold` | A boundary value that triggers behavior |
93
+ | `weight` | A relative importance factor |
94
+ | `custom` | Anything else |
80
95
 
81
- Organized across 15 categories: supply chain, incentives, population, currency flow, bootstrap, feedback loops, regulator, market dynamics, measurement, statistical, system dynamics, resource management, player experience, open economy, and liveops.
96
+ ### Flow Impacts
82
97
 
83
- Each principle has a `check(metrics, thresholds)` function that returns either `{ violated: false }` or a violation with severity, evidence, suggested action, confidence, and estimated lag.
98
+ | Impact | What it does to currency flow |
99
+ |--------|------------------------------|
100
+ | `sink` | Removes currency from circulation |
101
+ | `faucet` | Adds currency to circulation |
102
+ | `friction` | Slows velocity without removing currency |
103
+ | `redistribution` | Moves currency between participants |
104
+ | `neutral` | No direct effect on flow |
84
105
 
85
- ## Tick Configuration
106
+ ## Multi-System, Multi-Currency
86
107
 
87
- ```typescript
88
- const agent = new AgentE({
89
- adapter: yourAdapter,
90
- tickConfig: {
91
- duration: 5, // one tick = 5 seconds
92
- unit: 'second',
93
- mediumWindow: 12, // medium metrics = every 12 ticks (60s)
94
- coarseWindow: 120, // coarse metrics = every 120 ticks (10min)
95
- },
96
- });
97
- ```
108
+ AgentE tracks each system and currency independently:
109
+
110
+ - Per-currency: supply, net flow, velocity, inflation, Gini, wealth distribution, faucet/sink volumes, price index
111
+ - Per-system: flow, activity, participant count
112
+ - Cross-system: arbitrage index, source/sink share analysis
113
+
114
+ ## Modes
115
+
116
+ | Mode | Behavior |
117
+ |------|----------|
118
+ | `autonomous` | Full pipeline — executes parameter changes automatically |
119
+ | `advisor` | Full pipeline but stops before execution — emits recommendations via `onDecision` |
98
120
 
99
121
  ## Developer API
100
122
 
101
123
  ```typescript
102
- // Lock a parameter from automated adjustment
103
- agent.lock('productionCost'); // lock for ALL currencies
104
- // Future: agent.lock('productionCost', 'gems'); // lock for specific currency
105
- agent.unlock('productionCost');
124
+ // Lock AgentE will never adjust this parameter
125
+ agent.lock('your_param_name');
126
+ agent.unlock('your_param_name');
106
127
 
107
- // Constrain a parameter to a range
108
- agent.constrain('transactionFee', { min: 0.01, max: 0.50 });
128
+ // Constrain AgentE can adjust, but only within this range
129
+ agent.constrain('another_param', { min: 0.01, max: 0.50 });
109
130
 
110
131
  // Add a custom principle
111
132
  agent.addPrinciple(myPrinciple);
@@ -115,7 +136,7 @@ agent.registerCustomMetric('myMetric', (state) => compute(state));
115
136
 
116
137
  // Veto actions
117
138
  agent.on('beforeAction', (plan) => {
118
- if (plan.targetValue > 2.0) return false;
139
+ if (plan.parameterType === 'reward') return false;
119
140
  });
120
141
 
121
142
  // Query decision history
@@ -135,21 +156,22 @@ import type { Principle } from '@agent-e/core';
135
156
 
136
157
  const myRule: Principle = {
137
158
  id: 'MY_01',
138
- name: 'Support Role Population Floor',
159
+ name: 'Minimum Provider Population',
139
160
  category: 'population',
140
- description: 'Support role share below 5% is a crisis',
161
+ description: 'Triggers when a critical role drops below 5% of population',
141
162
  check(metrics, thresholds) {
142
- const share = metrics.roleShares['support'] ?? 0;
163
+ const share = metrics.roleShares['role_a'] ?? 0;
143
164
  if (share < 0.05) {
144
165
  return {
145
166
  violated: true,
146
167
  severity: 8,
147
168
  evidence: { share },
148
169
  suggestedAction: {
149
- parameter: 'supportReward',
170
+ parameterType: 'reward',
171
+ scope: { tags: ['role_a'] },
150
172
  direction: 'increase',
151
173
  magnitude: 0.25,
152
- reasoning: 'Support role population critically low.',
174
+ reasoning: 'Critical role population below 5%.',
153
175
  },
154
176
  confidence: 0.90,
155
177
  estimatedLag: 10,
@@ -162,14 +184,23 @@ const myRule: Principle = {
162
184
  agent.addPrinciple(myRule);
163
185
  ```
164
186
 
187
+ ## 60 Principles
188
+
189
+ Organized across 15 categories: supply chain, incentives, population, currency flow, bootstrap, feedback loops, regulator, market dynamics, measurement, statistical, system dynamics, resource management, participant experience, open economy, and operations.
190
+
165
191
  ## Performance
166
192
 
167
193
  - **O(N) event classification** — single-pass instead of 6 separate filters
194
+ - **O(n) arbitrage index** — log-price standard deviation instead of pairwise
168
195
  - **Cached diagnosis** — no redundant principle checks within the same tick
169
- - **Numerical stability** — clamped inputs to prevent NaN edge cases
196
+ - **Numerical stability** — clamped inputs to prevent NaN/Infinity edge cases
170
197
 
171
198
  Typical for 1,000 agents, 100 events/tick: ~60ms end-to-end.
172
199
 
173
200
  ## License
174
201
 
175
202
  MIT
203
+
204
+ ---
205
+
206
+ **Built by Oka × Claude — AB Labs**
package/dist/index.d.mts CHANGED
@@ -303,7 +303,7 @@ interface Thresholds {
303
303
  maxAdjustmentPercent: number;
304
304
  cooldownTicks: number;
305
305
  poolWinRate: number;
306
- poolHouseCut: number;
306
+ poolOperatorShare: number;
307
307
  roleSwitchFrictionMax: number;
308
308
  poolCapPercent: number;
309
309
  poolDecayRate: number;
@@ -332,6 +332,16 @@ interface TickConfig {
332
332
  /** Coarse-resolution metric window in ticks. Default: 100 */
333
333
  coarseWindow?: number;
334
334
  }
335
+ interface SimulationConfig {
336
+ sinkMultiplier?: number;
337
+ faucetMultiplier?: number;
338
+ frictionMultiplier?: number;
339
+ frictionVelocityScale?: number;
340
+ redistributionMultiplier?: number;
341
+ neutralMultiplier?: number;
342
+ minIterations?: number;
343
+ maxProjectionTicks?: number;
344
+ }
335
345
  type AgentEMode = 'autonomous' | 'advisor';
336
346
  interface AgentEConfig {
337
347
  adapter: EconomyAdapter;
@@ -346,6 +356,8 @@ interface AgentEConfig {
346
356
  checkInterval?: number;
347
357
  maxAdjustmentPercent?: number;
348
358
  cooldownTicks?: number;
359
+ simulation?: SimulationConfig;
360
+ settlementWindowTicks?: number;
349
361
  thresholds?: Partial<Thresholds>;
350
362
  onDecision?: (entry: DecisionEntry) => void;
351
363
  onAlert?: (diagnosis: Diagnosis) => void;
@@ -503,8 +515,10 @@ declare class Observer {
503
515
  declare class Simulator {
504
516
  private diagnoser;
505
517
  private registry;
506
- constructor(registry?: ParameterRegistry);
507
- private beforeViolationsCache;
518
+ private simConfig;
519
+ constructor(registry?: ParameterRegistry, simConfig?: SimulationConfig);
520
+ private cachedViolationsTick;
521
+ private cachedViolations;
508
522
  /**
509
523
  * Simulate the effect of applying `action` to the current economy forward `forwardTicks`.
510
524
  * Runs `iterations` Monte Carlo trials and returns the outcome distribution.
@@ -556,12 +570,19 @@ declare class Planner {
556
570
  isOnCooldown(param: string, currentTick: number, cooldownTicks: number): boolean;
557
571
  /** Reset all cooldowns (useful for testing) */
558
572
  resetCooldowns(): void;
573
+ /** V1.5.2: Reset active plan count (e.g., on system restart) */
574
+ resetActivePlans(): void;
575
+ /** V1.5.2: Current active plan count (for diagnostics) */
576
+ getActivePlanCount(): number;
559
577
  private typeCooldownKey;
560
578
  private isTypeCooldown;
561
579
  }
562
580
 
581
+ type ExecutionResult = 'applied' | 'rolled_back' | 'rollback_skipped';
563
582
  declare class Executor {
564
583
  private activePlans;
584
+ private maxActiveTicks;
585
+ constructor(settlementWindowTicks?: number);
565
586
  apply(plan: ActionPlan, adapter: EconomyAdapter, currentParams: Record<string, number>): Promise<void>;
566
587
  /**
567
588
  * Check all active plans for rollback conditions.
@@ -577,6 +598,7 @@ declare class Executor {
577
598
 
578
599
  declare class PersonaTracker {
579
600
  private agentHistory;
601
+ private lastSeen;
580
602
  /** Ingest a state snapshot and update agent signal history */
581
603
  update(state: EconomyState): void;
582
604
  /** Classify all agents and return persona distribution */
@@ -628,7 +650,7 @@ declare const P4_MaterialsFlowFasterThanCooldown: Principle;
628
650
  declare const P60_SurplusDisposalAsymmetry: Principle;
629
651
  declare const SUPPLY_CHAIN_PRINCIPLES: Principle[];
630
652
 
631
- declare const P5_ProfitabilityIsCompetitive: Principle;
653
+ declare const P5_ProfitabilityIsRelative: Principle;
632
654
  declare const P6_CrowdingMultiplierOnAllRoles: Principle;
633
655
  declare const P7_NonSpecialistsSubsidiseSpecialists: Principle;
634
656
  declare const P8_RegulatorCannotFightDesign: Principle;
@@ -714,4 +736,4 @@ declare const OPERATIONS_PRINCIPLES: Principle[];
714
736
  /** All 60 built-in principles in priority order (supply chain → operations) */
715
737
  declare const ALL_PRINCIPLES: Principle[];
716
738
 
717
- export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, Executor, FEEDBACK_LOOP_PRINCIPLES, type FlowImpact, INCENTIVE_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, OPERATIONS_PRINCIPLES, Observer, P10_EntryWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_BottleneckDetection, P2_ClosedLoopsNeedDirectHandoff, P30_DynamicBottleneckRotation, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_CyclicalEngagement, P52_EndowmentEffect, P53_EventCompletionRate, P54_OperationalCadence, P55_ArbitrageThermometer, P56_SupplyShockAbsorption, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsCompetitive, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PARTICIPANT_EXPERIENCE_PRINCIPLES, PERSONA_HEALTHY_RANGES, POPULATION_PRINCIPLES, ParameterRegistry, type ParameterScope, type ParameterType, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RegisteredParameter, type RegistryValidationResult, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, findWorstSystem, validateEconomyState };
739
+ export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, type ExecutionResult, Executor, FEEDBACK_LOOP_PRINCIPLES, type FlowImpact, INCENTIVE_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, OPERATIONS_PRINCIPLES, Observer, P10_EntryWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_BottleneckDetection, P2_ClosedLoopsNeedDirectHandoff, P30_DynamicBottleneckRotation, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_CyclicalEngagement, P52_EndowmentEffect, P53_EventCompletionRate, P54_OperationalCadence, P55_ArbitrageThermometer, P56_SupplyShockAbsorption, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsRelative, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PARTICIPANT_EXPERIENCE_PRINCIPLES, PERSONA_HEALTHY_RANGES, POPULATION_PRINCIPLES, ParameterRegistry, type ParameterScope, type ParameterType, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RegisteredParameter, type RegistryValidationResult, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationConfig, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, findWorstSystem, validateEconomyState };
package/dist/index.d.ts CHANGED
@@ -303,7 +303,7 @@ interface Thresholds {
303
303
  maxAdjustmentPercent: number;
304
304
  cooldownTicks: number;
305
305
  poolWinRate: number;
306
- poolHouseCut: number;
306
+ poolOperatorShare: number;
307
307
  roleSwitchFrictionMax: number;
308
308
  poolCapPercent: number;
309
309
  poolDecayRate: number;
@@ -332,6 +332,16 @@ interface TickConfig {
332
332
  /** Coarse-resolution metric window in ticks. Default: 100 */
333
333
  coarseWindow?: number;
334
334
  }
335
+ interface SimulationConfig {
336
+ sinkMultiplier?: number;
337
+ faucetMultiplier?: number;
338
+ frictionMultiplier?: number;
339
+ frictionVelocityScale?: number;
340
+ redistributionMultiplier?: number;
341
+ neutralMultiplier?: number;
342
+ minIterations?: number;
343
+ maxProjectionTicks?: number;
344
+ }
335
345
  type AgentEMode = 'autonomous' | 'advisor';
336
346
  interface AgentEConfig {
337
347
  adapter: EconomyAdapter;
@@ -346,6 +356,8 @@ interface AgentEConfig {
346
356
  checkInterval?: number;
347
357
  maxAdjustmentPercent?: number;
348
358
  cooldownTicks?: number;
359
+ simulation?: SimulationConfig;
360
+ settlementWindowTicks?: number;
349
361
  thresholds?: Partial<Thresholds>;
350
362
  onDecision?: (entry: DecisionEntry) => void;
351
363
  onAlert?: (diagnosis: Diagnosis) => void;
@@ -503,8 +515,10 @@ declare class Observer {
503
515
  declare class Simulator {
504
516
  private diagnoser;
505
517
  private registry;
506
- constructor(registry?: ParameterRegistry);
507
- private beforeViolationsCache;
518
+ private simConfig;
519
+ constructor(registry?: ParameterRegistry, simConfig?: SimulationConfig);
520
+ private cachedViolationsTick;
521
+ private cachedViolations;
508
522
  /**
509
523
  * Simulate the effect of applying `action` to the current economy forward `forwardTicks`.
510
524
  * Runs `iterations` Monte Carlo trials and returns the outcome distribution.
@@ -556,12 +570,19 @@ declare class Planner {
556
570
  isOnCooldown(param: string, currentTick: number, cooldownTicks: number): boolean;
557
571
  /** Reset all cooldowns (useful for testing) */
558
572
  resetCooldowns(): void;
573
+ /** V1.5.2: Reset active plan count (e.g., on system restart) */
574
+ resetActivePlans(): void;
575
+ /** V1.5.2: Current active plan count (for diagnostics) */
576
+ getActivePlanCount(): number;
559
577
  private typeCooldownKey;
560
578
  private isTypeCooldown;
561
579
  }
562
580
 
581
+ type ExecutionResult = 'applied' | 'rolled_back' | 'rollback_skipped';
563
582
  declare class Executor {
564
583
  private activePlans;
584
+ private maxActiveTicks;
585
+ constructor(settlementWindowTicks?: number);
565
586
  apply(plan: ActionPlan, adapter: EconomyAdapter, currentParams: Record<string, number>): Promise<void>;
566
587
  /**
567
588
  * Check all active plans for rollback conditions.
@@ -577,6 +598,7 @@ declare class Executor {
577
598
 
578
599
  declare class PersonaTracker {
579
600
  private agentHistory;
601
+ private lastSeen;
580
602
  /** Ingest a state snapshot and update agent signal history */
581
603
  update(state: EconomyState): void;
582
604
  /** Classify all agents and return persona distribution */
@@ -628,7 +650,7 @@ declare const P4_MaterialsFlowFasterThanCooldown: Principle;
628
650
  declare const P60_SurplusDisposalAsymmetry: Principle;
629
651
  declare const SUPPLY_CHAIN_PRINCIPLES: Principle[];
630
652
 
631
- declare const P5_ProfitabilityIsCompetitive: Principle;
653
+ declare const P5_ProfitabilityIsRelative: Principle;
632
654
  declare const P6_CrowdingMultiplierOnAllRoles: Principle;
633
655
  declare const P7_NonSpecialistsSubsidiseSpecialists: Principle;
634
656
  declare const P8_RegulatorCannotFightDesign: Principle;
@@ -714,4 +736,4 @@ declare const OPERATIONS_PRINCIPLES: Principle[];
714
736
  /** All 60 built-in principles in priority order (supply chain → operations) */
715
737
  declare const ALL_PRINCIPLES: Principle[];
716
738
 
717
- export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, Executor, FEEDBACK_LOOP_PRINCIPLES, type FlowImpact, INCENTIVE_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, OPERATIONS_PRINCIPLES, Observer, P10_EntryWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_BottleneckDetection, P2_ClosedLoopsNeedDirectHandoff, P30_DynamicBottleneckRotation, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_CyclicalEngagement, P52_EndowmentEffect, P53_EventCompletionRate, P54_OperationalCadence, P55_ArbitrageThermometer, P56_SupplyShockAbsorption, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsCompetitive, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PARTICIPANT_EXPERIENCE_PRINCIPLES, PERSONA_HEALTHY_RANGES, POPULATION_PRINCIPLES, ParameterRegistry, type ParameterScope, type ParameterType, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RegisteredParameter, type RegistryValidationResult, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, findWorstSystem, validateEconomyState };
739
+ export { ALL_PRINCIPLES, type ActionPlan, AgentE, type AgentEConfig, type AgentEMode, BOOTSTRAP_PRINCIPLES, CURRENCY_FLOW_PRINCIPLES, DEFAULT_THRESHOLDS, type DecisionEntry, DecisionLog, type DecisionResult, Diagnoser, type Diagnosis, type EconomicEvent, type EconomicEventType, type EconomyAdapter, type EconomyMetrics, type EconomyState, type ExecutionResult, Executor, FEEDBACK_LOOP_PRINCIPLES, type FlowImpact, INCENTIVE_PRINCIPLES, MARKET_DYNAMICS_PRINCIPLES, MEASUREMENT_PRINCIPLES, type MetricQuery, type MetricQueryResult, type MetricResolution, MetricStore, OPEN_ECONOMY_PRINCIPLES, OPERATIONS_PRINCIPLES, Observer, P10_EntryWeightingUsesInversePopulation, P11_TwoTierPressure, P12_OnePrimaryFaucet, P13_PotsAreZeroSumAndSelfRegulate, P14_TrackActualInjection, P15_PoolsNeedCapAndDecay, P16_WithdrawalPenaltyScales, P17_GracePeriodBeforeIntervention, P18_FirstProducerNeedsStartingInventory, P19_StartingSupplyExceedsDemand, P1_ProductionMatchesConsumption, P20_DecayPreventsAccumulation, P21_PriceFromGlobalSupply, P22_MarketAwarenessPreventsSurplus, P23_ProfitabilityFactorsFeasibility, P24_BlockedAgentsDecayFaster, P25_CorrectLeversForCorrectProblems, P26_ContinuousPressureBeatsThresholdCuts, P27_AdjustmentsNeedCooldowns, P28_StructuralDominanceIsNotPathological, P29_BottleneckDetection, P2_ClosedLoopsNeedDirectHandoff, P30_DynamicBottleneckRotation, P31_AnchorValueTracking, P32_VelocityAboveSupply, P33_FairNotEqual, P34_ExtractionRatio, P35_DestructionCreatesValue, P36_MechanicFrictionDetector, P37_LatecommerProblem, P38_CommunicationPreventsRevolt, P39_TheLagPrinciple, P3_BootstrapCapitalCoversFirstTransaction, P40_ReplacementRate, P41_MultiResolutionMonitoring, P42_TheMedianPrinciple, P43_SimulationMinimum, P44_ComplexityBudget, P45_TimeBudget, P46_PersonaDiversity, P47_SmokeTest, P48_CurrencyInsulation, P49_IdleAssetTax, P4_MaterialsFlowFasterThanCooldown, P50_PayPowerRatio, P51_CyclicalEngagement, P52_EndowmentEffect, P53_EventCompletionRate, P54_OperationalCadence, P55_ArbitrageThermometer, P56_SupplyShockAbsorption, P57_CombinatorialPriceSpace, P58_NoNaturalNumeraire, P59_GiftEconomyNoise, P5_ProfitabilityIsRelative, P60_SurplusDisposalAsymmetry, P6_CrowdingMultiplierOnAllRoles, P7_NonSpecialistsSubsidiseSpecialists, P8_RegulatorCannotFightDesign, P9_RoleSwitchingNeedsFriction, PARTICIPANT_EXPERIENCE_PRINCIPLES, PERSONA_HEALTHY_RANGES, POPULATION_PRINCIPLES, ParameterRegistry, type ParameterScope, type ParameterType, type PersonaProfile, PersonaTracker, type PersonaType, type PinchPointStatus, Planner, type Principle, type PrincipleCategory, type PrincipleOk, type PrincipleResult, type PrincipleViolation, REGULATOR_PRINCIPLES, RESOURCE_MGMT_PRINCIPLES, type RegisteredParameter, type RegistryValidationResult, type RollbackCondition, STATISTICAL_PRINCIPLES, SUPPLY_CHAIN_PRINCIPLES, SYSTEM_DYNAMICS_PRINCIPLES, type SimulationConfig, type SimulationOutcome, type SimulationResult, Simulator, type SuggestedAction, type Thresholds, type TickConfig, type ValidationError, type ValidationResult, type ValidationWarning, emptyMetrics, findWorstSystem, validateEconomyState };