@riddledc/riddle-proof 0.7.171 → 0.7.173

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
@@ -7006,6 +7006,7 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
7006
7006
  "fill",
7007
7007
  "set_input_value",
7008
7008
  "set_range_value",
7009
+ "deterministic_runtime",
7009
7010
  "canvas_signature",
7010
7011
  "assert_text_visible",
7011
7012
  "assert_text_absent",
@@ -7468,6 +7469,23 @@ function profileSetupWindowEvalReceipts(results) {
7468
7469
  return receipt;
7469
7470
  });
7470
7471
  }
7472
+ function profileSetupDeterministicRuntimeReceipts(results) {
7473
+ return results.filter((result) => profileSetupResultAction(result) === "deterministic_runtime").map((result) => ({
7474
+ ordinal: result.ordinal ?? null,
7475
+ ok: result.ok !== false,
7476
+ random_enabled: result.random_enabled ?? null,
7477
+ random_queue_added: result.random_queue_added ?? null,
7478
+ random_queue_length: result.random_queue_length ?? null,
7479
+ random_queue_mode: result.random_queue_mode ?? null,
7480
+ random_underflow_count: result.random_underflow_count ?? null,
7481
+ clock_enabled: result.clock_enabled ?? null,
7482
+ previous_now: result.previous_now ?? null,
7483
+ now: result.now ?? null,
7484
+ advance_ms: result.advance_ms ?? null,
7485
+ restored: result.restored ?? null,
7486
+ reason: result.reason ?? result.error ?? null
7487
+ }));
7488
+ }
7471
7489
  function profileSetupReturnSummaryFields(result) {
7472
7490
  const input = result.return_summary_fields;
7473
7491
  if (!Array.isArray(input)) return [];
@@ -7571,21 +7589,28 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
7571
7589
  }
7572
7590
  const warnings = [];
7573
7591
  for (const group of groups.values()) {
7574
- const hashes = new Set(group.receipts.map((receipt) => receipt.hash));
7575
- const labels = [...new Set(group.receipts.map((receipt) => receipt.label))];
7576
- if (group.receipts.length < 2 || labels.length < 2 || hashes.size !== 1) continue;
7577
- const visibleLabels = labels.slice(0, 8);
7578
- warnings.push({
7579
- selector: group.selector,
7580
- frame_selector: group.frame_selector ?? null,
7581
- hash: group.receipts[0].hash,
7582
- count: group.receipts.length,
7583
- label_count: labels.length,
7584
- labels: visibleLabels,
7585
- omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
7586
- ordinals: group.receipts.map((receipt) => receipt.ordinal).filter((value) => value !== void 0).slice(0, 12),
7587
- reason: "stable_canvas_signature_hash"
7588
- });
7592
+ const receiptsByHash = /* @__PURE__ */ new Map();
7593
+ for (const receipt of group.receipts) {
7594
+ const hashReceipts = receiptsByHash.get(receipt.hash) || [];
7595
+ hashReceipts.push(receipt);
7596
+ receiptsByHash.set(receipt.hash, hashReceipts);
7597
+ }
7598
+ for (const [hash, receipts] of receiptsByHash.entries()) {
7599
+ const labels = [...new Set(receipts.map((receipt) => receipt.label))];
7600
+ if (receipts.length < 2 || labels.length < 2) continue;
7601
+ const visibleLabels = labels.slice(0, 8);
7602
+ warnings.push({
7603
+ selector: group.selector,
7604
+ frame_selector: group.frame_selector ?? null,
7605
+ hash,
7606
+ count: receipts.length,
7607
+ label_count: labels.length,
7608
+ labels: visibleLabels,
7609
+ omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
7610
+ ordinals: receipts.map((receipt) => receipt.ordinal).filter((value) => value !== void 0).slice(0, 12),
7611
+ reason: "stable_canvas_signature_hash"
7612
+ });
7613
+ }
7589
7614
  }
7590
7615
  return warnings;
7591
7616
  }
@@ -7682,6 +7707,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7682
7707
  const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
7683
7708
  const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
7684
7709
  const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
7710
+ const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
7711
+ const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
7685
7712
  const rangeValueReceipts = profileSetupRangeValueReceipts(results);
7686
7713
  const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
7687
7714
  const dragReceipts = profileSetupDragReceipts(results);
@@ -7741,6 +7768,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
7741
7768
  window_eval_captured_total: windowEvalCapturedTotal,
7742
7769
  window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
7743
7770
  window_eval: sampledWindowEvalReceipts,
7771
+ deterministic_runtime_total: deterministicRuntimeReceipts.length,
7772
+ deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
7773
+ deterministic_runtime: sampledDeterministicRuntimeReceipts,
7744
7774
  set_range_value_total: rangeValueReceipts.length,
7745
7775
  set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
7746
7776
  set_range_value: sampledRangeValueReceipts,
@@ -7803,7 +7833,7 @@ function isSupportedCheckType(value) {
7803
7833
  }
7804
7834
  function normalizeSetupActionType(value, index) {
7805
7835
  const normalizedInput = String(value || "").trim().replace(/-/g, "_");
7806
- const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
7836
+ const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "set_slider_value" || normalizedInput === "slider_value" || normalizedInput === "set_slider" || normalizedInput === "set_range" || normalizedInput === "range_value" || normalizedInput === "range_input" || normalizedInput === "set_range_input" ? "set_range_value" : normalizedInput === "deterministic_runtime" || normalizedInput === "mock_runtime" || normalizedInput === "mock_random" || normalizedInput === "mock_random_queue" || normalizedInput === "seed_random_queue" || normalizedInput === "set_random_queue" || normalizedInput === "mock_clock" || normalizedInput === "set_mock_clock" || normalizedInput === "set_runtime_determinism" || normalizedInput === "runtime_determinism" ? "deterministic_runtime" : normalizedInput === "canvas_hash" || normalizedInput === "capture_canvas_hash" || normalizedInput === "capture_canvas_signature" || normalizedInput === "canvas_state_signature" ? "canvas_signature" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
7807
7837
  if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
7808
7838
  return normalized;
7809
7839
  }
@@ -7922,6 +7952,39 @@ function normalizeSetupActionScreenshotFullPage(input, type, index) {
7922
7952
  }
7923
7953
  return values[0];
7924
7954
  }
7955
+ function normalizeSetupActionRandomQueue(input, index) {
7956
+ const rawQueue = valueFromOwn(
7957
+ input,
7958
+ "random_queue",
7959
+ "randomQueue",
7960
+ "random_values",
7961
+ "randomValues",
7962
+ "random_sequence",
7963
+ "randomSequence",
7964
+ "math_random",
7965
+ "mathRandom"
7966
+ );
7967
+ if (rawQueue === void 0) return void 0;
7968
+ if (!Array.isArray(rawQueue) || rawQueue.length === 0) {
7969
+ throw new Error(`target.setup_actions[${index}].random_queue must be a non-empty array of numbers from 0 inclusive to 1 exclusive.`);
7970
+ }
7971
+ return rawQueue.map((item, queueIndex) => {
7972
+ const value = numberValue(item);
7973
+ if (value === void 0 || value < 0 || value >= 1) {
7974
+ throw new Error(`target.setup_actions[${index}].random_queue[${queueIndex}] must be a finite number from 0 inclusive to 1 exclusive.`);
7975
+ }
7976
+ return value;
7977
+ });
7978
+ }
7979
+ function normalizeSetupActionNonNegativeNumber(input, index, outputKey, ...keys) {
7980
+ const rawValue = valueFromOwn(input, ...keys);
7981
+ if (rawValue === void 0) return void 0;
7982
+ const value = numberValue(rawValue);
7983
+ if (value === void 0 || value < 0) {
7984
+ throw new Error(`target.setup_actions[${index}].${outputKey} must be a finite non-negative number.`);
7985
+ }
7986
+ return value;
7987
+ }
7925
7988
  function normalizeSetupAction(input, index) {
7926
7989
  if (!isRecord(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
7927
7990
  const type = normalizeSetupActionType(stringValue2(input.type), index);
@@ -7982,6 +8045,14 @@ function normalizeSetupAction(input, index) {
7982
8045
  if ((type === "fill" || type === "set_input_value" || type === "set_range_value") && value === void 0 && !hasJsonValue) {
7983
8046
  throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
7984
8047
  }
8048
+ const randomQueue = type === "deterministic_runtime" ? normalizeSetupActionRandomQueue(input, index) : void 0;
8049
+ const deterministicNow = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "now", "now", "date_now", "dateNow", "mock_now", "mockNow", "clock", "timestamp", "time_ms", "timeMs") : void 0;
8050
+ const deterministicAdvanceMs = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "advance_ms", "advance_ms", "advanceMs", "tick_ms", "tickMs", "add_ms", "addMs") : void 0;
8051
+ const deterministicAppend = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "append", "append_random", "appendRandom")) === true;
8052
+ const deterministicRestore = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "restore", "reset", "restore_originals", "restoreOriginals")) === true;
8053
+ if (type === "deterministic_runtime" && randomQueue === void 0 && deterministicNow === void 0 && deterministicAdvanceMs === void 0 && !deterministicRestore) {
8054
+ throw new Error(`target.setup_actions[${index}] deterministic_runtime requires random_queue, now, advance_ms, or restore.`);
8055
+ }
7985
8056
  const key = stringValue2(input.key);
7986
8057
  let dialogAccept;
7987
8058
  if (type === "dialog_response") {
@@ -8089,6 +8160,11 @@ function normalizeSetupAction(input, index) {
8089
8160
  key,
8090
8161
  value,
8091
8162
  value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
8163
+ random_queue: randomQueue,
8164
+ now: deterministicNow,
8165
+ advance_ms: deterministicAdvanceMs,
8166
+ append: deterministicAppend || void 0,
8167
+ restore: deterministicRestore || void 0,
8092
8168
  label: stringFromOwn(input, "label", "name", "screenshot_label", "screenshotLabel"),
8093
8169
  script,
8094
8170
  path: path7,
@@ -11149,6 +11225,25 @@ function profileSetupWindowEvalReceipts(results) {
11149
11225
  return receipt;
11150
11226
  });
11151
11227
  }
11228
+ function profileSetupDeterministicRuntimeReceipts(results) {
11229
+ return (results || [])
11230
+ .filter((result) => result && profileSetupResultAction(result) === "deterministic_runtime")
11231
+ .map((result) => ({
11232
+ ordinal: result.ordinal ?? null,
11233
+ ok: result.ok !== false,
11234
+ random_enabled: result.random_enabled ?? null,
11235
+ random_queue_added: result.random_queue_added ?? null,
11236
+ random_queue_length: result.random_queue_length ?? null,
11237
+ random_queue_mode: result.random_queue_mode ?? null,
11238
+ random_underflow_count: result.random_underflow_count ?? null,
11239
+ clock_enabled: result.clock_enabled ?? null,
11240
+ previous_now: result.previous_now ?? null,
11241
+ now: result.now ?? null,
11242
+ advance_ms: result.advance_ms ?? null,
11243
+ restored: result.restored ?? null,
11244
+ reason: result.reason || result.error || null,
11245
+ }));
11246
+ }
11152
11247
  function profileSetupReturnSummaryFields(result) {
11153
11248
  const input = result && result.return_summary_fields;
11154
11249
  if (!Array.isArray(input)) return [];
@@ -11262,24 +11357,31 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
11262
11357
  }
11263
11358
  const warnings = [];
11264
11359
  for (const group of groups.values()) {
11265
- const hashes = new Set(group.receipts.map((receipt) => receipt.hash));
11266
- const labels = [...new Set(group.receipts.map((receipt) => receipt.label))];
11267
- if (group.receipts.length < 2 || labels.length < 2 || hashes.size !== 1) continue;
11268
- const visibleLabels = labels.slice(0, 8);
11269
- warnings.push({
11270
- selector: group.selector,
11271
- frame_selector: group.frame_selector || null,
11272
- hash: group.receipts[0].hash,
11273
- count: group.receipts.length,
11274
- label_count: labels.length,
11275
- labels: visibleLabels,
11276
- omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
11277
- ordinals: group.receipts
11278
- .map((receipt) => receipt.ordinal)
11279
- .filter((value) => value !== undefined)
11280
- .slice(0, 12),
11281
- reason: "stable_canvas_signature_hash",
11282
- });
11360
+ const receiptsByHash = new Map();
11361
+ for (const receipt of group.receipts) {
11362
+ const hashReceipts = receiptsByHash.get(receipt.hash) || [];
11363
+ hashReceipts.push(receipt);
11364
+ receiptsByHash.set(receipt.hash, hashReceipts);
11365
+ }
11366
+ for (const [hash, receipts] of receiptsByHash.entries()) {
11367
+ const labels = [...new Set(receipts.map((receipt) => receipt.label))];
11368
+ if (receipts.length < 2 || labels.length < 2) continue;
11369
+ const visibleLabels = labels.slice(0, 8);
11370
+ warnings.push({
11371
+ selector: group.selector,
11372
+ frame_selector: group.frame_selector || null,
11373
+ hash,
11374
+ count: receipts.length,
11375
+ label_count: labels.length,
11376
+ labels: visibleLabels,
11377
+ omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
11378
+ ordinals: receipts
11379
+ .map((receipt) => receipt.ordinal)
11380
+ .filter((value) => value !== undefined)
11381
+ .slice(0, 12),
11382
+ reason: "stable_canvas_signature_hash",
11383
+ });
11384
+ }
11283
11385
  }
11284
11386
  return warnings;
11285
11387
  }
@@ -11392,6 +11494,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
11392
11494
  const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
11393
11495
  const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
11394
11496
  const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
11497
+ const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
11498
+ const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
11395
11499
  const rangeValueReceipts = profileSetupRangeValueReceipts(results);
11396
11500
  const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
11397
11501
  const dragReceipts = profileSetupDragReceipts(results);
@@ -11461,6 +11565,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
11461
11565
  window_eval_captured_total: windowEvalCapturedTotal,
11462
11566
  window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
11463
11567
  window_eval: sampledWindowEvalReceipts,
11568
+ deterministic_runtime_total: deterministicRuntimeReceipts.length,
11569
+ deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
11570
+ deterministic_runtime: sampledDeterministicRuntimeReceipts,
11464
11571
  set_range_value_total: rangeValueReceipts.length,
11465
11572
  set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
11466
11573
  set_range_value: sampledRangeValueReceipts,
@@ -13082,6 +13189,111 @@ async function executeSetupAction(action, ordinal, viewport) {
13082
13189
  }
13083
13190
  return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
13084
13191
  }
13192
+ if (type === "deterministic_runtime") {
13193
+ const scope = await setupActionScope(action, timeout);
13194
+ if (!scope.ok) return setupScopeFailure(base, scope);
13195
+ const randomQueue = Array.isArray(action.random_queue)
13196
+ ? action.random_queue
13197
+ : Array.isArray(action.randomQueue)
13198
+ ? action.randomQueue
13199
+ : null;
13200
+ const now = setupFiniteNumber(action.now ?? action.date_now ?? action.dateNow ?? action.mock_now ?? action.mockNow ?? action.clock ?? action.timestamp ?? action.time_ms ?? action.timeMs);
13201
+ const advanceMs = setupFiniteNumber(action.advance_ms ?? action.advanceMs ?? action.tick_ms ?? action.tickMs ?? action.add_ms ?? action.addMs);
13202
+ const append = action.append === true || action.append_random === true || action.appendRandom === true;
13203
+ const restore = action.restore === true || action.reset === true || action.restore_originals === true || action.restoreOriginals === true;
13204
+ const runtimeResult = await scope.context.evaluate((payload) => {
13205
+ const root = window;
13206
+ const stateKey = "__RIDDLE_PROOF_DETERMINISTIC_RUNTIME__";
13207
+ const state = root[stateKey] && typeof root[stateKey] === "object" && !Array.isArray(root[stateKey])
13208
+ ? root[stateKey]
13209
+ : {};
13210
+ root[stateKey] = state;
13211
+ if (typeof state.originalRandom !== "function") state.originalRandom = Math.random;
13212
+ if (typeof state.originalDateNow !== "function") state.originalDateNow = Date.now;
13213
+ const previousNow = typeof state.now === "number" && Number.isFinite(state.now)
13214
+ ? state.now
13215
+ : Date.now === state.originalDateNow
13216
+ ? null
13217
+ : Date.now();
13218
+ if (payload.restore) {
13219
+ Math.random = state.originalRandom;
13220
+ Date.now = state.originalDateNow;
13221
+ delete root[stateKey];
13222
+ return {
13223
+ ok: true,
13224
+ restored: true,
13225
+ random_enabled: false,
13226
+ random_queue_added: 0,
13227
+ random_queue_length: 0,
13228
+ random_queue_mode: null,
13229
+ random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
13230
+ clock_enabled: false,
13231
+ previous_now: previousNow,
13232
+ now: null,
13233
+ advance_ms: null,
13234
+ };
13235
+ }
13236
+ let randomQueueAdded = null;
13237
+ let randomQueueMode = null;
13238
+ if (Array.isArray(payload.random_queue)) {
13239
+ const queue = payload.random_queue.filter((value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value < 1);
13240
+ const existing = Array.isArray(state.randomQueue) ? state.randomQueue : [];
13241
+ state.randomQueue = payload.append ? existing.concat(queue) : queue.slice();
13242
+ randomQueueAdded = queue.length;
13243
+ randomQueueMode = payload.append ? "append" : "replace";
13244
+ Math.random = function riddleProofMockRandom() {
13245
+ const activeQueue = Array.isArray(state.randomQueue) ? state.randomQueue : [];
13246
+ if (activeQueue.length) return activeQueue.shift();
13247
+ state.randomUnderflowCount = (typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0) + 1;
13248
+ return 0;
13249
+ };
13250
+ }
13251
+ if (typeof payload.now === "number" && Number.isFinite(payload.now)) {
13252
+ state.now = payload.now;
13253
+ Date.now = function riddleProofMockDateNow() {
13254
+ return state.now;
13255
+ };
13256
+ }
13257
+ if (typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms)) {
13258
+ const baseNow = typeof state.now === "number" && Number.isFinite(state.now)
13259
+ ? state.now
13260
+ : Date.now();
13261
+ state.now = baseNow + payload.advance_ms;
13262
+ Date.now = function riddleProofMockDateNow() {
13263
+ return state.now;
13264
+ };
13265
+ }
13266
+ return {
13267
+ ok: true,
13268
+ restored: false,
13269
+ random_enabled: Math.random !== state.originalRandom,
13270
+ random_queue_added: randomQueueAdded,
13271
+ random_queue_length: Array.isArray(state.randomQueue) ? state.randomQueue.length : 0,
13272
+ random_queue_mode: randomQueueMode,
13273
+ random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
13274
+ clock_enabled: Date.now !== state.originalDateNow,
13275
+ previous_now: previousNow,
13276
+ now: typeof state.now === "number" && Number.isFinite(state.now) ? state.now : null,
13277
+ advance_ms: typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms) ? payload.advance_ms : null,
13278
+ };
13279
+ }, { random_queue: randomQueue, now, advance_ms: advanceMs, append, restore });
13280
+ return {
13281
+ ...base,
13282
+ ...setupScopeEvidence(scope),
13283
+ ok: runtimeResult && runtimeResult.ok === true,
13284
+ random_enabled: runtimeResult?.random_enabled,
13285
+ random_queue_added: runtimeResult?.random_queue_added,
13286
+ random_queue_length: runtimeResult?.random_queue_length,
13287
+ random_queue_mode: runtimeResult?.random_queue_mode,
13288
+ random_underflow_count: runtimeResult?.random_underflow_count,
13289
+ clock_enabled: runtimeResult?.clock_enabled,
13290
+ previous_now: runtimeResult?.previous_now,
13291
+ now: runtimeResult?.now,
13292
+ advance_ms: runtimeResult?.advance_ms,
13293
+ restored: runtimeResult?.restored,
13294
+ reason: runtimeResult && runtimeResult.ok === true ? undefined : runtimeResult?.reason || "deterministic_runtime_not_applied",
13295
+ };
13296
+ }
13085
13297
  if (type === "window_eval") {
13086
13298
  const script = String(action.script || action.code || action.source || action.body || "");
13087
13299
  const args = Array.isArray(action.args) ? action.args : [];
@@ -16062,6 +16274,7 @@ function profileSetupSummaryMarkdown(result) {
16062
16274
  const windowEvalTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_total) || 0), 0);
16063
16275
  const windowEvalStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_stored_total) || 0), 0);
16064
16276
  const windowEvalCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_captured_total) || 0), 0);
16277
+ const deterministicRuntimeTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.deterministic_runtime_total) || 0), 0);
16065
16278
  const windowCallUntilTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_total) || 0), 0);
16066
16279
  const windowCallUntilCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_call_total) || 0), 0);
16067
16280
  const rangeValueTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.set_range_value_total) || 0), 0);
@@ -16086,6 +16299,9 @@ function profileSetupSummaryMarkdown(result) {
16086
16299
  if (windowEvalTotal) {
16087
16300
  lines.push(`- window_eval: ${windowEvalTotal} action(s), stored returns ${windowEvalStoredTotal}, captured returns ${windowEvalCapturedTotal}`);
16088
16301
  }
16302
+ if (deterministicRuntimeTotal) {
16303
+ lines.push(`- deterministic_runtime: ${deterministicRuntimeTotal} action(s)`);
16304
+ }
16089
16305
  if (windowCallUntilTotal) {
16090
16306
  lines.push(`- window_call_until: ${windowCallUntilTotal} action(s), call_count total ${windowCallUntilCallTotal}`);
16091
16307
  }
@@ -16112,13 +16328,14 @@ function profileSetupSummaryMarkdown(result) {
16112
16328
  const windowEvalActions = cliFiniteNumber(viewport.window_eval_total) || 0;
16113
16329
  const windowEvalStored = cliFiniteNumber(viewport.window_eval_stored_total) || 0;
16114
16330
  const windowEvalCaptured = cliFiniteNumber(viewport.window_eval_captured_total) || 0;
16331
+ const deterministicRuntimeActions = cliFiniteNumber(viewport.deterministic_runtime_total) || 0;
16115
16332
  const windowCallUntilActions = cliFiniteNumber(viewport.window_call_until_total) || 0;
16116
16333
  const windowCallUntilCalls = cliFiniteNumber(viewport.window_call_until_call_total) || 0;
16117
16334
  const rangeValueActions = cliFiniteNumber(viewport.set_range_value_total) || 0;
16118
16335
  const dragActions = cliFiniteNumber(viewport.drag_total) || 0;
16119
16336
  const canvasSignatureActions = cliFiniteNumber(viewport.canvas_signature_total) || 0;
16120
16337
  const observedPath = cliString(viewport.observed_path);
16121
- lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickSequenceCount ? `, ${clickSequenceCount} click sequence(s)` : ""}${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${rangeValueActions ? `, ${rangeValueActions} set_range_value action(s)` : ""}${dragActions ? `, ${dragActions} drag action(s)` : ""}${canvasSignatureActions ? `, ${canvasSignatureActions} canvas_signature action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
16338
+ lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickSequenceCount ? `, ${clickSequenceCount} click sequence(s)` : ""}${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${rangeValueActions ? `, ${rangeValueActions} set_range_value action(s)` : ""}${dragActions ? `, ${dragActions} drag action(s)` : ""}${canvasSignatureActions ? `, ${canvasSignatureActions} canvas_signature action(s)` : ""}${deterministicRuntimeActions ? `, ${deterministicRuntimeActions} deterministic_runtime action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
16122
16339
  }
16123
16340
  const clickSequenceGroups = viewports.map((viewport) => {
16124
16341
  const name = cliString(viewport.name) || "viewport";
@@ -16210,6 +16427,31 @@ function profileSetupSummaryMarkdown(result) {
16210
16427
  lines.push(`- ${name} canvas_signature warning: ${markdownInlineCode(selector)}${frameSelector ? ` in frame ${markdownInlineCode(frameSelector)}` : ""} returned the same hash${hash ? ` ${markdownInlineCode(hash, 80)}` : ""} for ${count ?? labelCount ?? "multiple"} labeled capture(s)${labelText}; treat canvas signatures as diagnostic when runtime evidence or screenshots show state changes.`);
16211
16428
  }
16212
16429
  if (canvasSignatureWarnings.length > sampledCanvasSignatureWarnings.length) lines.push(`- ${canvasSignatureWarnings.length - sampledCanvasSignatureWarnings.length} additional canvas_signature warning(s) omitted.`);
16430
+ const deterministicRuntimeGroups = viewports.map((viewport) => {
16431
+ const name = cliString(viewport.name) || "viewport";
16432
+ const receipts = Array.isArray(viewport.deterministic_runtime) ? viewport.deterministic_runtime.map(cliRecord).filter((item) => Boolean(item)) : [];
16433
+ return receipts.map((receipt) => ({ name, receipt }));
16434
+ });
16435
+ const deterministicRuntimeDetails = deterministicRuntimeGroups.flat();
16436
+ const sampledDeterministicRuntimeDetails = balancedSetupReceiptDetails(deterministicRuntimeGroups, 12);
16437
+ for (const { name, receipt } of sampledDeterministicRuntimeDetails) {
16438
+ const ok = receipt.ok === false ? "failed" : "ok";
16439
+ const randomEnabled = receipt.random_enabled === true ? "on" : receipt.random_enabled === false ? "off" : "unknown";
16440
+ const clockEnabled = receipt.clock_enabled === true ? "on" : receipt.clock_enabled === false ? "off" : "unknown";
16441
+ const randomQueueAdded = cliFiniteNumber(receipt.random_queue_added);
16442
+ const randomQueueLength = cliFiniteNumber(receipt.random_queue_length);
16443
+ const randomQueueMode = cliString(receipt.random_queue_mode);
16444
+ const randomUnderflowCount = cliFiniteNumber(receipt.random_underflow_count);
16445
+ const previousNow = cliFiniteNumber(receipt.previous_now);
16446
+ const now = cliFiniteNumber(receipt.now);
16447
+ const advanceMs = cliFiniteNumber(receipt.advance_ms);
16448
+ const restored = receipt.restored === true;
16449
+ const reason = cliString(receipt.reason);
16450
+ const randomText = randomQueueAdded === void 0 && randomQueueLength === void 0 ? `random ${randomEnabled}` : `random ${randomEnabled}${randomQueueMode ? ` ${randomQueueMode}` : ""}${randomQueueAdded === void 0 ? "" : ` +${randomQueueAdded}`}${randomQueueLength === void 0 ? "" : ` -> ${randomQueueLength}`}`;
16451
+ const clockText = now === void 0 ? `clock ${clockEnabled}` : `clock ${clockEnabled}${previousNow === void 0 ? "" : ` ${previousNow} ->`} ${now}`;
16452
+ lines.push(`- ${name} deterministic_runtime: ${ok}, ${restored ? "restored, " : ""}${randomText}${randomUnderflowCount ? `, underflows ${randomUnderflowCount}` : ""}, ${clockText}${advanceMs === void 0 ? "" : `, advance ${advanceMs}ms`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
16453
+ }
16454
+ if (deterministicRuntimeDetails.length > sampledDeterministicRuntimeDetails.length) lines.push(`- ${deterministicRuntimeDetails.length - sampledDeterministicRuntimeDetails.length} additional deterministic_runtime receipt(s) omitted.`);
16213
16455
  const rangeValueGroups = viewports.map((viewport) => {
16214
16456
  const name = cliString(viewport.name) || "viewport";
16215
16457
  const receipts = Array.isArray(viewport.set_range_value) ? viewport.set_range_value.map(cliRecord).filter((item) => Boolean(item)) : [];
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  profileStatusExitCode,
14
14
  resolveRiddleProofProfileTargetUrl,
15
15
  resolveRiddleProofProfileTimeoutSec
16
- } from "./chunk-KBLWL6MZ.js";
16
+ } from "./chunk-JIAMASZX.js";
17
17
  import {
18
18
  createRiddleApiClient,
19
19
  isTerminalRiddleJobStatus,
@@ -785,6 +785,7 @@ function profileSetupSummaryMarkdown(result) {
785
785
  const windowEvalTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_total) || 0), 0);
786
786
  const windowEvalStoredTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_stored_total) || 0), 0);
787
787
  const windowEvalCapturedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_eval_captured_total) || 0), 0);
788
+ const deterministicRuntimeTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.deterministic_runtime_total) || 0), 0);
788
789
  const windowCallUntilTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_total) || 0), 0);
789
790
  const windowCallUntilCallTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.window_call_until_call_total) || 0), 0);
790
791
  const rangeValueTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.set_range_value_total) || 0), 0);
@@ -809,6 +810,9 @@ function profileSetupSummaryMarkdown(result) {
809
810
  if (windowEvalTotal) {
810
811
  lines.push(`- window_eval: ${windowEvalTotal} action(s), stored returns ${windowEvalStoredTotal}, captured returns ${windowEvalCapturedTotal}`);
811
812
  }
813
+ if (deterministicRuntimeTotal) {
814
+ lines.push(`- deterministic_runtime: ${deterministicRuntimeTotal} action(s)`);
815
+ }
812
816
  if (windowCallUntilTotal) {
813
817
  lines.push(`- window_call_until: ${windowCallUntilTotal} action(s), call_count total ${windowCallUntilCallTotal}`);
814
818
  }
@@ -835,13 +839,14 @@ function profileSetupSummaryMarkdown(result) {
835
839
  const windowEvalActions = cliFiniteNumber(viewport.window_eval_total) || 0;
836
840
  const windowEvalStored = cliFiniteNumber(viewport.window_eval_stored_total) || 0;
837
841
  const windowEvalCaptured = cliFiniteNumber(viewport.window_eval_captured_total) || 0;
842
+ const deterministicRuntimeActions = cliFiniteNumber(viewport.deterministic_runtime_total) || 0;
838
843
  const windowCallUntilActions = cliFiniteNumber(viewport.window_call_until_total) || 0;
839
844
  const windowCallUntilCalls = cliFiniteNumber(viewport.window_call_until_call_total) || 0;
840
845
  const rangeValueActions = cliFiniteNumber(viewport.set_range_value_total) || 0;
841
846
  const dragActions = cliFiniteNumber(viewport.drag_total) || 0;
842
847
  const canvasSignatureActions = cliFiniteNumber(viewport.canvas_signature_total) || 0;
843
848
  const observedPath = cliString(viewport.observed_path);
844
- lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickSequenceCount ? `, ${clickSequenceCount} click sequence(s)` : ""}${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${rangeValueActions ? `, ${rangeValueActions} set_range_value action(s)` : ""}${dragActions ? `, ${dragActions} drag action(s)` : ""}${canvasSignatureActions ? `, ${canvasSignatureActions} canvas_signature action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
849
+ lines.push(`- ${name}: ${ok}, ${resultCount} result(s), ${screenshotCount} setup screenshot(s), ${clicked} click(s)${clickSequenceCount ? `, ${clickSequenceCount} click sequence(s)` : ""}${clickCountActions ? `, ${clickCountActions} click_count action(s)` : ""}${rangeValueActions ? `, ${rangeValueActions} set_range_value action(s)` : ""}${dragActions ? `, ${dragActions} drag action(s)` : ""}${canvasSignatureActions ? `, ${canvasSignatureActions} canvas_signature action(s)` : ""}${deterministicRuntimeActions ? `, ${deterministicRuntimeActions} deterministic_runtime action(s)` : ""}${windowCallActions ? `, ${windowCallActions} window_call action(s), ${windowCallStored} stored return(s), ${windowCallCaptured} captured return(s)` : ""}${windowEvalActions ? `, ${windowEvalActions} window_eval action(s), ${windowEvalStored} stored return(s), ${windowEvalCaptured} captured return(s)` : ""}${windowCallUntilActions ? `, ${windowCallUntilActions} window_call_until action(s), ${windowCallUntilCalls} call(s)` : ""}${observedPath ? `, path ${observedPath}` : ""}`);
845
850
  }
846
851
  const clickSequenceGroups = viewports.map((viewport) => {
847
852
  const name = cliString(viewport.name) || "viewport";
@@ -933,6 +938,31 @@ function profileSetupSummaryMarkdown(result) {
933
938
  lines.push(`- ${name} canvas_signature warning: ${markdownInlineCode(selector)}${frameSelector ? ` in frame ${markdownInlineCode(frameSelector)}` : ""} returned the same hash${hash ? ` ${markdownInlineCode(hash, 80)}` : ""} for ${count ?? labelCount ?? "multiple"} labeled capture(s)${labelText}; treat canvas signatures as diagnostic when runtime evidence or screenshots show state changes.`);
934
939
  }
935
940
  if (canvasSignatureWarnings.length > sampledCanvasSignatureWarnings.length) lines.push(`- ${canvasSignatureWarnings.length - sampledCanvasSignatureWarnings.length} additional canvas_signature warning(s) omitted.`);
941
+ const deterministicRuntimeGroups = viewports.map((viewport) => {
942
+ const name = cliString(viewport.name) || "viewport";
943
+ const receipts = Array.isArray(viewport.deterministic_runtime) ? viewport.deterministic_runtime.map(cliRecord).filter((item) => Boolean(item)) : [];
944
+ return receipts.map((receipt) => ({ name, receipt }));
945
+ });
946
+ const deterministicRuntimeDetails = deterministicRuntimeGroups.flat();
947
+ const sampledDeterministicRuntimeDetails = balancedSetupReceiptDetails(deterministicRuntimeGroups, 12);
948
+ for (const { name, receipt } of sampledDeterministicRuntimeDetails) {
949
+ const ok = receipt.ok === false ? "failed" : "ok";
950
+ const randomEnabled = receipt.random_enabled === true ? "on" : receipt.random_enabled === false ? "off" : "unknown";
951
+ const clockEnabled = receipt.clock_enabled === true ? "on" : receipt.clock_enabled === false ? "off" : "unknown";
952
+ const randomQueueAdded = cliFiniteNumber(receipt.random_queue_added);
953
+ const randomQueueLength = cliFiniteNumber(receipt.random_queue_length);
954
+ const randomQueueMode = cliString(receipt.random_queue_mode);
955
+ const randomUnderflowCount = cliFiniteNumber(receipt.random_underflow_count);
956
+ const previousNow = cliFiniteNumber(receipt.previous_now);
957
+ const now = cliFiniteNumber(receipt.now);
958
+ const advanceMs = cliFiniteNumber(receipt.advance_ms);
959
+ const restored = receipt.restored === true;
960
+ const reason = cliString(receipt.reason);
961
+ const randomText = randomQueueAdded === void 0 && randomQueueLength === void 0 ? `random ${randomEnabled}` : `random ${randomEnabled}${randomQueueMode ? ` ${randomQueueMode}` : ""}${randomQueueAdded === void 0 ? "" : ` +${randomQueueAdded}`}${randomQueueLength === void 0 ? "" : ` -> ${randomQueueLength}`}`;
962
+ const clockText = now === void 0 ? `clock ${clockEnabled}` : `clock ${clockEnabled}${previousNow === void 0 ? "" : ` ${previousNow} ->`} ${now}`;
963
+ lines.push(`- ${name} deterministic_runtime: ${ok}, ${restored ? "restored, " : ""}${randomText}${randomUnderflowCount ? `, underflows ${randomUnderflowCount}` : ""}, ${clockText}${advanceMs === void 0 ? "" : `, advance ${advanceMs}ms`}${reason ? `, reason ${markdownInlineCode(reason, 100)}` : ""}`);
964
+ }
965
+ if (deterministicRuntimeDetails.length > sampledDeterministicRuntimeDetails.length) lines.push(`- ${deterministicRuntimeDetails.length - sampledDeterministicRuntimeDetails.length} additional deterministic_runtime receipt(s) omitted.`);
936
966
  const rangeValueGroups = viewports.map((viewport) => {
937
967
  const name = cliString(viewport.name) || "viewport";
938
968
  const receipts = Array.isArray(viewport.set_range_value) ? viewport.set_range_value.map(cliRecord).filter((item) => Boolean(item)) : [];