@riddledc/riddle-proof 0.7.175 → 0.7.176

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.
@@ -2637,6 +2637,27 @@ function successfulRoute(route, targetUrl) {
2637
2637
  const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
2638
2638
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
2639
2639
  }
2640
+ function routeReadinessFailed(route, targetUrl) {
2641
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
2642
+ const httpOk = route.http_status === null || route.http_status === void 0 || route.http_status < 400;
2643
+ return matched && httpOk && Boolean(route.error);
2644
+ }
2645
+ function compactRouteError(error) {
2646
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
2647
+ return text ? text.slice(0, 240) : void 0;
2648
+ }
2649
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
2650
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
2651
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
2652
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
2653
+ return `Route matched ${expectedPath}, but readiness failed in ${readinessFailures.length} viewport(s)${sample ? `: ${sample}` : "."}`;
2654
+ }
2655
+ if (readinessFailures.length) {
2656
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
2657
+ return `Route did not become ready as ${expectedPath} in ${failedRoutes.length} viewport(s); ${readinessFailures.length} matched path and HTTP but failed readiness${sample ? `: ${sample}` : "."}`;
2658
+ }
2659
+ return `Route did not load as ${expectedPath} in ${failedRoutes.length} viewport(s).`;
2660
+ }
2640
2661
  function parseEvidenceUrl(value, targetUrl) {
2641
2662
  if (!value) return void 0;
2642
2663
  try {
@@ -2706,11 +2727,12 @@ function assessCheckFromEvidence(check, evidence) {
2706
2727
  }
2707
2728
  if (check.type === "route_loaded") {
2708
2729
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
2709
- const failed = viewports.filter((viewport) => !successfulRoute({
2730
+ const routes = viewports.map((viewport) => ({
2710
2731
  ...viewport.route,
2711
2732
  expected_path: expectedPath,
2712
2733
  matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
2713
- }, evidence.target_url));
2734
+ }));
2735
+ const failed = routes.filter((route) => !successfulRoute(route, evidence.target_url));
2714
2736
  return {
2715
2737
  type: check.type,
2716
2738
  label: checkLabel(check),
@@ -2718,9 +2740,10 @@ function assessCheckFromEvidence(check, evidence) {
2718
2740
  evidence: {
2719
2741
  expected_path: expectedPath,
2720
2742
  observed_paths: viewports.map((viewport) => viewport.route.observed),
2721
- http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null)
2743
+ http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null),
2744
+ route_errors: viewports.map((viewport) => viewport.route.error ?? null)
2722
2745
  },
2723
- message: failed.length ? `Route did not load as ${expectedPath} in ${failed.length} viewport(s).` : void 0
2746
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : void 0
2724
2747
  };
2725
2748
  }
2726
2749
  if (check.type === "url_search_param_equals") {
@@ -3588,6 +3611,29 @@ function routePathMatches(observed, expected, targetUrl) {
3588
3611
  function routeOk(route, targetUrl) {
3589
3612
  return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
3590
3613
  }
3614
+ function routeReadinessFailed(route, targetUrl) {
3615
+ const matched = route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl));
3616
+ const httpOk = route && (route.http_status == null || route.http_status < 400);
3617
+ return Boolean(matched && httpOk && route.error);
3618
+ }
3619
+ function compactRouteError(error) {
3620
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
3621
+ return text ? text.slice(0, 240) : undefined;
3622
+ }
3623
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
3624
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
3625
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
3626
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
3627
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
3628
+ return "Route matched " + expectedPath + ", but readiness failed in " + readinessFailures.length + " viewport(s)" + (sample ? ": " + sample : ".");
3629
+ }
3630
+ if (readinessFailures.length) {
3631
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
3632
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
3633
+ return "Route did not become ready as " + expectedPath + " in " + failedRoutes.length + " viewport(s); " + readinessFailures.length + " matched path and HTTP but failed readiness" + (sample ? ": " + sample : ".");
3634
+ }
3635
+ return "Route did not load as " + expectedPath + " in " + failedRoutes.length + " viewport(s).";
3636
+ }
3591
3637
  function parseEvidenceUrl(value, targetUrl) {
3592
3638
  if (!value) return null;
3593
3639
  try { return targetUrl ? new URL(value, targetUrl) : new URL(value); } catch {}
@@ -4889,11 +4935,12 @@ function assessProfile(profile, evidence) {
4889
4935
  }
4890
4936
  if (check.type === "route_loaded") {
4891
4937
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
4892
- const failed = checkViewports.filter((viewport) => {
4938
+ const routes = checkViewports.map((viewport) => {
4893
4939
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
4894
4940
  route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
4895
- return !routeOk(route, evidence.target_url);
4941
+ return route;
4896
4942
  });
4943
+ const failed = routes.filter((route) => !routeOk(route, evidence.target_url));
4897
4944
  checks.push({
4898
4945
  type: check.type,
4899
4946
  label: check.label || check.type,
@@ -4902,8 +4949,9 @@ function assessProfile(profile, evidence) {
4902
4949
  expected_path: expectedPath,
4903
4950
  observed_paths: checkViewports.map((viewport) => viewport.route && viewport.route.observed),
4904
4951
  http_statuses: checkViewports.map((viewport) => viewport.route ? viewport.route.http_status ?? null : null),
4952
+ route_errors: checkViewports.map((viewport) => viewport.route ? viewport.route.error ?? null : null),
4905
4953
  },
4906
- message: failed.length ? "Route did not load as " + expectedPath + " in " + failed.length + " viewport(s)." : undefined,
4954
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : undefined,
4907
4955
  });
4908
4956
  continue;
4909
4957
  }
package/dist/cli.cjs CHANGED
@@ -9594,6 +9594,27 @@ function successfulRoute(route, targetUrl) {
9594
9594
  const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
9595
9595
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
9596
9596
  }
9597
+ function routeReadinessFailed(route, targetUrl) {
9598
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
9599
+ const httpOk = route.http_status === null || route.http_status === void 0 || route.http_status < 400;
9600
+ return matched && httpOk && Boolean(route.error);
9601
+ }
9602
+ function compactRouteError(error) {
9603
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
9604
+ return text ? text.slice(0, 240) : void 0;
9605
+ }
9606
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
9607
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
9608
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
9609
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
9610
+ return `Route matched ${expectedPath}, but readiness failed in ${readinessFailures.length} viewport(s)${sample ? `: ${sample}` : "."}`;
9611
+ }
9612
+ if (readinessFailures.length) {
9613
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
9614
+ return `Route did not become ready as ${expectedPath} in ${failedRoutes.length} viewport(s); ${readinessFailures.length} matched path and HTTP but failed readiness${sample ? `: ${sample}` : "."}`;
9615
+ }
9616
+ return `Route did not load as ${expectedPath} in ${failedRoutes.length} viewport(s).`;
9617
+ }
9597
9618
  function parseEvidenceUrl(value, targetUrl) {
9598
9619
  if (!value) return void 0;
9599
9620
  try {
@@ -9663,11 +9684,12 @@ function assessCheckFromEvidence(check, evidence) {
9663
9684
  }
9664
9685
  if (check.type === "route_loaded") {
9665
9686
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
9666
- const failed = viewports.filter((viewport) => !successfulRoute({
9687
+ const routes = viewports.map((viewport) => ({
9667
9688
  ...viewport.route,
9668
9689
  expected_path: expectedPath,
9669
9690
  matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
9670
- }, evidence.target_url));
9691
+ }));
9692
+ const failed = routes.filter((route) => !successfulRoute(route, evidence.target_url));
9671
9693
  return {
9672
9694
  type: check.type,
9673
9695
  label: checkLabel(check),
@@ -9675,9 +9697,10 @@ function assessCheckFromEvidence(check, evidence) {
9675
9697
  evidence: {
9676
9698
  expected_path: expectedPath,
9677
9699
  observed_paths: viewports.map((viewport) => viewport.route.observed),
9678
- http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null)
9700
+ http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null),
9701
+ route_errors: viewports.map((viewport) => viewport.route.error ?? null)
9679
9702
  },
9680
- message: failed.length ? `Route did not load as ${expectedPath} in ${failed.length} viewport(s).` : void 0
9703
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : void 0
9681
9704
  };
9682
9705
  }
9683
9706
  if (check.type === "url_search_param_equals") {
@@ -10529,6 +10552,29 @@ function routePathMatches(observed, expected, targetUrl) {
10529
10552
  function routeOk(route, targetUrl) {
10530
10553
  return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
10531
10554
  }
10555
+ function routeReadinessFailed(route, targetUrl) {
10556
+ const matched = route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl));
10557
+ const httpOk = route && (route.http_status == null || route.http_status < 400);
10558
+ return Boolean(matched && httpOk && route.error);
10559
+ }
10560
+ function compactRouteError(error) {
10561
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
10562
+ return text ? text.slice(0, 240) : undefined;
10563
+ }
10564
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
10565
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
10566
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
10567
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
10568
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
10569
+ return "Route matched " + expectedPath + ", but readiness failed in " + readinessFailures.length + " viewport(s)" + (sample ? ": " + sample : ".");
10570
+ }
10571
+ if (readinessFailures.length) {
10572
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
10573
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
10574
+ return "Route did not become ready as " + expectedPath + " in " + failedRoutes.length + " viewport(s); " + readinessFailures.length + " matched path and HTTP but failed readiness" + (sample ? ": " + sample : ".");
10575
+ }
10576
+ return "Route did not load as " + expectedPath + " in " + failedRoutes.length + " viewport(s).";
10577
+ }
10532
10578
  function parseEvidenceUrl(value, targetUrl) {
10533
10579
  if (!value) return null;
10534
10580
  try { return targetUrl ? new URL(value, targetUrl) : new URL(value); } catch {}
@@ -11830,11 +11876,12 @@ function assessProfile(profile, evidence) {
11830
11876
  }
11831
11877
  if (check.type === "route_loaded") {
11832
11878
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
11833
- const failed = checkViewports.filter((viewport) => {
11879
+ const routes = checkViewports.map((viewport) => {
11834
11880
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
11835
11881
  route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
11836
- return !routeOk(route, evidence.target_url);
11882
+ return route;
11837
11883
  });
11884
+ const failed = routes.filter((route) => !routeOk(route, evidence.target_url));
11838
11885
  checks.push({
11839
11886
  type: check.type,
11840
11887
  label: check.label || check.type,
@@ -11843,8 +11890,9 @@ function assessProfile(profile, evidence) {
11843
11890
  expected_path: expectedPath,
11844
11891
  observed_paths: checkViewports.map((viewport) => viewport.route && viewport.route.observed),
11845
11892
  http_statuses: checkViewports.map((viewport) => viewport.route ? viewport.route.http_status ?? null : null),
11893
+ route_errors: checkViewports.map((viewport) => viewport.route ? viewport.route.error ?? null : null),
11846
11894
  },
11847
- message: failed.length ? "Route did not load as " + expectedPath + " in " + failed.length + " viewport(s)." : undefined,
11895
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : undefined,
11848
11896
  });
11849
11897
  continue;
11850
11898
  }
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  profileStatusExitCode,
14
14
  resolveRiddleProofProfileTargetUrl,
15
15
  resolveRiddleProofProfileTimeoutSec
16
- } from "./chunk-RAEZDEAU.js";
16
+ } from "./chunk-GDFGO66T.js";
17
17
  import {
18
18
  createRiddleApiClient,
19
19
  isTerminalRiddleJobStatus,
package/dist/index.cjs CHANGED
@@ -11370,6 +11370,27 @@ function successfulRoute(route, targetUrl) {
11370
11370
  const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
11371
11371
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
11372
11372
  }
11373
+ function routeReadinessFailed(route, targetUrl) {
11374
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
11375
+ const httpOk = route.http_status === null || route.http_status === void 0 || route.http_status < 400;
11376
+ return matched && httpOk && Boolean(route.error);
11377
+ }
11378
+ function compactRouteError(error) {
11379
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
11380
+ return text ? text.slice(0, 240) : void 0;
11381
+ }
11382
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
11383
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
11384
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
11385
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
11386
+ return `Route matched ${expectedPath}, but readiness failed in ${readinessFailures.length} viewport(s)${sample ? `: ${sample}` : "."}`;
11387
+ }
11388
+ if (readinessFailures.length) {
11389
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
11390
+ return `Route did not become ready as ${expectedPath} in ${failedRoutes.length} viewport(s); ${readinessFailures.length} matched path and HTTP but failed readiness${sample ? `: ${sample}` : "."}`;
11391
+ }
11392
+ return `Route did not load as ${expectedPath} in ${failedRoutes.length} viewport(s).`;
11393
+ }
11373
11394
  function parseEvidenceUrl(value, targetUrl) {
11374
11395
  if (!value) return void 0;
11375
11396
  try {
@@ -11439,11 +11460,12 @@ function assessCheckFromEvidence(check, evidence) {
11439
11460
  }
11440
11461
  if (check.type === "route_loaded") {
11441
11462
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
11442
- const failed = viewports.filter((viewport) => !successfulRoute({
11463
+ const routes = viewports.map((viewport) => ({
11443
11464
  ...viewport.route,
11444
11465
  expected_path: expectedPath,
11445
11466
  matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
11446
- }, evidence.target_url));
11467
+ }));
11468
+ const failed = routes.filter((route) => !successfulRoute(route, evidence.target_url));
11447
11469
  return {
11448
11470
  type: check.type,
11449
11471
  label: checkLabel(check),
@@ -11451,9 +11473,10 @@ function assessCheckFromEvidence(check, evidence) {
11451
11473
  evidence: {
11452
11474
  expected_path: expectedPath,
11453
11475
  observed_paths: viewports.map((viewport) => viewport.route.observed),
11454
- http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null)
11476
+ http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null),
11477
+ route_errors: viewports.map((viewport) => viewport.route.error ?? null)
11455
11478
  },
11456
- message: failed.length ? `Route did not load as ${expectedPath} in ${failed.length} viewport(s).` : void 0
11479
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : void 0
11457
11480
  };
11458
11481
  }
11459
11482
  if (check.type === "url_search_param_equals") {
@@ -12321,6 +12344,29 @@ function routePathMatches(observed, expected, targetUrl) {
12321
12344
  function routeOk(route, targetUrl) {
12322
12345
  return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
12323
12346
  }
12347
+ function routeReadinessFailed(route, targetUrl) {
12348
+ const matched = route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl));
12349
+ const httpOk = route && (route.http_status == null || route.http_status < 400);
12350
+ return Boolean(matched && httpOk && route.error);
12351
+ }
12352
+ function compactRouteError(error) {
12353
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
12354
+ return text ? text.slice(0, 240) : undefined;
12355
+ }
12356
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
12357
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
12358
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
12359
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
12360
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
12361
+ return "Route matched " + expectedPath + ", but readiness failed in " + readinessFailures.length + " viewport(s)" + (sample ? ": " + sample : ".");
12362
+ }
12363
+ if (readinessFailures.length) {
12364
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
12365
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
12366
+ return "Route did not become ready as " + expectedPath + " in " + failedRoutes.length + " viewport(s); " + readinessFailures.length + " matched path and HTTP but failed readiness" + (sample ? ": " + sample : ".");
12367
+ }
12368
+ return "Route did not load as " + expectedPath + " in " + failedRoutes.length + " viewport(s).";
12369
+ }
12324
12370
  function parseEvidenceUrl(value, targetUrl) {
12325
12371
  if (!value) return null;
12326
12372
  try { return targetUrl ? new URL(value, targetUrl) : new URL(value); } catch {}
@@ -13622,11 +13668,12 @@ function assessProfile(profile, evidence) {
13622
13668
  }
13623
13669
  if (check.type === "route_loaded") {
13624
13670
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
13625
- const failed = checkViewports.filter((viewport) => {
13671
+ const routes = checkViewports.map((viewport) => {
13626
13672
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
13627
13673
  route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
13628
- return !routeOk(route, evidence.target_url);
13674
+ return route;
13629
13675
  });
13676
+ const failed = routes.filter((route) => !routeOk(route, evidence.target_url));
13630
13677
  checks.push({
13631
13678
  type: check.type,
13632
13679
  label: check.label || check.type,
@@ -13635,8 +13682,9 @@ function assessProfile(profile, evidence) {
13635
13682
  expected_path: expectedPath,
13636
13683
  observed_paths: checkViewports.map((viewport) => viewport.route && viewport.route.observed),
13637
13684
  http_statuses: checkViewports.map((viewport) => viewport.route ? viewport.route.http_status ?? null : null),
13685
+ route_errors: checkViewports.map((viewport) => viewport.route ? viewport.route.error ?? null : null),
13638
13686
  },
13639
- message: failed.length ? "Route did not load as " + expectedPath + " in " + failed.length + " viewport(s)." : undefined,
13687
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : undefined,
13640
13688
  });
13641
13689
  continue;
13642
13690
  }
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  resolveRiddleProofProfileTimeoutSec,
63
63
  slugifyRiddleProofProfileName,
64
64
  summarizeRiddleProofProfileResult
65
- } from "./chunk-RAEZDEAU.js";
65
+ } from "./chunk-GDFGO66T.js";
66
66
  import {
67
67
  DEFAULT_RIDDLE_API_BASE_URL,
68
68
  DEFAULT_RIDDLE_API_KEY_FILE,
package/dist/profile.cjs CHANGED
@@ -2684,6 +2684,27 @@ function successfulRoute(route, targetUrl) {
2684
2684
  const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
2685
2685
  return matched && !route.error && (route.http_status === null || route.http_status === void 0 || route.http_status < 400);
2686
2686
  }
2687
+ function routeReadinessFailed(route, targetUrl) {
2688
+ const matched = route.matched || routePathMatches(route.observed, route.expected_path, targetUrl);
2689
+ const httpOk = route.http_status === null || route.http_status === void 0 || route.http_status < 400;
2690
+ return matched && httpOk && Boolean(route.error);
2691
+ }
2692
+ function compactRouteError(error) {
2693
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
2694
+ return text ? text.slice(0, 240) : void 0;
2695
+ }
2696
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
2697
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
2698
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
2699
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
2700
+ return `Route matched ${expectedPath}, but readiness failed in ${readinessFailures.length} viewport(s)${sample ? `: ${sample}` : "."}`;
2701
+ }
2702
+ if (readinessFailures.length) {
2703
+ const sample = compactRouteError(readinessFailures.find((route) => route.error)?.error);
2704
+ return `Route did not become ready as ${expectedPath} in ${failedRoutes.length} viewport(s); ${readinessFailures.length} matched path and HTTP but failed readiness${sample ? `: ${sample}` : "."}`;
2705
+ }
2706
+ return `Route did not load as ${expectedPath} in ${failedRoutes.length} viewport(s).`;
2707
+ }
2687
2708
  function parseEvidenceUrl(value, targetUrl) {
2688
2709
  if (!value) return void 0;
2689
2710
  try {
@@ -2753,11 +2774,12 @@ function assessCheckFromEvidence(check, evidence) {
2753
2774
  }
2754
2775
  if (check.type === "route_loaded") {
2755
2776
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
2756
- const failed = viewports.filter((viewport) => !successfulRoute({
2777
+ const routes = viewports.map((viewport) => ({
2757
2778
  ...viewport.route,
2758
2779
  expected_path: expectedPath,
2759
2780
  matched: routePathMatches(viewport.route.observed, expectedPath, evidence.target_url) || viewport.route.matched
2760
- }, evidence.target_url));
2781
+ }));
2782
+ const failed = routes.filter((route) => !successfulRoute(route, evidence.target_url));
2761
2783
  return {
2762
2784
  type: check.type,
2763
2785
  label: checkLabel(check),
@@ -2765,9 +2787,10 @@ function assessCheckFromEvidence(check, evidence) {
2765
2787
  evidence: {
2766
2788
  expected_path: expectedPath,
2767
2789
  observed_paths: viewports.map((viewport) => viewport.route.observed),
2768
- http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null)
2790
+ http_statuses: viewports.map((viewport) => viewport.route.http_status ?? null),
2791
+ route_errors: viewports.map((viewport) => viewport.route.error ?? null)
2769
2792
  },
2770
- message: failed.length ? `Route did not load as ${expectedPath} in ${failed.length} viewport(s).` : void 0
2793
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : void 0
2771
2794
  };
2772
2795
  }
2773
2796
  if (check.type === "url_search_param_equals") {
@@ -3635,6 +3658,29 @@ function routePathMatches(observed, expected, targetUrl) {
3635
3658
  function routeOk(route, targetUrl) {
3636
3659
  return Boolean(route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl)) && !route.error && (route.http_status == null || route.http_status < 400));
3637
3660
  }
3661
+ function routeReadinessFailed(route, targetUrl) {
3662
+ const matched = route && (route.matched || routePathMatches(route.observed, route.expected_path, targetUrl));
3663
+ const httpOk = route && (route.http_status == null || route.http_status < 400);
3664
+ return Boolean(matched && httpOk && route.error);
3665
+ }
3666
+ function compactRouteError(error) {
3667
+ const text = typeof error === "string" ? error.replace(/\s+/g, " ").trim() : "";
3668
+ return text ? text.slice(0, 240) : undefined;
3669
+ }
3670
+ function routeLoadedFailureMessage(failedRoutes, expectedPath, targetUrl) {
3671
+ const readinessFailures = failedRoutes.filter((route) => routeReadinessFailed(route, targetUrl));
3672
+ if (readinessFailures.length === failedRoutes.length && readinessFailures.length) {
3673
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
3674
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
3675
+ return "Route matched " + expectedPath + ", but readiness failed in " + readinessFailures.length + " viewport(s)" + (sample ? ": " + sample : ".");
3676
+ }
3677
+ if (readinessFailures.length) {
3678
+ const sampleRoute = readinessFailures.find((route) => route && route.error);
3679
+ const sample = compactRouteError(sampleRoute && sampleRoute.error);
3680
+ return "Route did not become ready as " + expectedPath + " in " + failedRoutes.length + " viewport(s); " + readinessFailures.length + " matched path and HTTP but failed readiness" + (sample ? ": " + sample : ".");
3681
+ }
3682
+ return "Route did not load as " + expectedPath + " in " + failedRoutes.length + " viewport(s).";
3683
+ }
3638
3684
  function parseEvidenceUrl(value, targetUrl) {
3639
3685
  if (!value) return null;
3640
3686
  try { return targetUrl ? new URL(value, targetUrl) : new URL(value); } catch {}
@@ -4936,11 +4982,12 @@ function assessProfile(profile, evidence) {
4936
4982
  }
4937
4983
  if (check.type === "route_loaded") {
4938
4984
  const expectedPath = check.expected_path || new URL(evidence.target_url).pathname || "/";
4939
- const failed = checkViewports.filter((viewport) => {
4985
+ const routes = checkViewports.map((viewport) => {
4940
4986
  const route = { ...(viewport.route || {}), expected_path: expectedPath };
4941
4987
  route.matched = routePathMatches(route.observed, expectedPath, evidence.target_url) || route.matched;
4942
- return !routeOk(route, evidence.target_url);
4988
+ return route;
4943
4989
  });
4990
+ const failed = routes.filter((route) => !routeOk(route, evidence.target_url));
4944
4991
  checks.push({
4945
4992
  type: check.type,
4946
4993
  label: check.label || check.type,
@@ -4949,8 +4996,9 @@ function assessProfile(profile, evidence) {
4949
4996
  expected_path: expectedPath,
4950
4997
  observed_paths: checkViewports.map((viewport) => viewport.route && viewport.route.observed),
4951
4998
  http_statuses: checkViewports.map((viewport) => viewport.route ? viewport.route.http_status ?? null : null),
4999
+ route_errors: checkViewports.map((viewport) => viewport.route ? viewport.route.error ?? null : null),
4952
5000
  },
4953
- message: failed.length ? "Route did not load as " + expectedPath + " in " + failed.length + " viewport(s)." : undefined,
5001
+ message: failed.length ? routeLoadedFailureMessage(failed, expectedPath, evidence.target_url) : undefined,
4954
5002
  });
4955
5003
  continue;
4956
5004
  }
package/dist/profile.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  resolveRiddleProofProfileTimeoutSec,
24
24
  slugifyRiddleProofProfileName,
25
25
  summarizeRiddleProofProfileResult
26
- } from "./chunk-RAEZDEAU.js";
26
+ } from "./chunk-GDFGO66T.js";
27
27
  export {
28
28
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
29
29
  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.175",
3
+ "version": "0.7.176",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",