@riddledc/riddle-proof 0.8.78 → 0.8.80

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.
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var profile_exports = {};
22
22
  __export(profile_exports, {
23
23
  RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS: () => RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS,
24
+ RIDDLE_PROOF_ORDERED_TRACE_OPERATORS: () => RIDDLE_PROOF_ORDERED_TRACE_OPERATORS,
24
25
  RIDDLE_PROOF_PROFILE_CHECK_TYPES: () => RIDDLE_PROOF_PROFILE_CHECK_TYPES,
25
26
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: () => RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
26
27
  RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES: () => RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES,
@@ -29,6 +30,8 @@ __export(profile_exports, {
29
30
  RIDDLE_PROOF_PROFILE_STATUSES: () => RIDDLE_PROOF_PROFILE_STATUSES,
30
31
  RIDDLE_PROOF_PROFILE_VERSION: () => RIDDLE_PROOF_PROFILE_VERSION,
31
32
  applyRiddleProofProfileArtifactCompleteness: () => applyRiddleProofProfileArtifactCompleteness,
33
+ assessRiddleProofOrderedTrace: () => assessRiddleProofOrderedTrace,
34
+ assessRiddleProofOrderedTraceSetupResults: () => assessRiddleProofOrderedTraceSetupResults,
32
35
  assessRiddleProofProfileArtifactCompleteness: () => assessRiddleProofProfileArtifactCompleteness,
33
36
  assessRiddleProofProfileEvidence: () => assessRiddleProofProfileEvidence,
34
37
  buildRiddleProofProfileScript: () => buildRiddleProofProfileScript,
@@ -79,6 +82,7 @@ var RIDDLE_PROOF_PROFILE_CHECK_TYPES = [
79
82
  "selector_text_visible",
80
83
  "selector_text_absent",
81
84
  "selector_text_order",
85
+ "ordered_trace",
82
86
  "observe_within",
83
87
  "frame_text_visible",
84
88
  "frame_url_equals",
@@ -142,6 +146,21 @@ var RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES = [
142
146
  "timedout",
143
147
  "failed"
144
148
  ];
149
+ var RIDDLE_PROOF_ORDERED_TRACE_OPERATORS = [
150
+ "exists",
151
+ "equals",
152
+ "not_equals",
153
+ "truthy",
154
+ "falsy",
155
+ "gt",
156
+ "gte",
157
+ "lt",
158
+ "lte",
159
+ "abs_gt",
160
+ "abs_gte",
161
+ "abs_lt",
162
+ "abs_lte"
163
+ ];
145
164
  function uniqueNonEmptyStrings(values) {
146
165
  const seen = /* @__PURE__ */ new Set();
147
166
  const result = [];
@@ -433,6 +452,185 @@ function resolveJsonPath(root, path) {
433
452
  }
434
453
  return { exists: true, value: current };
435
454
  }
455
+ function assessRiddleProofOrderedTrace(trace, events) {
456
+ const insufficient = (reason, traceLength = Array.isArray(trace) ? trace.length : 0, witnesses2 = [], missingEvent, missingPaths) => ({
457
+ version: "riddle-proof.ordered-trace-assessment.v1",
458
+ status: "proof_insufficient",
459
+ trace_length: traceLength,
460
+ witnesses: witnesses2,
461
+ missing_event: missingEvent,
462
+ missing_paths: missingPaths,
463
+ reason
464
+ });
465
+ const parsePath = (path) => {
466
+ const segments = [];
467
+ let token = "";
468
+ const pushToken = () => {
469
+ const value = token.trim();
470
+ if (value) segments.push(value);
471
+ token = "";
472
+ };
473
+ for (let index = 0; index < path.length; index += 1) {
474
+ const char = path[index];
475
+ if (char === ".") {
476
+ pushToken();
477
+ continue;
478
+ }
479
+ if (char !== "[") {
480
+ token += char;
481
+ continue;
482
+ }
483
+ pushToken();
484
+ const closeIndex = path.indexOf("]", index + 1);
485
+ if (closeIndex === -1) throw new Error(`unterminated bracket at ${index}`);
486
+ const bracket = path.slice(index + 1, closeIndex).trim();
487
+ if (!bracket) throw new Error(`empty bracket at ${index}`);
488
+ if (/^\d+$/.test(bracket)) {
489
+ segments.push(Number(bracket));
490
+ } else {
491
+ segments.push(bracket.replace(/^['"]|['"]$/g, ""));
492
+ }
493
+ index = closeIndex;
494
+ }
495
+ pushToken();
496
+ return segments;
497
+ };
498
+ const resolve = (root, path) => {
499
+ let segments;
500
+ try {
501
+ segments = parsePath(path);
502
+ } catch {
503
+ return { exists: false };
504
+ }
505
+ let current = root;
506
+ for (const segment of segments) {
507
+ if (Array.isArray(current)) {
508
+ const index = typeof segment === "number" ? segment : /^\d+$/.test(segment) ? Number(segment) : -1;
509
+ if (index < 0 || index >= current.length) return { exists: false };
510
+ current = current[index];
511
+ continue;
512
+ }
513
+ if (typeof segment !== "string" || current === null || typeof current !== "object") return { exists: false };
514
+ if (!Object.hasOwn(current, segment)) return { exists: false };
515
+ current = current[segment];
516
+ }
517
+ return { exists: true, value: current };
518
+ };
519
+ const valuesEqual = (left, right) => {
520
+ if (Object.is(left, right)) return true;
521
+ if (Array.isArray(left) || Array.isArray(right)) {
522
+ return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => valuesEqual(value, right[index]));
523
+ }
524
+ if (left === null || right === null || typeof left !== "object" || typeof right !== "object") return false;
525
+ const leftRecord = left;
526
+ const rightRecord = right;
527
+ const leftKeys = Object.keys(leftRecord).sort();
528
+ const rightKeys = Object.keys(rightRecord).sort();
529
+ return leftKeys.length === rightKeys.length && leftKeys.every((key, index) => key === rightKeys[index] && valuesEqual(leftRecord[key], rightRecord[key]));
530
+ };
531
+ const numericOperator = (op) => [
532
+ "gt",
533
+ "gte",
534
+ "lt",
535
+ "lte",
536
+ "abs_gt",
537
+ "abs_gte",
538
+ "abs_lt",
539
+ "abs_lte"
540
+ ].includes(op);
541
+ const matches = (value, predicate) => {
542
+ if (predicate.op === "exists") return true;
543
+ if (predicate.op === "equals") return valuesEqual(value, predicate.value);
544
+ if (predicate.op === "not_equals") return !valuesEqual(value, predicate.value);
545
+ if (predicate.op === "truthy") return Boolean(value);
546
+ if (predicate.op === "falsy") return !value;
547
+ const observed = typeof value === "number" ? value : Number.NaN;
548
+ const expected = typeof predicate.value === "number" ? predicate.value : Number.NaN;
549
+ if (!Number.isFinite(observed) || !Number.isFinite(expected)) return false;
550
+ const candidate = predicate.op.startsWith("abs_") ? Math.abs(observed) : observed;
551
+ if (predicate.op === "gt" || predicate.op === "abs_gt") return candidate > expected;
552
+ if (predicate.op === "gte" || predicate.op === "abs_gte") return candidate >= expected;
553
+ if (predicate.op === "lt" || predicate.op === "abs_lt") return candidate < expected;
554
+ return candidate <= expected;
555
+ };
556
+ if (!Array.isArray(trace) || trace.length === 0) return insufficient("trace_missing_or_empty");
557
+ if (!Array.isArray(events) || events.length === 0) return insufficient("events_missing", trace.length);
558
+ for (const event of events) {
559
+ const missingPaths = event.predicates.filter((predicate) => !trace.some((sample) => {
560
+ const resolved = resolve(sample, predicate.path);
561
+ return resolved.exists && (!numericOperator(predicate.op) || typeof resolved.value === "number" && Number.isFinite(resolved.value));
562
+ })).map((predicate) => predicate.path);
563
+ if (missingPaths.length) {
564
+ return insufficient("required_trace_field_missing", trace.length, [], event.label, Array.from(new Set(missingPaths)));
565
+ }
566
+ }
567
+ const witnesses = [];
568
+ let cursor = 0;
569
+ for (const event of events) {
570
+ let witnessIndex = -1;
571
+ for (let index = cursor; index < trace.length; index += 1) {
572
+ if (event.predicates.every((predicate) => {
573
+ const resolved = resolve(trace[index], predicate.path);
574
+ return resolved.exists && matches(resolved.value, predicate);
575
+ })) {
576
+ witnessIndex = index;
577
+ break;
578
+ }
579
+ }
580
+ if (witnessIndex < 0) {
581
+ return {
582
+ version: "riddle-proof.ordered-trace-assessment.v1",
583
+ status: "failed",
584
+ trace_length: trace.length,
585
+ witnesses,
586
+ missing_event: event.label,
587
+ reason: "ordered_event_not_observed"
588
+ };
589
+ }
590
+ witnesses.push({
591
+ label: event.label,
592
+ index: witnessIndex,
593
+ observations: event.predicates.map((predicate) => {
594
+ const observed = resolve(trace[witnessIndex], predicate.path).value;
595
+ return {
596
+ path: predicate.path,
597
+ op: predicate.op,
598
+ expected: predicate.value,
599
+ observed
600
+ };
601
+ })
602
+ });
603
+ cursor = witnessIndex + 1;
604
+ }
605
+ return {
606
+ version: "riddle-proof.ordered-trace-assessment.v1",
607
+ status: "passed",
608
+ trace_length: trace.length,
609
+ witnesses
610
+ };
611
+ }
612
+ function assessRiddleProofOrderedTraceSetupResults(results, setupActionLabel, tracePath, events) {
613
+ const insufficient = (reason) => ({
614
+ version: "riddle-proof.ordered-trace-assessment.v1",
615
+ status: "proof_insufficient",
616
+ trace_length: 0,
617
+ witnesses: [],
618
+ reason
619
+ });
620
+ if (!Array.isArray(results)) return insufficient("setup_results_missing");
621
+ const source = results.find((item) => item && typeof item === "object" && !Array.isArray(item) && item.label === setupActionLabel);
622
+ if (!source) return insufficient("setup_action_result_missing");
623
+ if (!Object.hasOwn(source, "returned")) return insufficient("setup_action_return_missing");
624
+ const segments = tracePath.split(".").map((segment) => segment.trim()).filter(Boolean);
625
+ let trace = source.returned;
626
+ for (const segment of segments) {
627
+ if (trace === null || typeof trace !== "object" || Array.isArray(trace) || !Object.hasOwn(trace, segment)) {
628
+ return insufficient("trace_path_missing");
629
+ }
630
+ trace = trace[segment];
631
+ }
632
+ return assessRiddleProofOrderedTrace(trace, events);
633
+ }
436
634
  function evaluateHttpStatusBodyJsonAssertion(root, assertion) {
437
635
  const resolved = resolveJsonPath(root, assertion.path);
438
636
  const errors = [];
@@ -539,6 +737,7 @@ function profileSetupWindowCallReceipts(results) {
539
737
  return results.filter((result) => profileSetupResultAction(result) === "window_call").map((result) => {
540
738
  const receipt = {
541
739
  ordinal: result.ordinal ?? null,
740
+ label: result.label ?? null,
542
741
  ok: result.ok !== false,
543
742
  path: result.path ?? null,
544
743
  return_captured: result.return_captured ?? null,
@@ -557,6 +756,7 @@ function profileSetupWindowEvalReceipts(results) {
557
756
  return results.filter((result) => profileSetupResultAction(result) === "window_eval").map((result) => {
558
757
  const receipt = {
559
758
  ordinal: result.ordinal ?? null,
759
+ label: result.label ?? null,
560
760
  ok: result.ok !== false,
561
761
  script_length: result.script_length ?? null,
562
762
  return_captured: result.return_captured ?? null,
@@ -1829,6 +2029,51 @@ function dialogCountFieldForCheckType(type) {
1829
2029
  if (type === "dialog_dismiss_count_equals") return "dialog_dismiss_count";
1830
2030
  return "dialog_count";
1831
2031
  }
2032
+ function normalizeOrderedTraceEvents(value, label) {
2033
+ if (value === void 0) return void 0;
2034
+ if (!Array.isArray(value) || !value.length) throw new Error(`${label} must be a non-empty array.`);
2035
+ const seenLabels = /* @__PURE__ */ new Set();
2036
+ return value.map((item, eventIndex) => {
2037
+ const eventLabel = `${label}[${eventIndex}]`;
2038
+ if (!isRecord(item)) throw new Error(`${eventLabel} must be an object.`);
2039
+ const name = stringFromOwn(item, "label", "name", "event");
2040
+ if (!name) throw new Error(`${eventLabel}.label is required.`);
2041
+ if (seenLabels.has(name)) throw new Error(`${eventLabel}.label must be unique.`);
2042
+ seenLabels.add(name);
2043
+ const predicatesInput = item.predicates ?? item.all ?? item.where;
2044
+ if (!Array.isArray(predicatesInput) || !predicatesInput.length) {
2045
+ throw new Error(`${eventLabel}.predicates must be a non-empty array.`);
2046
+ }
2047
+ const predicates = predicatesInput.map((predicateInput, predicateIndex) => {
2048
+ const predicateLabel = `${eventLabel}.predicates[${predicateIndex}]`;
2049
+ if (!isRecord(predicateInput)) throw new Error(`${predicateLabel} must be an object.`);
2050
+ const path = stringFromOwn(predicateInput, "path", "field", "key");
2051
+ if (!path) throw new Error(`${predicateLabel}.path is required.`);
2052
+ const op = stringFromOwn(predicateInput, "op", "operator");
2053
+ if (!op || !RIDDLE_PROOF_ORDERED_TRACE_OPERATORS.includes(op)) {
2054
+ throw new Error(`${predicateLabel}.op must be one of ${RIDDLE_PROOF_ORDERED_TRACE_OPERATORS.join(", ")}.`);
2055
+ }
2056
+ const requiresValue = !["exists", "truthy", "falsy"].includes(op);
2057
+ const hasValue = hasOwn(predicateInput, "value") || hasOwn(predicateInput, "expected");
2058
+ if (requiresValue && !hasValue) throw new Error(`${predicateLabel}.value is required for ${op}.`);
2059
+ const value2 = hasOwn(predicateInput, "value") ? predicateInput.value : predicateInput.expected;
2060
+ if (["gt", "gte", "lt", "lte", "abs_gt", "abs_gte", "abs_lt", "abs_lte"].includes(op)) {
2061
+ if (typeof value2 !== "number" || !Number.isFinite(value2)) {
2062
+ throw new Error(`${predicateLabel}.value must be a finite number for ${op}.`);
2063
+ }
2064
+ if (op.startsWith("abs_") && value2 < 0) {
2065
+ throw new Error(`${predicateLabel}.value must be non-negative for ${op}.`);
2066
+ }
2067
+ }
2068
+ return {
2069
+ path,
2070
+ op,
2071
+ value: requiresValue ? toJsonValue(value2) : void 0
2072
+ };
2073
+ });
2074
+ return { label: name, predicates };
2075
+ });
2076
+ }
1832
2077
  function normalizeCheck(input, index) {
1833
2078
  if (!isRecord(input)) throw new Error(`checks[${index}] must be an object.`);
1834
2079
  const type = stringValue(input.type);
@@ -1879,6 +2124,17 @@ function normalizeCheck(input, index) {
1879
2124
  if (!stringValue(input.selector)) throw new Error(`checks[${index}] selector_text_order requires selector.`);
1880
2125
  if (!expectedTexts?.length) throw new Error(`checks[${index}] selector_text_order requires expected_texts.`);
1881
2126
  }
2127
+ const setupActionLabel = stringFromOwn(input, "setup_action_label", "setupActionLabel", "source_action_label", "sourceActionLabel");
2128
+ const tracePath = stringFromOwn(input, "trace_path", "tracePath", "path");
2129
+ const orderedTraceEvents = normalizeOrderedTraceEvents(
2130
+ input.events ?? input.sequence ?? input.ordered_events ?? input.orderedEvents,
2131
+ `checks[${index}].events`
2132
+ );
2133
+ if (type === "ordered_trace") {
2134
+ if (!setupActionLabel) throw new Error(`checks[${index}] ordered_trace requires setup_action_label.`);
2135
+ if (!tracePath) throw new Error(`checks[${index}] ordered_trace requires trace_path.`);
2136
+ if (!orderedTraceEvents?.length) throw new Error(`checks[${index}] ordered_trace requires events.`);
2137
+ }
1882
2138
  const expectedRoutes = normalizeRouteInventoryRoutes(input.expected_routes ?? input.expectedRoutes, index);
1883
2139
  if (type === "route_inventory" && !expectedRoutes?.length) {
1884
2140
  throw new Error(`checks[${index}] route_inventory requires expected_routes.`);
@@ -1951,6 +2207,9 @@ function normalizeCheck(input, index) {
1951
2207
  body_not_patterns: bodyNotPatterns,
1952
2208
  body_json_assertions: bodyJsonAssertions,
1953
2209
  expected_texts: expectedTexts,
2210
+ setup_action_label: type === "ordered_trace" ? setupActionLabel : void 0,
2211
+ trace_path: type === "ordered_trace" ? tracePath : void 0,
2212
+ events: type === "ordered_trace" ? orderedTraceEvents : void 0,
1954
2213
  link_selector: stringValue(input.link_selector) || stringValue(input.linkSelector),
1955
2214
  source_selector: stringValue(input.source_selector) || stringValue(input.sourceSelector),
1956
2215
  route_path_prefix: stringValue(input.route_path_prefix) || stringValue(input.routePathPrefix),
@@ -2017,6 +2276,20 @@ function normalizeRiddleProofProfile(input, options = {}) {
2017
2276
  const targetUrl = stringValue(options.url) || stringValue(targetInput.url);
2018
2277
  const route = stringValue(options.route) || stringValue(targetInput.route);
2019
2278
  if (!targetUrl && !route) throw new Error("profile.target requires url or route, or pass --url.");
2279
+ const setupActions = normalizeSetupActions(targetInput.setup_actions ?? targetInput.setupActions);
2280
+ for (const [index, check] of checks.entries()) {
2281
+ if (check.type !== "ordered_trace") continue;
2282
+ const matches = (setupActions || []).filter((action) => action.label === check.setup_action_label);
2283
+ if (matches.length !== 1) {
2284
+ throw new Error(`checks[${index}] ordered_trace setup_action_label must match exactly one target.setup_actions label.`);
2285
+ }
2286
+ if (!["window_eval", "window_call", "window_call_until"].includes(matches[0].type)) {
2287
+ throw new Error(`checks[${index}] ordered_trace source action must capture a window_eval, window_call, or window_call_until return.`);
2288
+ }
2289
+ if (matches[0].capture_return === false) {
2290
+ throw new Error(`checks[${index}] ordered_trace source action must not set capture_return to false.`);
2291
+ }
2292
+ }
2020
2293
  return {
2021
2294
  version: RIDDLE_PROOF_PROFILE_VERSION,
2022
2295
  name: normalizeName(input.name, "riddle-proof-profile"),
@@ -2029,7 +2302,7 @@ function normalizeRiddleProofProfile(input, options = {}) {
2029
2302
  wait_for_selector: stringValue(targetInput.wait_for_selector) || stringValue(targetInput.waitForSelector),
2030
2303
  wait_ms: numberValue(targetInput.wait_ms) ?? numberValue(targetInput.waitMs),
2031
2304
  screenshot_full_page: normalizeTargetScreenshotFullPage(targetInput),
2032
- setup_actions: normalizeSetupActions(targetInput.setup_actions ?? targetInput.setupActions),
2305
+ setup_actions: setupActions,
2033
2306
  network_mocks: normalizeNetworkMocks(targetInput.network_mocks ?? targetInput.networkMocks)
2034
2307
  },
2035
2308
  checks,
@@ -3042,6 +3315,32 @@ function assessCheckFromEvidence(check, evidence) {
3042
3315
  message: failed ? `Selector ${key} text order failed in ${failed} viewport(s).` : void 0
3043
3316
  };
3044
3317
  }
3318
+ if (check.type === "ordered_trace") {
3319
+ const assessments = viewports.map((viewport) => ({
3320
+ viewport: viewport.name,
3321
+ assessment: assessRiddleProofOrderedTraceSetupResults(
3322
+ viewport.setup_action_results,
3323
+ check.setup_action_label || "",
3324
+ check.trace_path || "",
3325
+ check.events || []
3326
+ )
3327
+ }));
3328
+ const insufficient = assessments.filter((item) => item.assessment.status === "proof_insufficient");
3329
+ const failed = assessments.filter((item) => item.assessment.status === "failed");
3330
+ const status = insufficient.length ? "proof_insufficient" : failed.length ? "failed" : "passed";
3331
+ return {
3332
+ type: check.type,
3333
+ label: checkLabel(check),
3334
+ status,
3335
+ evidence: {
3336
+ setup_action_label: check.setup_action_label || "",
3337
+ trace_path: check.trace_path || "",
3338
+ events: toJsonValue((check.events || []).map((event) => event.label)),
3339
+ viewports: toJsonValue(assessments)
3340
+ },
3341
+ message: insufficient.length ? `Ordered trace evidence was insufficient in ${insufficient.length} viewport(s).` : failed.length ? `Ordered trace did not contain the required event sequence in ${failed.length} viewport(s).` : void 0
3342
+ };
3343
+ }
3045
3344
  if (check.type === "observe_within") {
3046
3345
  const key = observeWithinKey(check);
3047
3346
  const timeoutMs = observeWithinTimeoutMs(check);
@@ -3541,6 +3840,7 @@ function profileStatusFromEvidence(profile, evidence, checks) {
3541
3840
  if (!viewports.length || !checks.length) return "proof_insufficient";
3542
3841
  if (viewports.some((viewport) => viewport.navigation_error)) return "environment_blocked";
3543
3842
  if (expectedViewportCount && viewports.length < expectedViewportCount) return "proof_insufficient";
3843
+ if (checks.some((check) => check.status === "proof_insufficient")) return "proof_insufficient";
3544
3844
  if (checks.some((check) => check.status === "needs_human_review")) return "needs_human_review";
3545
3845
  if (checks.some((check) => check.status === "failed")) return "product_regression";
3546
3846
  return "passed";
@@ -3870,8 +4170,12 @@ function createRiddleProofProfileInsufficientResult(input) {
3870
4170
  error: message
3871
4171
  };
3872
4172
  }
3873
- function runtimeScriptAssessmentSource() {
4173
+ function runtimeScriptAssessmentSource(includeOrderedTrace = false) {
4174
+ const orderedTraceSource = includeOrderedTrace ? String.raw`
4175
+ const assessRiddleProofOrderedTrace = ${assessRiddleProofOrderedTrace.toString()};
4176
+ const assessRiddleProofOrderedTraceSetupResults = ${assessRiddleProofOrderedTraceSetupResults.toString()};` : "";
3874
4177
  return String.raw`
4178
+ ${orderedTraceSource}
3875
4179
  function normalizeRoutePath(path) {
3876
4180
  const value = path || "/";
3877
4181
  if (value === "/") return "/";
@@ -4701,6 +5005,7 @@ function profileSetupWindowCallReceipts(results) {
4701
5005
  .map((result) => {
4702
5006
  const receipt = {
4703
5007
  ordinal: result.ordinal ?? null,
5008
+ label: result.label ?? null,
4704
5009
  ok: result.ok !== false,
4705
5010
  path: result.path ?? null,
4706
5011
  return_captured: result.return_captured ?? null,
@@ -4721,6 +5026,7 @@ function profileSetupWindowEvalReceipts(results) {
4721
5026
  .map((result) => {
4722
5027
  const receipt = {
4723
5028
  ordinal: result.ordinal ?? null,
5029
+ label: result.label ?? null,
4724
5030
  ok: result.ok !== false,
4725
5031
  script_length: result.script_length ?? null,
4726
5032
  return_captured: result.return_captured ?? null,
@@ -5536,6 +5842,36 @@ function assessProfile(profile, evidence) {
5536
5842
  });
5537
5843
  continue;
5538
5844
  }
5845
+ if (check.type === "ordered_trace") {
5846
+ const assessments = checkViewports.map((viewport) => ({
5847
+ viewport: viewport.name,
5848
+ assessment: assessRiddleProofOrderedTraceSetupResults(
5849
+ viewport.setup_action_results,
5850
+ check.setup_action_label || "",
5851
+ check.trace_path || "",
5852
+ check.events || [],
5853
+ ),
5854
+ }));
5855
+ const insufficient = assessments.filter((item) => item.assessment.status === "proof_insufficient");
5856
+ const failed = assessments.filter((item) => item.assessment.status === "failed");
5857
+ checks.push({
5858
+ type: check.type,
5859
+ label: check.label || check.type,
5860
+ status: insufficient.length ? "proof_insufficient" : failed.length ? "failed" : "passed",
5861
+ evidence: {
5862
+ setup_action_label: check.setup_action_label || "",
5863
+ trace_path: check.trace_path || "",
5864
+ events: (check.events || []).map((event) => event.label),
5865
+ viewports: assessments,
5866
+ },
5867
+ message: insufficient.length
5868
+ ? "Ordered trace evidence was insufficient in " + insufficient.length + " viewport(s)."
5869
+ : failed.length
5870
+ ? "Ordered trace did not contain the required event sequence in " + failed.length + " viewport(s)."
5871
+ : undefined,
5872
+ });
5873
+ continue;
5874
+ }
5539
5875
  if (check.type === "observe_within") {
5540
5876
  const key = observeWithinKey(check);
5541
5877
  const timeoutMs = observeWithinTimeoutMs(check);
@@ -5892,6 +6228,7 @@ function assessProfile(profile, evidence) {
5892
6228
  if (!viewports.length || !checks.length) status = "proof_insufficient";
5893
6229
  else if (viewports.some((viewport) => viewport.navigation_error)) status = "environment_blocked";
5894
6230
  else if (expectedViewportCount && viewports.length < expectedViewportCount) status = "proof_insufficient";
6231
+ else if (checks.some((check) => check.status === "proof_insufficient")) status = "proof_insufficient";
5895
6232
  else if (checks.some((check) => check.status === "needs_human_review")) status = "needs_human_review";
5896
6233
  else if (checks.some((check) => check.status === "failed")) status = "product_regression";
5897
6234
  const screenshotLabels = profileScreenshotLabels(viewports);
@@ -6823,7 +7160,7 @@ let activeViewportName = null;
6823
7160
  async function executeSetupAction(action, ordinal, viewport) {
6824
7161
  const type = setupActionType(action);
6825
7162
  const frameSelector = setupFrameSelector(action);
6826
- const base = { ok: false, action: type || "unknown", ordinal, selector: action.selector || null, frame_selector: frameSelector || null, optional: action.optional === true };
7163
+ const base = { ok: false, action: type || "unknown", ordinal, label: action.label || null, selector: action.selector || null, frame_selector: frameSelector || null, optional: action.optional === true };
6827
7164
  const timeout = setupNumber(action.timeout_ms, 5000);
6828
7165
  try {
6829
7166
  if (type === "wait") {
@@ -9475,7 +9812,7 @@ async function captureViewport(viewport) {
9475
9812
  wait_error: waitError,
9476
9813
  };
9477
9814
  }
9478
- ${runtimeScriptAssessmentSource()}
9815
+ ${runtimeScriptAssessmentSource(profile.checks.some((check) => check.type === "ordered_trace"))}
9479
9816
  const viewports = [];
9480
9817
  function buildProfileEvidence(currentViewports) {
9481
9818
  const expectedViewportCount = (profile.target.viewports || []).length;
@@ -9680,6 +10017,7 @@ function extractRiddleProofProfileResult(input) {
9680
10017
  // Annotate the CommonJS export names for ESM import in node:
9681
10018
  0 && (module.exports = {
9682
10019
  RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS,
10020
+ RIDDLE_PROOF_ORDERED_TRACE_OPERATORS,
9683
10021
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
9684
10022
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
9685
10023
  RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES,
@@ -9688,6 +10026,8 @@ function extractRiddleProofProfileResult(input) {
9688
10026
  RIDDLE_PROOF_PROFILE_STATUSES,
9689
10027
  RIDDLE_PROOF_PROFILE_VERSION,
9690
10028
  applyRiddleProofProfileArtifactCompleteness,
10029
+ assessRiddleProofOrderedTrace,
10030
+ assessRiddleProofOrderedTraceSetupResults,
9691
10031
  assessRiddleProofProfileArtifactCompleteness,
9692
10032
  assessRiddleProofProfileEvidence,
9693
10033
  buildRiddleProofProfileScript,
@@ -1,3 +1,3 @@
1
- export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofProfile, RiddleProofProfileArtifactCompleteness, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileRunnerArtifactPreflight, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, applyRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, preflightRiddleProofProfileRunnerArtifacts, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from '../profile.cjs';
1
+ export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS, RIDDLE_PROOF_ORDERED_TRACE_OPERATORS, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofOrderedTraceAssessment, RiddleProofOrderedTraceEvent, RiddleProofOrderedTraceOperator, RiddleProofOrderedTracePredicate, RiddleProofOrderedTraceWitness, RiddleProofProfile, RiddleProofProfileArtifactCompleteness, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileRunnerArtifactPreflight, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, applyRiddleProofProfileArtifactCompleteness, assessRiddleProofOrderedTrace, assessRiddleProofOrderedTraceSetupResults, assessRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, preflightRiddleProofProfileRunnerArtifacts, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from '../profile.cjs';
2
2
  import '../types.cjs';
3
3
  import '../public-state.cjs';
@@ -1,3 +1,3 @@
1
- export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofProfile, RiddleProofProfileArtifactCompleteness, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileRunnerArtifactPreflight, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, applyRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, preflightRiddleProofProfileRunnerArtifacts, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from '../profile.js';
1
+ export { NormalizeRiddleProofProfileOptions, RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS, RIDDLE_PROOF_ORDERED_TRACE_OPERATORS, RIDDLE_PROOF_PROFILE_CHECK_TYPES, RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION, RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES, RIDDLE_PROOF_PROFILE_RESULT_VERSION, RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES, RIDDLE_PROOF_PROFILE_STATUSES, RIDDLE_PROOF_PROFILE_VERSION, RiddleProofArtifactBodyAssertionInput, RiddleProofArtifactBodyAssertionResult, RiddleProofOrderedTraceAssessment, RiddleProofOrderedTraceEvent, RiddleProofOrderedTraceOperator, RiddleProofOrderedTracePredicate, RiddleProofOrderedTraceWitness, RiddleProofProfile, RiddleProofProfileArtifactCompleteness, RiddleProofProfileArtifactRef, RiddleProofProfileBaselinePolicy, RiddleProofProfileBoundsOffender, RiddleProofProfileCheck, RiddleProofProfileCheckResult, RiddleProofProfileCheckType, RiddleProofProfileEvidence, RiddleProofProfileFailureAction, RiddleProofProfileHttpStatusBodyJsonAssertion, RiddleProofProfileHttpStatusBodyJsonAssertionResult, RiddleProofProfileHttpStatusPreflightCheckResult, RiddleProofProfileHttpStatusPreflightFetch, RiddleProofProfileHttpStatusPreflightFetchResponse, RiddleProofProfileHttpStatusPreflightOptions, RiddleProofProfileHttpStatusPreflightResult, RiddleProofProfileJsonValueType, RiddleProofProfileNetworkAbortErrorCode, RiddleProofProfileNetworkMock, RiddleProofProfileNetworkMockResponse, RiddleProofProfileResult, RiddleProofProfileReturnSummaryField, RiddleProofProfileRouteEvidence, RiddleProofProfileRouteInventoryRoute, RiddleProofProfileRunner, RiddleProofProfileRunnerArtifactPreflight, RiddleProofProfileSetupAction, RiddleProofProfileSetupActionType, RiddleProofProfileStatus, RiddleProofProfileTarget, RiddleProofProfileViewport, RiddleProofProfileViewportEvidence, applyRiddleProofProfileArtifactCompleteness, assessRiddleProofOrderedTrace, assessRiddleProofOrderedTraceSetupResults, assessRiddleProofProfileArtifactCompleteness, assessRiddleProofProfileEvidence, buildRiddleProofProfileScript, collectRiddleProfileArtifactRefs, collectRiddleProofProfileWarnings, createRiddleProofProfileConfigurationError, createRiddleProofProfileEnvironmentBlockedResult, createRiddleProofProfileInsufficientResult, deriveRiddleProofArtifactBodyAssertions, extractRiddleProofProfileResult, normalizeRiddleProofProfile, preflightRiddleProofProfileHttpStatusChecks, preflightRiddleProofProfileRunnerArtifacts, profileStatusExitCode, resolveRiddleProofProfileRouteUrl, resolveRiddleProofProfileTargetUrl, resolveRiddleProofProfileTimeoutSec, slugifyRiddleProofProfileName, summarizeRiddleProofProfileResult } from '../profile.js';
2
2
  import '../types.js';
3
3
  import '../public-state.js';
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS,
3
+ RIDDLE_PROOF_ORDERED_TRACE_OPERATORS,
3
4
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
4
5
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
5
6
  RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES,
@@ -8,6 +9,8 @@ import {
8
9
  RIDDLE_PROOF_PROFILE_STATUSES,
9
10
  RIDDLE_PROOF_PROFILE_VERSION,
10
11
  applyRiddleProofProfileArtifactCompleteness,
12
+ assessRiddleProofOrderedTrace,
13
+ assessRiddleProofOrderedTraceSetupResults,
11
14
  assessRiddleProofProfileArtifactCompleteness,
12
15
  assessRiddleProofProfileEvidence,
13
16
  buildRiddleProofProfileScript,
@@ -27,10 +30,11 @@ import {
27
30
  resolveRiddleProofProfileTimeoutSec,
28
31
  slugifyRiddleProofProfileName,
29
32
  summarizeRiddleProofProfileResult
30
- } from "../chunk-FCSJZBC5.js";
33
+ } from "../chunk-ZNVYJFR7.js";
31
34
  import "../chunk-MLKGABMK.js";
32
35
  export {
33
36
  RIDDLE_PROOF_HOSTED_PROFILE_ARTIFACTS,
37
+ RIDDLE_PROOF_ORDERED_TRACE_OPERATORS,
34
38
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
35
39
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
36
40
  RIDDLE_PROOF_PROFILE_NETWORK_ABORT_ERROR_CODES,
@@ -39,6 +43,8 @@ export {
39
43
  RIDDLE_PROOF_PROFILE_STATUSES,
40
44
  RIDDLE_PROOF_PROFILE_VERSION,
41
45
  applyRiddleProofProfileArtifactCompleteness,
46
+ assessRiddleProofOrderedTrace,
47
+ assessRiddleProofOrderedTraceSetupResults,
42
48
  assessRiddleProofProfileArtifactCompleteness,
43
49
  assessRiddleProofProfileEvidence,
44
50
  buildRiddleProofProfileScript,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  RIDDLE_PROOF_PROFILE_SUGGESTIONS_VERSION,
3
3
  suggestRiddleProofProfileChecks
4
- } from "./chunk-RQPCKRKT.js";
5
- import "./chunk-FCSJZBC5.js";
4
+ } from "./chunk-A4EF4M3B.js";
5
+ import "./chunk-ZNVYJFR7.js";
6
6
  import "./chunk-MLKGABMK.js";
7
7
  export {
8
8
  RIDDLE_PROOF_PROFILE_SUGGESTIONS_VERSION,