@riddledc/riddle-proof 0.7.156 → 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 CHANGED
@@ -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
- let artifactPayload;
15952
- try {
15953
- artifactPayload = await input.client.requestJson(`/v1/jobs/${input.jobId}/artifacts`);
15954
- } catch {
15955
- return void 0;
15956
- }
15957
- const artifacts = collectRiddleProfileArtifactRefs(artifactPayload);
15958
- if (!artifacts.length) return void 0;
15959
- const artifactStatus = riddleArtifactsPayloadStatus(artifactPayload);
15960
- const terminal = artifactStatus ? isTerminalRiddleJobStatus(artifactStatus) : true;
15961
- const recoveredPoll = input.poll.poll ? {
15962
- ...input.poll.poll,
15963
- status: artifactStatus ?? input.poll.poll.status,
15964
- terminal
15965
- } : void 0;
15966
- const artifactResult = await profileResultFromRiddleArtifacts(profile, artifacts, [artifactPayload, input.poll.job]);
15967
- if (artifactResult) {
15968
- return withRiddleMetadata(artifactResult, {
15969
- job_id: input.jobId,
15970
- status: artifactStatus ?? input.poll.status,
15971
- terminal,
15972
- poll: recoveredPoll,
15973
- artifacts,
15974
- artifactRecovery: true
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
- if (!terminal) return void 0;
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
@@ -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
- let artifactPayload;
1203
- try {
1204
- artifactPayload = await input.client.requestJson(`/v1/jobs/${input.jobId}/artifacts`);
1205
- } catch {
1206
- return void 0;
1207
- }
1208
- const artifacts = collectRiddleProfileArtifactRefs(artifactPayload);
1209
- if (!artifacts.length) return void 0;
1210
- const artifactStatus = riddleArtifactsPayloadStatus(artifactPayload);
1211
- const terminal = artifactStatus ? isTerminalRiddleJobStatus(artifactStatus) : true;
1212
- const recoveredPoll = input.poll.poll ? {
1213
- ...input.poll.poll,
1214
- status: artifactStatus ?? input.poll.poll.status,
1215
- terminal
1216
- } : void 0;
1217
- const artifactResult = await profileResultFromRiddleArtifacts(profile, artifacts, [artifactPayload, input.poll.job]);
1218
- if (artifactResult) {
1219
- return withRiddleMetadata(artifactResult, {
1220
- job_id: input.jobId,
1221
- status: artifactStatus ?? input.poll.status,
1222
- terminal,
1223
- poll: recoveredPoll,
1224
- artifacts,
1225
- artifactRecovery: true
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
- if (!terminal) return void 0;
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 });
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "recon" | "author" | "ship" | "implement" | "verify" | "setup" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.156",
3
+ "version": "0.7.157",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",