@idlekit/core 0.2.1 → 0.3.0

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.
Files changed (82) hide show
  1. package/dist/index.d.ts +12 -0
  2. package/dist/index.js +12 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/scenario/compile.d.ts +25 -0
  5. package/dist/scenario/compile.js +60 -0
  6. package/dist/scenario/compile.js.map +1 -1
  7. package/dist/scenario/scenarioContract.d.ts +152 -0
  8. package/dist/scenario/scenarioContract.js +2815 -0
  9. package/dist/scenario/scenarioContract.js.map +1 -0
  10. package/dist/sim/analysis/analyzers.d.ts +245 -0
  11. package/dist/sim/analysis/analyzers.js +1076 -0
  12. package/dist/sim/analysis/analyzers.js.map +1 -0
  13. package/dist/sim/analysis/contracts.d.ts +147 -0
  14. package/dist/sim/analysis/contracts.js +1230 -0
  15. package/dist/sim/analysis/contracts.js.map +1 -0
  16. package/dist/sim/analysis/distribution.d.ts +199 -0
  17. package/dist/sim/analysis/distribution.js +1246 -0
  18. package/dist/sim/analysis/distribution.js.map +1 -0
  19. package/dist/sim/analysis/eta.d.ts +118 -0
  20. package/dist/sim/analysis/eta.js +968 -70
  21. package/dist/sim/analysis/eta.js.map +1 -1
  22. package/dist/sim/analysis/experiment.d.ts +300 -0
  23. package/dist/sim/analysis/experiment.js +2206 -0
  24. package/dist/sim/analysis/experiment.js.map +1 -0
  25. package/dist/sim/analysis/growth.d.ts +2 -0
  26. package/dist/sim/analysis/growth.js +5 -1
  27. package/dist/sim/analysis/growth.js.map +1 -1
  28. package/dist/sim/analysis/growthFit.d.ts +183 -0
  29. package/dist/sim/analysis/growthFit.js +1798 -0
  30. package/dist/sim/analysis/growthFit.js.map +1 -0
  31. package/dist/sim/analysis/inspect.d.ts +236 -0
  32. package/dist/sim/analysis/inspect.js +388 -0
  33. package/dist/sim/analysis/inspect.js.map +1 -0
  34. package/dist/sim/analysis/metrics.d.ts +91 -0
  35. package/dist/sim/analysis/metrics.js +266 -0
  36. package/dist/sim/analysis/metrics.js.map +1 -0
  37. package/dist/sim/analysis/prestigeCycle.d.ts +6 -0
  38. package/dist/sim/analysis/prestigeCycle.js +10 -1
  39. package/dist/sim/analysis/prestigeCycle.js.map +1 -1
  40. package/dist/sim/analysis/registry.d.ts +41 -0
  41. package/dist/sim/analysis/registry.js +54 -0
  42. package/dist/sim/analysis/registry.js.map +1 -0
  43. package/dist/sim/analysis/resetActions.d.ts +7 -0
  44. package/dist/sim/analysis/resetActions.js +45 -0
  45. package/dist/sim/analysis/resetActions.js.map +1 -0
  46. package/dist/sim/analysis/resetCycle.d.ts +175 -0
  47. package/dist/sim/analysis/resetCycle.js +1009 -0
  48. package/dist/sim/analysis/resetCycle.js.map +1 -0
  49. package/dist/sim/analysis/resetOptimization.d.ts +198 -0
  50. package/dist/sim/analysis/resetOptimization.js +2187 -0
  51. package/dist/sim/analysis/resetOptimization.js.map +1 -0
  52. package/dist/sim/analysis/sensitivity.d.ts +73 -0
  53. package/dist/sim/analysis/sensitivity.js +160 -0
  54. package/dist/sim/analysis/sensitivity.js.map +1 -0
  55. package/dist/sim/monteCarlo.d.ts +12 -0
  56. package/dist/sim/monteCarlo.js +33 -4
  57. package/dist/sim/monteCarlo.js.map +1 -1
  58. package/dist/sim/observation.d.ts +22 -0
  59. package/dist/sim/observation.js +33 -0
  60. package/dist/sim/observation.js.map +1 -1
  61. package/dist/sim/offline.js +9 -2
  62. package/dist/sim/offline.js.map +1 -1
  63. package/dist/sim/random.d.ts +15 -0
  64. package/dist/sim/random.js +28 -0
  65. package/dist/sim/random.js.map +1 -1
  66. package/dist/sim/session.d.ts +7 -0
  67. package/dist/sim/session.js +13 -0
  68. package/dist/sim/session.js.map +1 -1
  69. package/dist/sim/simulator.js +7 -1
  70. package/dist/sim/simulator.js.map +1 -1
  71. package/dist/sim/step.d.ts +67 -1
  72. package/dist/sim/step.js +100 -18
  73. package/dist/sim/step.js.map +1 -1
  74. package/dist/sim/strategy/opt/freshRun.d.ts +3 -0
  75. package/dist/sim/strategy/opt/freshRun.js +6 -0
  76. package/dist/sim/strategy/opt/freshRun.js.map +1 -0
  77. package/dist/sim/strategy/opt/runner.js +2 -2
  78. package/dist/sim/strategy/opt/runner.js.map +1 -1
  79. package/dist/sim/strategy/planner.d.ts +26 -0
  80. package/dist/sim/strategy/planner.js +30 -0
  81. package/dist/sim/strategy/planner.js.map +1 -1
  82. package/package.json +2 -2
@@ -0,0 +1,175 @@
1
+ import typia, { type IValidation } from "typia";
2
+ import { type Action, type CompiledScenario, type ScenarioConstraints, type SimContext, type SimState } from "../types";
3
+ /**
4
+ * Reset-cycle execution v1.
5
+ * `analyzePrestigeCycle` stays the legacy interval scan.
6
+ * This artifact does not copy that scan's stability or break-even fields.
7
+ */
8
+ declare const RESET_CYCLE_ALGORITHM_VERSION: "reset-cycle-v1";
9
+ declare const RESET_CYCLE_SCHEMA_ID: "https://idlekit.dev/schemas/reset.cycle.v1.schema.json";
10
+ /**
11
+ * @evidence docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset Each cycle commits a reset through the action payment path.
12
+ * @evidenceReview docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset #22d7a8a Re-read the section: three cycles leave three resets, and the reset does not mint income.
13
+ */
14
+ export declare const resetCycleExecution: "committed-reset-transition";
15
+ /**
16
+ * @evidence docs/requirements/active/reset-cycle-execution.md#req-pr10-refused-reset A refused cost, condition, or cooldown pays no reward.
17
+ * @evidenceReview docs/requirements/active/reset-cycle-execution.md#req-pr10-refused-reset #5bbd1e4 Re-read the section: cannot-apply, insufficient funds, and cooldown are recorded, and the point stock stays put.
18
+ */
19
+ export declare const resetCycleSameContract: "prestige-and-custom-reset";
20
+ /**
21
+ * @evidence docs/requirements/active/reset-cycle-execution.md#req-pr10-reward-delta Reward gained by the reset does not include the stock already held.
22
+ * @evidenceReview docs/requirements/active/reset-cycle-execution.md#req-pr10-reward-delta #ed22025 Re-read the section: opening points of 100 stay out of the delta.
23
+ */
24
+ export declare const resetCycleRewardDelta: "reward-delta-excludes-opening-stock";
25
+ export declare function resetCycleSchemaId(): typeof RESET_CYCLE_SCHEMA_ID;
26
+ export declare function resetCycleAlgorithmVersion(): typeof RESET_CYCLE_ALGORITHM_VERSION;
27
+ export declare class ResetCycleRejected extends Error {
28
+ constructor(message: string);
29
+ }
30
+ export type ResetCycleStatus = "ok" | "incomplete" | "censored" | "unsupported";
31
+ export type ResetSkipReason = "cannot-apply" | "insufficient-funds" | "cooldown" | "budget" | "rejected" | "missing-adapter";
32
+ export type ResetCycleRowV1 = Readonly<{
33
+ index: number;
34
+ startSec: number;
35
+ endSec: number;
36
+ resetAtSec: number | null;
37
+ durationSec: number;
38
+ rewardDelta: string;
39
+ accumulatedReward: string;
40
+ resetSkippedReason?: ResetSkipReason;
41
+ carried: Readonly<{
42
+ points: string;
43
+ multiplier: string;
44
+ count: number;
45
+ reward: string;
46
+ }>;
47
+ }>;
48
+ export type ResetCycleArtifactV1 = Readonly<{
49
+ schemaVersion: 1;
50
+ algorithmVersion: typeof RESET_CYCLE_ALGORITHM_VERSION;
51
+ status: ResetCycleStatus;
52
+ policy: "fixed-interval" | "explicit";
53
+ appliedResets: number;
54
+ originSec: number;
55
+ globalElapsedSec: number;
56
+ assumptions: readonly string[];
57
+ warnings: readonly string[];
58
+ cycles: readonly ResetCycleRowV1[];
59
+ }>;
60
+ /**
61
+ * @evidence docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset The generated validator accepts this artifact and rejects a missing status.
62
+ * @evidenceReview docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset #22d7a8a Re-read the section: the wire object is reset cycle v1.
63
+ */
64
+ export declare const validateResetCycleArtifact: (input: unknown) => IValidation<ResetCycleArtifactV1>;
65
+ declare function buildResetCycleJsonSchema(): typia.IJsonSchemaUnit.IV3_1<Readonly<{
66
+ schemaVersion: 1;
67
+ algorithmVersion: typeof RESET_CYCLE_ALGORITHM_VERSION;
68
+ status: ResetCycleStatus;
69
+ policy: "fixed-interval" | "explicit";
70
+ appliedResets: number;
71
+ originSec: number;
72
+ globalElapsedSec: number;
73
+ assumptions: readonly string[];
74
+ warnings: readonly string[];
75
+ cycles: readonly ResetCycleRowV1[];
76
+ }>>;
77
+ /**
78
+ * @evidence docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset The structural schema is OpenAPI 3.1 from typia.
79
+ * @evidenceReview docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset #22d7a8a Re-read the section: schema version is 3.1.
80
+ */
81
+ export declare function resetCycleJsonSchema(): ReturnType<typeof buildResetCycleJsonSchema>;
82
+ /**
83
+ * What a reset is allowed to keep, and how its reward is measured.
84
+ * `pointsFrom` is a declared gain. `resetState` writes the next state.
85
+ * `multiplierFrom` maps the post-reset point total and is not applied a second time.
86
+ */
87
+ export type ResetAdapter<N, U extends string, Vars> = Readonly<{
88
+ id: string;
89
+ kind: "prestige" | "custom";
90
+ preserved: readonly ("points" | "multiplier" | "count" | "vars")[];
91
+ action: (ctx: SimContext<N, U, Vars>, state: SimState<N, U, Vars>) => Action<N, U, Vars> | undefined;
92
+ reward: (ctx: SimContext<N, U, Vars>, state: SimState<N, U, Vars>) => N;
93
+ }>;
94
+ export type ResetCyclePolicy = Readonly<{
95
+ kind: "fixed-interval";
96
+ intervalSec: number;
97
+ cycles: number;
98
+ }> | Readonly<{
99
+ kind: "explicit";
100
+ steps: readonly Readonly<{
101
+ durationSec: number;
102
+ }>[];
103
+ }>;
104
+ export type ResetCycleRng = Readonly<{
105
+ /** Names the generator. A checkpoint records it, and a resume with another generator is rejected. */
106
+ id: string;
107
+ /** The version of the snapshot format. A checkpoint records it, and a resume with another version is rejected. */
108
+ stateVersion: number;
109
+ snapshot: () => unknown;
110
+ restore: (state: unknown) => void;
111
+ }>;
112
+ export type ResetCycleCheckpoint<N, U extends string, Vars> = Readonly<{
113
+ contract: "idlekit.reset-cycle-checkpoint";
114
+ version: 1;
115
+ state: SimState<N, U, Vars>;
116
+ constraints?: ScenarioConstraints;
117
+ nextIndex: number;
118
+ originSec: number;
119
+ /** Simulated seconds since the origin, summed from each runner result. Absent on older checkpoints. */
120
+ elapsedSec?: number;
121
+ accumulatedReward: N;
122
+ strategyState?: unknown;
123
+ /** The explicit reset adapter whose reward accumulatedReward sums. A resume checks it. */
124
+ adapterId?: string;
125
+ adapterKind?: "prestige" | "custom";
126
+ /** Seconds already played of a cycle a budget cut. A resume plays only the rest of that cycle. */
127
+ pendingSec?: number;
128
+ /** The planned duration of that cut cycle. A resume must plan the same duration for it. */
129
+ pendingDurationSec?: number;
130
+ /** The t at which that cut cycle started. The resumed row keeps it, so its span matches its duration. */
131
+ pendingStartSec?: number;
132
+ /** The model the state belongs to. A resume checks it. */
133
+ modelId?: string;
134
+ modelVersion?: number;
135
+ /** The id and state version of the strategy that wrote strategyState. A resume checks them. */
136
+ strategyId?: string;
137
+ strategyStateVersion?: number;
138
+ rngState?: unknown;
139
+ /** The id and state version of the generator that wrote rngState. A resume checks them. */
140
+ rngId?: string;
141
+ rngStateVersion?: number;
142
+ }>;
143
+ export type ResetCycleExecution<N, U extends string, Vars> = Readonly<{
144
+ artifact: ResetCycleArtifactV1;
145
+ state: SimState<N, U, Vars>;
146
+ constraints?: ScenarioConstraints;
147
+ checkpoint: ResetCycleCheckpoint<N, U, Vars>;
148
+ }>;
149
+ /**
150
+ * Prestige action wins when both an action and a spec exist.
151
+ * The spec functions are not called on that path, so the bonus is not applied twice.
152
+ * A model with neither needs the caller to pass an adapter.
153
+ *
154
+ * @evidence docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset The default adapter uses the prestige action, or the spec when no action exists.
155
+ * @evidenceReview docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset #22d7a8a Re-read the section: an action and a spec are not both applied.
156
+ */
157
+ export declare function resetAdapterFor<N, U extends string, Vars>(scenario: CompiledScenario<N, U, Vars>, explicit?: ResetAdapter<N, U, Vars>, state?: SimState<N, U, Vars>, ctx?: SimContext<N, U, Vars>): ResetAdapter<N, U, Vars> | undefined;
158
+ /**
159
+ * Run a fixed interval or an explicit list of reset durations.
160
+ * Each completed cycle ends in one committed reset. A refused reset is kept and not forced.
161
+ *
162
+ * @evidence docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset The executor chains cycle end into the next cycle start.
163
+ * @evidenceReview docs/requirements/active/reset-cycle-execution.md#req-pr10-committed-reset #22d7a8a Re-read the section: carried points and multiplier are the next cycle's start, and a split resume matches one run.
164
+ */
165
+ export declare function executeResetCycles<N, U extends string, Vars>(args: {
166
+ scenario: CompiledScenario<N, U, Vars>;
167
+ policy: ResetCyclePolicy;
168
+ adapter?: ResetAdapter<N, U, Vars>;
169
+ maxCycles?: number;
170
+ horizonSec?: number;
171
+ budgetSteps?: number;
172
+ resume?: ResetCycleCheckpoint<N, U, Vars>;
173
+ rng?: ResetCycleRng;
174
+ }): ResetCycleExecution<N, U, Vars>;
175
+ export {};