@riddledc/riddle-proof 0.7.155 → 0.7.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +63 -40
- package/dist/cli.js +63 -40
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -14858,7 +14858,7 @@ function runProfileSplitViewportsOption(options) {
|
|
|
14858
14858
|
return optionBoolean(options, "splitViewports") ?? false;
|
|
14859
14859
|
}
|
|
14860
14860
|
var DEFAULT_PROFILE_UNSUBMITTED_RETRY_TIMEOUT_MS = 9e4;
|
|
14861
|
-
var DEFAULT_PROFILE_UNSUBMITTED_RETRIES =
|
|
14861
|
+
var DEFAULT_PROFILE_UNSUBMITTED_RETRIES = 2;
|
|
14862
14862
|
function optionNumber(options, ...keys) {
|
|
14863
14863
|
for (const key of keys) {
|
|
14864
14864
|
const value = optionString(options, key);
|
|
@@ -15948,45 +15948,55 @@ function riddleArtifactsPayloadStatus(payload) {
|
|
|
15948
15948
|
}
|
|
15949
15949
|
async function recoverProfileResultFromRiddleArtifacts(profile, input) {
|
|
15950
15950
|
if (input.poll.poll?.timed_out !== true) return void 0;
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15954
|
-
|
|
15955
|
-
|
|
15956
|
-
|
|
15957
|
-
|
|
15958
|
-
|
|
15959
|
-
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15951
|
+
const attempts = Math.max(1, Math.floor(input.attempts ?? 3));
|
|
15952
|
+
const intervalMs = Math.max(0, Math.floor(input.intervalMs ?? 0));
|
|
15953
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
15954
|
+
let artifactPayload;
|
|
15955
|
+
try {
|
|
15956
|
+
artifactPayload = await input.client.requestJson(`/v1/jobs/${input.jobId}/artifacts`);
|
|
15957
|
+
} catch {
|
|
15958
|
+
artifactPayload = {};
|
|
15959
|
+
}
|
|
15960
|
+
const artifacts = collectRiddleProfileArtifactRefs(artifactPayload);
|
|
15961
|
+
if (artifacts.length) {
|
|
15962
|
+
const artifactStatus = riddleArtifactsPayloadStatus(artifactPayload);
|
|
15963
|
+
const terminal = artifactStatus ? isTerminalRiddleJobStatus(artifactStatus) : true;
|
|
15964
|
+
const recoveredPoll = input.poll.poll ? {
|
|
15965
|
+
...input.poll.poll,
|
|
15966
|
+
status: artifactStatus ?? input.poll.poll.status,
|
|
15967
|
+
terminal
|
|
15968
|
+
} : void 0;
|
|
15969
|
+
const artifactResult = await profileResultFromRiddleArtifacts(profile, artifacts, [artifactPayload, input.poll.job]);
|
|
15970
|
+
if (artifactResult) {
|
|
15971
|
+
return withRiddleMetadata(artifactResult, {
|
|
15972
|
+
job_id: input.jobId,
|
|
15973
|
+
status: artifactStatus ?? input.poll.status,
|
|
15974
|
+
terminal,
|
|
15975
|
+
poll: recoveredPoll,
|
|
15976
|
+
artifacts,
|
|
15977
|
+
artifactRecovery: true
|
|
15978
|
+
});
|
|
15979
|
+
}
|
|
15980
|
+
if (terminal) {
|
|
15981
|
+
return createRiddleProofProfileInsufficientResult({
|
|
15982
|
+
profile,
|
|
15983
|
+
runner: input.runner,
|
|
15984
|
+
error: `Riddle job ${input.jobId} timed out in status ${input.poll.status || "unknown"}, but artifacts were recovered without a proof result.`,
|
|
15985
|
+
riddle: {
|
|
15986
|
+
...riddleMetadataFromPoll(input.jobId, input.poll),
|
|
15987
|
+
status: artifactStatus ?? input.poll.status,
|
|
15988
|
+
terminal,
|
|
15989
|
+
artifact_recovery: true
|
|
15990
|
+
},
|
|
15991
|
+
artifacts
|
|
15992
|
+
});
|
|
15993
|
+
}
|
|
15994
|
+
}
|
|
15995
|
+
if (attempt + 1 < attempts && intervalMs > 0) {
|
|
15996
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
15997
|
+
}
|
|
15976
15998
|
}
|
|
15977
|
-
|
|
15978
|
-
return createRiddleProofProfileInsufficientResult({
|
|
15979
|
-
profile,
|
|
15980
|
-
runner: input.runner,
|
|
15981
|
-
error: `Riddle job ${input.jobId} timed out in status ${input.poll.status || "unknown"}, but artifacts were recovered without a proof result.`,
|
|
15982
|
-
riddle: {
|
|
15983
|
-
...riddleMetadataFromPoll(input.jobId, input.poll),
|
|
15984
|
-
status: artifactStatus ?? input.poll.status,
|
|
15985
|
-
terminal,
|
|
15986
|
-
artifact_recovery: true
|
|
15987
|
-
},
|
|
15988
|
-
artifacts
|
|
15989
|
-
});
|
|
15999
|
+
return void 0;
|
|
15990
16000
|
}
|
|
15991
16001
|
function riddleMetadataFromPoll(jobId, poll) {
|
|
15992
16002
|
return {
|
|
@@ -16215,6 +16225,17 @@ async function runSingleRiddleProfileForCli(profile, options, input) {
|
|
|
16215
16225
|
}
|
|
16216
16226
|
poll = await client.pollJob(jobId, pollOptions);
|
|
16217
16227
|
if (attempt < retryLimit && shouldRetryUnsubmittedRiddleJob(poll)) {
|
|
16228
|
+
const recoveredResult = await recoverProfileResultFromRiddleArtifacts(profile, {
|
|
16229
|
+
client,
|
|
16230
|
+
runner,
|
|
16231
|
+
jobId,
|
|
16232
|
+
poll,
|
|
16233
|
+
attempts: 3,
|
|
16234
|
+
intervalMs: Math.min(2e3, Math.max(0, poll.poll?.interval_ms ?? 0))
|
|
16235
|
+
});
|
|
16236
|
+
if (recoveredResult) {
|
|
16237
|
+
return recoveredResult;
|
|
16238
|
+
}
|
|
16218
16239
|
staleJobIds.push(jobId);
|
|
16219
16240
|
if (options.quiet !== true) {
|
|
16220
16241
|
process.stderr.write(`[riddle-poll] ${jobId} stayed unsubmitted for ${formatPollDuration(poll.poll?.pre_submission_elapsed_ms)}; retrying hosted run ${attempt + 1}/${retryLimit}
|
|
@@ -16234,7 +16255,9 @@ async function runSingleRiddleProfileForCli(profile, options, input) {
|
|
|
16234
16255
|
client,
|
|
16235
16256
|
runner,
|
|
16236
16257
|
jobId,
|
|
16237
|
-
poll
|
|
16258
|
+
poll,
|
|
16259
|
+
attempts: 3,
|
|
16260
|
+
intervalMs: Math.min(2e3, Math.max(0, poll.poll?.interval_ms ?? 0))
|
|
16238
16261
|
});
|
|
16239
16262
|
if (recoveredResult) {
|
|
16240
16263
|
return withRiddleMetadata(recoveredResult, { retryCount, staleJobIds });
|
package/dist/cli.js
CHANGED
|
@@ -109,7 +109,7 @@ function runProfileSplitViewportsOption(options) {
|
|
|
109
109
|
return optionBoolean(options, "splitViewports") ?? false;
|
|
110
110
|
}
|
|
111
111
|
var DEFAULT_PROFILE_UNSUBMITTED_RETRY_TIMEOUT_MS = 9e4;
|
|
112
|
-
var DEFAULT_PROFILE_UNSUBMITTED_RETRIES =
|
|
112
|
+
var DEFAULT_PROFILE_UNSUBMITTED_RETRIES = 2;
|
|
113
113
|
function optionNumber(options, ...keys) {
|
|
114
114
|
for (const key of keys) {
|
|
115
115
|
const value = optionString(options, key);
|
|
@@ -1199,45 +1199,55 @@ function riddleArtifactsPayloadStatus(payload) {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
async function recoverProfileResultFromRiddleArtifacts(profile, input) {
|
|
1201
1201
|
if (input.poll.poll?.timed_out !== true) return void 0;
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1202
|
+
const attempts = Math.max(1, Math.floor(input.attempts ?? 3));
|
|
1203
|
+
const intervalMs = Math.max(0, Math.floor(input.intervalMs ?? 0));
|
|
1204
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
1205
|
+
let artifactPayload;
|
|
1206
|
+
try {
|
|
1207
|
+
artifactPayload = await input.client.requestJson(`/v1/jobs/${input.jobId}/artifacts`);
|
|
1208
|
+
} catch {
|
|
1209
|
+
artifactPayload = {};
|
|
1210
|
+
}
|
|
1211
|
+
const artifacts = collectRiddleProfileArtifactRefs(artifactPayload);
|
|
1212
|
+
if (artifacts.length) {
|
|
1213
|
+
const artifactStatus = riddleArtifactsPayloadStatus(artifactPayload);
|
|
1214
|
+
const terminal = artifactStatus ? isTerminalRiddleJobStatus(artifactStatus) : true;
|
|
1215
|
+
const recoveredPoll = input.poll.poll ? {
|
|
1216
|
+
...input.poll.poll,
|
|
1217
|
+
status: artifactStatus ?? input.poll.poll.status,
|
|
1218
|
+
terminal
|
|
1219
|
+
} : void 0;
|
|
1220
|
+
const artifactResult = await profileResultFromRiddleArtifacts(profile, artifacts, [artifactPayload, input.poll.job]);
|
|
1221
|
+
if (artifactResult) {
|
|
1222
|
+
return withRiddleMetadata(artifactResult, {
|
|
1223
|
+
job_id: input.jobId,
|
|
1224
|
+
status: artifactStatus ?? input.poll.status,
|
|
1225
|
+
terminal,
|
|
1226
|
+
poll: recoveredPoll,
|
|
1227
|
+
artifacts,
|
|
1228
|
+
artifactRecovery: true
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
if (terminal) {
|
|
1232
|
+
return createRiddleProofProfileInsufficientResult({
|
|
1233
|
+
profile,
|
|
1234
|
+
runner: input.runner,
|
|
1235
|
+
error: `Riddle job ${input.jobId} timed out in status ${input.poll.status || "unknown"}, but artifacts were recovered without a proof result.`,
|
|
1236
|
+
riddle: {
|
|
1237
|
+
...riddleMetadataFromPoll(input.jobId, input.poll),
|
|
1238
|
+
status: artifactStatus ?? input.poll.status,
|
|
1239
|
+
terminal,
|
|
1240
|
+
artifact_recovery: true
|
|
1241
|
+
},
|
|
1242
|
+
artifacts
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
if (attempt + 1 < attempts && intervalMs > 0) {
|
|
1247
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
1248
|
+
}
|
|
1227
1249
|
}
|
|
1228
|
-
|
|
1229
|
-
return createRiddleProofProfileInsufficientResult({
|
|
1230
|
-
profile,
|
|
1231
|
-
runner: input.runner,
|
|
1232
|
-
error: `Riddle job ${input.jobId} timed out in status ${input.poll.status || "unknown"}, but artifacts were recovered without a proof result.`,
|
|
1233
|
-
riddle: {
|
|
1234
|
-
...riddleMetadataFromPoll(input.jobId, input.poll),
|
|
1235
|
-
status: artifactStatus ?? input.poll.status,
|
|
1236
|
-
terminal,
|
|
1237
|
-
artifact_recovery: true
|
|
1238
|
-
},
|
|
1239
|
-
artifacts
|
|
1240
|
-
});
|
|
1250
|
+
return void 0;
|
|
1241
1251
|
}
|
|
1242
1252
|
function riddleMetadataFromPoll(jobId, poll) {
|
|
1243
1253
|
return {
|
|
@@ -1466,6 +1476,17 @@ async function runSingleRiddleProfileForCli(profile, options, input) {
|
|
|
1466
1476
|
}
|
|
1467
1477
|
poll = await client.pollJob(jobId, pollOptions);
|
|
1468
1478
|
if (attempt < retryLimit && shouldRetryUnsubmittedRiddleJob(poll)) {
|
|
1479
|
+
const recoveredResult = await recoverProfileResultFromRiddleArtifacts(profile, {
|
|
1480
|
+
client,
|
|
1481
|
+
runner,
|
|
1482
|
+
jobId,
|
|
1483
|
+
poll,
|
|
1484
|
+
attempts: 3,
|
|
1485
|
+
intervalMs: Math.min(2e3, Math.max(0, poll.poll?.interval_ms ?? 0))
|
|
1486
|
+
});
|
|
1487
|
+
if (recoveredResult) {
|
|
1488
|
+
return recoveredResult;
|
|
1489
|
+
}
|
|
1469
1490
|
staleJobIds.push(jobId);
|
|
1470
1491
|
if (options.quiet !== true) {
|
|
1471
1492
|
process.stderr.write(`[riddle-poll] ${jobId} stayed unsubmitted for ${formatPollDuration(poll.poll?.pre_submission_elapsed_ms)}; retrying hosted run ${attempt + 1}/${retryLimit}
|
|
@@ -1485,7 +1506,9 @@ async function runSingleRiddleProfileForCli(profile, options, input) {
|
|
|
1485
1506
|
client,
|
|
1486
1507
|
runner,
|
|
1487
1508
|
jobId,
|
|
1488
|
-
poll
|
|
1509
|
+
poll,
|
|
1510
|
+
attempts: 3,
|
|
1511
|
+
intervalMs: Math.min(2e3, Math.max(0, poll.poll?.interval_ms ?? 0))
|
|
1489
1512
|
});
|
|
1490
1513
|
if (recoveredResult) {
|
|
1491
1514
|
return withRiddleMetadata(recoveredResult, { retryCount, staleJobIds });
|