@riddledc/riddle-proof 0.7.171 → 0.7.172
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/README.md +9 -1
- package/dist/{chunk-KBLWL6MZ.js → chunk-5ELOMJ7U.js} +199 -1
- package/dist/cli.cjs +230 -2
- package/dist/cli.js +32 -2
- package/dist/index.cjs +199 -1
- package/dist/index.js +1 -1
- package/dist/profile.cjs +199 -1
- package/dist/profile.d.cts +6 -1
- package/dist/profile.d.ts +6 -1
- package/dist/profile.js +1 -1
- package/package.json +1 -1
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 [];
|
|
@@ -9458,6 +9476,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
9458
9476
|
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
9459
9477
|
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
9460
9478
|
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
9479
|
+
const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
|
|
9480
|
+
const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
|
|
9461
9481
|
const rangeValueReceipts = profileSetupRangeValueReceipts(results);
|
|
9462
9482
|
const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
|
|
9463
9483
|
const dragReceipts = profileSetupDragReceipts(results);
|
|
@@ -9517,6 +9537,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
9517
9537
|
window_eval_captured_total: windowEvalCapturedTotal,
|
|
9518
9538
|
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
9519
9539
|
window_eval: sampledWindowEvalReceipts,
|
|
9540
|
+
deterministic_runtime_total: deterministicRuntimeReceipts.length,
|
|
9541
|
+
deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
|
|
9542
|
+
deterministic_runtime: sampledDeterministicRuntimeReceipts,
|
|
9520
9543
|
set_range_value_total: rangeValueReceipts.length,
|
|
9521
9544
|
set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
|
|
9522
9545
|
set_range_value: sampledRangeValueReceipts,
|
|
@@ -9579,7 +9602,7 @@ function isSupportedCheckType(value) {
|
|
|
9579
9602
|
}
|
|
9580
9603
|
function normalizeSetupActionType(value, index) {
|
|
9581
9604
|
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;
|
|
9605
|
+
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
9606
|
if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
|
|
9584
9607
|
return normalized;
|
|
9585
9608
|
}
|
|
@@ -9698,6 +9721,39 @@ function normalizeSetupActionScreenshotFullPage(input, type, index) {
|
|
|
9698
9721
|
}
|
|
9699
9722
|
return values[0];
|
|
9700
9723
|
}
|
|
9724
|
+
function normalizeSetupActionRandomQueue(input, index) {
|
|
9725
|
+
const rawQueue = valueFromOwn(
|
|
9726
|
+
input,
|
|
9727
|
+
"random_queue",
|
|
9728
|
+
"randomQueue",
|
|
9729
|
+
"random_values",
|
|
9730
|
+
"randomValues",
|
|
9731
|
+
"random_sequence",
|
|
9732
|
+
"randomSequence",
|
|
9733
|
+
"math_random",
|
|
9734
|
+
"mathRandom"
|
|
9735
|
+
);
|
|
9736
|
+
if (rawQueue === void 0) return void 0;
|
|
9737
|
+
if (!Array.isArray(rawQueue) || rawQueue.length === 0) {
|
|
9738
|
+
throw new Error(`target.setup_actions[${index}].random_queue must be a non-empty array of numbers from 0 inclusive to 1 exclusive.`);
|
|
9739
|
+
}
|
|
9740
|
+
return rawQueue.map((item, queueIndex) => {
|
|
9741
|
+
const value = numberValue3(item);
|
|
9742
|
+
if (value === void 0 || value < 0 || value >= 1) {
|
|
9743
|
+
throw new Error(`target.setup_actions[${index}].random_queue[${queueIndex}] must be a finite number from 0 inclusive to 1 exclusive.`);
|
|
9744
|
+
}
|
|
9745
|
+
return value;
|
|
9746
|
+
});
|
|
9747
|
+
}
|
|
9748
|
+
function normalizeSetupActionNonNegativeNumber(input, index, outputKey, ...keys) {
|
|
9749
|
+
const rawValue = valueFromOwn(input, ...keys);
|
|
9750
|
+
if (rawValue === void 0) return void 0;
|
|
9751
|
+
const value = numberValue3(rawValue);
|
|
9752
|
+
if (value === void 0 || value < 0) {
|
|
9753
|
+
throw new Error(`target.setup_actions[${index}].${outputKey} must be a finite non-negative number.`);
|
|
9754
|
+
}
|
|
9755
|
+
return value;
|
|
9756
|
+
}
|
|
9701
9757
|
function normalizeSetupAction(input, index) {
|
|
9702
9758
|
if (!isRecord2(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
|
|
9703
9759
|
const type = normalizeSetupActionType(stringValue5(input.type), index);
|
|
@@ -9758,6 +9814,14 @@ function normalizeSetupAction(input, index) {
|
|
|
9758
9814
|
if ((type === "fill" || type === "set_input_value" || type === "set_range_value") && value === void 0 && !hasJsonValue) {
|
|
9759
9815
|
throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
|
|
9760
9816
|
}
|
|
9817
|
+
const randomQueue = type === "deterministic_runtime" ? normalizeSetupActionRandomQueue(input, index) : void 0;
|
|
9818
|
+
const deterministicNow = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "now", "now", "date_now", "dateNow", "mock_now", "mockNow", "clock", "timestamp", "time_ms", "timeMs") : void 0;
|
|
9819
|
+
const deterministicAdvanceMs = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "advance_ms", "advance_ms", "advanceMs", "tick_ms", "tickMs", "add_ms", "addMs") : void 0;
|
|
9820
|
+
const deterministicAppend = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "append", "append_random", "appendRandom")) === true;
|
|
9821
|
+
const deterministicRestore = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "restore", "reset", "restore_originals", "restoreOriginals")) === true;
|
|
9822
|
+
if (type === "deterministic_runtime" && randomQueue === void 0 && deterministicNow === void 0 && deterministicAdvanceMs === void 0 && !deterministicRestore) {
|
|
9823
|
+
throw new Error(`target.setup_actions[${index}] deterministic_runtime requires random_queue, now, advance_ms, or restore.`);
|
|
9824
|
+
}
|
|
9761
9825
|
const key = stringValue5(input.key);
|
|
9762
9826
|
let dialogAccept;
|
|
9763
9827
|
if (type === "dialog_response") {
|
|
@@ -9865,6 +9929,11 @@ function normalizeSetupAction(input, index) {
|
|
|
9865
9929
|
key,
|
|
9866
9930
|
value,
|
|
9867
9931
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
9932
|
+
random_queue: randomQueue,
|
|
9933
|
+
now: deterministicNow,
|
|
9934
|
+
advance_ms: deterministicAdvanceMs,
|
|
9935
|
+
append: deterministicAppend || void 0,
|
|
9936
|
+
restore: deterministicRestore || void 0,
|
|
9868
9937
|
label: stringFromOwn(input, "label", "name", "screenshot_label", "screenshotLabel"),
|
|
9869
9938
|
script,
|
|
9870
9939
|
path: path6,
|
|
@@ -12941,6 +13010,25 @@ function profileSetupWindowEvalReceipts(results) {
|
|
|
12941
13010
|
return receipt;
|
|
12942
13011
|
});
|
|
12943
13012
|
}
|
|
13013
|
+
function profileSetupDeterministicRuntimeReceipts(results) {
|
|
13014
|
+
return (results || [])
|
|
13015
|
+
.filter((result) => result && profileSetupResultAction(result) === "deterministic_runtime")
|
|
13016
|
+
.map((result) => ({
|
|
13017
|
+
ordinal: result.ordinal ?? null,
|
|
13018
|
+
ok: result.ok !== false,
|
|
13019
|
+
random_enabled: result.random_enabled ?? null,
|
|
13020
|
+
random_queue_added: result.random_queue_added ?? null,
|
|
13021
|
+
random_queue_length: result.random_queue_length ?? null,
|
|
13022
|
+
random_queue_mode: result.random_queue_mode ?? null,
|
|
13023
|
+
random_underflow_count: result.random_underflow_count ?? null,
|
|
13024
|
+
clock_enabled: result.clock_enabled ?? null,
|
|
13025
|
+
previous_now: result.previous_now ?? null,
|
|
13026
|
+
now: result.now ?? null,
|
|
13027
|
+
advance_ms: result.advance_ms ?? null,
|
|
13028
|
+
restored: result.restored ?? null,
|
|
13029
|
+
reason: result.reason || result.error || null,
|
|
13030
|
+
}));
|
|
13031
|
+
}
|
|
12944
13032
|
function profileSetupReturnSummaryFields(result) {
|
|
12945
13033
|
const input = result && result.return_summary_fields;
|
|
12946
13034
|
if (!Array.isArray(input)) return [];
|
|
@@ -13184,6 +13272,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
13184
13272
|
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
13185
13273
|
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
13186
13274
|
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
13275
|
+
const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
|
|
13276
|
+
const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
|
|
13187
13277
|
const rangeValueReceipts = profileSetupRangeValueReceipts(results);
|
|
13188
13278
|
const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
|
|
13189
13279
|
const dragReceipts = profileSetupDragReceipts(results);
|
|
@@ -13253,6 +13343,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
13253
13343
|
window_eval_captured_total: windowEvalCapturedTotal,
|
|
13254
13344
|
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
13255
13345
|
window_eval: sampledWindowEvalReceipts,
|
|
13346
|
+
deterministic_runtime_total: deterministicRuntimeReceipts.length,
|
|
13347
|
+
deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
|
|
13348
|
+
deterministic_runtime: sampledDeterministicRuntimeReceipts,
|
|
13256
13349
|
set_range_value_total: rangeValueReceipts.length,
|
|
13257
13350
|
set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
|
|
13258
13351
|
set_range_value: sampledRangeValueReceipts,
|
|
@@ -14874,6 +14967,111 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14874
14967
|
}
|
|
14875
14968
|
return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
|
|
14876
14969
|
}
|
|
14970
|
+
if (type === "deterministic_runtime") {
|
|
14971
|
+
const scope = await setupActionScope(action, timeout);
|
|
14972
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
14973
|
+
const randomQueue = Array.isArray(action.random_queue)
|
|
14974
|
+
? action.random_queue
|
|
14975
|
+
: Array.isArray(action.randomQueue)
|
|
14976
|
+
? action.randomQueue
|
|
14977
|
+
: null;
|
|
14978
|
+
const now = setupFiniteNumber(action.now ?? action.date_now ?? action.dateNow ?? action.mock_now ?? action.mockNow ?? action.clock ?? action.timestamp ?? action.time_ms ?? action.timeMs);
|
|
14979
|
+
const advanceMs = setupFiniteNumber(action.advance_ms ?? action.advanceMs ?? action.tick_ms ?? action.tickMs ?? action.add_ms ?? action.addMs);
|
|
14980
|
+
const append = action.append === true || action.append_random === true || action.appendRandom === true;
|
|
14981
|
+
const restore = action.restore === true || action.reset === true || action.restore_originals === true || action.restoreOriginals === true;
|
|
14982
|
+
const runtimeResult = await scope.context.evaluate((payload) => {
|
|
14983
|
+
const root = window;
|
|
14984
|
+
const stateKey = "__RIDDLE_PROOF_DETERMINISTIC_RUNTIME__";
|
|
14985
|
+
const state = root[stateKey] && typeof root[stateKey] === "object" && !Array.isArray(root[stateKey])
|
|
14986
|
+
? root[stateKey]
|
|
14987
|
+
: {};
|
|
14988
|
+
root[stateKey] = state;
|
|
14989
|
+
if (typeof state.originalRandom !== "function") state.originalRandom = Math.random;
|
|
14990
|
+
if (typeof state.originalDateNow !== "function") state.originalDateNow = Date.now;
|
|
14991
|
+
const previousNow = typeof state.now === "number" && Number.isFinite(state.now)
|
|
14992
|
+
? state.now
|
|
14993
|
+
: Date.now === state.originalDateNow
|
|
14994
|
+
? null
|
|
14995
|
+
: Date.now();
|
|
14996
|
+
if (payload.restore) {
|
|
14997
|
+
Math.random = state.originalRandom;
|
|
14998
|
+
Date.now = state.originalDateNow;
|
|
14999
|
+
delete root[stateKey];
|
|
15000
|
+
return {
|
|
15001
|
+
ok: true,
|
|
15002
|
+
restored: true,
|
|
15003
|
+
random_enabled: false,
|
|
15004
|
+
random_queue_added: 0,
|
|
15005
|
+
random_queue_length: 0,
|
|
15006
|
+
random_queue_mode: null,
|
|
15007
|
+
random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
|
|
15008
|
+
clock_enabled: false,
|
|
15009
|
+
previous_now: previousNow,
|
|
15010
|
+
now: null,
|
|
15011
|
+
advance_ms: null,
|
|
15012
|
+
};
|
|
15013
|
+
}
|
|
15014
|
+
let randomQueueAdded = null;
|
|
15015
|
+
let randomQueueMode = null;
|
|
15016
|
+
if (Array.isArray(payload.random_queue)) {
|
|
15017
|
+
const queue = payload.random_queue.filter((value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value < 1);
|
|
15018
|
+
const existing = Array.isArray(state.randomQueue) ? state.randomQueue : [];
|
|
15019
|
+
state.randomQueue = payload.append ? existing.concat(queue) : queue.slice();
|
|
15020
|
+
randomQueueAdded = queue.length;
|
|
15021
|
+
randomQueueMode = payload.append ? "append" : "replace";
|
|
15022
|
+
Math.random = function riddleProofMockRandom() {
|
|
15023
|
+
const activeQueue = Array.isArray(state.randomQueue) ? state.randomQueue : [];
|
|
15024
|
+
if (activeQueue.length) return activeQueue.shift();
|
|
15025
|
+
state.randomUnderflowCount = (typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0) + 1;
|
|
15026
|
+
return 0;
|
|
15027
|
+
};
|
|
15028
|
+
}
|
|
15029
|
+
if (typeof payload.now === "number" && Number.isFinite(payload.now)) {
|
|
15030
|
+
state.now = payload.now;
|
|
15031
|
+
Date.now = function riddleProofMockDateNow() {
|
|
15032
|
+
return state.now;
|
|
15033
|
+
};
|
|
15034
|
+
}
|
|
15035
|
+
if (typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms)) {
|
|
15036
|
+
const baseNow = typeof state.now === "number" && Number.isFinite(state.now)
|
|
15037
|
+
? state.now
|
|
15038
|
+
: Date.now();
|
|
15039
|
+
state.now = baseNow + payload.advance_ms;
|
|
15040
|
+
Date.now = function riddleProofMockDateNow() {
|
|
15041
|
+
return state.now;
|
|
15042
|
+
};
|
|
15043
|
+
}
|
|
15044
|
+
return {
|
|
15045
|
+
ok: true,
|
|
15046
|
+
restored: false,
|
|
15047
|
+
random_enabled: Math.random !== state.originalRandom,
|
|
15048
|
+
random_queue_added: randomQueueAdded,
|
|
15049
|
+
random_queue_length: Array.isArray(state.randomQueue) ? state.randomQueue.length : 0,
|
|
15050
|
+
random_queue_mode: randomQueueMode,
|
|
15051
|
+
random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
|
|
15052
|
+
clock_enabled: Date.now !== state.originalDateNow,
|
|
15053
|
+
previous_now: previousNow,
|
|
15054
|
+
now: typeof state.now === "number" && Number.isFinite(state.now) ? state.now : null,
|
|
15055
|
+
advance_ms: typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms) ? payload.advance_ms : null,
|
|
15056
|
+
};
|
|
15057
|
+
}, { random_queue: randomQueue, now, advance_ms: advanceMs, append, restore });
|
|
15058
|
+
return {
|
|
15059
|
+
...base,
|
|
15060
|
+
...setupScopeEvidence(scope),
|
|
15061
|
+
ok: runtimeResult && runtimeResult.ok === true,
|
|
15062
|
+
random_enabled: runtimeResult?.random_enabled,
|
|
15063
|
+
random_queue_added: runtimeResult?.random_queue_added,
|
|
15064
|
+
random_queue_length: runtimeResult?.random_queue_length,
|
|
15065
|
+
random_queue_mode: runtimeResult?.random_queue_mode,
|
|
15066
|
+
random_underflow_count: runtimeResult?.random_underflow_count,
|
|
15067
|
+
clock_enabled: runtimeResult?.clock_enabled,
|
|
15068
|
+
previous_now: runtimeResult?.previous_now,
|
|
15069
|
+
now: runtimeResult?.now,
|
|
15070
|
+
advance_ms: runtimeResult?.advance_ms,
|
|
15071
|
+
restored: runtimeResult?.restored,
|
|
15072
|
+
reason: runtimeResult && runtimeResult.ok === true ? undefined : runtimeResult?.reason || "deterministic_runtime_not_applied",
|
|
15073
|
+
};
|
|
15074
|
+
}
|
|
14877
15075
|
if (type === "window_eval") {
|
|
14878
15076
|
const script = String(action.script || action.code || action.source || action.body || "");
|
|
14879
15077
|
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-
|
|
65
|
+
} from "./chunk-5ELOMJ7U.js";
|
|
66
66
|
import {
|
|
67
67
|
DEFAULT_RIDDLE_API_BASE_URL,
|
|
68
68
|
DEFAULT_RIDDLE_API_KEY_FILE,
|
package/dist/profile.cjs
CHANGED
|
@@ -96,6 +96,7 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
|
96
96
|
"fill",
|
|
97
97
|
"set_input_value",
|
|
98
98
|
"set_range_value",
|
|
99
|
+
"deterministic_runtime",
|
|
99
100
|
"canvas_signature",
|
|
100
101
|
"assert_text_visible",
|
|
101
102
|
"assert_text_absent",
|
|
@@ -558,6 +559,23 @@ function profileSetupWindowEvalReceipts(results) {
|
|
|
558
559
|
return receipt;
|
|
559
560
|
});
|
|
560
561
|
}
|
|
562
|
+
function profileSetupDeterministicRuntimeReceipts(results) {
|
|
563
|
+
return results.filter((result) => profileSetupResultAction(result) === "deterministic_runtime").map((result) => ({
|
|
564
|
+
ordinal: result.ordinal ?? null,
|
|
565
|
+
ok: result.ok !== false,
|
|
566
|
+
random_enabled: result.random_enabled ?? null,
|
|
567
|
+
random_queue_added: result.random_queue_added ?? null,
|
|
568
|
+
random_queue_length: result.random_queue_length ?? null,
|
|
569
|
+
random_queue_mode: result.random_queue_mode ?? null,
|
|
570
|
+
random_underflow_count: result.random_underflow_count ?? null,
|
|
571
|
+
clock_enabled: result.clock_enabled ?? null,
|
|
572
|
+
previous_now: result.previous_now ?? null,
|
|
573
|
+
now: result.now ?? null,
|
|
574
|
+
advance_ms: result.advance_ms ?? null,
|
|
575
|
+
restored: result.restored ?? null,
|
|
576
|
+
reason: result.reason ?? result.error ?? null
|
|
577
|
+
}));
|
|
578
|
+
}
|
|
561
579
|
function profileSetupReturnSummaryFields(result) {
|
|
562
580
|
const input = result.return_summary_fields;
|
|
563
581
|
if (!Array.isArray(input)) return [];
|
|
@@ -772,6 +790,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
772
790
|
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
773
791
|
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
774
792
|
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
793
|
+
const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
|
|
794
|
+
const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
|
|
775
795
|
const rangeValueReceipts = profileSetupRangeValueReceipts(results);
|
|
776
796
|
const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
|
|
777
797
|
const dragReceipts = profileSetupDragReceipts(results);
|
|
@@ -831,6 +851,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
831
851
|
window_eval_captured_total: windowEvalCapturedTotal,
|
|
832
852
|
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
833
853
|
window_eval: sampledWindowEvalReceipts,
|
|
854
|
+
deterministic_runtime_total: deterministicRuntimeReceipts.length,
|
|
855
|
+
deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
|
|
856
|
+
deterministic_runtime: sampledDeterministicRuntimeReceipts,
|
|
834
857
|
set_range_value_total: rangeValueReceipts.length,
|
|
835
858
|
set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
|
|
836
859
|
set_range_value: sampledRangeValueReceipts,
|
|
@@ -893,7 +916,7 @@ function isSupportedCheckType(value) {
|
|
|
893
916
|
}
|
|
894
917
|
function normalizeSetupActionType(value, index) {
|
|
895
918
|
const normalizedInput = String(value || "").trim().replace(/-/g, "_");
|
|
896
|
-
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;
|
|
919
|
+
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;
|
|
897
920
|
if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
|
|
898
921
|
return normalized;
|
|
899
922
|
}
|
|
@@ -1012,6 +1035,39 @@ function normalizeSetupActionScreenshotFullPage(input, type, index) {
|
|
|
1012
1035
|
}
|
|
1013
1036
|
return values[0];
|
|
1014
1037
|
}
|
|
1038
|
+
function normalizeSetupActionRandomQueue(input, index) {
|
|
1039
|
+
const rawQueue = valueFromOwn(
|
|
1040
|
+
input,
|
|
1041
|
+
"random_queue",
|
|
1042
|
+
"randomQueue",
|
|
1043
|
+
"random_values",
|
|
1044
|
+
"randomValues",
|
|
1045
|
+
"random_sequence",
|
|
1046
|
+
"randomSequence",
|
|
1047
|
+
"math_random",
|
|
1048
|
+
"mathRandom"
|
|
1049
|
+
);
|
|
1050
|
+
if (rawQueue === void 0) return void 0;
|
|
1051
|
+
if (!Array.isArray(rawQueue) || rawQueue.length === 0) {
|
|
1052
|
+
throw new Error(`target.setup_actions[${index}].random_queue must be a non-empty array of numbers from 0 inclusive to 1 exclusive.`);
|
|
1053
|
+
}
|
|
1054
|
+
return rawQueue.map((item, queueIndex) => {
|
|
1055
|
+
const value = numberValue(item);
|
|
1056
|
+
if (value === void 0 || value < 0 || value >= 1) {
|
|
1057
|
+
throw new Error(`target.setup_actions[${index}].random_queue[${queueIndex}] must be a finite number from 0 inclusive to 1 exclusive.`);
|
|
1058
|
+
}
|
|
1059
|
+
return value;
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function normalizeSetupActionNonNegativeNumber(input, index, outputKey, ...keys) {
|
|
1063
|
+
const rawValue = valueFromOwn(input, ...keys);
|
|
1064
|
+
if (rawValue === void 0) return void 0;
|
|
1065
|
+
const value = numberValue(rawValue);
|
|
1066
|
+
if (value === void 0 || value < 0) {
|
|
1067
|
+
throw new Error(`target.setup_actions[${index}].${outputKey} must be a finite non-negative number.`);
|
|
1068
|
+
}
|
|
1069
|
+
return value;
|
|
1070
|
+
}
|
|
1015
1071
|
function normalizeSetupAction(input, index) {
|
|
1016
1072
|
if (!isRecord(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
|
|
1017
1073
|
const type = normalizeSetupActionType(stringValue(input.type), index);
|
|
@@ -1072,6 +1128,14 @@ function normalizeSetupAction(input, index) {
|
|
|
1072
1128
|
if ((type === "fill" || type === "set_input_value" || type === "set_range_value") && value === void 0 && !hasJsonValue) {
|
|
1073
1129
|
throw new Error(`target.setup_actions[${index}] ${type} requires value.`);
|
|
1074
1130
|
}
|
|
1131
|
+
const randomQueue = type === "deterministic_runtime" ? normalizeSetupActionRandomQueue(input, index) : void 0;
|
|
1132
|
+
const deterministicNow = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "now", "now", "date_now", "dateNow", "mock_now", "mockNow", "clock", "timestamp", "time_ms", "timeMs") : void 0;
|
|
1133
|
+
const deterministicAdvanceMs = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "advance_ms", "advance_ms", "advanceMs", "tick_ms", "tickMs", "add_ms", "addMs") : void 0;
|
|
1134
|
+
const deterministicAppend = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "append", "append_random", "appendRandom")) === true;
|
|
1135
|
+
const deterministicRestore = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "restore", "reset", "restore_originals", "restoreOriginals")) === true;
|
|
1136
|
+
if (type === "deterministic_runtime" && randomQueue === void 0 && deterministicNow === void 0 && deterministicAdvanceMs === void 0 && !deterministicRestore) {
|
|
1137
|
+
throw new Error(`target.setup_actions[${index}] deterministic_runtime requires random_queue, now, advance_ms, or restore.`);
|
|
1138
|
+
}
|
|
1075
1139
|
const key = stringValue(input.key);
|
|
1076
1140
|
let dialogAccept;
|
|
1077
1141
|
if (type === "dialog_response") {
|
|
@@ -1179,6 +1243,11 @@ function normalizeSetupAction(input, index) {
|
|
|
1179
1243
|
key,
|
|
1180
1244
|
value,
|
|
1181
1245
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
1246
|
+
random_queue: randomQueue,
|
|
1247
|
+
now: deterministicNow,
|
|
1248
|
+
advance_ms: deterministicAdvanceMs,
|
|
1249
|
+
append: deterministicAppend || void 0,
|
|
1250
|
+
restore: deterministicRestore || void 0,
|
|
1182
1251
|
label: stringFromOwn(input, "label", "name", "screenshot_label", "screenshotLabel"),
|
|
1183
1252
|
script,
|
|
1184
1253
|
path,
|
|
@@ -4255,6 +4324,25 @@ function profileSetupWindowEvalReceipts(results) {
|
|
|
4255
4324
|
return receipt;
|
|
4256
4325
|
});
|
|
4257
4326
|
}
|
|
4327
|
+
function profileSetupDeterministicRuntimeReceipts(results) {
|
|
4328
|
+
return (results || [])
|
|
4329
|
+
.filter((result) => result && profileSetupResultAction(result) === "deterministic_runtime")
|
|
4330
|
+
.map((result) => ({
|
|
4331
|
+
ordinal: result.ordinal ?? null,
|
|
4332
|
+
ok: result.ok !== false,
|
|
4333
|
+
random_enabled: result.random_enabled ?? null,
|
|
4334
|
+
random_queue_added: result.random_queue_added ?? null,
|
|
4335
|
+
random_queue_length: result.random_queue_length ?? null,
|
|
4336
|
+
random_queue_mode: result.random_queue_mode ?? null,
|
|
4337
|
+
random_underflow_count: result.random_underflow_count ?? null,
|
|
4338
|
+
clock_enabled: result.clock_enabled ?? null,
|
|
4339
|
+
previous_now: result.previous_now ?? null,
|
|
4340
|
+
now: result.now ?? null,
|
|
4341
|
+
advance_ms: result.advance_ms ?? null,
|
|
4342
|
+
restored: result.restored ?? null,
|
|
4343
|
+
reason: result.reason || result.error || null,
|
|
4344
|
+
}));
|
|
4345
|
+
}
|
|
4258
4346
|
function profileSetupReturnSummaryFields(result) {
|
|
4259
4347
|
const input = result && result.return_summary_fields;
|
|
4260
4348
|
if (!Array.isArray(input)) return [];
|
|
@@ -4498,6 +4586,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
4498
4586
|
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
4499
4587
|
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
4500
4588
|
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
4589
|
+
const deterministicRuntimeReceipts = profileSetupDeterministicRuntimeReceipts(results);
|
|
4590
|
+
const sampledDeterministicRuntimeReceipts = sampleProfileSetupSummaryItems(deterministicRuntimeReceipts, 8);
|
|
4501
4591
|
const rangeValueReceipts = profileSetupRangeValueReceipts(results);
|
|
4502
4592
|
const sampledRangeValueReceipts = sampleProfileSetupSummaryItems(rangeValueReceipts, 8);
|
|
4503
4593
|
const dragReceipts = profileSetupDragReceipts(results);
|
|
@@ -4567,6 +4657,9 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
4567
4657
|
window_eval_captured_total: windowEvalCapturedTotal,
|
|
4568
4658
|
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
4569
4659
|
window_eval: sampledWindowEvalReceipts,
|
|
4660
|
+
deterministic_runtime_total: deterministicRuntimeReceipts.length,
|
|
4661
|
+
deterministic_runtime_truncated: deterministicRuntimeReceipts.length > sampledDeterministicRuntimeReceipts.length,
|
|
4662
|
+
deterministic_runtime: sampledDeterministicRuntimeReceipts,
|
|
4570
4663
|
set_range_value_total: rangeValueReceipts.length,
|
|
4571
4664
|
set_range_value_truncated: rangeValueReceipts.length > sampledRangeValueReceipts.length,
|
|
4572
4665
|
set_range_value: sampledRangeValueReceipts,
|
|
@@ -6188,6 +6281,111 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
6188
6281
|
}
|
|
6189
6282
|
return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
|
|
6190
6283
|
}
|
|
6284
|
+
if (type === "deterministic_runtime") {
|
|
6285
|
+
const scope = await setupActionScope(action, timeout);
|
|
6286
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
6287
|
+
const randomQueue = Array.isArray(action.random_queue)
|
|
6288
|
+
? action.random_queue
|
|
6289
|
+
: Array.isArray(action.randomQueue)
|
|
6290
|
+
? action.randomQueue
|
|
6291
|
+
: null;
|
|
6292
|
+
const now = setupFiniteNumber(action.now ?? action.date_now ?? action.dateNow ?? action.mock_now ?? action.mockNow ?? action.clock ?? action.timestamp ?? action.time_ms ?? action.timeMs);
|
|
6293
|
+
const advanceMs = setupFiniteNumber(action.advance_ms ?? action.advanceMs ?? action.tick_ms ?? action.tickMs ?? action.add_ms ?? action.addMs);
|
|
6294
|
+
const append = action.append === true || action.append_random === true || action.appendRandom === true;
|
|
6295
|
+
const restore = action.restore === true || action.reset === true || action.restore_originals === true || action.restoreOriginals === true;
|
|
6296
|
+
const runtimeResult = await scope.context.evaluate((payload) => {
|
|
6297
|
+
const root = window;
|
|
6298
|
+
const stateKey = "__RIDDLE_PROOF_DETERMINISTIC_RUNTIME__";
|
|
6299
|
+
const state = root[stateKey] && typeof root[stateKey] === "object" && !Array.isArray(root[stateKey])
|
|
6300
|
+
? root[stateKey]
|
|
6301
|
+
: {};
|
|
6302
|
+
root[stateKey] = state;
|
|
6303
|
+
if (typeof state.originalRandom !== "function") state.originalRandom = Math.random;
|
|
6304
|
+
if (typeof state.originalDateNow !== "function") state.originalDateNow = Date.now;
|
|
6305
|
+
const previousNow = typeof state.now === "number" && Number.isFinite(state.now)
|
|
6306
|
+
? state.now
|
|
6307
|
+
: Date.now === state.originalDateNow
|
|
6308
|
+
? null
|
|
6309
|
+
: Date.now();
|
|
6310
|
+
if (payload.restore) {
|
|
6311
|
+
Math.random = state.originalRandom;
|
|
6312
|
+
Date.now = state.originalDateNow;
|
|
6313
|
+
delete root[stateKey];
|
|
6314
|
+
return {
|
|
6315
|
+
ok: true,
|
|
6316
|
+
restored: true,
|
|
6317
|
+
random_enabled: false,
|
|
6318
|
+
random_queue_added: 0,
|
|
6319
|
+
random_queue_length: 0,
|
|
6320
|
+
random_queue_mode: null,
|
|
6321
|
+
random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
|
|
6322
|
+
clock_enabled: false,
|
|
6323
|
+
previous_now: previousNow,
|
|
6324
|
+
now: null,
|
|
6325
|
+
advance_ms: null,
|
|
6326
|
+
};
|
|
6327
|
+
}
|
|
6328
|
+
let randomQueueAdded = null;
|
|
6329
|
+
let randomQueueMode = null;
|
|
6330
|
+
if (Array.isArray(payload.random_queue)) {
|
|
6331
|
+
const queue = payload.random_queue.filter((value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value < 1);
|
|
6332
|
+
const existing = Array.isArray(state.randomQueue) ? state.randomQueue : [];
|
|
6333
|
+
state.randomQueue = payload.append ? existing.concat(queue) : queue.slice();
|
|
6334
|
+
randomQueueAdded = queue.length;
|
|
6335
|
+
randomQueueMode = payload.append ? "append" : "replace";
|
|
6336
|
+
Math.random = function riddleProofMockRandom() {
|
|
6337
|
+
const activeQueue = Array.isArray(state.randomQueue) ? state.randomQueue : [];
|
|
6338
|
+
if (activeQueue.length) return activeQueue.shift();
|
|
6339
|
+
state.randomUnderflowCount = (typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0) + 1;
|
|
6340
|
+
return 0;
|
|
6341
|
+
};
|
|
6342
|
+
}
|
|
6343
|
+
if (typeof payload.now === "number" && Number.isFinite(payload.now)) {
|
|
6344
|
+
state.now = payload.now;
|
|
6345
|
+
Date.now = function riddleProofMockDateNow() {
|
|
6346
|
+
return state.now;
|
|
6347
|
+
};
|
|
6348
|
+
}
|
|
6349
|
+
if (typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms)) {
|
|
6350
|
+
const baseNow = typeof state.now === "number" && Number.isFinite(state.now)
|
|
6351
|
+
? state.now
|
|
6352
|
+
: Date.now();
|
|
6353
|
+
state.now = baseNow + payload.advance_ms;
|
|
6354
|
+
Date.now = function riddleProofMockDateNow() {
|
|
6355
|
+
return state.now;
|
|
6356
|
+
};
|
|
6357
|
+
}
|
|
6358
|
+
return {
|
|
6359
|
+
ok: true,
|
|
6360
|
+
restored: false,
|
|
6361
|
+
random_enabled: Math.random !== state.originalRandom,
|
|
6362
|
+
random_queue_added: randomQueueAdded,
|
|
6363
|
+
random_queue_length: Array.isArray(state.randomQueue) ? state.randomQueue.length : 0,
|
|
6364
|
+
random_queue_mode: randomQueueMode,
|
|
6365
|
+
random_underflow_count: typeof state.randomUnderflowCount === "number" ? state.randomUnderflowCount : 0,
|
|
6366
|
+
clock_enabled: Date.now !== state.originalDateNow,
|
|
6367
|
+
previous_now: previousNow,
|
|
6368
|
+
now: typeof state.now === "number" && Number.isFinite(state.now) ? state.now : null,
|
|
6369
|
+
advance_ms: typeof payload.advance_ms === "number" && Number.isFinite(payload.advance_ms) ? payload.advance_ms : null,
|
|
6370
|
+
};
|
|
6371
|
+
}, { random_queue: randomQueue, now, advance_ms: advanceMs, append, restore });
|
|
6372
|
+
return {
|
|
6373
|
+
...base,
|
|
6374
|
+
...setupScopeEvidence(scope),
|
|
6375
|
+
ok: runtimeResult && runtimeResult.ok === true,
|
|
6376
|
+
random_enabled: runtimeResult?.random_enabled,
|
|
6377
|
+
random_queue_added: runtimeResult?.random_queue_added,
|
|
6378
|
+
random_queue_length: runtimeResult?.random_queue_length,
|
|
6379
|
+
random_queue_mode: runtimeResult?.random_queue_mode,
|
|
6380
|
+
random_underflow_count: runtimeResult?.random_underflow_count,
|
|
6381
|
+
clock_enabled: runtimeResult?.clock_enabled,
|
|
6382
|
+
previous_now: runtimeResult?.previous_now,
|
|
6383
|
+
now: runtimeResult?.now,
|
|
6384
|
+
advance_ms: runtimeResult?.advance_ms,
|
|
6385
|
+
restored: runtimeResult?.restored,
|
|
6386
|
+
reason: runtimeResult && runtimeResult.ok === true ? undefined : runtimeResult?.reason || "deterministic_runtime_not_applied",
|
|
6387
|
+
};
|
|
6388
|
+
}
|
|
6191
6389
|
if (type === "window_eval") {
|
|
6192
6390
|
const script = String(action.script || action.code || action.source || action.body || "");
|
|
6193
6391
|
const args = Array.isArray(action.args) ? action.args : [];
|
package/dist/profile.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
|
|
|
5
5
|
declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
|
|
6
6
|
declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
|
|
7
7
|
declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "url_search_param_equals", "url_search_param_absent", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "dialog_count_equals", "dialog_accept_count_equals", "dialog_dismiss_count_equals", "selector_text_visible", "selector_text_absent", "selector_text_order", "observe_within", "frame_text_visible", "frame_url_equals", "frame_url_matches", "frame_no_horizontal_overflow", "text_visible", "text_absent", "http_status", "link_status", "artifact_link_status", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors", "no_console_warnings"];
|
|
8
|
-
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "set_range_value", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
8
|
+
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
9
9
|
type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
|
|
10
10
|
type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
|
|
11
11
|
type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
|
|
@@ -126,6 +126,11 @@ interface RiddleProofProfileSetupAction {
|
|
|
126
126
|
key?: string;
|
|
127
127
|
value?: string;
|
|
128
128
|
value_json?: JsonValue;
|
|
129
|
+
random_queue?: number[];
|
|
130
|
+
now?: number;
|
|
131
|
+
advance_ms?: number;
|
|
132
|
+
append?: boolean;
|
|
133
|
+
restore?: boolean;
|
|
129
134
|
label?: string;
|
|
130
135
|
script?: string;
|
|
131
136
|
path?: string;
|
package/dist/profile.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
|
|
|
5
5
|
declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
|
|
6
6
|
declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
|
|
7
7
|
declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "url_search_param_equals", "url_search_param_absent", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "dialog_count_equals", "dialog_accept_count_equals", "dialog_dismiss_count_equals", "selector_text_visible", "selector_text_absent", "selector_text_order", "observe_within", "frame_text_visible", "frame_url_equals", "frame_url_matches", "frame_no_horizontal_overflow", "text_visible", "text_absent", "http_status", "link_status", "artifact_link_status", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors", "no_console_warnings"];
|
|
8
|
-
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "set_range_value", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
8
|
+
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "set_range_value", "deterministic_runtime", "canvas_signature", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
9
9
|
type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
|
|
10
10
|
type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
|
|
11
11
|
type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
|
|
@@ -126,6 +126,11 @@ interface RiddleProofProfileSetupAction {
|
|
|
126
126
|
key?: string;
|
|
127
127
|
value?: string;
|
|
128
128
|
value_json?: JsonValue;
|
|
129
|
+
random_queue?: number[];
|
|
130
|
+
now?: number;
|
|
131
|
+
advance_ms?: number;
|
|
132
|
+
append?: boolean;
|
|
133
|
+
restore?: boolean;
|
|
129
134
|
label?: string;
|
|
130
135
|
script?: string;
|
|
131
136
|
path?: string;
|
package/dist/profile.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
resolveRiddleProofProfileTimeoutSec,
|
|
24
24
|
slugifyRiddleProofProfileName,
|
|
25
25
|
summarizeRiddleProofProfileResult
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-5ELOMJ7U.js";
|
|
27
27
|
export {
|
|
28
28
|
RIDDLE_PROOF_PROFILE_CHECK_TYPES,
|
|
29
29
|
RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
|