@agent-e/core 1.5.1 → 1.5.2
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 +70 -70
- package/dist/index.d.mts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +114 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -80
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
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 — games, DeFi, marketplaces, token systems, social platforms.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -13,40 +13,38 @@ npm install @agent-e/core
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { AgentE } from '@agent-e/core';
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
const agent = new AgentE({
|
|
17
|
+
adapter: {
|
|
18
|
+
getState: () => ({
|
|
19
|
+
tick: currentTick,
|
|
20
|
+
currencies: ['credits', 'tokens'],
|
|
21
|
+
systems: ['exchange', 'rewards'],
|
|
22
|
+
agentBalances: {
|
|
23
|
+
user_a: { credits: 500, tokens: 20 },
|
|
24
|
+
user_b: { credits: 300, tokens: 80 },
|
|
25
|
+
},
|
|
26
|
+
agentRoles: { user_a: 'provider', user_b: 'consumer' },
|
|
27
|
+
marketPrices: {
|
|
28
|
+
credits: { service_a: 10, service_b: 25 },
|
|
29
|
+
},
|
|
30
|
+
agentSatisfaction: { user_a: 72, user_b: 85 },
|
|
31
|
+
poolSizes: { rewardPool: { credits: 5000 } },
|
|
32
|
+
roles: ['provider', 'consumer'],
|
|
33
|
+
resources: ['service_a', 'service_b'],
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
mode: 'advisor',
|
|
40
|
+
parameters: [
|
|
41
|
+
{ key: 'exchangeFee', type: 'fee', flowImpact: 'friction', scope: { system: 'exchange' } },
|
|
42
|
+
{ key: 'dailyReward', type: 'reward', flowImpact: 'faucet', scope: { system: 'rewards' } },
|
|
43
|
+
],
|
|
44
|
+
mode: 'advisor',
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
agent.
|
|
48
|
-
|
|
49
|
-
// Call once per tick in your loop:
|
|
47
|
+
agent.start();
|
|
50
48
|
await agent.tick();
|
|
51
49
|
```
|
|
52
50
|
|
|
@@ -58,16 +56,29 @@ await agent.tick();
|
|
|
58
56
|
4. **Planner** — Lag-aware, cooldown-aware planning with rollback conditions
|
|
59
57
|
5. **Executor** — Applies actions and monitors for rollback triggers
|
|
60
58
|
|
|
61
|
-
##
|
|
59
|
+
## Parameter Registry
|
|
60
|
+
|
|
61
|
+
Register your economy's parameters with semantic types and flow impacts:
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
```typescript
|
|
64
|
+
parameters: [
|
|
65
|
+
{ key: 'tradeFee', type: 'fee', flowImpact: 'friction', scope: { system: 'trading' } },
|
|
66
|
+
{ key: 'mintReward', type: 'reward', flowImpact: 'faucet', scope: { system: 'minting' } },
|
|
67
|
+
{ key: 'burnRate', type: 'rate', flowImpact: 'sink', scope: { system: 'burning' } },
|
|
68
|
+
{ key: 'lpYield', type: 'yield', flowImpact: 'faucet', scope: { system: 'liquidity', currency: 'tokens' } },
|
|
69
|
+
{ key: 'platformCut', type: 'fee', flowImpact: 'sink', scope: { system: 'marketplace', tags: ['operator'] } },
|
|
70
|
+
]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Principles target types (e.g., "decrease `fee` in `trading`"), and the registry resolves to your concrete parameter name.
|
|
74
|
+
|
|
75
|
+
## Multi-System, Multi-Currency
|
|
68
76
|
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
AgentE tracks each system and currency independently:
|
|
78
|
+
|
|
79
|
+
- Per-currency: supply, net flow, velocity, inflation, Gini, wealth distribution, faucet/sink volumes, price index
|
|
80
|
+
- Per-system: flow, activity, participant count
|
|
81
|
+
- Cross-system: arbitrage index, source/sink share analysis
|
|
71
82
|
|
|
72
83
|
## Modes
|
|
73
84
|
|
|
@@ -76,36 +87,15 @@ is unhealthy and the suggested action is scoped to that currency.
|
|
|
76
87
|
| `autonomous` | Full pipeline — executes parameter changes automatically |
|
|
77
88
|
| `advisor` | Full pipeline but stops before execution — emits recommendations via `onDecision` |
|
|
78
89
|
|
|
79
|
-
## 60 Principles
|
|
80
|
-
|
|
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.
|
|
82
|
-
|
|
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.
|
|
84
|
-
|
|
85
|
-
## Tick Configuration
|
|
86
|
-
|
|
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
|
-
```
|
|
98
|
-
|
|
99
90
|
## Developer API
|
|
100
91
|
|
|
101
92
|
```typescript
|
|
102
93
|
// Lock a parameter from automated adjustment
|
|
103
|
-
agent.lock('
|
|
104
|
-
|
|
105
|
-
agent.unlock('productionCost');
|
|
94
|
+
agent.lock('exchangeFee');
|
|
95
|
+
agent.unlock('exchangeFee');
|
|
106
96
|
|
|
107
97
|
// Constrain a parameter to a range
|
|
108
|
-
agent.constrain('
|
|
98
|
+
agent.constrain('dailyReward', { min: 1, max: 100 });
|
|
109
99
|
|
|
110
100
|
// Add a custom principle
|
|
111
101
|
agent.addPrinciple(myPrinciple);
|
|
@@ -115,7 +105,7 @@ agent.registerCustomMetric('myMetric', (state) => compute(state));
|
|
|
115
105
|
|
|
116
106
|
// Veto actions
|
|
117
107
|
agent.on('beforeAction', (plan) => {
|
|
118
|
-
if (plan.
|
|
108
|
+
if (plan.parameterType === 'reward') return false;
|
|
119
109
|
});
|
|
120
110
|
|
|
121
111
|
// Query decision history
|
|
@@ -135,21 +125,22 @@ import type { Principle } from '@agent-e/core';
|
|
|
135
125
|
|
|
136
126
|
const myRule: Principle = {
|
|
137
127
|
id: 'MY_01',
|
|
138
|
-
name: '
|
|
128
|
+
name: 'Provider Population Floor',
|
|
139
129
|
category: 'population',
|
|
140
|
-
description: '
|
|
130
|
+
description: 'Provider role share below 5% is a crisis',
|
|
141
131
|
check(metrics, thresholds) {
|
|
142
|
-
const share = metrics.roleShares['
|
|
132
|
+
const share = metrics.roleShares['provider'] ?? 0;
|
|
143
133
|
if (share < 0.05) {
|
|
144
134
|
return {
|
|
145
135
|
violated: true,
|
|
146
136
|
severity: 8,
|
|
147
137
|
evidence: { share },
|
|
148
138
|
suggestedAction: {
|
|
149
|
-
|
|
139
|
+
parameterType: 'reward',
|
|
140
|
+
scope: { tags: ['provider'] },
|
|
150
141
|
direction: 'increase',
|
|
151
142
|
magnitude: 0.25,
|
|
152
|
-
reasoning: '
|
|
143
|
+
reasoning: 'Provider population critically low.',
|
|
153
144
|
},
|
|
154
145
|
confidence: 0.90,
|
|
155
146
|
estimatedLag: 10,
|
|
@@ -162,14 +153,23 @@ const myRule: Principle = {
|
|
|
162
153
|
agent.addPrinciple(myRule);
|
|
163
154
|
```
|
|
164
155
|
|
|
156
|
+
## 60 Principles
|
|
157
|
+
|
|
158
|
+
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.
|
|
159
|
+
|
|
165
160
|
## Performance
|
|
166
161
|
|
|
167
162
|
- **O(N) event classification** — single-pass instead of 6 separate filters
|
|
163
|
+
- **O(n) arbitrage index** — log-price standard deviation instead of pairwise
|
|
168
164
|
- **Cached diagnosis** — no redundant principle checks within the same tick
|
|
169
|
-
- **Numerical stability** — clamped inputs to prevent NaN edge cases
|
|
165
|
+
- **Numerical stability** — clamped inputs to prevent NaN/Infinity edge cases
|
|
170
166
|
|
|
171
167
|
Typical for 1,000 agents, 100 events/tick: ~60ms end-to-end.
|
|
172
168
|
|
|
173
169
|
## License
|
|
174
170
|
|
|
175
171
|
MIT
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
**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
|
-
|
|
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
|
-
|
|
507
|
-
|
|
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
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
507
|
-
|
|
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
|
|
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,
|
|
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 };
|