@riddledc/riddle-proof 0.8.76 → 0.8.77

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.
@@ -79,6 +79,33 @@ function collectProfileArtifacts(result) {
79
79
  }
80
80
  return artifacts;
81
81
  }
82
+ function collectChangeReceiptArtifacts(result) {
83
+ const artifacts = [];
84
+ const seen = /* @__PURE__ */ new Set();
85
+ const collectSide = (sideName, side) => {
86
+ const candidates = [
87
+ ...asArray(side.screenshots),
88
+ ...asArray(side.artifacts)
89
+ ];
90
+ for (const [index, item] of candidates.entries()) {
91
+ const artifact = asRecord(item);
92
+ const url = stringValue(artifact.url) || stringValue(artifact.path);
93
+ if (!url || seen.has(url)) continue;
94
+ seen.add(url);
95
+ const fallbackName = `${sideName}-artifact-${index + 1}`;
96
+ const name = `${sideName}/${artifactDisplayName(artifact.name, fallbackName)}`;
97
+ artifacts.push({
98
+ name,
99
+ url,
100
+ kind: artifactKind(name, url),
101
+ size_bytes: numberValue(artifact.size_bytes) ?? numberValue(artifact.size)
102
+ });
103
+ }
104
+ };
105
+ collectSide("before", asRecord(result.before));
106
+ collectSide("after", asRecord(result.after));
107
+ return artifacts;
108
+ }
82
109
  function mergeArtifacts(...artifactLists) {
83
110
  const artifacts = [];
84
111
  const seen = /* @__PURE__ */ new Set();
@@ -134,6 +161,32 @@ function profilePageSummaries(result, counts) {
134
161
  failed: counts.failed
135
162
  }];
136
163
  }
164
+ function changeReceiptCheckCounts(result) {
165
+ const deltas = asArray(result.deltas);
166
+ if (!deltas.length) return void 0;
167
+ let passed = 0;
168
+ let failed = 0;
169
+ for (const item of deltas) {
170
+ const status = stringValue(asRecord(item).status);
171
+ if (status === "passed") passed += 1;
172
+ if (status === "failed" || status === "proof_insufficient" || status === "configuration_error") failed += 1;
173
+ }
174
+ return { passed, failed };
175
+ }
176
+ function changeReceiptPageSummaries(result) {
177
+ const pages = [];
178
+ for (const sideName of ["before", "after"]) {
179
+ const side = asRecord(result[sideName]);
180
+ if (!Object.keys(side).length) continue;
181
+ const checks = asRecord(side.checks);
182
+ pages.push({
183
+ route: firstStringValue(side.source, side.profile_name) || sideName,
184
+ passed: numberValue(checks.passed) ?? 0,
185
+ failed: numberValue(checks.failed) ?? 0
186
+ });
187
+ }
188
+ return pages;
189
+ }
137
190
  function summarizeExplicitChecks(value) {
138
191
  let passed = 0;
139
192
  let failed = 0;
@@ -189,11 +242,20 @@ function isProfileResult(result) {
189
242
  const version = stringValue(result.version);
190
243
  return version === "riddle-proof.profile-result.v1" || version === "riddle-proof.profile-compact-result.v1";
191
244
  }
245
+ function isChangeReceiptResult(result) {
246
+ return stringValue(result.version) === "riddle-proof.change-receipt.v1";
247
+ }
248
+ function isChangeResult(result) {
249
+ const version = stringValue(result.version);
250
+ return version === "riddle-proof.change-result.v1" || version === "riddle-proof.change-compact-result.v1";
251
+ }
192
252
  function summarizeRiddleProofPrComment(input) {
193
253
  const runResponse = asRecord(input.runResponse);
194
254
  const result = asRecord(input.result);
195
255
  const proofResult = asRecord(runResponse.proofResult);
196
256
  const profileResult = isProfileResult(result);
257
+ const changeReceiptResult = isChangeReceiptResult(result);
258
+ const changeResult = changeReceiptResult || isChangeResult(result);
197
259
  const profileRiddle = asRecord(result.riddle);
198
260
  const preview = asRecord(runResponse.preview);
199
261
  const resultRunCard = asRecord(result.run_card);
@@ -202,15 +264,18 @@ function summarizeRiddleProofPrComment(input) {
202
264
  const resultRaw = asRecord(result.raw);
203
265
  const rawDetails = asRecord(resultRaw.details);
204
266
  const profileChecks = profileResult ? profileCheckCounts(result) : void 0;
267
+ const changeChecks = changeResult ? changeReceiptCheckCounts(result) : void 0;
205
268
  const artifacts = mergeArtifacts(
206
269
  collectArtifacts(runResponse),
207
- profileResult ? collectProfileArtifacts(result) : []
270
+ profileResult ? collectProfileArtifacts(result) : [],
271
+ changeReceiptResult ? collectChangeReceiptArtifacts(result) : []
208
272
  );
209
- const pages = profileResult ? profilePageSummaries(result, profileChecks) : pageSummaries(result);
273
+ const pages = changeReceiptResult ? changeReceiptPageSummaries(result) : profileResult ? profilePageSummaries(result, profileChecks) : pageSummaries(result);
210
274
  const checkSource = { ...result };
211
275
  delete checkSource.ok;
212
276
  const nestedChecks = summarizeExplicitChecks(checkSource);
213
- const ok = booleanValue(result.ok) ?? booleanValue(runResponse.ok) ?? null;
277
+ const resultStatus = firstStringValue(result.status, stopCondition.status);
278
+ const ok = changeResult ? resultStatus === "passed" : booleanValue(result.ok) ?? booleanValue(runResponse.ok) ?? null;
214
279
  const checkpointSummary = checkpointSummaryFrom(
215
280
  result.checkpoint_summary,
216
281
  stopCondition.checkpoint_summary,
@@ -220,7 +285,7 @@ function summarizeRiddleProofPrComment(input) {
220
285
  );
221
286
  const publicState = summarizeRiddleProofPublicState({
222
287
  ...result,
223
- status: firstStringValue(result.status, stopCondition.status),
288
+ status: resultStatus,
224
289
  checkpoint_summary: checkpointSummary || result.checkpoint_summary
225
290
  });
226
291
  const mergeRecommendation = riddleProofPublicStateMergeRecommendation(
@@ -230,7 +295,7 @@ function summarizeRiddleProofPrComment(input) {
230
295
  return {
231
296
  ok,
232
297
  status: firstStringValue(proofResult.status, profileRiddle.status),
233
- result_status: publicState.status,
298
+ result_status: changeResult ? resultStatus : publicState.status,
234
299
  job_id: firstStringValue(proofResult.job_id, profileRiddle.job_id),
235
300
  duration_ms: numberValue(proofResult.duration_ms) ?? numberValue(profileRiddle.elapsed_ms),
236
301
  proof_url: stringValue(runResponse.proofUrl),
@@ -244,11 +309,11 @@ function summarizeRiddleProofPrComment(input) {
244
309
  merge_ready: publicState.merge_ready,
245
310
  sync_allowed: publicState.sync_allowed,
246
311
  proof_decision: firstStringValue(result.proof_decision, stopCondition.proof_decision, resultRaw.proof_decision),
247
- merge_recommendation: mergeRecommendation,
312
+ merge_recommendation: changeReceiptResult && resultStatus ? stringValue(result.verdict) : mergeRecommendation,
248
313
  checkpoint_summary: checkpointSummary,
249
314
  public_state: publicState,
250
- passed_checks: profileChecks?.passed ?? nestedChecks.passed,
251
- failed_checks: profileChecks?.failed ?? nestedChecks.failed,
315
+ passed_checks: changeChecks?.passed ?? profileChecks?.passed ?? nestedChecks.passed,
316
+ failed_checks: changeChecks?.failed ?? profileChecks?.failed ?? nestedChecks.failed,
252
317
  pages,
253
318
  artifacts,
254
319
  primary_image: selectPrimaryImage(artifacts)
package/dist/cli/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import "../chunk-AK2EPEVO.js";
1
+ import "../chunk-H25IDX76.js";
2
2
  import "../chunk-B2DP2LET.js";
3
3
  import "../chunk-JFQXAJH2.js";
4
- import "../chunk-CWRIXP5H.js";
4
+ import "../chunk-IY4W6STC.js";
5
5
  import "../chunk-UE4I7RTI.js";
6
6
  import "../chunk-GG2D3MFZ.js";
7
- import "../chunk-6S7DZWVC.js";
7
+ import "../chunk-BILL3UC2.js";
8
8
  import "../chunk-KXLEN4SA.js";
9
9
  import "../chunk-WLUMLHII.js";
10
10
  import "../chunk-CGJX7LJO.js";