@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,1230 @@
|
|
|
1
|
+
import * as _validateReport_1 from "typia/lib/internal/_validateReport";
|
|
2
|
+
import * as _createStandardSchema_1 from "typia/lib/internal/_createStandardSchema";
|
|
3
|
+
import { createHash } from "crypto";
|
|
4
|
+
import typia, {} from "typia";
|
|
5
|
+
/**
|
|
6
|
+
* Analysis artifact v1.
|
|
7
|
+
* This is not CLI `_meta` and it does not replace ScenarioV1.
|
|
8
|
+
* DX-02 owns AnalyzerRegistry. This module does not run analyzers.
|
|
9
|
+
*/
|
|
10
|
+
const ANALYSIS_SCHEMA_ID = "https://idlekit.dev/schemas/analysis.artifact.v1.schema.json";
|
|
11
|
+
const ANALYSIS_ALGORITHM_VERSION = "analysis-artifact-v1";
|
|
12
|
+
export function analysisSchemaId() {
|
|
13
|
+
return ANALYSIS_SCHEMA_ID;
|
|
14
|
+
}
|
|
15
|
+
export function analysisAlgorithmVersion() {
|
|
16
|
+
return ANALYSIS_ALGORITHM_VERSION;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @evidence docs/requirements/active/analysis-contracts.md#req-pr08-shared-goal One predicate feeds the ETA, experiment, and check adapters.
|
|
20
|
+
* @evidenceReview docs/requirements/active/analysis-contracts.md#req-pr08-shared-goal #89fb124 Re-read the section: the shared id is eta-experiment-check.
|
|
21
|
+
*/
|
|
22
|
+
export const sharedGoalEvaluation = "eta-experiment-check";
|
|
23
|
+
/**
|
|
24
|
+
* @evidence docs/requirements/active/analysis-contracts.md#req-pr08-custom-metric A model id is registered from the outside. Core does not name that model's resources.
|
|
25
|
+
* @evidenceReview docs/requirements/active/analysis-contracts.md#req-pr08-custom-metric #9564912 Re-read the section: registration is a registry entry, not a Model method.
|
|
26
|
+
*/
|
|
27
|
+
export const customMetricRegistration = "model-analysis-registry";
|
|
28
|
+
/**
|
|
29
|
+
* @evidence docs/requirements/active/analysis-contracts.md#req-pr08-analysis-artifact The wire contract is analysis artifact v1. Missing numbers stay absent.
|
|
30
|
+
* @evidenceReview docs/requirements/active/analysis-contracts.md#req-pr08-analysis-artifact #5f4c544 Re-read the section: the id is idlekit.analysis.artifact.v1 and status is separate from method.
|
|
31
|
+
*/
|
|
32
|
+
export const analysisArtifactContract = "idlekit.analysis.artifact.v1";
|
|
33
|
+
/*
|
|
34
|
+
* typia runs on first call, not at module load. A plugin that the bundled CLI loads
|
|
35
|
+
* imports core source without the transform, and a module-load call would throw there.
|
|
36
|
+
*/
|
|
37
|
+
let analysisArtifactValidator;
|
|
38
|
+
export const validateAnalysisArtifact = (input) => (analysisArtifactValidator ??= (() => {
|
|
39
|
+
const _ip0 = input => Array.isArray(input["assumptions"]) && input["assumptions"].every(elem => "string" === typeof elem);
|
|
40
|
+
const _ip1 = input => "censored" === input["status"] || "error" === input["status"] || "insufficient-data" === input["status"] || "invalid" === input["status"] || "ok" === input["status"] || "unknown" === input["status"] || "unsupported" === input["status"];
|
|
41
|
+
const _ip2 = input => undefined === input["method"] || "analytic-local" === input["method"] || "exact" === input["method"] || "fixed-step" === input["method"] || "heuristic-fit" === input["method"] || "monte-carlo" === input["method"];
|
|
42
|
+
const _ve0 = "Readonly<{ schemaVersion: 1; algorithmVersion: string; assumptions: readonly string[]; warnings: readonly string[]; observationCoverage: ArtifactCoverage; horizon?: Readonly<{ sec: number; kind: \"budget\" | \"duration\" | \"unknown\" | \"until\"; }> | undefined; ... 4 more ...; capabilities: Readonly<...>; }>";
|
|
43
|
+
const _vp0 = (input, _path, _exceptionable = true) => (Array.isArray(input["assumptions"]) || _report(_exceptionable, {
|
|
44
|
+
path: _path + ".assumptions",
|
|
45
|
+
expected: "ReadonlyArray<string>",
|
|
46
|
+
value: input["assumptions"]
|
|
47
|
+
})) && input["assumptions"].map((elem, _index5) => "string" === typeof elem || _report(_exceptionable, {
|
|
48
|
+
path: _path + ".assumptions[" + _index5 + "]",
|
|
49
|
+
expected: "string",
|
|
50
|
+
value: elem
|
|
51
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
52
|
+
path: _path + ".assumptions",
|
|
53
|
+
expected: "ReadonlyArray<string>",
|
|
54
|
+
value: input["assumptions"]
|
|
55
|
+
});
|
|
56
|
+
const _ve1 = "Readonly<{ metricId: string; metricVersion: number; meaning: string; metricKind: MetricKind; timeAxis: MetricTimeAxis; domain: MetricDomain; reading: \"estimated\" | ... 1 more ... | \"unavailable\"; ... 5 more ...; reason?: string | undefined; }>";
|
|
57
|
+
const _ve2 = "ReadonlyArray<Readonly<{ metricId: string; metricVersion: number; meaning: string; metricKind: MetricKind; timeAxis: MetricTimeAxis; domain: MetricDomain; reading: \"estimated\" | ... 1 more ... | \"unavailable\"; ... 5 more ...; reason?: string | undefined; }>>";
|
|
58
|
+
const _ve3 = "Readonly<{ goalId: string; goalVersion: number; status: AnalysisStatus; method?: AnalysisMethod | undefined; reached?: boolean | undefined; atSec?: number | undefined; assumptions: readonly string[]; }>";
|
|
59
|
+
const _ve4 = "ReadonlyArray<Readonly<{ goalId: string; goalVersion: number; status: AnalysisStatus; method?: AnalysisMethod | undefined; reached?: boolean | undefined; atSec?: number | undefined; assumptions: readonly string[]; }>>";
|
|
60
|
+
const _ve5 = "Readonly<{ metrics: CapabilityKnowledge; goals: CapabilityKnowledge; reset: CapabilityKnowledge; flow: CapabilityKnowledge; advance: CapabilityKnowledge; }>";
|
|
61
|
+
const _vp1 = (input, _path, _exceptionable = true) => "censored" === input["status"] || "error" === input["status"] || "insufficient-data" === input["status"] || "invalid" === input["status"] || "ok" === input["status"] || "unknown" === input["status"] || "unsupported" === input["status"] || _report(_exceptionable, {
|
|
62
|
+
path: _path + ".status",
|
|
63
|
+
expected: "(\"censored\" | \"error\" | \"insufficient-data\" | \"invalid\" | \"ok\" | \"unknown\" | \"unsupported\")",
|
|
64
|
+
value: input["status"]
|
|
65
|
+
});
|
|
66
|
+
const _vp2 = (input, _path, _exceptionable = true) => undefined === input["method"] || "analytic-local" === input["method"] || "exact" === input["method"] || "fixed-step" === input["method"] || "heuristic-fit" === input["method"] || "monte-carlo" === input["method"] || _report(_exceptionable, {
|
|
67
|
+
path: _path + ".method",
|
|
68
|
+
expected: "(\"analytic-local\" | \"exact\" | \"fixed-step\" | \"heuristic-fit\" | \"monte-carlo\" | undefined)",
|
|
69
|
+
value: input["method"]
|
|
70
|
+
});
|
|
71
|
+
const _io0 = input => 1 === input.schemaVersion && "string" === typeof input.algorithmVersion && _ip0(input) && (Array.isArray(input.warnings) && input.warnings.every(elem => "string" === typeof elem)) && ("complete" === input.observationCoverage || "disabled" === input.observationCoverage || "incomplete" === input.observationCoverage || "partial" === input.observationCoverage || "unknown" === input.observationCoverage) && (undefined === input.horizon || "object" === typeof input.horizon && null !== input.horizon && _io1(input.horizon)) && (undefined === input.sampleCount || "number" === typeof input.sampleCount) && (undefined === input.effectiveRunHash || "string" === typeof input.effectiveRunHash) && (Array.isArray(input.metrics) && input.metrics.every(elem => "object" === typeof elem && null !== elem && _io2(elem))) && (Array.isArray(input.goals) && input.goals.every(elem => "object" === typeof elem && null !== elem && _io4(elem))) && ("object" === typeof input.capabilities && null !== input.capabilities && _io5(input.capabilities));
|
|
72
|
+
const _io1 = input => "number" === typeof input.sec && ("budget" === input.kind || "duration" === input.kind || "unknown" === input.kind || "until" === input.kind);
|
|
73
|
+
const _io2 = input => "string" === typeof input.metricId && "number" === typeof input.metricVersion && "string" === typeof input.meaning && ("cumulative" === input.metricKind || "stock" === input.metricKind) && ("instant" === input.timeAxis || "interval" === input.timeAxis) && ("amount" === input.domain || "count" === input.domain || "ratio" === input.domain || "time" === input.domain) && ("estimated" === input.reading || "observed" === input.reading || "unavailable" === input.reading) && _ip1(input) && _ip2(input) && (undefined === input.sign || "negative" === input.sign || "nonfinite" === input.sign || "positive" === input.sign || "zero" === input.sign) && (undefined === input.amount || "object" === typeof input.amount && null !== input.amount && _io3(input.amount)) && (undefined === input.value || "number" === typeof input.value) && (undefined === input.reason || "string" === typeof input.reason);
|
|
74
|
+
const _io3 = input => "string" === typeof input.unit && "string" === typeof input.decimal;
|
|
75
|
+
const _io4 = input => "string" === typeof input.goalId && "number" === typeof input.goalVersion && _ip1(input) && _ip2(input) && (undefined === input.reached || "boolean" === typeof input.reached) && (undefined === input.atSec || "number" === typeof input.atSec) && _ip0(input);
|
|
76
|
+
const _io5 = input => ("statically-known" === input.metrics || "unknown" === input.metrics || "unsupported" === input.metrics) && ("statically-known" === input.goals || "unknown" === input.goals || "unsupported" === input.goals) && ("statically-known" === input.reset || "unknown" === input.reset || "unsupported" === input.reset) && ("statically-known" === input.flow || "unknown" === input.flow || "unsupported" === input.flow) && ("statically-known" === input.advance || "unknown" === input.advance || "unsupported" === input.advance);
|
|
77
|
+
const _vo0 = (input, _path, _exceptionable = true) => [1 === input.schemaVersion || _report(_exceptionable, {
|
|
78
|
+
path: _path + ".schemaVersion",
|
|
79
|
+
expected: "1",
|
|
80
|
+
value: input.schemaVersion
|
|
81
|
+
}), "string" === typeof input.algorithmVersion || _report(_exceptionable, {
|
|
82
|
+
path: _path + ".algorithmVersion",
|
|
83
|
+
expected: "string",
|
|
84
|
+
value: input.algorithmVersion
|
|
85
|
+
}), _vp0(input, _path, true && _exceptionable), (Array.isArray(input.warnings) || _report(_exceptionable, {
|
|
86
|
+
path: _path + ".warnings",
|
|
87
|
+
expected: "ReadonlyArray<string>",
|
|
88
|
+
value: input.warnings
|
|
89
|
+
})) && input.warnings.map((elem, _index6) => "string" === typeof elem || _report(_exceptionable, {
|
|
90
|
+
path: _path + ".warnings[" + _index6 + "]",
|
|
91
|
+
expected: "string",
|
|
92
|
+
value: elem
|
|
93
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
94
|
+
path: _path + ".warnings",
|
|
95
|
+
expected: "ReadonlyArray<string>",
|
|
96
|
+
value: input.warnings
|
|
97
|
+
}), "complete" === input.observationCoverage || "disabled" === input.observationCoverage || "incomplete" === input.observationCoverage || "partial" === input.observationCoverage || "unknown" === input.observationCoverage || _report(_exceptionable, {
|
|
98
|
+
path: _path + ".observationCoverage",
|
|
99
|
+
expected: "(\"complete\" | \"disabled\" | \"incomplete\" | \"partial\" | \"unknown\")",
|
|
100
|
+
value: input.observationCoverage
|
|
101
|
+
}), undefined === input.horizon || ("object" === typeof input.horizon && null !== input.horizon || _report(_exceptionable, {
|
|
102
|
+
path: _path + ".horizon",
|
|
103
|
+
expected: "(Readonly<{ sec: number; kind: \"budget\" | \"duration\" | \"unknown\" | \"until\"; }> | undefined)",
|
|
104
|
+
value: input.horizon
|
|
105
|
+
})) && _vo1(input.horizon, _path + ".horizon", true && _exceptionable) || _report(_exceptionable, {
|
|
106
|
+
path: _path + ".horizon",
|
|
107
|
+
expected: "(Readonly<{ sec: number; kind: \"budget\" | \"duration\" | \"unknown\" | \"until\"; }> | undefined)",
|
|
108
|
+
value: input.horizon
|
|
109
|
+
}), undefined === input.sampleCount || "number" === typeof input.sampleCount || _report(_exceptionable, {
|
|
110
|
+
path: _path + ".sampleCount",
|
|
111
|
+
expected: "(number | undefined)",
|
|
112
|
+
value: input.sampleCount
|
|
113
|
+
}), undefined === input.effectiveRunHash || "string" === typeof input.effectiveRunHash || _report(_exceptionable, {
|
|
114
|
+
path: _path + ".effectiveRunHash",
|
|
115
|
+
expected: "(string | undefined)",
|
|
116
|
+
value: input.effectiveRunHash
|
|
117
|
+
}), (Array.isArray(input.metrics) || _report(_exceptionable, {
|
|
118
|
+
path: _path + ".metrics",
|
|
119
|
+
expected: _ve2,
|
|
120
|
+
value: input.metrics
|
|
121
|
+
})) && input.metrics.map((elem, _index7) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
122
|
+
path: _path + ".metrics[" + _index7 + "]",
|
|
123
|
+
expected: _ve1,
|
|
124
|
+
value: elem
|
|
125
|
+
})) && _vo2(elem, _path + ".metrics[" + _index7 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
126
|
+
path: _path + ".metrics[" + _index7 + "]",
|
|
127
|
+
expected: _ve1,
|
|
128
|
+
value: elem
|
|
129
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
130
|
+
path: _path + ".metrics",
|
|
131
|
+
expected: _ve2,
|
|
132
|
+
value: input.metrics
|
|
133
|
+
}), (Array.isArray(input.goals) || _report(_exceptionable, {
|
|
134
|
+
path: _path + ".goals",
|
|
135
|
+
expected: _ve4,
|
|
136
|
+
value: input.goals
|
|
137
|
+
})) && input.goals.map((elem, _index8) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
138
|
+
path: _path + ".goals[" + _index8 + "]",
|
|
139
|
+
expected: _ve3,
|
|
140
|
+
value: elem
|
|
141
|
+
})) && _vo4(elem, _path + ".goals[" + _index8 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
142
|
+
path: _path + ".goals[" + _index8 + "]",
|
|
143
|
+
expected: _ve3,
|
|
144
|
+
value: elem
|
|
145
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
146
|
+
path: _path + ".goals",
|
|
147
|
+
expected: _ve4,
|
|
148
|
+
value: input.goals
|
|
149
|
+
}), ("object" === typeof input.capabilities && null !== input.capabilities || _report(_exceptionable, {
|
|
150
|
+
path: _path + ".capabilities",
|
|
151
|
+
expected: _ve5,
|
|
152
|
+
value: input.capabilities
|
|
153
|
+
})) && _vo5(input.capabilities, _path + ".capabilities", true && _exceptionable) || _report(_exceptionable, {
|
|
154
|
+
path: _path + ".capabilities",
|
|
155
|
+
expected: _ve5,
|
|
156
|
+
value: input.capabilities
|
|
157
|
+
})].every(flag => flag);
|
|
158
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["number" === typeof input.sec || _report(_exceptionable, {
|
|
159
|
+
path: _path + ".sec",
|
|
160
|
+
expected: "number",
|
|
161
|
+
value: input.sec
|
|
162
|
+
}), "budget" === input.kind || "duration" === input.kind || "unknown" === input.kind || "until" === input.kind || _report(_exceptionable, {
|
|
163
|
+
path: _path + ".kind",
|
|
164
|
+
expected: "(\"budget\" | \"duration\" | \"unknown\" | \"until\")",
|
|
165
|
+
value: input.kind
|
|
166
|
+
})].every(flag => flag);
|
|
167
|
+
const _vo2 = (input, _path, _exceptionable = true) => ["string" === typeof input.metricId || _report(_exceptionable, {
|
|
168
|
+
path: _path + ".metricId",
|
|
169
|
+
expected: "string",
|
|
170
|
+
value: input.metricId
|
|
171
|
+
}), "number" === typeof input.metricVersion || _report(_exceptionable, {
|
|
172
|
+
path: _path + ".metricVersion",
|
|
173
|
+
expected: "number",
|
|
174
|
+
value: input.metricVersion
|
|
175
|
+
}), "string" === typeof input.meaning || _report(_exceptionable, {
|
|
176
|
+
path: _path + ".meaning",
|
|
177
|
+
expected: "string",
|
|
178
|
+
value: input.meaning
|
|
179
|
+
}), "cumulative" === input.metricKind || "stock" === input.metricKind || _report(_exceptionable, {
|
|
180
|
+
path: _path + ".metricKind",
|
|
181
|
+
expected: "(\"cumulative\" | \"stock\")",
|
|
182
|
+
value: input.metricKind
|
|
183
|
+
}), "instant" === input.timeAxis || "interval" === input.timeAxis || _report(_exceptionable, {
|
|
184
|
+
path: _path + ".timeAxis",
|
|
185
|
+
expected: "(\"instant\" | \"interval\")",
|
|
186
|
+
value: input.timeAxis
|
|
187
|
+
}), "amount" === input.domain || "count" === input.domain || "ratio" === input.domain || "time" === input.domain || _report(_exceptionable, {
|
|
188
|
+
path: _path + ".domain",
|
|
189
|
+
expected: "(\"amount\" | \"count\" | \"ratio\" | \"time\")",
|
|
190
|
+
value: input.domain
|
|
191
|
+
}), "estimated" === input.reading || "observed" === input.reading || "unavailable" === input.reading || _report(_exceptionable, {
|
|
192
|
+
path: _path + ".reading",
|
|
193
|
+
expected: "(\"estimated\" | \"observed\" | \"unavailable\")",
|
|
194
|
+
value: input.reading
|
|
195
|
+
}), _vp1(input, _path, true && _exceptionable), _vp2(input, _path, true && _exceptionable), undefined === input.sign || "negative" === input.sign || "nonfinite" === input.sign || "positive" === input.sign || "zero" === input.sign || _report(_exceptionable, {
|
|
196
|
+
path: _path + ".sign",
|
|
197
|
+
expected: "(\"negative\" | \"nonfinite\" | \"positive\" | \"zero\" | undefined)",
|
|
198
|
+
value: input.sign
|
|
199
|
+
}), undefined === input.amount || ("object" === typeof input.amount && null !== input.amount || _report(_exceptionable, {
|
|
200
|
+
path: _path + ".amount",
|
|
201
|
+
expected: "(Readonly<{ unit: string; decimal: string; }> | undefined)",
|
|
202
|
+
value: input.amount
|
|
203
|
+
})) && _vo3(input.amount, _path + ".amount", true && _exceptionable) || _report(_exceptionable, {
|
|
204
|
+
path: _path + ".amount",
|
|
205
|
+
expected: "(Readonly<{ unit: string; decimal: string; }> | undefined)",
|
|
206
|
+
value: input.amount
|
|
207
|
+
}), undefined === input.value || "number" === typeof input.value || _report(_exceptionable, {
|
|
208
|
+
path: _path + ".value",
|
|
209
|
+
expected: "(number | undefined)",
|
|
210
|
+
value: input.value
|
|
211
|
+
}), undefined === input.reason || "string" === typeof input.reason || _report(_exceptionable, {
|
|
212
|
+
path: _path + ".reason",
|
|
213
|
+
expected: "(string | undefined)",
|
|
214
|
+
value: input.reason
|
|
215
|
+
})].every(flag => flag);
|
|
216
|
+
const _vo3 = (input, _path, _exceptionable = true) => ["string" === typeof input.unit || _report(_exceptionable, {
|
|
217
|
+
path: _path + ".unit",
|
|
218
|
+
expected: "string",
|
|
219
|
+
value: input.unit
|
|
220
|
+
}), "string" === typeof input.decimal || _report(_exceptionable, {
|
|
221
|
+
path: _path + ".decimal",
|
|
222
|
+
expected: "string",
|
|
223
|
+
value: input.decimal
|
|
224
|
+
})].every(flag => flag);
|
|
225
|
+
const _vo4 = (input, _path, _exceptionable = true) => ["string" === typeof input.goalId || _report(_exceptionable, {
|
|
226
|
+
path: _path + ".goalId",
|
|
227
|
+
expected: "string",
|
|
228
|
+
value: input.goalId
|
|
229
|
+
}), "number" === typeof input.goalVersion || _report(_exceptionable, {
|
|
230
|
+
path: _path + ".goalVersion",
|
|
231
|
+
expected: "number",
|
|
232
|
+
value: input.goalVersion
|
|
233
|
+
}), _vp1(input, _path, true && _exceptionable), _vp2(input, _path, true && _exceptionable), undefined === input.reached || "boolean" === typeof input.reached || _report(_exceptionable, {
|
|
234
|
+
path: _path + ".reached",
|
|
235
|
+
expected: "(boolean | undefined)",
|
|
236
|
+
value: input.reached
|
|
237
|
+
}), undefined === input.atSec || "number" === typeof input.atSec || _report(_exceptionable, {
|
|
238
|
+
path: _path + ".atSec",
|
|
239
|
+
expected: "(number | undefined)",
|
|
240
|
+
value: input.atSec
|
|
241
|
+
}), _vp0(input, _path, true && _exceptionable)].every(flag => flag);
|
|
242
|
+
const _vo5 = (input, _path, _exceptionable = true) => ["statically-known" === input.metrics || "unknown" === input.metrics || "unsupported" === input.metrics || _report(_exceptionable, {
|
|
243
|
+
path: _path + ".metrics",
|
|
244
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
245
|
+
value: input.metrics
|
|
246
|
+
}), "statically-known" === input.goals || "unknown" === input.goals || "unsupported" === input.goals || _report(_exceptionable, {
|
|
247
|
+
path: _path + ".goals",
|
|
248
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
249
|
+
value: input.goals
|
|
250
|
+
}), "statically-known" === input.reset || "unknown" === input.reset || "unsupported" === input.reset || _report(_exceptionable, {
|
|
251
|
+
path: _path + ".reset",
|
|
252
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
253
|
+
value: input.reset
|
|
254
|
+
}), "statically-known" === input.flow || "unknown" === input.flow || "unsupported" === input.flow || _report(_exceptionable, {
|
|
255
|
+
path: _path + ".flow",
|
|
256
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
257
|
+
value: input.flow
|
|
258
|
+
}), "statically-known" === input.advance || "unknown" === input.advance || "unsupported" === input.advance || _report(_exceptionable, {
|
|
259
|
+
path: _path + ".advance",
|
|
260
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
261
|
+
value: input.advance
|
|
262
|
+
})].every(flag => flag);
|
|
263
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
264
|
+
let errors;
|
|
265
|
+
let _report;
|
|
266
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
267
|
+
if (false === __is(input)) {
|
|
268
|
+
errors = [];
|
|
269
|
+
_report = _validateReport_1._validateReport(errors);
|
|
270
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
271
|
+
path: _path + "",
|
|
272
|
+
expected: _ve0,
|
|
273
|
+
value: input
|
|
274
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
275
|
+
path: _path + "",
|
|
276
|
+
expected: _ve0,
|
|
277
|
+
value: input
|
|
278
|
+
}))(input, "$input", true);
|
|
279
|
+
const success = 0 === errors.length;
|
|
280
|
+
return success ? {
|
|
281
|
+
success,
|
|
282
|
+
data: input
|
|
283
|
+
} : {
|
|
284
|
+
success,
|
|
285
|
+
errors,
|
|
286
|
+
data: input
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
success: true,
|
|
291
|
+
data: input
|
|
292
|
+
};
|
|
293
|
+
});
|
|
294
|
+
})())(input);
|
|
295
|
+
export function parseAnalysisArtifact(input) {
|
|
296
|
+
return (() => {
|
|
297
|
+
const _ip0 = input => Array.isArray(input["assumptions"]) && input["assumptions"].every(elem => "string" === typeof elem);
|
|
298
|
+
const _ip1 = input => "censored" === input["status"] || "error" === input["status"] || "insufficient-data" === input["status"] || "invalid" === input["status"] || "ok" === input["status"] || "unknown" === input["status"] || "unsupported" === input["status"];
|
|
299
|
+
const _ip2 = input => undefined === input["method"] || "analytic-local" === input["method"] || "exact" === input["method"] || "fixed-step" === input["method"] || "heuristic-fit" === input["method"] || "monte-carlo" === input["method"];
|
|
300
|
+
const _ve0 = "Readonly<{ schemaVersion: 1; algorithmVersion: string; assumptions: readonly string[]; warnings: readonly string[]; observationCoverage: ArtifactCoverage; horizon?: Readonly<{ sec: number; kind: \"budget\" | \"duration\" | \"unknown\" | \"until\"; }> | undefined; ... 4 more ...; capabilities: Readonly<...>; }>";
|
|
301
|
+
const _vp0 = (input, _path, _exceptionable = true) => (Array.isArray(input["assumptions"]) || _report(_exceptionable, {
|
|
302
|
+
path: _path + ".assumptions",
|
|
303
|
+
expected: "ReadonlyArray<string>",
|
|
304
|
+
value: input["assumptions"]
|
|
305
|
+
})) && input["assumptions"].map((elem, _index5) => "string" === typeof elem || _report(_exceptionable, {
|
|
306
|
+
path: _path + ".assumptions[" + _index5 + "]",
|
|
307
|
+
expected: "string",
|
|
308
|
+
value: elem
|
|
309
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
310
|
+
path: _path + ".assumptions",
|
|
311
|
+
expected: "ReadonlyArray<string>",
|
|
312
|
+
value: input["assumptions"]
|
|
313
|
+
});
|
|
314
|
+
const _ve1 = "Readonly<{ metricId: string; metricVersion: number; meaning: string; metricKind: MetricKind; timeAxis: MetricTimeAxis; domain: MetricDomain; reading: \"estimated\" | ... 1 more ... | \"unavailable\"; ... 5 more ...; reason?: string | undefined; }>";
|
|
315
|
+
const _ve2 = "ReadonlyArray<Readonly<{ metricId: string; metricVersion: number; meaning: string; metricKind: MetricKind; timeAxis: MetricTimeAxis; domain: MetricDomain; reading: \"estimated\" | ... 1 more ... | \"unavailable\"; ... 5 more ...; reason?: string | undefined; }>>";
|
|
316
|
+
const _ve3 = "Readonly<{ goalId: string; goalVersion: number; status: AnalysisStatus; method?: AnalysisMethod | undefined; reached?: boolean | undefined; atSec?: number | undefined; assumptions: readonly string[]; }>";
|
|
317
|
+
const _ve4 = "ReadonlyArray<Readonly<{ goalId: string; goalVersion: number; status: AnalysisStatus; method?: AnalysisMethod | undefined; reached?: boolean | undefined; atSec?: number | undefined; assumptions: readonly string[]; }>>";
|
|
318
|
+
const _ve5 = "Readonly<{ metrics: CapabilityKnowledge; goals: CapabilityKnowledge; reset: CapabilityKnowledge; flow: CapabilityKnowledge; advance: CapabilityKnowledge; }>";
|
|
319
|
+
const _vp1 = (input, _path, _exceptionable = true) => "censored" === input["status"] || "error" === input["status"] || "insufficient-data" === input["status"] || "invalid" === input["status"] || "ok" === input["status"] || "unknown" === input["status"] || "unsupported" === input["status"] || _report(_exceptionable, {
|
|
320
|
+
path: _path + ".status",
|
|
321
|
+
expected: "(\"censored\" | \"error\" | \"insufficient-data\" | \"invalid\" | \"ok\" | \"unknown\" | \"unsupported\")",
|
|
322
|
+
value: input["status"]
|
|
323
|
+
});
|
|
324
|
+
const _vp2 = (input, _path, _exceptionable = true) => undefined === input["method"] || "analytic-local" === input["method"] || "exact" === input["method"] || "fixed-step" === input["method"] || "heuristic-fit" === input["method"] || "monte-carlo" === input["method"] || _report(_exceptionable, {
|
|
325
|
+
path: _path + ".method",
|
|
326
|
+
expected: "(\"analytic-local\" | \"exact\" | \"fixed-step\" | \"heuristic-fit\" | \"monte-carlo\" | undefined)",
|
|
327
|
+
value: input["method"]
|
|
328
|
+
});
|
|
329
|
+
const _io0 = input => 1 === input.schemaVersion && "string" === typeof input.algorithmVersion && _ip0(input) && (Array.isArray(input.warnings) && input.warnings.every(elem => "string" === typeof elem)) && ("complete" === input.observationCoverage || "disabled" === input.observationCoverage || "incomplete" === input.observationCoverage || "partial" === input.observationCoverage || "unknown" === input.observationCoverage) && (undefined === input.horizon || "object" === typeof input.horizon && null !== input.horizon && _io1(input.horizon)) && (undefined === input.sampleCount || "number" === typeof input.sampleCount) && (undefined === input.effectiveRunHash || "string" === typeof input.effectiveRunHash) && (Array.isArray(input.metrics) && input.metrics.every(elem => "object" === typeof elem && null !== elem && _io2(elem))) && (Array.isArray(input.goals) && input.goals.every(elem => "object" === typeof elem && null !== elem && _io4(elem))) && ("object" === typeof input.capabilities && null !== input.capabilities && _io5(input.capabilities));
|
|
330
|
+
const _io1 = input => "number" === typeof input.sec && ("budget" === input.kind || "duration" === input.kind || "unknown" === input.kind || "until" === input.kind);
|
|
331
|
+
const _io2 = input => "string" === typeof input.metricId && "number" === typeof input.metricVersion && "string" === typeof input.meaning && ("cumulative" === input.metricKind || "stock" === input.metricKind) && ("instant" === input.timeAxis || "interval" === input.timeAxis) && ("amount" === input.domain || "count" === input.domain || "ratio" === input.domain || "time" === input.domain) && ("estimated" === input.reading || "observed" === input.reading || "unavailable" === input.reading) && _ip1(input) && _ip2(input) && (undefined === input.sign || "negative" === input.sign || "nonfinite" === input.sign || "positive" === input.sign || "zero" === input.sign) && (undefined === input.amount || "object" === typeof input.amount && null !== input.amount && _io3(input.amount)) && (undefined === input.value || "number" === typeof input.value) && (undefined === input.reason || "string" === typeof input.reason);
|
|
332
|
+
const _io3 = input => "string" === typeof input.unit && "string" === typeof input.decimal;
|
|
333
|
+
const _io4 = input => "string" === typeof input.goalId && "number" === typeof input.goalVersion && _ip1(input) && _ip2(input) && (undefined === input.reached || "boolean" === typeof input.reached) && (undefined === input.atSec || "number" === typeof input.atSec) && _ip0(input);
|
|
334
|
+
const _io5 = input => ("statically-known" === input.metrics || "unknown" === input.metrics || "unsupported" === input.metrics) && ("statically-known" === input.goals || "unknown" === input.goals || "unsupported" === input.goals) && ("statically-known" === input.reset || "unknown" === input.reset || "unsupported" === input.reset) && ("statically-known" === input.flow || "unknown" === input.flow || "unsupported" === input.flow) && ("statically-known" === input.advance || "unknown" === input.advance || "unsupported" === input.advance);
|
|
335
|
+
const _vo0 = (input, _path, _exceptionable = true) => [1 === input.schemaVersion || _report(_exceptionable, {
|
|
336
|
+
path: _path + ".schemaVersion",
|
|
337
|
+
expected: "1",
|
|
338
|
+
value: input.schemaVersion
|
|
339
|
+
}), "string" === typeof input.algorithmVersion || _report(_exceptionable, {
|
|
340
|
+
path: _path + ".algorithmVersion",
|
|
341
|
+
expected: "string",
|
|
342
|
+
value: input.algorithmVersion
|
|
343
|
+
}), _vp0(input, _path, true && _exceptionable), (Array.isArray(input.warnings) || _report(_exceptionable, {
|
|
344
|
+
path: _path + ".warnings",
|
|
345
|
+
expected: "ReadonlyArray<string>",
|
|
346
|
+
value: input.warnings
|
|
347
|
+
})) && input.warnings.map((elem, _index6) => "string" === typeof elem || _report(_exceptionable, {
|
|
348
|
+
path: _path + ".warnings[" + _index6 + "]",
|
|
349
|
+
expected: "string",
|
|
350
|
+
value: elem
|
|
351
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
352
|
+
path: _path + ".warnings",
|
|
353
|
+
expected: "ReadonlyArray<string>",
|
|
354
|
+
value: input.warnings
|
|
355
|
+
}), "complete" === input.observationCoverage || "disabled" === input.observationCoverage || "incomplete" === input.observationCoverage || "partial" === input.observationCoverage || "unknown" === input.observationCoverage || _report(_exceptionable, {
|
|
356
|
+
path: _path + ".observationCoverage",
|
|
357
|
+
expected: "(\"complete\" | \"disabled\" | \"incomplete\" | \"partial\" | \"unknown\")",
|
|
358
|
+
value: input.observationCoverage
|
|
359
|
+
}), undefined === input.horizon || ("object" === typeof input.horizon && null !== input.horizon || _report(_exceptionable, {
|
|
360
|
+
path: _path + ".horizon",
|
|
361
|
+
expected: "(Readonly<{ sec: number; kind: \"budget\" | \"duration\" | \"unknown\" | \"until\"; }> | undefined)",
|
|
362
|
+
value: input.horizon
|
|
363
|
+
})) && _vo1(input.horizon, _path + ".horizon", true && _exceptionable) || _report(_exceptionable, {
|
|
364
|
+
path: _path + ".horizon",
|
|
365
|
+
expected: "(Readonly<{ sec: number; kind: \"budget\" | \"duration\" | \"unknown\" | \"until\"; }> | undefined)",
|
|
366
|
+
value: input.horizon
|
|
367
|
+
}), undefined === input.sampleCount || "number" === typeof input.sampleCount || _report(_exceptionable, {
|
|
368
|
+
path: _path + ".sampleCount",
|
|
369
|
+
expected: "(number | undefined)",
|
|
370
|
+
value: input.sampleCount
|
|
371
|
+
}), undefined === input.effectiveRunHash || "string" === typeof input.effectiveRunHash || _report(_exceptionable, {
|
|
372
|
+
path: _path + ".effectiveRunHash",
|
|
373
|
+
expected: "(string | undefined)",
|
|
374
|
+
value: input.effectiveRunHash
|
|
375
|
+
}), (Array.isArray(input.metrics) || _report(_exceptionable, {
|
|
376
|
+
path: _path + ".metrics",
|
|
377
|
+
expected: _ve2,
|
|
378
|
+
value: input.metrics
|
|
379
|
+
})) && input.metrics.map((elem, _index7) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
380
|
+
path: _path + ".metrics[" + _index7 + "]",
|
|
381
|
+
expected: _ve1,
|
|
382
|
+
value: elem
|
|
383
|
+
})) && _vo2(elem, _path + ".metrics[" + _index7 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
384
|
+
path: _path + ".metrics[" + _index7 + "]",
|
|
385
|
+
expected: _ve1,
|
|
386
|
+
value: elem
|
|
387
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
388
|
+
path: _path + ".metrics",
|
|
389
|
+
expected: _ve2,
|
|
390
|
+
value: input.metrics
|
|
391
|
+
}), (Array.isArray(input.goals) || _report(_exceptionable, {
|
|
392
|
+
path: _path + ".goals",
|
|
393
|
+
expected: _ve4,
|
|
394
|
+
value: input.goals
|
|
395
|
+
})) && input.goals.map((elem, _index8) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
396
|
+
path: _path + ".goals[" + _index8 + "]",
|
|
397
|
+
expected: _ve3,
|
|
398
|
+
value: elem
|
|
399
|
+
})) && _vo4(elem, _path + ".goals[" + _index8 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
400
|
+
path: _path + ".goals[" + _index8 + "]",
|
|
401
|
+
expected: _ve3,
|
|
402
|
+
value: elem
|
|
403
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
404
|
+
path: _path + ".goals",
|
|
405
|
+
expected: _ve4,
|
|
406
|
+
value: input.goals
|
|
407
|
+
}), ("object" === typeof input.capabilities && null !== input.capabilities || _report(_exceptionable, {
|
|
408
|
+
path: _path + ".capabilities",
|
|
409
|
+
expected: _ve5,
|
|
410
|
+
value: input.capabilities
|
|
411
|
+
})) && _vo5(input.capabilities, _path + ".capabilities", true && _exceptionable) || _report(_exceptionable, {
|
|
412
|
+
path: _path + ".capabilities",
|
|
413
|
+
expected: _ve5,
|
|
414
|
+
value: input.capabilities
|
|
415
|
+
})].every(flag => flag);
|
|
416
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["number" === typeof input.sec || _report(_exceptionable, {
|
|
417
|
+
path: _path + ".sec",
|
|
418
|
+
expected: "number",
|
|
419
|
+
value: input.sec
|
|
420
|
+
}), "budget" === input.kind || "duration" === input.kind || "unknown" === input.kind || "until" === input.kind || _report(_exceptionable, {
|
|
421
|
+
path: _path + ".kind",
|
|
422
|
+
expected: "(\"budget\" | \"duration\" | \"unknown\" | \"until\")",
|
|
423
|
+
value: input.kind
|
|
424
|
+
})].every(flag => flag);
|
|
425
|
+
const _vo2 = (input, _path, _exceptionable = true) => ["string" === typeof input.metricId || _report(_exceptionable, {
|
|
426
|
+
path: _path + ".metricId",
|
|
427
|
+
expected: "string",
|
|
428
|
+
value: input.metricId
|
|
429
|
+
}), "number" === typeof input.metricVersion || _report(_exceptionable, {
|
|
430
|
+
path: _path + ".metricVersion",
|
|
431
|
+
expected: "number",
|
|
432
|
+
value: input.metricVersion
|
|
433
|
+
}), "string" === typeof input.meaning || _report(_exceptionable, {
|
|
434
|
+
path: _path + ".meaning",
|
|
435
|
+
expected: "string",
|
|
436
|
+
value: input.meaning
|
|
437
|
+
}), "cumulative" === input.metricKind || "stock" === input.metricKind || _report(_exceptionable, {
|
|
438
|
+
path: _path + ".metricKind",
|
|
439
|
+
expected: "(\"cumulative\" | \"stock\")",
|
|
440
|
+
value: input.metricKind
|
|
441
|
+
}), "instant" === input.timeAxis || "interval" === input.timeAxis || _report(_exceptionable, {
|
|
442
|
+
path: _path + ".timeAxis",
|
|
443
|
+
expected: "(\"instant\" | \"interval\")",
|
|
444
|
+
value: input.timeAxis
|
|
445
|
+
}), "amount" === input.domain || "count" === input.domain || "ratio" === input.domain || "time" === input.domain || _report(_exceptionable, {
|
|
446
|
+
path: _path + ".domain",
|
|
447
|
+
expected: "(\"amount\" | \"count\" | \"ratio\" | \"time\")",
|
|
448
|
+
value: input.domain
|
|
449
|
+
}), "estimated" === input.reading || "observed" === input.reading || "unavailable" === input.reading || _report(_exceptionable, {
|
|
450
|
+
path: _path + ".reading",
|
|
451
|
+
expected: "(\"estimated\" | \"observed\" | \"unavailable\")",
|
|
452
|
+
value: input.reading
|
|
453
|
+
}), _vp1(input, _path, true && _exceptionable), _vp2(input, _path, true && _exceptionable), undefined === input.sign || "negative" === input.sign || "nonfinite" === input.sign || "positive" === input.sign || "zero" === input.sign || _report(_exceptionable, {
|
|
454
|
+
path: _path + ".sign",
|
|
455
|
+
expected: "(\"negative\" | \"nonfinite\" | \"positive\" | \"zero\" | undefined)",
|
|
456
|
+
value: input.sign
|
|
457
|
+
}), undefined === input.amount || ("object" === typeof input.amount && null !== input.amount || _report(_exceptionable, {
|
|
458
|
+
path: _path + ".amount",
|
|
459
|
+
expected: "(Readonly<{ unit: string; decimal: string; }> | undefined)",
|
|
460
|
+
value: input.amount
|
|
461
|
+
})) && _vo3(input.amount, _path + ".amount", true && _exceptionable) || _report(_exceptionable, {
|
|
462
|
+
path: _path + ".amount",
|
|
463
|
+
expected: "(Readonly<{ unit: string; decimal: string; }> | undefined)",
|
|
464
|
+
value: input.amount
|
|
465
|
+
}), undefined === input.value || "number" === typeof input.value || _report(_exceptionable, {
|
|
466
|
+
path: _path + ".value",
|
|
467
|
+
expected: "(number | undefined)",
|
|
468
|
+
value: input.value
|
|
469
|
+
}), undefined === input.reason || "string" === typeof input.reason || _report(_exceptionable, {
|
|
470
|
+
path: _path + ".reason",
|
|
471
|
+
expected: "(string | undefined)",
|
|
472
|
+
value: input.reason
|
|
473
|
+
})].every(flag => flag);
|
|
474
|
+
const _vo3 = (input, _path, _exceptionable = true) => ["string" === typeof input.unit || _report(_exceptionable, {
|
|
475
|
+
path: _path + ".unit",
|
|
476
|
+
expected: "string",
|
|
477
|
+
value: input.unit
|
|
478
|
+
}), "string" === typeof input.decimal || _report(_exceptionable, {
|
|
479
|
+
path: _path + ".decimal",
|
|
480
|
+
expected: "string",
|
|
481
|
+
value: input.decimal
|
|
482
|
+
})].every(flag => flag);
|
|
483
|
+
const _vo4 = (input, _path, _exceptionable = true) => ["string" === typeof input.goalId || _report(_exceptionable, {
|
|
484
|
+
path: _path + ".goalId",
|
|
485
|
+
expected: "string",
|
|
486
|
+
value: input.goalId
|
|
487
|
+
}), "number" === typeof input.goalVersion || _report(_exceptionable, {
|
|
488
|
+
path: _path + ".goalVersion",
|
|
489
|
+
expected: "number",
|
|
490
|
+
value: input.goalVersion
|
|
491
|
+
}), _vp1(input, _path, true && _exceptionable), _vp2(input, _path, true && _exceptionable), undefined === input.reached || "boolean" === typeof input.reached || _report(_exceptionable, {
|
|
492
|
+
path: _path + ".reached",
|
|
493
|
+
expected: "(boolean | undefined)",
|
|
494
|
+
value: input.reached
|
|
495
|
+
}), undefined === input.atSec || "number" === typeof input.atSec || _report(_exceptionable, {
|
|
496
|
+
path: _path + ".atSec",
|
|
497
|
+
expected: "(number | undefined)",
|
|
498
|
+
value: input.atSec
|
|
499
|
+
}), _vp0(input, _path, true && _exceptionable)].every(flag => flag);
|
|
500
|
+
const _vo5 = (input, _path, _exceptionable = true) => ["statically-known" === input.metrics || "unknown" === input.metrics || "unsupported" === input.metrics || _report(_exceptionable, {
|
|
501
|
+
path: _path + ".metrics",
|
|
502
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
503
|
+
value: input.metrics
|
|
504
|
+
}), "statically-known" === input.goals || "unknown" === input.goals || "unsupported" === input.goals || _report(_exceptionable, {
|
|
505
|
+
path: _path + ".goals",
|
|
506
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
507
|
+
value: input.goals
|
|
508
|
+
}), "statically-known" === input.reset || "unknown" === input.reset || "unsupported" === input.reset || _report(_exceptionable, {
|
|
509
|
+
path: _path + ".reset",
|
|
510
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
511
|
+
value: input.reset
|
|
512
|
+
}), "statically-known" === input.flow || "unknown" === input.flow || "unsupported" === input.flow || _report(_exceptionable, {
|
|
513
|
+
path: _path + ".flow",
|
|
514
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
515
|
+
value: input.flow
|
|
516
|
+
}), "statically-known" === input.advance || "unknown" === input.advance || "unsupported" === input.advance || _report(_exceptionable, {
|
|
517
|
+
path: _path + ".advance",
|
|
518
|
+
expected: "(\"statically-known\" | \"unknown\" | \"unsupported\")",
|
|
519
|
+
value: input.advance
|
|
520
|
+
})].every(flag => flag);
|
|
521
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
522
|
+
let errors;
|
|
523
|
+
let _report;
|
|
524
|
+
const __validate = input => {
|
|
525
|
+
if (false === __is(input)) {
|
|
526
|
+
errors = [];
|
|
527
|
+
_report = _validateReport_1._validateReport(errors);
|
|
528
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
529
|
+
path: _path + "",
|
|
530
|
+
expected: _ve0,
|
|
531
|
+
value: input
|
|
532
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
533
|
+
path: _path + "",
|
|
534
|
+
expected: _ve0,
|
|
535
|
+
value: input
|
|
536
|
+
}))(input, "$input", true);
|
|
537
|
+
const success = 0 === errors.length;
|
|
538
|
+
return success ? {
|
|
539
|
+
success,
|
|
540
|
+
data: input
|
|
541
|
+
} : {
|
|
542
|
+
success,
|
|
543
|
+
errors,
|
|
544
|
+
data: input
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
success: true,
|
|
549
|
+
data: input
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
return input => __validate(JSON.parse(input));
|
|
553
|
+
})()(input);
|
|
554
|
+
}
|
|
555
|
+
function buildAnalysisArtifactJsonSchema() {
|
|
556
|
+
return {
|
|
557
|
+
components: {
|
|
558
|
+
schemas: {
|
|
559
|
+
"ReadonlyschemaVersion1algorithmVersionstringassumptionsreadonlystringwarningsreadonlystringobservationCoverageArtifactCoveragehorizonReadonlysecnumberkindbudgetdurationunknownuntilundefined---4more---capabilitiesReadonly---": {
|
|
560
|
+
type: "object",
|
|
561
|
+
properties: {
|
|
562
|
+
schemaVersion: {
|
|
563
|
+
"const": 1
|
|
564
|
+
},
|
|
565
|
+
algorithmVersion: {
|
|
566
|
+
type: "string"
|
|
567
|
+
},
|
|
568
|
+
assumptions: {
|
|
569
|
+
type: "array",
|
|
570
|
+
items: {
|
|
571
|
+
type: "string"
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
warnings: {
|
|
575
|
+
type: "array",
|
|
576
|
+
items: {
|
|
577
|
+
type: "string"
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
observationCoverage: {
|
|
581
|
+
$ref: "#/components/schemas/ArtifactCoverage"
|
|
582
|
+
},
|
|
583
|
+
horizon: {
|
|
584
|
+
$ref: "#/components/schemas/Readonlysecnumberkindbudgetdurationunknownuntil"
|
|
585
|
+
},
|
|
586
|
+
sampleCount: {
|
|
587
|
+
type: "number"
|
|
588
|
+
},
|
|
589
|
+
effectiveRunHash: {
|
|
590
|
+
type: "string"
|
|
591
|
+
},
|
|
592
|
+
metrics: {
|
|
593
|
+
type: "array",
|
|
594
|
+
items: {
|
|
595
|
+
$ref: "#/components/schemas/ReadonlymetricIdstringmetricVersionnumbermeaningstringmetricKindMetricKindtimeAxisMetricTimeAxisdomainMetricDomainreadingestimated---1more---unavailable---5more---reasonstringundefined"
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
goals: {
|
|
599
|
+
type: "array",
|
|
600
|
+
items: {
|
|
601
|
+
$ref: "#/components/schemas/ReadonlygoalIdstringgoalVersionnumberstatusAnalysisStatusmethodAnalysisMethodundefinedreachedbooleanundefinedatSecnumberundefinedassumptionsreadonlystring"
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
capabilities: {
|
|
605
|
+
$ref: "#/components/schemas/ReadonlymetricsCapabilityKnowledgegoalsCapabilityKnowledgeresetCapabilityKnowledgeflowCapabilityKnowledgeadvanceCapabilityKnowledge"
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
required: [
|
|
609
|
+
"schemaVersion",
|
|
610
|
+
"algorithmVersion",
|
|
611
|
+
"assumptions",
|
|
612
|
+
"warnings",
|
|
613
|
+
"observationCoverage",
|
|
614
|
+
"metrics",
|
|
615
|
+
"goals",
|
|
616
|
+
"capabilities"
|
|
617
|
+
],
|
|
618
|
+
additionalProperties: false
|
|
619
|
+
},
|
|
620
|
+
ArtifactCoverage: {
|
|
621
|
+
oneOf: [
|
|
622
|
+
{
|
|
623
|
+
"const": "complete"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"const": "disabled"
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
"const": "incomplete"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"const": "partial"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
"const": "unknown"
|
|
636
|
+
}
|
|
637
|
+
]
|
|
638
|
+
},
|
|
639
|
+
Readonlysecnumberkindbudgetdurationunknownuntil: {
|
|
640
|
+
type: "object",
|
|
641
|
+
properties: {
|
|
642
|
+
sec: {
|
|
643
|
+
type: "number"
|
|
644
|
+
},
|
|
645
|
+
kind: {
|
|
646
|
+
oneOf: [
|
|
647
|
+
{
|
|
648
|
+
"const": "budget"
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
"const": "duration"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
"const": "unknown"
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
"const": "until"
|
|
658
|
+
}
|
|
659
|
+
]
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
required: [
|
|
663
|
+
"sec",
|
|
664
|
+
"kind"
|
|
665
|
+
],
|
|
666
|
+
additionalProperties: false
|
|
667
|
+
},
|
|
668
|
+
"ReadonlymetricIdstringmetricVersionnumbermeaningstringmetricKindMetricKindtimeAxisMetricTimeAxisdomainMetricDomainreadingestimated---1more---unavailable---5more---reasonstringundefined": {
|
|
669
|
+
type: "object",
|
|
670
|
+
properties: {
|
|
671
|
+
metricId: {
|
|
672
|
+
type: "string"
|
|
673
|
+
},
|
|
674
|
+
metricVersion: {
|
|
675
|
+
type: "number"
|
|
676
|
+
},
|
|
677
|
+
meaning: {
|
|
678
|
+
type: "string"
|
|
679
|
+
},
|
|
680
|
+
metricKind: {
|
|
681
|
+
$ref: "#/components/schemas/MetricKind"
|
|
682
|
+
},
|
|
683
|
+
timeAxis: {
|
|
684
|
+
$ref: "#/components/schemas/MetricTimeAxis"
|
|
685
|
+
},
|
|
686
|
+
domain: {
|
|
687
|
+
$ref: "#/components/schemas/MetricDomain"
|
|
688
|
+
},
|
|
689
|
+
reading: {
|
|
690
|
+
oneOf: [
|
|
691
|
+
{
|
|
692
|
+
"const": "estimated"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"const": "observed"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
"const": "unavailable"
|
|
699
|
+
}
|
|
700
|
+
]
|
|
701
|
+
},
|
|
702
|
+
status: {
|
|
703
|
+
$ref: "#/components/schemas/AnalysisStatus"
|
|
704
|
+
},
|
|
705
|
+
method: {
|
|
706
|
+
oneOf: [
|
|
707
|
+
{
|
|
708
|
+
"const": "analytic-local"
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
"const": "exact"
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
"const": "fixed-step"
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
"const": "heuristic-fit"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"const": "monte-carlo"
|
|
721
|
+
}
|
|
722
|
+
]
|
|
723
|
+
},
|
|
724
|
+
sign: {
|
|
725
|
+
oneOf: [
|
|
726
|
+
{
|
|
727
|
+
"const": "negative"
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
"const": "nonfinite"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
"const": "positive"
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
"const": "zero"
|
|
737
|
+
}
|
|
738
|
+
]
|
|
739
|
+
},
|
|
740
|
+
amount: {
|
|
741
|
+
$ref: "#/components/schemas/Readonlyunitstringdecimalstring"
|
|
742
|
+
},
|
|
743
|
+
value: {
|
|
744
|
+
type: "number"
|
|
745
|
+
},
|
|
746
|
+
reason: {
|
|
747
|
+
type: "string"
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
required: [
|
|
751
|
+
"metricId",
|
|
752
|
+
"metricVersion",
|
|
753
|
+
"meaning",
|
|
754
|
+
"metricKind",
|
|
755
|
+
"timeAxis",
|
|
756
|
+
"domain",
|
|
757
|
+
"reading",
|
|
758
|
+
"status"
|
|
759
|
+
],
|
|
760
|
+
additionalProperties: false
|
|
761
|
+
},
|
|
762
|
+
MetricKind: {
|
|
763
|
+
oneOf: [
|
|
764
|
+
{
|
|
765
|
+
"const": "cumulative"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
"const": "stock"
|
|
769
|
+
}
|
|
770
|
+
]
|
|
771
|
+
},
|
|
772
|
+
MetricTimeAxis: {
|
|
773
|
+
oneOf: [
|
|
774
|
+
{
|
|
775
|
+
"const": "instant"
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
"const": "interval"
|
|
779
|
+
}
|
|
780
|
+
]
|
|
781
|
+
},
|
|
782
|
+
MetricDomain: {
|
|
783
|
+
oneOf: [
|
|
784
|
+
{
|
|
785
|
+
"const": "amount"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
"const": "count"
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
"const": "ratio"
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
"const": "time"
|
|
795
|
+
}
|
|
796
|
+
]
|
|
797
|
+
},
|
|
798
|
+
AnalysisStatus: {
|
|
799
|
+
oneOf: [
|
|
800
|
+
{
|
|
801
|
+
"const": "censored"
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
"const": "error"
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
"const": "insufficient-data"
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
"const": "invalid"
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
"const": "ok"
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
"const": "unknown"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"const": "unsupported"
|
|
820
|
+
}
|
|
821
|
+
]
|
|
822
|
+
},
|
|
823
|
+
Readonlyunitstringdecimalstring: {
|
|
824
|
+
type: "object",
|
|
825
|
+
properties: {
|
|
826
|
+
unit: {
|
|
827
|
+
type: "string"
|
|
828
|
+
},
|
|
829
|
+
decimal: {
|
|
830
|
+
type: "string"
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
required: [
|
|
834
|
+
"unit",
|
|
835
|
+
"decimal"
|
|
836
|
+
],
|
|
837
|
+
additionalProperties: false
|
|
838
|
+
},
|
|
839
|
+
ReadonlygoalIdstringgoalVersionnumberstatusAnalysisStatusmethodAnalysisMethodundefinedreachedbooleanundefinedatSecnumberundefinedassumptionsreadonlystring: {
|
|
840
|
+
type: "object",
|
|
841
|
+
properties: {
|
|
842
|
+
goalId: {
|
|
843
|
+
type: "string"
|
|
844
|
+
},
|
|
845
|
+
goalVersion: {
|
|
846
|
+
type: "number"
|
|
847
|
+
},
|
|
848
|
+
status: {
|
|
849
|
+
$ref: "#/components/schemas/AnalysisStatus"
|
|
850
|
+
},
|
|
851
|
+
method: {
|
|
852
|
+
oneOf: [
|
|
853
|
+
{
|
|
854
|
+
"const": "analytic-local"
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
"const": "exact"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"const": "fixed-step"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
"const": "heuristic-fit"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"const": "monte-carlo"
|
|
867
|
+
}
|
|
868
|
+
]
|
|
869
|
+
},
|
|
870
|
+
reached: {
|
|
871
|
+
type: "boolean"
|
|
872
|
+
},
|
|
873
|
+
atSec: {
|
|
874
|
+
type: "number"
|
|
875
|
+
},
|
|
876
|
+
assumptions: {
|
|
877
|
+
type: "array",
|
|
878
|
+
items: {
|
|
879
|
+
type: "string"
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
},
|
|
883
|
+
required: [
|
|
884
|
+
"goalId",
|
|
885
|
+
"goalVersion",
|
|
886
|
+
"status",
|
|
887
|
+
"assumptions"
|
|
888
|
+
],
|
|
889
|
+
additionalProperties: false
|
|
890
|
+
},
|
|
891
|
+
ReadonlymetricsCapabilityKnowledgegoalsCapabilityKnowledgeresetCapabilityKnowledgeflowCapabilityKnowledgeadvanceCapabilityKnowledge: {
|
|
892
|
+
type: "object",
|
|
893
|
+
properties: {
|
|
894
|
+
metrics: {
|
|
895
|
+
$ref: "#/components/schemas/CapabilityKnowledge"
|
|
896
|
+
},
|
|
897
|
+
goals: {
|
|
898
|
+
$ref: "#/components/schemas/CapabilityKnowledge"
|
|
899
|
+
},
|
|
900
|
+
reset: {
|
|
901
|
+
$ref: "#/components/schemas/CapabilityKnowledge"
|
|
902
|
+
},
|
|
903
|
+
flow: {
|
|
904
|
+
$ref: "#/components/schemas/CapabilityKnowledge"
|
|
905
|
+
},
|
|
906
|
+
advance: {
|
|
907
|
+
$ref: "#/components/schemas/CapabilityKnowledge"
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
required: [
|
|
911
|
+
"metrics",
|
|
912
|
+
"goals",
|
|
913
|
+
"reset",
|
|
914
|
+
"flow",
|
|
915
|
+
"advance"
|
|
916
|
+
],
|
|
917
|
+
additionalProperties: false
|
|
918
|
+
},
|
|
919
|
+
CapabilityKnowledge: {
|
|
920
|
+
oneOf: [
|
|
921
|
+
{
|
|
922
|
+
"const": "statically-known"
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
"const": "unknown"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
"const": "unsupported"
|
|
929
|
+
}
|
|
930
|
+
]
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
},
|
|
934
|
+
schema: {
|
|
935
|
+
type: "object",
|
|
936
|
+
properties: {
|
|
937
|
+
schemaVersion: {
|
|
938
|
+
"const": 1
|
|
939
|
+
},
|
|
940
|
+
algorithmVersion: {
|
|
941
|
+
type: "string"
|
|
942
|
+
},
|
|
943
|
+
assumptions: {
|
|
944
|
+
type: "array",
|
|
945
|
+
items: {
|
|
946
|
+
type: "string"
|
|
947
|
+
}
|
|
948
|
+
},
|
|
949
|
+
warnings: {
|
|
950
|
+
type: "array",
|
|
951
|
+
items: {
|
|
952
|
+
type: "string"
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
observationCoverage: {
|
|
956
|
+
$ref: "#/components/schemas/ArtifactCoverage"
|
|
957
|
+
},
|
|
958
|
+
horizon: {
|
|
959
|
+
$ref: "#/components/schemas/Readonlysecnumberkindbudgetdurationunknownuntil"
|
|
960
|
+
},
|
|
961
|
+
sampleCount: {
|
|
962
|
+
type: "number"
|
|
963
|
+
},
|
|
964
|
+
effectiveRunHash: {
|
|
965
|
+
type: "string"
|
|
966
|
+
},
|
|
967
|
+
metrics: {
|
|
968
|
+
type: "array",
|
|
969
|
+
items: {
|
|
970
|
+
$ref: "#/components/schemas/ReadonlymetricIdstringmetricVersionnumbermeaningstringmetricKindMetricKindtimeAxisMetricTimeAxisdomainMetricDomainreadingestimated---1more---unavailable---5more---reasonstringundefined"
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
goals: {
|
|
974
|
+
type: "array",
|
|
975
|
+
items: {
|
|
976
|
+
$ref: "#/components/schemas/ReadonlygoalIdstringgoalVersionnumberstatusAnalysisStatusmethodAnalysisMethodundefinedreachedbooleanundefinedatSecnumberundefinedassumptionsreadonlystring"
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
capabilities: {
|
|
980
|
+
$ref: "#/components/schemas/ReadonlymetricsCapabilityKnowledgegoalsCapabilityKnowledgeresetCapabilityKnowledgeflowCapabilityKnowledgeadvanceCapabilityKnowledge"
|
|
981
|
+
}
|
|
982
|
+
},
|
|
983
|
+
required: [
|
|
984
|
+
"schemaVersion",
|
|
985
|
+
"algorithmVersion",
|
|
986
|
+
"assumptions",
|
|
987
|
+
"warnings",
|
|
988
|
+
"observationCoverage",
|
|
989
|
+
"metrics",
|
|
990
|
+
"goals",
|
|
991
|
+
"capabilities"
|
|
992
|
+
],
|
|
993
|
+
additionalProperties: false
|
|
994
|
+
},
|
|
995
|
+
version: "3.1"
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
let analysisArtifactJsonSchemaUnit;
|
|
999
|
+
export function analysisArtifactJsonSchema() {
|
|
1000
|
+
analysisArtifactJsonSchemaUnit ??= buildAnalysisArtifactJsonSchema();
|
|
1001
|
+
return analysisArtifactJsonSchemaUnit;
|
|
1002
|
+
}
|
|
1003
|
+
function sha256Text(value) {
|
|
1004
|
+
return createHash("sha256").update(value).digest("hex");
|
|
1005
|
+
}
|
|
1006
|
+
export function analysisCanonicalJson(value) {
|
|
1007
|
+
return renderCanonical(value, new Set());
|
|
1008
|
+
}
|
|
1009
|
+
function renderCanonical(value, seen) {
|
|
1010
|
+
if (value === null || typeof value !== "object")
|
|
1011
|
+
return JSON.stringify(value) ?? "null";
|
|
1012
|
+
if (seen.has(value))
|
|
1013
|
+
return '"[circular]"';
|
|
1014
|
+
seen.add(value);
|
|
1015
|
+
try {
|
|
1016
|
+
if (Array.isArray(value)) {
|
|
1017
|
+
const entries = Array.from({ length: value.length }, (_, index) => renderCanonical(value[index] ?? null, seen));
|
|
1018
|
+
return `[${entries.join(",")}]`;
|
|
1019
|
+
}
|
|
1020
|
+
const entries = Object.entries(value).filter(([, entry]) => entry !== undefined);
|
|
1021
|
+
entries.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
|
|
1022
|
+
return `{${entries
|
|
1023
|
+
.map(([key, entry]) => `${JSON.stringify(key)}:${renderCanonical(entry, seen)}`)
|
|
1024
|
+
.join(",")}}`;
|
|
1025
|
+
}
|
|
1026
|
+
finally {
|
|
1027
|
+
seen.delete(value);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
export function analysisSchemaHash() {
|
|
1031
|
+
return sha256Text(analysisCanonicalJson(analysisArtifactJsonSchema()));
|
|
1032
|
+
}
|
|
1033
|
+
export function artifactProvenance(artifact, schemaHash) {
|
|
1034
|
+
// Goal-level assumptions, such as a wallet fallback for net worth, are part of the analytical basis.
|
|
1035
|
+
const goalAssumptions = (artifact.goals ?? [])
|
|
1036
|
+
.filter((goal) => goal.assumptions.length > 0)
|
|
1037
|
+
.map((goal) => ({ goalId: goal.goalId, goalVersion: goal.goalVersion, assumptions: goal.assumptions }));
|
|
1038
|
+
const assumptionHash = sha256Text(analysisCanonicalJson(goalAssumptions.length > 0 ? { assumptions: artifact.assumptions, goalAssumptions } : artifact.assumptions));
|
|
1039
|
+
const provenance = sha256Text(analysisCanonicalJson({
|
|
1040
|
+
algorithmVersion: artifact.algorithmVersion,
|
|
1041
|
+
assumptionHash,
|
|
1042
|
+
schemaHash,
|
|
1043
|
+
}));
|
|
1044
|
+
return {
|
|
1045
|
+
schemaHash,
|
|
1046
|
+
algorithmVersion: artifact.algorithmVersion,
|
|
1047
|
+
assumptionHash,
|
|
1048
|
+
provenance,
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
export function classifyAmount(engine, amount, unit) {
|
|
1052
|
+
if (!engine.isFinite(amount)) {
|
|
1053
|
+
return {
|
|
1054
|
+
status: "invalid",
|
|
1055
|
+
sign: "nonfinite",
|
|
1056
|
+
reason: nonfiniteKind(engine.toString(amount)),
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
const decimal = engine.toString(amount);
|
|
1060
|
+
const cmp = engine.cmp(amount, engine.zero());
|
|
1061
|
+
if (cmp < 0)
|
|
1062
|
+
return { status: "ok", sign: "negative", amount: { unit, decimal } };
|
|
1063
|
+
if (cmp === 0)
|
|
1064
|
+
return { status: "ok", sign: "zero", amount: { unit, decimal } };
|
|
1065
|
+
return { status: "ok", sign: "positive", amount: { unit, decimal } };
|
|
1066
|
+
}
|
|
1067
|
+
function nonfiniteKind(text) {
|
|
1068
|
+
const lower = text.toLowerCase();
|
|
1069
|
+
if (lower.includes("nan"))
|
|
1070
|
+
return "nan";
|
|
1071
|
+
if (text.startsWith("-"))
|
|
1072
|
+
return "negative-infinity";
|
|
1073
|
+
return "infinity";
|
|
1074
|
+
}
|
|
1075
|
+
export function classifyFinite(value) {
|
|
1076
|
+
if (!Number.isFinite(value)) {
|
|
1077
|
+
return {
|
|
1078
|
+
status: "invalid",
|
|
1079
|
+
sign: "nonfinite",
|
|
1080
|
+
reason: nonfiniteKind(String(value)),
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
if (value < 0)
|
|
1084
|
+
return { status: "ok", sign: "negative", value };
|
|
1085
|
+
if (value === 0)
|
|
1086
|
+
return { status: "ok", sign: "zero", value };
|
|
1087
|
+
return { status: "ok", sign: "positive", value };
|
|
1088
|
+
}
|
|
1089
|
+
const DECIMAL_SPELLING = /^([+-])?(\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
1090
|
+
/** The sign a finite decimal spelling denotes, without an engine. An unparsed spelling is null. */
|
|
1091
|
+
function decimalSign(decimal) {
|
|
1092
|
+
const match = DECIMAL_SPELLING.exec(decimal.trim());
|
|
1093
|
+
if (!match)
|
|
1094
|
+
return null;
|
|
1095
|
+
if (!/[1-9]/.test(match[2] ?? ""))
|
|
1096
|
+
return "zero";
|
|
1097
|
+
return match[1] === "-" ? "negative" : "positive";
|
|
1098
|
+
}
|
|
1099
|
+
/** Nonfinite spellings an engine can print. A nonfinite amount is invalid and omits `amount`. */
|
|
1100
|
+
const NONFINITE_DECIMAL = /^[+-]?(nan|inf|infinity)$/i;
|
|
1101
|
+
/**
|
|
1102
|
+
* Cross-field rules the generator does not claim.
|
|
1103
|
+
* Unavailable readings must not carry a numeric stand-in.
|
|
1104
|
+
*/
|
|
1105
|
+
export function validateAnalysisSemantics(artifact) {
|
|
1106
|
+
const issues = [];
|
|
1107
|
+
artifact.metrics.forEach((reading, index) => {
|
|
1108
|
+
const path = `metrics.${index}`;
|
|
1109
|
+
const unavailable = reading.reading === "unavailable" || reading.status !== "ok";
|
|
1110
|
+
if (reading.status !== "ok" && reading.reading !== "unavailable") {
|
|
1111
|
+
issues.push({ path, message: "non-ok reading is not labeled unavailable" });
|
|
1112
|
+
}
|
|
1113
|
+
if (unavailable && (reading.amount !== undefined || reading.value !== undefined)) {
|
|
1114
|
+
issues.push({ path, message: "unavailable reading carries a value" });
|
|
1115
|
+
}
|
|
1116
|
+
if (reading.status === "ok" && reading.domain === "amount" && reading.amount === undefined) {
|
|
1117
|
+
issues.push({ path, message: "ok amount reading has no decimal" });
|
|
1118
|
+
}
|
|
1119
|
+
if (reading.status === "ok" && reading.domain !== "amount" && reading.value === undefined) {
|
|
1120
|
+
issues.push({ path, message: "ok numeric reading has no value" });
|
|
1121
|
+
}
|
|
1122
|
+
if (reading.value !== undefined && !Number.isFinite(reading.value)) {
|
|
1123
|
+
issues.push({ path, message: "numeric value is nonfinite" });
|
|
1124
|
+
}
|
|
1125
|
+
if (reading.amount !== undefined && NONFINITE_DECIMAL.test(reading.amount.decimal.trim())) {
|
|
1126
|
+
issues.push({ path, message: "amount decimal is nonfinite" });
|
|
1127
|
+
}
|
|
1128
|
+
if (reading.value !== undefined && Number.isFinite(reading.value) && reading.sign !== undefined) {
|
|
1129
|
+
const sign = reading.value < 0 ? "negative" : reading.value === 0 ? "zero" : "positive";
|
|
1130
|
+
if (reading.sign !== sign)
|
|
1131
|
+
issues.push({ path, message: "numeric sign contradicts its value" });
|
|
1132
|
+
}
|
|
1133
|
+
// One representation per domain: an amount reading has no number, and a numeric reading has no amount.
|
|
1134
|
+
if (reading.domain === "amount" && reading.value !== undefined) {
|
|
1135
|
+
issues.push({ path, message: "amount reading carries a numeric value" });
|
|
1136
|
+
}
|
|
1137
|
+
if (reading.domain !== "amount" && reading.amount !== undefined) {
|
|
1138
|
+
issues.push({ path, message: "numeric reading carries an amount" });
|
|
1139
|
+
}
|
|
1140
|
+
if (reading.amount !== undefined && reading.sign !== undefined) {
|
|
1141
|
+
const expected = decimalSign(reading.amount.decimal);
|
|
1142
|
+
if (expected !== null && reading.sign !== expected) {
|
|
1143
|
+
issues.push({ path, message: "sign does not match the amount decimal" });
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
if (!Number.isFinite(reading.metricVersion)) {
|
|
1147
|
+
issues.push({ path, message: "metricVersion is nonfinite" });
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
artifact.goals.forEach((goal, index) => {
|
|
1151
|
+
if (goal.status !== "ok" && goal.reached !== undefined) {
|
|
1152
|
+
issues.push({ path: `goals.${index}`, message: "unreached status still carries reached" });
|
|
1153
|
+
}
|
|
1154
|
+
if (goal.status !== "ok" && goal.method !== undefined) {
|
|
1155
|
+
issues.push({ path: `goals.${index}`, message: "non-ok goal carries a method" });
|
|
1156
|
+
}
|
|
1157
|
+
if (!Number.isFinite(goal.goalVersion)) {
|
|
1158
|
+
issues.push({ path: `goals.${index}`, message: "goalVersion is nonfinite" });
|
|
1159
|
+
}
|
|
1160
|
+
if (goal.atSec !== undefined && !Number.isFinite(goal.atSec)) {
|
|
1161
|
+
issues.push({ path: `goals.${index}`, message: "atSec is nonfinite" });
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
// JSON writes a nonfinite number as null, which the generated schema rejects.
|
|
1165
|
+
if (artifact.horizon !== undefined && !Number.isFinite(artifact.horizon.sec)) {
|
|
1166
|
+
issues.push({ path: "horizon.sec", message: "horizon.sec is nonfinite" });
|
|
1167
|
+
}
|
|
1168
|
+
if (artifact.sampleCount !== undefined &&
|
|
1169
|
+
(!Number.isInteger(artifact.sampleCount) || artifact.sampleCount < 0)) {
|
|
1170
|
+
issues.push({ path: "sampleCount", message: "sampleCount is not a nonnegative integer" });
|
|
1171
|
+
}
|
|
1172
|
+
return issues;
|
|
1173
|
+
}
|
|
1174
|
+
export function renderAnalysisMarkdown(artifact) {
|
|
1175
|
+
const lines = [
|
|
1176
|
+
"# Analysis artifact v1",
|
|
1177
|
+
"",
|
|
1178
|
+
`Algorithm: ${artifact.algorithmVersion}`,
|
|
1179
|
+
`Coverage: ${artifact.observationCoverage}`,
|
|
1180
|
+
`Capabilities: metrics ${artifact.capabilities.metrics}, goals ${artifact.capabilities.goals}, reset ${artifact.capabilities.reset}, flow ${artifact.capabilities.flow}, advance ${artifact.capabilities.advance}`,
|
|
1181
|
+
];
|
|
1182
|
+
if (artifact.effectiveRunHash !== undefined)
|
|
1183
|
+
lines.push(`Run: ${artifact.effectiveRunHash}`);
|
|
1184
|
+
if (artifact.sampleCount !== undefined)
|
|
1185
|
+
lines.push(`Samples: ${artifact.sampleCount}`);
|
|
1186
|
+
if (artifact.assumptions.length > 0) {
|
|
1187
|
+
lines.push("", "## Assumptions", ...artifact.assumptions.map((item) => `- ${item}`));
|
|
1188
|
+
}
|
|
1189
|
+
if (artifact.warnings.length > 0) {
|
|
1190
|
+
lines.push("", "## Warnings", ...artifact.warnings.map((item) => `- ${item}`));
|
|
1191
|
+
}
|
|
1192
|
+
lines.push("", "## Metrics");
|
|
1193
|
+
if (artifact.metrics.length === 0)
|
|
1194
|
+
lines.push("None.");
|
|
1195
|
+
for (const metric of artifact.metrics) {
|
|
1196
|
+
const wire = metric.amount
|
|
1197
|
+
? `${metric.amount.decimal} ${metric.amount.unit}`
|
|
1198
|
+
: metric.value !== undefined
|
|
1199
|
+
? String(metric.value)
|
|
1200
|
+
: "absent";
|
|
1201
|
+
lines.push(`- ${metric.metricId}@${metric.metricVersion} ${metric.reading} ${metric.status} ${wire}`);
|
|
1202
|
+
}
|
|
1203
|
+
lines.push("", "## Goals");
|
|
1204
|
+
if (artifact.goals.length === 0)
|
|
1205
|
+
lines.push("None.");
|
|
1206
|
+
for (const goal of artifact.goals) {
|
|
1207
|
+
const reached = goal.reached === undefined ? "absent" : String(goal.reached);
|
|
1208
|
+
// A reach time belongs to a goal that was reached. Other statuses do not print one.
|
|
1209
|
+
const at = goal.atSec === undefined || goal.status !== "ok" || goal.reached !== true ? "" : ` at ${goal.atSec}s`;
|
|
1210
|
+
lines.push(`- ${goal.goalId}@${goal.goalVersion} ${goal.status} reached ${reached}${at}`);
|
|
1211
|
+
}
|
|
1212
|
+
return `${lines.join("\n")}\n`;
|
|
1213
|
+
}
|
|
1214
|
+
export function analysisArtifactJson(artifact) {
|
|
1215
|
+
return `${analysisCanonicalJson(artifact)}\n`;
|
|
1216
|
+
}
|
|
1217
|
+
export function unavailableReading(args) {
|
|
1218
|
+
return {
|
|
1219
|
+
metricId: args.metricId,
|
|
1220
|
+
metricVersion: args.metricVersion,
|
|
1221
|
+
meaning: args.meaning,
|
|
1222
|
+
metricKind: args.metricKind,
|
|
1223
|
+
timeAxis: args.timeAxis,
|
|
1224
|
+
domain: args.domain,
|
|
1225
|
+
reading: "unavailable",
|
|
1226
|
+
status: args.status,
|
|
1227
|
+
...(args.reason !== undefined ? { reason: args.reason } : {}),
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
//# sourceMappingURL=contracts.js.map
|