@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/index.cjs CHANGED
@@ -8782,6 +8782,7 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
8782
8782
  "fill",
8783
8783
  "set_input_value",
8784
8784
  "set_range_value",
8785
+ "deterministic_runtime",
8785
8786
  "canvas_signature",
8786
8787
  "assert_text_visible",
8787
8788
  "assert_text_absent",
@@ -9244,6 +9245,23 @@ function profileSetupWindowEvalReceipts(results) {
9244
9245
  return receipt;
9245
9246
  });
9246
9247
  }
9248
+ function profileSetupDeterministicRuntimeReceipts(results) {
9249
+ return results.filter((result) => profileSetupResultAction(result) === "deterministic_runtime").map((result) => ({
9250
+ ordinal: result.ordinal ?? null,
9251
+ ok: result.ok !== false,
9252
+ random_enabled: result.random_enabled ?? null,
9253
+ random_queue_added: result.random_queue_added ?? null,
9254
+ random_queue_length: result.random_queue_length ?? null,
9255
+ random_queue_mode: result.random_queue_mode ?? null,
9256
+ random_underflow_count: result.random_underflow_count ?? null,
9257
+ clock_enabled: result.clock_enabled ?? null,
9258
+ previous_now: result.previous_now ?? null,
9259
+ now: result.now ?? null,
9260
+ advance_ms: result.advance_ms ?? null,
9261
+ restored: result.restored ?? null,
9262
+ reason: result.reason ?? result.error ?? null
9263
+ }));
9264
+ }
9247
9265
  function profileSetupReturnSummaryFields(result) {
9248
9266
  const input = result.return_summary_fields;
9249
9267
  if (!Array.isArray(input)) return [];
@@ -9347,21 +9365,28 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
9347
9365
  }
9348
9366
  const warnings = [];
9349
9367
  for (const group of groups.values()) {
9350
- const hashes = new Set(group.receipts.map((receipt) => receipt.hash));
9351
- const labels = [...new Set(group.receipts.map((receipt) => receipt.label))];
9352
- if (group.receipts.length < 2 || labels.length < 2 || hashes.size !== 1) continue;
9353
- const visibleLabels = labels.slice(0, 8);
9354
- warnings.push({
9355
- selector: group.selector,
9356
- frame_selector: group.frame_selector ?? null,
9357
- hash: group.receipts[0].hash,
9358
- count: group.receipts.length,
9359
- label_count: labels.length,
9360
- labels: visibleLabels,
9361
- omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
9362
- ordinals: group.receipts.map((receipt) => receipt.ordinal).filter((value) => value !== void 0).slice(0, 12),
9363
- reason: "stable_canvas_signature_hash"
9364
- });
9368
+ const receiptsByHash = /* @__PURE__ */ new Map();
9369
+ for (const receipt of group.receipts) {
9370
+ const hashReceipts = receiptsByHash.get(receipt.hash) || [];
9371
+ hashReceipts.push(receipt);
9372
+ receiptsByHash.set(receipt.hash, hashReceipts);
9373
+ }
9374
+ for (const [hash, receipts] of receiptsByHash.entries()) {
9375
+ const labels = [...new Set(receipts.map((receipt) => receipt.label))];
9376
+ if (receipts.length < 2 || labels.length < 2) continue;
9377
+ const visibleLabels = labels.slice(0, 8);
9378
+ warnings.push({
9379
+ selector: group.selector,
9380
+ frame_selector: group.frame_selector ?? null,
9381
+ hash,
9382
+ count: receipts.length,
9383
+ label_count: labels.length,
9384
+ labels: visibleLabels,
9385
+ omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
9386
+ ordinals: receipts.map((receipt) => receipt.ordinal).filter((value) => value !== void 0).slice(0, 12),
9387
+ reason: "stable_canvas_signature_hash"
9388
+ });
9389
+ }
9365
9390
  }
9366
9391
  return warnings;
9367
9392
  }
@@ -9458,6 +9483,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
9458
9483
  const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
9459
9484
  const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
9460
9485
  const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
9486
+ const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
9487
+ const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
9461
9488
  const rangeValueReceipts = profileSetupRangeValueReceipts(results);
9462
9489
  const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
9463
9490
  const dragReceipts = profileSetupDragReceipts(results);
@@ -9517,6 +9544,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
9517
9544
  window_eval_captured_total: windowEvalCapturedTotal,
9518
9545
  window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
9519
9546
  window_eval: sampledWindowEvalReceipts,
9547
+ deterministic_runtime_total: deterministicRuntimeReceipts.length,
9548
+ deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
9549
+ deterministic_runtime: sampledDeterministicRuntimeReceipts,
9520
9550
  set_range_value_total: rangeValueReceipts.length,
9521
9551
  set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
9522
9552
  set_range_value: sampledRangeValueReceipts,
@@ -9579,7 +9609,7 @@ function isSupportedCheckType(value) {
9579
9609
  }
9580
9610
  function normalizeSetupActionType(value, index) {
9581
9611
  const normalizedInput = String(value || "").trim().replace(/-/g, "_");
9582
- 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;
9612
+ 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;
9583
9613
  if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
9584
9614
  return normalized;
9585
9615
  }
@@ -9698,6 +9728,39 @@ function normalizeSetupActionScreenshotFullPage(input, type, index) {
9698
9728
  }
9699
9729
  return values[0];
9700
9730
  }
9731
+ function normalizeSetupActionRandomQueue(input, index) {
9732
+ const rawQueue = valueFromOwn(
9733
+ input,
9734
+ "random_queue",
9735
+ "randomQueue",
9736
+ "random_values",
9737
+ "randomValues",
9738
+ "random_sequence",
9739
+ "randomSequence",
9740
+ "math_random",
9741
+ "mathRandom"
9742
+ );
9743
+ if (rawQueue === void 0) return void 0;
9744
+ if (!Array.isArray(rawQueue) || rawQueue.length === 0) {
9745
+ throw new Error(`target.setup_actions[${index}].random_queue must be a non-empty array of numbers from 0 inclusive to 1 exclusive.`);
9746
+ }
9747
+ return rawQueue.map((item, queueIndex) => {
9748
+ const value = numberValue3(item);
9749
+ if (value === void 0 || value < 0 || value >= 1) {
9750
+ throw new Error(`target.setup_actions[${index}].random_queue[${queueIndex}] must be a finite number from 0 inclusive to 1 exclusive.`);
9751
+ }
9752
+ return value;
9753
+ });
9754
+ }
9755
+ function normalizeSetupActionNonNegativeNumber(input, index, outputKey, ...keys) {
9756
+ const rawValue = valueFromOwn(input, ...keys);
9757
+ if (rawValue === void 0) return void 0;
9758
+ const value = numberValue3(rawValue);
9759
+ if (value === void 0 || value < 0) {
9760
+ throw new Error(`target.setup_actions[${index}].${outputKey} must be a finite non-negative number.`);
9761
+ }
9762
+ return value;
9763
+ }
9701
9764
  function normalizeSetupAction(input, index) {
9702
9765
  if (!isRecord2(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
9703
9766
  const type = normalizeSetupActionType(stringValue5(input.type), index);
@@ -9758,6 +9821,14 @@ function normalizeSetupAction(input, index) {
9758
9821
  if ((type === "fill" || type === "set_input_value" || type === "set_range_value") && value === void 0 && !hasJsonValue) {
9759
9822
  throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
9760
9823
  }
9824
+ const randomQueue = type === "deterministic_runtime" ? normalizeSetupActionRandomQueue(input, index) : void 0;
9825
+ const deterministicNow = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "now", "now", "date_now", "dateNow", "mock_now", "mockNow", "clock", "timestamp", "time_ms", "timeMs") : void 0;
9826
+ const deterministicAdvanceMs = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "advance_ms", "advance_ms", "advanceMs", "tick_ms", "tickMs", "add_ms", "addMs") : void 0;
9827
+ const deterministicAppend = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "append", "append_random", "appendRandom")) === true;
9828
+ const deterministicRestore = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "restore", "reset", "restore_originals", "restoreOriginals")) === true;
9829
+ if (type === "deterministic_runtime" && randomQueue === void 0 && deterministicNow === void 0 && deterministicAdvanceMs === void 0 && !deterministicRestore) {
9830
+ throw new Error(`target.setup_actions[${index}] deterministic_runtime requires random_queue, now, advance_ms, or restore.`);
9831
+ }
9761
9832
  const key = stringValue5(input.key);
9762
9833
  let dialogAccept;
9763
9834
  if (type === "dialog_response") {
@@ -9865,6 +9936,11 @@ function normalizeSetupAction(input, index) {
9865
9936
  key,
9866
9937
  value,
9867
9938
  value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
9939
+ random_queue: randomQueue,
9940
+ now: deterministicNow,
9941
+ advance_ms: deterministicAdvanceMs,
9942
+ append: deterministicAppend || void 0,
9943
+ restore: deterministicRestore || void 0,
9868
9944
  label: stringFromOwn(input, "label", "name", "screenshot_label", "screenshotLabel"),
9869
9945
  script,
9870
9946
  path: path6,
@@ -12941,6 +13017,25 @@ function profileSetupWindowEvalReceipts(results) {
12941
13017
  return receipt;
12942
13018
  });
12943
13019
  }
13020
+ function profileSetupDeterministicRuntimeReceipts(results) {
13021
+ return (results || [])
13022
+ .filter((result) => result && profileSetupResultAction(result) === "deterministic_runtime")
13023
+ .map((result) => ({
13024
+ ordinal: result.ordinal ?? null,
13025
+ ok: result.ok !== false,
13026
+ random_enabled: result.random_enabled ?? null,
13027
+ random_queue_added: result.random_queue_added ?? null,
13028
+ random_queue_length: result.random_queue_length ?? null,
13029
+ random_queue_mode: result.random_queue_mode ?? null,
13030
+ random_underflow_count: result.random_underflow_count ?? null,
13031
+ clock_enabled: result.clock_enabled ?? null,
13032
+ previous_now: result.previous_now ?? null,
13033
+ now: result.now ?? null,
13034
+ advance_ms: result.advance_ms ?? null,
13035
+ restored: result.restored ?? null,
13036
+ reason: result.reason || result.error || null,
13037
+ }));
13038
+ }
12944
13039
  function profileSetupReturnSummaryFields(result) {
12945
13040
  const input = result && result.return_summary_fields;
12946
13041
  if (!Array.isArray(input)) return [];
@@ -13054,24 +13149,31 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
13054
13149
  }
13055
13150
  const warnings = [];
13056
13151
  for (const group of groups.values()) {
13057
- const hashes = new Set(group.receipts.map((receipt) => receipt.hash));
13058
- const labels = [...new Set(group.receipts.map((receipt) => receipt.label))];
13059
- if (group.receipts.length < 2 || labels.length < 2 || hashes.size !== 1) continue;
13060
- const visibleLabels = labels.slice(0, 8);
13061
- warnings.push({
13062
- selector: group.selector,
13063
- frame_selector: group.frame_selector || null,
13064
- hash: group.receipts[0].hash,
13065
- count: group.receipts.length,
13066
- label_count: labels.length,
13067
- labels: visibleLabels,
13068
- omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
13069
- ordinals: group.receipts
13070
- .map((receipt) => receipt.ordinal)
13071
- .filter((value) => value !== undefined)
13072
- .slice(0, 12),
13073
- reason: "stable_canvas_signature_hash",
13074
- });
13152
+ const receiptsByHash = new Map();
13153
+ for (const receipt of group.receipts) {
13154
+ const hashReceipts = receiptsByHash.get(receipt.hash) || [];
13155
+ hashReceipts.push(receipt);
13156
+ receiptsByHash.set(receipt.hash, hashReceipts);
13157
+ }
13158
+ for (const [hash, receipts] of receiptsByHash.entries()) {
13159
+ const labels = [...new Set(receipts.map((receipt) => receipt.label))];
13160
+ if (receipts.length < 2 || labels.length < 2) continue;
13161
+ const visibleLabels = labels.slice(0, 8);
13162
+ warnings.push({
13163
+ selector: group.selector,
13164
+ frame_selector: group.frame_selector || null,
13165
+ hash,
13166
+ count: receipts.length,
13167
+ label_count: labels.length,
13168
+ labels: visibleLabels,
13169
+ omitted_label_count: Math.max(0, labels.length - visibleLabels.length),
13170
+ ordinals: receipts
13171
+ .map((receipt) => receipt.ordinal)
13172
+ .filter((value) => value !== undefined)
13173
+ .slice(0, 12),
13174
+ reason: "stable_canvas_signature_hash",
13175
+ });
13176
+ }
13075
13177
  }
13076
13178
  return warnings;
13077
13179
  }
@@ -13184,6 +13286,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
13184
13286
  const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
13185
13287
  const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
13186
13288
  const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
13289
+ const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
13290
+ const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
13187
13291
  const rangeValueReceipts = profileSetupRangeValueReceipts(results);
13188
13292
  const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
13189
13293
  const dragReceipts = profileSetupDragReceipts(results);
@@ -13253,6 +13357,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
13253
13357
  window_eval_captured_total: windowEvalCapturedTotal,
13254
13358
  window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
13255
13359
  window_eval: sampledWindowEvalReceipts,
13360
+ deterministic_runtime_total: deterministicRuntimeReceipts.length,
13361
+ deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
13362
+ deterministic_runtime: sampledDeterministicRuntimeReceipts,
13256
13363
  set_range_value_total: rangeValueReceipts.length,
13257
13364
  set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
13258
13365
  set_range_value: sampledRangeValueReceipts,
@@ -14874,6 +14981,111 @@ async function executeSetupAction(action, ordinal, viewport) {
14874
14981
  }
14875
14982
  return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
14876
14983
  }
14984
+ if (type === "deterministic_runtime") {
14985
+ const scope = await setupActionScope(action, timeout);
14986
+ if (!scope.ok) return setupScopeFailure(base, scope);
14987
+ const randomQueue = Array.isArray(action.random_queue)
14988
+ ? action.random_queue
14989
+ : Array.isArray(action.randomQueue)
14990
+ ? action.randomQueue
14991
+ : null;
14992
+ const now = setupFiniteNumber(action.now ?? action.date_now ?? action.dateNow ?? action.mock_now ?? action.mockNow ?? action.clock ?? action.timestamp ?? action.time_ms ?? action.timeMs);
14993
+ const advanceMs = setupFiniteNumber(action.advance_ms ?? action.advanceMs ?? action.tick_ms ?? action.tickMs ?? action.add_ms ?? action.addMs);
14994
+ const append = action.append === true || action.append_random === true || action.appendRandom === true;
14995
+ const restore = action.restore === true || action.reset === true || action.restore_originals === true || action.restoreOriginals === true;
14996
+ const runtimeResult = await scope.context.evaluate((payload) => {
14997
+ const root = window;
14998
+ const stateKey = "__RIDDLE_PROOF_DETERMINISTIC_RUNTIME__";
14999
+ const state = root[stateKey] && typeof root[stateKey] === "object" && !Array.isArray(root[stateKey])
15000
+ ? root[stateKey]
15001
+ : {};
15002
+ root[stateKey] = state;
15003
+ if (typeof state.originalRandom !== "function") state.originalRandom = Math.random;
15004
+ if (typeof state.originalDateNow !== "function") state.originalDateNow = Date.now;
15005
+ const previousNow = typeof state.now === "number" && Number.isFinite(state.now)
15006
+ ? state.now
15007
+ : Date.now === state.originalDateNow
15008
+ ? null
15009
+ : Date.now();
15010
+ if (payload.restore) {
15011
+ Math.random = state.originalRandom;
15012
+ Date.now = state.originalDateNow;
15013
+ delete root[stateKey];
15014
+ return {
15015
+ ok: true,
15016
+ restored: true,
15017
+ random_enabled: false,
15018
+ random_queue_added: 0,
15019
+ random_queue_length: 0,
15020
+ random_queue_mode: null,
15021
+ random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
15022
+ clock_enabled: false,
15023
+ previous_now: previousNow,
15024
+ now: null,
15025
+ advance_ms: null,
15026
+ };
15027
+ }
15028
+ let randomQueueAdded = null;
15029
+ let randomQueueMode = null;
15030
+ if (Array.isArray(payload.random_queue)) {
15031
+ const queue = payload.random_queue.filter((value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value < 1);
15032
+ const existing = Array.isArray(state.randomQueue) ? state.randomQueue : [];
15033
+ state.randomQueue = payload.append ? existing.concat(queue) : queue.slice();
15034
+ randomQueueAdded = queue.length;
15035
+ randomQueueMode = payload.append ? "append" : "replace";
15036
+ Math.random = function riddleProofMockRandom() {
15037
+ const activeQueue = Array.isArray(state.randomQueue) ? state.randomQueue : [];
15038
+ if (activeQueue.length) return activeQueue.shift();
15039
+ state.randomUnderflowCount = (typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0) + 1;
15040
+ return 0;
15041
+ };
15042
+ }
15043
+ if (typeof payload.now === "number" && Number.isFinite(payload.now)) {
15044
+ state.now = payload.now;
15045
+ Date.now = function riddleProofMockDateNow() {
15046
+ return state.now;
15047
+ };
15048
+ }
15049
+ if (typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms)) {
15050
+ const baseNow = typeof state.now === "number" && Number.isFinite(state.now)
15051
+ ? state.now
15052
+ : Date.now();
15053
+ state.now = baseNow + payload.advance_ms;
15054
+ Date.now = function riddleProofMockDateNow() {
15055
+ return state.now;
15056
+ };
15057
+ }
15058
+ return {
15059
+ ok: true,
15060
+ restored: false,
15061
+ random_enabled: Math.random !== state.originalRandom,
15062
+ random_queue_added: randomQueueAdded,
15063
+ random_queue_length: Array.isArray(state.randomQueue) ? state.randomQueue.length : 0,
15064
+ random_queue_mode: randomQueueMode,
15065
+ random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
15066
+ clock_enabled: Date.now !== state.originalDateNow,
15067
+ previous_now: previousNow,
15068
+ now: typeof state.now === "number" && Number.isFinite(state.now) ? state.now : null,
15069
+ advance_ms: typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms) ? payload.advance_ms : null,
15070
+ };
15071
+ }, { random_queue: randomQueue, now, advance_ms: advanceMs, append, restore });
15072
+ return {
15073
+ ...base,
15074
+ ...setupScopeEvidence(scope),
15075
+ ok: runtimeResult && runtimeResult.ok === true,
15076
+ random_enabled: runtimeResult?.random_enabled,
15077
+ random_queue_added: runtimeResult?.random_queue_added,
15078
+ random_queue_length: runtimeResult?.random_queue_length,
15079
+ random_queue_mode: runtimeResult?.random_queue_mode,
15080
+ random_underflow_count: runtimeResult?.random_underflow_count,
15081
+ clock_enabled: runtimeResult?.clock_enabled,
15082
+ previous_now: runtimeResult?.previous_now,
15083
+ now: runtimeResult?.now,
15084
+ advance_ms: runtimeResult?.advance_ms,
15085
+ restored: runtimeResult?.restored,
15086
+ reason: runtimeResult && runtimeResult.ok === true ? undefined : runtimeResult?.reason || "deterministic_runtime_not_applied",
15087
+ };
15088
+ }
14877
15089
  if (type === "window_eval") {
14878
15090
  const script = String(action.script || action.code || action.source || action.body || "");
14879
15091
  const args = Array.isArray(action.args) ? action.args : [];
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  resolveRiddleProofProfileTimeoutSec,
63
63
  slugifyRiddleProofProfileName,
64
64
  summarizeRiddleProofProfileResult
65
- } from "./chunk-KBLWL6MZ.js";
65
+ } from "./chunk-JIAMASZX.js";
66
66
  import {
67
67
  DEFAULT_RIDDLE_API_BASE_URL,
68
68
  DEFAULT_RIDDLE_API_KEY_FILE,