@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.
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/scenario/compile.d.ts +25 -0
- package/dist/scenario/compile.js +60 -0
- package/dist/scenario/compile.js.map +1 -1
- package/dist/scenario/scenarioContract.d.ts +152 -0
- package/dist/scenario/scenarioContract.js +2815 -0
- package/dist/scenario/scenarioContract.js.map +1 -0
- package/dist/sim/analysis/analyzers.d.ts +245 -0
- package/dist/sim/analysis/analyzers.js +1076 -0
- package/dist/sim/analysis/analyzers.js.map +1 -0
- package/dist/sim/analysis/contracts.d.ts +147 -0
- package/dist/sim/analysis/contracts.js +1230 -0
- package/dist/sim/analysis/contracts.js.map +1 -0
- package/dist/sim/analysis/distribution.d.ts +199 -0
- package/dist/sim/analysis/distribution.js +1246 -0
- package/dist/sim/analysis/distribution.js.map +1 -0
- package/dist/sim/analysis/eta.d.ts +118 -0
- package/dist/sim/analysis/eta.js +968 -70
- package/dist/sim/analysis/eta.js.map +1 -1
- package/dist/sim/analysis/experiment.d.ts +300 -0
- package/dist/sim/analysis/experiment.js +2206 -0
- package/dist/sim/analysis/experiment.js.map +1 -0
- package/dist/sim/analysis/growth.d.ts +2 -0
- package/dist/sim/analysis/growth.js +5 -1
- package/dist/sim/analysis/growth.js.map +1 -1
- package/dist/sim/analysis/growthFit.d.ts +183 -0
- package/dist/sim/analysis/growthFit.js +1798 -0
- package/dist/sim/analysis/growthFit.js.map +1 -0
- package/dist/sim/analysis/inspect.d.ts +236 -0
- package/dist/sim/analysis/inspect.js +388 -0
- package/dist/sim/analysis/inspect.js.map +1 -0
- package/dist/sim/analysis/metrics.d.ts +91 -0
- package/dist/sim/analysis/metrics.js +266 -0
- package/dist/sim/analysis/metrics.js.map +1 -0
- package/dist/sim/analysis/prestigeCycle.d.ts +6 -0
- package/dist/sim/analysis/prestigeCycle.js +10 -1
- package/dist/sim/analysis/prestigeCycle.js.map +1 -1
- package/dist/sim/analysis/registry.d.ts +41 -0
- package/dist/sim/analysis/registry.js +54 -0
- package/dist/sim/analysis/registry.js.map +1 -0
- package/dist/sim/analysis/resetActions.d.ts +7 -0
- package/dist/sim/analysis/resetActions.js +45 -0
- package/dist/sim/analysis/resetActions.js.map +1 -0
- package/dist/sim/analysis/resetCycle.d.ts +175 -0
- package/dist/sim/analysis/resetCycle.js +1009 -0
- package/dist/sim/analysis/resetCycle.js.map +1 -0
- package/dist/sim/analysis/resetOptimization.d.ts +198 -0
- package/dist/sim/analysis/resetOptimization.js +2187 -0
- package/dist/sim/analysis/resetOptimization.js.map +1 -0
- package/dist/sim/analysis/sensitivity.d.ts +73 -0
- package/dist/sim/analysis/sensitivity.js +160 -0
- package/dist/sim/analysis/sensitivity.js.map +1 -0
- package/dist/sim/monteCarlo.d.ts +12 -0
- package/dist/sim/monteCarlo.js +33 -4
- package/dist/sim/monteCarlo.js.map +1 -1
- package/dist/sim/observation.d.ts +22 -0
- package/dist/sim/observation.js +33 -0
- package/dist/sim/observation.js.map +1 -1
- package/dist/sim/offline.js +9 -2
- package/dist/sim/offline.js.map +1 -1
- package/dist/sim/random.d.ts +15 -0
- package/dist/sim/random.js +28 -0
- package/dist/sim/random.js.map +1 -1
- package/dist/sim/session.d.ts +7 -0
- package/dist/sim/session.js +13 -0
- package/dist/sim/session.js.map +1 -1
- package/dist/sim/simulator.js +7 -1
- package/dist/sim/simulator.js.map +1 -1
- package/dist/sim/step.d.ts +67 -1
- package/dist/sim/step.js +100 -18
- package/dist/sim/step.js.map +1 -1
- package/dist/sim/strategy/opt/freshRun.d.ts +3 -0
- package/dist/sim/strategy/opt/freshRun.js +6 -0
- package/dist/sim/strategy/opt/freshRun.js.map +1 -0
- package/dist/sim/strategy/opt/runner.js +2 -2
- package/dist/sim/strategy/opt/runner.js.map +1 -1
- package/dist/sim/strategy/planner.d.ts +26 -0
- package/dist/sim/strategy/planner.js +30 -0
- package/dist/sim/strategy/planner.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { observationMeets } from "./analyzers";
|
|
2
|
+
import { observationContract } from "../observation";
|
|
3
|
+
import { nextBoundary } from "../timeBoundary";
|
|
4
|
+
import { plannerExpansionBound } from "../strategy/planner";
|
|
5
|
+
import { untilExprLiterals } from "../../scenario/compile";
|
|
6
|
+
import { alphaInfiniteIndex } from "../../notation/suffixer";
|
|
7
|
+
/**
|
|
8
|
+
* Inspect explains a resolved plan. It does not tick, import plugins, or call the network.
|
|
9
|
+
* Doctor remains the environment check. A cost figure is a budget proposal, not wall time.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-partial-tick A fixed duration counts every tick, including a shorter last tick.
|
|
13
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-partial-tick #12b41ae Re-read the section: 10 seconds at step 3 is 4 ticks and the last dt is 1.
|
|
14
|
+
*/
|
|
15
|
+
export const inspectPartialTick = "partial-tick-included";
|
|
16
|
+
/**
|
|
17
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-until-unknown An until-only clock has no step upper bound.
|
|
18
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-until-unknown #3b187c6 Re-read the section: without durationSec the step count is unknown.
|
|
19
|
+
*/
|
|
20
|
+
export const inspectUntilUnknown = "until-only-unknown";
|
|
21
|
+
/**
|
|
22
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-decimal-range A number-engine literal past the exact range is a warning. The literal is not passed through Number.
|
|
23
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-decimal-range #ce8dd3e Re-read the section: 1e400 warns on number and does not warn on breakInfinity.
|
|
24
|
+
*/
|
|
25
|
+
export const inspectDecimalRange = "decimal-range-is-advisory";
|
|
26
|
+
/**
|
|
27
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-stage-override Simulate and experience keep different step and session applies. Planner cost is a bound.
|
|
28
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-stage-override #d77f1bd Re-read the section: the command step stays on simulate, and the planner figure is not a duration.
|
|
29
|
+
*/
|
|
30
|
+
export const inspectStageOverride = "stage-plans-differ";
|
|
31
|
+
/**
|
|
32
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-plugins-default Named plugins stay unloaded unless resolve is set.
|
|
33
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-plugins-default #f0a188d Re-read the section: user code is not-run and the loaded id list is empty.
|
|
34
|
+
*/
|
|
35
|
+
export const inspectPluginsDefault = "plugins-stay-unloaded";
|
|
36
|
+
/**
|
|
37
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-plugin-metadata Resolve reports factory ids and that import may run user code. Source text stays out.
|
|
38
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-plugin-metadata #211b9cf Re-read the section: the loaded id is reported and the source sentinel is absent.
|
|
39
|
+
*/
|
|
40
|
+
export const inspectPluginMetadata = "metadata-after-trust";
|
|
41
|
+
/**
|
|
42
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-capability-split Unsupported is a declared no. Unknown is the absence of a declaration.
|
|
43
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-capability-split #761d04c Re-read the section: reset unsupported emits missing-reset, and flow unknown does not.
|
|
44
|
+
*/
|
|
45
|
+
export const inspectCapabilitySplit = "unsupported-is-not-unknown";
|
|
46
|
+
/**
|
|
47
|
+
* @evidence docs/requirements/active/scenario-inspect.md#req-dx03-no-run Inspect does not call the runner or the network. Analyzer demand is attached to the plan.
|
|
48
|
+
* @evidenceReview docs/requirements/active/scenario-inspect.md#req-dx03-no-run #97d9296 Re-read the section: a trace demand is unmet when the scenario has no trace, and fetch is unused.
|
|
49
|
+
*/
|
|
50
|
+
export const inspectNoRun = "no-tick-no-network";
|
|
51
|
+
const PLANNER_WARN_EXPANSIONS = 64;
|
|
52
|
+
/** Ticks of a fixed duration. Past the counting cap the count is null, not the cap. */
|
|
53
|
+
export function fixedDurationStepCount(durationSec, stepSec) {
|
|
54
|
+
let elapsed = 0;
|
|
55
|
+
let steps = 0;
|
|
56
|
+
let lastDt = null;
|
|
57
|
+
const limit = 1_000_000;
|
|
58
|
+
while (true) {
|
|
59
|
+
const decision = nextBoundary({
|
|
60
|
+
elapsedSec: elapsed,
|
|
61
|
+
steps,
|
|
62
|
+
stepSec,
|
|
63
|
+
durationSec,
|
|
64
|
+
untilMet: false,
|
|
65
|
+
hasUntil: false,
|
|
66
|
+
});
|
|
67
|
+
if (decision.kind !== "step") {
|
|
68
|
+
return { steps, lastDt, partial: lastDt !== null && lastDt + 1e-12 < stepSec };
|
|
69
|
+
}
|
|
70
|
+
// The cap is checked only when another tick is due, so a horizon of exactly the cap keeps its count.
|
|
71
|
+
if (steps >= limit)
|
|
72
|
+
return { steps: null, lastDt: null, partial: false };
|
|
73
|
+
lastDt = decision.dt;
|
|
74
|
+
elapsed += decision.dt;
|
|
75
|
+
steps += 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function exponentMagnitude(text) {
|
|
79
|
+
let sign = 1;
|
|
80
|
+
let body = text;
|
|
81
|
+
if (body.startsWith("+"))
|
|
82
|
+
body = body.slice(1);
|
|
83
|
+
else if (body.startsWith("-")) {
|
|
84
|
+
sign = -1;
|
|
85
|
+
body = body.slice(1);
|
|
86
|
+
}
|
|
87
|
+
let value = 0;
|
|
88
|
+
for (const ch of body)
|
|
89
|
+
value = value * 10 + (ch.charCodeAt(0) - 48);
|
|
90
|
+
return sign * value;
|
|
91
|
+
}
|
|
92
|
+
export function decimalExceedsNumberDomain(literal) {
|
|
93
|
+
const trimmed = literal.trim();
|
|
94
|
+
// The money parser accepts a sign and a leading-dot mantissa, such as +1e400 and .1e400.
|
|
95
|
+
const scientific = /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)[eE]([+-]?\d+)$/.exec(trimmed);
|
|
96
|
+
if (scientific?.[1] !== undefined)
|
|
97
|
+
return Math.abs(exponentMagnitude(scientific[1])) >= 15;
|
|
98
|
+
const digits = trimmed.replace(/^[+-]/, "").split(".")[0] ?? "";
|
|
99
|
+
if (/^\d+$/.test(digits) && digits.length > 15)
|
|
100
|
+
return true;
|
|
101
|
+
// An alpha suffix scales the mantissa by 1e3 per index, as the money parser reads it: 1aa is 1e3 and 1zz is 1e2028.
|
|
102
|
+
const suffixed = /^[-+]?(\d+(?:\.\d+)?|\.\d+)(?:[eE]([+-]?\d+))?([A-Za-z]+)$/.exec(trimmed);
|
|
103
|
+
if (suffixed?.[1] === undefined || suffixed[3] === undefined)
|
|
104
|
+
return false;
|
|
105
|
+
const index = alphaInfiniteIndex(suffixed[3], 2);
|
|
106
|
+
if (index < 0)
|
|
107
|
+
return false;
|
|
108
|
+
const whole = (suffixed[1].split(".")[0] ?? "").replace(/^0+/, "");
|
|
109
|
+
const exponent = (suffixed[2] !== undefined ? exponentMagnitude(suffixed[2]) : 0) + Math.max(whole.length - 1, 0);
|
|
110
|
+
return Math.abs(exponent + index * 3) >= 15;
|
|
111
|
+
}
|
|
112
|
+
function numericDomainOf(engine) {
|
|
113
|
+
if (engine.source === "custom")
|
|
114
|
+
return "unknown";
|
|
115
|
+
if (engine.effectiveId === "number")
|
|
116
|
+
return "safe-integer";
|
|
117
|
+
if (engine.effectiveId === "breakInfinity")
|
|
118
|
+
return "decimal-string";
|
|
119
|
+
return "unknown";
|
|
120
|
+
}
|
|
121
|
+
function engineReason(engine) {
|
|
122
|
+
if (!engine.accepted)
|
|
123
|
+
return engine.rejectReason ?? "The engine was rejected before a run.";
|
|
124
|
+
if (engine.source === "default")
|
|
125
|
+
return "Number is the default. scenario.engine is metadata and is not applied.";
|
|
126
|
+
if (engine.effectiveId === "breakInfinity")
|
|
127
|
+
return "The engine flag selected breakInfinity. The literal is not passed through Number.";
|
|
128
|
+
if (engine.source === "custom")
|
|
129
|
+
return "A trusted factory already held by the caller created this engine.";
|
|
130
|
+
return `The engine flag selected ${engine.effectiveId}.`;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Steps between the runner's trace samples. The runner samples when `steps % everySteps === 0`, so a negative
|
|
134
|
+
* integer samples as its magnitude does, and a fraction samples at the first whole step it divides. A cadence that
|
|
135
|
+
* divides no step up to the counting cap, such as 0, retains no periodic samples.
|
|
136
|
+
*/
|
|
137
|
+
export function traceSampleSteps(everySteps) {
|
|
138
|
+
if (Number.isInteger(everySteps) && everySteps !== 0)
|
|
139
|
+
return Math.abs(everySteps);
|
|
140
|
+
if (!Number.isFinite(everySteps) || everySteps === 0)
|
|
141
|
+
return null;
|
|
142
|
+
for (let steps = 1; steps <= 1_000_000; steps += 1) {
|
|
143
|
+
if (steps % everySteps === 0)
|
|
144
|
+
return steps;
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
function observationSupply(request, stepSec) {
|
|
149
|
+
const untilOnly = request.clock.durationSec === undefined && Boolean(request.clock.untilExpr?.trim());
|
|
150
|
+
const coverage = request.trace.include ? "trace" : request.clock.durationSec !== undefined ? "summary" : "missing";
|
|
151
|
+
// compileScenario traces every step when the scenario includes a trace without a cadence.
|
|
152
|
+
const sampleSteps = request.trace.include ? traceSampleSteps(request.trace.everySteps ?? 1) : null;
|
|
153
|
+
const cadence = sampleSteps === null ? null : sampleSteps * stepSec;
|
|
154
|
+
return {
|
|
155
|
+
schema: observationContract,
|
|
156
|
+
// The finest window the samples supply is the trace cadence. A summary supplies no finite window.
|
|
157
|
+
windowSec: cadence,
|
|
158
|
+
sampleCadenceSec: cadence,
|
|
159
|
+
coverage: untilOnly && !request.trace.include ? "missing" : coverage,
|
|
160
|
+
metricIds: ["money", "netWorth"],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export function buildScenarioInspect(request) {
|
|
164
|
+
const diagnostics = [];
|
|
165
|
+
const untilText = request.clock.untilExpr?.trim() ? request.clock.untilExpr.trim() : null;
|
|
166
|
+
const horizonKind = request.clock.durationSec !== undefined ? "duration" : untilText ? "until" : "unknown";
|
|
167
|
+
const supplyStep = request.stages.find((stage) => stage.name === "simulate")?.stepSec.value ?? request.clock.stepSec;
|
|
168
|
+
const supply = observationSupply(request, supplyStep);
|
|
169
|
+
if (!request.engine.accepted) {
|
|
170
|
+
diagnostics.push({
|
|
171
|
+
severity: "error",
|
|
172
|
+
code: "bad-engine",
|
|
173
|
+
evidence: {
|
|
174
|
+
effectiveId: request.engine.effectiveId,
|
|
175
|
+
reason: request.engine.rejectReason ?? null,
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// A custom engine declares no numeric domain. Its id does not say whether it narrows literals through Number,
|
|
180
|
+
// so wide literals warn for it as for the number engine. An untilExpr amount literal goes through the engine. A
|
|
181
|
+
// `t`, `prestige.count`, or known numeric state comparison goes through Number whatever the engine, so it always
|
|
182
|
+
// warns. Any other path picks its parser from the run-time value, which may be a string, so it does not warn.
|
|
183
|
+
const exact = numericDomainOf(request.engine);
|
|
184
|
+
if (request.engine.accepted) {
|
|
185
|
+
const until = untilExprLiterals(request.clock.untilExpr);
|
|
186
|
+
const engineLiterals = [
|
|
187
|
+
...request.decimals,
|
|
188
|
+
...until.filter((term) => term.parse === "engine").map((term) => term.literal),
|
|
189
|
+
];
|
|
190
|
+
const numericPaths = new Set(request.numericUntilPaths ?? []);
|
|
191
|
+
const numberLiterals = until
|
|
192
|
+
.filter((term) => term.parse === "number" || (term.parse === "runtime" && numericPaths.has(term.path)))
|
|
193
|
+
.map((term) => term.literal);
|
|
194
|
+
const numberWide = numberLiterals.filter(decimalExceedsNumberDomain);
|
|
195
|
+
const wide = [
|
|
196
|
+
...(exact !== "decimal-string" ? engineLiterals.filter(decimalExceedsNumberDomain) : []),
|
|
197
|
+
...numberWide,
|
|
198
|
+
];
|
|
199
|
+
if (wide.length > 0) {
|
|
200
|
+
diagnostics.push({
|
|
201
|
+
severity: "warning",
|
|
202
|
+
code: "decimal-range",
|
|
203
|
+
evidence: {
|
|
204
|
+
engineId: request.engine.effectiveId,
|
|
205
|
+
literal: wide[0] ?? null,
|
|
206
|
+
count: wide.length,
|
|
207
|
+
numberParsed: numberWide.length,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (request.walletUnit !== request.unitCode) {
|
|
213
|
+
diagnostics.push({
|
|
214
|
+
severity: "warning",
|
|
215
|
+
code: "unit-goal-mismatch",
|
|
216
|
+
evidence: { walletUnit: request.walletUnit, unitCode: request.unitCode },
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
if (request.prestigeRequested && request.capabilities.reset === "unsupported") {
|
|
220
|
+
diagnostics.push({
|
|
221
|
+
severity: "warning",
|
|
222
|
+
code: "missing-reset",
|
|
223
|
+
evidence: { reset: "unsupported" },
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
if (request.prestigeRequested && request.capabilities.reset === "unknown") {
|
|
227
|
+
diagnostics.push({
|
|
228
|
+
severity: "warning",
|
|
229
|
+
code: "capability-unknown",
|
|
230
|
+
evidence: { capability: "reset" },
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
// The runner keeps the event log unless the scenario turns it off, so an omitted eventLog is enabled.
|
|
234
|
+
const eventsEnabled = request.eventLog?.enabled !== false;
|
|
235
|
+
const eventsUnlimited = eventsEnabled && request.eventLog?.maxEvents === undefined;
|
|
236
|
+
// compileScenario sets no maxPoints, so an included trace keeps every periodic state, however long the duration.
|
|
237
|
+
const traceUncapped = request.trace.include;
|
|
238
|
+
const traceUnlimited = traceUncapped || eventsUnlimited;
|
|
239
|
+
if (traceUnlimited) {
|
|
240
|
+
diagnostics.push({
|
|
241
|
+
severity: "warning",
|
|
242
|
+
code: "unlimited-trace",
|
|
243
|
+
evidence: {
|
|
244
|
+
trace: request.trace.include,
|
|
245
|
+
durationSec: request.clock.durationSec ?? null,
|
|
246
|
+
eventMax: request.eventLog?.maxEvents ?? null,
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const planner = request.planner ? plannerExpansionBound(request.planner) : null;
|
|
251
|
+
if (planner && (planner.clamped || planner.expansionUpperBound > PLANNER_WARN_EXPANSIONS)) {
|
|
252
|
+
diagnostics.push({
|
|
253
|
+
severity: "warning",
|
|
254
|
+
code: "planner-cost",
|
|
255
|
+
evidence: {
|
|
256
|
+
expansionUpperBound: planner.expansionUpperBound,
|
|
257
|
+
measuredDurationSec: planner.measuredDurationSec,
|
|
258
|
+
cappedHorizon: planner.capped.horizonSteps,
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (request.plugins.requested && !request.plugins.resolve) {
|
|
263
|
+
diagnostics.push({
|
|
264
|
+
severity: "warning",
|
|
265
|
+
code: "plugin-skipped",
|
|
266
|
+
evidence: {
|
|
267
|
+
userCode: "not-run",
|
|
268
|
+
model: request.plugins.unresolvedModel ?? null,
|
|
269
|
+
strategy: request.plugins.unresolvedStrategy ?? null,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (request.plugins.resolve) {
|
|
274
|
+
diagnostics.push({
|
|
275
|
+
severity: "warning",
|
|
276
|
+
code: "plugin-user-code",
|
|
277
|
+
evidence: { userCode: "may-run", loaded: request.plugins.loadedIds.length },
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
const analyzers = request.analyzers.map((analyzer) => {
|
|
281
|
+
const met = observationMeets(analyzer.observation, supply);
|
|
282
|
+
if (!met) {
|
|
283
|
+
diagnostics.push({
|
|
284
|
+
severity: "warning",
|
|
285
|
+
code: "insufficient-observation",
|
|
286
|
+
evidence: {
|
|
287
|
+
analyzer: `${analyzer.id}@${analyzer.version}`,
|
|
288
|
+
demand: analyzer.observation.coverage,
|
|
289
|
+
supply: supply.coverage,
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return { ...analyzer, met };
|
|
294
|
+
});
|
|
295
|
+
const stages = request.stages.map((stage) => {
|
|
296
|
+
// A stage the fast override does not apply to still runs the scenario's fast mode, which the input carries.
|
|
297
|
+
const fast = stage.fast ?? null;
|
|
298
|
+
const actionsLog = stage.actionsLog
|
|
299
|
+
? {
|
|
300
|
+
kept: stage.actionsLog.kept,
|
|
301
|
+
maxActions: stage.actionsLog.maxActions ?? null,
|
|
302
|
+
unlimited: stage.actionsLog.kept && stage.actionsLog.maxActions === undefined,
|
|
303
|
+
}
|
|
304
|
+
: null;
|
|
305
|
+
const stateTrace = stage.stateTrace
|
|
306
|
+
? {
|
|
307
|
+
kept: stage.stateTrace.kept,
|
|
308
|
+
everySteps: stage.stateTrace.kept ? stage.stateTrace.everySteps ?? 1 : null,
|
|
309
|
+
maxPoints: stage.stateTrace.maxPoints ?? null,
|
|
310
|
+
unlimited: stage.stateTrace.kept && stage.stateTrace.maxPoints === undefined,
|
|
311
|
+
}
|
|
312
|
+
: null;
|
|
313
|
+
// A session stage runs its schedule, and ltv runs the command's horizon, not the scenario duration, so the
|
|
314
|
+
// duration does not count their ticks.
|
|
315
|
+
if (request.clock.durationSec === undefined || stage.applies.session || stage.name === "ltv") {
|
|
316
|
+
return {
|
|
317
|
+
name: stage.name,
|
|
318
|
+
applies: stage.applies,
|
|
319
|
+
stepSec: stage.stepSec,
|
|
320
|
+
strategyId: stage.strategyId ?? null,
|
|
321
|
+
strategySource: stage.strategySource,
|
|
322
|
+
session: stage.applies.session ? stage.session ?? null : null,
|
|
323
|
+
fast,
|
|
324
|
+
actionsLog,
|
|
325
|
+
stateTrace,
|
|
326
|
+
stepCount: "unknown",
|
|
327
|
+
lastDt: null,
|
|
328
|
+
partialTick: false,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
const counted = fixedDurationStepCount(request.clock.durationSec, stage.stepSec.value);
|
|
332
|
+
return {
|
|
333
|
+
name: stage.name,
|
|
334
|
+
applies: stage.applies,
|
|
335
|
+
stepSec: stage.stepSec,
|
|
336
|
+
strategyId: stage.strategyId ?? null,
|
|
337
|
+
strategySource: stage.strategySource,
|
|
338
|
+
session: stage.applies.session ? stage.session ?? null : null,
|
|
339
|
+
fast,
|
|
340
|
+
actionsLog,
|
|
341
|
+
stateTrace,
|
|
342
|
+
stepCount: counted.steps ?? "unknown",
|
|
343
|
+
lastDt: counted.lastDt,
|
|
344
|
+
partialTick: counted.partial,
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
return {
|
|
348
|
+
schemaVersion: 1,
|
|
349
|
+
contract: "idlekit.scenario-inspect.v1",
|
|
350
|
+
simulated: false,
|
|
351
|
+
doctor: false,
|
|
352
|
+
invalid: diagnostics.some((item) => item.severity === "error"),
|
|
353
|
+
engine: { ...request.engine, reason: engineReason(request.engine) },
|
|
354
|
+
model: request.model,
|
|
355
|
+
horizon: {
|
|
356
|
+
kind: horizonKind,
|
|
357
|
+
durationSec: request.clock.durationSec ?? null,
|
|
358
|
+
untilExpr: untilText,
|
|
359
|
+
},
|
|
360
|
+
stages,
|
|
361
|
+
offline: request.offline ?? null,
|
|
362
|
+
budgets: {
|
|
363
|
+
events: {
|
|
364
|
+
enabled: eventsEnabled,
|
|
365
|
+
maxEvents: request.eventLog?.maxEvents ?? null,
|
|
366
|
+
unlimited: eventsUnlimited,
|
|
367
|
+
},
|
|
368
|
+
trace: {
|
|
369
|
+
include: request.trace.include,
|
|
370
|
+
everySteps: request.trace.include ? request.trace.everySteps ?? 1 : request.trace.everySteps ?? null,
|
|
371
|
+
unlimited: traceUncapped,
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
numericDomain: {
|
|
375
|
+
engineId: request.engine.effectiveId,
|
|
376
|
+
exact,
|
|
377
|
+
},
|
|
378
|
+
capabilities: request.capabilities,
|
|
379
|
+
analyzers,
|
|
380
|
+
planner,
|
|
381
|
+
plugins: {
|
|
382
|
+
userCode: request.plugins.resolve ? "may-run" : "not-run",
|
|
383
|
+
loadedIds: request.plugins.resolve ? request.plugins.loadedIds : [],
|
|
384
|
+
},
|
|
385
|
+
diagnostics,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
//# sourceMappingURL=inspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../../src/sim/analysis/inspect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAgC,CAAC;AAEnE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAA6B,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAAoC,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAA6B,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAgC,CAAC;AAEtE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAA+B,CAAC;AAErE;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAAqC,CAAC;AAE5E;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,oBAA6B,CAAC;AAkI1D,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,uFAAuF;AACvF,MAAM,U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AS,EAAE,eAAe;aAC3B;YACD,KAAK,EAAE;gBACL,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO;gBAC9B,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI;gBACpG,SAAS,EAAE,aAAa;aACzB;SACF;QACD,aAAa,EAAE;YACb,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW;YACpC,KAAK;SACN;QACD,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,SAAS;QACT,OAAO;QACP,OAAO,EAAE;YACP,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YACzD,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;SACpE;QACD,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { SimContext, SimState } from "../types";
|
|
2
|
+
import { type AnalysisCapabilityName, type AnalysisMethod, type AnalysisStatus, type CapabilityKnowledge, type GoalResultV1, type MetricDomain, type MetricKind, type MetricReadingV1, type MetricTimeAxis, type AnalysisArtifactV1, type ArtifactCoverage } from "./contracts";
|
|
3
|
+
export type MetricExtract<N> = Readonly<{
|
|
4
|
+
available: false;
|
|
5
|
+
status: Exclude<AnalysisStatus, "ok">;
|
|
6
|
+
reason?: string;
|
|
7
|
+
}> | Readonly<{
|
|
8
|
+
available: true;
|
|
9
|
+
domain: "amount";
|
|
10
|
+
amount: N;
|
|
11
|
+
unit: string;
|
|
12
|
+
}> | Readonly<{
|
|
13
|
+
available: true;
|
|
14
|
+
domain: Exclude<MetricDomain, "amount">;
|
|
15
|
+
value: number;
|
|
16
|
+
}>;
|
|
17
|
+
export type MetricDefinition<N, U extends string, Vars> = Readonly<{
|
|
18
|
+
id: string;
|
|
19
|
+
version: number;
|
|
20
|
+
meaning: string;
|
|
21
|
+
domain: MetricDomain;
|
|
22
|
+
timeAxis: MetricTimeAxis;
|
|
23
|
+
kind: MetricKind;
|
|
24
|
+
extract: (ctx: SimContext<N, U, Vars>, state: SimState<N, U, Vars>) => MetricExtract<N>;
|
|
25
|
+
}>;
|
|
26
|
+
export type GoalDefinition<N, U extends string, Vars> = Readonly<{
|
|
27
|
+
id: string;
|
|
28
|
+
version: number;
|
|
29
|
+
observation: "state" | "milestone-key" | "custom";
|
|
30
|
+
timeResolution: "step";
|
|
31
|
+
met: (state: SimState<N, U, Vars>, ctx: SimContext<N, U, Vars>) => boolean | undefined;
|
|
32
|
+
assumptionsFor?: (state: SimState<N, U, Vars>, ctx: SimContext<N, U, Vars>) => readonly string[];
|
|
33
|
+
}>;
|
|
34
|
+
export type GoalEvaluation = Readonly<{
|
|
35
|
+
goalId: string;
|
|
36
|
+
goalVersion: number;
|
|
37
|
+
reached?: boolean;
|
|
38
|
+
status: "ok" | "unsupported" | "insufficient-data" | "invalid";
|
|
39
|
+
assumptions: readonly string[];
|
|
40
|
+
}>;
|
|
41
|
+
export declare function walletMoneyMetric<N, U extends string, Vars>(): MetricDefinition<N, U, Vars>;
|
|
42
|
+
export declare function netWorthMetric<N, U extends string, Vars>(read: (ctx: SimContext<N, U, Vars>, state: SimState<N, U, Vars>) => {
|
|
43
|
+
amount: N;
|
|
44
|
+
unit: string;
|
|
45
|
+
} | undefined): MetricDefinition<N, U, Vars>;
|
|
46
|
+
export declare function prestigePointsMetric<N, U extends string, Vars>(): MetricDefinition<N, U, Vars>;
|
|
47
|
+
export declare function finiteValueMetric<N, U extends string, Vars>(args: {
|
|
48
|
+
id: string;
|
|
49
|
+
version?: number;
|
|
50
|
+
meaning: string;
|
|
51
|
+
domain: Exclude<MetricDomain, "amount">;
|
|
52
|
+
kind?: MetricKind;
|
|
53
|
+
timeAxis?: MetricTimeAxis;
|
|
54
|
+
read: (ctx: SimContext<N, U, Vars>, state: SimState<N, U, Vars>) => number | undefined;
|
|
55
|
+
}): MetricDefinition<N, U, Vars>;
|
|
56
|
+
export declare function readMetric<N, U extends string, Vars>(metric: MetricDefinition<N, U, Vars>, ctx: SimContext<N, U, Vars>, state: SimState<N, U, Vars>, method?: AnalysisMethod): MetricReadingV1;
|
|
57
|
+
export declare function moneyAtLeast<N, U extends string, Vars>(target: string): GoalDefinition<N, U, Vars>;
|
|
58
|
+
export declare function netWorthAtLeast<N, U extends string, Vars>(args: {
|
|
59
|
+
target: string;
|
|
60
|
+
netWorth: (state: SimState<N, U, Vars>, ctx: SimContext<N, U, Vars>) => N | undefined;
|
|
61
|
+
fallbackToWallet?: boolean;
|
|
62
|
+
}): GoalDefinition<N, U, Vars>;
|
|
63
|
+
export declare function prestigePointsAtLeast<N, U extends string, Vars>(target: string): GoalDefinition<N, U, Vars>;
|
|
64
|
+
export declare function milestoneReached<N, U extends string, Vars>(args: {
|
|
65
|
+
key: string;
|
|
66
|
+
seen: readonly string[];
|
|
67
|
+
}): GoalDefinition<N, U, Vars>;
|
|
68
|
+
export declare function defineGoal<N, U extends string, Vars>(goal: GoalDefinition<N, U, Vars>): GoalDefinition<N, U, Vars>;
|
|
69
|
+
export declare function evaluateGoal<N, U extends string, Vars>(goal: GoalDefinition<N, U, Vars>, state: SimState<N, U, Vars>, ctx: SimContext<N, U, Vars>): GoalEvaluation;
|
|
70
|
+
export declare function evaluateGoalForEta<N, U extends string, Vars>(goal: GoalDefinition<N, U, Vars>, state: SimState<N, U, Vars>, ctx: SimContext<N, U, Vars>): GoalResultV1;
|
|
71
|
+
export declare function evaluateGoalForExperiment<N, U extends string, Vars>(goal: GoalDefinition<N, U, Vars>, state: SimState<N, U, Vars>, ctx: SimContext<N, U, Vars>): GoalResultV1;
|
|
72
|
+
export declare function evaluateGoalForCheck<N, U extends string, Vars>(goal: GoalDefinition<N, U, Vars>, state: SimState<N, U, Vars>, ctx: SimContext<N, U, Vars>): GoalResultV1;
|
|
73
|
+
export declare function capabilityKnowledge(declared: Partial<Record<AnalysisCapabilityName, "statically-known" | "unsupported">> | undefined, name: AnalysisCapabilityName): CapabilityKnowledge;
|
|
74
|
+
export declare function unsupportedCapabilityResult(name: AnalysisCapabilityName): Readonly<{
|
|
75
|
+
capability: AnalysisCapabilityName;
|
|
76
|
+
knowledge: "unsupported";
|
|
77
|
+
status: "unsupported";
|
|
78
|
+
}>;
|
|
79
|
+
export type AnalysisArtifactDraft = Readonly<{
|
|
80
|
+
algorithmVersion?: string;
|
|
81
|
+
assumptions?: readonly string[];
|
|
82
|
+
warnings?: readonly string[];
|
|
83
|
+
observationCoverage?: ArtifactCoverage;
|
|
84
|
+
horizon?: AnalysisArtifactV1["horizon"];
|
|
85
|
+
sampleCount?: number;
|
|
86
|
+
effectiveRunHash?: string;
|
|
87
|
+
metrics?: readonly MetricReadingV1[];
|
|
88
|
+
goals?: readonly GoalResultV1[];
|
|
89
|
+
capabilities?: AnalysisArtifactV1["capabilities"];
|
|
90
|
+
}>;
|
|
91
|
+
export declare function buildAnalysisArtifact(draft?: AnalysisArtifactDraft): AnalysisArtifactV1;
|