@riddledc/riddle-proof 0.7.77 → 0.7.78

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.
@@ -927,6 +927,41 @@ function matchesAllowedMessage(input, texts, patterns) {
927
927
  }
928
928
  return false;
929
929
  }
930
+ function consoleEventLocationUrl(input) {
931
+ if (!isRecord(input) || !isRecord(input.location)) return void 0;
932
+ return stringValue(input.location.url);
933
+ }
934
+ function expectedFailedNetworkMockEvents(evidence) {
935
+ return (evidence.network_mocks || []).filter((event) => {
936
+ if (!isRecord(event) || event.ok === false) return false;
937
+ const status = numberValue(event.status);
938
+ return status !== void 0 && status >= 400 && Boolean(stringValue(event.url));
939
+ });
940
+ }
941
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
942
+ const sample = allowedMessageSample(event);
943
+ if (!/Failed to load resource/i.test(sample)) return void 0;
944
+ const eventUrl = consoleEventLocationUrl(event);
945
+ if (!eventUrl) return void 0;
946
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
947
+ const status = numberValue(mockEvent.status);
948
+ return stringValue(mockEvent.url) === eventUrl && status !== void 0 && sample.includes(String(status));
949
+ });
950
+ }
951
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
952
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
953
+ }
954
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
955
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
956
+ const sample = allowedMessageSample(event);
957
+ return {
958
+ url: consoleEventLocationUrl(event) ?? null,
959
+ status: match ? numberValue(match.status) ?? null : null,
960
+ label: match ? stringValue(match.label) ?? null : null,
961
+ response_label: match ? stringValue(match.response_label) ?? null : null,
962
+ text: isRecord(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300)
963
+ };
964
+ }
930
965
  function normalizeRoutePath(path) {
931
966
  const value = path || "/";
932
967
  if (value === "/") return "/";
@@ -1344,8 +1379,10 @@ function assessCheckFromEvidence(check, evidence) {
1344
1379
  }
1345
1380
  if (check.type === "no_fatal_console_errors") {
1346
1381
  const fatalConsoleEvents = (evidence.console?.events || []).filter((event) => event.type === "error" || event.type === "assert");
1347
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
1348
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
1382
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
1383
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && isExpectedFailedNetworkMockConsoleEvent(event, evidence));
1384
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) || isExpectedFailedNetworkMockConsoleEvent(event, evidence));
1385
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && !isExpectedFailedNetworkMockConsoleEvent(event, evidence));
1349
1386
  const pageErrors = evidence.page_errors || [];
1350
1387
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
1351
1388
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -1360,6 +1397,9 @@ function assessCheckFromEvidence(check, evidence) {
1360
1397
  total_console_fatal_count: fatalConsoleEvents.length,
1361
1398
  total_page_error_count: pageErrors.length,
1362
1399
  allowed_console_fatal_count: allowedConsoleEvents.length,
1400
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
1401
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
1402
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
1363
1403
  allowed_page_error_count: allowedPageErrors.length,
1364
1404
  allowed_console_texts: check.allowed_console_texts || [],
1365
1405
  allowed_console_patterns: check.allowed_console_patterns || [],
@@ -1722,6 +1762,44 @@ function matchesAllowedMessage(input, texts, patterns) {
1722
1762
  }
1723
1763
  return false;
1724
1764
  }
1765
+ function consoleEventLocationUrl(input) {
1766
+ if (!input || typeof input !== "object" || Array.isArray(input)) return undefined;
1767
+ if (!input.location || typeof input.location !== "object" || Array.isArray(input.location)) return undefined;
1768
+ return typeof input.location.url === "string" && input.location.url.trim() ? input.location.url.trim() : undefined;
1769
+ }
1770
+ function expectedFailedNetworkMockEvents(evidence) {
1771
+ return ((evidence && evidence.network_mocks) || []).filter((event) => {
1772
+ if (!event || typeof event !== "object" || Array.isArray(event) || event.ok === false) return false;
1773
+ const status = typeof event.status === "number" && Number.isFinite(event.status) ? event.status : undefined;
1774
+ const url = typeof event.url === "string" && event.url.trim() ? event.url.trim() : undefined;
1775
+ return status !== undefined && status >= 400 && Boolean(url);
1776
+ });
1777
+ }
1778
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
1779
+ const sample = allowedMessageSample(event);
1780
+ if (!/Failed to load resource/i.test(sample)) return undefined;
1781
+ const eventUrl = consoleEventLocationUrl(event);
1782
+ if (!eventUrl) return undefined;
1783
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
1784
+ const status = typeof mockEvent.status === "number" && Number.isFinite(mockEvent.status) ? mockEvent.status : undefined;
1785
+ const mockUrl = typeof mockEvent.url === "string" && mockEvent.url.trim() ? mockEvent.url.trim() : undefined;
1786
+ return mockUrl === eventUrl && status !== undefined && sample.includes(String(status));
1787
+ });
1788
+ }
1789
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
1790
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
1791
+ }
1792
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
1793
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
1794
+ const sample = allowedMessageSample(event);
1795
+ return {
1796
+ url: consoleEventLocationUrl(event) || null,
1797
+ status: match && typeof match.status === "number" && Number.isFinite(match.status) ? match.status : null,
1798
+ label: match && typeof match.label === "string" && match.label.trim() ? match.label.trim() : null,
1799
+ response_label: match && typeof match.response_label === "string" && match.response_label.trim() ? match.response_label.trim() : null,
1800
+ text: event && typeof event === "object" && !Array.isArray(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300),
1801
+ };
1802
+ }
1725
1803
  function textSequenceForCheck(viewport, check) {
1726
1804
  const key = check.selector || "";
1727
1805
  const sequence = viewport.text_sequences && viewport.text_sequences[key];
@@ -2445,8 +2523,19 @@ function assessProfile(profile, evidence) {
2445
2523
  }
2446
2524
  if (check.type === "no_fatal_console_errors") {
2447
2525
  const fatalConsoleEvents = ((evidence.console && evidence.console.events) || []).filter((event) => event && (event.type === "error" || event.type === "assert"));
2448
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
2449
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
2526
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
2527
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => (
2528
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
2529
+ && isExpectedFailedNetworkMockConsoleEvent(event, evidence)
2530
+ ));
2531
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => (
2532
+ matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
2533
+ || isExpectedFailedNetworkMockConsoleEvent(event, evidence)
2534
+ ));
2535
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => (
2536
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
2537
+ && !isExpectedFailedNetworkMockConsoleEvent(event, evidence)
2538
+ ));
2450
2539
  const pageErrors = evidence.page_errors || [];
2451
2540
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
2452
2541
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -2461,6 +2550,9 @@ function assessProfile(profile, evidence) {
2461
2550
  total_console_fatal_count: fatalConsoleEvents.length,
2462
2551
  total_page_error_count: pageErrors.length,
2463
2552
  allowed_console_fatal_count: allowedConsoleEvents.length,
2553
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
2554
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
2555
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
2464
2556
  allowed_page_error_count: allowedPageErrors.length,
2465
2557
  allowed_console_texts: check.allowed_console_texts || [],
2466
2558
  allowed_console_patterns: check.allowed_console_patterns || [],
package/dist/cli.cjs CHANGED
@@ -7800,6 +7800,41 @@ function matchesAllowedMessage(input, texts, patterns) {
7800
7800
  }
7801
7801
  return false;
7802
7802
  }
7803
+ function consoleEventLocationUrl(input) {
7804
+ if (!isRecord(input) || !isRecord(input.location)) return void 0;
7805
+ return stringValue2(input.location.url);
7806
+ }
7807
+ function expectedFailedNetworkMockEvents(evidence) {
7808
+ return (evidence.network_mocks || []).filter((event) => {
7809
+ if (!isRecord(event) || event.ok === false) return false;
7810
+ const status = numberValue(event.status);
7811
+ return status !== void 0 && status >= 400 && Boolean(stringValue2(event.url));
7812
+ });
7813
+ }
7814
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
7815
+ const sample = allowedMessageSample(event);
7816
+ if (!/Failed to load resource/i.test(sample)) return void 0;
7817
+ const eventUrl = consoleEventLocationUrl(event);
7818
+ if (!eventUrl) return void 0;
7819
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
7820
+ const status = numberValue(mockEvent.status);
7821
+ return stringValue2(mockEvent.url) === eventUrl && status !== void 0 && sample.includes(String(status));
7822
+ });
7823
+ }
7824
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
7825
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
7826
+ }
7827
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
7828
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
7829
+ const sample = allowedMessageSample(event);
7830
+ return {
7831
+ url: consoleEventLocationUrl(event) ?? null,
7832
+ status: match ? numberValue(match.status) ?? null : null,
7833
+ label: match ? stringValue2(match.label) ?? null : null,
7834
+ response_label: match ? stringValue2(match.response_label) ?? null : null,
7835
+ text: isRecord(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300)
7836
+ };
7837
+ }
7803
7838
  function normalizeRoutePath(path7) {
7804
7839
  const value = path7 || "/";
7805
7840
  if (value === "/") return "/";
@@ -8217,8 +8252,10 @@ function assessCheckFromEvidence(check, evidence) {
8217
8252
  }
8218
8253
  if (check.type === "no_fatal_console_errors") {
8219
8254
  const fatalConsoleEvents = (evidence.console?.events || []).filter((event) => event.type === "error" || event.type === "assert");
8220
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
8221
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
8255
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
8256
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && isExpectedFailedNetworkMockConsoleEvent(event, evidence));
8257
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) || isExpectedFailedNetworkMockConsoleEvent(event, evidence));
8258
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && !isExpectedFailedNetworkMockConsoleEvent(event, evidence));
8222
8259
  const pageErrors = evidence.page_errors || [];
8223
8260
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
8224
8261
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -8233,6 +8270,9 @@ function assessCheckFromEvidence(check, evidence) {
8233
8270
  total_console_fatal_count: fatalConsoleEvents.length,
8234
8271
  total_page_error_count: pageErrors.length,
8235
8272
  allowed_console_fatal_count: allowedConsoleEvents.length,
8273
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
8274
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
8275
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
8236
8276
  allowed_page_error_count: allowedPageErrors.length,
8237
8277
  allowed_console_texts: check.allowed_console_texts || [],
8238
8278
  allowed_console_patterns: check.allowed_console_patterns || [],
@@ -8579,6 +8619,44 @@ function matchesAllowedMessage(input, texts, patterns) {
8579
8619
  }
8580
8620
  return false;
8581
8621
  }
8622
+ function consoleEventLocationUrl(input) {
8623
+ if (!input || typeof input !== "object" || Array.isArray(input)) return undefined;
8624
+ if (!input.location || typeof input.location !== "object" || Array.isArray(input.location)) return undefined;
8625
+ return typeof input.location.url === "string" && input.location.url.trim() ? input.location.url.trim() : undefined;
8626
+ }
8627
+ function expectedFailedNetworkMockEvents(evidence) {
8628
+ return ((evidence && evidence.network_mocks) || []).filter((event) => {
8629
+ if (!event || typeof event !== "object" || Array.isArray(event) || event.ok === false) return false;
8630
+ const status = typeof event.status === "number" && Number.isFinite(event.status) ? event.status : undefined;
8631
+ const url = typeof event.url === "string" && event.url.trim() ? event.url.trim() : undefined;
8632
+ return status !== undefined && status >= 400 && Boolean(url);
8633
+ });
8634
+ }
8635
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
8636
+ const sample = allowedMessageSample(event);
8637
+ if (!/Failed to load resource/i.test(sample)) return undefined;
8638
+ const eventUrl = consoleEventLocationUrl(event);
8639
+ if (!eventUrl) return undefined;
8640
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
8641
+ const status = typeof mockEvent.status === "number" && Number.isFinite(mockEvent.status) ? mockEvent.status : undefined;
8642
+ const mockUrl = typeof mockEvent.url === "string" && mockEvent.url.trim() ? mockEvent.url.trim() : undefined;
8643
+ return mockUrl === eventUrl && status !== undefined && sample.includes(String(status));
8644
+ });
8645
+ }
8646
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
8647
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
8648
+ }
8649
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
8650
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
8651
+ const sample = allowedMessageSample(event);
8652
+ return {
8653
+ url: consoleEventLocationUrl(event) || null,
8654
+ status: match && typeof match.status === "number" && Number.isFinite(match.status) ? match.status : null,
8655
+ label: match && typeof match.label === "string" && match.label.trim() ? match.label.trim() : null,
8656
+ response_label: match && typeof match.response_label === "string" && match.response_label.trim() ? match.response_label.trim() : null,
8657
+ text: event && typeof event === "object" && !Array.isArray(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300),
8658
+ };
8659
+ }
8582
8660
  function textSequenceForCheck(viewport, check) {
8583
8661
  const key = check.selector || "";
8584
8662
  const sequence = viewport.text_sequences && viewport.text_sequences[key];
@@ -9302,8 +9380,19 @@ function assessProfile(profile, evidence) {
9302
9380
  }
9303
9381
  if (check.type === "no_fatal_console_errors") {
9304
9382
  const fatalConsoleEvents = ((evidence.console && evidence.console.events) || []).filter((event) => event && (event.type === "error" || event.type === "assert"));
9305
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
9306
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
9383
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
9384
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => (
9385
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
9386
+ && isExpectedFailedNetworkMockConsoleEvent(event, evidence)
9387
+ ));
9388
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => (
9389
+ matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
9390
+ || isExpectedFailedNetworkMockConsoleEvent(event, evidence)
9391
+ ));
9392
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => (
9393
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
9394
+ && !isExpectedFailedNetworkMockConsoleEvent(event, evidence)
9395
+ ));
9307
9396
  const pageErrors = evidence.page_errors || [];
9308
9397
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
9309
9398
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -9318,6 +9407,9 @@ function assessProfile(profile, evidence) {
9318
9407
  total_console_fatal_count: fatalConsoleEvents.length,
9319
9408
  total_page_error_count: pageErrors.length,
9320
9409
  allowed_console_fatal_count: allowedConsoleEvents.length,
9410
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
9411
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
9412
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
9321
9413
  allowed_page_error_count: allowedPageErrors.length,
9322
9414
  allowed_console_texts: check.allowed_console_texts || [],
9323
9415
  allowed_console_patterns: check.allowed_console_patterns || [],
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  profileStatusExitCode,
11
11
  resolveRiddleProofProfileTargetUrl,
12
12
  resolveRiddleProofProfileTimeoutSec
13
- } from "./chunk-RBZ4A5M4.js";
13
+ } from "./chunk-3K5AFX6X.js";
14
14
  import {
15
15
  createRiddleApiClient,
16
16
  parseRiddleViewport
package/dist/index.cjs CHANGED
@@ -9641,6 +9641,41 @@ function matchesAllowedMessage(input, texts, patterns) {
9641
9641
  }
9642
9642
  return false;
9643
9643
  }
9644
+ function consoleEventLocationUrl(input) {
9645
+ if (!isRecord2(input) || !isRecord2(input.location)) return void 0;
9646
+ return stringValue5(input.location.url);
9647
+ }
9648
+ function expectedFailedNetworkMockEvents(evidence) {
9649
+ return (evidence.network_mocks || []).filter((event) => {
9650
+ if (!isRecord2(event) || event.ok === false) return false;
9651
+ const status = numberValue3(event.status);
9652
+ return status !== void 0 && status >= 400 && Boolean(stringValue5(event.url));
9653
+ });
9654
+ }
9655
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
9656
+ const sample = allowedMessageSample(event);
9657
+ if (!/Failed to load resource/i.test(sample)) return void 0;
9658
+ const eventUrl = consoleEventLocationUrl(event);
9659
+ if (!eventUrl) return void 0;
9660
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
9661
+ const status = numberValue3(mockEvent.status);
9662
+ return stringValue5(mockEvent.url) === eventUrl && status !== void 0 && sample.includes(String(status));
9663
+ });
9664
+ }
9665
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
9666
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
9667
+ }
9668
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
9669
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
9670
+ const sample = allowedMessageSample(event);
9671
+ return {
9672
+ url: consoleEventLocationUrl(event) ?? null,
9673
+ status: match ? numberValue3(match.status) ?? null : null,
9674
+ label: match ? stringValue5(match.label) ?? null : null,
9675
+ response_label: match ? stringValue5(match.response_label) ?? null : null,
9676
+ text: isRecord2(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300)
9677
+ };
9678
+ }
9644
9679
  function normalizeRoutePath(path6) {
9645
9680
  const value = path6 || "/";
9646
9681
  if (value === "/") return "/";
@@ -10058,8 +10093,10 @@ function assessCheckFromEvidence(check, evidence) {
10058
10093
  }
10059
10094
  if (check.type === "no_fatal_console_errors") {
10060
10095
  const fatalConsoleEvents = (evidence.console?.events || []).filter((event) => event.type === "error" || event.type === "assert");
10061
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
10062
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
10096
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
10097
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && isExpectedFailedNetworkMockConsoleEvent(event, evidence));
10098
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) || isExpectedFailedNetworkMockConsoleEvent(event, evidence));
10099
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && !isExpectedFailedNetworkMockConsoleEvent(event, evidence));
10063
10100
  const pageErrors = evidence.page_errors || [];
10064
10101
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
10065
10102
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -10074,6 +10111,9 @@ function assessCheckFromEvidence(check, evidence) {
10074
10111
  total_console_fatal_count: fatalConsoleEvents.length,
10075
10112
  total_page_error_count: pageErrors.length,
10076
10113
  allowed_console_fatal_count: allowedConsoleEvents.length,
10114
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
10115
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
10116
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
10077
10117
  allowed_page_error_count: allowedPageErrors.length,
10078
10118
  allowed_console_texts: check.allowed_console_texts || [],
10079
10119
  allowed_console_patterns: check.allowed_console_patterns || [],
@@ -10436,6 +10476,44 @@ function matchesAllowedMessage(input, texts, patterns) {
10436
10476
  }
10437
10477
  return false;
10438
10478
  }
10479
+ function consoleEventLocationUrl(input) {
10480
+ if (!input || typeof input !== "object" || Array.isArray(input)) return undefined;
10481
+ if (!input.location || typeof input.location !== "object" || Array.isArray(input.location)) return undefined;
10482
+ return typeof input.location.url === "string" && input.location.url.trim() ? input.location.url.trim() : undefined;
10483
+ }
10484
+ function expectedFailedNetworkMockEvents(evidence) {
10485
+ return ((evidence && evidence.network_mocks) || []).filter((event) => {
10486
+ if (!event || typeof event !== "object" || Array.isArray(event) || event.ok === false) return false;
10487
+ const status = typeof event.status === "number" && Number.isFinite(event.status) ? event.status : undefined;
10488
+ const url = typeof event.url === "string" && event.url.trim() ? event.url.trim() : undefined;
10489
+ return status !== undefined && status >= 400 && Boolean(url);
10490
+ });
10491
+ }
10492
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
10493
+ const sample = allowedMessageSample(event);
10494
+ if (!/Failed to load resource/i.test(sample)) return undefined;
10495
+ const eventUrl = consoleEventLocationUrl(event);
10496
+ if (!eventUrl) return undefined;
10497
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
10498
+ const status = typeof mockEvent.status === "number" && Number.isFinite(mockEvent.status) ? mockEvent.status : undefined;
10499
+ const mockUrl = typeof mockEvent.url === "string" && mockEvent.url.trim() ? mockEvent.url.trim() : undefined;
10500
+ return mockUrl === eventUrl && status !== undefined && sample.includes(String(status));
10501
+ });
10502
+ }
10503
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
10504
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
10505
+ }
10506
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
10507
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
10508
+ const sample = allowedMessageSample(event);
10509
+ return {
10510
+ url: consoleEventLocationUrl(event) || null,
10511
+ status: match && typeof match.status === "number" && Number.isFinite(match.status) ? match.status : null,
10512
+ label: match && typeof match.label === "string" && match.label.trim() ? match.label.trim() : null,
10513
+ response_label: match && typeof match.response_label === "string" && match.response_label.trim() ? match.response_label.trim() : null,
10514
+ text: event && typeof event === "object" && !Array.isArray(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300),
10515
+ };
10516
+ }
10439
10517
  function textSequenceForCheck(viewport, check) {
10440
10518
  const key = check.selector || "";
10441
10519
  const sequence = viewport.text_sequences && viewport.text_sequences[key];
@@ -11159,8 +11237,19 @@ function assessProfile(profile, evidence) {
11159
11237
  }
11160
11238
  if (check.type === "no_fatal_console_errors") {
11161
11239
  const fatalConsoleEvents = ((evidence.console && evidence.console.events) || []).filter((event) => event && (event.type === "error" || event.type === "assert"));
11162
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
11163
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
11240
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
11241
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => (
11242
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
11243
+ && isExpectedFailedNetworkMockConsoleEvent(event, evidence)
11244
+ ));
11245
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => (
11246
+ matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
11247
+ || isExpectedFailedNetworkMockConsoleEvent(event, evidence)
11248
+ ));
11249
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => (
11250
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
11251
+ && !isExpectedFailedNetworkMockConsoleEvent(event, evidence)
11252
+ ));
11164
11253
  const pageErrors = evidence.page_errors || [];
11165
11254
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
11166
11255
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -11175,6 +11264,9 @@ function assessProfile(profile, evidence) {
11175
11264
  total_console_fatal_count: fatalConsoleEvents.length,
11176
11265
  total_page_error_count: pageErrors.length,
11177
11266
  allowed_console_fatal_count: allowedConsoleEvents.length,
11267
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
11268
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
11269
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
11178
11270
  allowed_page_error_count: allowedPageErrors.length,
11179
11271
  allowed_console_texts: check.allowed_console_texts || [],
11180
11272
  allowed_console_patterns: check.allowed_console_patterns || [],
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ import {
58
58
  resolveRiddleProofProfileTimeoutSec,
59
59
  slugifyRiddleProofProfileName,
60
60
  summarizeRiddleProofProfileResult
61
- } from "./chunk-RBZ4A5M4.js";
61
+ } from "./chunk-3K5AFX6X.js";
62
62
  import {
63
63
  DEFAULT_RIDDLE_API_BASE_URL,
64
64
  DEFAULT_RIDDLE_API_KEY_FILE,
package/dist/profile.cjs CHANGED
@@ -970,6 +970,41 @@ function matchesAllowedMessage(input, texts, patterns) {
970
970
  }
971
971
  return false;
972
972
  }
973
+ function consoleEventLocationUrl(input) {
974
+ if (!isRecord(input) || !isRecord(input.location)) return void 0;
975
+ return stringValue(input.location.url);
976
+ }
977
+ function expectedFailedNetworkMockEvents(evidence) {
978
+ return (evidence.network_mocks || []).filter((event) => {
979
+ if (!isRecord(event) || event.ok === false) return false;
980
+ const status = numberValue(event.status);
981
+ return status !== void 0 && status >= 400 && Boolean(stringValue(event.url));
982
+ });
983
+ }
984
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
985
+ const sample = allowedMessageSample(event);
986
+ if (!/Failed to load resource/i.test(sample)) return void 0;
987
+ const eventUrl = consoleEventLocationUrl(event);
988
+ if (!eventUrl) return void 0;
989
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
990
+ const status = numberValue(mockEvent.status);
991
+ return stringValue(mockEvent.url) === eventUrl && status !== void 0 && sample.includes(String(status));
992
+ });
993
+ }
994
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
995
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
996
+ }
997
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
998
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
999
+ const sample = allowedMessageSample(event);
1000
+ return {
1001
+ url: consoleEventLocationUrl(event) ?? null,
1002
+ status: match ? numberValue(match.status) ?? null : null,
1003
+ label: match ? stringValue(match.label) ?? null : null,
1004
+ response_label: match ? stringValue(match.response_label) ?? null : null,
1005
+ text: isRecord(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300)
1006
+ };
1007
+ }
973
1008
  function normalizeRoutePath(path) {
974
1009
  const value = path || "/";
975
1010
  if (value === "/") return "/";
@@ -1387,8 +1422,10 @@ function assessCheckFromEvidence(check, evidence) {
1387
1422
  }
1388
1423
  if (check.type === "no_fatal_console_errors") {
1389
1424
  const fatalConsoleEvents = (evidence.console?.events || []).filter((event) => event.type === "error" || event.type === "assert");
1390
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
1391
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
1425
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
1426
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && isExpectedFailedNetworkMockConsoleEvent(event, evidence));
1427
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) || isExpectedFailedNetworkMockConsoleEvent(event, evidence));
1428
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns) && !isExpectedFailedNetworkMockConsoleEvent(event, evidence));
1392
1429
  const pageErrors = evidence.page_errors || [];
1393
1430
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
1394
1431
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -1403,6 +1440,9 @@ function assessCheckFromEvidence(check, evidence) {
1403
1440
  total_console_fatal_count: fatalConsoleEvents.length,
1404
1441
  total_page_error_count: pageErrors.length,
1405
1442
  allowed_console_fatal_count: allowedConsoleEvents.length,
1443
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
1444
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
1445
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
1406
1446
  allowed_page_error_count: allowedPageErrors.length,
1407
1447
  allowed_console_texts: check.allowed_console_texts || [],
1408
1448
  allowed_console_patterns: check.allowed_console_patterns || [],
@@ -1765,6 +1805,44 @@ function matchesAllowedMessage(input, texts, patterns) {
1765
1805
  }
1766
1806
  return false;
1767
1807
  }
1808
+ function consoleEventLocationUrl(input) {
1809
+ if (!input || typeof input !== "object" || Array.isArray(input)) return undefined;
1810
+ if (!input.location || typeof input.location !== "object" || Array.isArray(input.location)) return undefined;
1811
+ return typeof input.location.url === "string" && input.location.url.trim() ? input.location.url.trim() : undefined;
1812
+ }
1813
+ function expectedFailedNetworkMockEvents(evidence) {
1814
+ return ((evidence && evidence.network_mocks) || []).filter((event) => {
1815
+ if (!event || typeof event !== "object" || Array.isArray(event) || event.ok === false) return false;
1816
+ const status = typeof event.status === "number" && Number.isFinite(event.status) ? event.status : undefined;
1817
+ const url = typeof event.url === "string" && event.url.trim() ? event.url.trim() : undefined;
1818
+ return status !== undefined && status >= 400 && Boolean(url);
1819
+ });
1820
+ }
1821
+ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
1822
+ const sample = allowedMessageSample(event);
1823
+ if (!/Failed to load resource/i.test(sample)) return undefined;
1824
+ const eventUrl = consoleEventLocationUrl(event);
1825
+ if (!eventUrl) return undefined;
1826
+ return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
1827
+ const status = typeof mockEvent.status === "number" && Number.isFinite(mockEvent.status) ? mockEvent.status : undefined;
1828
+ const mockUrl = typeof mockEvent.url === "string" && mockEvent.url.trim() ? mockEvent.url.trim() : undefined;
1829
+ return mockUrl === eventUrl && status !== undefined && sample.includes(String(status));
1830
+ });
1831
+ }
1832
+ function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
1833
+ return Boolean(matchingExpectedFailedNetworkMockConsoleEvent(event, evidence));
1834
+ }
1835
+ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
1836
+ const match = matchingExpectedFailedNetworkMockConsoleEvent(event, evidence);
1837
+ const sample = allowedMessageSample(event);
1838
+ return {
1839
+ url: consoleEventLocationUrl(event) || null,
1840
+ status: match && typeof match.status === "number" && Number.isFinite(match.status) ? match.status : null,
1841
+ label: match && typeof match.label === "string" && match.label.trim() ? match.label.trim() : null,
1842
+ response_label: match && typeof match.response_label === "string" && match.response_label.trim() ? match.response_label.trim() : null,
1843
+ text: event && typeof event === "object" && !Array.isArray(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300),
1844
+ };
1845
+ }
1768
1846
  function textSequenceForCheck(viewport, check) {
1769
1847
  const key = check.selector || "";
1770
1848
  const sequence = viewport.text_sequences && viewport.text_sequences[key];
@@ -2488,8 +2566,19 @@ function assessProfile(profile, evidence) {
2488
2566
  }
2489
2567
  if (check.type === "no_fatal_console_errors") {
2490
2568
  const fatalConsoleEvents = ((evidence.console && evidence.console.events) || []).filter((event) => event && (event.type === "error" || event.type === "assert"));
2491
- const allowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
2492
- const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
2569
+ const explicitlyAllowedConsoleEvents = fatalConsoleEvents.filter((event) => matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns));
2570
+ const expectedNetworkMockConsoleEvents = fatalConsoleEvents.filter((event) => (
2571
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
2572
+ && isExpectedFailedNetworkMockConsoleEvent(event, evidence)
2573
+ ));
2574
+ const allowedConsoleEvents = fatalConsoleEvents.filter((event) => (
2575
+ matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
2576
+ || isExpectedFailedNetworkMockConsoleEvent(event, evidence)
2577
+ ));
2578
+ const unallowedConsoleEvents = fatalConsoleEvents.filter((event) => (
2579
+ !matchesAllowedMessage(event, check.allowed_console_texts, check.allowed_console_patterns)
2580
+ && !isExpectedFailedNetworkMockConsoleEvent(event, evidence)
2581
+ ));
2493
2582
  const pageErrors = evidence.page_errors || [];
2494
2583
  const allowedPageErrors = pageErrors.filter((error) => matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
2495
2584
  const unallowedPageErrors = pageErrors.filter((error) => !matchesAllowedMessage(error, check.allowed_page_error_texts, check.allowed_page_error_patterns));
@@ -2504,6 +2593,9 @@ function assessProfile(profile, evidence) {
2504
2593
  total_console_fatal_count: fatalConsoleEvents.length,
2505
2594
  total_page_error_count: pageErrors.length,
2506
2595
  allowed_console_fatal_count: allowedConsoleEvents.length,
2596
+ explicitly_allowed_console_fatal_count: explicitlyAllowedConsoleEvents.length,
2597
+ allowed_expected_network_mock_console_count: expectedNetworkMockConsoleEvents.length,
2598
+ allowed_expected_network_mock_console_events: expectedNetworkMockConsoleEvents.slice(0, 5).map((event) => expectedFailedNetworkMockConsoleEventSummary(event, evidence)),
2507
2599
  allowed_page_error_count: allowedPageErrors.length,
2508
2600
  allowed_console_texts: check.allowed_console_texts || [],
2509
2601
  allowed_console_patterns: check.allowed_console_patterns || [],
package/dist/profile.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  resolveRiddleProofProfileTimeoutSec,
20
20
  slugifyRiddleProofProfileName,
21
21
  summarizeRiddleProofProfileResult
22
- } from "./chunk-RBZ4A5M4.js";
22
+ } from "./chunk-3K5AFX6X.js";
23
23
  export {
24
24
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
25
25
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.77",
3
+ "version": "0.7.78",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",