@idlekit/core 0.3.1 → 0.4.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/README.md +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/scenario/compile.js +1 -0
- package/dist/scenario/compile.js.map +1 -1
- package/dist/scenario/scenarioContract.d.ts +30 -0
- package/dist/scenario/scenarioContract.js +35 -0
- package/dist/scenario/scenarioContract.js.map +1 -1
- package/dist/sim/advance.d.ts +198 -0
- package/dist/sim/advance.js +609 -0
- package/dist/sim/advance.js.map +1 -0
- package/dist/sim/analysis/checks.d.ts +260 -0
- package/dist/sim/analysis/checks.js +1442 -0
- package/dist/sim/analysis/checks.js.map +1 -0
- package/dist/sim/analysis/flow.d.ts +169 -0
- package/dist/sim/analysis/flow.js +1359 -0
- package/dist/sim/analysis/flow.js.map +1 -0
- package/dist/sim/analysis/jevAdvisory.d.ts +113 -0
- package/dist/sim/analysis/jevAdvisory.js +846 -0
- package/dist/sim/analysis/jevAdvisory.js.map +1 -0
- package/dist/sim/analysis/judge.d.ts +145 -0
- package/dist/sim/analysis/judge.js +1451 -0
- package/dist/sim/analysis/judge.js.map +1 -0
- package/dist/sim/analysis/registry.d.ts +9 -6
- package/dist/sim/analysis/registry.js +15 -2
- package/dist/sim/analysis/registry.js.map +1 -1
- package/dist/sim/executionBackend.d.ts +165 -0
- package/dist/sim/executionBackend.js +521 -0
- package/dist/sim/executionBackend.js.map +1 -0
- package/dist/sim/integrationMatrix.d.ts +52 -0
- package/dist/sim/integrationMatrix.js +68 -0
- package/dist/sim/integrationMatrix.js.map +1 -0
- package/dist/sim/observation.d.ts +11 -0
- package/dist/sim/observation.js +12 -0
- package/dist/sim/observation.js.map +1 -1
- package/dist/sim/offline.d.ts +2 -0
- package/dist/sim/offline.js +68 -1
- package/dist/sim/offline.js.map +1 -1
- package/dist/sim/simulator.d.ts +2 -0
- package/dist/sim/simulator.js +71 -1
- package/dist/sim/simulator.js.map +1 -1
- package/dist/sim/step.d.ts +10 -0
- package/dist/sim/step.js +10 -0
- package/dist/sim/step.js.map +1 -1
- package/dist/sim/types.d.ts +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1451 @@
|
|
|
1
|
+
import * as _accessExpressionAsString_1 from "typia/lib/internal/_accessExpressionAsString";
|
|
2
|
+
import * as _validateReport_1 from "typia/lib/internal/_validateReport";
|
|
3
|
+
import * as _createStandardSchema_1 from "typia/lib/internal/_createStandardSchema";
|
|
4
|
+
import typia, {} from "typia";
|
|
5
|
+
import { analysisAlgorithmVersion, validateAnalysisSemantics, } from "./contracts";
|
|
6
|
+
import { evaluateBalanceChecks, } from "./checks";
|
|
7
|
+
/**
|
|
8
|
+
* Optional rules judge. It reads a finished analysis artifact and a versioned rubric.
|
|
9
|
+
* Numeric comparisons go through the balance-check engine. This module does not run a simulation,
|
|
10
|
+
* does not rewrite that engine's report, and does not call an external provider.
|
|
11
|
+
*/
|
|
12
|
+
const JUDGE_SCHEMA_ID = "https://idlekit.dev/schemas/judge.output.schema.json";
|
|
13
|
+
const JUDGE_ALGORITHM_VERSION = "judge-rules-1";
|
|
14
|
+
export function judgeSchemaId() {
|
|
15
|
+
return JUDGE_SCHEMA_ID;
|
|
16
|
+
}
|
|
17
|
+
export function judgeAlgorithmVersion() {
|
|
18
|
+
return JUDGE_ALGORITHM_VERSION;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @evidence docs/requirements/active/optional-analysis-judge.md#req-pr18-rules-provider The provider is rules. The output contract does not carry a vendor response.
|
|
22
|
+
* @evidenceReview docs/requirements/active/optional-analysis-judge.md#req-pr18-rules-provider #bb58b8a Re-read the section: provider is rules and externalProvider is false.
|
|
23
|
+
*/
|
|
24
|
+
export const judgeRulesProvider = "rules-not-vendor";
|
|
25
|
+
/**
|
|
26
|
+
* @evidence docs/requirements/active/optional-analysis-judge.md#req-pr18-check-reuse A numeric threshold is decided by the balance-check engine.
|
|
27
|
+
* @evidenceReview docs/requirements/active/optional-analysis-judge.md#req-pr18-check-reuse #33488b3 Re-read the section: the judge does not recompute the metric.
|
|
28
|
+
*/
|
|
29
|
+
export const judgeCheckReuse = "checks-not-recomputed";
|
|
30
|
+
/**
|
|
31
|
+
* @evidence docs/requirements/active/optional-analysis-judge.md#req-pr18-evidence-refs A rubric ref must name a metric that exists on the artifact.
|
|
32
|
+
* @evidenceReview docs/requirements/active/optional-analysis-judge.md#req-pr18-evidence-refs #a078dea Re-read the section: a bad version or a missing ref is rejected.
|
|
33
|
+
*/
|
|
34
|
+
export const judgeEvidenceRefs = "existing-refs-only";
|
|
35
|
+
/**
|
|
36
|
+
* @evidence docs/requirements/active/optional-analysis-judge.md#req-pr18-separated-report Numerical results, estimates, and semantic notes stay in separate fields.
|
|
37
|
+
* @evidenceReview docs/requirements/active/optional-analysis-judge.md#req-pr18-separated-report #0fb3aa6 Re-read the section: a conflict does not rewrite the numerical verdict.
|
|
38
|
+
*/
|
|
39
|
+
export const judgeSeparatedReport = "layers-stay-apart";
|
|
40
|
+
/**
|
|
41
|
+
* @evidence docs/requirements/active/optional-analysis-judge.md#req-pr18-insufficient Missing information stays insufficient.
|
|
42
|
+
* @evidenceReview docs/requirements/active/optional-analysis-judge.md#req-pr18-insufficient #ed2626d Re-read the section: the report does not assign a health label.
|
|
43
|
+
*/
|
|
44
|
+
export const judgeInsufficient = "not-a-health-label";
|
|
45
|
+
/*
|
|
46
|
+
* typia runs on first call, not at module load. A plugin that the bundled CLI loads
|
|
47
|
+
* imports core source without the transform, and a module-load call would throw there.
|
|
48
|
+
*/
|
|
49
|
+
let validateJudgeReportValidator;
|
|
50
|
+
let validateRubricValidator;
|
|
51
|
+
/**
|
|
52
|
+
* @evidence docs/requirements/active/optional-analysis-judge.md#req-pr18-rules-provider The published validator is createValidate of the judge report.
|
|
53
|
+
* @evidenceReview docs/requirements/active/optional-analysis-judge.md#req-pr18-rules-provider #bb58b8a Re-read the section: the structural document is JudgeReportV1.
|
|
54
|
+
*/
|
|
55
|
+
export const validateJudgeReport = (input) => (validateJudgeReportValidator ??= (() => {
|
|
56
|
+
const _ip0 = input => 1 === input["schemaVersion"];
|
|
57
|
+
const _ip1 = input => false === input["externalProvider"];
|
|
58
|
+
const _ip2 = input => false === input["baselineRewrite"];
|
|
59
|
+
const _ip3 = input => "string" === typeof input["id"];
|
|
60
|
+
const _ip4 = input => "string" === typeof input["metricId"];
|
|
61
|
+
const _ip5 = input => null === input["value"] || "number" === typeof input["value"];
|
|
62
|
+
const _ve0 = "Readonly<{ schemaVersion: 1; contract: \"idlekit.judge.v1\"; algorithmVersion: \"judge-rules-1\"; provider: \"rules\"; rubricVersion: string; advisoryDigest: string; numerical: Readonly<{ schemaVersion: 1; contract: \"idlekit.balance-checks.v1\"; ... 7 more ...; externalProvider: false; }>; estimatedObservations: readonly R...";
|
|
63
|
+
const _vp0 = (input, _path, _exceptionable = true) => 1 === input["schemaVersion"] || _report(_exceptionable, {
|
|
64
|
+
path: _path + ".schemaVersion",
|
|
65
|
+
expected: "1",
|
|
66
|
+
value: input["schemaVersion"]
|
|
67
|
+
});
|
|
68
|
+
const _ve1 = "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...";
|
|
69
|
+
const _ve2 = "Readonly<{ id: string; category: JudgeLayer; severity: \"error\" | \"info\" | \"warn\"; evidenceRefs: readonly string[]; assumptionRefs: readonly string[]; recommendationId: RecommendationId; status: DiagnosticStatus; text: Readonly<...>; }>";
|
|
70
|
+
const _ve3 = "ReadonlyArray<Readonly<{ id: string; category: JudgeLayer; severity: \"error\" | \"info\" | \"warn\"; evidenceRefs: readonly string[]; assumptionRefs: readonly string[]; recommendationId: RecommendationId; status: DiagnosticStatus; text: Readonly<...>; }>>";
|
|
71
|
+
const _vp1 = (input, _path, _exceptionable = true) => false === input["externalProvider"] || _report(_exceptionable, {
|
|
72
|
+
path: _path + ".externalProvider",
|
|
73
|
+
expected: "false",
|
|
74
|
+
value: input["externalProvider"]
|
|
75
|
+
});
|
|
76
|
+
const _vp2 = (input, _path, _exceptionable = true) => false === input["baselineRewrite"] || _report(_exceptionable, {
|
|
77
|
+
path: _path + ".baselineRewrite",
|
|
78
|
+
expected: "false",
|
|
79
|
+
value: input["baselineRewrite"]
|
|
80
|
+
});
|
|
81
|
+
const _ve4 = "Readonly<{ id: string; metricId: string; severity: CheckSeverity; verdict: CheckVerdict; reason: string; mismatches: readonly string[]; evidence: Readonly<{ status: \"absent\" | ObservationStatus; ... 6 more ...; unit: string; }>; }>";
|
|
82
|
+
const _ve5 = "ReadonlyArray<Readonly<{ id: string; metricId: string; severity: CheckSeverity; verdict: CheckVerdict; reason: string; mismatches: readonly string[]; evidence: Readonly<{ status: \"absent\" | ObservationStatus; ... 6 more ...; unit: string; }>; }>>";
|
|
83
|
+
const _vp3 = (input, _path, _exceptionable = true) => "string" === typeof input["id"] || _report(_exceptionable, {
|
|
84
|
+
path: _path + ".id",
|
|
85
|
+
expected: "string",
|
|
86
|
+
value: input["id"]
|
|
87
|
+
});
|
|
88
|
+
const _vp4 = (input, _path, _exceptionable = true) => "string" === typeof input["metricId"] || _report(_exceptionable, {
|
|
89
|
+
path: _path + ".metricId",
|
|
90
|
+
expected: "string",
|
|
91
|
+
value: input["metricId"]
|
|
92
|
+
});
|
|
93
|
+
const _ve6 = "Readonly<{ status: \"absent\" | ObservationStatus; value: number | null; lower: number | null; upper: number | null; operator: CheckOperator; threshold: number; upperThreshold: number | null; unit: string; }>";
|
|
94
|
+
const _vp5 = (input, _path, _exceptionable = true) => null === input["value"] || "number" === typeof input["value"] || _report(_exceptionable, {
|
|
95
|
+
path: _path + ".value",
|
|
96
|
+
expected: "(null | number)",
|
|
97
|
+
value: input["value"]
|
|
98
|
+
});
|
|
99
|
+
const _ve7 = "(\"rec.metric.estimate-not-measured\" | \"rec.metric.identity-mismatch\" | \"rec.metric.insufficient\" | \"rec.metric.outside-threshold\" | \"rec.metric.unsupported\" | \"rec.metric.within-threshold\")";
|
|
100
|
+
const _io0 = input => _ip0(input) && "idlekit.judge.v1" === input.contract && "judge-rules-1" === input.algorithmVersion && "rules" === input.provider && "string" === typeof input.rubricVersion && "string" === typeof input.advisoryDigest && ("object" === typeof input.numerical && null !== input.numerical && _io1(input.numerical)) && (Array.isArray(input.estimatedObservations) && input.estimatedObservations.every(elem => "object" === typeof elem && null !== elem && _io4(elem))) && (Array.isArray(input.diagnostics) && input.diagnostics.every(elem => "object" === typeof elem && null !== elem && _io5(elem))) && _ip1(input) && _ip2(input);
|
|
101
|
+
const _io1 = input => _ip0(input) && "idlekit.balance-checks.v1" === input.contract && "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 && _io2(elem))) && (null === input.advisory || "string" === typeof input.advisory) && _ip2(input) && _ip1(input);
|
|
102
|
+
const _io2 = input => _ip3(input) && _ip4(input) && ("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 && _io3(input.evidence));
|
|
103
|
+
const _io3 = input => ("absent" === input.status || "censored" === input.status || "measured" === input.status || "missing" === input.status || "unknown" === input.status || "unsupported" === input.status) && _ip5(input) && (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;
|
|
104
|
+
const _io4 = input => _ip4(input) && _ip5(input) && (null === input.reason || "string" === typeof input.reason);
|
|
105
|
+
const _io5 = input => _ip3(input) && ("estimate" === input.category || "rule" === input.category || "semantic" === input.category) && ("error" === input.severity || "info" === input.severity || "warn" === input.severity) && (Array.isArray(input.evidenceRefs) && input.evidenceRefs.every(elem => "string" === typeof elem)) && (Array.isArray(input.assumptionRefs) && input.assumptionRefs.every(elem => "string" === typeof elem)) && ("rec.metric.estimate-not-measured" === input.recommendationId || "rec.metric.identity-mismatch" === input.recommendationId || "rec.metric.insufficient" === input.recommendationId || "rec.metric.outside-threshold" === input.recommendationId || "rec.metric.unsupported" === input.recommendationId || "rec.metric.within-threshold" === input.recommendationId) && ("conflict" === input.status || "indeterminate" === input.status || "insufficient" === input.status || "noted" === input.status || "unsupported" === input.status) && ("object" === typeof input.text && null !== input.text && _io6(input.text));
|
|
106
|
+
const _io6 = input => "string" === typeof input.en && "string" === typeof input.ko;
|
|
107
|
+
const _vo0 = (input, _path, _exceptionable = true) => [_vp0(input, _path, true && _exceptionable), "idlekit.judge.v1" === input.contract || _report(_exceptionable, {
|
|
108
|
+
path: _path + ".contract",
|
|
109
|
+
expected: "\"idlekit.judge.v1\"",
|
|
110
|
+
value: input.contract
|
|
111
|
+
}), "judge-rules-1" === input.algorithmVersion || _report(_exceptionable, {
|
|
112
|
+
path: _path + ".algorithmVersion",
|
|
113
|
+
expected: "\"judge-rules-1\"",
|
|
114
|
+
value: input.algorithmVersion
|
|
115
|
+
}), "rules" === input.provider || _report(_exceptionable, {
|
|
116
|
+
path: _path + ".provider",
|
|
117
|
+
expected: "\"rules\"",
|
|
118
|
+
value: input.provider
|
|
119
|
+
}), "string" === typeof input.rubricVersion || _report(_exceptionable, {
|
|
120
|
+
path: _path + ".rubricVersion",
|
|
121
|
+
expected: "string",
|
|
122
|
+
value: input.rubricVersion
|
|
123
|
+
}), "string" === typeof input.advisoryDigest || _report(_exceptionable, {
|
|
124
|
+
path: _path + ".advisoryDigest",
|
|
125
|
+
expected: "string",
|
|
126
|
+
value: input.advisoryDigest
|
|
127
|
+
}), ("object" === typeof input.numerical && null !== input.numerical || _report(_exceptionable, {
|
|
128
|
+
path: _path + ".numerical",
|
|
129
|
+
expected: _ve1,
|
|
130
|
+
value: input.numerical
|
|
131
|
+
})) && _vo1(input.numerical, _path + ".numerical", true && _exceptionable) || _report(_exceptionable, {
|
|
132
|
+
path: _path + ".numerical",
|
|
133
|
+
expected: _ve1,
|
|
134
|
+
value: input.numerical
|
|
135
|
+
}), (Array.isArray(input.estimatedObservations) || _report(_exceptionable, {
|
|
136
|
+
path: _path + ".estimatedObservations",
|
|
137
|
+
expected: "ReadonlyArray<Readonly<{ metricId: string; value: number | null; reason: string | null; }>>",
|
|
138
|
+
value: input.estimatedObservations
|
|
139
|
+
})) && input.estimatedObservations.map((elem, _index8) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
140
|
+
path: _path + ".estimatedObservations[" + _index8 + "]",
|
|
141
|
+
expected: "Readonly<{ metricId: string; value: number | null; reason: string | null; }>",
|
|
142
|
+
value: elem
|
|
143
|
+
})) && _vo4(elem, _path + ".estimatedObservations[" + _index8 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
144
|
+
path: _path + ".estimatedObservations[" + _index8 + "]",
|
|
145
|
+
expected: "Readonly<{ metricId: string; value: number | null; reason: string | null; }>",
|
|
146
|
+
value: elem
|
|
147
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
148
|
+
path: _path + ".estimatedObservations",
|
|
149
|
+
expected: "ReadonlyArray<Readonly<{ metricId: string; value: number | null; reason: string | null; }>>",
|
|
150
|
+
value: input.estimatedObservations
|
|
151
|
+
}), (Array.isArray(input.diagnostics) || _report(_exceptionable, {
|
|
152
|
+
path: _path + ".diagnostics",
|
|
153
|
+
expected: _ve3,
|
|
154
|
+
value: input.diagnostics
|
|
155
|
+
})) && input.diagnostics.map((elem, _index9) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
156
|
+
path: _path + ".diagnostics[" + _index9 + "]",
|
|
157
|
+
expected: _ve2,
|
|
158
|
+
value: elem
|
|
159
|
+
})) && _vo5(elem, _path + ".diagnostics[" + _index9 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
160
|
+
path: _path + ".diagnostics[" + _index9 + "]",
|
|
161
|
+
expected: _ve2,
|
|
162
|
+
value: elem
|
|
163
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
164
|
+
path: _path + ".diagnostics",
|
|
165
|
+
expected: _ve3,
|
|
166
|
+
value: input.diagnostics
|
|
167
|
+
}), _vp1(input, _path, true && _exceptionable), _vp2(input, _path, true && _exceptionable)].every(flag => flag);
|
|
168
|
+
const _vo1 = (input, _path, _exceptionable = true) => [_vp0(input, _path, true && _exceptionable), "idlekit.balance-checks.v1" === input.contract || _report(_exceptionable, {
|
|
169
|
+
path: _path + ".contract",
|
|
170
|
+
expected: "\"idlekit.balance-checks.v1\"",
|
|
171
|
+
value: input.contract
|
|
172
|
+
}), "balance-checks-1" === input.algorithmVersion || _report(_exceptionable, {
|
|
173
|
+
path: _path + ".algorithmVersion",
|
|
174
|
+
expected: "\"balance-checks-1\"",
|
|
175
|
+
value: input.algorithmVersion
|
|
176
|
+
}), (Array.isArray(input.failOn) || _report(_exceptionable, {
|
|
177
|
+
path: _path + ".failOn",
|
|
178
|
+
expected: "ReadonlyArray<FailOnToken>",
|
|
179
|
+
value: input.failOn
|
|
180
|
+
})) && input.failOn.map((elem, _index10) => "error" === elem || "inconclusive" === elem || "unsupported" === elem || "warn" === elem || _report(_exceptionable, {
|
|
181
|
+
path: _path + ".failOn[" + _index10 + "]",
|
|
182
|
+
expected: "(\"error\" | \"inconclusive\" | \"unsupported\" | \"warn\")",
|
|
183
|
+
value: elem
|
|
184
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
185
|
+
path: _path + ".failOn",
|
|
186
|
+
expected: "ReadonlyArray<FailOnToken>",
|
|
187
|
+
value: input.failOn
|
|
188
|
+
}), "boolean" === typeof input.pass || _report(_exceptionable, {
|
|
189
|
+
path: _path + ".pass",
|
|
190
|
+
expected: "boolean",
|
|
191
|
+
value: input.pass
|
|
192
|
+
}), 0 === input.exitCode || 2 === input.exitCode || _report(_exceptionable, {
|
|
193
|
+
path: _path + ".exitCode",
|
|
194
|
+
expected: "(0 | 2)",
|
|
195
|
+
value: input.exitCode
|
|
196
|
+
}), (Array.isArray(input.results) || _report(_exceptionable, {
|
|
197
|
+
path: _path + ".results",
|
|
198
|
+
expected: _ve5,
|
|
199
|
+
value: input.results
|
|
200
|
+
})) && input.results.map((elem, _index11) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
201
|
+
path: _path + ".results[" + _index11 + "]",
|
|
202
|
+
expected: _ve4,
|
|
203
|
+
value: elem
|
|
204
|
+
})) && _vo2(elem, _path + ".results[" + _index11 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
205
|
+
path: _path + ".results[" + _index11 + "]",
|
|
206
|
+
expected: _ve4,
|
|
207
|
+
value: elem
|
|
208
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
209
|
+
path: _path + ".results",
|
|
210
|
+
expected: _ve5,
|
|
211
|
+
value: input.results
|
|
212
|
+
}), null === input.advisory || "string" === typeof input.advisory || _report(_exceptionable, {
|
|
213
|
+
path: _path + ".advisory",
|
|
214
|
+
expected: "(null | string)",
|
|
215
|
+
value: input.advisory
|
|
216
|
+
}), _vp2(input, _path, true && _exceptionable), _vp1(input, _path, true && _exceptionable)].every(flag => flag);
|
|
217
|
+
const _vo2 = (input, _path, _exceptionable = true) => [_vp3(input, _path, true && _exceptionable), _vp4(input, _path, true && _exceptionable), "error" === input.severity || "warn" === input.severity || _report(_exceptionable, {
|
|
218
|
+
path: _path + ".severity",
|
|
219
|
+
expected: "(\"error\" | \"warn\")",
|
|
220
|
+
value: input.severity
|
|
221
|
+
}), "fail" === input.verdict || "inconclusive" === input.verdict || "pass" === input.verdict || "unsupported" === input.verdict || _report(_exceptionable, {
|
|
222
|
+
path: _path + ".verdict",
|
|
223
|
+
expected: "(\"fail\" | \"inconclusive\" | \"pass\" | \"unsupported\")",
|
|
224
|
+
value: input.verdict
|
|
225
|
+
}), "string" === typeof input.reason || _report(_exceptionable, {
|
|
226
|
+
path: _path + ".reason",
|
|
227
|
+
expected: "string",
|
|
228
|
+
value: input.reason
|
|
229
|
+
}), (Array.isArray(input.mismatches) || _report(_exceptionable, {
|
|
230
|
+
path: _path + ".mismatches",
|
|
231
|
+
expected: "ReadonlyArray<string>",
|
|
232
|
+
value: input.mismatches
|
|
233
|
+
})) && input.mismatches.map((elem, _index12) => "string" === typeof elem || _report(_exceptionable, {
|
|
234
|
+
path: _path + ".mismatches[" + _index12 + "]",
|
|
235
|
+
expected: "string",
|
|
236
|
+
value: elem
|
|
237
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
238
|
+
path: _path + ".mismatches",
|
|
239
|
+
expected: "ReadonlyArray<string>",
|
|
240
|
+
value: input.mismatches
|
|
241
|
+
}), ("object" === typeof input.evidence && null !== input.evidence || _report(_exceptionable, {
|
|
242
|
+
path: _path + ".evidence",
|
|
243
|
+
expected: _ve6,
|
|
244
|
+
value: input.evidence
|
|
245
|
+
})) && _vo3(input.evidence, _path + ".evidence", true && _exceptionable) || _report(_exceptionable, {
|
|
246
|
+
path: _path + ".evidence",
|
|
247
|
+
expected: _ve6,
|
|
248
|
+
value: input.evidence
|
|
249
|
+
})].every(flag => flag);
|
|
250
|
+
const _vo3 = (input, _path, _exceptionable = true) => ["absent" === input.status || "censored" === input.status || "measured" === input.status || "missing" === input.status || "unknown" === input.status || "unsupported" === input.status || _report(_exceptionable, {
|
|
251
|
+
path: _path + ".status",
|
|
252
|
+
expected: "(\"absent\" | \"censored\" | \"measured\" | \"missing\" | \"unknown\" | \"unsupported\")",
|
|
253
|
+
value: input.status
|
|
254
|
+
}), _vp5(input, _path, true && _exceptionable), null === input.lower || "number" === typeof input.lower || _report(_exceptionable, {
|
|
255
|
+
path: _path + ".lower",
|
|
256
|
+
expected: "(null | number)",
|
|
257
|
+
value: input.lower
|
|
258
|
+
}), null === input.upper || "number" === typeof input.upper || _report(_exceptionable, {
|
|
259
|
+
path: _path + ".upper",
|
|
260
|
+
expected: "(null | number)",
|
|
261
|
+
value: input.upper
|
|
262
|
+
}), "between" === input.operator || "eq" === input.operator || "gt" === input.operator || "gte" === input.operator || "lt" === input.operator || "lte" === input.operator || _report(_exceptionable, {
|
|
263
|
+
path: _path + ".operator",
|
|
264
|
+
expected: "(\"between\" | \"eq\" | \"gt\" | \"gte\" | \"lt\" | \"lte\")",
|
|
265
|
+
value: input.operator
|
|
266
|
+
}), "number" === typeof input.threshold || _report(_exceptionable, {
|
|
267
|
+
path: _path + ".threshold",
|
|
268
|
+
expected: "number",
|
|
269
|
+
value: input.threshold
|
|
270
|
+
}), null === input.upperThreshold || "number" === typeof input.upperThreshold || _report(_exceptionable, {
|
|
271
|
+
path: _path + ".upperThreshold",
|
|
272
|
+
expected: "(null | number)",
|
|
273
|
+
value: input.upperThreshold
|
|
274
|
+
}), "string" === typeof input.unit || _report(_exceptionable, {
|
|
275
|
+
path: _path + ".unit",
|
|
276
|
+
expected: "string",
|
|
277
|
+
value: input.unit
|
|
278
|
+
})].every(flag => flag);
|
|
279
|
+
const _vo4 = (input, _path, _exceptionable = true) => [_vp4(input, _path, true && _exceptionable), _vp5(input, _path, true && _exceptionable), null === input.reason || "string" === typeof input.reason || _report(_exceptionable, {
|
|
280
|
+
path: _path + ".reason",
|
|
281
|
+
expected: "(null | string)",
|
|
282
|
+
value: input.reason
|
|
283
|
+
})].every(flag => flag);
|
|
284
|
+
const _vo5 = (input, _path, _exceptionable = true) => [_vp3(input, _path, true && _exceptionable), "estimate" === input.category || "rule" === input.category || "semantic" === input.category || _report(_exceptionable, {
|
|
285
|
+
path: _path + ".category",
|
|
286
|
+
expected: "(\"estimate\" | \"rule\" | \"semantic\")",
|
|
287
|
+
value: input.category
|
|
288
|
+
}), "error" === input.severity || "info" === input.severity || "warn" === input.severity || _report(_exceptionable, {
|
|
289
|
+
path: _path + ".severity",
|
|
290
|
+
expected: "(\"error\" | \"info\" | \"warn\")",
|
|
291
|
+
value: input.severity
|
|
292
|
+
}), (Array.isArray(input.evidenceRefs) || _report(_exceptionable, {
|
|
293
|
+
path: _path + ".evidenceRefs",
|
|
294
|
+
expected: "ReadonlyArray<string>",
|
|
295
|
+
value: input.evidenceRefs
|
|
296
|
+
})) && input.evidenceRefs.map((elem, _index13) => "string" === typeof elem || _report(_exceptionable, {
|
|
297
|
+
path: _path + ".evidenceRefs[" + _index13 + "]",
|
|
298
|
+
expected: "string",
|
|
299
|
+
value: elem
|
|
300
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
301
|
+
path: _path + ".evidenceRefs",
|
|
302
|
+
expected: "ReadonlyArray<string>",
|
|
303
|
+
value: input.evidenceRefs
|
|
304
|
+
}), (Array.isArray(input.assumptionRefs) || _report(_exceptionable, {
|
|
305
|
+
path: _path + ".assumptionRefs",
|
|
306
|
+
expected: "ReadonlyArray<string>",
|
|
307
|
+
value: input.assumptionRefs
|
|
308
|
+
})) && input.assumptionRefs.map((elem, _index14) => "string" === typeof elem || _report(_exceptionable, {
|
|
309
|
+
path: _path + ".assumptionRefs[" + _index14 + "]",
|
|
310
|
+
expected: "string",
|
|
311
|
+
value: elem
|
|
312
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
313
|
+
path: _path + ".assumptionRefs",
|
|
314
|
+
expected: "ReadonlyArray<string>",
|
|
315
|
+
value: input.assumptionRefs
|
|
316
|
+
}), "rec.metric.estimate-not-measured" === input.recommendationId || "rec.metric.identity-mismatch" === input.recommendationId || "rec.metric.insufficient" === input.recommendationId || "rec.metric.outside-threshold" === input.recommendationId || "rec.metric.unsupported" === input.recommendationId || "rec.metric.within-threshold" === input.recommendationId || _report(_exceptionable, {
|
|
317
|
+
path: _path + ".recommendationId",
|
|
318
|
+
expected: _ve7,
|
|
319
|
+
value: input.recommendationId
|
|
320
|
+
}), "conflict" === input.status || "indeterminate" === input.status || "insufficient" === input.status || "noted" === input.status || "unsupported" === input.status || _report(_exceptionable, {
|
|
321
|
+
path: _path + ".status",
|
|
322
|
+
expected: "(\"conflict\" | \"indeterminate\" | \"insufficient\" | \"noted\" | \"unsupported\")",
|
|
323
|
+
value: input.status
|
|
324
|
+
}), ("object" === typeof input.text && null !== input.text || _report(_exceptionable, {
|
|
325
|
+
path: _path + ".text",
|
|
326
|
+
expected: "Readonly<{ en: string; ko: string; }>",
|
|
327
|
+
value: input.text
|
|
328
|
+
})) && _vo6(input.text, _path + ".text", true && _exceptionable) || _report(_exceptionable, {
|
|
329
|
+
path: _path + ".text",
|
|
330
|
+
expected: "Readonly<{ en: string; ko: string; }>",
|
|
331
|
+
value: input.text
|
|
332
|
+
})].every(flag => flag);
|
|
333
|
+
const _vo6 = (input, _path, _exceptionable = true) => ["string" === typeof input.en || _report(_exceptionable, {
|
|
334
|
+
path: _path + ".en",
|
|
335
|
+
expected: "string",
|
|
336
|
+
value: input.en
|
|
337
|
+
}), "string" === typeof input.ko || _report(_exceptionable, {
|
|
338
|
+
path: _path + ".ko",
|
|
339
|
+
expected: "string",
|
|
340
|
+
value: input.ko
|
|
341
|
+
})].every(flag => flag);
|
|
342
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
343
|
+
let errors;
|
|
344
|
+
let _report;
|
|
345
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
346
|
+
if (false === __is(input)) {
|
|
347
|
+
errors = [];
|
|
348
|
+
_report = _validateReport_1._validateReport(errors);
|
|
349
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
350
|
+
path: _path + "",
|
|
351
|
+
expected: _ve0,
|
|
352
|
+
value: input
|
|
353
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
354
|
+
path: _path + "",
|
|
355
|
+
expected: _ve0,
|
|
356
|
+
value: input
|
|
357
|
+
}))(input, "$input", true);
|
|
358
|
+
const success = 0 === errors.length;
|
|
359
|
+
return success ? {
|
|
360
|
+
success,
|
|
361
|
+
data: input
|
|
362
|
+
} : {
|
|
363
|
+
success,
|
|
364
|
+
errors,
|
|
365
|
+
data: input
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
success: true,
|
|
370
|
+
data: input
|
|
371
|
+
};
|
|
372
|
+
});
|
|
373
|
+
})())(input);
|
|
374
|
+
function buildJudgeJsonSchema() {
|
|
375
|
+
return {
|
|
376
|
+
components: {
|
|
377
|
+
schemas: {
|
|
378
|
+
"ReadonlyschemaVersion1contractidlekit_x2E_judge_x2E_v1algorithmVersionjudge-rules-1providerrulesrubricVersionstringadvisoryDigeststringnumericalReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1---7more---externalProviderfalseestimatedObservationsreadonlyR----x4B4366421365969E": {
|
|
379
|
+
type: "object",
|
|
380
|
+
properties: {
|
|
381
|
+
schemaVersion: {
|
|
382
|
+
"const": 1
|
|
383
|
+
},
|
|
384
|
+
contract: {
|
|
385
|
+
"const": "idlekit.judge.v1"
|
|
386
|
+
},
|
|
387
|
+
algorithmVersion: {
|
|
388
|
+
"const": "judge-rules-1"
|
|
389
|
+
},
|
|
390
|
+
provider: {
|
|
391
|
+
"const": "rules"
|
|
392
|
+
},
|
|
393
|
+
rubricVersion: {
|
|
394
|
+
type: "string"
|
|
395
|
+
},
|
|
396
|
+
advisoryDigest: {
|
|
397
|
+
type: "string"
|
|
398
|
+
},
|
|
399
|
+
numerical: {
|
|
400
|
+
$ref: "#/components/schemas/ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1algorithmVersionbalance-checks-1failOnreadonlyFailOnTokenpassbooleanexitCode02resultsreadonlyReadonlyidstring---5more---evidenceReadonly---advisorystringnullbaselineRewritefalseexternalPr----xF9B05F531712B64E"
|
|
401
|
+
},
|
|
402
|
+
estimatedObservations: {
|
|
403
|
+
type: "array",
|
|
404
|
+
items: {
|
|
405
|
+
$ref: "#/components/schemas/ReadonlymetricIdstringvaluenumbernullreasonstringnull"
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
diagnostics: {
|
|
409
|
+
type: "array",
|
|
410
|
+
items: {
|
|
411
|
+
$ref: "#/components/schemas/ReadonlyidstringcategoryJudgeLayerseverityerrorinfowarnevidenceRefsreadonlystringassumptionRefsreadonlystringrecommendationIdRecommendationIdstatusDiagnosticStatustextReadonly---"
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
externalProvider: {
|
|
415
|
+
"const": false
|
|
416
|
+
},
|
|
417
|
+
baselineRewrite: {
|
|
418
|
+
"const": false
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
required: [
|
|
422
|
+
"schemaVersion",
|
|
423
|
+
"contract",
|
|
424
|
+
"algorithmVersion",
|
|
425
|
+
"provider",
|
|
426
|
+
"rubricVersion",
|
|
427
|
+
"advisoryDigest",
|
|
428
|
+
"numerical",
|
|
429
|
+
"estimatedObservations",
|
|
430
|
+
"diagnostics",
|
|
431
|
+
"externalProvider",
|
|
432
|
+
"baselineRewrite"
|
|
433
|
+
],
|
|
434
|
+
additionalProperties: false
|
|
435
|
+
},
|
|
436
|
+
"ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1algorithmVersionbalance-checks-1failOnreadonlyFailOnTokenpassbooleanexitCode02resultsreadonlyReadonlyidstring---5more---evidenceReadonly---advisorystringnullbaselineRewritefalseexternalPr----xF9B05F531712B64E": {
|
|
437
|
+
type: "object",
|
|
438
|
+
properties: {
|
|
439
|
+
schemaVersion: {
|
|
440
|
+
"const": 1
|
|
441
|
+
},
|
|
442
|
+
contract: {
|
|
443
|
+
"const": "idlekit.balance-checks.v1"
|
|
444
|
+
},
|
|
445
|
+
algorithmVersion: {
|
|
446
|
+
"const": "balance-checks-1"
|
|
447
|
+
},
|
|
448
|
+
failOn: {
|
|
449
|
+
type: "array",
|
|
450
|
+
items: {
|
|
451
|
+
$ref: "#/components/schemas/FailOnToken"
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
pass: {
|
|
455
|
+
type: "boolean"
|
|
456
|
+
},
|
|
457
|
+
exitCode: {
|
|
458
|
+
oneOf: [
|
|
459
|
+
{
|
|
460
|
+
"const": 0
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"const": 2
|
|
464
|
+
}
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
results: {
|
|
468
|
+
type: "array",
|
|
469
|
+
items: {
|
|
470
|
+
$ref: "#/components/schemas/ReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonlystatusabsentObservationStatus---6more---unitstring"
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
advisory: {
|
|
474
|
+
oneOf: [
|
|
475
|
+
{
|
|
476
|
+
type: "null"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
type: "string"
|
|
480
|
+
}
|
|
481
|
+
]
|
|
482
|
+
},
|
|
483
|
+
baselineRewrite: {
|
|
484
|
+
"const": false
|
|
485
|
+
},
|
|
486
|
+
externalProvider: {
|
|
487
|
+
"const": false
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
required: [
|
|
491
|
+
"schemaVersion",
|
|
492
|
+
"contract",
|
|
493
|
+
"algorithmVersion",
|
|
494
|
+
"failOn",
|
|
495
|
+
"pass",
|
|
496
|
+
"exitCode",
|
|
497
|
+
"results",
|
|
498
|
+
"advisory",
|
|
499
|
+
"baselineRewrite",
|
|
500
|
+
"externalProvider"
|
|
501
|
+
],
|
|
502
|
+
additionalProperties: false
|
|
503
|
+
},
|
|
504
|
+
FailOnToken: {
|
|
505
|
+
oneOf: [
|
|
506
|
+
{
|
|
507
|
+
"const": "error"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
"const": "inconclusive"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"const": "unsupported"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"const": "warn"
|
|
517
|
+
}
|
|
518
|
+
]
|
|
519
|
+
},
|
|
520
|
+
"ReadonlyidstringmetricIdstringseverityCheckSeverityverdictCheckVerdictreasonstringmismatchesreadonlystringevidenceReadonlystatusabsentObservationStatus---6more---unitstring": {
|
|
521
|
+
type: "object",
|
|
522
|
+
properties: {
|
|
523
|
+
id: {
|
|
524
|
+
type: "string"
|
|
525
|
+
},
|
|
526
|
+
metricId: {
|
|
527
|
+
type: "string"
|
|
528
|
+
},
|
|
529
|
+
severity: {
|
|
530
|
+
$ref: "#/components/schemas/CheckSeverity"
|
|
531
|
+
},
|
|
532
|
+
verdict: {
|
|
533
|
+
$ref: "#/components/schemas/CheckVerdict"
|
|
534
|
+
},
|
|
535
|
+
reason: {
|
|
536
|
+
type: "string"
|
|
537
|
+
},
|
|
538
|
+
mismatches: {
|
|
539
|
+
type: "array",
|
|
540
|
+
items: {
|
|
541
|
+
type: "string"
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
evidence: {
|
|
545
|
+
$ref: "#/components/schemas/ReadonlystatusabsentObservationStatusvaluenumbernulllowernumbernulluppernumbernulloperatorCheckOperatorthresholdnumberupperThresholdnumbernullunitstring"
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
required: [
|
|
549
|
+
"id",
|
|
550
|
+
"metricId",
|
|
551
|
+
"severity",
|
|
552
|
+
"verdict",
|
|
553
|
+
"reason",
|
|
554
|
+
"mismatches",
|
|
555
|
+
"evidence"
|
|
556
|
+
],
|
|
557
|
+
additionalProperties: false
|
|
558
|
+
},
|
|
559
|
+
CheckSeverity: {
|
|
560
|
+
oneOf: [
|
|
561
|
+
{
|
|
562
|
+
"const": "error"
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
"const": "warn"
|
|
566
|
+
}
|
|
567
|
+
]
|
|
568
|
+
},
|
|
569
|
+
CheckVerdict: {
|
|
570
|
+
oneOf: [
|
|
571
|
+
{
|
|
572
|
+
"const": "fail"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
"const": "inconclusive"
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
"const": "pass"
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"const": "unsupported"
|
|
582
|
+
}
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
ReadonlystatusabsentObservationStatusvaluenumbernulllowernumbernulluppernumbernulloperatorCheckOperatorthresholdnumberupperThresholdnumbernullunitstring: {
|
|
586
|
+
type: "object",
|
|
587
|
+
properties: {
|
|
588
|
+
status: {
|
|
589
|
+
oneOf: [
|
|
590
|
+
{
|
|
591
|
+
"const": "absent"
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
"const": "censored"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"const": "measured"
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
"const": "missing"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
"const": "unknown"
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
"const": "unsupported"
|
|
607
|
+
}
|
|
608
|
+
]
|
|
609
|
+
},
|
|
610
|
+
value: {
|
|
611
|
+
oneOf: [
|
|
612
|
+
{
|
|
613
|
+
type: "null"
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
type: "number"
|
|
617
|
+
}
|
|
618
|
+
]
|
|
619
|
+
},
|
|
620
|
+
lower: {
|
|
621
|
+
oneOf: [
|
|
622
|
+
{
|
|
623
|
+
type: "null"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
type: "number"
|
|
627
|
+
}
|
|
628
|
+
]
|
|
629
|
+
},
|
|
630
|
+
upper: {
|
|
631
|
+
oneOf: [
|
|
632
|
+
{
|
|
633
|
+
type: "null"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
type: "number"
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
},
|
|
640
|
+
operator: {
|
|
641
|
+
$ref: "#/components/schemas/CheckOperator"
|
|
642
|
+
},
|
|
643
|
+
threshold: {
|
|
644
|
+
type: "number"
|
|
645
|
+
},
|
|
646
|
+
upperThreshold: {
|
|
647
|
+
oneOf: [
|
|
648
|
+
{
|
|
649
|
+
type: "null"
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
type: "number"
|
|
653
|
+
}
|
|
654
|
+
]
|
|
655
|
+
},
|
|
656
|
+
unit: {
|
|
657
|
+
type: "string"
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
required: [
|
|
661
|
+
"status",
|
|
662
|
+
"value",
|
|
663
|
+
"lower",
|
|
664
|
+
"upper",
|
|
665
|
+
"operator",
|
|
666
|
+
"threshold",
|
|
667
|
+
"upperThreshold",
|
|
668
|
+
"unit"
|
|
669
|
+
],
|
|
670
|
+
additionalProperties: false
|
|
671
|
+
},
|
|
672
|
+
CheckOperator: {
|
|
673
|
+
oneOf: [
|
|
674
|
+
{
|
|
675
|
+
"const": "between"
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
"const": "eq"
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
"const": "gt"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"const": "gte"
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
"const": "lt"
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
"const": "lte"
|
|
691
|
+
}
|
|
692
|
+
]
|
|
693
|
+
},
|
|
694
|
+
ReadonlymetricIdstringvaluenumbernullreasonstringnull: {
|
|
695
|
+
type: "object",
|
|
696
|
+
properties: {
|
|
697
|
+
metricId: {
|
|
698
|
+
type: "string"
|
|
699
|
+
},
|
|
700
|
+
value: {
|
|
701
|
+
oneOf: [
|
|
702
|
+
{
|
|
703
|
+
type: "null"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
type: "number"
|
|
707
|
+
}
|
|
708
|
+
]
|
|
709
|
+
},
|
|
710
|
+
reason: {
|
|
711
|
+
oneOf: [
|
|
712
|
+
{
|
|
713
|
+
type: "null"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
type: "string"
|
|
717
|
+
}
|
|
718
|
+
]
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
required: [
|
|
722
|
+
"metricId",
|
|
723
|
+
"value",
|
|
724
|
+
"reason"
|
|
725
|
+
],
|
|
726
|
+
additionalProperties: false
|
|
727
|
+
},
|
|
728
|
+
"ReadonlyidstringcategoryJudgeLayerseverityerrorinfowarnevidenceRefsreadonlystringassumptionRefsreadonlystringrecommendationIdRecommendationIdstatusDiagnosticStatustextReadonly---": {
|
|
729
|
+
type: "object",
|
|
730
|
+
properties: {
|
|
731
|
+
id: {
|
|
732
|
+
type: "string"
|
|
733
|
+
},
|
|
734
|
+
category: {
|
|
735
|
+
$ref: "#/components/schemas/JudgeLayer"
|
|
736
|
+
},
|
|
737
|
+
severity: {
|
|
738
|
+
oneOf: [
|
|
739
|
+
{
|
|
740
|
+
"const": "error"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
"const": "info"
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
"const": "warn"
|
|
747
|
+
}
|
|
748
|
+
]
|
|
749
|
+
},
|
|
750
|
+
evidenceRefs: {
|
|
751
|
+
type: "array",
|
|
752
|
+
items: {
|
|
753
|
+
type: "string"
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
assumptionRefs: {
|
|
757
|
+
type: "array",
|
|
758
|
+
items: {
|
|
759
|
+
type: "string"
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
recommendationId: {
|
|
763
|
+
$ref: "#/components/schemas/RecommendationId"
|
|
764
|
+
},
|
|
765
|
+
status: {
|
|
766
|
+
$ref: "#/components/schemas/DiagnosticStatus"
|
|
767
|
+
},
|
|
768
|
+
text: {
|
|
769
|
+
$ref: "#/components/schemas/Readonlyenstringkostring"
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
required: [
|
|
773
|
+
"id",
|
|
774
|
+
"category",
|
|
775
|
+
"severity",
|
|
776
|
+
"evidenceRefs",
|
|
777
|
+
"assumptionRefs",
|
|
778
|
+
"recommendationId",
|
|
779
|
+
"status",
|
|
780
|
+
"text"
|
|
781
|
+
],
|
|
782
|
+
additionalProperties: false
|
|
783
|
+
},
|
|
784
|
+
JudgeLayer: {
|
|
785
|
+
oneOf: [
|
|
786
|
+
{
|
|
787
|
+
"const": "estimate"
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
"const": "rule"
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
"const": "semantic"
|
|
794
|
+
}
|
|
795
|
+
]
|
|
796
|
+
},
|
|
797
|
+
RecommendationId: {
|
|
798
|
+
oneOf: [
|
|
799
|
+
{
|
|
800
|
+
"const": "rec.metric.estimate-not-measured"
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
"const": "rec.metric.identity-mismatch"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"const": "rec.metric.insufficient"
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
"const": "rec.metric.outside-threshold"
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
"const": "rec.metric.unsupported"
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
"const": "rec.metric.within-threshold"
|
|
816
|
+
}
|
|
817
|
+
]
|
|
818
|
+
},
|
|
819
|
+
DiagnosticStatus: {
|
|
820
|
+
oneOf: [
|
|
821
|
+
{
|
|
822
|
+
"const": "conflict"
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
"const": "indeterminate"
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
"const": "insufficient"
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
"const": "noted"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
"const": "unsupported"
|
|
835
|
+
}
|
|
836
|
+
]
|
|
837
|
+
},
|
|
838
|
+
Readonlyenstringkostring: {
|
|
839
|
+
type: "object",
|
|
840
|
+
properties: {
|
|
841
|
+
en: {
|
|
842
|
+
type: "string"
|
|
843
|
+
},
|
|
844
|
+
ko: {
|
|
845
|
+
type: "string"
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
required: [
|
|
849
|
+
"en",
|
|
850
|
+
"ko"
|
|
851
|
+
],
|
|
852
|
+
additionalProperties: false
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
schema: {
|
|
857
|
+
type: "object",
|
|
858
|
+
properties: {
|
|
859
|
+
schemaVersion: {
|
|
860
|
+
"const": 1
|
|
861
|
+
},
|
|
862
|
+
contract: {
|
|
863
|
+
"const": "idlekit.judge.v1"
|
|
864
|
+
},
|
|
865
|
+
algorithmVersion: {
|
|
866
|
+
"const": "judge-rules-1"
|
|
867
|
+
},
|
|
868
|
+
provider: {
|
|
869
|
+
"const": "rules"
|
|
870
|
+
},
|
|
871
|
+
rubricVersion: {
|
|
872
|
+
type: "string"
|
|
873
|
+
},
|
|
874
|
+
advisoryDigest: {
|
|
875
|
+
type: "string"
|
|
876
|
+
},
|
|
877
|
+
numerical: {
|
|
878
|
+
$ref: "#/components/schemas/ReadonlyschemaVersion1contractidlekit_x2E_balance-checks_x2E_v1algorithmVersionbalance-checks-1failOnreadonlyFailOnTokenpassbooleanexitCode02resultsreadonlyReadonlyidstring---5more---evidenceReadonly---advisorystringnullbaselineRewritefalseexternalPr----xF9B05F531712B64E"
|
|
879
|
+
},
|
|
880
|
+
estimatedObservations: {
|
|
881
|
+
type: "array",
|
|
882
|
+
items: {
|
|
883
|
+
$ref: "#/components/schemas/ReadonlymetricIdstringvaluenumbernullreasonstringnull"
|
|
884
|
+
}
|
|
885
|
+
},
|
|
886
|
+
diagnostics: {
|
|
887
|
+
type: "array",
|
|
888
|
+
items: {
|
|
889
|
+
$ref: "#/components/schemas/ReadonlyidstringcategoryJudgeLayerseverityerrorinfowarnevidenceRefsreadonlystringassumptionRefsreadonlystringrecommendationIdRecommendationIdstatusDiagnosticStatustextReadonly---"
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
externalProvider: {
|
|
893
|
+
"const": false
|
|
894
|
+
},
|
|
895
|
+
baselineRewrite: {
|
|
896
|
+
"const": false
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
required: [
|
|
900
|
+
"schemaVersion",
|
|
901
|
+
"contract",
|
|
902
|
+
"algorithmVersion",
|
|
903
|
+
"provider",
|
|
904
|
+
"rubricVersion",
|
|
905
|
+
"advisoryDigest",
|
|
906
|
+
"numerical",
|
|
907
|
+
"estimatedObservations",
|
|
908
|
+
"diagnostics",
|
|
909
|
+
"externalProvider",
|
|
910
|
+
"baselineRewrite"
|
|
911
|
+
],
|
|
912
|
+
additionalProperties: false
|
|
913
|
+
},
|
|
914
|
+
version: "3.1"
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
let judgeJsonSchemaUnit;
|
|
918
|
+
/**
|
|
919
|
+
* @evidence docs/requirements/active/optional-analysis-judge.md#req-pr18-rules-provider The structural schema is OpenAPI 3.1 from typia.
|
|
920
|
+
* @evidenceReview docs/requirements/active/optional-analysis-judge.md#req-pr18-rules-provider #bb58b8a Re-read the section: schema version is 3.1 and the contract id is idlekit.judge.v1.
|
|
921
|
+
*/
|
|
922
|
+
export function judgeJsonSchema() {
|
|
923
|
+
judgeJsonSchemaUnit ??= buildJudgeJsonSchema();
|
|
924
|
+
return judgeJsonSchemaUnit;
|
|
925
|
+
}
|
|
926
|
+
// Equals validation: an unknown rubric field is rejected, not ignored.
|
|
927
|
+
const validateRubric = (input) => (validateRubricValidator ??= (() => {
|
|
928
|
+
const _ve0 = "Readonly<{ schemaVersion: 1; contract: \"idlekit.judge.rubric.v1\"; rubricVersion: string; failOn: readonly FailOnToken[]; rules: readonly Readonly<{ id: string; metricId: string; operator: CheckOperator; ... 13 more ...; recommendationId: RecommendationId; }>[]; }>";
|
|
929
|
+
const _ve1 = "Readonly<{ id: string; metricId: string; operator: CheckOperator; threshold: number; upperThreshold: number | null; unit: string; severity: CheckSeverity; missingPolicy: MissingPolicy; ... 8 more ...; recommendationId: RecommendationId; }>";
|
|
930
|
+
const _ve2 = "ReadonlyArray<Readonly<{ id: string; metricId: string; operator: CheckOperator; threshold: number; upperThreshold: number | null; unit: string; severity: CheckSeverity; missingPolicy: MissingPolicy; ... 8 more ...; recommendationId: RecommendationId; }>>";
|
|
931
|
+
const _ve3 = "(\"rec.metric.estimate-not-measured\" | \"rec.metric.identity-mismatch\" | \"rec.metric.insufficient\" | \"rec.metric.outside-threshold\" | \"rec.metric.unsupported\" | \"rec.metric.within-threshold\")";
|
|
932
|
+
const _io0 = (input, _exceptionable = true) => 1 === input.schemaVersion && "idlekit.judge.rubric.v1" === input.contract && "string" === typeof input.rubricVersion && (Array.isArray(input.failOn) && input.failOn.every((elem, _index1) => "error" === elem || "inconclusive" === elem || "unsupported" === elem || "warn" === elem)) && (Array.isArray(input.rules) && input.rules.every((elem, _index2) => "object" === typeof elem && null !== elem && _io1(elem, true && _exceptionable))) && (5 === Object.keys(input).length || Object.keys(input).every(key => {
|
|
933
|
+
if (["schemaVersion", "contract", "rubricVersion", "failOn", "rules"].some(prop => key === prop))
|
|
934
|
+
return true;
|
|
935
|
+
const value = input[key];
|
|
936
|
+
if (undefined === value)
|
|
937
|
+
return true;
|
|
938
|
+
return false;
|
|
939
|
+
}));
|
|
940
|
+
const _io1 = (input, _exceptionable = true) => "string" === typeof input.id && "string" === typeof input.metricId && ("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 && ("error" === input.severity || "warn" === input.severity) && ("fail" === input.missingPolicy || "inconclusive" === input.missingPolicy || "unsupported" === input.missingPolicy) && "string" === typeof input.definition && "string" === typeof input.method && (null === input.scenarioVersion || "string" === typeof input.scenarioVersion) && (null === input.specVersion || "string" === typeof input.specVersion) && (null === input.engineId || "string" === typeof input.engineId) && (null === input.pluginVersion || "string" === typeof input.pluginVersion) && (null === input.seed || "string" === typeof input.seed) && (null === input.algorithmVersion || "string" === typeof input.algorithmVersion) && ("rec.metric.estimate-not-measured" === input.recommendationId || "rec.metric.identity-mismatch" === input.recommendationId || "rec.metric.insufficient" === input.recommendationId || "rec.metric.outside-threshold" === input.recommendationId || "rec.metric.unsupported" === input.recommendationId || "rec.metric.within-threshold" === input.recommendationId) && (17 === Object.keys(input).length || Object.keys(input).every(key => {
|
|
941
|
+
if (["id", "metricId", "operator", "threshold", "upperThreshold", "unit", "severity", "missingPolicy", "definition", "method", "scenarioVersion", "specVersion", "engineId", "pluginVersion", "seed", "algorithmVersion", "recommendationId"].some(prop => key === prop))
|
|
942
|
+
return true;
|
|
943
|
+
const value = input[key];
|
|
944
|
+
if (undefined === value)
|
|
945
|
+
return true;
|
|
946
|
+
return false;
|
|
947
|
+
}));
|
|
948
|
+
const _vo0 = (input, _path, _exceptionable = true) => [1 === input.schemaVersion || _report(_exceptionable, {
|
|
949
|
+
path: _path + ".schemaVersion",
|
|
950
|
+
expected: "1",
|
|
951
|
+
value: input.schemaVersion
|
|
952
|
+
}), "idlekit.judge.rubric.v1" === input.contract || _report(_exceptionable, {
|
|
953
|
+
path: _path + ".contract",
|
|
954
|
+
expected: "\"idlekit.judge.rubric.v1\"",
|
|
955
|
+
value: input.contract
|
|
956
|
+
}), "string" === typeof input.rubricVersion || _report(_exceptionable, {
|
|
957
|
+
path: _path + ".rubricVersion",
|
|
958
|
+
expected: "string",
|
|
959
|
+
value: input.rubricVersion
|
|
960
|
+
}), (Array.isArray(input.failOn) || _report(_exceptionable, {
|
|
961
|
+
path: _path + ".failOn",
|
|
962
|
+
expected: "ReadonlyArray<FailOnToken>",
|
|
963
|
+
value: input.failOn
|
|
964
|
+
})) && input.failOn.map((elem, _index3) => "error" === elem || "inconclusive" === elem || "unsupported" === elem || "warn" === elem || _report(_exceptionable, {
|
|
965
|
+
path: _path + ".failOn[" + _index3 + "]",
|
|
966
|
+
expected: "(\"error\" | \"inconclusive\" | \"unsupported\" | \"warn\")",
|
|
967
|
+
value: elem
|
|
968
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
969
|
+
path: _path + ".failOn",
|
|
970
|
+
expected: "ReadonlyArray<FailOnToken>",
|
|
971
|
+
value: input.failOn
|
|
972
|
+
}), (Array.isArray(input.rules) || _report(_exceptionable, {
|
|
973
|
+
path: _path + ".rules",
|
|
974
|
+
expected: _ve2,
|
|
975
|
+
value: input.rules
|
|
976
|
+
})) && input.rules.map((elem, _index4) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
977
|
+
path: _path + ".rules[" + _index4 + "]",
|
|
978
|
+
expected: _ve1,
|
|
979
|
+
value: elem
|
|
980
|
+
})) && _vo1(elem, _path + ".rules[" + _index4 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
981
|
+
path: _path + ".rules[" + _index4 + "]",
|
|
982
|
+
expected: _ve1,
|
|
983
|
+
value: elem
|
|
984
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
985
|
+
path: _path + ".rules",
|
|
986
|
+
expected: _ve2,
|
|
987
|
+
value: input.rules
|
|
988
|
+
}), 5 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map(key => {
|
|
989
|
+
if (["schemaVersion", "contract", "rubricVersion", "failOn", "rules"].some(prop => key === prop))
|
|
990
|
+
return true;
|
|
991
|
+
const value = input[key];
|
|
992
|
+
if (undefined === value)
|
|
993
|
+
return true;
|
|
994
|
+
return _report(_exceptionable, {
|
|
995
|
+
path: _path + _accessExpressionAsString_1._accessExpressionAsString(key),
|
|
996
|
+
expected: "undefined",
|
|
997
|
+
value: value,
|
|
998
|
+
description: [
|
|
999
|
+
`The property \`${key}\` is not defined in the object type.`,
|
|
1000
|
+
"",
|
|
1001
|
+
"Please remove the property next time."
|
|
1002
|
+
].join("\n")
|
|
1003
|
+
});
|
|
1004
|
+
}).every(flag => flag))].every(flag => flag);
|
|
1005
|
+
const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
|
|
1006
|
+
path: _path + ".id",
|
|
1007
|
+
expected: "string",
|
|
1008
|
+
value: input.id
|
|
1009
|
+
}), "string" === typeof input.metricId || _report(_exceptionable, {
|
|
1010
|
+
path: _path + ".metricId",
|
|
1011
|
+
expected: "string",
|
|
1012
|
+
value: input.metricId
|
|
1013
|
+
}), "between" === input.operator || "eq" === input.operator || "gt" === input.operator || "gte" === input.operator || "lt" === input.operator || "lte" === input.operator || _report(_exceptionable, {
|
|
1014
|
+
path: _path + ".operator",
|
|
1015
|
+
expected: "(\"between\" | \"eq\" | \"gt\" | \"gte\" | \"lt\" | \"lte\")",
|
|
1016
|
+
value: input.operator
|
|
1017
|
+
}), "number" === typeof input.threshold || _report(_exceptionable, {
|
|
1018
|
+
path: _path + ".threshold",
|
|
1019
|
+
expected: "number",
|
|
1020
|
+
value: input.threshold
|
|
1021
|
+
}), null === input.upperThreshold || "number" === typeof input.upperThreshold || _report(_exceptionable, {
|
|
1022
|
+
path: _path + ".upperThreshold",
|
|
1023
|
+
expected: "(null | number)",
|
|
1024
|
+
value: input.upperThreshold
|
|
1025
|
+
}), "string" === typeof input.unit || _report(_exceptionable, {
|
|
1026
|
+
path: _path + ".unit",
|
|
1027
|
+
expected: "string",
|
|
1028
|
+
value: input.unit
|
|
1029
|
+
}), "error" === input.severity || "warn" === input.severity || _report(_exceptionable, {
|
|
1030
|
+
path: _path + ".severity",
|
|
1031
|
+
expected: "(\"error\" | \"warn\")",
|
|
1032
|
+
value: input.severity
|
|
1033
|
+
}), "fail" === input.missingPolicy || "inconclusive" === input.missingPolicy || "unsupported" === input.missingPolicy || _report(_exceptionable, {
|
|
1034
|
+
path: _path + ".missingPolicy",
|
|
1035
|
+
expected: "(\"fail\" | \"inconclusive\" | \"unsupported\")",
|
|
1036
|
+
value: input.missingPolicy
|
|
1037
|
+
}), "string" === typeof input.definition || _report(_exceptionable, {
|
|
1038
|
+
path: _path + ".definition",
|
|
1039
|
+
expected: "string",
|
|
1040
|
+
value: input.definition
|
|
1041
|
+
}), "string" === typeof input.method || _report(_exceptionable, {
|
|
1042
|
+
path: _path + ".method",
|
|
1043
|
+
expected: "string",
|
|
1044
|
+
value: input.method
|
|
1045
|
+
}), null === input.scenarioVersion || "string" === typeof input.scenarioVersion || _report(_exceptionable, {
|
|
1046
|
+
path: _path + ".scenarioVersion",
|
|
1047
|
+
expected: "(null | string)",
|
|
1048
|
+
value: input.scenarioVersion
|
|
1049
|
+
}), null === input.specVersion || "string" === typeof input.specVersion || _report(_exceptionable, {
|
|
1050
|
+
path: _path + ".specVersion",
|
|
1051
|
+
expected: "(null | string)",
|
|
1052
|
+
value: input.specVersion
|
|
1053
|
+
}), null === input.engineId || "string" === typeof input.engineId || _report(_exceptionable, {
|
|
1054
|
+
path: _path + ".engineId",
|
|
1055
|
+
expected: "(null | string)",
|
|
1056
|
+
value: input.engineId
|
|
1057
|
+
}), null === input.pluginVersion || "string" === typeof input.pluginVersion || _report(_exceptionable, {
|
|
1058
|
+
path: _path + ".pluginVersion",
|
|
1059
|
+
expected: "(null | string)",
|
|
1060
|
+
value: input.pluginVersion
|
|
1061
|
+
}), null === input.seed || "string" === typeof input.seed || _report(_exceptionable, {
|
|
1062
|
+
path: _path + ".seed",
|
|
1063
|
+
expected: "(null | string)",
|
|
1064
|
+
value: input.seed
|
|
1065
|
+
}), null === input.algorithmVersion || "string" === typeof input.algorithmVersion || _report(_exceptionable, {
|
|
1066
|
+
path: _path + ".algorithmVersion",
|
|
1067
|
+
expected: "(null | string)",
|
|
1068
|
+
value: input.algorithmVersion
|
|
1069
|
+
}), "rec.metric.estimate-not-measured" === input.recommendationId || "rec.metric.identity-mismatch" === input.recommendationId || "rec.metric.insufficient" === input.recommendationId || "rec.metric.outside-threshold" === input.recommendationId || "rec.metric.unsupported" === input.recommendationId || "rec.metric.within-threshold" === input.recommendationId || _report(_exceptionable, {
|
|
1070
|
+
path: _path + ".recommendationId",
|
|
1071
|
+
expected: _ve3,
|
|
1072
|
+
value: input.recommendationId
|
|
1073
|
+
}), 17 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).map(key => {
|
|
1074
|
+
if (["id", "metricId", "operator", "threshold", "upperThreshold", "unit", "severity", "missingPolicy", "definition", "method", "scenarioVersion", "specVersion", "engineId", "pluginVersion", "seed", "algorithmVersion", "recommendationId"].some(prop => key === prop))
|
|
1075
|
+
return true;
|
|
1076
|
+
const value = input[key];
|
|
1077
|
+
if (undefined === value)
|
|
1078
|
+
return true;
|
|
1079
|
+
return _report(_exceptionable, {
|
|
1080
|
+
path: _path + _accessExpressionAsString_1._accessExpressionAsString(key),
|
|
1081
|
+
expected: "undefined",
|
|
1082
|
+
value: value,
|
|
1083
|
+
description: [
|
|
1084
|
+
`The property \`${key}\` is not defined in the object type.`,
|
|
1085
|
+
"",
|
|
1086
|
+
"Please remove the property next time."
|
|
1087
|
+
].join("\n")
|
|
1088
|
+
});
|
|
1089
|
+
}).every(flag => flag))].every(flag => flag);
|
|
1090
|
+
const __is = (input, _exceptionable = true) => "object" === typeof input && null !== input && _io0(input, true);
|
|
1091
|
+
let errors;
|
|
1092
|
+
let _report;
|
|
1093
|
+
return _createStandardSchema_1._createStandardSchema(input => {
|
|
1094
|
+
if (false === __is(input)) {
|
|
1095
|
+
errors = [];
|
|
1096
|
+
_report = _validateReport_1._validateReport(errors);
|
|
1097
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
1098
|
+
path: _path + "",
|
|
1099
|
+
expected: _ve0,
|
|
1100
|
+
value: input
|
|
1101
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
1102
|
+
path: _path + "",
|
|
1103
|
+
expected: _ve0,
|
|
1104
|
+
value: input
|
|
1105
|
+
}))(input, "$input", true);
|
|
1106
|
+
const success = 0 === errors.length;
|
|
1107
|
+
return success ? {
|
|
1108
|
+
success,
|
|
1109
|
+
data: input
|
|
1110
|
+
} : {
|
|
1111
|
+
success,
|
|
1112
|
+
errors,
|
|
1113
|
+
data: input
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
return {
|
|
1117
|
+
success: true,
|
|
1118
|
+
data: input
|
|
1119
|
+
};
|
|
1120
|
+
});
|
|
1121
|
+
})())(input);
|
|
1122
|
+
const TEMPLATES = {
|
|
1123
|
+
"rec.metric.within-threshold": {
|
|
1124
|
+
en: "Metric {metricId} meets the rubric threshold. This note does not rewrite the numerical verdict.",
|
|
1125
|
+
ko: "지표 {metricId}가 rubric threshold를 만족한다. 이 문장은 수치 verdict를 바꾸지 않는다.",
|
|
1126
|
+
},
|
|
1127
|
+
"rec.metric.outside-threshold": {
|
|
1128
|
+
en: "Metric {metricId} conflicts with the rubric threshold. The numerical verdict stays as recorded.",
|
|
1129
|
+
ko: "지표 {metricId}가 rubric threshold와 충돌한다. 수치 verdict는 기록된 그대로다.",
|
|
1130
|
+
},
|
|
1131
|
+
"rec.metric.insufficient": {
|
|
1132
|
+
en: "Metric {metricId} has no measured value. The rules provider does not fill one in.",
|
|
1133
|
+
ko: "지표 {metricId}의 측정값이 없다. rules provider는 값을 채우지 않는다.",
|
|
1134
|
+
},
|
|
1135
|
+
"rec.metric.estimate-not-measured": {
|
|
1136
|
+
en: "Metric {metricId} is an estimate. It is not used as a measured numerical fact.",
|
|
1137
|
+
ko: "지표 {metricId}는 추정이다. 측정된 수치 사실로 쓰지 않는다.",
|
|
1138
|
+
},
|
|
1139
|
+
"rec.metric.unsupported": {
|
|
1140
|
+
en: "Metric {metricId} cannot be compared by the rules provider.",
|
|
1141
|
+
ko: "지표 {metricId}는 rules provider가 비교할 수 없다.",
|
|
1142
|
+
},
|
|
1143
|
+
"rec.metric.identity-mismatch": {
|
|
1144
|
+
en: "Metric {metricId} was measured under a different identity than the rubric rule names. It is not compared.",
|
|
1145
|
+
ko: "지표 {metricId}는 rubric rule이 적은 것과 다른 동일성으로 측정되었다. 비교하지 않는다.",
|
|
1146
|
+
},
|
|
1147
|
+
};
|
|
1148
|
+
export function parseJudgeRubric(input) {
|
|
1149
|
+
const validated = validateRubric(input);
|
|
1150
|
+
if (!validated.success) {
|
|
1151
|
+
return { ok: false, issues: validated.errors.map((error) => `${error.path} ${error.expected}`) };
|
|
1152
|
+
}
|
|
1153
|
+
if (validated.data.rules.length === 0)
|
|
1154
|
+
return { ok: false, issues: ["rubric has no rules"] };
|
|
1155
|
+
const nonfinite = nonfiniteThresholds(validated.data);
|
|
1156
|
+
if (nonfinite.length > 0)
|
|
1157
|
+
return { ok: false, issues: nonfinite };
|
|
1158
|
+
return { ok: true, rubric: validated.data };
|
|
1159
|
+
}
|
|
1160
|
+
/** JSON parses 1e400 as Infinity. A nonfinite threshold cannot be compared and would serialize as null. */
|
|
1161
|
+
function nonfiniteThresholds(rubric) {
|
|
1162
|
+
const issues = [];
|
|
1163
|
+
rubric.rules.forEach((rule, index) => {
|
|
1164
|
+
if (!Number.isFinite(rule.threshold))
|
|
1165
|
+
issues.push(`$input.rules[${index}].threshold finite number`);
|
|
1166
|
+
if (rule.upperThreshold !== null && !Number.isFinite(rule.upperThreshold)) {
|
|
1167
|
+
issues.push(`$input.rules[${index}].upperThreshold finite number or null`);
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
return issues;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Judge each group of rules against only its own synthesized observation, so a rule that matches no
|
|
1174
|
+
* observation reports its mismatch against the observation built for it, never against another rule's.
|
|
1175
|
+
* Pass is the conjunction of the groups' passes; a single group is exactly one engine call.
|
|
1176
|
+
*/
|
|
1177
|
+
function evaluateGroups(failOn, groups, checks) {
|
|
1178
|
+
const results = new Array(checks.length);
|
|
1179
|
+
const reports = [...groups.values()].map((group) => {
|
|
1180
|
+
const report = evaluateBalanceChecks({
|
|
1181
|
+
schemaVersion: 1,
|
|
1182
|
+
contract: "idlekit.balance-checks.v1",
|
|
1183
|
+
failOn,
|
|
1184
|
+
checks: group.indices.map((index) => checks[index]),
|
|
1185
|
+
observations: [group.observation],
|
|
1186
|
+
advisory: null,
|
|
1187
|
+
});
|
|
1188
|
+
group.indices.forEach((index, position) => {
|
|
1189
|
+
results[index] = report.results[position];
|
|
1190
|
+
});
|
|
1191
|
+
return report;
|
|
1192
|
+
});
|
|
1193
|
+
const first = reports[0];
|
|
1194
|
+
if (reports.length === 1)
|
|
1195
|
+
return first;
|
|
1196
|
+
const pass = reports.every((report) => report.pass);
|
|
1197
|
+
return { ...first, results, pass, exitCode: pass ? 0 : 2 };
|
|
1198
|
+
}
|
|
1199
|
+
function findReadings(artifact, metricId) {
|
|
1200
|
+
return artifact.metrics.filter((reading) => reading.metricId === metricId);
|
|
1201
|
+
}
|
|
1202
|
+
function isUnavailable(reading) {
|
|
1203
|
+
return reading.reading === "unavailable" || reading.status !== "ok";
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Coverage the artifact itself cannot vouch for. A value observed under an unknown metrics
|
|
1207
|
+
* capability or incomplete coverage is not a measured fact; it stays insufficient.
|
|
1208
|
+
*/
|
|
1209
|
+
function coverageWithheld(artifact) {
|
|
1210
|
+
const coverage = artifact.observationCoverage;
|
|
1211
|
+
const metrics = artifact.capabilities.metrics;
|
|
1212
|
+
return coverage === "incomplete" || coverage === "unknown" || coverage === "disabled" || metrics !== "statically-known";
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* readMetric records a method only on an estimate, so observed and unavailable readings carry none.
|
|
1216
|
+
* A numeric reading records a domain but no unit, and an unavailable amount carries no unit either.
|
|
1217
|
+
* A field the reading does not record cannot disagree with the rule, so the rule's value stands in;
|
|
1218
|
+
* a field the reading records (a method, an amount unit) is compared as is.
|
|
1219
|
+
*/
|
|
1220
|
+
export function toObservation(artifact, reading, rule) {
|
|
1221
|
+
const unavailable = isUnavailable(reading);
|
|
1222
|
+
const unit = reading.amount?.unit ?? rule.unit;
|
|
1223
|
+
const identity = {
|
|
1224
|
+
metricId: reading.metricId,
|
|
1225
|
+
definition: reading.meaning,
|
|
1226
|
+
method: reading.method ?? rule.method,
|
|
1227
|
+
scenarioVersion: "unspecified",
|
|
1228
|
+
specVersion: "unspecified",
|
|
1229
|
+
engineId: "unspecified",
|
|
1230
|
+
pluginVersion: "unspecified",
|
|
1231
|
+
seed: "unspecified",
|
|
1232
|
+
unit,
|
|
1233
|
+
algorithmVersion: artifact.algorithmVersion,
|
|
1234
|
+
};
|
|
1235
|
+
// Availability first: an unavailable reading has no value or bound, so it is missing evidence whatever
|
|
1236
|
+
// its domain or status (a censored status without bounds included). The missing policy decides it.
|
|
1237
|
+
if (unavailable) {
|
|
1238
|
+
return { observation: { identity, status: "missing", value: null, lower: null, upper: null }, estimated: null };
|
|
1239
|
+
}
|
|
1240
|
+
// An available amount, observed or estimated, is not narrowed to a number.
|
|
1241
|
+
if (reading.domain === "amount") {
|
|
1242
|
+
return {
|
|
1243
|
+
observation: { identity, status: "unsupported", value: null, lower: null, upper: null },
|
|
1244
|
+
estimated: null,
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
if (reading.reading === "estimated") {
|
|
1248
|
+
return {
|
|
1249
|
+
observation: { identity, status: "missing", value: null, lower: null, upper: null },
|
|
1250
|
+
estimated: {
|
|
1251
|
+
metricId: reading.metricId,
|
|
1252
|
+
value: typeof reading.value === "number" && Number.isFinite(reading.value) ? reading.value : null,
|
|
1253
|
+
reason: reading.reason ?? null,
|
|
1254
|
+
},
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
if (coverageWithheld(artifact)) {
|
|
1258
|
+
return { observation: { identity, status: "unknown", value: null, lower: null, upper: null }, estimated: null };
|
|
1259
|
+
}
|
|
1260
|
+
if (reading.reading === "observed" &&
|
|
1261
|
+
reading.status === "ok" &&
|
|
1262
|
+
typeof reading.value === "number" &&
|
|
1263
|
+
Number.isFinite(reading.value)) {
|
|
1264
|
+
return {
|
|
1265
|
+
observation: {
|
|
1266
|
+
identity,
|
|
1267
|
+
status: "measured",
|
|
1268
|
+
value: reading.value,
|
|
1269
|
+
lower: reading.value,
|
|
1270
|
+
upper: reading.value,
|
|
1271
|
+
},
|
|
1272
|
+
estimated: null,
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
return {
|
|
1276
|
+
observation: { identity, status: "missing", value: null, lower: null, upper: null },
|
|
1277
|
+
estimated: null,
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
function fillTemplate(id, metricId) {
|
|
1281
|
+
const template = TEMPLATES[id];
|
|
1282
|
+
return {
|
|
1283
|
+
en: template.en.replaceAll("{metricId}", metricId),
|
|
1284
|
+
ko: template.ko.replaceAll("{metricId}", metricId),
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
function outcomeFor(result, estimated, rule) {
|
|
1288
|
+
const verdict = result?.verdict ?? "inconclusive";
|
|
1289
|
+
// A missing, absent, or withheld (unknown) reading is insufficient whatever its missing policy makes
|
|
1290
|
+
// the numerical verdict, and before any identity mismatch is considered.
|
|
1291
|
+
const noReading = !result ||
|
|
1292
|
+
result.evidence.status === "missing" ||
|
|
1293
|
+
result.evidence.status === "absent" ||
|
|
1294
|
+
result.evidence.status === "unknown";
|
|
1295
|
+
if (estimated) {
|
|
1296
|
+
return {
|
|
1297
|
+
recommendationId: "rec.metric.estimate-not-measured",
|
|
1298
|
+
status: "insufficient",
|
|
1299
|
+
category: "estimate",
|
|
1300
|
+
severity: "info",
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
if (noReading) {
|
|
1304
|
+
return {
|
|
1305
|
+
recommendationId: "rec.metric.insufficient",
|
|
1306
|
+
status: "insufficient",
|
|
1307
|
+
category: "semantic",
|
|
1308
|
+
severity: "info",
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
// A reading taken under another identity is not missing data; it is not comparable.
|
|
1312
|
+
if (result.mismatches.length > 0) {
|
|
1313
|
+
return {
|
|
1314
|
+
recommendationId: "rec.metric.identity-mismatch",
|
|
1315
|
+
status: "indeterminate",
|
|
1316
|
+
category: "semantic",
|
|
1317
|
+
severity: "info",
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
if (verdict === "pass") {
|
|
1321
|
+
return {
|
|
1322
|
+
recommendationId: "rec.metric.within-threshold",
|
|
1323
|
+
status: "noted",
|
|
1324
|
+
category: "semantic",
|
|
1325
|
+
severity: "info",
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
if (verdict === "fail") {
|
|
1329
|
+
// The rubric rule selects the recommendation for its own violation.
|
|
1330
|
+
return {
|
|
1331
|
+
recommendationId: rule.recommendationId,
|
|
1332
|
+
status: "conflict",
|
|
1333
|
+
category: "semantic",
|
|
1334
|
+
severity: "warn",
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
if (verdict === "unsupported") {
|
|
1338
|
+
return {
|
|
1339
|
+
recommendationId: "rec.metric.unsupported",
|
|
1340
|
+
status: "unsupported",
|
|
1341
|
+
category: "semantic",
|
|
1342
|
+
severity: "info",
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
return {
|
|
1346
|
+
recommendationId: "rec.metric.insufficient",
|
|
1347
|
+
status: "insufficient",
|
|
1348
|
+
category: "semantic",
|
|
1349
|
+
severity: "info",
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
function checkFor(rule) {
|
|
1353
|
+
return {
|
|
1354
|
+
id: rule.id,
|
|
1355
|
+
metricId: rule.metricId,
|
|
1356
|
+
operator: rule.operator,
|
|
1357
|
+
threshold: rule.threshold,
|
|
1358
|
+
upperThreshold: rule.upperThreshold,
|
|
1359
|
+
unit: rule.unit,
|
|
1360
|
+
severity: rule.severity,
|
|
1361
|
+
missingPolicy: rule.missingPolicy,
|
|
1362
|
+
definition: rule.definition,
|
|
1363
|
+
method: rule.method,
|
|
1364
|
+
scenarioVersion: rule.scenarioVersion,
|
|
1365
|
+
specVersion: rule.specVersion,
|
|
1366
|
+
engineId: rule.engineId,
|
|
1367
|
+
pluginVersion: rule.pluginVersion,
|
|
1368
|
+
seed: rule.seed,
|
|
1369
|
+
algorithmVersion: rule.algorithmVersion,
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
export function judgeArtifact(artifact, rubric) {
|
|
1373
|
+
if (artifact.schemaVersion !== 1)
|
|
1374
|
+
return { ok: false, issues: ["artifact schemaVersion"] };
|
|
1375
|
+
if (artifact.algorithmVersion !== analysisAlgorithmVersion()) {
|
|
1376
|
+
return { ok: false, issues: ["artifact algorithmVersion"] };
|
|
1377
|
+
}
|
|
1378
|
+
if (rubric.rules.length === 0)
|
|
1379
|
+
return { ok: false, issues: ["rubric has no rules"] };
|
|
1380
|
+
// A direct caller can pass Infinity in a typed rubric; it is rejected here as in parseJudgeRubric.
|
|
1381
|
+
const nonfinite = nonfiniteThresholds(rubric);
|
|
1382
|
+
if (nonfinite.length > 0)
|
|
1383
|
+
return { ok: false, issues: nonfinite };
|
|
1384
|
+
// A structurally valid artifact can still break its cross-field contract; that artifact is not judged.
|
|
1385
|
+
const semantic = validateAnalysisSemantics(artifact);
|
|
1386
|
+
if (semantic.length > 0) {
|
|
1387
|
+
return { ok: false, issues: semantic.map((issue) => `artifact ${issue.path} ${issue.message}`) };
|
|
1388
|
+
}
|
|
1389
|
+
const issues = [];
|
|
1390
|
+
const groups = new Map();
|
|
1391
|
+
const estimatedObservations = [];
|
|
1392
|
+
const prepared = [];
|
|
1393
|
+
for (const rule of rubric.rules) {
|
|
1394
|
+
const readings = findReadings(artifact, rule.metricId);
|
|
1395
|
+
const reading = readings[0];
|
|
1396
|
+
if (!reading) {
|
|
1397
|
+
issues.push(`missing evidenceRef metric:${rule.metricId}`);
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
// An evidence ref must name exactly one reading, so reading order cannot change a verdict.
|
|
1401
|
+
if (readings.length > 1) {
|
|
1402
|
+
issues.push(`ambiguous evidenceRef metric:${rule.metricId} matches ${readings.length} readings`);
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
const mapped = toObservation(artifact, reading, rule);
|
|
1406
|
+
// One observation per distinct identity. Rules whose stand-in method and unit agree share it and
|
|
1407
|
+
// are judged together; rules that differ get their own observation and their own group.
|
|
1408
|
+
const key = JSON.stringify([reading.metricId, mapped.observation.identity.method, mapped.observation.identity.unit]);
|
|
1409
|
+
const group = groups.get(key) ?? { observation: mapped.observation, indices: [] };
|
|
1410
|
+
group.indices.push(prepared.length);
|
|
1411
|
+
groups.set(key, group);
|
|
1412
|
+
if (mapped.estimated && !estimatedObservations.some((item) => item.metricId === reading.metricId)) {
|
|
1413
|
+
estimatedObservations.push(mapped.estimated);
|
|
1414
|
+
}
|
|
1415
|
+
prepared.push({ rule, estimated: mapped.estimated, ref: `metric:${rule.metricId}` });
|
|
1416
|
+
}
|
|
1417
|
+
if (issues.length > 0)
|
|
1418
|
+
return { ok: false, issues };
|
|
1419
|
+
const checks = prepared.map(({ rule }) => checkFor(rule));
|
|
1420
|
+
const numerical = evaluateGroups(rubric.failOn, groups, checks);
|
|
1421
|
+
const assumptionRefs = artifact.assumptions.filter((item) => item.length > 0);
|
|
1422
|
+
const diagnostics = prepared.map((item, index) => {
|
|
1423
|
+
const outcome = outcomeFor(numerical.results[index], item.estimated !== null, item.rule);
|
|
1424
|
+
return {
|
|
1425
|
+
id: item.rule.id,
|
|
1426
|
+
category: outcome.category,
|
|
1427
|
+
severity: outcome.severity,
|
|
1428
|
+
evidenceRefs: [item.ref],
|
|
1429
|
+
assumptionRefs,
|
|
1430
|
+
recommendationId: outcome.recommendationId,
|
|
1431
|
+
status: outcome.status,
|
|
1432
|
+
text: fillTemplate(outcome.recommendationId, item.rule.metricId),
|
|
1433
|
+
};
|
|
1434
|
+
});
|
|
1435
|
+
const advisoryDigest = `rules:${rubric.rubricVersion}:${diagnostics.map((item) => item.recommendationId).join(",")}`;
|
|
1436
|
+
const report = {
|
|
1437
|
+
schemaVersion: 1,
|
|
1438
|
+
contract: "idlekit.judge.v1",
|
|
1439
|
+
algorithmVersion: JUDGE_ALGORITHM_VERSION,
|
|
1440
|
+
provider: "rules",
|
|
1441
|
+
rubricVersion: rubric.rubricVersion,
|
|
1442
|
+
advisoryDigest,
|
|
1443
|
+
numerical,
|
|
1444
|
+
estimatedObservations,
|
|
1445
|
+
diagnostics,
|
|
1446
|
+
externalProvider: false,
|
|
1447
|
+
baselineRewrite: false,
|
|
1448
|
+
};
|
|
1449
|
+
return { ok: true, report };
|
|
1450
|
+
}
|
|
1451
|
+
//# sourceMappingURL=judge.js.map
|