@riddledc/riddle-proof 0.8.76 → 0.8.78
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 +74 -5
- package/dist/advanced/index.d.cts +1 -1
- package/dist/advanced/index.d.ts +1 -1
- package/dist/advanced/proof-run-engine.d.cts +1 -1
- package/dist/advanced/proof-run-engine.d.ts +1 -1
- package/dist/change-proof.cjs +991 -7
- package/dist/change-proof.d.cts +157 -1
- package/dist/change-proof.d.ts +157 -1
- package/dist/change-proof.js +25 -3
- package/dist/{chunk-B2DP2LET.js → chunk-5IFZSUPF.js} +52 -13
- package/dist/chunk-6VFS2JFR.js +886 -0
- package/dist/{chunk-CWRIXP5H.js → chunk-7N6X54WG.js} +181 -17
- package/dist/{chunk-GG2D3MFZ.js → chunk-FCSJZBC5.js} +26 -1
- package/dist/{chunk-AK2EPEVO.js → chunk-HSGZV2NK.js} +221 -63
- package/dist/chunk-MEVVL4TI.js +258 -0
- package/dist/{chunk-UE4I7RTI.js → chunk-RQPCKRKT.js} +1 -1
- package/dist/cli/index.js +7 -6
- package/dist/cli.cjs +1678 -361
- package/dist/cli.js +7 -6
- package/dist/index.cjs +1242 -42
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +46 -10
- package/dist/pr-comment.cjs +481 -17
- package/dist/pr-comment.d.cts +6 -1
- package/dist/pr-comment.d.ts +6 -1
- package/dist/pr-comment.js +6 -1
- package/dist/profile/index.cjs +26 -1
- package/dist/profile/index.js +1 -1
- package/dist/profile-suggestions.js +2 -2
- package/dist/profile.cjs +26 -1
- package/dist/profile.d.cts +7 -0
- package/dist/profile.d.ts +7 -0
- package/dist/profile.js +1 -1
- package/dist/{proof-run-engine-MiKZt9oY.d.ts → proof-run-engine-CsQshTUX.d.ts} +3 -3
- package/dist/{proof-run-engine-Baiv6l3A.d.cts → proof-run-engine-DmUqh7Cw.d.cts} +3 -3
- package/dist/proof-run-engine.d.cts +1 -1
- package/dist/proof-run-engine.d.ts +1 -1
- package/dist/receipts.cjs +286 -0
- package/dist/receipts.d.cts +115 -0
- package/dist/receipts.d.ts +115 -0
- package/dist/receipts.js +15 -0
- package/dist/riddle-client.cjs +98 -13
- package/dist/riddle-client.d.cts +18 -5
- package/dist/riddle-client.d.ts +18 -5
- package/dist/riddle-client.js +4 -1
- package/dist/runtime/index.cjs +98 -13
- package/dist/runtime/index.d.cts +5 -1
- package/dist/runtime/index.d.ts +5 -1
- package/dist/runtime/index.js +4 -1
- package/dist/runtime/riddle-client.cjs +98 -13
- package/dist/runtime/riddle-client.d.cts +5 -1
- package/dist/runtime/riddle-client.d.ts +5 -1
- package/dist/runtime/riddle-client.js +4 -1
- package/package.json +7 -2
- package/dist/chunk-6S7DZWVC.js +0 -167
package/dist/chunk-6S7DZWVC.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
// src/change-proof.ts
|
|
2
|
-
var RIDDLE_PROOF_CHANGE_CONTRACT_VERSION = "riddle-proof.change-contract.v1";
|
|
3
|
-
var RIDDLE_PROOF_CHANGE_RESULT_VERSION = "riddle-proof.change-result.v1";
|
|
4
|
-
var DEFAULT_BEFORE_STATUSES = ["passed", "product_regression"];
|
|
5
|
-
var DEFAULT_AFTER_STATUSES = ["passed"];
|
|
6
|
-
var DEFAULT_PROFILE_STATUS_TRANSITION_BEFORE = ["product_regression"];
|
|
7
|
-
var DEFAULT_PROFILE_STATUS_TRANSITION_AFTER = ["passed"];
|
|
8
|
-
var DEFAULT_CHECK_STATUS_TRANSITION_BEFORE = ["failed"];
|
|
9
|
-
var DEFAULT_CHECK_STATUS_TRANSITION_AFTER = ["passed"];
|
|
10
|
-
function listValue(value, fallback) {
|
|
11
|
-
if (Array.isArray(value)) return value;
|
|
12
|
-
if (value === void 0) return fallback;
|
|
13
|
-
return [value];
|
|
14
|
-
}
|
|
15
|
-
function includesValue(allowed, observed) {
|
|
16
|
-
return observed !== void 0 && allowed.includes(observed);
|
|
17
|
-
}
|
|
18
|
-
function groupResult(side, contract, result) {
|
|
19
|
-
const fallback = side === "before" ? DEFAULT_BEFORE_STATUSES : DEFAULT_AFTER_STATUSES;
|
|
20
|
-
const requiredStatus = listValue(contract?.required_status, fallback);
|
|
21
|
-
const label = contract?.label || side;
|
|
22
|
-
if (!result) {
|
|
23
|
-
return {
|
|
24
|
-
side,
|
|
25
|
-
label,
|
|
26
|
-
ok: false,
|
|
27
|
-
status: "missing",
|
|
28
|
-
required_status: requiredStatus,
|
|
29
|
-
message: `${label} profile result is missing.`
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const ok = includesValue(requiredStatus, result.status);
|
|
33
|
-
return {
|
|
34
|
-
side,
|
|
35
|
-
label,
|
|
36
|
-
ok,
|
|
37
|
-
profile_name: result.profile_name,
|
|
38
|
-
status: result.status,
|
|
39
|
-
required_status: requiredStatus,
|
|
40
|
-
summary: result.summary,
|
|
41
|
-
message: ok ? void 0 : `${label} profile status ${result.status} did not match required status ${requiredStatus.join(", ")}.`
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function findCheck(result, delta) {
|
|
45
|
-
return result.checks.find((check) => {
|
|
46
|
-
if (delta.check_label && check.label !== delta.check_label) return false;
|
|
47
|
-
if (delta.check_type && check.type !== delta.check_type) return false;
|
|
48
|
-
return Boolean(delta.check_label || delta.check_type);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function profileStatusTransitionResult(delta, before, after) {
|
|
52
|
-
const label = delta.label || "profile-status-transition";
|
|
53
|
-
if (!before || !after) {
|
|
54
|
-
return {
|
|
55
|
-
type: delta.type,
|
|
56
|
-
label,
|
|
57
|
-
status: "proof_insufficient",
|
|
58
|
-
before_observed: before?.status,
|
|
59
|
-
after_observed: after?.status,
|
|
60
|
-
message: `${label} needs both before and after profile results.`
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const beforeAllowed = listValue(delta.before_status, DEFAULT_PROFILE_STATUS_TRANSITION_BEFORE);
|
|
64
|
-
const afterAllowed = listValue(delta.after_status, DEFAULT_PROFILE_STATUS_TRANSITION_AFTER);
|
|
65
|
-
const passed = includesValue(beforeAllowed, before.status) && includesValue(afterAllowed, after.status);
|
|
66
|
-
return {
|
|
67
|
-
type: delta.type,
|
|
68
|
-
label,
|
|
69
|
-
status: passed ? "passed" : "failed",
|
|
70
|
-
before_observed: before.status,
|
|
71
|
-
after_observed: after.status,
|
|
72
|
-
message: passed ? void 0 : `${label} expected before ${beforeAllowed.join(", ")} and after ${afterAllowed.join(", ")}, got ${before.status} -> ${after.status}.`
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function checkStatusTransitionResult(delta, before, after) {
|
|
76
|
-
const label = delta.label || delta.check_label || delta.check_type || "check-status-transition";
|
|
77
|
-
if (!delta.check_label && !delta.check_type) {
|
|
78
|
-
return {
|
|
79
|
-
type: delta.type,
|
|
80
|
-
label,
|
|
81
|
-
status: "configuration_error",
|
|
82
|
-
message: `${label} needs check_label or check_type.`
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
if (!before || !after) {
|
|
86
|
-
return {
|
|
87
|
-
type: delta.type,
|
|
88
|
-
label,
|
|
89
|
-
status: "proof_insufficient",
|
|
90
|
-
before_observed: before?.status,
|
|
91
|
-
after_observed: after?.status,
|
|
92
|
-
message: `${label} needs both before and after profile results.`
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
const beforeCheck = findCheck(before, delta);
|
|
96
|
-
const afterCheck = findCheck(after, delta);
|
|
97
|
-
if (!beforeCheck || !afterCheck) {
|
|
98
|
-
return {
|
|
99
|
-
type: delta.type,
|
|
100
|
-
label,
|
|
101
|
-
status: "proof_insufficient",
|
|
102
|
-
before_observed: beforeCheck?.status,
|
|
103
|
-
after_observed: afterCheck?.status,
|
|
104
|
-
message: `${label} was not present in ${!beforeCheck && !afterCheck ? "before or after" : !beforeCheck ? "before" : "after"} profile checks.`
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
const beforeAllowed = listValue(delta.before_status, DEFAULT_CHECK_STATUS_TRANSITION_BEFORE);
|
|
108
|
-
const afterAllowed = listValue(delta.after_status, DEFAULT_CHECK_STATUS_TRANSITION_AFTER);
|
|
109
|
-
const passed = includesValue(beforeAllowed, beforeCheck.status) && includesValue(afterAllowed, afterCheck.status);
|
|
110
|
-
return {
|
|
111
|
-
type: delta.type,
|
|
112
|
-
label,
|
|
113
|
-
status: passed ? "passed" : "failed",
|
|
114
|
-
before_observed: beforeCheck.status,
|
|
115
|
-
after_observed: afterCheck.status,
|
|
116
|
-
message: passed ? void 0 : `${label} expected before ${beforeAllowed.join(", ")} and after ${afterAllowed.join(", ")}, got ${beforeCheck.status} -> ${afterCheck.status}.`
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function assessDelta(delta, before, after) {
|
|
120
|
-
if (delta.type === "profile_status_transition") {
|
|
121
|
-
return profileStatusTransitionResult(delta, before, after);
|
|
122
|
-
}
|
|
123
|
-
return checkStatusTransitionResult(delta, before, after);
|
|
124
|
-
}
|
|
125
|
-
function collapsedChangeStatus(groups, deltas) {
|
|
126
|
-
const groupResults = [groups.before, groups.after];
|
|
127
|
-
if (groupResults.some((group) => group.status === "environment_blocked")) return "environment_blocked";
|
|
128
|
-
if (groupResults.some((group) => group.status === "configuration_error")) return "configuration_error";
|
|
129
|
-
if (deltas.some((delta) => delta.status === "configuration_error")) return "configuration_error";
|
|
130
|
-
if (groupResults.some((group) => group.status === "needs_human_review")) return "needs_human_review";
|
|
131
|
-
if (groupResults.some((group) => group.status === "missing" || group.status === "proof_insufficient")) return "proof_insufficient";
|
|
132
|
-
if (!deltas.length || deltas.some((delta) => delta.status === "proof_insufficient")) return "proof_insufficient";
|
|
133
|
-
if (groupResults.some((group) => !group.ok)) return "product_regression";
|
|
134
|
-
if (deltas.some((delta) => delta.status === "failed")) return "product_regression";
|
|
135
|
-
return "passed";
|
|
136
|
-
}
|
|
137
|
-
function changeSummary(name, status, deltas) {
|
|
138
|
-
if (status === "passed") return `${name} passed ${deltas.length} change delta(s).`;
|
|
139
|
-
if (status === "environment_blocked") return `${name} could not compare reliable evidence because an environment was blocked.`;
|
|
140
|
-
if (status === "configuration_error") return `${name} has an invalid change proof contract.`;
|
|
141
|
-
if (status === "needs_human_review") return `${name} needs human review before the change proof can pass.`;
|
|
142
|
-
if (status === "proof_insufficient") return `${name} did not produce enough before/after evidence for a change proof.`;
|
|
143
|
-
return `${name} failed ${deltas.filter((delta) => delta.status === "failed").length} change delta(s).`;
|
|
144
|
-
}
|
|
145
|
-
function assessRiddleProofChange(contract, input) {
|
|
146
|
-
const groups = {
|
|
147
|
-
before: groupResult("before", contract.before, input.before_result),
|
|
148
|
-
after: groupResult("after", contract.after, input.after_result)
|
|
149
|
-
};
|
|
150
|
-
const deltas = (contract.deltas || []).map((delta) => assessDelta(delta, input.before_result, input.after_result));
|
|
151
|
-
const status = collapsedChangeStatus(groups, deltas);
|
|
152
|
-
return {
|
|
153
|
-
version: RIDDLE_PROOF_CHANGE_RESULT_VERSION,
|
|
154
|
-
contract_name: contract.name,
|
|
155
|
-
status,
|
|
156
|
-
groups,
|
|
157
|
-
deltas,
|
|
158
|
-
summary: changeSummary(contract.name, status, deltas),
|
|
159
|
-
metadata: contract.metadata
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export {
|
|
164
|
-
RIDDLE_PROOF_CHANGE_CONTRACT_VERSION,
|
|
165
|
-
RIDDLE_PROOF_CHANGE_RESULT_VERSION,
|
|
166
|
-
assessRiddleProofChange
|
|
167
|
-
};
|