@riddledc/riddle-proof 0.7.18 → 0.7.20

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.
@@ -456,11 +456,13 @@ function assessSetupActionsFromEvidence(profile, evidence) {
456
456
  message: failed.length ? `Setup actions failed in ${failed.length} viewport action(s).` : void 0
457
457
  };
458
458
  }
459
- function profileStatusFromEvidence(evidence, checks) {
459
+ function profileStatusFromEvidence(profile, evidence, checks) {
460
460
  if (!evidence) return "proof_insufficient";
461
461
  const viewports = evidence.viewports || [];
462
+ const expectedViewportCount = profile.target.viewports?.length || 0;
462
463
  if (!viewports.length || !checks.length) return "proof_insufficient";
463
464
  if (viewports.some((viewport) => viewport.navigation_error)) return "environment_blocked";
465
+ if (expectedViewportCount && viewports.length < expectedViewportCount) return "proof_insufficient";
464
466
  if (checks.some((check) => check.status === "needs_human_review")) return "needs_human_review";
465
467
  if (checks.some((check) => check.status === "failed")) return "product_regression";
466
468
  return "passed";
@@ -471,7 +473,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
471
473
  assessSetupActionsFromEvidence(profile, evidence),
472
474
  ...profile.checks.map((check) => assessCheckFromEvidence(check, evidence))
473
475
  ].filter((check) => Boolean(check)) : [];
474
- const status = profileStatusFromEvidence(evidence, checks);
476
+ const status = profileStatusFromEvidence(profile, evidence, checks);
475
477
  const firstViewport = evidence?.viewports?.[0];
476
478
  const screenshots = (evidence?.viewports || []).map((viewport) => viewport.screenshot_label).filter((label) => Boolean(label));
477
479
  return {
@@ -751,8 +753,10 @@ function assessProfile(profile, evidence) {
751
753
  checks.push({ type: check.type, label: check.label || check.type, status: "needs_human_review", evidence: {}, message: "Unsupported check type." });
752
754
  }
753
755
  let status = "passed";
756
+ const expectedViewportCount = profile.target && Array.isArray(profile.target.viewports) ? profile.target.viewports.length : 0;
754
757
  if (!viewports.length || !checks.length) status = "proof_insufficient";
755
758
  else if (viewports.some((viewport) => viewport.navigation_error)) status = "environment_blocked";
759
+ else if (expectedViewportCount && viewports.length < expectedViewportCount) status = "proof_insufficient";
756
760
  else if (checks.some((check) => check.status === "needs_human_review")) status = "needs_human_review";
757
761
  else if (checks.some((check) => check.status === "failed")) status = "product_regression";
758
762
  const screenshotLabels = viewports.map((viewport) => viewport.screenshot_label).filter(Boolean);
@@ -832,6 +836,11 @@ function setupTextMatches(sample, action) {
832
836
  async function setupLocatorText(locator, index) {
833
837
  return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
834
838
  }
839
+ function compactSetupResultText(value) {
840
+ const text = String(value || "").replace(/\s+/g, " ").trim();
841
+ if (text.length <= 500) return text;
842
+ return text.slice(0, 500) + "... (" + text.length + " chars)";
843
+ }
835
844
  async function setupLocatorVisible(locator, index) {
836
845
  return await locator.nth(index).isVisible({ timeout: 1000 }).catch(() => false);
837
846
  }
@@ -865,12 +874,12 @@ async function executeSetupAction(action, ordinal) {
865
874
  const visible = await setupLocatorVisible(locator, index);
866
875
  if (visible) {
867
876
  targetIndex = index;
868
- matchedText = text;
877
+ matchedText = compactSetupResultText(text);
869
878
  break;
870
879
  }
871
880
  if (hiddenMatchIndex < 0) {
872
881
  hiddenMatchIndex = index;
873
- hiddenMatchedText = text;
882
+ hiddenMatchedText = compactSetupResultText(text);
874
883
  }
875
884
  }
876
885
  }
@@ -891,12 +900,12 @@ async function executeSetupAction(action, ordinal) {
891
900
  const text = await setupLocatorText(locator, index);
892
901
  lastText = text || lastText;
893
902
  if (setupTextMatches(text, action)) {
894
- return { ...base, ok: true, text, target_index: index, timeout_ms: timeout };
903
+ return { ...base, ok: true, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
895
904
  }
896
905
  }
897
906
  await page.waitForTimeout(100);
898
907
  }
899
- return { ...base, reason: "text_not_found", text: lastText, timeout_ms: timeout };
908
+ return { ...base, reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
900
909
  }
901
910
  return { ...base, reason: "unsupported_action" };
902
911
  } catch (error) {
@@ -1021,33 +1030,44 @@ async function captureViewport(viewport) {
1021
1030
  }
1022
1031
  ${runtimeScriptAssessmentSource()}
1023
1032
  const viewports = [];
1033
+ function buildProfileEvidence(currentViewports) {
1034
+ const expectedViewportCount = (profile.target.viewports || []).length;
1035
+ return {
1036
+ version: "riddle-proof.profile-evidence.v1",
1037
+ profile_name: profile.name,
1038
+ target_url: targetUrl,
1039
+ baseline_policy: profile.baseline_policy || "invariant_only",
1040
+ captured_at: capturedAt,
1041
+ viewports: currentViewports.slice(),
1042
+ console: {
1043
+ events: consoleEvents,
1044
+ fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
1045
+ },
1046
+ page_errors: pageErrors,
1047
+ dom_summary: {
1048
+ expected_viewport_count: expectedViewportCount,
1049
+ viewport_count: currentViewports.length,
1050
+ partial: expectedViewportCount > 0 && currentViewports.length < expectedViewportCount,
1051
+ routes: currentViewports.map((viewport) => viewport.route),
1052
+ titles: currentViewports.map((viewport) => viewport.title),
1053
+ overflow_px: currentViewports.map((viewport) => viewport.overflow_px),
1054
+ },
1055
+ };
1056
+ }
1057
+ async function saveProfileArtifacts(currentViewports) {
1058
+ const evidence = buildProfileEvidence(currentViewports);
1059
+ const result = assessProfile(profile, evidence);
1060
+ if (typeof saveJson === "function") {
1061
+ await saveJson("proof.json", result);
1062
+ await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
1063
+ await saveJson("dom-summary.json", evidence.dom_summary);
1064
+ }
1065
+ return result;
1066
+ }
1067
+ let result = await saveProfileArtifacts(viewports);
1024
1068
  for (const viewport of profile.target.viewports || []) {
1025
1069
  viewports.push(await captureViewport(viewport));
1026
- }
1027
- const evidence = {
1028
- version: "riddle-proof.profile-evidence.v1",
1029
- profile_name: profile.name,
1030
- target_url: targetUrl,
1031
- baseline_policy: profile.baseline_policy || "invariant_only",
1032
- captured_at: capturedAt,
1033
- viewports,
1034
- console: {
1035
- events: consoleEvents,
1036
- fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
1037
- },
1038
- page_errors: pageErrors,
1039
- dom_summary: {
1040
- viewport_count: viewports.length,
1041
- routes: viewports.map((viewport) => viewport.route),
1042
- titles: viewports.map((viewport) => viewport.title),
1043
- overflow_px: viewports.map((viewport) => viewport.overflow_px),
1044
- },
1045
- };
1046
- const result = assessProfile(profile, evidence);
1047
- if (typeof saveJson === "function") {
1048
- await saveJson("proof.json", result);
1049
- await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
1050
- await saveJson("dom-summary.json", evidence.dom_summary);
1070
+ result = await saveProfileArtifacts(viewports);
1051
1071
  }
1052
1072
  return result;
1053
1073
  `.trim();
package/dist/cli.cjs CHANGED
@@ -7236,11 +7236,13 @@ function assessSetupActionsFromEvidence(profile, evidence) {
7236
7236
  message: failed.length ? `Setup actions failed in ${failed.length} viewport action(s).` : void 0
7237
7237
  };
7238
7238
  }
7239
- function profileStatusFromEvidence(evidence, checks) {
7239
+ function profileStatusFromEvidence(profile, evidence, checks) {
7240
7240
  if (!evidence) return "proof_insufficient";
7241
7241
  const viewports = evidence.viewports || [];
7242
+ const expectedViewportCount = profile.target.viewports?.length || 0;
7242
7243
  if (!viewports.length || !checks.length) return "proof_insufficient";
7243
7244
  if (viewports.some((viewport) => viewport.navigation_error)) return "environment_blocked";
7245
+ if (expectedViewportCount && viewports.length < expectedViewportCount) return "proof_insufficient";
7244
7246
  if (checks.some((check) => check.status === "needs_human_review")) return "needs_human_review";
7245
7247
  if (checks.some((check) => check.status === "failed")) return "product_regression";
7246
7248
  return "passed";
@@ -7251,7 +7253,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
7251
7253
  assessSetupActionsFromEvidence(profile, evidence),
7252
7254
  ...profile.checks.map((check) => assessCheckFromEvidence(check, evidence))
7253
7255
  ].filter((check) => Boolean(check)) : [];
7254
- const status = profileStatusFromEvidence(evidence, checks);
7256
+ const status = profileStatusFromEvidence(profile, evidence, checks);
7255
7257
  const firstViewport = evidence?.viewports?.[0];
7256
7258
  const screenshots = (evidence?.viewports || []).map((viewport) => viewport.screenshot_label).filter((label) => Boolean(label));
7257
7259
  return {
@@ -7515,8 +7517,10 @@ function assessProfile(profile, evidence) {
7515
7517
  checks.push({ type: check.type, label: check.label || check.type, status: "needs_human_review", evidence: {}, message: "Unsupported check type." });
7516
7518
  }
7517
7519
  let status = "passed";
7520
+ const expectedViewportCount = profile.target && Array.isArray(profile.target.viewports) ? profile.target.viewports.length : 0;
7518
7521
  if (!viewports.length || !checks.length) status = "proof_insufficient";
7519
7522
  else if (viewports.some((viewport) => viewport.navigation_error)) status = "environment_blocked";
7523
+ else if (expectedViewportCount && viewports.length < expectedViewportCount) status = "proof_insufficient";
7520
7524
  else if (checks.some((check) => check.status === "needs_human_review")) status = "needs_human_review";
7521
7525
  else if (checks.some((check) => check.status === "failed")) status = "product_regression";
7522
7526
  const screenshotLabels = viewports.map((viewport) => viewport.screenshot_label).filter(Boolean);
@@ -7596,6 +7600,11 @@ function setupTextMatches(sample, action) {
7596
7600
  async function setupLocatorText(locator, index) {
7597
7601
  return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
7598
7602
  }
7603
+ function compactSetupResultText(value) {
7604
+ const text = String(value || "").replace(/\s+/g, " ").trim();
7605
+ if (text.length <= 500) return text;
7606
+ return text.slice(0, 500) + "... (" + text.length + " chars)";
7607
+ }
7599
7608
  async function setupLocatorVisible(locator, index) {
7600
7609
  return await locator.nth(index).isVisible({ timeout: 1000 }).catch(() => false);
7601
7610
  }
@@ -7629,12 +7638,12 @@ async function executeSetupAction(action, ordinal) {
7629
7638
  const visible = await setupLocatorVisible(locator, index);
7630
7639
  if (visible) {
7631
7640
  targetIndex = index;
7632
- matchedText = text;
7641
+ matchedText = compactSetupResultText(text);
7633
7642
  break;
7634
7643
  }
7635
7644
  if (hiddenMatchIndex < 0) {
7636
7645
  hiddenMatchIndex = index;
7637
- hiddenMatchedText = text;
7646
+ hiddenMatchedText = compactSetupResultText(text);
7638
7647
  }
7639
7648
  }
7640
7649
  }
@@ -7655,12 +7664,12 @@ async function executeSetupAction(action, ordinal) {
7655
7664
  const text = await setupLocatorText(locator, index);
7656
7665
  lastText = text || lastText;
7657
7666
  if (setupTextMatches(text, action)) {
7658
- return { ...base, ok: true, text, target_index: index, timeout_ms: timeout };
7667
+ return { ...base, ok: true, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
7659
7668
  }
7660
7669
  }
7661
7670
  await page.waitForTimeout(100);
7662
7671
  }
7663
- return { ...base, reason: "text_not_found", text: lastText, timeout_ms: timeout };
7672
+ return { ...base, reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
7664
7673
  }
7665
7674
  return { ...base, reason: "unsupported_action" };
7666
7675
  } catch (error) {
@@ -7785,33 +7794,44 @@ async function captureViewport(viewport) {
7785
7794
  }
7786
7795
  ${runtimeScriptAssessmentSource()}
7787
7796
  const viewports = [];
7797
+ function buildProfileEvidence(currentViewports) {
7798
+ const expectedViewportCount = (profile.target.viewports || []).length;
7799
+ return {
7800
+ version: "riddle-proof.profile-evidence.v1",
7801
+ profile_name: profile.name,
7802
+ target_url: targetUrl,
7803
+ baseline_policy: profile.baseline_policy || "invariant_only",
7804
+ captured_at: capturedAt,
7805
+ viewports: currentViewports.slice(),
7806
+ console: {
7807
+ events: consoleEvents,
7808
+ fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
7809
+ },
7810
+ page_errors: pageErrors,
7811
+ dom_summary: {
7812
+ expected_viewport_count: expectedViewportCount,
7813
+ viewport_count: currentViewports.length,
7814
+ partial: expectedViewportCount > 0 && currentViewports.length < expectedViewportCount,
7815
+ routes: currentViewports.map((viewport) => viewport.route),
7816
+ titles: currentViewports.map((viewport) => viewport.title),
7817
+ overflow_px: currentViewports.map((viewport) => viewport.overflow_px),
7818
+ },
7819
+ };
7820
+ }
7821
+ async function saveProfileArtifacts(currentViewports) {
7822
+ const evidence = buildProfileEvidence(currentViewports);
7823
+ const result = assessProfile(profile, evidence);
7824
+ if (typeof saveJson === "function") {
7825
+ await saveJson("proof.json", result);
7826
+ await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
7827
+ await saveJson("dom-summary.json", evidence.dom_summary);
7828
+ }
7829
+ return result;
7830
+ }
7831
+ let result = await saveProfileArtifacts(viewports);
7788
7832
  for (const viewport of profile.target.viewports || []) {
7789
7833
  viewports.push(await captureViewport(viewport));
7790
- }
7791
- const evidence = {
7792
- version: "riddle-proof.profile-evidence.v1",
7793
- profile_name: profile.name,
7794
- target_url: targetUrl,
7795
- baseline_policy: profile.baseline_policy || "invariant_only",
7796
- captured_at: capturedAt,
7797
- viewports,
7798
- console: {
7799
- events: consoleEvents,
7800
- fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
7801
- },
7802
- page_errors: pageErrors,
7803
- dom_summary: {
7804
- viewport_count: viewports.length,
7805
- routes: viewports.map((viewport) => viewport.route),
7806
- titles: viewports.map((viewport) => viewport.title),
7807
- overflow_px: viewports.map((viewport) => viewport.overflow_px),
7808
- },
7809
- };
7810
- const result = assessProfile(profile, evidence);
7811
- if (typeof saveJson === "function") {
7812
- await saveJson("proof.json", result);
7813
- await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
7814
- await saveJson("dom-summary.json", evidence.dom_summary);
7834
+ result = await saveProfileArtifacts(viewports);
7815
7835
  }
7816
7836
  return result;
7817
7837
  `.trim();
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  profileStatusExitCode,
11
11
  resolveRiddleProofProfileTargetUrl,
12
12
  resolveRiddleProofProfileTimeoutSec
13
- } from "./chunk-7T5WT2WO.js";
13
+ } from "./chunk-TPUR67H5.js";
14
14
  import {
15
15
  createRiddleApiClient,
16
16
  parseRiddleViewport
package/dist/index.cjs CHANGED
@@ -9025,11 +9025,13 @@ function assessSetupActionsFromEvidence(profile, evidence) {
9025
9025
  message: failed.length ? `Setup actions failed in ${failed.length} viewport action(s).` : void 0
9026
9026
  };
9027
9027
  }
9028
- function profileStatusFromEvidence(evidence, checks) {
9028
+ function profileStatusFromEvidence(profile, evidence, checks) {
9029
9029
  if (!evidence) return "proof_insufficient";
9030
9030
  const viewports = evidence.viewports || [];
9031
+ const expectedViewportCount = profile.target.viewports?.length || 0;
9031
9032
  if (!viewports.length || !checks.length) return "proof_insufficient";
9032
9033
  if (viewports.some((viewport) => viewport.navigation_error)) return "environment_blocked";
9034
+ if (expectedViewportCount && viewports.length < expectedViewportCount) return "proof_insufficient";
9033
9035
  if (checks.some((check) => check.status === "needs_human_review")) return "needs_human_review";
9034
9036
  if (checks.some((check) => check.status === "failed")) return "product_regression";
9035
9037
  return "passed";
@@ -9040,7 +9042,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
9040
9042
  assessSetupActionsFromEvidence(profile, evidence),
9041
9043
  ...profile.checks.map((check) => assessCheckFromEvidence(check, evidence))
9042
9044
  ].filter((check) => Boolean(check)) : [];
9043
- const status = profileStatusFromEvidence(evidence, checks);
9045
+ const status = profileStatusFromEvidence(profile, evidence, checks);
9044
9046
  const firstViewport = evidence?.viewports?.[0];
9045
9047
  const screenshots = (evidence?.viewports || []).map((viewport) => viewport.screenshot_label).filter((label) => Boolean(label));
9046
9048
  return {
@@ -9320,8 +9322,10 @@ function assessProfile(profile, evidence) {
9320
9322
  checks.push({ type: check.type, label: check.label || check.type, status: "needs_human_review", evidence: {}, message: "Unsupported check type." });
9321
9323
  }
9322
9324
  let status = "passed";
9325
+ const expectedViewportCount = profile.target && Array.isArray(profile.target.viewports) ? profile.target.viewports.length : 0;
9323
9326
  if (!viewports.length || !checks.length) status = "proof_insufficient";
9324
9327
  else if (viewports.some((viewport) => viewport.navigation_error)) status = "environment_blocked";
9328
+ else if (expectedViewportCount && viewports.length < expectedViewportCount) status = "proof_insufficient";
9325
9329
  else if (checks.some((check) => check.status === "needs_human_review")) status = "needs_human_review";
9326
9330
  else if (checks.some((check) => check.status === "failed")) status = "product_regression";
9327
9331
  const screenshotLabels = viewports.map((viewport) => viewport.screenshot_label).filter(Boolean);
@@ -9401,6 +9405,11 @@ function setupTextMatches(sample, action) {
9401
9405
  async function setupLocatorText(locator, index) {
9402
9406
  return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
9403
9407
  }
9408
+ function compactSetupResultText(value) {
9409
+ const text = String(value || "").replace(/\s+/g, " ").trim();
9410
+ if (text.length <= 500) return text;
9411
+ return text.slice(0, 500) + "... (" + text.length + " chars)";
9412
+ }
9404
9413
  async function setupLocatorVisible(locator, index) {
9405
9414
  return await locator.nth(index).isVisible({ timeout: 1000 }).catch(() => false);
9406
9415
  }
@@ -9434,12 +9443,12 @@ async function executeSetupAction(action, ordinal) {
9434
9443
  const visible = await setupLocatorVisible(locator, index);
9435
9444
  if (visible) {
9436
9445
  targetIndex = index;
9437
- matchedText = text;
9446
+ matchedText = compactSetupResultText(text);
9438
9447
  break;
9439
9448
  }
9440
9449
  if (hiddenMatchIndex < 0) {
9441
9450
  hiddenMatchIndex = index;
9442
- hiddenMatchedText = text;
9451
+ hiddenMatchedText = compactSetupResultText(text);
9443
9452
  }
9444
9453
  }
9445
9454
  }
@@ -9460,12 +9469,12 @@ async function executeSetupAction(action, ordinal) {
9460
9469
  const text = await setupLocatorText(locator, index);
9461
9470
  lastText = text || lastText;
9462
9471
  if (setupTextMatches(text, action)) {
9463
- return { ...base, ok: true, text, target_index: index, timeout_ms: timeout };
9472
+ return { ...base, ok: true, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
9464
9473
  }
9465
9474
  }
9466
9475
  await page.waitForTimeout(100);
9467
9476
  }
9468
- return { ...base, reason: "text_not_found", text: lastText, timeout_ms: timeout };
9477
+ return { ...base, reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
9469
9478
  }
9470
9479
  return { ...base, reason: "unsupported_action" };
9471
9480
  } catch (error) {
@@ -9590,33 +9599,44 @@ async function captureViewport(viewport) {
9590
9599
  }
9591
9600
  ${runtimeScriptAssessmentSource()}
9592
9601
  const viewports = [];
9602
+ function buildProfileEvidence(currentViewports) {
9603
+ const expectedViewportCount = (profile.target.viewports || []).length;
9604
+ return {
9605
+ version: "riddle-proof.profile-evidence.v1",
9606
+ profile_name: profile.name,
9607
+ target_url: targetUrl,
9608
+ baseline_policy: profile.baseline_policy || "invariant_only",
9609
+ captured_at: capturedAt,
9610
+ viewports: currentViewports.slice(),
9611
+ console: {
9612
+ events: consoleEvents,
9613
+ fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
9614
+ },
9615
+ page_errors: pageErrors,
9616
+ dom_summary: {
9617
+ expected_viewport_count: expectedViewportCount,
9618
+ viewport_count: currentViewports.length,
9619
+ partial: expectedViewportCount > 0 && currentViewports.length < expectedViewportCount,
9620
+ routes: currentViewports.map((viewport) => viewport.route),
9621
+ titles: currentViewports.map((viewport) => viewport.title),
9622
+ overflow_px: currentViewports.map((viewport) => viewport.overflow_px),
9623
+ },
9624
+ };
9625
+ }
9626
+ async function saveProfileArtifacts(currentViewports) {
9627
+ const evidence = buildProfileEvidence(currentViewports);
9628
+ const result = assessProfile(profile, evidence);
9629
+ if (typeof saveJson === "function") {
9630
+ await saveJson("proof.json", result);
9631
+ await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
9632
+ await saveJson("dom-summary.json", evidence.dom_summary);
9633
+ }
9634
+ return result;
9635
+ }
9636
+ let result = await saveProfileArtifacts(viewports);
9593
9637
  for (const viewport of profile.target.viewports || []) {
9594
9638
  viewports.push(await captureViewport(viewport));
9595
- }
9596
- const evidence = {
9597
- version: "riddle-proof.profile-evidence.v1",
9598
- profile_name: profile.name,
9599
- target_url: targetUrl,
9600
- baseline_policy: profile.baseline_policy || "invariant_only",
9601
- captured_at: capturedAt,
9602
- viewports,
9603
- console: {
9604
- events: consoleEvents,
9605
- fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
9606
- },
9607
- page_errors: pageErrors,
9608
- dom_summary: {
9609
- viewport_count: viewports.length,
9610
- routes: viewports.map((viewport) => viewport.route),
9611
- titles: viewports.map((viewport) => viewport.title),
9612
- overflow_px: viewports.map((viewport) => viewport.overflow_px),
9613
- },
9614
- };
9615
- const result = assessProfile(profile, evidence);
9616
- if (typeof saveJson === "function") {
9617
- await saveJson("proof.json", result);
9618
- await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
9619
- await saveJson("dom-summary.json", evidence.dom_summary);
9639
+ result = await saveProfileArtifacts(viewports);
9620
9640
  }
9621
9641
  return result;
9622
9642
  `.trim();
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ import {
58
58
  resolveRiddleProofProfileTimeoutSec,
59
59
  slugifyRiddleProofProfileName,
60
60
  summarizeRiddleProofProfileResult
61
- } from "./chunk-7T5WT2WO.js";
61
+ } from "./chunk-TPUR67H5.js";
62
62
  import {
63
63
  DEFAULT_RIDDLE_API_BASE_URL,
64
64
  DEFAULT_RIDDLE_API_KEY_FILE,
package/dist/profile.cjs CHANGED
@@ -499,11 +499,13 @@ function assessSetupActionsFromEvidence(profile, evidence) {
499
499
  message: failed.length ? `Setup actions failed in ${failed.length} viewport action(s).` : void 0
500
500
  };
501
501
  }
502
- function profileStatusFromEvidence(evidence, checks) {
502
+ function profileStatusFromEvidence(profile, evidence, checks) {
503
503
  if (!evidence) return "proof_insufficient";
504
504
  const viewports = evidence.viewports || [];
505
+ const expectedViewportCount = profile.target.viewports?.length || 0;
505
506
  if (!viewports.length || !checks.length) return "proof_insufficient";
506
507
  if (viewports.some((viewport) => viewport.navigation_error)) return "environment_blocked";
508
+ if (expectedViewportCount && viewports.length < expectedViewportCount) return "proof_insufficient";
507
509
  if (checks.some((check) => check.status === "needs_human_review")) return "needs_human_review";
508
510
  if (checks.some((check) => check.status === "failed")) return "product_regression";
509
511
  return "passed";
@@ -514,7 +516,7 @@ function assessRiddleProofProfileEvidence(profile, evidence, options = {}) {
514
516
  assessSetupActionsFromEvidence(profile, evidence),
515
517
  ...profile.checks.map((check) => assessCheckFromEvidence(check, evidence))
516
518
  ].filter((check) => Boolean(check)) : [];
517
- const status = profileStatusFromEvidence(evidence, checks);
519
+ const status = profileStatusFromEvidence(profile, evidence, checks);
518
520
  const firstViewport = evidence?.viewports?.[0];
519
521
  const screenshots = (evidence?.viewports || []).map((viewport) => viewport.screenshot_label).filter((label) => Boolean(label));
520
522
  return {
@@ -794,8 +796,10 @@ function assessProfile(profile, evidence) {
794
796
  checks.push({ type: check.type, label: check.label || check.type, status: "needs_human_review", evidence: {}, message: "Unsupported check type." });
795
797
  }
796
798
  let status = "passed";
799
+ const expectedViewportCount = profile.target && Array.isArray(profile.target.viewports) ? profile.target.viewports.length : 0;
797
800
  if (!viewports.length || !checks.length) status = "proof_insufficient";
798
801
  else if (viewports.some((viewport) => viewport.navigation_error)) status = "environment_blocked";
802
+ else if (expectedViewportCount && viewports.length < expectedViewportCount) status = "proof_insufficient";
799
803
  else if (checks.some((check) => check.status === "needs_human_review")) status = "needs_human_review";
800
804
  else if (checks.some((check) => check.status === "failed")) status = "product_regression";
801
805
  const screenshotLabels = viewports.map((viewport) => viewport.screenshot_label).filter(Boolean);
@@ -875,6 +879,11 @@ function setupTextMatches(sample, action) {
875
879
  async function setupLocatorText(locator, index) {
876
880
  return await locator.nth(index).textContent({ timeout: 1000 }).catch(() => "");
877
881
  }
882
+ function compactSetupResultText(value) {
883
+ const text = String(value || "").replace(/\s+/g, " ").trim();
884
+ if (text.length <= 500) return text;
885
+ return text.slice(0, 500) + "... (" + text.length + " chars)";
886
+ }
878
887
  async function setupLocatorVisible(locator, index) {
879
888
  return await locator.nth(index).isVisible({ timeout: 1000 }).catch(() => false);
880
889
  }
@@ -908,12 +917,12 @@ async function executeSetupAction(action, ordinal) {
908
917
  const visible = await setupLocatorVisible(locator, index);
909
918
  if (visible) {
910
919
  targetIndex = index;
911
- matchedText = text;
920
+ matchedText = compactSetupResultText(text);
912
921
  break;
913
922
  }
914
923
  if (hiddenMatchIndex < 0) {
915
924
  hiddenMatchIndex = index;
916
- hiddenMatchedText = text;
925
+ hiddenMatchedText = compactSetupResultText(text);
917
926
  }
918
927
  }
919
928
  }
@@ -934,12 +943,12 @@ async function executeSetupAction(action, ordinal) {
934
943
  const text = await setupLocatorText(locator, index);
935
944
  lastText = text || lastText;
936
945
  if (setupTextMatches(text, action)) {
937
- return { ...base, ok: true, text, target_index: index, timeout_ms: timeout };
946
+ return { ...base, ok: true, text: compactSetupResultText(text), target_index: index, timeout_ms: timeout };
938
947
  }
939
948
  }
940
949
  await page.waitForTimeout(100);
941
950
  }
942
- return { ...base, reason: "text_not_found", text: lastText, timeout_ms: timeout };
951
+ return { ...base, reason: "text_not_found", text: compactSetupResultText(lastText), timeout_ms: timeout };
943
952
  }
944
953
  return { ...base, reason: "unsupported_action" };
945
954
  } catch (error) {
@@ -1064,33 +1073,44 @@ async function captureViewport(viewport) {
1064
1073
  }
1065
1074
  ${runtimeScriptAssessmentSource()}
1066
1075
  const viewports = [];
1076
+ function buildProfileEvidence(currentViewports) {
1077
+ const expectedViewportCount = (profile.target.viewports || []).length;
1078
+ return {
1079
+ version: "riddle-proof.profile-evidence.v1",
1080
+ profile_name: profile.name,
1081
+ target_url: targetUrl,
1082
+ baseline_policy: profile.baseline_policy || "invariant_only",
1083
+ captured_at: capturedAt,
1084
+ viewports: currentViewports.slice(),
1085
+ console: {
1086
+ events: consoleEvents,
1087
+ fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
1088
+ },
1089
+ page_errors: pageErrors,
1090
+ dom_summary: {
1091
+ expected_viewport_count: expectedViewportCount,
1092
+ viewport_count: currentViewports.length,
1093
+ partial: expectedViewportCount > 0 && currentViewports.length < expectedViewportCount,
1094
+ routes: currentViewports.map((viewport) => viewport.route),
1095
+ titles: currentViewports.map((viewport) => viewport.title),
1096
+ overflow_px: currentViewports.map((viewport) => viewport.overflow_px),
1097
+ },
1098
+ };
1099
+ }
1100
+ async function saveProfileArtifacts(currentViewports) {
1101
+ const evidence = buildProfileEvidence(currentViewports);
1102
+ const result = assessProfile(profile, evidence);
1103
+ if (typeof saveJson === "function") {
1104
+ await saveJson("proof.json", result);
1105
+ await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
1106
+ await saveJson("dom-summary.json", evidence.dom_summary);
1107
+ }
1108
+ return result;
1109
+ }
1110
+ let result = await saveProfileArtifacts(viewports);
1067
1111
  for (const viewport of profile.target.viewports || []) {
1068
1112
  viewports.push(await captureViewport(viewport));
1069
- }
1070
- const evidence = {
1071
- version: "riddle-proof.profile-evidence.v1",
1072
- profile_name: profile.name,
1073
- target_url: targetUrl,
1074
- baseline_policy: profile.baseline_policy || "invariant_only",
1075
- captured_at: capturedAt,
1076
- viewports,
1077
- console: {
1078
- events: consoleEvents,
1079
- fatal_count: consoleEvents.filter((event) => event.type === "error" || event.type === "assert").length,
1080
- },
1081
- page_errors: pageErrors,
1082
- dom_summary: {
1083
- viewport_count: viewports.length,
1084
- routes: viewports.map((viewport) => viewport.route),
1085
- titles: viewports.map((viewport) => viewport.title),
1086
- overflow_px: viewports.map((viewport) => viewport.overflow_px),
1087
- },
1088
- };
1089
- const result = assessProfile(profile, evidence);
1090
- if (typeof saveJson === "function") {
1091
- await saveJson("proof.json", result);
1092
- await saveJson("console.json", { events: consoleEvents, page_errors: pageErrors });
1093
- await saveJson("dom-summary.json", evidence.dom_summary);
1113
+ result = await saveProfileArtifacts(viewports);
1094
1114
  }
1095
1115
  return result;
1096
1116
  `.trim();
package/dist/profile.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  resolveRiddleProofProfileTimeoutSec,
20
20
  slugifyRiddleProofProfileName,
21
21
  summarizeRiddleProofProfileResult
22
- } from "./chunk-7T5WT2WO.js";
22
+ } from "./chunk-TPUR67H5.js";
23
23
  export {
24
24
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
25
25
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
@@ -292,7 +292,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
292
292
  blocking?: boolean;
293
293
  details?: Record<string, unknown>;
294
294
  ok: boolean;
295
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
295
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
296
296
  state_path: string;
297
297
  stage: any;
298
298
  summary: string;
@@ -382,7 +382,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
382
382
  continueWithStage?: WorkflowStage | null;
383
383
  blocking?: boolean;
384
384
  details?: Record<string, unknown>;
385
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
385
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
386
386
  state_path: string;
387
387
  stage: any;
388
388
  checkpoint: string;
@@ -659,7 +659,7 @@ declare function executeWorkflow(params: WorkflowParams, pluginConfig: any, reso
659
659
  error?: undefined;
660
660
  } | {
661
661
  ok: boolean;
662
- action: "setup" | "recon" | "author" | "implement" | "verify" | "ship" | "run";
662
+ action: "author" | "recon" | "ship" | "implement" | "verify" | "setup" | "run";
663
663
  state_path: string;
664
664
  stage: any;
665
665
  summary: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.18",
3
+ "version": "0.7.20",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",