@idlekit/core 0.3.1 → 0.4.1

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 (47) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +7 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/scenario/compile.js +1 -0
  6. package/dist/scenario/compile.js.map +1 -1
  7. package/dist/scenario/scenarioContract.d.ts +32 -2
  8. package/dist/scenario/scenarioContract.js +37 -2
  9. package/dist/scenario/scenarioContract.js.map +1 -1
  10. package/dist/sim/advance.d.ts +198 -0
  11. package/dist/sim/advance.js +609 -0
  12. package/dist/sim/advance.js.map +1 -0
  13. package/dist/sim/analysis/checks.d.ts +260 -0
  14. package/dist/sim/analysis/checks.js +1442 -0
  15. package/dist/sim/analysis/checks.js.map +1 -0
  16. package/dist/sim/analysis/flow.d.ts +169 -0
  17. package/dist/sim/analysis/flow.js +1359 -0
  18. package/dist/sim/analysis/flow.js.map +1 -0
  19. package/dist/sim/analysis/jevAdvisory.d.ts +113 -0
  20. package/dist/sim/analysis/jevAdvisory.js +846 -0
  21. package/dist/sim/analysis/jevAdvisory.js.map +1 -0
  22. package/dist/sim/analysis/judge.d.ts +145 -0
  23. package/dist/sim/analysis/judge.js +1451 -0
  24. package/dist/sim/analysis/judge.js.map +1 -0
  25. package/dist/sim/analysis/registry.d.ts +9 -6
  26. package/dist/sim/analysis/registry.js +15 -2
  27. package/dist/sim/analysis/registry.js.map +1 -1
  28. package/dist/sim/executionBackend.d.ts +165 -0
  29. package/dist/sim/executionBackend.js +521 -0
  30. package/dist/sim/executionBackend.js.map +1 -0
  31. package/dist/sim/integrationMatrix.d.ts +52 -0
  32. package/dist/sim/integrationMatrix.js +68 -0
  33. package/dist/sim/integrationMatrix.js.map +1 -0
  34. package/dist/sim/observation.d.ts +11 -0
  35. package/dist/sim/observation.js +12 -0
  36. package/dist/sim/observation.js.map +1 -1
  37. package/dist/sim/offline.d.ts +2 -0
  38. package/dist/sim/offline.js +68 -1
  39. package/dist/sim/offline.js.map +1 -1
  40. package/dist/sim/simulator.d.ts +2 -0
  41. package/dist/sim/simulator.js +71 -1
  42. package/dist/sim/simulator.js.map +1 -1
  43. package/dist/sim/step.d.ts +10 -0
  44. package/dist/sim/step.js +10 -0
  45. package/dist/sim/step.js.map +1 -1
  46. package/dist/sim/types.d.ts +11 -0
  47. package/package.json +3 -3
@@ -0,0 +1,1442 @@
1
+ import * as _validateReport_1 from "typia/lib/internal/_validateReport";
2
+ import * as _createStandardSchema_1 from "typia/lib/internal/_createStandardSchema";
3
+ import typia, {} from "typia";
4
+ /**
5
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-check-spec A check names a registered metric, operator, threshold, unit, severity, and missing policy.
6
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-check-spec #d7f7211 Re-read the section: the default path is a data spec, not an arbitrary expression.
7
+ */
8
+ export const balanceCheckSpec = "registered-check-spec";
9
+ /**
10
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-verdict-bounds Pass and fail come only from a measured point or a bound that decides the comparison.
11
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-verdict-bounds #7c48cdf Re-read the section: a missing or unknown value is not zero, and a censored lower bound can fail.
12
+ */
13
+ export const balanceVerdictBounds = "bounds-not-zero";
14
+ /**
15
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-identity-mismatch A different definition, method, version, seed, engine, or unit is a mismatch and is not rewritten.
16
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-identity-mismatch #b9af2a2 Re-read the section: mismatch stays inconclusive and baselineRewrite stays false.
17
+ */
18
+ export const balanceIdentityMismatch = "mismatch-not-rewritten";
19
+ /**
20
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-kpi-adapter The existing a/b horizon report is mapped into this engine.
21
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-kpi-adapter #9f228f6 Re-read the section: identical fixture rows pass and a lower worth fails.
22
+ */
23
+ export const balanceKpiAdapter = "kpi-adapter";
24
+ /**
25
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-assertion-grammar Scenario assertions are declaration-only. The supported grammar is the safe comparison term.
26
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-assertion-grammar #2ad185e Re-read the section: an unsafe expression is unsupported and is not executed.
27
+ */
28
+ export const balanceAssertionGrammar = "declaration-only";
29
+ /**
30
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-numeric-advisory The numeric verdict and the advisory text are separate, and the default path does not fetch.
31
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-numeric-advisory #80bc2bf Re-read the section: advisory text cannot turn a fail into a pass.
32
+ */
33
+ export const balanceNumericAdvisory = "numeric-not-advisory";
34
+ /**
35
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-failure-report A blocking result exits 2 and the error document validates.
36
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-failure-report #fd8c2d1 Re-read the section: unsupported, error, and missing do not become pass.
37
+ */
38
+ export const balanceFailureReport = "failure-exit-two";
39
+ /*
40
+ * typia runs on first call, not at module load. A plugin that the bundled CLI loads
41
+ * imports core source without the transform, and a module-load call would throw there.
42
+ */
43
+ let validateRequestValidator;
44
+ let validateBalanceCheckReportValidator;
45
+ const validateRequest = (input) => (validateRequestValidator ??= (() => {
46
+ const _ip0 = input => "string" === typeof input["id"];
47
+ const _ip1 = input => "string" === typeof input["metricId"];
48
+ const _ip2 = input => "between" === input["operator"] || "eq" === input["operator"] || "gt" === input["operator"] || "gte" === input["operator"] || "lt" === input["operator"] || "lte" === input["operator"];
49
+ const _ip3 = input => "number" === typeof input["threshold"];
50
+ const _ip4 = input => null === input["upperThreshold"] || "number" === typeof input["upperThreshold"];
51
+ const _ip5 = input => "string" === typeof input["unit"];
52
+ const _ip6 = input => "error" === input["severity"] || "warn" === input["severity"];
53
+ const _ip7 = input => "fail" === input["missingPolicy"] || "inconclusive" === input["missingPolicy"] || "unsupported" === input["missingPolicy"];
54
+ const _ip8 = input => "string" === typeof input["definition"];
55
+ const _ip9 = input => "string" === typeof input["method"];
56
+ const _ip10 = input => null === input["scenarioVersion"] || "string" === typeof input["scenarioVersion"];
57
+ const _ip11 = input => null === input["specVersion"] || "string" === typeof input["specVersion"];
58
+ const _ip12 = input => null === input["engineId"] || "string" === typeof input["engineId"];
59
+ const _ip13 = input => null === input["pluginVersion"] || "string" === typeof input["pluginVersion"];
60
+ const _ip14 = input => null === input["seed"] || "string" === typeof input["seed"];
61
+ const _ip15 = input => null === input["algorithmVersion"] || "string" === typeof input["algorithmVersion"];
62
+ const _ve0 = "Readonly<{ schemaVersion: 1; contract: \"idlekit.balance-checks.v1\"; failOn: readonly FailOnToken[]; checks: readonly Readonly<{ id: string; metricId: string; operator: CheckOperator; threshold: number; ... 11 more ...; algorithmVersion: string | null; }>[]; observations: readonly Readonly<...>[]; advisory: string | ...";
63
+ const _ve1 = "Readonly<{ id: string; metricId: string; operator: CheckOperator; threshold: number; upperThreshold: number | null; unit: string; severity: CheckSeverity; missingPolicy: MissingPolicy; ... 7 more ...; algorithmVersion: string | null; }>";
64
+ const _ve2 = "ReadonlyArray<Readonly<{ id: string; metricId: string; operator: CheckOperator; threshold: number; upperThreshold: number | null; unit: string; severity: CheckSeverity; missingPolicy: MissingPolicy; ... 7 more ...; algorithmVersion: string | null; }>>";
65
+ const _ve3 = "Readonly<{ identity: Readonly<{ metricId: string; definition: string; method: string; scenarioVersion: string; specVersion: string; engineId: string; pluginVersion: string; seed: string; unit: string; algorithmVersion: string; }>; status: ObservationStatus; value: number | null; lower: number | null; upper: number |...";
66
+ const _ve4 = "ReadonlyArray<Readonly<{ identity: Readonly<{ metricId: string; definition: string; method: string; scenarioVersion: string; specVersion: string; engineId: string; pluginVersion: string; seed: string; unit: string; algorithmVersion: string; }>; status: ObservationStatus; value: number | null; lower: number | null; upper: number |...>";
67
+ const _vp0 = (input, _path, _exceptionable = true) => "string" === typeof input["id"] || _report(_exceptionable, {
68
+ path: _path + ".id",
69
+ expected: "string",
70
+ value: input["id"]
71
+ });
72
+ const _vp1 = (input, _path, _exceptionable = true) => "string" === typeof input["metricId"] || _report(_exceptionable, {
73
+ path: _path + ".metricId",
74
+ expected: "string",
75
+ value: input["metricId"]
76
+ });
77
+ const _vp2 = (input, _path, _exceptionable = true) => "between" === input["operator"] || "eq" === input["operator"] || "gt" === input["operator"] || "gte" === input["operator"] || "lt" === input["operator"] || "lte" === input["operator"] || _report(_exceptionable, {
78
+ path: _path + ".operator",
79
+ expected: "(\"between\" | \"eq\" | \"gt\" | \"gte\" | \"lt\" | \"lte\")",
80
+ value: input["operator"]
81
+ });
82
+ const _vp3 = (input, _path, _exceptionable = true) => "number" === typeof input["threshold"] || _report(_exceptionable, {
83
+ path: _path + ".threshold",
84
+ expected: "number",
85
+ value: input["threshold"]
86
+ });
87
+ const _vp4 = (input, _path, _exceptionable = true) => null === input["upperThreshold"] || "number" === typeof input["upperThreshold"] || _report(_exceptionable, {
88
+ path: _path + ".upperThreshold",
89
+ expected: "(null | number)",
90
+ value: input["upperThreshold"]
91
+ });
92
+ const _vp5 = (input, _path, _exceptionable = true) => "string" === typeof input["unit"] || _report(_exceptionable, {
93
+ path: _path + ".unit",
94
+ expected: "string",
95
+ value: input["unit"]
96
+ });
97
+ const _vp6 = (input, _path, _exceptionable = true) => "error" === input["severity"] || "warn" === input["severity"] || _report(_exceptionable, {
98
+ path: _path + ".severity",
99
+ expected: "(\"error\" | \"warn\")",
100
+ value: input["severity"]
101
+ });
102
+ const _vp7 = (input, _path, _exceptionable = true) => "fail" === input["missingPolicy"] || "inconclusive" === input["missingPolicy"] || "unsupported" === input["missingPolicy"] || _report(_exceptionable, {
103
+ path: _path + ".missingPolicy",
104
+ expected: "(\"fail\" | \"inconclusive\" | \"unsupported\")",
105
+ value: input["missingPolicy"]
106
+ });
107
+ const _vp8 = (input, _path, _exceptionable = true) => "string" === typeof input["definition"] || _report(_exceptionable, {
108
+ path: _path + ".definition",
109
+ expected: "string",
110
+ value: input["definition"]
111
+ });
112
+ const _vp9 = (input, _path, _exceptionable = true) => "string" === typeof input["method"] || _report(_exceptionable, {
113
+ path: _path + ".method",
114
+ expected: "string",
115
+ value: input["method"]
116
+ });
117
+ const _vp10 = (input, _path, _exceptionable = true) => null === input["scenarioVersion"] || "string" === typeof input["scenarioVersion"] || _report(_exceptionable, {
118
+ path: _path + ".scenarioVersion",
119
+ expected: "(null | string)",
120
+ value: input["scenarioVersion"]
121
+ });
122
+ const _vp11 = (input, _path, _exceptionable = true) => null === input["specVersion"] || "string" === typeof input["specVersion"] || _report(_exceptionable, {
123
+ path: _path + ".specVersion",
124
+ expected: "(null | string)",
125
+ value: input["specVersion"]
126
+ });
127
+ const _vp12 = (input, _path, _exceptionable = true) => null === input["engineId"] || "string" === typeof input["engineId"] || _report(_exceptionable, {
128
+ path: _path + ".engineId",
129
+ expected: "(null | string)",
130
+ value: input["engineId"]
131
+ });
132
+ const _vp13 = (input, _path, _exceptionable = true) => null === input["pluginVersion"] || "string" === typeof input["pluginVersion"] || _report(_exceptionable, {
133
+ path: _path + ".pluginVersion",
134
+ expected: "(null | string)",
135
+ value: input["pluginVersion"]
136
+ });
137
+ const _vp14 = (input, _path, _exceptionable = true) => null === input["seed"] || "string" === typeof input["seed"] || _report(_exceptionable, {
138
+ path: _path + ".seed",
139
+ expected: "(null | string)",
140
+ value: input["seed"]
141
+ });
142
+ const _vp15 = (input, _path, _exceptionable = true) => null === input["algorithmVersion"] || "string" === typeof input["algorithmVersion"] || _report(_exceptionable, {
143
+ path: _path + ".algorithmVersion",
144
+ expected: "(null | string)",
145
+ value: input["algorithmVersion"]
146
+ });
147
+ const _ve5 = "Readonly<{ metricId: string; definition: string; method: string; scenarioVersion: string; specVersion: string; engineId: string; pluginVersion: string; seed: string; unit: string; algorithmVersion: string; }>";
148
+ const _io0 = input => 1 === input.schemaVersion && "idlekit.balance-checks.v1" === input.contract && (Array.isArray(input.failOn) && input.failOn.every(elem => "error" === elem || "inconclusive" === elem || "unsupported" === elem || "warn" === elem)) && (Array.isArray(input.checks) && input.checks.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && (Array.isArray(input.observations) && input.observations.every(elem => "object" === typeof elem && null !== elem && _io2(elem))) && (null === input.advisory || "string" === typeof input.advisory);
149
+ const _io1 = input => _ip0(input) && _ip1(input) && _ip2(input) && _ip3(input) && _ip4(input) && _ip5(input) && _ip6(input) && _ip7(input) && _ip8(input) && _ip9(input) && _ip10(input) && _ip11(input) && _ip12(input) && _ip13(input) && _ip14(input) && _ip15(input);
150
+ const _io2 = input => "object" === typeof input.identity && null !== input.identity && _io3(input.identity) && ("censored" === input.status || "measured" === input.status || "missing" === input.status || "unknown" === input.status || "unsupported" === input.status) && (null === input.value || "number" === typeof input.value) && (null === input.lower || "number" === typeof input.lower) && (null === input.upper || "number" === typeof input.upper);
151
+ const _io3 = input => _ip1(input) && _ip8(input) && _ip9(input) && "string" === typeof input.scenarioVersion && "string" === typeof input.specVersion && "string" === typeof input.engineId && "string" === typeof input.pluginVersion && "string" === typeof input.seed && _ip5(input) && "string" === typeof input.algorithmVersion;
152
+ const _vo0 = (input, _path, _exceptionable = true) => [1 === input.schemaVersion || _report(_exceptionable, {
153
+ path: _path + ".schemaVersion",
154
+ expected: "1",
155
+ value: input.schemaVersion
156
+ }), "idlekit.balance-checks.v1" === input.contract || _report(_exceptionable, {
157
+ path: _path + ".contract",
158
+ expected: "\"idlekit.balance-checks.v1\"",
159
+ value: input.contract
160
+ }), (Array.isArray(input.failOn) || _report(_exceptionable, {
161
+ path: _path + ".failOn",
162
+ expected: "ReadonlyArray<FailOnToken>",
163
+ value: input.failOn
164
+ })) && input.failOn.map((elem, _index4) => "error" === elem || "inconclusive" === elem || "unsupported" === elem || "warn" === elem || _report(_exceptionable, {
165
+ path: _path + ".failOn[" + _index4 + "]",
166
+ expected: "(\"error\" | \"inconclusive\" | \"unsupported\" | \"warn\")",
167
+ value: elem
168
+ })).every(flag => flag) || _report(_exceptionable, {
169
+ path: _path + ".failOn",
170
+ expected: "ReadonlyArray<FailOnToken>",
171
+ value: input.failOn
172
+ }), (Array.isArray(input.checks) || _report(_exceptionable, {
173
+ path: _path + ".checks",
174
+ expected: _ve2,
175
+ value: input.checks
176
+ })) && input.checks.map((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
177
+ path: _path + ".checks[" + _index5 + "]",
178
+ expected: _ve1,
179
+ value: elem
180
+ })) && _vo1(elem, _path + ".checks[" + _index5 + "]", true && _exceptionable) || _report(_exceptionable, {
181
+ path: _path + ".checks[" + _index5 + "]",
182
+ expected: _ve1,
183
+ value: elem
184
+ })).every(flag => flag) || _report(_exceptionable, {
185
+ path: _path + ".checks",
186
+ expected: _ve2,
187
+ value: input.checks
188
+ }), (Array.isArray(input.observations) || _report(_exceptionable, {
189
+ path: _path + ".observations",
190
+ expected: _ve4,
191
+ value: input.observations
192
+ })) && input.observations.map((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
193
+ path: _path + ".observations[" + _index6 + "]",
194
+ expected: _ve3,
195
+ value: elem
196
+ })) && _vo2(elem, _path + ".observations[" + _index6 + "]", true && _exceptionable) || _report(_exceptionable, {
197
+ path: _path + ".observations[" + _index6 + "]",
198
+ expected: _ve3,
199
+ value: elem
200
+ })).every(flag => flag) || _report(_exceptionable, {
201
+ path: _path + ".observations",
202
+ expected: _ve4,
203
+ value: input.observations
204
+ }), null === input.advisory || "string" === typeof input.advisory || _report(_exceptionable, {
205
+ path: _path + ".advisory",
206
+ expected: "(null | string)",
207
+ value: input.advisory
208
+ })].every(flag => flag);
209
+ const _vo1 = (input, _path, _exceptionable = true) => [_vp0(input, _path, true && _exceptionable), _vp1(input, _path, true && _exceptionable), _vp2(input, _path, true && _exceptionable), _vp3(input, _path, true && _exceptionable), _vp4(input, _path, true && _exceptionable), _vp5(input, _path, true && _exceptionable), _vp6(input, _path, true && _exceptionable), _vp7(input, _path, true && _exceptionable), _vp8(input, _path, true && _exceptionable), _vp9(input, _path, true && _exceptionable), _vp10(input, _path, true && _exceptionable), _vp11(input, _path, true && _exceptionable), _vp12(input, _path, true && _exceptionable), _vp13(input, _path, true && _exceptionable), _vp14(input, _path, true && _exceptionable), _vp15(input, _path, true && _exceptionable)].every(flag => flag);
210
+ const _vo2 = (input, _path, _exceptionable = true) => [("object" === typeof input.identity && null !== input.identity || _report(_exceptionable, {
211
+ path: _path + ".identity",
212
+ expected: _ve5,
213
+ value: input.identity
214
+ })) && _vo3(input.identity, _path + ".identity", true && _exceptionable) || _report(_exceptionable, {
215
+ path: _path + ".identity",
216
+ expected: _ve5,
217
+ value: input.identity
218
+ }), "censored" === input.status || "measured" === input.status || "missing" === input.status || "unknown" === input.status || "unsupported" === input.status || _report(_exceptionable, {
219
+ path: _path + ".status",
220
+ expected: "(\"censored\" | \"measured\" | \"missing\" | \"unknown\" | \"unsupported\")",
221
+ value: input.status
222
+ }), null === input.value || "number" === typeof input.value || _report(_exceptionable, {
223
+ path: _path + ".value",
224
+ expected: "(null | number)",
225
+ value: input.value
226
+ }), null === input.lower || "number" === typeof input.lower || _report(_exceptionable, {
227
+ path: _path + ".lower",
228
+ expected: "(null | number)",
229
+ value: input.lower
230
+ }), null === input.upper || "number" === typeof input.upper || _report(_exceptionable, {
231
+ path: _path + ".upper",
232
+ expected: "(null | number)",
233
+ value: input.upper
234
+ })].every(flag => flag);
235
+ const _vo3 = (input, _path, _exceptionable = true) => [_vp1(input, _path, true && _exceptionable), _vp8(input, _path, true && _exceptionable), _vp9(input, _path, true && _exceptionable), "string" === typeof input.scenarioVersion || _report(_exceptionable, {
236
+ path: _path + ".scenarioVersion",
237
+ expected: "string",
238
+ value: input.scenarioVersion
239
+ }), "string" === typeof input.specVersion || _report(_exceptionable, {
240
+ path: _path + ".specVersion",
241
+ expected: "string",
242
+ value: input.specVersion
243
+ }), "string" === typeof input.engineId || _report(_exceptionable, {
244
+ path: _path + ".engineId",
245
+ expected: "string",
246
+ value: input.engineId
247
+ }), "string" === typeof input.pluginVersion || _report(_exceptionable, {
248
+ path: _path + ".pluginVersion",
249
+ expected: "string",
250
+ value: input.pluginVersion
251
+ }), "string" === typeof input.seed || _report(_exceptionable, {
252
+ path: _path + ".seed",
253
+ expected: "string",
254
+ value: input.seed
255
+ }), _vp5(input, _path, true && _exceptionable), "string" === typeof input.algorithmVersion || _report(_exceptionable, {
256
+ path: _path + ".algorithmVersion",
257
+ expected: "string",
258
+ value: input.algorithmVersion
259
+ })].every(flag => flag);
260
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
261
+ let errors;
262
+ let _report;
263
+ return _createStandardSchema_1._createStandardSchema(input => {
264
+ if (false === __is(input)) {
265
+ errors = [];
266
+ _report = _validateReport_1._validateReport(errors);
267
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
268
+ path: _path + "",
269
+ expected: _ve0,
270
+ value: input
271
+ })) && _vo0(input, _path + "", true) || _report(true, {
272
+ path: _path + "",
273
+ expected: _ve0,
274
+ value: input
275
+ }))(input, "$input", true);
276
+ const success = 0 === errors.length;
277
+ return success ? {
278
+ success,
279
+ data: input
280
+ } : {
281
+ success,
282
+ errors,
283
+ data: input
284
+ };
285
+ }
286
+ return {
287
+ success: true,
288
+ data: input
289
+ };
290
+ });
291
+ })())(input);
292
+ /**
293
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-failure-report The published validator is createValidate of the balance document.
294
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-failure-report #fd8c2d1 Re-read the section: the error kind validates with the report.
295
+ */
296
+ export const validateBalanceCheckReport = (input) => (validateBalanceCheckReportValidator ??= (() => {
297
+ const _ip0 = input => 1 === input["schemaVersion"];
298
+ const _ip1 = input => "idlekit.balance-checks.v1" === input["contract"];
299
+ const _ip2 = input => null === input["advisory"] || "string" === typeof input["advisory"];
300
+ const _ip3 = input => false === input["baselineRewrite"];
301
+ const _ip4 = input => false === input["externalProvider"];
302
+ const _ve0 = "(Readonly<{ schemaVersion: 1; contract: \"idlekit.balance-checks.v1\"; algorithmVersion: \"balance-checks-1\"; failOn: readonly FailOnToken[]; pass: boolean; exitCode: 0 | 2; results: readonly Readonly<{ id: string; ... 5 more ...; evidence: Readonly<...>; }>[]; advisory: string | null; baselineRewrite: false; externalPr... | Readonly<{ schemaVersion: 1; contract: \"idlekit.balance-checks.v1\"; kind: \"balance-check-error\"; exitCode: 2; failed: readonly Readonly<{ id: string; metricId: string; severity: CheckSeverity; verdict: CheckVerdict; reason: string; mismatches: readonly string[]; evidence: Readonly<...>; }>[]; advisory: string | null...)";
303
+ const _vp0 = (input, _path, _exceptionable = true) => 1 === input["schemaVersion"] || _report(_exceptionable, {
304
+ path: _path + ".schemaVersion",
305
+ expected: "1",
306
+ value: input["schemaVersion"]
307
+ });
308
+ const _vp1 = (input, _path, _exceptionable = true) => "idlekit.balance-checks.v1" === input["contract"] || _report(_exceptionable, {
309
+ path: _path + ".contract",
310
+ expected: "\"idlekit.balance-checks.v1\"",
311
+ value: input["contract"]
312
+ });
313
+ const _ve1 = "Readonly<{ id: string; metricId: string; severity: CheckSeverity; verdict: CheckVerdict; reason: string; mismatches: readonly string[]; evidence: Readonly<{ status: \"absent\" | ObservationStatus; ... 6 more ...; unit: string; }>; }>";
314
+ const _ve2 = "ReadonlyArray<Readonly<{ id: string; metricId: string; severity: CheckSeverity; verdict: CheckVerdict; reason: string; mismatches: readonly string[]; evidence: Readonly<{ status: \"absent\" | ObservationStatus; ... 6 more ...; unit: string; }>; }>>";
315
+ const _vp2 = (input, _path, _exceptionable = true) => null === input["advisory"] || "string" === typeof input["advisory"] || _report(_exceptionable, {
316
+ path: _path + ".advisory",
317
+ expected: "(null | string)",
318
+ value: input["advisory"]
319
+ });
320
+ const _vp3 = (input, _path, _exceptionable = true) => false === input["baselineRewrite"] || _report(_exceptionable, {
321
+ path: _path + ".baselineRewrite",
322
+ expected: "false",
323
+ value: input["baselineRewrite"]
324
+ });
325
+ const _vp4 = (input, _path, _exceptionable = true) => false === input["externalProvider"] || _report(_exceptionable, {
326
+ path: _path + ".externalProvider",
327
+ expected: "false",
328
+ value: input["externalProvider"]
329
+ });
330
+ const _ve3 = "Readonly<{ status: \"absent\" | ObservationStatus; value: number | null; lower: number | null; upper: number | null; operator: CheckOperator; threshold: number; upperThreshold: number | null; unit: string; }>";
331
+ const _io0 = input => _ip0(input) && _ip1(input) && "balance-checks-1" === input.algorithmVersion && (Array.isArray(input.failOn) && input.failOn.every(elem => "error" === elem || "inconclusive" === elem || "unsupported" === elem || "warn" === elem)) && "boolean" === typeof input.pass && (0 === input.exitCode || 2 === input.exitCode) && (Array.isArray(input.results) && input.results.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && _ip2(input) && _ip3(input) && _ip4(input);
332
+ const _io1 = input => "string" === typeof input.id && "string" === typeof input.metricId && ("error" === input.severity || "warn" === input.severity) && ("fail" === input.verdict || "inconclusive" === input.verdict || "pass" === input.verdict || "unsupported" === input.verdict) && "string" === typeof input.reason && (Array.isArray(input.mismatches) && input.mismatches.every(elem => "string" === typeof elem)) && ("object" === typeof input.evidence && null !== input.evidence && _io2(input.evidence));
333
+ const _io2 = input => ("absent" === input.status || "censored" === input.status || "measured" === input.status || "missing" === input.status || "unknown" === input.status || "unsupported" === input.status) && (null === input.value || "number" === typeof input.value) && (null === input.lower || "number" === typeof input.lower) && (null === input.upper || "number" === typeof input.upper) && ("between" === input.operator || "eq" === input.operator || "gt" === input.operator || "gte" === input.operator || "lt" === input.operator || "lte" === input.operator) && "number" === typeof input.threshold && (null === input.upperThreshold || "number" === typeof input.upperThreshold) && "string" === typeof input.unit;
334
+ const _io3 = input => _ip0(input) && _ip1(input) && "balance-check-error" === input.kind && 2 === input.exitCode && (Array.isArray(input.failed) && input.failed.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && _ip2(input) && _ip3(input) && _ip4(input);
335
+ const _iu0 = input => (() => {
336
+ if (undefined !== input.algorithmVersion)
337
+ return _io0(input);
338
+ else if (undefined !== input.kind)
339
+ return _io3(input);
340
+ else
341
+ return false;
342
+ })();
343
+ const _vo0 = (input, _path, _exceptionable = true) => [_vp0(input, _path, true && _exceptionable), _vp1(input, _path, true && _exceptionable), "balance-checks-1" === input.algorithmVersion || _report(_exceptionable, {
344
+ path: _path + ".algorithmVersion",
345
+ expected: "\"balance-checks-1\"",
346
+ value: input.algorithmVersion
347
+ }), (Array.isArray(input.failOn) || _report(_exceptionable, {
348
+ path: _path + ".failOn",
349
+ expected: "ReadonlyArray<FailOnToken>",
350
+ value: input.failOn
351
+ })) && input.failOn.map((elem, _index5) => "error" === elem || "inconclusive" === elem || "unsupported" === elem || "warn" === elem || _report(_exceptionable, {
352
+ path: _path + ".failOn[" + _index5 + "]",
353
+ expected: "(\"error\" | \"inconclusive\" | \"unsupported\" | \"warn\")",
354
+ value: elem
355
+ })).every(flag => flag) || _report(_exceptionable, {
356
+ path: _path + ".failOn",
357
+ expected: "ReadonlyArray<FailOnToken>",
358
+ value: input.failOn
359
+ }), "boolean" === typeof input.pass || _report(_exceptionable, {
360
+ path: _path + ".pass",
361
+ expected: "boolean",
362
+ value: input.pass
363
+ }), 0 === input.exitCode || 2 === input.exitCode || _report(_exceptionable, {
364
+ path: _path + ".exitCode",
365
+ expected: "(0 | 2)",
366
+ value: input.exitCode
367
+ }), (Array.isArray(input.results) || _report(_exceptionable, {
368
+ path: _path + ".results",
369
+ expected: _ve2,
370
+ value: input.results
371
+ })) && input.results.map((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
372
+ path: _path + ".results[" + _index6 + "]",
373
+ expected: _ve1,
374
+ value: elem
375
+ })) && _vo1(elem, _path + ".results[" + _index6 + "]", true && _exceptionable) || _report(_exceptionable, {
376
+ path: _path + ".results[" + _index6 + "]",
377
+ expected: _ve1,
378
+ value: elem
379
+ })).every(flag => flag) || _report(_exceptionable, {
380
+ path: _path + ".results",
381
+ expected: _ve2,
382
+ value: input.results
383
+ }), _vp2(input, _path, true && _exceptionable), _vp3(input, _path, true && _exceptionable), _vp4(input, _path, true && _exceptionable)].every(flag => flag);
384
+ const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
385
+ path: _path + ".id",
386
+ expected: "string",
387
+ value: input.id
388
+ }), "string" === typeof input.metricId || _report(_exceptionable, {
389
+ path: _path + ".metricId",
390
+ expected: "string",
391
+ value: input.metricId
392
+ }), "error" === input.severity || "warn" === input.severity || _report(_exceptionable, {
393
+ path: _path + ".severity",
394
+ expected: "(\"error\" | \"warn\")",
395
+ value: input.severity
396
+ }), "fail" === input.verdict || "inconclusive" === input.verdict || "pass" === input.verdict || "unsupported" === input.verdict || _report(_exceptionable, {
397
+ path: _path + ".verdict",
398
+ expected: "(\"fail\" | \"inconclusive\" | \"pass\" | \"unsupported\")",
399
+ value: input.verdict
400
+ }), "string" === typeof input.reason || _report(_exceptionable, {
401
+ path: _path + ".reason",
402
+ expected: "string",
403
+ value: input.reason
404
+ }), (Array.isArray(input.mismatches) || _report(_exceptionable, {
405
+ path: _path + ".mismatches",
406
+ expected: "ReadonlyArray<string>",
407
+ value: input.mismatches
408
+ })) && input.mismatches.map((elem, _index7) => "string" === typeof elem || _report(_exceptionable, {
409
+ path: _path + ".mismatches[" + _index7 + "]",
410
+ expected: "string",
411
+ value: elem
412
+ })).every(flag => flag) || _report(_exceptionable, {
413
+ path: _path + ".mismatches",
414
+ expected: "ReadonlyArray<string>",
415
+ value: input.mismatches
416
+ }), ("object" === typeof input.evidence && null !== input.evidence || _report(_exceptionable, {
417
+ path: _path + ".evidence",
418
+ expected: _ve3,
419
+ value: input.evidence
420
+ })) && _vo2(input.evidence, _path + ".evidence", true && _exceptionable) || _report(_exceptionable, {
421
+ path: _path + ".evidence",
422
+ expected: _ve3,
423
+ value: input.evidence
424
+ })].every(flag => flag);
425
+ const _vo2 = (input, _path, _exceptionable = true) => ["absent" === input.status || "censored" === input.status || "measured" === input.status || "missing" === input.status || "unknown" === input.status || "unsupported" === input.status || _report(_exceptionable, {
426
+ path: _path + ".status",
427
+ expected: "(\"absent\" | \"censored\" | \"measured\" | \"missing\" | \"unknown\" | \"unsupported\")",
428
+ value: input.status
429
+ }), null === input.value || "number" === typeof input.value || _report(_exceptionable, {
430
+ path: _path + ".value",
431
+ expected: "(null | number)",
432
+ value: input.value
433
+ }), null === input.lower || "number" === typeof input.lower || _report(_exceptionable, {
434
+ path: _path + ".lower",
435
+ expected: "(null | number)",
436
+ value: input.lower
437
+ }), null === input.upper || "number" === typeof input.upper || _report(_exceptionable, {
438
+ path: _path + ".upper",
439
+ expected: "(null | number)",
440
+ value: input.upper
441
+ }), "between" === input.operator || "eq" === input.operator || "gt" === input.operator || "gte" === input.operator || "lt" === input.operator || "lte" === input.operator || _report(_exceptionable, {
442
+ path: _path + ".operator",
443
+ expected: "(\"between\" | \"eq\" | \"gt\" | \"gte\" | \"lt\" | \"lte\")",
444
+ value: input.operator
445
+ }), "number" === typeof input.threshold || _report(_exceptionable, {
446
+ path: _path + ".threshold",
447
+ expected: "number",
448
+ value: input.threshold
449
+ }), null === input.upperThreshold || "number" === typeof input.upperThreshold || _report(_exceptionable, {
450
+ path: _path + ".upperThreshold",
451
+ expected: "(null | number)",
452
+ value: input.upperThreshold
453
+ }), "string" === typeof input.unit || _report(_exceptionable, {
454
+ path: _path + ".unit",
455
+ expected: "string",
456
+ value: input.unit
457
+ })].every(flag => flag);
458
+ const _vo3 = (input, _path, _exceptionable = true) => [_vp0(input, _path, true && _exceptionable), _vp1(input, _path, true && _exceptionable), "balance-check-error" === input.kind || _report(_exceptionable, {
459
+ path: _path + ".kind",
460
+ expected: "\"balance-check-error\"",
461
+ value: input.kind
462
+ }), 2 === input.exitCode || _report(_exceptionable, {
463
+ path: _path + ".exitCode",
464
+ expected: "2",
465
+ value: input.exitCode
466
+ }), (Array.isArray(input.failed) || _report(_exceptionable, {
467
+ path: _path + ".failed",
468
+ expected: _ve2,
469
+ value: input.failed
470
+ })) && input.failed.map((elem, _index8) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
471
+ path: _path + ".failed[" + _index8 + "]",
472
+ expected: _ve1,
473
+ value: elem
474
+ })) && _vo1(elem, _path + ".failed[" + _index8 + "]", true && _exceptionable) || _report(_exceptionable, {
475
+ path: _path + ".failed[" + _index8 + "]",
476
+ expected: _ve1,
477
+ value: elem
478
+ })).every(flag => flag) || _report(_exceptionable, {
479
+ path: _path + ".failed",
480
+ expected: _ve2,
481
+ value: input.failed
482
+ }), _vp2(input, _path, true && _exceptionable), _vp3(input, _path, true && _exceptionable), _vp4(input, _path, true && _exceptionable)].every(flag => flag);
483
+ const _vu0 = (input, _path, _exceptionable = true) => (() => {
484
+ if (undefined !== input.algorithmVersion)
485
+ return _vo0(input, _path, true && _exceptionable);
486
+ else if (undefined !== input.kind)
487
+ return _vo3(input, _path, true && _exceptionable);
488
+ else
489
+ return _report(_exceptionable, {
490
+ path: _path,
491
+ expected: _ve0,
492
+ value: input
493
+ });
494
+ })();
495
+ const __is = input => "object" === typeof input && null !== input && _iu0(input);
496
+ let errors;
497
+ let _report;
498
+ return _createStandardSchema_1._createStandardSchema(input => {
499
+ if (false === __is(input)) {
500
+ errors = [];
501
+ _report = _validateReport_1._validateReport(errors);
502
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
503
+ path: _path + "",
504
+ expected: _ve0,
505
+ value: input
506
+ })) && _vu0(input, _path + "", true) || _report(true, {
507
+ path: _path + "",
508
+ expected: _ve0,
509
+ value: input
510
+ }))(input, "$input", true);
511
+ const success = 0 === errors.length;
512
+ return success ? {
513
+ success,
514
+ data: input
515
+ } : {
516
+ success,
517
+ errors,
518
+ data: input
519
+ };
520
+ }
521
+ return {
522
+ success: true,
523
+ data: input
524
+ };
525
+ });
526
+ })())(input);
527
+ function buildBalanceChecksJsonSchema() {
528
+ return {
529
+ components: {
530
+ schemas: {
531
+ BalanceCheckDocumentV1: {
532
+ oneOf: [
533
+ {
534
+ $ref: "#/components/schemas/ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1algorithmVersionbalance-checks-1failOnreadonlyFailOnTokenpassbooleanexitCode02resultsreadonlyReadonlyidstring---5more---evidenceReadonly---advisorystringnullbaselineRewritefalseexternalPr----xF9B05F531712B64E"
535
+ },
536
+ {
537
+ $ref: "#/components/schemas/ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1kindbalance-check-errorexitCode2failedreadonlyReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonly---advisorystringnull----x4FEBABB14C8879F1"
538
+ }
539
+ ]
540
+ },
541
+ "ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1algorithmVersionbalance-checks-1failOnreadonlyFailOnTokenpassbooleanexitCode02resultsreadonlyReadonlyidstring---5more---evidenceReadonly---advisorystringnullbaselineRewritefalseexternalPr----xF9B05F531712B64E": {
542
+ type: "object",
543
+ properties: {
544
+ schemaVersion: {
545
+ "const": 1
546
+ },
547
+ contract: {
548
+ "const": "idlekit.balance-checks.v1"
549
+ },
550
+ algorithmVersion: {
551
+ "const": "balance-checks-1"
552
+ },
553
+ failOn: {
554
+ type: "array",
555
+ items: {
556
+ $ref: "#/components/schemas/FailOnToken"
557
+ }
558
+ },
559
+ pass: {
560
+ type: "boolean"
561
+ },
562
+ exitCode: {
563
+ oneOf: [
564
+ {
565
+ "const": 0
566
+ },
567
+ {
568
+ "const": 2
569
+ }
570
+ ]
571
+ },
572
+ results: {
573
+ type: "array",
574
+ items: {
575
+ $ref: "#/components/schemas/ReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonlystatusabsentObservationStatus---6more---unitstring"
576
+ }
577
+ },
578
+ advisory: {
579
+ oneOf: [
580
+ {
581
+ type: "null"
582
+ },
583
+ {
584
+ type: "string"
585
+ }
586
+ ]
587
+ },
588
+ baselineRewrite: {
589
+ "const": false
590
+ },
591
+ externalProvider: {
592
+ "const": false
593
+ }
594
+ },
595
+ required: [
596
+ "schemaVersion",
597
+ "contract",
598
+ "algorithmVersion",
599
+ "failOn",
600
+ "pass",
601
+ "exitCode",
602
+ "results",
603
+ "advisory",
604
+ "baselineRewrite",
605
+ "externalProvider"
606
+ ],
607
+ additionalProperties: false
608
+ },
609
+ FailOnToken: {
610
+ oneOf: [
611
+ {
612
+ "const": "error"
613
+ },
614
+ {
615
+ "const": "inconclusive"
616
+ },
617
+ {
618
+ "const": "unsupported"
619
+ },
620
+ {
621
+ "const": "warn"
622
+ }
623
+ ]
624
+ },
625
+ "ReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonlystatusabsentObservationStatus---6more---unitstring": {
626
+ type: "object",
627
+ properties: {
628
+ id: {
629
+ type: "string"
630
+ },
631
+ metricId: {
632
+ type: "string"
633
+ },
634
+ severity: {
635
+ $ref: "#/components/schemas/CheckSeverity"
636
+ },
637
+ verdict: {
638
+ $ref: "#/components/schemas/CheckVerdict"
639
+ },
640
+ reason: {
641
+ type: "string"
642
+ },
643
+ mismatches: {
644
+ type: "array",
645
+ items: {
646
+ type: "string"
647
+ }
648
+ },
649
+ evidence: {
650
+ $ref: "#/components/schemas/ReadonlystatusabsentObservationStatusvaluenumbernulllowernumbernulluppernumbernulloperatorCheckOperatorthresholdnumberupperThresholdnumbernullunitstring"
651
+ }
652
+ },
653
+ required: [
654
+ "id",
655
+ "metricId",
656
+ "severity",
657
+ "verdict",
658
+ "reason",
659
+ "mismatches",
660
+ "evidence"
661
+ ],
662
+ additionalProperties: false
663
+ },
664
+ CheckSeverity: {
665
+ oneOf: [
666
+ {
667
+ "const": "error"
668
+ },
669
+ {
670
+ "const": "warn"
671
+ }
672
+ ]
673
+ },
674
+ CheckVerdict: {
675
+ oneOf: [
676
+ {
677
+ "const": "fail"
678
+ },
679
+ {
680
+ "const": "inconclusive"
681
+ },
682
+ {
683
+ "const": "pass"
684
+ },
685
+ {
686
+ "const": "unsupported"
687
+ }
688
+ ]
689
+ },
690
+ ReadonlystatusabsentObservationStatusvaluenumbernulllowernumbernulluppernumbernulloperatorCheckOperatorthresholdnumberupperThresholdnumbernullunitstring: {
691
+ type: "object",
692
+ properties: {
693
+ status: {
694
+ oneOf: [
695
+ {
696
+ "const": "absent"
697
+ },
698
+ {
699
+ "const": "censored"
700
+ },
701
+ {
702
+ "const": "measured"
703
+ },
704
+ {
705
+ "const": "missing"
706
+ },
707
+ {
708
+ "const": "unknown"
709
+ },
710
+ {
711
+ "const": "unsupported"
712
+ }
713
+ ]
714
+ },
715
+ value: {
716
+ oneOf: [
717
+ {
718
+ type: "null"
719
+ },
720
+ {
721
+ type: "number"
722
+ }
723
+ ]
724
+ },
725
+ lower: {
726
+ oneOf: [
727
+ {
728
+ type: "null"
729
+ },
730
+ {
731
+ type: "number"
732
+ }
733
+ ]
734
+ },
735
+ upper: {
736
+ oneOf: [
737
+ {
738
+ type: "null"
739
+ },
740
+ {
741
+ type: "number"
742
+ }
743
+ ]
744
+ },
745
+ operator: {
746
+ $ref: "#/components/schemas/CheckOperator"
747
+ },
748
+ threshold: {
749
+ type: "number"
750
+ },
751
+ upperThreshold: {
752
+ oneOf: [
753
+ {
754
+ type: "null"
755
+ },
756
+ {
757
+ type: "number"
758
+ }
759
+ ]
760
+ },
761
+ unit: {
762
+ type: "string"
763
+ }
764
+ },
765
+ required: [
766
+ "status",
767
+ "value",
768
+ "lower",
769
+ "upper",
770
+ "operator",
771
+ "threshold",
772
+ "upperThreshold",
773
+ "unit"
774
+ ],
775
+ additionalProperties: false
776
+ },
777
+ CheckOperator: {
778
+ oneOf: [
779
+ {
780
+ "const": "between"
781
+ },
782
+ {
783
+ "const": "eq"
784
+ },
785
+ {
786
+ "const": "gt"
787
+ },
788
+ {
789
+ "const": "gte"
790
+ },
791
+ {
792
+ "const": "lt"
793
+ },
794
+ {
795
+ "const": "lte"
796
+ }
797
+ ]
798
+ },
799
+ "ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1kindbalance-check-errorexitCode2failedreadonlyReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonly---advisorystringnull----x4FEBABB14C8879F1": {
800
+ type: "object",
801
+ properties: {
802
+ schemaVersion: {
803
+ "const": 1
804
+ },
805
+ contract: {
806
+ "const": "idlekit.balance-checks.v1"
807
+ },
808
+ kind: {
809
+ "const": "balance-check-error"
810
+ },
811
+ exitCode: {
812
+ "const": 2
813
+ },
814
+ failed: {
815
+ type: "array",
816
+ items: {
817
+ $ref: "#/components/schemas/ReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonlystatusabsentObservationStatus---6more---unitstring"
818
+ }
819
+ },
820
+ advisory: {
821
+ oneOf: [
822
+ {
823
+ type: "null"
824
+ },
825
+ {
826
+ type: "string"
827
+ }
828
+ ]
829
+ },
830
+ baselineRewrite: {
831
+ "const": false
832
+ },
833
+ externalProvider: {
834
+ "const": false
835
+ }
836
+ },
837
+ required: [
838
+ "schemaVersion",
839
+ "contract",
840
+ "kind",
841
+ "exitCode",
842
+ "failed",
843
+ "advisory",
844
+ "baselineRewrite",
845
+ "externalProvider"
846
+ ],
847
+ additionalProperties: false
848
+ }
849
+ }
850
+ },
851
+ schema: {
852
+ oneOf: [
853
+ {
854
+ $ref: "#/components/schemas/ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1algorithmVersionbalance-checks-1failOnreadonlyFailOnTokenpassbooleanexitCode02resultsreadonlyReadonlyidstring---5more---evidenceReadonly---advisorystringnullbaselineRewritefalseexternalPr----xF9B05F531712B64E"
855
+ },
856
+ {
857
+ $ref: "#/components/schemas/ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1kindbalance-check-errorexitCode2failedreadonlyReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonly---advisorystringnull----x4FEBABB14C8879F1"
858
+ }
859
+ ]
860
+ },
861
+ version: "3.1"
862
+ };
863
+ }
864
+ let balanceChecksJsonSchemaUnit;
865
+ /**
866
+ * @evidence docs/requirements/active/balance-checks.md#req-pr17-failure-report The structural schema is OpenAPI 3.1 from typia.
867
+ * @evidenceReview docs/requirements/active/balance-checks.md#req-pr17-failure-report #fd8c2d1 Re-read the section: schema version is 3.1 and the contract id is idlekit.balance-checks.v1.
868
+ */
869
+ export function balanceChecksJsonSchema() {
870
+ balanceChecksJsonSchemaUnit ??= buildBalanceChecksJsonSchema();
871
+ return balanceChecksJsonSchemaUnit;
872
+ }
873
+ export function balanceChecksSchemaId() {
874
+ return "https://idlekit.dev/schemas/balance-checks.v1.schema.json";
875
+ }
876
+ export function balanceChecksAlgorithmVersion() {
877
+ return "balance-checks-1";
878
+ }
879
+ const FAIL_ON = ["error", "warn", "inconclusive", "unsupported"];
880
+ export function parseFailOn(raw) {
881
+ const parts = raw.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
882
+ if (parts.length === 0 || parts.some((part) => !FAIL_ON.includes(part)))
883
+ return null;
884
+ return parts;
885
+ }
886
+ export function parseBalanceCheckRequest(input) {
887
+ const validated = validateRequest(input);
888
+ if (validated.success) {
889
+ // An empty gate is not a pass. A check file must name at least one check.
890
+ if (validated.data.checks.length === 0)
891
+ return { ok: false, issues: ["$input.checks at least one check"] };
892
+ return { ok: true, request: validated.data };
893
+ }
894
+ return {
895
+ ok: false,
896
+ issues: validated.errors.map((error) => `${error.path} ${error.expected}`),
897
+ };
898
+ }
899
+ const ASSERTION_TERM = /^([A-Za-z_][A-Za-z0-9_.]*)\s*(<=|>=|==|!=|<|>)\s*([^\s&|]+)$/;
900
+ export function classifyAssertionExpr(expr) {
901
+ if (expr.trim().length === 0)
902
+ return { status: "unsupported", reason: "empty assertion" };
903
+ // Empty clauses are kept, so `a <= 1 ||` and `a <= 1 && && b >= 2` stay outside the grammar.
904
+ const disjunction = expr.split("||").map((part) => part.trim());
905
+ const terms = [];
906
+ for (const clause of disjunction) {
907
+ if (clause.length === 0)
908
+ return { status: "unsupported", reason: "empty clause" };
909
+ const conjunction = clause.split("&&").map((part) => part.trim());
910
+ if (conjunction.some((part) => part.length === 0))
911
+ return { status: "unsupported", reason: "empty term" };
912
+ const parsed = [];
913
+ for (const raw of conjunction) {
914
+ const match = ASSERTION_TERM.exec(raw);
915
+ if (!match?.[1] || !match[2] || !match[3]) {
916
+ return { status: "unsupported", reason: "term is not path, operator, value" };
917
+ }
918
+ parsed.push({ path: match[1], op: match[2], value: match[3] });
919
+ }
920
+ terms.push(parsed);
921
+ }
922
+ return { status: "supported", terms };
923
+ }
924
+ function finite(value) {
925
+ return typeof value === "number" && Number.isFinite(value);
926
+ }
927
+ function jsonNumber(value) {
928
+ return finite(value) ? value : null;
929
+ }
930
+ function pointSatisfies(operator, value, threshold, upper) {
931
+ if (operator === "between") {
932
+ if (!finite(upper) || !finite(threshold) || threshold > upper)
933
+ return "unsupported";
934
+ if (!finite(value))
935
+ return false;
936
+ return value >= threshold && value <= upper;
937
+ }
938
+ if (!finite(threshold) || !finite(value))
939
+ return false;
940
+ if (operator === "lt")
941
+ return value < threshold;
942
+ if (operator === "lte")
943
+ return value <= threshold;
944
+ if (operator === "gt")
945
+ return value > threshold;
946
+ if (operator === "gte")
947
+ return value >= threshold;
948
+ return value === threshold;
949
+ }
950
+ function measuredVerdict(operator, threshold, upper, value) {
951
+ if (Number.isNaN(value))
952
+ return "inconclusive";
953
+ if (value === Number.POSITIVE_INFINITY) {
954
+ if (operator === "gt" || operator === "gte")
955
+ return finite(threshold) ? "pass" : "unsupported";
956
+ return "fail";
957
+ }
958
+ if (value === Number.NEGATIVE_INFINITY) {
959
+ if (operator === "lt" || operator === "lte")
960
+ return finite(threshold) ? "pass" : "unsupported";
961
+ return "fail";
962
+ }
963
+ const satisfied = pointSatisfies(operator, value, threshold, upper);
964
+ if (satisfied === "unsupported")
965
+ return "unsupported";
966
+ return satisfied ? "pass" : "fail";
967
+ }
968
+ function intervalVerdict(operator, threshold, upperThreshold, lower, upper) {
969
+ const low = finite(lower) ? lower : null;
970
+ const high = finite(upper) ? upper : null;
971
+ // Contradictory bounds describe no value, so they cannot decide a comparison.
972
+ if (low !== null && high !== null && low > high)
973
+ return "inconclusive";
974
+ if (operator === "between") {
975
+ if (!finite(upperThreshold) || !finite(threshold) || threshold > upperThreshold)
976
+ return "unsupported";
977
+ if (low !== null && high !== null && low >= threshold && high <= upperThreshold)
978
+ return "pass";
979
+ if ((high !== null && high < threshold) || (low !== null && low > upperThreshold))
980
+ return "fail";
981
+ return "inconclusive";
982
+ }
983
+ if (!finite(threshold))
984
+ return "unsupported";
985
+ if (operator === "lt") {
986
+ if (high !== null && high < threshold)
987
+ return "pass";
988
+ if (low !== null && low >= threshold)
989
+ return "fail";
990
+ return "inconclusive";
991
+ }
992
+ if (operator === "lte") {
993
+ if (high !== null && high <= threshold)
994
+ return "pass";
995
+ if (low !== null && low > threshold)
996
+ return "fail";
997
+ return "inconclusive";
998
+ }
999
+ if (operator === "gt") {
1000
+ if (low !== null && low > threshold)
1001
+ return "pass";
1002
+ if (high !== null && high <= threshold)
1003
+ return "fail";
1004
+ return "inconclusive";
1005
+ }
1006
+ if (operator === "gte") {
1007
+ if (low !== null && low >= threshold)
1008
+ return "pass";
1009
+ if (high !== null && high < threshold)
1010
+ return "fail";
1011
+ return "inconclusive";
1012
+ }
1013
+ if (low !== null && high !== null && low === threshold && high === threshold)
1014
+ return "pass";
1015
+ if ((high !== null && high < threshold) || (low !== null && low > threshold))
1016
+ return "fail";
1017
+ return "inconclusive";
1018
+ }
1019
+ function identityMismatches(check, observation) {
1020
+ const found = [];
1021
+ const identity = observation.identity;
1022
+ if (identity.metricId !== check.metricId)
1023
+ found.push("metricId");
1024
+ if (identity.definition !== check.definition)
1025
+ found.push("definition");
1026
+ if (identity.method !== check.method)
1027
+ found.push("method");
1028
+ if (identity.unit !== check.unit)
1029
+ found.push("unit");
1030
+ if (check.scenarioVersion !== null && identity.scenarioVersion !== check.scenarioVersion)
1031
+ found.push("scenarioVersion");
1032
+ if (check.specVersion !== null && identity.specVersion !== check.specVersion)
1033
+ found.push("specVersion");
1034
+ if (check.engineId !== null && identity.engineId !== check.engineId)
1035
+ found.push("engineId");
1036
+ if (check.pluginVersion !== null && identity.pluginVersion !== check.pluginVersion)
1037
+ found.push("pluginVersion");
1038
+ if (check.seed !== null && identity.seed !== check.seed)
1039
+ found.push("seed");
1040
+ if (check.algorithmVersion !== null && identity.algorithmVersion !== check.algorithmVersion) {
1041
+ found.push("algorithmVersion");
1042
+ }
1043
+ return found;
1044
+ }
1045
+ function evidenceOf(check, observation) {
1046
+ const hide = !observation || observation.status === "missing" || observation.status === "unsupported";
1047
+ return {
1048
+ status: observation?.status ?? "absent",
1049
+ value: hide ? null : jsonNumber(observation.value),
1050
+ lower: hide ? null : jsonNumber(observation.lower),
1051
+ upper: hide ? null : jsonNumber(observation.upper),
1052
+ operator: check.operator,
1053
+ threshold: check.threshold,
1054
+ upperThreshold: check.upperThreshold,
1055
+ unit: check.unit,
1056
+ };
1057
+ }
1058
+ /**
1059
+ * Select by the identity the check declares, not by metric id alone. A later observation
1060
+ * that matches every pinned field wins over an earlier mismatch. Two full matches are ambiguous.
1061
+ */
1062
+ function matchObservation(check, observations) {
1063
+ const sameMetric = observations.filter((observation) => observation.identity.metricId === check.metricId);
1064
+ const exact = sameMetric.filter((observation) => identityMismatches(check, observation).length === 0);
1065
+ if (exact.length > 1)
1066
+ return { kind: "ambiguous", count: exact.length };
1067
+ return { kind: "one", observation: exact[0] ?? sameMetric[0] };
1068
+ }
1069
+ function judgeOne(check, match) {
1070
+ if (match.kind === "ambiguous") {
1071
+ return {
1072
+ id: check.id,
1073
+ metricId: check.metricId,
1074
+ severity: check.severity,
1075
+ verdict: "inconclusive",
1076
+ reason: `ambiguous ${match.count} observations match the check identity`,
1077
+ mismatches: [],
1078
+ evidence: evidenceOf(check, undefined),
1079
+ };
1080
+ }
1081
+ const observation = match.observation;
1082
+ const evidence = evidenceOf(check, observation);
1083
+ if (!observation) {
1084
+ return {
1085
+ id: check.id,
1086
+ metricId: check.metricId,
1087
+ severity: check.severity,
1088
+ verdict: check.missingPolicy,
1089
+ reason: "required metric is absent",
1090
+ mismatches: [],
1091
+ evidence,
1092
+ };
1093
+ }
1094
+ const mismatches = identityMismatches(check, observation);
1095
+ if (mismatches.length > 0) {
1096
+ return {
1097
+ id: check.id,
1098
+ metricId: check.metricId,
1099
+ severity: check.severity,
1100
+ verdict: "inconclusive",
1101
+ reason: `mismatch ${mismatches.join(",")}`,
1102
+ mismatches,
1103
+ evidence,
1104
+ };
1105
+ }
1106
+ if (observation.status === "missing") {
1107
+ return {
1108
+ id: check.id,
1109
+ metricId: check.metricId,
1110
+ severity: check.severity,
1111
+ verdict: check.missingPolicy,
1112
+ reason: "required metric is missing",
1113
+ mismatches: [],
1114
+ evidence,
1115
+ };
1116
+ }
1117
+ if (observation.status === "unsupported") {
1118
+ return {
1119
+ id: check.id,
1120
+ metricId: check.metricId,
1121
+ severity: check.severity,
1122
+ verdict: "unsupported",
1123
+ reason: "metric is unsupported",
1124
+ mismatches: [],
1125
+ evidence,
1126
+ };
1127
+ }
1128
+ if (observation.status === "measured") {
1129
+ if (!finite(observation.value) && observation.value !== Number.POSITIVE_INFINITY && observation.value !== Number.NEGATIVE_INFINITY) {
1130
+ return {
1131
+ id: check.id,
1132
+ metricId: check.metricId,
1133
+ severity: check.severity,
1134
+ verdict: "inconclusive",
1135
+ reason: "measured value is absent",
1136
+ mismatches: [],
1137
+ evidence,
1138
+ };
1139
+ }
1140
+ const verdict = measuredVerdict(check.operator, check.threshold, check.upperThreshold, observation.value);
1141
+ return {
1142
+ id: check.id,
1143
+ metricId: check.metricId,
1144
+ severity: check.severity,
1145
+ verdict,
1146
+ reason: verdict === "pass" ? "measured point satisfies the check" : "measured point does not satisfy the check",
1147
+ mismatches: [],
1148
+ evidence,
1149
+ };
1150
+ }
1151
+ const verdict = intervalVerdict(check.operator, check.threshold, check.upperThreshold, observation.lower, observation.upper);
1152
+ const inverted = finite(observation.lower) && finite(observation.upper) && observation.lower > observation.upper;
1153
+ return {
1154
+ id: check.id,
1155
+ metricId: check.metricId,
1156
+ severity: check.severity,
1157
+ verdict,
1158
+ reason: inverted
1159
+ ? "bounds are contradictory"
1160
+ : verdict === "inconclusive"
1161
+ ? "bounds do not decide the comparison"
1162
+ : "bounds decide the comparison",
1163
+ mismatches: [],
1164
+ evidence,
1165
+ };
1166
+ }
1167
+ function blocks(result, failOn) {
1168
+ if (result.verdict === "pass")
1169
+ return false;
1170
+ if (result.verdict === "fail")
1171
+ return failOn.includes(result.severity);
1172
+ return failOn.includes(result.verdict) || failOn.includes(result.severity);
1173
+ }
1174
+ export function evaluateBalanceChecks(request) {
1175
+ const results = request.checks.map((check) => judgeOne(check, matchObservation(check, request.observations)));
1176
+ const pass = results.every((result) => !blocks(result, request.failOn));
1177
+ return {
1178
+ schemaVersion: 1,
1179
+ contract: "idlekit.balance-checks.v1",
1180
+ algorithmVersion: "balance-checks-1",
1181
+ failOn: request.failOn,
1182
+ pass,
1183
+ exitCode: pass ? 0 : 2,
1184
+ results,
1185
+ advisory: request.advisory,
1186
+ baselineRewrite: false,
1187
+ externalProvider: false,
1188
+ };
1189
+ }
1190
+ export function toBalanceCheckError(report) {
1191
+ return {
1192
+ schemaVersion: 1,
1193
+ contract: "idlekit.balance-checks.v1",
1194
+ kind: "balance-check-error",
1195
+ exitCode: 2,
1196
+ failed: report.results.filter((result) => blocks(result, report.failOn)),
1197
+ advisory: report.advisory,
1198
+ baselineRewrite: false,
1199
+ externalProvider: false,
1200
+ };
1201
+ }
1202
+ export function renderBalanceCheckMarkdown(report) {
1203
+ const failed = "failed" in report ? report.failed : report.results.filter((result) => result.verdict !== "pass");
1204
+ const lines = ["# Balance checks", "", `Pass: ${"pass" in report ? report.pass : false}`, "", "## Failed metrics", ""];
1205
+ if (failed.length === 0)
1206
+ lines.push("None.");
1207
+ for (const row of failed) {
1208
+ lines.push(`- ${row.metricId} (${row.id}): ${row.verdict} ${row.severity}`);
1209
+ lines.push(` - evidence status ${row.evidence.status} value ${String(row.evidence.value)} lower ${String(row.evidence.lower)} upper ${String(row.evidence.upper)} ${row.evidence.operator} ${row.evidence.threshold} ${row.evidence.unit}`);
1210
+ if (row.mismatches.length > 0)
1211
+ lines.push(` - mismatch ${row.mismatches.join(", ")}`);
1212
+ lines.push(` - ${row.reason}`);
1213
+ }
1214
+ if (report.advisory) {
1215
+ lines.push("", "## Advisory", "", report.advisory, "", "Advisory is not a pass or fail.");
1216
+ }
1217
+ return lines.join("\n");
1218
+ }
1219
+ function asRecord(value) {
1220
+ if (!value || typeof value !== "object" || Array.isArray(value))
1221
+ return null;
1222
+ return value;
1223
+ }
1224
+ function readHorizon(report, side, horizon) {
1225
+ const root = asRecord(report);
1226
+ const ltv = asRecord(root?.ltv);
1227
+ const sideRow = asRecord(ltv?.[side]);
1228
+ const summary = asRecord(sideRow?.summary);
1229
+ const row = asRecord(summary?.[horizon]);
1230
+ if (!row)
1231
+ throw new Error(`Missing horizon '${horizon}' for side '${side}'`);
1232
+ return row;
1233
+ }
1234
+ function toLog10(value) {
1235
+ if (typeof value === "number") {
1236
+ if (value <= 0)
1237
+ return Number.NEGATIVE_INFINITY;
1238
+ return Math.log10(value);
1239
+ }
1240
+ if (typeof value !== "string")
1241
+ throw new Error(`Expected numeric string, got ${typeof value}`);
1242
+ const text = value.trim().toLowerCase();
1243
+ if (!text || text === "0")
1244
+ return Number.NEGATIVE_INFINITY;
1245
+ const asNum = Number(text);
1246
+ if (Number.isFinite(asNum) && asNum > 0)
1247
+ return Math.log10(asNum);
1248
+ const sci = text.match(/^([+-]?\d+(?:\.\d+)?)e([+-]?\d+)$/);
1249
+ if (sci) {
1250
+ const mantissa = Number(sci[1] ?? "");
1251
+ const exponent = Number(sci[2] ?? "");
1252
+ if (!Number.isFinite(mantissa) || !Number.isFinite(exponent) || mantissa <= 0) {
1253
+ throw new Error(`Invalid numeric string: ${value}`);
1254
+ }
1255
+ return Math.log10(mantissa) + exponent;
1256
+ }
1257
+ throw new Error(`Unsupported numeric string: ${value}`);
1258
+ }
1259
+ function kpiIdentity(metricId, unit) {
1260
+ return {
1261
+ metricId,
1262
+ definition: "kpi-regress-v1",
1263
+ method: "legacy-delta",
1264
+ scenarioVersion: "kpi-report",
1265
+ specVersion: "kpi-regress",
1266
+ engineId: "kpi-report",
1267
+ pluginVersion: "kpi-report",
1268
+ seed: "kpi-regress",
1269
+ unit,
1270
+ algorithmVersion: "balance-checks-1",
1271
+ };
1272
+ }
1273
+ function kpiCheck(id, metricId, operator, threshold, unit) {
1274
+ return {
1275
+ id,
1276
+ metricId,
1277
+ operator,
1278
+ threshold,
1279
+ upperThreshold: null,
1280
+ unit,
1281
+ severity: "error",
1282
+ missingPolicy: "fail",
1283
+ definition: "kpi-regress-v1",
1284
+ method: "legacy-delta",
1285
+ scenarioVersion: "kpi-report",
1286
+ specVersion: "kpi-regress",
1287
+ engineId: "kpi-report",
1288
+ pluginVersion: "kpi-report",
1289
+ seed: "kpi-regress",
1290
+ algorithmVersion: "balance-checks-1",
1291
+ };
1292
+ }
1293
+ /**
1294
+ * A KPI delta or ratio can be infinite (a zero baseline) or NaN. JSON cannot carry either, so a
1295
+ * measured point would publish a null value beside a decided verdict. An infinite value becomes a
1296
+ * censored observation bounded by the largest finite number, and NaN becomes unknown.
1297
+ */
1298
+ function measured(metricId, unit, value) {
1299
+ const identity = kpiIdentity(metricId, unit);
1300
+ if (value === Number.POSITIVE_INFINITY) {
1301
+ return { identity, status: "censored", value: null, lower: Number.MAX_VALUE, upper: null };
1302
+ }
1303
+ if (value === Number.NEGATIVE_INFINITY) {
1304
+ return { identity, status: "censored", value: null, lower: null, upper: -Number.MAX_VALUE };
1305
+ }
1306
+ if (Number.isNaN(value)) {
1307
+ return { identity, status: "unknown", value: null, lower: null, upper: null };
1308
+ }
1309
+ return { identity, status: "measured", value, lower: value, upper: value };
1310
+ }
1311
+ export function adaptKpiRegression(input) {
1312
+ const horizons = ["at7d", "at30d", "at90d"];
1313
+ const sides = ["a", "b"];
1314
+ const minWorthLog10Delta = Math.log10(input.minWorthRatio);
1315
+ const checks = [];
1316
+ const observations = [];
1317
+ const rows = [];
1318
+ for (const side of sides) {
1319
+ for (const horizon of horizons) {
1320
+ const baseline = readHorizon(input.baseline, side, horizon);
1321
+ const current = readHorizon(input.current, side, horizon);
1322
+ const baselineWorth = String(baseline.endNetWorth ?? "");
1323
+ const currentWorth = String(current.endNetWorth ?? "");
1324
+ const baselineGuard = asRecord(baseline.guardrails);
1325
+ const currentGuard = asRecord(current.guardrails);
1326
+ const baselineStall = Number(baselineGuard?.stallRatio ?? 0);
1327
+ const currentStall = Number(currentGuard?.stallRatio ?? 0);
1328
+ const baselineDropped = Number(baselineGuard?.droppedRate ?? 0);
1329
+ const currentDropped = Number(currentGuard?.droppedRate ?? 0);
1330
+ const worthDelta = toLog10(currentWorth) - toLog10(baselineWorth);
1331
+ const stallDelta = currentStall - baselineStall;
1332
+ const droppedDelta = currentDropped - baselineDropped;
1333
+ const worthId = `${side}:${horizon}:worth`;
1334
+ const stallId = `${side}:${horizon}:stall`;
1335
+ const droppedId = `${side}:${horizon}:dropped`;
1336
+ const worthMetric = `${worthId}:endNetWorthLog10Delta`;
1337
+ const stallMetric = `${stallId}:stallRatioDelta`;
1338
+ const droppedMetric = `${droppedId}:droppedRateDelta`;
1339
+ checks.push(kpiCheck(worthId, worthMetric, "gte", minWorthLog10Delta, "log10"));
1340
+ checks.push(kpiCheck(stallId, stallMetric, "lte", input.maxStallDelta, "ratio"));
1341
+ checks.push(kpiCheck(droppedId, droppedMetric, "lte", input.maxDroppedDelta, "ratio"));
1342
+ observations.push(measured(worthMetric, "log10", worthDelta));
1343
+ observations.push(measured(stallMetric, "ratio", stallDelta));
1344
+ observations.push(measured(droppedMetric, "ratio", droppedDelta));
1345
+ rows.push({
1346
+ side,
1347
+ horizon,
1348
+ baseline: { endNetWorth: baselineWorth, stallRatio: baselineStall, droppedRate: baselineDropped },
1349
+ current: { endNetWorth: currentWorth, stallRatio: currentStall, droppedRate: currentDropped },
1350
+ deltas: { endWorthLog10: worthDelta, stallRatio: stallDelta, droppedRate: droppedDelta },
1351
+ ids: { worth: worthId, stall: stallId, dropped: droppedId },
1352
+ });
1353
+ }
1354
+ }
1355
+ const experienceRows = sides.map((side) => {
1356
+ const baselineRoot = asRecord(input.baseline);
1357
+ const currentRoot = asRecord(input.current);
1358
+ const baselinePerceived = asRecord(asRecord(asRecord(baselineRoot?.experience)?.[side])?.perceived) ?? {};
1359
+ const currentPerceived = asRecord(asRecord(asRecord(currentRoot?.experience)?.[side])?.perceived) ?? {};
1360
+ const baselineVisible = Number(baselinePerceived.visibleChangesPerMinute ?? 0);
1361
+ const currentVisible = Number(currentPerceived.visibleChangesPerMinute ?? 0);
1362
+ const baselineGap = Number(baselinePerceived.maxNoRewardGapSec ?? 0);
1363
+ const currentGap = Number(currentPerceived.maxNoRewardGapSec ?? 0);
1364
+ const visibleRatio = baselineVisible <= 0 ? (currentVisible > 0 ? Number.POSITIVE_INFINITY : 1) : currentVisible / baselineVisible;
1365
+ const gapDelta = currentGap - baselineGap;
1366
+ const visibleId = `${side}:visible`;
1367
+ const gapId = `${side}:noReward`;
1368
+ const visibleMetric = `${visibleId}:visibleChangesPerMinuteRatio`;
1369
+ const gapMetric = `${gapId}:maxNoRewardGapSecDelta`;
1370
+ checks.push(kpiCheck(visibleId, visibleMetric, "gte", input.minVisibleProgressRatio, "ratio"));
1371
+ checks.push(kpiCheck(gapId, gapMetric, "lte", input.maxNoRewardGapDelta, "s"));
1372
+ observations.push(measured(visibleMetric, "ratio", visibleRatio));
1373
+ observations.push(measured(gapMetric, "s", gapDelta));
1374
+ return {
1375
+ side,
1376
+ baseline: { visibleChangesPerMinute: baselineVisible, maxNoRewardGapSec: baselineGap },
1377
+ current: { visibleChangesPerMinute: currentVisible, maxNoRewardGapSec: currentGap },
1378
+ deltas: { visibleRatio, noRewardGapSec: gapDelta },
1379
+ ids: { visible: visibleId, gap: gapId },
1380
+ };
1381
+ });
1382
+ const balanceChecks = evaluateBalanceChecks({
1383
+ schemaVersion: 1,
1384
+ contract: "idlekit.balance-checks.v1",
1385
+ failOn: ["error"],
1386
+ checks,
1387
+ observations,
1388
+ advisory: null,
1389
+ });
1390
+ const verdict = new Map(balanceChecks.results.map((result) => [result.id, result.verdict === "pass"]));
1391
+ const legacyChecks = rows.map((row) => {
1392
+ const worth = verdict.get(row.ids.worth) === true;
1393
+ const stallRatio = verdict.get(row.ids.stall) === true;
1394
+ const droppedRate = verdict.get(row.ids.dropped) === true;
1395
+ return {
1396
+ side: row.side,
1397
+ horizon: row.horizon,
1398
+ baseline: row.baseline,
1399
+ current: row.current,
1400
+ deltas: row.deltas,
1401
+ thresholds: {
1402
+ minWorthLog10Delta,
1403
+ maxStallDelta: input.maxStallDelta,
1404
+ maxDroppedDelta: input.maxDroppedDelta,
1405
+ },
1406
+ pass: { worth, stallRatio, droppedRate, overall: worth && stallRatio && droppedRate },
1407
+ };
1408
+ });
1409
+ const experienceChecks = experienceRows.map((row) => {
1410
+ const visibleProgress = verdict.get(row.ids.visible) === true;
1411
+ const noRewardGap = verdict.get(row.ids.gap) === true;
1412
+ return {
1413
+ side: row.side,
1414
+ baseline: row.baseline,
1415
+ current: row.current,
1416
+ deltas: row.deltas,
1417
+ thresholds: {
1418
+ minVisibleProgressRatio: input.minVisibleProgressRatio,
1419
+ maxNoRewardGapDelta: input.maxNoRewardGapDelta,
1420
+ },
1421
+ pass: { visibleProgress, noRewardGap, overall: visibleProgress && noRewardGap },
1422
+ };
1423
+ });
1424
+ const pass = legacyChecks.every((row) => row.pass.overall) && experienceChecks.every((row) => row.pass.overall);
1425
+ return {
1426
+ baselinePath: input.baselinePath,
1427
+ currentPath: input.currentPath,
1428
+ generatedAt: input.generatedAt,
1429
+ thresholds: {
1430
+ minWorthRatio: input.minWorthRatio,
1431
+ maxStallDelta: input.maxStallDelta,
1432
+ maxDroppedDelta: input.maxDroppedDelta,
1433
+ minVisibleProgressRatio: input.minVisibleProgressRatio,
1434
+ maxNoRewardGapDelta: input.maxNoRewardGapDelta,
1435
+ },
1436
+ pass,
1437
+ checks: legacyChecks,
1438
+ experienceChecks,
1439
+ balanceChecks,
1440
+ };
1441
+ }
1442
+ //# sourceMappingURL=checks.js.map