@riddledc/riddle-proof 0.8.58 → 0.8.60

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.
Files changed (118) hide show
  1. package/dist/adapters/codex-exec-agent.d.cts +1 -0
  2. package/dist/adapters/codex-exec-agent.d.ts +1 -0
  3. package/dist/adapters/codex-exec-agent.js +3 -2
  4. package/dist/adapters/codex.d.cts +1 -0
  5. package/dist/adapters/codex.d.ts +1 -0
  6. package/dist/adapters/codex.js +3 -2
  7. package/dist/adapters/local-agent.d.cts +1 -0
  8. package/dist/adapters/local-agent.d.ts +1 -0
  9. package/dist/adapters/local-agent.js +3 -2
  10. package/dist/adapters/openclaw.d.cts +1 -0
  11. package/dist/adapters/openclaw.d.ts +1 -0
  12. package/dist/adapters/openclaw.js +6 -5
  13. package/dist/advanced/engine-harness.cjs +253 -43
  14. package/dist/advanced/engine-harness.d.cts +1 -0
  15. package/dist/advanced/engine-harness.d.ts +1 -0
  16. package/dist/advanced/engine-harness.js +6 -5
  17. package/dist/advanced/index.cjs +253 -43
  18. package/dist/advanced/index.d.cts +1 -0
  19. package/dist/advanced/index.d.ts +1 -0
  20. package/dist/advanced/index.js +7 -6
  21. package/dist/advanced/runner.cjs +202 -4
  22. package/dist/advanced/runner.d.cts +1 -0
  23. package/dist/advanced/runner.d.ts +1 -0
  24. package/dist/advanced/runner.js +6 -5
  25. package/dist/checkpoint.d.cts +1 -0
  26. package/dist/checkpoint.d.ts +1 -0
  27. package/dist/checkpoint.js +3 -2
  28. package/dist/{chunk-TTB3ZAVX.js → chunk-3FK5HZHK.js} +2 -2
  29. package/dist/{chunk-ONOPGCID.js → chunk-AWRBSVNW.js} +4 -4
  30. package/dist/{chunk-MOTQNIZX.js → chunk-FX2CB4MG.js} +1 -1
  31. package/dist/{chunk-62XLYPMS.js → chunk-HZOILEGF.js} +15 -2
  32. package/dist/{chunk-KNPCWWF3.js → chunk-NXEAFQYZ.js} +16 -10
  33. package/dist/{chunk-GHBNDHG7.js → chunk-PCEDAQPG.js} +4 -4
  34. package/dist/{chunk-CUBYSWZT.js → chunk-QGMSN34W.js} +51 -4
  35. package/dist/{chunk-RS4HJLJQ.js → chunk-QPKY767W.js} +1 -1
  36. package/dist/{chunk-UZIX7M7D.js → chunk-UEY5SJG5.js} +13 -9
  37. package/dist/{chunk-KG64Y5MC.js → chunk-WKIIJX3O.js} +12 -0
  38. package/dist/{chunk-JLOZTVXU.js → chunk-XKNJ5OE4.js} +2 -2
  39. package/dist/cli/index.js +9 -9
  40. package/dist/cli.cjs +473 -403
  41. package/dist/cli.js +9 -9
  42. package/dist/codex-exec-agent.d.cts +1 -0
  43. package/dist/codex-exec-agent.d.ts +1 -0
  44. package/dist/codex-exec-agent.js +3 -2
  45. package/dist/diagnostics.d.cts +1 -0
  46. package/dist/diagnostics.d.ts +1 -0
  47. package/dist/engine-harness.cjs +253 -43
  48. package/dist/engine-harness.d.cts +1 -0
  49. package/dist/engine-harness.d.ts +1 -0
  50. package/dist/engine-harness.js +6 -5
  51. package/dist/index.cjs +248 -168
  52. package/dist/index.d.cts +2 -2
  53. package/dist/index.d.ts +2 -2
  54. package/dist/index.js +21 -11
  55. package/dist/local-agent.d.cts +1 -0
  56. package/dist/local-agent.d.ts +1 -0
  57. package/dist/local-agent.js +3 -2
  58. package/dist/openclaw.d.cts +1 -0
  59. package/dist/openclaw.d.ts +1 -0
  60. package/dist/openclaw.js +6 -5
  61. package/dist/pr-comment.cjs +19 -1
  62. package/dist/pr-comment.d.cts +2 -0
  63. package/dist/pr-comment.d.ts +2 -0
  64. package/dist/pr-comment.js +2 -2
  65. package/dist/profile/index.d.cts +1 -0
  66. package/dist/profile/index.d.ts +1 -0
  67. package/dist/profile.d.cts +1 -0
  68. package/dist/profile.d.ts +1 -0
  69. package/dist/proof-session.d.cts +1 -0
  70. package/dist/proof-session.d.ts +1 -0
  71. package/dist/public-state.cjs +15 -0
  72. package/dist/public-state.d.cts +4 -1
  73. package/dist/public-state.d.ts +4 -1
  74. package/dist/public-state.js +7 -1
  75. package/dist/result.cjs +211 -4
  76. package/dist/result.d.cts +12 -1
  77. package/dist/result.d.ts +12 -1
  78. package/dist/result.js +6 -1
  79. package/dist/run-card.cjs +198 -40
  80. package/dist/run-card.d.cts +1 -0
  81. package/dist/run-card.d.ts +1 -0
  82. package/dist/run-card.js +4 -3
  83. package/dist/runner.cjs +202 -4
  84. package/dist/runner.d.cts +1 -0
  85. package/dist/runner.d.ts +1 -0
  86. package/dist/runner.js +6 -5
  87. package/dist/spec/checkpoint.d.cts +1 -0
  88. package/dist/spec/checkpoint.d.ts +1 -0
  89. package/dist/spec/checkpoint.js +3 -2
  90. package/dist/spec/index.cjs +235 -167
  91. package/dist/spec/index.d.cts +2 -2
  92. package/dist/spec/index.d.ts +2 -2
  93. package/dist/spec/index.js +17 -7
  94. package/dist/spec/public-state.cjs +15 -0
  95. package/dist/spec/public-state.d.cts +1 -1
  96. package/dist/spec/public-state.d.ts +1 -1
  97. package/dist/spec/public-state.js +7 -1
  98. package/dist/spec/result.cjs +209 -4
  99. package/dist/spec/result.d.cts +2 -1
  100. package/dist/spec/result.d.ts +2 -1
  101. package/dist/spec/result.js +6 -1
  102. package/dist/spec/run-card.cjs +198 -40
  103. package/dist/spec/run-card.d.cts +1 -0
  104. package/dist/spec/run-card.d.ts +1 -0
  105. package/dist/spec/run-card.js +4 -3
  106. package/dist/spec/state.cjs +207 -45
  107. package/dist/spec/state.d.cts +1 -0
  108. package/dist/spec/state.d.ts +1 -0
  109. package/dist/spec/state.js +5 -4
  110. package/dist/spec/types.d.cts +1 -0
  111. package/dist/spec/types.d.ts +1 -0
  112. package/dist/state.cjs +207 -45
  113. package/dist/state.d.cts +1 -0
  114. package/dist/state.d.ts +1 -0
  115. package/dist/state.js +5 -4
  116. package/dist/types.d.cts +14 -0
  117. package/dist/types.d.ts +14 -0
  118. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -1609,7 +1609,7 @@ function normalizeStageRequest(state, requestedAdvanceStage) {
1609
1609
  if (!state?.recon_results || ["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "")) return "recon";
1610
1610
  return null;
1611
1611
  }
1612
- function stringValue(value) {
1612
+ function stringValue2(value) {
1613
1613
  return typeof value === "string" && value.trim() ? value.trim() : "";
1614
1614
  }
1615
1615
  function commandResult(command, args, cwd, timeout = 6e4) {
@@ -1632,7 +1632,7 @@ function repoDirForSync(state) {
1632
1632
  state?.repo_dir,
1633
1633
  state?.after_worktree,
1634
1634
  state?.before_worktree
1635
- ].map(stringValue).filter(Boolean);
1635
+ ].map(stringValue2).filter(Boolean);
1636
1636
  return candidates.find((candidate) => (0, import_node_fs2.existsSync)(import_node_path2.default.join(candidate, ".git"))) || "";
1637
1637
  }
1638
1638
  function parseWorktreeList(output) {
@@ -1752,32 +1752,32 @@ function baseCheckoutReport(repoDir, baseBranch, updateRequested, updateAllowed)
1752
1752
  return report;
1753
1753
  }
1754
1754
  function normalizeGhPrStatus(value) {
1755
- const status = stringValue(value).toLowerCase();
1755
+ const status = stringValue2(value).toLowerCase();
1756
1756
  if (status === "merged") return "merged";
1757
1757
  if (status === "open") return "open";
1758
1758
  if (status === "closed") return "closed";
1759
1759
  return status || "unknown";
1760
1760
  }
1761
1761
  function prRefFromState(state) {
1762
- return stringValue(state?.pr_number) || stringValue(state?.pr_url);
1762
+ return stringValue2(state?.pr_number) || stringValue2(state?.pr_url);
1763
1763
  }
1764
1764
  function prNumberFromUrl(url) {
1765
1765
  const match = url.match(/\/pull\/(\d+)(?:$|[?#])/);
1766
1766
  return match?.[1] || "";
1767
1767
  }
1768
1768
  function normalizePrState(raw, state, checkedAt = (/* @__PURE__ */ new Date()).toISOString()) {
1769
- const mergeCommit = typeof raw?.mergeCommit === "object" && raw.mergeCommit ? stringValue(raw.mergeCommit.oid) : stringValue(raw?.mergeCommit);
1770
- const url = stringValue(raw?.url) || stringValue(state?.pr_url);
1769
+ const mergeCommit = typeof raw?.mergeCommit === "object" && raw.mergeCommit ? stringValue2(raw.mergeCommit.oid) : stringValue2(raw?.mergeCommit);
1770
+ const url = stringValue2(raw?.url) || stringValue2(state?.pr_url);
1771
1771
  return {
1772
1772
  status: normalizeGhPrStatus(raw?.state),
1773
1773
  pr_url: url || null,
1774
1774
  pr_number: String(raw?.number || state?.pr_number || prNumberFromUrl(url) || ""),
1775
- repo: stringValue(state?.repo) || null,
1776
- head_branch: stringValue(raw?.headRefName) || stringValue(state?.target_branch) || stringValue(state?.branch) || null,
1777
- base_branch: stringValue(raw?.baseRefName) || stringValue(state?.base_branch) || "main",
1775
+ repo: stringValue2(state?.repo) || null,
1776
+ head_branch: stringValue2(raw?.headRefName) || stringValue2(state?.target_branch) || stringValue2(state?.branch) || null,
1777
+ base_branch: stringValue2(raw?.baseRefName) || stringValue2(state?.base_branch) || "main",
1778
1778
  merge_commit: mergeCommit || null,
1779
- merged_at: stringValue(raw?.mergedAt) || null,
1780
- closed_at: stringValue(raw?.closedAt) || null,
1779
+ merged_at: stringValue2(raw?.mergedAt) || null,
1780
+ closed_at: stringValue2(raw?.closedAt) || null,
1781
1781
  checked_at: checkedAt,
1782
1782
  source: "gh"
1783
1783
  };
@@ -1794,7 +1794,7 @@ function cleanupMergedProofRun(state, repoDir, params, prState) {
1794
1794
  branch_delete_errors: [],
1795
1795
  pruned: false
1796
1796
  };
1797
- const baseBranch = stringValue(prState.base_branch) || stringValue(state?.base_branch) || "main";
1797
+ const baseBranch = stringValue2(prState.base_branch) || stringValue2(state?.base_branch) || "main";
1798
1798
  let fetchedBase = params.fetch_base === false;
1799
1799
  if (params.fetch_base !== false && baseBranch) {
1800
1800
  const fetch2 = commandResult("git", ["fetch", "origin", baseBranch], repoDir, 12e4);
@@ -1812,7 +1812,7 @@ function cleanupMergedProofRun(state, repoDir, params, prState) {
1812
1812
  }
1813
1813
  const removed = [];
1814
1814
  const removeErrors = [];
1815
- for (const candidate of [state?.before_worktree, state?.after_worktree].map(stringValue).filter(Boolean)) {
1815
+ for (const candidate of [state?.before_worktree, state?.after_worktree].map(stringValue2).filter(Boolean)) {
1816
1816
  if (!(0, import_node_fs2.existsSync)(candidate) || import_node_path2.default.resolve(candidate) === import_node_path2.default.resolve(repoDir)) continue;
1817
1817
  const remove = commandResult("git", ["worktree", "remove", "--force", candidate], repoDir, 12e4);
1818
1818
  if (remove.ok) {
@@ -1823,7 +1823,7 @@ function cleanupMergedProofRun(state, repoDir, params, prState) {
1823
1823
  }
1824
1824
  cleanup.worktrees_removed = removed;
1825
1825
  cleanup.worktree_remove_errors = removeErrors;
1826
- const afterBranch = stringValue(state?.after_worktree_branch);
1826
+ const afterBranch = stringValue2(state?.after_worktree_branch);
1827
1827
  if (afterBranch.startsWith("riddle-proof/")) {
1828
1828
  const deleted = commandResult("git", ["branch", "-D", afterBranch], repoDir, 6e4);
1829
1829
  if (deleted.ok) {
@@ -1859,7 +1859,7 @@ function syncPrLifecycle(statePath, params) {
1859
1859
  const prState2 = {
1860
1860
  status: missingPr ? "orphaned" : "unavailable",
1861
1861
  pr_url: state.pr_url || null,
1862
- pr_number: String(state.pr_number || prNumberFromUrl(stringValue(state.pr_url)) || ""),
1862
+ pr_number: String(state.pr_number || prNumberFromUrl(stringValue2(state.pr_url)) || ""),
1863
1863
  repo: state.repo || null,
1864
1864
  head_branch: state.target_branch || state.branch || null,
1865
1865
  base_branch: state.base_branch || "main",
@@ -1888,7 +1888,7 @@ function syncPrLifecycle(statePath, params) {
1888
1888
  const prState2 = {
1889
1889
  status: "unavailable",
1890
1890
  pr_url: state.pr_url || null,
1891
- pr_number: String(state.pr_number || prNumberFromUrl(stringValue(state.pr_url)) || ""),
1891
+ pr_number: String(state.pr_number || prNumberFromUrl(stringValue2(state.pr_url)) || ""),
1892
1892
  repo: state.repo || null,
1893
1893
  head_branch: state.target_branch || state.branch || null,
1894
1894
  base_branch: state.base_branch || "main",
@@ -2669,8 +2669,8 @@ ${implementRes.stdout || ""}
2669
2669
  ${implementRes.stderr || ""}`;
2670
2670
  if (implementError.includes("No implementation detected")) {
2671
2671
  const implementationState = readState(config.statePath) || {};
2672
- const implementationSummary = stringValue(implementationState?.implementation_summary) || null;
2673
- const implementationDetectionSummary = stringValue(implementationState?.implementation_detection_summary) || null;
2672
+ const implementationSummary = stringValue2(implementationState?.implementation_summary) || null;
2673
+ const implementationDetectionSummary = stringValue2(implementationState?.implementation_detection_summary) || null;
2674
2674
  const implementationDetection = implementationState?.implementation_detection && typeof implementationState.implementation_detection === "object" && !Array.isArray(implementationState.implementation_detection) ? implementationState.implementation_detection : null;
2675
2675
  recordAttempt("implement", "checkpoint", "Implementation checkpoint found no material code changes yet.", {
2676
2676
  checkpoint: "implement_changes_missing",
@@ -2788,14 +2788,14 @@ ${implementRes.stderr || ""}`;
2788
2788
  const captureQuality = verifyDecisionRequest2?.capture_quality || {};
2789
2789
  const conclusiveVerifyBlockers2 = proofAssessmentHardBlockersForState({
2790
2790
  ...failedVerifyState,
2791
- structured_interaction_capture_failure_summary: stringValue(verifyDecisionRequest2?.structured_interaction_capture_failure_summary) || stringValue(failedVerifyState?.structured_interaction_capture_failure_summary) || void 0,
2792
- structured_interaction_failure_summary: stringValue(verifyDecisionRequest2?.structured_interaction_failure_summary) || stringValue(failedVerifyState?.structured_interaction_failure_summary) || void 0
2791
+ structured_interaction_capture_failure_summary: stringValue2(verifyDecisionRequest2?.structured_interaction_capture_failure_summary) || stringValue2(failedVerifyState?.structured_interaction_capture_failure_summary) || void 0,
2792
+ structured_interaction_failure_summary: stringValue2(verifyDecisionRequest2?.structured_interaction_failure_summary) || stringValue2(failedVerifyState?.structured_interaction_failure_summary) || void 0
2793
2793
  });
2794
- const structuredInteractionFailureSummary2 = stringValue(verifyDecisionRequest2?.structured_interaction_capture_failure_summary) || stringValue(verifyDecisionRequest2?.structured_interaction_failure_summary) || stringValue(failedVerifyState?.structured_interaction_capture_failure_summary) || stringValue(failedVerifyState?.structured_interaction_failure_summary) || stringValue(conclusiveVerifyBlockers2[0]);
2794
+ const structuredInteractionFailureSummary2 = stringValue2(verifyDecisionRequest2?.structured_interaction_capture_failure_summary) || stringValue2(verifyDecisionRequest2?.structured_interaction_failure_summary) || stringValue2(failedVerifyState?.structured_interaction_capture_failure_summary) || stringValue2(failedVerifyState?.structured_interaction_failure_summary) || stringValue2(conclusiveVerifyBlockers2[0]);
2795
2795
  const captureTerminalBlocker = failedVerifyStatus === "capture_error" || conclusiveVerifyBlockers2.length > 0 || Boolean(structuredInteractionFailureSummary2) || captureQuality?.terminal_blocker === true || captureQuality?.blocking === true;
2796
- const terminalCaptureQualitySummary = captureQuality?.terminal_blocker === true || captureQuality?.blocking === true ? stringValue(captureQuality?.summary) : "";
2796
+ const terminalCaptureQualitySummary = captureQuality?.terminal_blocker === true || captureQuality?.blocking === true ? stringValue2(captureQuality?.summary) : "";
2797
2797
  const checkpointName = captureTerminalBlocker ? "verify_capture_blocked" : "verify_capture_retry";
2798
- const summary = terminalCaptureQualitySummary || structuredInteractionFailureSummary2 || stringValue(verifyDecisionRequest2?.summary) || stringValue(failedVerifyState?.verify_summary) || stringValue(failedVerifyState?.proof_summary) || stringValue(verifyRes.error) || "Verify capture failed before the evidence could be judged.";
2798
+ const summary = terminalCaptureQualitySummary || structuredInteractionFailureSummary2 || stringValue2(verifyDecisionRequest2?.summary) || stringValue2(failedVerifyState?.verify_summary) || stringValue2(failedVerifyState?.proof_summary) || stringValue2(verifyRes.error) || "Verify capture failed before the evidence could be judged.";
2799
2799
  const failedVerifyDetails = {
2800
2800
  executed,
2801
2801
  verifyStatus: failedVerifyStatus,
@@ -2873,10 +2873,10 @@ ${implementRes.stderr || ""}`;
2873
2873
  };
2874
2874
  const conclusiveVerifyBlockers = proofAssessmentHardBlockersForState({
2875
2875
  ...state,
2876
- structured_interaction_capture_failure_summary: stringValue(verifyDecisionRequest?.structured_interaction_capture_failure_summary) || stringValue(state?.structured_interaction_capture_failure_summary) || void 0,
2877
- structured_interaction_failure_summary: stringValue(verifyDecisionRequest?.structured_interaction_failure_summary) || stringValue(state?.structured_interaction_failure_summary) || void 0
2876
+ structured_interaction_capture_failure_summary: stringValue2(verifyDecisionRequest?.structured_interaction_capture_failure_summary) || stringValue2(state?.structured_interaction_capture_failure_summary) || void 0,
2877
+ structured_interaction_failure_summary: stringValue2(verifyDecisionRequest?.structured_interaction_failure_summary) || stringValue2(state?.structured_interaction_failure_summary) || void 0
2878
2878
  });
2879
- const structuredInteractionFailureSummary = stringValue(verifyDecisionRequest?.structured_interaction_capture_failure_summary) || stringValue(verifyDecisionRequest?.structured_interaction_failure_summary) || stringValue(state?.structured_interaction_capture_failure_summary) || stringValue(state?.structured_interaction_failure_summary) || stringValue(conclusiveVerifyBlockers[0]);
2879
+ const structuredInteractionFailureSummary = stringValue2(verifyDecisionRequest?.structured_interaction_capture_failure_summary) || stringValue2(verifyDecisionRequest?.structured_interaction_failure_summary) || stringValue2(state?.structured_interaction_capture_failure_summary) || stringValue2(state?.structured_interaction_failure_summary) || stringValue2(conclusiveVerifyBlockers[0]);
2880
2880
  if (verifyStatus !== "evidence_captured") {
2881
2881
  const captureQuality = verifyDecisionRequest?.capture_quality || {};
2882
2882
  const captureTerminalBlocker = conclusiveVerifyBlockers.length > 0 || Boolean(structuredInteractionFailureSummary) || captureQuality?.terminal_blocker === true || captureQuality?.blocking === true;
@@ -2888,9 +2888,9 @@ ${implementRes.stderr || ""}`;
2888
2888
  });
2889
2889
  state = readState(config.statePath);
2890
2890
  }
2891
- const terminalCaptureQualitySummary = captureQuality?.terminal_blocker === true || captureQuality?.blocking === true ? stringValue(captureQuality?.summary) : "";
2891
+ const terminalCaptureQualitySummary = captureQuality?.terminal_blocker === true || captureQuality?.blocking === true ? stringValue2(captureQuality?.summary) : "";
2892
2892
  const checkpointName = captureTerminalBlocker ? "verify_capture_blocked" : "verify_capture_retry";
2893
- const summary = terminalCaptureQualitySummary || structuredInteractionFailureSummary || stringValue(proofAssessment.summary) || "Verify ran, but the proof packet still needs internal capture-plan work before it should ship.";
2893
+ const summary = terminalCaptureQualitySummary || structuredInteractionFailureSummary || stringValue2(proofAssessment.summary) || "Verify ran, but the proof packet still needs internal capture-plan work before it should ship.";
2894
2894
  recordAttempt("verify", "checkpoint", summary, {
2895
2895
  autoApproved: verifyRes.autoApproved || false,
2896
2896
  checkpoint: checkpointName,
@@ -3415,6 +3415,167 @@ var import_node_fs3 = require("fs");
3415
3415
  var import_node_path3 = __toESM(require("path"), 1);
3416
3416
  var import_node_crypto3 = __toESM(require("crypto"), 1);
3417
3417
 
3418
+ // src/public-state.ts
3419
+ function riddleProofPublicStateAllowsClaim(summary, claim) {
3420
+ return !summary?.prohibited_claims.includes(claim);
3421
+ }
3422
+ function riddleProofPublicStateAllowsMergeRecommendation(summary) {
3423
+ return riddleProofPublicStateAllowsClaim(summary, "merge_ready") && riddleProofPublicStateAllowsClaim(summary, "sync_allowed");
3424
+ }
3425
+ function riddleProofPublicStateMergeRecommendation(summary, recommendation) {
3426
+ return recommendation && riddleProofPublicStateAllowsMergeRecommendation(summary) ? recommendation : void 0;
3427
+ }
3428
+ function asRecord(value) {
3429
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
3430
+ }
3431
+ function stringValue(value) {
3432
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
3433
+ }
3434
+ function booleanValue(value) {
3435
+ return typeof value === "boolean" ? value : void 0;
3436
+ }
3437
+ function numberValue(value) {
3438
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
3439
+ }
3440
+ function firstStringValue(...values) {
3441
+ for (const value of values) {
3442
+ const text = stringValue(value);
3443
+ if (text) return text;
3444
+ }
3445
+ return void 0;
3446
+ }
3447
+ function firstBooleanValue(...values) {
3448
+ for (const value of values) {
3449
+ const bool = booleanValue(value);
3450
+ if (typeof bool === "boolean") return bool;
3451
+ }
3452
+ return void 0;
3453
+ }
3454
+ function firstRecordValue(...values) {
3455
+ for (const value of values) {
3456
+ const record = asRecord(value);
3457
+ if (Object.keys(record).length) return record;
3458
+ }
3459
+ return void 0;
3460
+ }
3461
+ function countValue(value) {
3462
+ const number = numberValue(value);
3463
+ return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
3464
+ }
3465
+ function checkpointSummaryFrom(...values) {
3466
+ const record = firstRecordValue(...values);
3467
+ if (!record) return void 0;
3468
+ const accepted = countValue(record.response_count);
3469
+ const rejected = countValue(record.rejected_response_count);
3470
+ const ignored = countValue(record.ignored_response_count);
3471
+ const duplicate = countValue(record.duplicate_response_count);
3472
+ const summary = {
3473
+ pending: booleanValue(record.pending),
3474
+ accepted_response_count: accepted,
3475
+ rejected_response_count: rejected,
3476
+ ignored_response_count: ignored,
3477
+ duplicate_response_count: duplicate,
3478
+ latest_decision: stringValue(record.latest_decision),
3479
+ audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
3480
+ };
3481
+ return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
3482
+ }
3483
+ function uniqueStrings(values) {
3484
+ return [...new Set(values.filter(Boolean))];
3485
+ }
3486
+ function summarizeRiddleProofPublicState(input) {
3487
+ const record = asRecord(input);
3488
+ const runCard = asRecord(record.run_card);
3489
+ const stopCondition = asRecord(runCard.stop_condition);
3490
+ const raw = asRecord(record.raw);
3491
+ const request = asRecord(record.request);
3492
+ const requestMetadata = asRecord(record.request_metadata);
3493
+ const prState = asRecord(record.pr_state);
3494
+ const handoff = asRecord(record.pr_handoff_policy);
3495
+ const handoffState = stringValue(handoff.state);
3496
+ const status = firstStringValue(record.status, stopCondition.status);
3497
+ const ok = booleanValue(record.ok) ?? null;
3498
+ const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
3499
+ const explicitShippingDisabled = firstBooleanValue(
3500
+ record.shipping_disabled,
3501
+ stopCondition.shipping_disabled,
3502
+ raw.shipping_disabled,
3503
+ handoff.shipping_disabled
3504
+ );
3505
+ const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
3506
+ const explicitShipAuthorized = firstBooleanValue(
3507
+ record.ship_authorized,
3508
+ stopCondition.ship_authorized,
3509
+ raw.ship_authorized
3510
+ );
3511
+ const authorizationEvidence = Boolean(
3512
+ status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
3513
+ );
3514
+ const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
3515
+ const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
3516
+ const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
3517
+ const shipHeld = explicitShipHeld === true || inferredHeld;
3518
+ const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
3519
+ const proofComplete = Boolean(
3520
+ status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
3521
+ );
3522
+ const checkpointSummary = checkpointSummaryFrom(
3523
+ record.checkpoint_summary,
3524
+ stopCondition.checkpoint_summary,
3525
+ asRecord(record.details).checkpoint_summary,
3526
+ asRecord(raw.details).checkpoint_summary
3527
+ );
3528
+ const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
3529
+ const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
3530
+ const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
3531
+ const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
3532
+ const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
3533
+ const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
3534
+ const syncAllowed = mergeReady;
3535
+ let policyState = "unknown";
3536
+ if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
3537
+ else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
3538
+ else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
3539
+ else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
3540
+ else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
3541
+ else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
3542
+ else if (shipAuthorized) policyState = "ship_authorized";
3543
+ else if (proofPassed) policyState = "proof_passed";
3544
+ else if (status === "running") policyState = "proof_in_progress";
3545
+ const requiredDisclosures = [];
3546
+ if (shipHeld) requiredDisclosures.push("ship_held");
3547
+ if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
3548
+ if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
3549
+ if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
3550
+ const prohibitedClaims = [];
3551
+ if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
3552
+ if (!mergeReady) prohibitedClaims.push("merge_ready");
3553
+ if (!syncAllowed) prohibitedClaims.push("sync_allowed");
3554
+ if (blockedOrWaiting) {
3555
+ prohibitedClaims.push("proof_passed", "ready_to_ship");
3556
+ }
3557
+ if (checkpointSummary?.audit_disclosure_required) {
3558
+ prohibitedClaims.push("all_checkpoint_responses_accepted");
3559
+ }
3560
+ const resultLabel2 = policyState === "awaiting_checkpoint" ? "checkpoint required" : policyState === "proof_blocked" ? "blocked" : policyState === "proof_failed" ? "failed" : policyState === "proof_complete_ship_disabled" ? "proof complete; shipping disabled" : policyState === "proof_passed_ship_held" ? "proof passed; ship held" : policyState === "ship_authorized" ? status === "shipped" ? "shipped" : "ship authorized" : policyState === "proof_passed" ? "passed" : policyState === "proof_in_progress" ? "running" : status || "recorded";
3561
+ return {
3562
+ status,
3563
+ ok,
3564
+ policy_state: policyState,
3565
+ result_label: resultLabel2,
3566
+ proof_complete: proofComplete,
3567
+ proof_passed: proofPassed,
3568
+ ship_held: shipHeld,
3569
+ shipping_disabled: shippingDisabled,
3570
+ ship_authorized: shipAuthorized,
3571
+ merge_ready: mergeReady,
3572
+ sync_allowed: syncAllowed,
3573
+ checkpoint_summary: checkpointSummary,
3574
+ required_disclosures: uniqueStrings(requiredDisclosures),
3575
+ prohibited_claims: uniqueStrings(prohibitedClaims)
3576
+ };
3577
+ }
3578
+
3418
3579
  // src/result.ts
3419
3580
  function isTerminalStatus(status) {
3420
3581
  return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
@@ -3589,6 +3750,37 @@ function applyTerminalMetadata(state, metadata) {
3589
3750
  if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
3590
3751
  return state;
3591
3752
  }
3753
+ function publicStateForRunState(input) {
3754
+ const state = input.state;
3755
+ const status = input.status || state.status;
3756
+ const raw = recordValue(input.raw) || {};
3757
+ const extendedState = state;
3758
+ const terminalOk = isTerminalStatus(status) ? state.ok : void 0;
3759
+ return summarizeRiddleProofPublicState(compactRecord({
3760
+ status,
3761
+ ok: terminalOk,
3762
+ request: state.request,
3763
+ pr_state: state.pr_state,
3764
+ marked_ready: state.marked_ready,
3765
+ ship_held: state.ship_held,
3766
+ shipping_disabled: state.shipping_disabled,
3767
+ ship_authorized: state.ship_authorized,
3768
+ ship_mode: state.request?.ship_mode,
3769
+ merge_commit: state.merge_commit,
3770
+ merged_at: state.merged_at,
3771
+ checkpoint_summary: state.checkpoint_summary,
3772
+ pr_handoff_policy: recordValue(extendedState.pr_handoff_policy),
3773
+ merge_ready: extendedState.merge_ready,
3774
+ normal_pr_allowed: extendedState.normal_pr_allowed,
3775
+ raw: Object.keys(raw).length ? raw : void 0
3776
+ }));
3777
+ }
3778
+ function publicMergeRecommendationForRunState(input) {
3779
+ return riddleProofPublicStateMergeRecommendation(
3780
+ publicStateForRunState(input),
3781
+ input.state.merge_recommendation
3782
+ );
3783
+ }
3592
3784
  function shipControlStateFor(input) {
3593
3785
  const state = input.state;
3594
3786
  const status = input.status || state.status;
@@ -3637,6 +3829,11 @@ function createRunResult(input) {
3637
3829
  state.ok = ok;
3638
3830
  if (isProtectedFinalStatus(status)) state.finalized = true;
3639
3831
  applyShipControlState(state, { status, raw: input.raw });
3832
+ const publicState = publicStateForRunState({ state, status, raw: input.raw });
3833
+ const publicMergeRecommendation = riddleProofPublicStateMergeRecommendation(
3834
+ publicState,
3835
+ state.merge_recommendation
3836
+ );
3640
3837
  return compactRecord({
3641
3838
  ok,
3642
3839
  status,
@@ -3654,9 +3851,12 @@ function createRunResult(input) {
3654
3851
  pr_state: state.pr_state,
3655
3852
  marked_ready: state.marked_ready,
3656
3853
  left_draft: state.left_draft,
3657
- ship_held: state.ship_held,
3658
- shipping_disabled: state.shipping_disabled,
3659
- ship_authorized: state.ship_authorized,
3854
+ result_label: publicState.result_label,
3855
+ ship_held: publicState.ship_held,
3856
+ shipping_disabled: publicState.shipping_disabled,
3857
+ ship_authorized: publicState.ship_authorized,
3858
+ merge_ready: publicState.merge_ready,
3859
+ sync_allowed: publicState.sync_allowed,
3660
3860
  ci_status: state.ci_status,
3661
3861
  ship_commit: state.ship_commit,
3662
3862
  ship_remote_head: state.ship_remote_head,
@@ -3670,7 +3870,8 @@ function createRunResult(input) {
3670
3870
  cleanup_report: state.cleanup_report,
3671
3871
  notification: state.notification,
3672
3872
  proof_decision: state.proof_decision,
3673
- merge_recommendation: state.merge_recommendation,
3873
+ merge_recommendation: publicMergeRecommendation,
3874
+ public_state: publicState,
3674
3875
  finalized: state.finalized,
3675
3876
  blocker: state.blocker,
3676
3877
  checkpoint_packet: state.checkpoint_packet,
@@ -4640,7 +4841,8 @@ function createRiddleProofRunCard(state, input = {}) {
4640
4841
  const visualDelta = visualDeltaFrom({ fullRiddleState: fullState, runState: state });
4641
4842
  const artifacts = artifactsFrom({ fullRiddleState: fullState, runState: state });
4642
4843
  const viewportMatrix = viewportMatrixFrom({ fullRiddleState: fullState, runState: state });
4643
- const shipControl = shipControlStateFor({ state });
4844
+ const publicState = publicStateForRunState({ state, status: state.status });
4845
+ const publicMergeRecommendation = publicMergeRecommendationForRunState({ state, status: state.status });
4644
4846
  return {
4645
4847
  version: RIDDLE_PROOF_RUN_CARD_VERSION,
4646
4848
  run_id: state.run_id || "unknown",
@@ -4694,14 +4896,18 @@ function createRiddleProofRunCard(state, input = {}) {
4694
4896
  stop_condition: compactRecord({
4695
4897
  status: state.status,
4696
4898
  terminal: isTerminalStatus(state.status),
4697
- ship_held: shipControl.ship_held,
4698
- shipping_disabled: shipControl.shipping_disabled,
4699
- ship_authorized: shipControl.ship_authorized,
4899
+ result_label: publicState.result_label,
4900
+ ship_held: publicState.ship_held,
4901
+ shipping_disabled: publicState.shipping_disabled,
4902
+ ship_authorized: publicState.ship_authorized,
4903
+ merge_ready: publicState.merge_ready,
4904
+ sync_allowed: publicState.sync_allowed,
4700
4905
  blocker_code: state.blocker?.code || null,
4701
4906
  blocker_message: state.blocker?.message || null,
4702
4907
  proof_decision: state.proof_decision,
4703
- merge_recommendation: state.merge_recommendation,
4704
- monitor_should_continue: !isTerminalStatus(state.status)
4908
+ merge_recommendation: publicMergeRecommendation,
4909
+ monitor_should_continue: !isTerminalStatus(state.status),
4910
+ public_state: publicState
4705
4911
  }),
4706
4912
  updated_at: state.updated_at
4707
4913
  };
@@ -4857,8 +5063,8 @@ function appendStageHeartbeat(state, input) {
4857
5063
  function createRunStatusSnapshot(state, at = timestamp2()) {
4858
5064
  const latestEvent = state.events[state.events.length - 1];
4859
5065
  const runId = state.run_id || "unknown";
4860
- const shipControl = shipControlStateFor({ state });
4861
- const existingRunCardCurrent = state.run_card?.status === state.status && state.run_card.stop_condition?.status === state.status && state.run_card.stop_condition?.terminal === isTerminalStatus(state.status) && state.run_card.stop_condition?.monitor_should_continue === !isTerminalStatus(state.status) && state.run_card.stop_condition?.ship_held === shipControl.ship_held && state.run_card.stop_condition?.shipping_disabled === shipControl.shipping_disabled && state.run_card.stop_condition?.ship_authorized === shipControl.ship_authorized;
5066
+ const publicState = publicStateForRunState({ state, status: state.status });
5067
+ const existingRunCardCurrent = state.run_card?.status === state.status && state.run_card.stop_condition?.status === state.status && state.run_card.stop_condition?.terminal === isTerminalStatus(state.status) && state.run_card.stop_condition?.monitor_should_continue === !isTerminalStatus(state.status) && state.run_card.stop_condition?.ship_held === publicState.ship_held && state.run_card.stop_condition?.shipping_disabled === publicState.shipping_disabled && state.run_card.stop_condition?.ship_authorized === publicState.ship_authorized && state.run_card.stop_condition?.merge_ready === publicState.merge_ready && state.run_card.stop_condition?.sync_allowed === publicState.sync_allowed && state.run_card.stop_condition?.result_label === publicState.result_label;
4862
5068
  const runCard = existingRunCardCurrent ? state.run_card : createRiddleProofRunCard(state, { at });
4863
5069
  return compactRecord({
4864
5070
  run_id: runId,
@@ -4872,9 +5078,13 @@ function createRunStatusSnapshot(state, at = timestamp2()) {
4872
5078
  pr_url: state.pr_url ?? null,
4873
5079
  pr_branch: state.pr_branch ?? null,
4874
5080
  pr_state: state.pr_state,
4875
- ship_held: shipControl.ship_held,
4876
- shipping_disabled: shipControl.shipping_disabled,
4877
- ship_authorized: shipControl.ship_authorized,
5081
+ result_label: publicState.result_label,
5082
+ ship_held: publicState.ship_held,
5083
+ shipping_disabled: publicState.shipping_disabled,
5084
+ ship_authorized: publicState.ship_authorized,
5085
+ merge_ready: publicState.merge_ready,
5086
+ sync_allowed: publicState.sync_allowed,
5087
+ public_state: publicState,
4878
5088
  ci_status: state.ci_status,
4879
5089
  ship_commit: state.ship_commit,
4880
5090
  ship_remote_head: state.ship_remote_head,
@@ -8314,7 +8524,7 @@ var DEFAULT_VIEWPORTS = [
8314
8524
  function isRecord(value) {
8315
8525
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
8316
8526
  }
8317
- function stringValue2(value) {
8527
+ function stringValue3(value) {
8318
8528
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
8319
8529
  }
8320
8530
  function hasOwn(value, key) {
@@ -8335,10 +8545,10 @@ function valueFromOwn(input, ...keys) {
8335
8545
  }
8336
8546
  return void 0;
8337
8547
  }
8338
- function numberValue(value) {
8548
+ function numberValue2(value) {
8339
8549
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
8340
8550
  }
8341
- function booleanValue(value) {
8551
+ function booleanValue2(value) {
8342
8552
  return typeof value === "boolean" ? value : void 0;
8343
8553
  }
8344
8554
  function horizontalBoundsOverflowPx(value) {
@@ -8380,10 +8590,10 @@ function horizontalOffenderOverflowPx(value) {
8380
8590
  ));
8381
8591
  }
8382
8592
  const rect = isRecord(value.rect || value.bounds || value.bounding_rect || value.boundingRect) ? value.rect || value.bounds || value.bounding_rect || value.boundingRect : void 0;
8383
- const viewportWidth = numberValue(value.viewport_width ?? value.viewportWidth);
8593
+ const viewportWidth = numberValue2(value.viewport_width ?? value.viewportWidth);
8384
8594
  if (isRecord(rect) && viewportWidth !== void 0) {
8385
- const left = numberValue(rect.left);
8386
- const right = numberValue(rect.right);
8595
+ const left = numberValue2(rect.left);
8596
+ const right = numberValue2(rect.right);
8387
8597
  if (left !== void 0 && left < 0) max = Math.max(max, Math.abs(left));
8388
8598
  if (right !== void 0 && right > viewportWidth) max = Math.max(max, right - viewportWidth);
8389
8599
  }
@@ -8406,7 +8616,7 @@ function boundsOffendersForEvidence(value) {
8406
8616
  function maxPositiveNumber(...values) {
8407
8617
  let max = 0;
8408
8618
  for (const value of values) {
8409
- const number = numberValue(value);
8619
+ const number = numberValue2(value);
8410
8620
  if (number !== void 0 && number > max) max = number;
8411
8621
  }
8412
8622
  return max;
@@ -8415,7 +8625,7 @@ function roundPixels(value) {
8415
8625
  return Math.round(value * 100) / 100;
8416
8626
  }
8417
8627
  function timeoutSecValue(value) {
8418
- const number = numberValue(value);
8628
+ const number = numberValue2(value);
8419
8629
  return number && number > 0 ? Math.ceil(number) : void 0;
8420
8630
  }
8421
8631
  function jsonRecord(value) {
@@ -8735,9 +8945,9 @@ function profileSetupReturnSummaryFields(result) {
8735
8945
  continue;
8736
8946
  }
8737
8947
  if (!isRecord(item)) continue;
8738
- const path7 = stringValue2(item.path) ?? stringValue2(item.key) ?? stringValue2(item.json_path) ?? stringValue2(item.jsonPath);
8948
+ const path7 = stringValue3(item.path) ?? stringValue3(item.key) ?? stringValue3(item.json_path) ?? stringValue3(item.jsonPath);
8739
8949
  if (!path7) continue;
8740
- const label = stringValue2(item.label) ?? stringValue2(item.name) ?? stringValue2(item.title);
8950
+ const label = stringValue3(item.label) ?? stringValue3(item.name) ?? stringValue3(item.title);
8741
8951
  fields.push(label ? { path: path7, label } : { path: path7 });
8742
8952
  }
8743
8953
  return fields;
@@ -8867,14 +9077,14 @@ function profileSetupCanvasSignatureStableHashGroups(results) {
8867
9077
  const groups = /* @__PURE__ */ new Map();
8868
9078
  for (const receipt of profileSetupCanvasSignatureReceipts(results)) {
8869
9079
  if (receipt.ok === false) continue;
8870
- const hash = stringValue2(receipt.hash);
9080
+ const hash = stringValue3(receipt.hash);
8871
9081
  if (!hash) continue;
8872
- const selector = stringValue2(receipt.selector) || "canvas";
8873
- const frameSelector = stringValue2(receipt.frame_selector);
9082
+ const selector = stringValue3(receipt.selector) || "canvas";
9083
+ const frameSelector = stringValue3(receipt.frame_selector);
8874
9084
  const key = String(frameSelector || "") + "\n" + selector;
8875
9085
  const group = groups.get(key) || { selector, frame_selector: frameSelector, receipts: [] };
8876
- const ordinal = numberValue(receipt.ordinal);
8877
- const label = stringValue2(receipt.label) || (ordinal === void 0 ? `capture-${group.receipts.length + 1}` : `#${ordinal}`);
9086
+ const ordinal = numberValue2(receipt.ordinal);
9087
+ const label = stringValue3(receipt.label) || (ordinal === void 0 ? `capture-${group.receipts.length + 1}` : `#${ordinal}`);
8878
9088
  group.receipts.push({ hash, label, ordinal });
8879
9089
  groups.set(key, group);
8880
9090
  }
@@ -8910,12 +9120,12 @@ function profileSetupClickSequenceReceipts(clickedItems) {
8910
9120
  const nthChildTemplatePattern = /:nth-child\(\d+\)/g;
8911
9121
  const groups = /* @__PURE__ */ new Map();
8912
9122
  for (const item of clickedItems) {
8913
- const selector = stringValue2(item.selector);
9123
+ const selector = stringValue3(item.selector);
8914
9124
  if (!selector) continue;
8915
- const frameSelector = stringValue2(item.frame_selector);
8916
- const clickCountValue = numberValue(item.click_count);
9125
+ const frameSelector = stringValue3(item.frame_selector);
9126
+ const clickCountValue = numberValue2(item.click_count);
8917
9127
  const clickCount = clickCountValue === void 0 ? 1 : Math.max(1, Math.min(100, Math.floor(clickCountValue)));
8918
- const ordinal = numberValue(item.ordinal);
9128
+ const ordinal = numberValue2(item.ordinal);
8919
9129
  const match = nthChildPattern.exec(selector);
8920
9130
  const selectorTemplate = match ? selector.replace(nthChildTemplatePattern, ":nth-child(*)") : selector;
8921
9131
  const valueSource = match ? "nth-child" : "same-selector";
@@ -9117,7 +9327,7 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
9117
9327
  });
9118
9328
  }
9119
9329
  function normalizeName(value, fallback) {
9120
- const name = stringValue2(value) || fallback;
9330
+ const name = stringValue3(value) || fallback;
9121
9331
  return name.replace(/\s+/g, " ").trim();
9122
9332
  }
9123
9333
  function slugifyRiddleProofProfileName(value) {
@@ -9125,8 +9335,8 @@ function slugifyRiddleProofProfileName(value) {
9125
9335
  }
9126
9336
  function normalizeViewport(input, index) {
9127
9337
  if (!isRecord(input)) throw new Error(`target.viewports[${index}] must be an object.`);
9128
- const width = numberValue(input.width);
9129
- const height = numberValue(input.height);
9338
+ const width = numberValue2(input.width);
9339
+ const height = numberValue2(input.height);
9130
9340
  if (!width || !height || width < 100 || height < 100) {
9131
9341
  throw new Error(`target.viewports[${index}] requires numeric width and height >= 100.`);
9132
9342
  }
@@ -9200,7 +9410,7 @@ function normalizeReturnSummaryFields(input, index) {
9200
9410
  });
9201
9411
  }
9202
9412
  function normalizeSetupActionRepeat(input, index) {
9203
- const repeat = numberValue(valueFromOwn(input, "repeat", "repeat_count", "repeatCount", "times"));
9413
+ const repeat = numberValue2(valueFromOwn(input, "repeat", "repeat_count", "repeatCount", "times"));
9204
9414
  if (repeat === void 0) return void 0;
9205
9415
  if (!Number.isInteger(repeat) || repeat < 1 || repeat > 100) {
9206
9416
  throw new Error(`target.setup_actions[${index}].repeat must be an integer from 1 to 100.`);
@@ -9213,7 +9423,7 @@ function normalizeSetupActionClickCount(input, type, index) {
9213
9423
  if (type !== "click") {
9214
9424
  throw new Error(`target.setup_actions[${index}].click_count is only supported for click actions.`);
9215
9425
  }
9216
- const clickCount = numberValue(clickCountInput);
9426
+ const clickCount = numberValue2(clickCountInput);
9217
9427
  if (clickCount === void 0 || !Number.isInteger(clickCount) || clickCount < 1 || clickCount > 10) {
9218
9428
  throw new Error(`target.setup_actions[${index}].click_count must be an integer from 1 to 10.`);
9219
9429
  }
@@ -9238,8 +9448,8 @@ function normalizeSetupActionPointerType(value, type, index) {
9238
9448
  throw new Error(`target.setup_actions[${index}].pointer_type ${String(value)} is not supported. Supported pointer types: mouse, touch, pen.`);
9239
9449
  }
9240
9450
  function normalizeSetupActionScreenshotFullPage(input, type, index) {
9241
- const directFullPage = booleanValue(valueFromOwn(input, "full_page", "fullPage"));
9242
- const viewportOnly = booleanValue(valueFromOwn(input, "viewport_only", "viewportOnly", "viewport_screenshot", "viewportScreenshot"));
9451
+ const directFullPage = booleanValue2(valueFromOwn(input, "full_page", "fullPage"));
9452
+ const viewportOnly = booleanValue2(valueFromOwn(input, "viewport_only", "viewportOnly", "viewport_screenshot", "viewportScreenshot"));
9243
9453
  if (type !== "screenshot") {
9244
9454
  if (directFullPage !== void 0 || viewportOnly !== void 0 || valueFromOwn(input, "screenshot_mode", "screenshotMode", "capture_mode", "captureMode") !== void 0) {
9245
9455
  throw new Error(`target.setup_actions[${index}].full_page is only supported for screenshot actions.`);
@@ -9282,7 +9492,7 @@ function normalizeSetupActionRandomQueue(input, index) {
9282
9492
  throw new Error(`target.setup_actions[${index}].random_queue must be a non-empty array of numbers from 0 inclusive to 1 exclusive.`);
9283
9493
  }
9284
9494
  return rawQueue.map((item, queueIndex) => {
9285
- const value = numberValue(item);
9495
+ const value = numberValue2(item);
9286
9496
  if (value === void 0 || value < 0 || value >= 1) {
9287
9497
  throw new Error(`target.setup_actions[${index}].random_queue[${queueIndex}] must be a finite number from 0 inclusive to 1 exclusive.`);
9288
9498
  }
@@ -9292,7 +9502,7 @@ function normalizeSetupActionRandomQueue(input, index) {
9292
9502
  function normalizeSetupActionNonNegativeNumber(input, index, outputKey, ...keys) {
9293
9503
  const rawValue = valueFromOwn(input, ...keys);
9294
9504
  if (rawValue === void 0) return void 0;
9295
- const value = numberValue(rawValue);
9505
+ const value = numberValue2(rawValue);
9296
9506
  if (value === void 0 || value < 0) {
9297
9507
  throw new Error(`target.setup_actions[${index}].${outputKey} must be a finite non-negative number.`);
9298
9508
  }
@@ -9300,24 +9510,24 @@ function normalizeSetupActionNonNegativeNumber(input, index, outputKey, ...keys)
9300
9510
  }
9301
9511
  function normalizeSetupAction(input, index) {
9302
9512
  if (!isRecord(input)) throw new Error(`target.setup_actions[${index}] must be an object.`);
9303
- const type = normalizeSetupActionType(stringValue2(input.type), index);
9513
+ const type = normalizeSetupActionType(stringValue3(input.type), index);
9304
9514
  const rawType = String(input.type || "").trim().replace(/-/g, "_").toLowerCase();
9305
- const selector = stringValue2(input.selector);
9515
+ const selector = stringValue3(input.selector);
9306
9516
  const frameSelector = stringFromOwn(input, "frame_selector", "frameSelector", "iframe_selector", "iframeSelector");
9307
- const frameIndex = numberValue(valueFromOwn(input, "frame_index", "frameIndex", "iframe_index", "iframeIndex"));
9517
+ const frameIndex = numberValue2(valueFromOwn(input, "frame_index", "frameIndex", "iframe_index", "iframeIndex"));
9308
9518
  if (frameIndex !== void 0 && (!Number.isInteger(frameIndex) || frameIndex < 0)) {
9309
9519
  throw new Error(`target.setup_actions[${index}].frame_index must be a non-negative integer.`);
9310
9520
  }
9311
9521
  if ((type === "click" || type === "tap" || type === "tap_until" || type === "drag" || type === "fill" || type === "set_input_value" || type === "set_range_value" || type === "canvas_signature" || type === "wait_for_selector" || type === "wait_for_text" || type === "assert_text_visible" || type === "assert_text_absent" || type === "assert_selector_count") && !selector) {
9312
9522
  throw new Error(`target.setup_actions[${index}] ${type} requires selector.`);
9313
9523
  }
9314
- const fromX = type === "click" || type === "tap" || type === "tap_until" ? numberValue(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
9315
- const fromY = type === "click" || type === "tap" || type === "tap_until" ? numberValue(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
9316
- const toX = numberValue(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
9317
- const toY = numberValue(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
9524
+ const fromX = type === "click" || type === "tap" || type === "tap_until" ? numberValue2(valueFromOwn(input, "from_x", "fromX", "x", "click_x", "clickX", "start_x", "startX", "x1")) : numberValue2(valueFromOwn(input, "from_x", "fromX", "start_x", "startX", "x1"));
9525
+ const fromY = type === "click" || type === "tap" || type === "tap_until" ? numberValue2(valueFromOwn(input, "from_y", "fromY", "y", "click_y", "clickY", "start_y", "startY", "y1")) : numberValue2(valueFromOwn(input, "from_y", "fromY", "start_y", "startY", "y1"));
9526
+ const toX = numberValue2(valueFromOwn(input, "to_x", "toX", "end_x", "endX", "x2"));
9527
+ const toY = numberValue2(valueFromOwn(input, "to_y", "toY", "end_y", "endY", "y2"));
9318
9528
  const coordinateMode = normalizeSetupActionCoordinateMode(valueFromOwn(input, "coordinate_mode", "coordinateMode", "coords", "units"), index);
9319
9529
  const pointerType = normalizeSetupActionPointerType(valueFromOwn(input, "pointer_type", "pointerType", "input_type", "inputType"), type, index);
9320
- const durationMs = numberValue(input.duration_ms) ?? numberValue(input.durationMs);
9530
+ const durationMs = numberValue2(input.duration_ms) ?? numberValue2(input.durationMs);
9321
9531
  const holdMs = type === "press" ? normalizeSetupActionNonNegativeNumber(input, index, "hold_ms", "hold_ms", "holdMs", "key_down_ms", "keyDownMs", "down_ms", "downMs") ?? durationMs : void 0;
9322
9532
  if (type === "press" && holdMs !== void 0 && (holdMs < 0 || holdMs > 3e4)) {
9323
9533
  throw new Error(`target.setup_actions[${index}].hold_ms must be a finite number from 0 to 30000.`);
@@ -9363,13 +9573,13 @@ function normalizeSetupAction(input, index) {
9363
9573
  throw new Error(`target.setup_actions[${index}] drag pixel coordinates must be non-negative.`);
9364
9574
  }
9365
9575
  }
9366
- if (type === "wait_for_text" && !stringValue2(input.text) && !stringValue2(input.pattern)) {
9576
+ if (type === "wait_for_text" && !stringValue3(input.text) && !stringValue3(input.pattern)) {
9367
9577
  throw new Error(`target.setup_actions[${index}] wait_for_text requires text or pattern.`);
9368
9578
  }
9369
- if ((type === "assert_text_visible" || type === "assert_text_absent") && !stringValue2(input.text) && !stringValue2(input.pattern)) {
9579
+ if ((type === "assert_text_visible" || type === "assert_text_absent") && !stringValue3(input.text) && !stringValue3(input.pattern)) {
9370
9580
  throw new Error(`target.setup_actions[${index}] ${type} requires text or pattern.`);
9371
9581
  }
9372
- const expectedCount = numberValue(input.expected_count ?? input.expectedCount ?? input.count);
9582
+ const expectedCount = numberValue2(input.expected_count ?? input.expectedCount ?? input.count);
9373
9583
  if (type === "assert_selector_count" && (expectedCount === void 0 || !Number.isInteger(expectedCount) || expectedCount < 0)) {
9374
9584
  throw new Error(`target.setup_actions[${index}] ${type} requires non-negative integer expected_count.`);
9375
9585
  }
@@ -9381,12 +9591,12 @@ function normalizeSetupAction(input, index) {
9381
9591
  const randomQueue = type === "deterministic_runtime" ? normalizeSetupActionRandomQueue(input, index) : void 0;
9382
9592
  const deterministicNow = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "now", "now", "date_now", "dateNow", "mock_now", "mockNow", "clock", "timestamp", "time_ms", "timeMs") : void 0;
9383
9593
  const deterministicAdvanceMs = type === "deterministic_runtime" ? normalizeSetupActionNonNegativeNumber(input, index, "advance_ms", "advance_ms", "advanceMs", "tick_ms", "tickMs", "add_ms", "addMs") : void 0;
9384
- const deterministicAppend = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "append", "append_random", "appendRandom")) === true;
9385
- const deterministicRestore = type === "deterministic_runtime" && booleanValue(valueFromOwn(input, "restore", "reset", "restore_originals", "restoreOriginals")) === true;
9594
+ const deterministicAppend = type === "deterministic_runtime" && booleanValue2(valueFromOwn(input, "append", "append_random", "appendRandom")) === true;
9595
+ const deterministicRestore = type === "deterministic_runtime" && booleanValue2(valueFromOwn(input, "restore", "reset", "restore_originals", "restoreOriginals")) === true;
9386
9596
  if (type === "deterministic_runtime" && randomQueue === void 0 && deterministicNow === void 0 && deterministicAdvanceMs === void 0 && !deterministicRestore) {
9387
9597
  throw new Error(`target.setup_actions[${index}] deterministic_runtime requires random_queue, now, advance_ms, or restore.`);
9388
9598
  }
9389
- const key = stringValue2(input.key);
9599
+ const key = stringValue3(input.key);
9390
9600
  let dialogAccept;
9391
9601
  if (type === "dialog_response") {
9392
9602
  const acceptInput = valueFromOwn(input, "accept", "accepted", "should_accept", "shouldAccept");
@@ -9425,13 +9635,13 @@ function normalizeSetupAction(input, index) {
9425
9635
  throw new Error(`target.setup_actions[${index}] ${type} requires expected_value.`);
9426
9636
  }
9427
9637
  const rawExpectedValue = valueFromOwn(input, "expected_value", "expectedValue", "expected", "expect_value", "expectValue", "expect");
9428
- const minValue = numberValue(valueFromOwn(input, "min_value", "minValue", "minimum", "min", "at_least", "atLeast", "gte"));
9429
- const maxValue = numberValue(valueFromOwn(input, "max_value", "maxValue", "maximum", "max", "at_most", "atMost", "lte"));
9638
+ const minValue = numberValue2(valueFromOwn(input, "min_value", "minValue", "minimum", "min", "at_least", "atLeast", "gte"));
9639
+ const maxValue = numberValue2(valueFromOwn(input, "max_value", "maxValue", "maximum", "max", "at_most", "atMost", "lte"));
9430
9640
  if (type === "assert_window_number") {
9431
9641
  if (!hasExpectedValue && minValue === void 0 && maxValue === void 0) {
9432
9642
  throw new Error(`target.setup_actions[${index}] ${type} requires expected_value, min_value, or max_value.`);
9433
9643
  }
9434
- if (hasExpectedValue && numberValue(rawExpectedValue) === void 0) {
9644
+ if (hasExpectedValue && numberValue2(rawExpectedValue) === void 0) {
9435
9645
  throw new Error(`target.setup_actions[${index}] ${type} expected_value must be a finite number.`);
9436
9646
  }
9437
9647
  }
@@ -9462,23 +9672,23 @@ function normalizeSetupAction(input, index) {
9462
9672
  throw new Error(`target.setup_actions[${index}] ${type} requires until_expected_value.`);
9463
9673
  }
9464
9674
  }
9465
- const maxCalls = numberValue(valueFromOwn(input, "max_calls", "maxCalls", "max_attempts", "maxAttempts", "attempts", "max_taps", "maxTaps", "tap_limit", "tapLimit"));
9675
+ const maxCalls = numberValue2(valueFromOwn(input, "max_calls", "maxCalls", "max_attempts", "maxAttempts", "attempts", "max_taps", "maxTaps", "tap_limit", "tapLimit"));
9466
9676
  if ((type === "window_call_until" || type === "tap_until") && (maxCalls === void 0 || !Number.isInteger(maxCalls) || maxCalls < 1 || maxCalls > 100)) {
9467
9677
  throw new Error(`target.setup_actions[${index}].max_calls must be an integer from 1 to 100.`);
9468
9678
  }
9469
- const tapBurstSize = type === "tap_until" ? numberValue(valueFromOwn(input, "tap_burst_size", "tapBurstSize", "burst_size", "burstSize", "check_every_taps", "checkEveryTaps", "predicate_interval_taps", "predicateIntervalTaps")) : void 0;
9679
+ const tapBurstSize = type === "tap_until" ? numberValue2(valueFromOwn(input, "tap_burst_size", "tapBurstSize", "burst_size", "burstSize", "check_every_taps", "checkEveryTaps", "predicate_interval_taps", "predicateIntervalTaps")) : void 0;
9470
9680
  if (type === "tap_until" && tapBurstSize !== void 0 && (!Number.isInteger(tapBurstSize) || tapBurstSize < 1 || tapBurstSize > 100)) {
9471
9681
  throw new Error(`target.setup_actions[${index}].tap_burst_size must be an integer from 1 to 100.`);
9472
9682
  }
9473
- const settleMs = type === "tap_until" ? numberValue(valueFromOwn(input, "settle_ms", "settleMs", "predicate_settle_ms", "predicateSettleMs", "post_burst_wait_ms", "postBurstWaitMs", "after_burst_ms", "afterBurstMs", "settle_after_tap_ms", "settleAfterTapMs")) : void 0;
9683
+ const settleMs = type === "tap_until" ? numberValue2(valueFromOwn(input, "settle_ms", "settleMs", "predicate_settle_ms", "predicateSettleMs", "post_burst_wait_ms", "postBurstWaitMs", "after_burst_ms", "afterBurstMs", "settle_after_tap_ms", "settleAfterTapMs")) : void 0;
9474
9684
  if (type === "tap_until" && settleMs !== void 0 && (!Number.isInteger(settleMs) || settleMs < 0 || settleMs > 1e4)) {
9475
9685
  throw new Error(`target.setup_actions[${index}].settle_ms must be an integer from 0 to 10000.`);
9476
9686
  }
9477
- const intervalMs = numberValue(valueFromOwn(input, "interval_ms", "intervalMs", "poll_ms", "pollMs", "call_interval_ms", "callIntervalMs"));
9687
+ const intervalMs = numberValue2(valueFromOwn(input, "interval_ms", "intervalMs", "poll_ms", "pollMs", "call_interval_ms", "callIntervalMs"));
9478
9688
  if ((type === "window_call_until" || type === "tap_until") && intervalMs !== void 0 && (!Number.isInteger(intervalMs) || intervalMs < 0 || intervalMs > 5e3)) {
9479
9689
  throw new Error(`target.setup_actions[${index}].interval_ms must be an integer from 0 to 5000.`);
9480
9690
  }
9481
- const steps = numberValue(input.steps);
9691
+ const steps = numberValue2(input.steps);
9482
9692
  if (type === "drag" && steps !== void 0 && (!Number.isInteger(steps) || steps < 1 || steps > 100)) {
9483
9693
  throw new Error(`target.setup_actions[${index}].steps must be an integer from 1 to 100.`);
9484
9694
  }
@@ -9517,7 +9727,7 @@ function normalizeSetupAction(input, index) {
9517
9727
  capture_return: captureReturn,
9518
9728
  return_summary_fields: normalizeReturnSummaryFields(input, index),
9519
9729
  compare_to: stringFromOwn(input, "compare_to", "compareTo", "previous_signature_path", "previousSignaturePath", "previous_path", "previousPath", "changed_from", "changedFrom"),
9520
- expect_changed: booleanValue(valueFromOwn(input, "expect_changed", "expectChanged", "should_change", "shouldChange", "changed")),
9730
+ expect_changed: booleanValue2(valueFromOwn(input, "expect_changed", "expectChanged", "should_change", "shouldChange", "changed")),
9521
9731
  until_path: untilPath,
9522
9732
  until_expected_value: hasUntilExpectedValue ? toJsonValue(valueFromOwn(input, "until_expected_value", "untilExpectedValue", "until_expected", "untilExpected", "until_value", "untilValue", "expected_value", "expectedValue", "expected")) : void 0,
9523
9733
  expected_path: stringFromOwn(input, "expected_path", "expectedPath", "expected_terminal_path", "expectedTerminalPath"),
@@ -9529,18 +9739,18 @@ function normalizeSetupAction(input, index) {
9529
9739
  expected_value: hasExpectedValue ? toJsonValue(rawExpectedValue) : void 0,
9530
9740
  min_value: minValue,
9531
9741
  max_value: maxValue,
9532
- text: stringValue2(input.text),
9533
- pattern: stringValue2(input.pattern),
9534
- flags: stringValue2(input.flags),
9742
+ text: stringValue3(input.text),
9743
+ pattern: stringValue3(input.pattern),
9744
+ flags: stringValue3(input.flags),
9535
9745
  accept: dialogAccept,
9536
9746
  prompt_text: stringFromOwn(input, "prompt_text", "promptText", "prompt_value", "promptValue"),
9537
9747
  message_text: stringFromOwn(input, "message_text", "messageText", "dialog_text", "dialogText"),
9538
9748
  message_pattern: stringFromOwn(input, "message_pattern", "messagePattern", "dialog_pattern", "dialogPattern"),
9539
- index: numberValue(valueFromOwn(input, "index", "target_index", "targetIndex")),
9749
+ index: numberValue2(valueFromOwn(input, "index", "target_index", "targetIndex")),
9540
9750
  expected_count: expectedCount,
9541
- ms: numberValue(input.ms) ?? numberValue(input.wait_ms) ?? numberValue(input.waitMs),
9542
- timeout_ms: numberValue(input.timeout_ms) ?? numberValue(input.timeoutMs),
9543
- after_ms: numberValue(input.after_ms) ?? numberValue(input.afterMs),
9751
+ ms: numberValue2(input.ms) ?? numberValue2(input.wait_ms) ?? numberValue2(input.waitMs),
9752
+ timeout_ms: numberValue2(input.timeout_ms) ?? numberValue2(input.timeoutMs),
9753
+ after_ms: numberValue2(input.after_ms) ?? numberValue2(input.afterMs),
9544
9754
  repeat: normalizeSetupActionRepeat(input, index),
9545
9755
  reload: input.reload === true,
9546
9756
  storage: normalizeSetupActionStorage(input.storage, index),
@@ -9555,7 +9765,7 @@ function normalizeSetupActions(value) {
9555
9765
  return value.map(normalizeSetupAction);
9556
9766
  }
9557
9767
  function normalizeTargetScreenshotFullPage(input) {
9558
- const directFullPage = booleanValue(valueFromOwn(
9768
+ const directFullPage = booleanValue2(valueFromOwn(
9559
9769
  input,
9560
9770
  "screenshot_full_page",
9561
9771
  "screenshotFullPage",
@@ -9564,7 +9774,7 @@ function normalizeTargetScreenshotFullPage(input) {
9564
9774
  "full_page_screenshots",
9565
9775
  "fullPageScreenshots"
9566
9776
  ));
9567
- const viewportOnly = booleanValue(valueFromOwn(
9777
+ const viewportOnly = booleanValue2(valueFromOwn(
9568
9778
  input,
9569
9779
  "viewport_screenshots",
9570
9780
  "viewportScreenshots",
@@ -9592,20 +9802,20 @@ function normalizeTargetScreenshotFullPage(input) {
9592
9802
  }
9593
9803
  function normalizeNetworkMock(input, index) {
9594
9804
  if (!isRecord(input)) throw new Error(`target.network_mocks[${index}] must be an object.`);
9595
- const url = stringValue2(input.url) || stringValue2(input.glob) || stringValue2(input.pattern);
9805
+ const url = stringValue3(input.url) || stringValue3(input.glob) || stringValue3(input.pattern);
9596
9806
  if (!url) throw new Error(`target.network_mocks[${index}] requires url.`);
9597
9807
  const payload = normalizeNetworkMockResponsePayload(input, `target.network_mocks[${index}]`);
9598
9808
  const responsesInput = input.responses ?? input.sequence;
9599
9809
  const responses = normalizeNetworkMockResponses(responsesInput, index, payload);
9600
9810
  const requestBody = normalizeNetworkMockRequestBodyConstraints(input, `target.network_mocks[${index}]`);
9601
- const requiredHitCount = numberValue(
9811
+ const requiredHitCount = numberValue2(
9602
9812
  input.required_hit_count ?? input.requiredHitCount ?? input.required_hits ?? input.requiredHits ?? input.min_hits ?? input.minHits
9603
9813
  );
9604
9814
  if (requiredHitCount !== void 0 && (!Number.isInteger(requiredHitCount) || requiredHitCount < 1)) {
9605
9815
  throw new Error(`target.network_mocks[${index}].required_hit_count must be a positive integer.`);
9606
9816
  }
9607
9817
  const forbidden = input.forbidden === true || input.must_not_hit === true || input.mustNotHit === true || input.should_not_run === true || input.shouldNotRun === true;
9608
- const configuredMaxHitCount = numberValue(
9818
+ const configuredMaxHitCount = numberValue2(
9609
9819
  input.max_hit_count ?? input.maxHitCount ?? input.max_hits ?? input.maxHits
9610
9820
  );
9611
9821
  if (configuredMaxHitCount !== void 0 && (!Number.isInteger(configuredMaxHitCount) || configuredMaxHitCount < 0)) {
@@ -9620,7 +9830,7 @@ function normalizeNetworkMock(input, index) {
9620
9830
  if (maxHitCount !== void 0 && effectiveRequiredHitCount > maxHitCount) {
9621
9831
  throw new Error(`target.network_mocks[${index}].max_hit_count cannot be less than its required hit count.`);
9622
9832
  }
9623
- const sequenceScopeInput = stringValue2(
9833
+ const sequenceScopeInput = stringValue3(
9624
9834
  input.sequence_scope ?? input.sequenceScope ?? input.response_sequence_scope ?? input.responseSequenceScope
9625
9835
  );
9626
9836
  let sequenceScope;
@@ -9638,7 +9848,7 @@ function normalizeNetworkMock(input, index) {
9638
9848
  ...payload,
9639
9849
  label: normalizeName(input.label || input.name, `network-mock-${index + 1}`),
9640
9850
  url,
9641
- method: stringValue2(input.method)?.toUpperCase(),
9851
+ method: stringValue3(input.method)?.toUpperCase(),
9642
9852
  responses,
9643
9853
  repeat_responses: input.repeat_responses === true || input.repeatResponses === true || input.cycle_responses === true || input.cycleResponses === true,
9644
9854
  sequence_scope: sequenceScope,
@@ -9681,18 +9891,18 @@ function normalizeNetworkMockRequestBodyConstraints(input, label) {
9681
9891
  };
9682
9892
  }
9683
9893
  function normalizeNetworkMockResponsePayload(input, label, defaults = {}) {
9684
- const status = numberValue(input.status) ?? defaults.status ?? 200;
9894
+ const status = numberValue2(input.status) ?? defaults.status ?? 200;
9685
9895
  if (!Number.isInteger(status) || status < 100 || status > 599) {
9686
9896
  throw new Error(`${label}.status must be an HTTP status code.`);
9687
9897
  }
9688
- const body = stringValue2(input.body) ?? stringValue2(input.body_text) ?? stringValue2(input.bodyText) ?? defaults.body;
9898
+ const body = stringValue3(input.body) ?? stringValue3(input.body_text) ?? stringValue3(input.bodyText) ?? defaults.body;
9689
9899
  const hasJsonBody = Object.prototype.hasOwnProperty.call(input, "body_json") || Object.prototype.hasOwnProperty.call(input, "bodyJson") || Object.prototype.hasOwnProperty.call(input, "json");
9690
9900
  const requestBody = normalizeNetworkMockRequestBodyConstraints(input, label);
9691
9901
  const abort = normalizeNetworkMockAbort(input, label, defaults.abort, defaults.abort_error_code);
9692
9902
  return {
9693
- label: stringValue2(input.label) || stringValue2(input.name) || defaults.label,
9903
+ label: stringValue3(input.label) || stringValue3(input.name) || defaults.label,
9694
9904
  status,
9695
- content_type: stringValue2(input.content_type) || stringValue2(input.contentType) || defaults.content_type,
9905
+ content_type: stringValue3(input.content_type) || stringValue3(input.contentType) || defaults.content_type,
9696
9906
  headers: stringRecord(input.headers) || defaults.headers,
9697
9907
  body,
9698
9908
  body_json: hasJsonBody ? toJsonValue(input.body_json ?? input.bodyJson ?? input.json) : defaults.body_json,
@@ -9711,7 +9921,7 @@ function normalizeNetworkMockAbort(input, label, defaultAbort, defaultErrorCode)
9711
9921
  const explicitAbort = typeof abortInput === "string" ? abortInput.trim().length > 0 : abortInput === true;
9712
9922
  const abort = explicitAbort || defaultAbort === true;
9713
9923
  if (!abort) return {};
9714
- const codeInput = stringValue2(
9924
+ const codeInput = stringValue3(
9715
9925
  typeof abortInput === "string" ? abortInput : input.abort_error_code ?? input.abortErrorCode ?? input.abort_error ?? input.abortError ?? input.network_error ?? input.networkError
9716
9926
  ) || defaultErrorCode || "failed";
9717
9927
  const abort_error_code = codeInput.toLowerCase();
@@ -9721,7 +9931,7 @@ function normalizeNetworkMockAbort(input, label, defaultAbort, defaultErrorCode)
9721
9931
  return { abort: true, abort_error_code };
9722
9932
  }
9723
9933
  function normalizeNetworkMockDelay(input, label, defaultValue) {
9724
- const value = numberValue(
9934
+ const value = numberValue2(
9725
9935
  input.delay_ms ?? input.delayMs ?? input.wait_ms ?? input.waitMs ?? input.latency_ms ?? input.latencyMs
9726
9936
  ) ?? defaultValue;
9727
9937
  if (value === void 0) return void 0;
@@ -9836,7 +10046,7 @@ function collectRiddleProofProfileEnvironmentBlockedWarnings(profile, blocker) {
9836
10046
  return warnings;
9837
10047
  }
9838
10048
  function normalizeRouteInventoryPath(value, label) {
9839
- const path7 = stringValue2(value);
10049
+ const path7 = stringValue3(value);
9840
10050
  if (!path7) throw new Error(`${label} requires path.`);
9841
10051
  if (!path7.startsWith("/")) throw new Error(`${label}.path must start with /.`);
9842
10052
  return normalizeRoutePath2(path7);
@@ -9845,7 +10055,7 @@ function normalizeRouteInventoryRoute(input, index) {
9845
10055
  if (typeof input === "string") return { path: normalizeRouteInventoryPath(input, `checks route_inventory expected_routes[${index}]`) };
9846
10056
  if (!isRecord(input)) throw new Error(`checks route_inventory expected_routes[${index}] must be a string or object.`);
9847
10057
  return {
9848
- name: stringValue2(input.name),
10058
+ name: stringValue3(input.name),
9849
10059
  path: normalizeRouteInventoryPath(input.path, `checks route_inventory expected_routes[${index}]`)
9850
10060
  };
9851
10061
  }
@@ -9880,7 +10090,7 @@ function normalizeStringList(value, label) {
9880
10090
  }
9881
10091
  function normalizeHttpStatus(value, label) {
9882
10092
  if (value === void 0) return void 0;
9883
- const status = numberValue(value);
10093
+ const status = numberValue2(value);
9884
10094
  if (status === void 0 || !Number.isInteger(status) || status < 100 || status > 599) {
9885
10095
  throw new Error(`${label} must be an HTTP status code.`);
9886
10096
  }
@@ -9895,7 +10105,7 @@ function normalizeHttpStatuses(value, label) {
9895
10105
  }
9896
10106
  function normalizePositiveInteger(value, label, max) {
9897
10107
  if (value === void 0) return void 0;
9898
- const number = numberValue(value);
10108
+ const number = numberValue2(value);
9899
10109
  if (number === void 0 || !Number.isInteger(number) || number < 1 || max !== void 0 && number > max) {
9900
10110
  throw new Error(`${label} must be an integer from 1 to ${max ?? "unbounded"}.`);
9901
10111
  }
@@ -9918,7 +10128,7 @@ function normalizeHttpStatusBodyJsonAssertions(value, label) {
9918
10128
  return value.map((item, index) => {
9919
10129
  const itemLabel = `${label}[${index}]`;
9920
10130
  if (typeof item === "string") {
9921
- const path8 = stringValue2(item);
10131
+ const path8 = stringValue3(item);
9922
10132
  if (!path8) throw new Error(`${itemLabel} path must not be empty.`);
9923
10133
  return { path: path8, exists: true };
9924
10134
  }
@@ -9926,12 +10136,12 @@ function normalizeHttpStatusBodyJsonAssertions(value, label) {
9926
10136
  const path7 = stringFromOwn(item, "path", "json_path", "jsonPath", "key");
9927
10137
  if (!path7) throw new Error(`${itemLabel}.path is required.`);
9928
10138
  const assertion = {
9929
- label: stringValue2(item.label),
10139
+ label: stringValue3(item.label),
9930
10140
  path: path7
9931
10141
  };
9932
- const exists = booleanValue(valueFromOwn(item, "exists", "present"));
10142
+ const exists = booleanValue2(valueFromOwn(item, "exists", "present"));
9933
10143
  if (exists !== void 0) assertion.exists = exists;
9934
- const type = stringValue2(valueFromOwn(item, "type", "value_type", "valueType"));
10144
+ const type = stringValue3(valueFromOwn(item, "type", "value_type", "valueType"));
9935
10145
  if (type !== void 0) {
9936
10146
  const allowedTypes = ["array", "boolean", "null", "number", "object", "string"];
9937
10147
  if (!allowedTypes.includes(type)) {
@@ -9961,43 +10171,43 @@ function dialogCountFieldForCheckType(type) {
9961
10171
  }
9962
10172
  function normalizeCheck(input, index) {
9963
10173
  if (!isRecord(input)) throw new Error(`checks[${index}] must be an object.`);
9964
- const type = stringValue2(input.type);
10174
+ const type = stringValue3(input.type);
9965
10175
  if (!type) throw new Error(`checks[${index}].type is required.`);
9966
10176
  if (!isSupportedCheckType(type)) {
9967
10177
  throw new Error(`checks[${index}].type ${type} is not supported. Supported checks: ${RIDDLE_PROOF_PROFILE_CHECK_TYPES.join(", ")}`);
9968
10178
  }
9969
10179
  const isDialogCountCheck = isDialogCountCheckType(type);
9970
- if ((type === "selector_visible" || type === "selector_absent" || type === "selector_count_at_least" || type === "selector_count_equals" || type === "selector_count_equal" || type === "selector_count_eq" || type === "selector_text_visible" || type === "selector_text_absent" || type === "observe_within" && !stringValue2(input.text) && !stringValue2(input.pattern)) && !stringValue2(input.selector)) {
10180
+ if ((type === "selector_visible" || type === "selector_absent" || type === "selector_count_at_least" || type === "selector_count_equals" || type === "selector_count_equal" || type === "selector_count_eq" || type === "selector_text_visible" || type === "selector_text_absent" || type === "observe_within" && !stringValue3(input.text) && !stringValue3(input.pattern)) && !stringValue3(input.selector)) {
9971
10181
  throw new Error(`checks[${index}] ${type} requires selector.`);
9972
10182
  }
9973
- if ((type === "frame_text_visible" || type === "frame_url_equals" || type === "frame_url_matches" || type === "frame_no_horizontal_overflow") && !stringValue2(input.selector)) {
10183
+ if ((type === "frame_text_visible" || type === "frame_url_equals" || type === "frame_url_matches" || type === "frame_no_horizontal_overflow") && !stringValue3(input.selector)) {
9974
10184
  throw new Error(`checks[${index}] ${type} requires selector.`);
9975
10185
  }
9976
- if (type === "frame_text_visible" && !stringValue2(input.text) && !stringValue2(input.pattern)) {
10186
+ if (type === "frame_text_visible" && !stringValue3(input.text) && !stringValue3(input.pattern)) {
9977
10187
  throw new Error(`checks[${index}] frame_text_visible requires text or pattern.`);
9978
10188
  }
9979
10189
  const expectedUrl = stringFromOwn(input, "expected_url", "expectedUrl", "url", "expected_value", "expectedValue", "value");
9980
10190
  if (type === "frame_url_equals" && expectedUrl === void 0) {
9981
10191
  throw new Error(`checks[${index}] frame_url_equals requires expected_url.`);
9982
10192
  }
9983
- if (type === "frame_url_matches" && !stringValue2(input.pattern)) {
10193
+ if (type === "frame_url_matches" && !stringValue3(input.pattern)) {
9984
10194
  throw new Error(`checks[${index}] frame_url_matches requires pattern.`);
9985
10195
  }
9986
- if ((type === "text_visible" || type === "text_absent" || type === "selector_text_visible" || type === "selector_text_absent") && !stringValue2(input.text) && !stringValue2(input.pattern)) {
10196
+ if ((type === "text_visible" || type === "text_absent" || type === "selector_text_visible" || type === "selector_text_absent") && !stringValue3(input.text) && !stringValue3(input.pattern)) {
9987
10197
  throw new Error(`checks[${index}] ${type} requires text or pattern.`);
9988
10198
  }
9989
- if ((type === "url_search_param_equals" || type === "url_search_param_absent") && !stringValue2(input.param) && !stringValue2(input.search_param) && !stringValue2(input.searchParam) && !stringValue2(input.key)) {
10199
+ if ((type === "url_search_param_equals" || type === "url_search_param_absent") && !stringValue3(input.param) && !stringValue3(input.search_param) && !stringValue3(input.searchParam) && !stringValue3(input.key)) {
9990
10200
  throw new Error(`checks[${index}] ${type} requires param.`);
9991
10201
  }
9992
10202
  const expectedValue = stringFromOwn(input, "expected_value", "expectedValue", "value");
9993
10203
  if (type === "url_search_param_equals" && expectedValue === void 0) {
9994
10204
  throw new Error(`checks[${index}] url_search_param_equals requires expected_value.`);
9995
10205
  }
9996
- const minCount = numberValue(input.min_count) ?? numberValue(input.minCount);
10206
+ const minCount = numberValue2(input.min_count) ?? numberValue2(input.minCount);
9997
10207
  if (type === "selector_count_at_least" && minCount === void 0) {
9998
10208
  throw new Error(`checks[${index}] selector_count_at_least requires min_count.`);
9999
10209
  }
10000
- const expectedCount = numberValue(input.expected_count) ?? numberValue(input.expectedCount) ?? numberValue(input.count);
10210
+ const expectedCount = numberValue2(input.expected_count) ?? numberValue2(input.expectedCount) ?? numberValue2(input.count);
10001
10211
  if ((type === "selector_count_equals" || type === "selector_count_equal" || type === "selector_count_eq" || isDialogCountCheck) && expectedCount === void 0) {
10002
10212
  throw new Error(`checks[${index}] ${type} requires expected_count.`);
10003
10213
  }
@@ -10006,7 +10216,7 @@ function normalizeCheck(input, index) {
10006
10216
  }
10007
10217
  const expectedTexts = normalizeExpectedTexts(input.expected_texts ?? input.expectedTexts, index);
10008
10218
  if (type === "selector_text_order") {
10009
- if (!stringValue2(input.selector)) throw new Error(`checks[${index}] selector_text_order requires selector.`);
10219
+ if (!stringValue3(input.selector)) throw new Error(`checks[${index}] selector_text_order requires selector.`);
10010
10220
  if (!expectedTexts?.length) throw new Error(`checks[${index}] selector_text_order requires expected_texts.`);
10011
10221
  }
10012
10222
  const expectedRoutes = normalizeRouteInventoryRoutes(input.expected_routes ?? input.expectedRoutes, index);
@@ -10032,7 +10242,7 @@ function normalizeCheck(input, index) {
10032
10242
  ) : void 0;
10033
10243
  const maxLinks = isLinkStatusCheck ? normalizePositiveInteger(input.max_links ?? input.maxLinks ?? input.limit, `checks[${index}] max_links`, 500) : void 0;
10034
10244
  const minBytes = isStatusCheck ? normalizePositiveInteger(input.min_bytes ?? input.minBytes ?? input.min_response_bytes ?? input.minResponseBytes, `checks[${index}] min_bytes`) : void 0;
10035
- const expectedContentType = isStatusCheck ? stringValue2(input.expected_content_type) || stringValue2(input.expectedContentType) || stringValue2(input.content_type) || stringValue2(input.contentType) : void 0;
10245
+ const expectedContentType = isStatusCheck ? stringValue3(input.expected_content_type) || stringValue3(input.expectedContentType) || stringValue3(input.content_type) || stringValue3(input.contentType) : void 0;
10036
10246
  const allowedContentTypes = isStatusCheck ? normalizeStringList(
10037
10247
  input.allowed_content_types ?? input.allowedContentTypes ?? input.expected_content_types ?? input.expectedContentTypes,
10038
10248
  `checks[${index}] allowed_content_types`
@@ -10064,33 +10274,33 @@ function normalizeCheck(input, index) {
10064
10274
  }
10065
10275
  return {
10066
10276
  type,
10067
- label: stringValue2(input.label),
10068
- expected_path: stringValue2(input.expected_path),
10069
- param: stringValue2(input.param) || stringValue2(input.search_param) || stringValue2(input.searchParam) || stringValue2(input.key),
10277
+ label: stringValue3(input.label),
10278
+ expected_path: stringValue3(input.expected_path),
10279
+ param: stringValue3(input.param) || stringValue3(input.search_param) || stringValue3(input.searchParam) || stringValue3(input.key),
10070
10280
  expected_value: expectedValue,
10071
10281
  expected_url: expectedUrl,
10072
10282
  expected_routes: expectedRoutes,
10073
- selector: stringValue2(input.selector),
10283
+ selector: stringValue3(input.selector),
10074
10284
  url: isHttpStatusCheck ? requestUrl : void 0,
10075
10285
  method: isHttpStatusCheck ? method || "GET" : void 0,
10076
10286
  headers: isHttpStatusCheck ? stringRecord(input.headers) : void 0,
10077
- body: isHttpStatusCheck ? stringValue2(input.body) : void 0,
10287
+ body: isHttpStatusCheck ? stringValue3(input.body) : void 0,
10078
10288
  body_json: isHttpStatusCheck && hasBodyJson ? toJsonValue(input.body_json ?? input.bodyJson ?? input.json) : void 0,
10079
10289
  body_contains: bodyContains,
10080
10290
  body_not_contains: bodyNotContains,
10081
10291
  body_not_patterns: bodyNotPatterns,
10082
10292
  body_json_assertions: bodyJsonAssertions,
10083
10293
  expected_texts: expectedTexts,
10084
- link_selector: stringValue2(input.link_selector) || stringValue2(input.linkSelector),
10085
- source_selector: stringValue2(input.source_selector) || stringValue2(input.sourceSelector),
10086
- route_path_prefix: stringValue2(input.route_path_prefix) || stringValue2(input.routePathPrefix),
10087
- route_ready_selector: stringValue2(input.route_ready_selector) || stringValue2(input.routeReadySelector),
10088
- route_ready_text: stringValue2(input.route_ready_text) || stringValue2(input.routeReadyText),
10089
- route_ready_pattern: stringValue2(input.route_ready_pattern) || stringValue2(input.routeReadyPattern),
10090
- route_ready_flags: stringValue2(input.route_ready_flags) || stringValue2(input.routeReadyFlags),
10091
- text: stringValue2(input.text),
10092
- pattern: stringValue2(input.pattern),
10093
- flags: stringValue2(input.flags),
10294
+ link_selector: stringValue3(input.link_selector) || stringValue3(input.linkSelector),
10295
+ source_selector: stringValue3(input.source_selector) || stringValue3(input.sourceSelector),
10296
+ route_path_prefix: stringValue3(input.route_path_prefix) || stringValue3(input.routePathPrefix),
10297
+ route_ready_selector: stringValue3(input.route_ready_selector) || stringValue3(input.routeReadySelector),
10298
+ route_ready_text: stringValue3(input.route_ready_text) || stringValue3(input.routeReadyText),
10299
+ route_ready_pattern: stringValue3(input.route_ready_pattern) || stringValue3(input.routeReadyPattern),
10300
+ route_ready_flags: stringValue3(input.route_ready_flags) || stringValue3(input.routeReadyFlags),
10301
+ text: stringValue3(input.text),
10302
+ pattern: stringValue3(input.pattern),
10303
+ flags: stringValue3(input.flags),
10094
10304
  viewports: normalizeStringList(input.viewports ?? input.viewport_names ?? input.viewportNames, `checks[${index}] viewports`),
10095
10305
  allowed_console_texts: normalizeStringList(input.allowed_console_texts ?? input.allowedConsoleTexts ?? input.allow_console_texts ?? input.allowConsoleTexts, `checks[${index}] allowed_console_texts`),
10096
10306
  allowed_console_patterns: normalizeStringList(input.allowed_console_patterns ?? input.allowedConsolePatterns ?? input.allow_console_patterns ?? input.allowConsolePatterns, `checks[${index}] allowed_console_patterns`),
@@ -10107,8 +10317,8 @@ function normalizeCheck(input, index) {
10107
10317
  min_bytes: minBytes,
10108
10318
  allowed_content_types: allowedContentTypes,
10109
10319
  allow_get_fallback: isLinkStatusCheck ? input.allow_get_fallback === false || input.allowGetFallback === false ? false : true : void 0,
10110
- max_overflow_px: numberValue(input.max_overflow_px),
10111
- timeout_ms: numberValue(input.timeout_ms) ?? numberValue(input.timeoutMs) ?? numberValue(input.within_ms) ?? numberValue(input.withinMs),
10320
+ max_overflow_px: numberValue2(input.max_overflow_px),
10321
+ timeout_ms: numberValue2(input.timeout_ms) ?? numberValue2(input.timeoutMs) ?? numberValue2(input.within_ms) ?? numberValue2(input.withinMs),
10112
10322
  run_direct_routes: input.run_direct_routes === false || input.runDirectRoutes === false ? false : true,
10113
10323
  run_clickthroughs: input.run_clickthroughs === false || input.runClickthroughs === false ? false : true,
10114
10324
  run_all_viewports: input.run_all_viewports === true || input.runAllViewports === true,
@@ -10137,15 +10347,15 @@ function normalizeFailurePolicy(input) {
10137
10347
  }
10138
10348
  function normalizeRiddleProofProfile(input, options = {}) {
10139
10349
  if (!isRecord(input)) throw new Error("profile must be a JSON object.");
10140
- const version = stringValue2(input.version) || RIDDLE_PROOF_PROFILE_VERSION;
10350
+ const version = stringValue3(input.version) || RIDDLE_PROOF_PROFILE_VERSION;
10141
10351
  if (version !== RIDDLE_PROOF_PROFILE_VERSION) {
10142
10352
  throw new Error(`Unsupported profile version ${version}. Expected ${RIDDLE_PROOF_PROFILE_VERSION}.`);
10143
10353
  }
10144
10354
  const targetInput = isRecord(input.target) ? input.target : {};
10145
10355
  const checks = Array.isArray(input.checks) ? input.checks.map(normalizeCheck) : [];
10146
10356
  if (!checks.length) throw new Error("profile.checks must contain at least one check.");
10147
- const targetUrl = stringValue2(options.url) || stringValue2(targetInput.url);
10148
- const route = stringValue2(options.route) || stringValue2(targetInput.route);
10357
+ const targetUrl = stringValue3(options.url) || stringValue3(targetInput.url);
10358
+ const route = stringValue3(options.route) || stringValue3(targetInput.route);
10149
10359
  if (!targetUrl && !route) throw new Error("profile.target requires url or route, or pass --url.");
10150
10360
  return {
10151
10361
  version: RIDDLE_PROOF_PROFILE_VERSION,
@@ -10154,17 +10364,17 @@ function normalizeRiddleProofProfile(input, options = {}) {
10154
10364
  url: targetUrl,
10155
10365
  route,
10156
10366
  viewports: options.viewports?.length ? options.viewports : normalizeViewports(targetInput.viewports),
10157
- auth: stringValue2(targetInput.auth) || "none",
10367
+ auth: stringValue3(targetInput.auth) || "none",
10158
10368
  timeout_sec: timeoutSecValue(targetInput.timeout_sec) ?? timeoutSecValue(targetInput.timeoutSec) ?? timeoutSecValue(targetInput.riddle_timeout_sec) ?? timeoutSecValue(targetInput.riddleTimeoutSec),
10159
- wait_for_selector: stringValue2(targetInput.wait_for_selector) || stringValue2(targetInput.waitForSelector),
10160
- wait_ms: numberValue(targetInput.wait_ms) ?? numberValue(targetInput.waitMs),
10369
+ wait_for_selector: stringValue3(targetInput.wait_for_selector) || stringValue3(targetInput.waitForSelector),
10370
+ wait_ms: numberValue2(targetInput.wait_ms) ?? numberValue2(targetInput.waitMs),
10161
10371
  screenshot_full_page: normalizeTargetScreenshotFullPage(targetInput),
10162
10372
  setup_actions: normalizeSetupActions(targetInput.setup_actions ?? targetInput.setupActions),
10163
10373
  network_mocks: normalizeNetworkMocks(targetInput.network_mocks ?? targetInput.networkMocks)
10164
10374
  },
10165
10375
  checks,
10166
10376
  artifacts: Array.isArray(input.artifacts) ? input.artifacts.map((item) => String(item)).filter(Boolean) : ["screenshot", "console", "dom_summary", "proof_json"],
10167
- baseline_policy: stringValue2(input.baseline_policy) || stringValue2(input.baselinePolicy) || "invariant_only",
10377
+ baseline_policy: stringValue3(input.baseline_policy) || stringValue3(input.baselinePolicy) || "invariant_only",
10168
10378
  failure_policy: normalizeFailurePolicy(input.failure_policy || input.failurePolicy),
10169
10379
  metadata: jsonRecord(input.metadata)
10170
10380
  };
@@ -10243,8 +10453,8 @@ function httpStatusIsAllowed(status, check) {
10243
10453
  return allowed?.length ? allowed.includes(status) : status >= 200 && status < 400;
10244
10454
  }
10245
10455
  function linkStatusObservedBytes(result) {
10246
- const bytes = numberValue(result.bytes);
10247
- const contentLength = numberValue(result.content_length);
10456
+ const bytes = numberValue2(result.bytes);
10457
+ const contentLength = numberValue2(result.content_length);
10248
10458
  return Math.max(bytes ?? 0, contentLength ?? 0) || void 0;
10249
10459
  }
10250
10460
  function normalizeLinkStatusContentType(value) {
@@ -10261,7 +10471,7 @@ function linkStatusContentTypesMatch(actual, expected) {
10261
10471
  function linkStatusContentTypeOk(result, check) {
10262
10472
  const expected = check.allowed_content_types;
10263
10473
  if (!expected?.length) return true;
10264
- const actual = normalizeLinkStatusContentType(stringValue2(result.content_type));
10474
+ const actual = normalizeLinkStatusContentType(stringValue3(result.content_type));
10265
10475
  if (!actual) return false;
10266
10476
  return expected.some((contentType) => {
10267
10477
  const normalized = normalizeLinkStatusContentType(contentType);
@@ -10301,28 +10511,28 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
10301
10511
  }));
10302
10512
  }
10303
10513
  return result.body_json_assertions.filter((assertion) => isRecord(assertion) && assertion.ok !== true).map((assertion) => ({
10304
- label: stringValue2(assertion.label) || stringValue2(assertion.path) || "json assertion",
10305
- path: stringValue2(assertion.path) || "",
10514
+ label: stringValue3(assertion.label) || stringValue3(assertion.path) || "json assertion",
10515
+ path: stringValue3(assertion.path) || "",
10306
10516
  ok: false,
10307
10517
  exists: assertion.exists === true,
10308
10518
  observed: hasOwn(assertion, "observed") ? toJsonValue(assertion.observed) : void 0,
10309
10519
  observed_sample: hasOwn(assertion, "observed_sample") ? toJsonValue(assertion.observed_sample) : void 0,
10310
- observed_length: numberValue(assertion.observed_length),
10311
- observed_key_count: numberValue(assertion.observed_key_count),
10312
- observed_omitted_count: numberValue(assertion.observed_omitted_count),
10313
- observed_type: stringValue2(assertion.observed_type) || "missing",
10314
- expected_exists: booleanValue(assertion.expected_exists),
10520
+ observed_length: numberValue2(assertion.observed_length),
10521
+ observed_key_count: numberValue2(assertion.observed_key_count),
10522
+ observed_omitted_count: numberValue2(assertion.observed_omitted_count),
10523
+ observed_type: stringValue3(assertion.observed_type) || "missing",
10524
+ expected_exists: booleanValue2(assertion.expected_exists),
10315
10525
  equals: hasOwn(assertion, "equals") ? toJsonValue(assertion.equals) : void 0,
10316
10526
  not_equals: hasOwn(assertion, "not_equals") ? toJsonValue(assertion.not_equals) : void 0,
10317
10527
  contains: hasOwn(assertion, "contains") ? toJsonValue(assertion.contains) : void 0,
10318
- type: stringValue2(assertion.type),
10528
+ type: stringValue3(assertion.type),
10319
10529
  errors: Array.isArray(assertion.errors) ? assertion.errors.map(String) : void 0
10320
10530
  }));
10321
10531
  }
10322
10532
  function linkStatusResultOk(result, check) {
10323
- const status = numberValue(result.status);
10533
+ const status = numberValue2(result.status);
10324
10534
  if (!httpStatusIsAllowed(status, check)) return false;
10325
- if (stringValue2(result.error)) return false;
10535
+ if (stringValue3(result.error)) return false;
10326
10536
  if (result.ok === false) return false;
10327
10537
  if (!linkStatusContentTypeOk(result, check)) return false;
10328
10538
  if (check.require_nonzero_bytes) {
@@ -10437,12 +10647,12 @@ async function preflightHttpStatusCheck(check, index, targetUrl, fetchImpl) {
10437
10647
  url,
10438
10648
  method,
10439
10649
  ok,
10440
- status: numberValue(result.status) ?? null,
10650
+ status: numberValue2(result.status) ?? null,
10441
10651
  status_text: statusText,
10442
10652
  error,
10443
- content_type: stringValue2(result.content_type) ?? null,
10444
- content_length: numberValue(result.content_length) ?? null,
10445
- bytes: numberValue(result.bytes) ?? null,
10653
+ content_type: stringValue3(result.content_type) ?? null,
10654
+ content_length: numberValue2(result.content_length) ?? null,
10655
+ bytes: numberValue2(result.bytes) ?? null,
10446
10656
  body_contains: isRecord(result.body_contains) ? Object.fromEntries(Object.entries(result.body_contains).map(([key, value]) => [key, value === true])) : null,
10447
10657
  body_contains_missing: bodyContainsMissing,
10448
10658
  body_not_contains: isRecord(result.body_not_contains) ? Object.fromEntries(Object.entries(result.body_not_contains).map(([key, value]) => [key, value === true])) : null,
@@ -10499,11 +10709,11 @@ function summarizeHttpStatusEvidence(viewport, check) {
10499
10709
  if (!linkStatusResultOk(statusEvidence, check)) {
10500
10710
  failures.push({
10501
10711
  code: "http_status_failed",
10502
- url: stringValue2(statusEvidence.url) ?? httpStatusRequestUrl(check, viewport.url),
10503
- status: numberValue(statusEvidence.status) ?? null,
10504
- method: stringValue2(statusEvidence.method) ?? httpStatusMethod(check),
10505
- error: stringValue2(statusEvidence.error) ?? null,
10506
- content_type: stringValue2(statusEvidence.content_type) ?? null,
10712
+ url: stringValue3(statusEvidence.url) ?? httpStatusRequestUrl(check, viewport.url),
10713
+ status: numberValue2(statusEvidence.status) ?? null,
10714
+ method: stringValue3(statusEvidence.method) ?? httpStatusMethod(check),
10715
+ error: stringValue3(statusEvidence.error) ?? null,
10716
+ content_type: stringValue3(statusEvidence.content_type) ?? null,
10507
10717
  bytes: linkStatusObservedBytes(statusEvidence) ?? null,
10508
10718
  allowed_statuses: httpStatusAllowedStatuses(check) ?? ["2xx", "3xx"],
10509
10719
  min_bytes: check.min_bytes ?? null,
@@ -10516,20 +10726,20 @@ function summarizeHttpStatusEvidence(viewport, check) {
10516
10726
  body_not_patterns_found: bodyNotPatternsFound,
10517
10727
  body_json_assertions: check.body_json_assertions ?? null,
10518
10728
  body_json_assertions_failed: bodyJsonAssertionsFailed.map((assertion) => toJsonValue(assertion)),
10519
- body_sample: stringValue2(statusEvidence.body_sample) ?? null
10729
+ body_sample: stringValue3(statusEvidence.body_sample) ?? null
10520
10730
  });
10521
10731
  }
10522
10732
  return {
10523
10733
  viewport: viewport.name,
10524
10734
  key,
10525
- url: stringValue2(statusEvidence.url) ?? httpStatusRequestUrl(check, viewport.url),
10526
- method: stringValue2(statusEvidence.method) ?? httpStatusMethod(check),
10527
- status: numberValue(statusEvidence.status) ?? null,
10528
- status_text: stringValue2(statusEvidence.status_text) ?? null,
10735
+ url: stringValue3(statusEvidence.url) ?? httpStatusRequestUrl(check, viewport.url),
10736
+ method: stringValue3(statusEvidence.method) ?? httpStatusMethod(check),
10737
+ status: numberValue2(statusEvidence.status) ?? null,
10738
+ status_text: stringValue3(statusEvidence.status_text) ?? null,
10529
10739
  ok: failures.length === 0,
10530
- error: stringValue2(statusEvidence.error) ?? null,
10531
- content_type: stringValue2(statusEvidence.content_type) ?? null,
10532
- content_length: numberValue(statusEvidence.content_length) ?? null,
10740
+ error: stringValue3(statusEvidence.error) ?? null,
10741
+ content_type: stringValue3(statusEvidence.content_type) ?? null,
10742
+ content_length: numberValue2(statusEvidence.content_length) ?? null,
10533
10743
  bytes: linkStatusObservedBytes(statusEvidence) ?? null,
10534
10744
  body_contains: isRecord(statusEvidence.body_contains) ? toJsonValue(statusEvidence.body_contains) : null,
10535
10745
  body_contains_missing: bodyContainsMissing,
@@ -10539,7 +10749,7 @@ function summarizeHttpStatusEvidence(viewport, check) {
10539
10749
  body_not_patterns_found: bodyNotPatternsFound,
10540
10750
  body_json_assertions: Array.isArray(statusEvidence.body_json_assertions) ? toJsonValue(statusEvidence.body_json_assertions) : null,
10541
10751
  body_json_assertions_failed: bodyJsonAssertionsFailed.map((assertion) => toJsonValue(assertion)),
10542
- body_sample: stringValue2(statusEvidence.body_sample) ?? null,
10752
+ body_sample: stringValue3(statusEvidence.body_sample) ?? null,
10543
10753
  failures
10544
10754
  };
10545
10755
  }
@@ -10560,27 +10770,27 @@ function summarizeLinkStatusEvidence(viewport, check) {
10560
10770
  };
10561
10771
  }
10562
10772
  const results = Array.isArray(linkEvidence.results) ? linkEvidence.results.filter(isRecord) : [];
10563
- const totalCount = numberValue(linkEvidence.total_count) ?? results.length;
10564
- const resultCount = numberValue(linkEvidence.result_count) ?? totalCount;
10565
- const storedResultCount = numberValue(linkEvidence.stored_result_count) ?? results.length;
10566
- const omittedResultCount = numberValue(linkEvidence.omitted_result_count) ?? Math.max(0, resultCount - storedResultCount);
10567
- const omittedSuccessCount = numberValue(linkEvidence.omitted_success_count) ?? 0;
10773
+ const totalCount = numberValue2(linkEvidence.total_count) ?? results.length;
10774
+ const resultCount = numberValue2(linkEvidence.result_count) ?? totalCount;
10775
+ const storedResultCount = numberValue2(linkEvidence.stored_result_count) ?? results.length;
10776
+ const omittedResultCount = numberValue2(linkEvidence.omitted_result_count) ?? Math.max(0, resultCount - storedResultCount);
10777
+ const omittedSuccessCount = numberValue2(linkEvidence.omitted_success_count) ?? 0;
10568
10778
  const okCount = results.filter((result) => linkStatusResultOk(result, check)).length;
10569
10779
  const failures = results.filter((result) => !linkStatusResultOk(result, check)).map((result) => ({
10570
10780
  code: "link_status_failed",
10571
- url: stringValue2(result.url) ?? null,
10572
- status: numberValue(result.status) ?? null,
10573
- method: stringValue2(result.method) ?? null,
10574
- error: stringValue2(result.error) ?? null,
10575
- content_type: stringValue2(result.content_type) ?? null,
10781
+ url: stringValue3(result.url) ?? null,
10782
+ status: numberValue2(result.status) ?? null,
10783
+ method: stringValue3(result.method) ?? null,
10784
+ error: stringValue3(result.error) ?? null,
10785
+ content_type: stringValue3(result.content_type) ?? null,
10576
10786
  bytes: linkStatusObservedBytes(result) ?? null,
10577
10787
  min_bytes: check.min_bytes ?? null,
10578
10788
  allowed_content_types: check.allowed_content_types ?? null
10579
10789
  }));
10580
- if (stringValue2(linkEvidence.error)) {
10581
- failures.push({ code: "link_status_capture_failed", error: stringValue2(linkEvidence.error) ?? "" });
10790
+ if (stringValue3(linkEvidence.error)) {
10791
+ failures.push({ code: "link_status_capture_failed", error: stringValue3(linkEvidence.error) ?? "" });
10582
10792
  }
10583
- const recordedFailedCount = numberValue(linkEvidence.failed_count) ?? 0;
10793
+ const recordedFailedCount = numberValue2(linkEvidence.failed_count) ?? 0;
10584
10794
  if (!failures.length && recordedFailedCount > 0) {
10585
10795
  const recordedFailures = Array.isArray(linkEvidence.failures) ? linkEvidence.failures.slice(0, 20) : [];
10586
10796
  failures.push({
@@ -10592,8 +10802,8 @@ function summarizeLinkStatusEvidence(viewport, check) {
10592
10802
  if (linkEvidence.truncated === true) {
10593
10803
  failures.push({
10594
10804
  code: "link_status_probe_truncated",
10595
- discovered_count: numberValue(linkEvidence.discovered_count) ?? totalCount,
10596
- max_links: numberValue(linkEvidence.max_links) ?? check.max_links ?? 100
10805
+ discovered_count: numberValue2(linkEvidence.discovered_count) ?? totalCount,
10806
+ max_links: numberValue2(linkEvidence.max_links) ?? check.max_links ?? 100
10597
10807
  });
10598
10808
  }
10599
10809
  if (check.expected_count !== void 0 && totalCount !== check.expected_count) {
@@ -10607,11 +10817,11 @@ function summarizeLinkStatusEvidence(viewport, check) {
10607
10817
  viewport: viewport.name,
10608
10818
  selector: linkStatusSelector(check),
10609
10819
  total_count: totalCount,
10610
- discovered_count: numberValue(linkEvidence.discovered_count) ?? totalCount,
10611
- ok_count: numberValue(linkEvidence.ok_count) ?? okCount,
10820
+ discovered_count: numberValue2(linkEvidence.discovered_count) ?? totalCount,
10821
+ ok_count: numberValue2(linkEvidence.ok_count) ?? okCount,
10612
10822
  failed_count: failures.length,
10613
10823
  truncated: linkEvidence.truncated === true,
10614
- max_links: numberValue(linkEvidence.max_links) ?? check.max_links ?? 100,
10824
+ max_links: numberValue2(linkEvidence.max_links) ?? check.max_links ?? 100,
10615
10825
  result_count: resultCount,
10616
10826
  stored_result_count: storedResultCount,
10617
10827
  omitted_result_count: omittedResultCount,
@@ -10686,13 +10896,13 @@ function frameTextSample(frame) {
10686
10896
  function summarizeRouteInventory(viewport, inventory) {
10687
10897
  const directRoutes = Array.isArray(inventory.direct_routes) ? inventory.direct_routes : [];
10688
10898
  const clickthroughs = Array.isArray(inventory.clickthroughs) ? inventory.clickthroughs : [];
10689
- const sourceLinkCount = numberValue(inventory.source_link_count) ?? numberValue(inventory.home_game_link_count) ?? null;
10690
- const sourceUniqueLinkCount = numberValue(inventory.source_unique_link_count) ?? numberValue(inventory.home_unique_game_link_count) ?? null;
10691
- const sourceCandidateCount = numberValue(inventory.source_candidate_count);
10692
- const sourceCandidateUniqueLinkCount = numberValue(inventory.source_candidate_unique_link_count);
10693
- const sourceLinkScope = stringValue2(inventory.source_link_scope);
10899
+ const sourceLinkCount = numberValue2(inventory.source_link_count) ?? numberValue2(inventory.home_game_link_count) ?? null;
10900
+ const sourceUniqueLinkCount = numberValue2(inventory.source_unique_link_count) ?? numberValue2(inventory.home_unique_game_link_count) ?? null;
10901
+ const sourceCandidateCount = numberValue2(inventory.source_candidate_count);
10902
+ const sourceCandidateUniqueLinkCount = numberValue2(inventory.source_candidate_unique_link_count);
10903
+ const sourceLinkScope = stringValue3(inventory.source_link_scope);
10694
10904
  const duplicateSourceLinks = Array.isArray(inventory.duplicate_source_link_paths) ? inventory.duplicate_source_link_paths.map((path7) => String(path7)) : [];
10695
- const duplicateSourceLinkCount = numberValue(inventory.duplicate_source_link_count) ?? (sourceLinkCount !== null && sourceUniqueLinkCount !== null ? Math.max(0, sourceLinkCount - sourceUniqueLinkCount) : null);
10905
+ const duplicateSourceLinkCount = numberValue2(inventory.duplicate_source_link_count) ?? (sourceLinkCount !== null && sourceUniqueLinkCount !== null ? Math.max(0, sourceLinkCount - sourceUniqueLinkCount) : null);
10696
10906
  const failures = Array.isArray(inventory.failures) ? inventory.failures : [];
10697
10907
  return {
10698
10908
  viewport,
@@ -10716,9 +10926,9 @@ function routeInventoryExpectedRouteSummaries(value, fallback) {
10716
10926
  return path8 ? { path: path8 } : void 0;
10717
10927
  }
10718
10928
  if (!isRecord(route)) return void 0;
10719
- const path7 = stringValue2(route.path);
10929
+ const path7 = stringValue3(route.path);
10720
10930
  if (!path7) return void 0;
10721
- const name = stringValue2(route.name);
10931
+ const name = stringValue3(route.name);
10722
10932
  return name ? { name, path: path7 } : { path: path7 };
10723
10933
  }).filter((route) => Boolean(route));
10724
10934
  }
@@ -10819,15 +11029,15 @@ function matchesAllowedMessage(input, texts, patterns) {
10819
11029
  }
10820
11030
  function consoleEventLocationUrl(input) {
10821
11031
  if (!isRecord(input) || !isRecord(input.location)) return void 0;
10822
- return stringValue2(input.location.url);
11032
+ return stringValue3(input.location.url);
10823
11033
  }
10824
11034
  function expectedFailedNetworkMockEvents(evidence) {
10825
11035
  return (evidence.network_mocks || []).filter((event) => {
10826
11036
  if (!isRecord(event) || event.ok === false) return false;
10827
- const status = numberValue(event.status);
11037
+ const status = numberValue2(event.status);
10828
11038
  const isHttpFailure = status !== void 0 && status >= 400;
10829
- const isAbortedMock = event.abort === true && Boolean(stringValue2(event.abort_error_code));
10830
- return (isHttpFailure || isAbortedMock) && Boolean(stringValue2(event.url));
11039
+ const isAbortedMock = event.abort === true && Boolean(stringValue3(event.abort_error_code));
11040
+ return (isHttpFailure || isAbortedMock) && Boolean(stringValue3(event.url));
10831
11041
  });
10832
11042
  }
10833
11043
  function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
@@ -10836,9 +11046,9 @@ function matchingExpectedFailedNetworkMockConsoleEvent(event, evidence) {
10836
11046
  const eventUrl = consoleEventLocationUrl(event);
10837
11047
  if (!eventUrl) return void 0;
10838
11048
  return expectedFailedNetworkMockEvents(evidence).find((mockEvent) => {
10839
- const status = numberValue(mockEvent.status);
10840
- const abortErrorCode = stringValue2(mockEvent.abort_error_code);
10841
- return stringValue2(mockEvent.url) === eventUrl && (status !== void 0 && sample.includes(String(status)) || Boolean(abortErrorCode) && /Failed to load resource/i.test(sample));
11049
+ const status = numberValue2(mockEvent.status);
11050
+ const abortErrorCode = stringValue3(mockEvent.abort_error_code);
11051
+ return stringValue3(mockEvent.url) === eventUrl && (status !== void 0 && sample.includes(String(status)) || Boolean(abortErrorCode) && /Failed to load resource/i.test(sample));
10842
11052
  });
10843
11053
  }
10844
11054
  function isExpectedFailedNetworkMockConsoleEvent(event, evidence) {
@@ -10849,10 +11059,10 @@ function expectedFailedNetworkMockConsoleEventSummary(event, evidence) {
10849
11059
  const sample = allowedMessageSample(event);
10850
11060
  return {
10851
11061
  url: consoleEventLocationUrl(event) ?? null,
10852
- status: match ? numberValue(match.status) ?? null : null,
10853
- abort_error_code: match ? stringValue2(match.abort_error_code) ?? null : null,
10854
- label: match ? stringValue2(match.label) ?? null : null,
10855
- response_label: match ? stringValue2(match.response_label) ?? null : null,
11062
+ status: match ? numberValue2(match.status) ?? null : null,
11063
+ abort_error_code: match ? stringValue3(match.abort_error_code) ?? null : null,
11064
+ label: match ? stringValue3(match.label) ?? null : null,
11065
+ response_label: match ? stringValue3(match.response_label) ?? null : null,
10856
11066
  text: isRecord(event) && typeof event.text === "string" ? event.text.slice(0, 300) : sample.slice(0, 300)
10857
11067
  };
10858
11068
  }
@@ -10980,7 +11190,7 @@ function assessCheckFromEvidence(check, evidence) {
10980
11190
  if (isDialogCountCheckType(check.type)) {
10981
11191
  const field = dialogCountFieldForCheckType(check.type);
10982
11192
  const expectedCount = check.expected_count ?? 0;
10983
- const actualCount = numberValue(evidence.dom_summary?.[field]) ?? 0;
11193
+ const actualCount = numberValue2(evidence.dom_summary?.[field]) ?? 0;
10984
11194
  return {
10985
11195
  type: check.type,
10986
11196
  label: checkLabel(check),
@@ -11181,14 +11391,14 @@ function assessCheckFromEvidence(check, evidence) {
11181
11391
  return {
11182
11392
  viewport: viewport.name,
11183
11393
  matched,
11184
- elapsed_ms: numberValue(observation?.elapsed_ms) ?? null,
11185
- timeout_ms: numberValue(observation?.timeout_ms) ?? timeoutMs,
11186
- attempts: numberValue(observation?.attempts) ?? null,
11187
- selector_count: numberValue(observation?.selector_count) ?? null,
11188
- visible_count: numberValue(observation?.visible_count) ?? null,
11189
- matched_count: numberValue(observation?.matched_count) ?? null,
11190
- sample: stringValue2(observation?.sample) ?? null,
11191
- error: stringValue2(observation?.error) ?? null
11394
+ elapsed_ms: numberValue2(observation?.elapsed_ms) ?? null,
11395
+ timeout_ms: numberValue2(observation?.timeout_ms) ?? timeoutMs,
11396
+ attempts: numberValue2(observation?.attempts) ?? null,
11397
+ selector_count: numberValue2(observation?.selector_count) ?? null,
11398
+ visible_count: numberValue2(observation?.visible_count) ?? null,
11399
+ matched_count: numberValue2(observation?.matched_count) ?? null,
11400
+ sample: stringValue3(observation?.sample) ?? null,
11401
+ error: stringValue3(observation?.error) ?? null
11192
11402
  };
11193
11403
  });
11194
11404
  const failed = results.filter((result) => !result.matched).length;
@@ -11346,7 +11556,7 @@ function assessCheckFromEvidence(check, evidence) {
11346
11556
  body_not_patterns: check.body_not_patterns ?? [],
11347
11557
  body_json_assertions: toJsonValue(check.body_json_assertions ?? []),
11348
11558
  viewports: summaries.map((summary) => toJsonValue(summary)),
11349
- failures: failed.flatMap((summary) => Array.isArray(summary.failures) ? summary.failures.map((failure) => toJsonValue({ viewport: stringValue2(summary.viewport) ?? null, failure })) : [])
11559
+ failures: failed.flatMap((summary) => Array.isArray(summary.failures) ? summary.failures.map((failure) => toJsonValue({ viewport: stringValue3(summary.viewport) ?? null, failure })) : [])
11350
11560
  },
11351
11561
  message: failed.length ? `HTTP status failed in ${failed.length} viewport(s).` : void 0
11352
11562
  };
@@ -11354,7 +11564,7 @@ function assessCheckFromEvidence(check, evidence) {
11354
11564
  if (check.type === "link_status" || check.type === "artifact_link_status") {
11355
11565
  const selector = linkStatusSelector(check);
11356
11566
  const summaries = viewports.map((viewport) => summarizeLinkStatusEvidence(viewport, check));
11357
- const failed = summaries.filter((summary) => (numberValue(summary.failed_count) ?? 0) > 0);
11567
+ const failed = summaries.filter((summary) => (numberValue2(summary.failed_count) ?? 0) > 0);
11358
11568
  return {
11359
11569
  type: check.type,
11360
11570
  label: checkLabel(check),
@@ -11368,7 +11578,7 @@ function assessCheckFromEvidence(check, evidence) {
11368
11578
  min_bytes: check.min_bytes ?? null,
11369
11579
  allowed_content_types: check.allowed_content_types ?? null,
11370
11580
  viewports: summaries.map((summary) => toJsonValue(summary)),
11371
- failures: failed.flatMap((summary) => Array.isArray(summary.failures) ? summary.failures.map((failure) => toJsonValue({ viewport: stringValue2(summary.viewport) ?? null, failure })) : [])
11581
+ failures: failed.flatMap((summary) => Array.isArray(summary.failures) ? summary.failures.map((failure) => toJsonValue({ viewport: stringValue3(summary.viewport) ?? null, failure })) : [])
11372
11582
  },
11373
11583
  message: failed.length ? `Link status failed in ${failed.length} viewport(s).` : void 0
11374
11584
  };
@@ -11392,13 +11602,13 @@ function assessCheckFromEvidence(check, evidence) {
11392
11602
  const first = inventories[0]?.inventory;
11393
11603
  const directRoutes = Array.isArray(first?.direct_routes) ? first.direct_routes : [];
11394
11604
  const clickthroughs = Array.isArray(first?.clickthroughs) ? first.clickthroughs : [];
11395
- const sourceLinkCount = numberValue(first?.source_link_count) ?? numberValue(first?.home_game_link_count) ?? null;
11396
- const sourceUniqueLinkCount = numberValue(first?.source_unique_link_count) ?? numberValue(first?.home_unique_game_link_count) ?? null;
11397
- const sourceCandidateCount = numberValue(first?.source_candidate_count);
11398
- const sourceCandidateUniqueLinkCount = numberValue(first?.source_candidate_unique_link_count);
11399
- const sourceLinkScope = stringValue2(first?.source_link_scope);
11605
+ const sourceLinkCount = numberValue2(first?.source_link_count) ?? numberValue2(first?.home_game_link_count) ?? null;
11606
+ const sourceUniqueLinkCount = numberValue2(first?.source_unique_link_count) ?? numberValue2(first?.home_unique_game_link_count) ?? null;
11607
+ const sourceCandidateCount = numberValue2(first?.source_candidate_count);
11608
+ const sourceCandidateUniqueLinkCount = numberValue2(first?.source_candidate_unique_link_count);
11609
+ const sourceLinkScope = stringValue3(first?.source_link_scope);
11400
11610
  const duplicateSourceLinks = Array.isArray(first?.duplicate_source_link_paths) ? first.duplicate_source_link_paths.map((path7) => String(path7)) : [];
11401
- const duplicateSourceLinkCount = numberValue(first?.duplicate_source_link_count) ?? (sourceLinkCount !== null && sourceUniqueLinkCount !== null ? Math.max(0, sourceLinkCount - sourceUniqueLinkCount) : null);
11611
+ const duplicateSourceLinkCount = numberValue2(first?.duplicate_source_link_count) ?? (sourceLinkCount !== null && sourceUniqueLinkCount !== null ? Math.max(0, sourceLinkCount - sourceUniqueLinkCount) : null);
11402
11612
  const expectedRoutes = routeInventoryExpectedRouteSummaries(first?.expected_routes, check.expected_routes);
11403
11613
  return {
11404
11614
  type: check.type,
@@ -11415,8 +11625,8 @@ function assessCheckFromEvidence(check, evidence) {
11415
11625
  duplicate_source_link_count: duplicateSourceLinkCount,
11416
11626
  duplicate_source_links: duplicateSourceLinks,
11417
11627
  duplicates_allowed: check.require_unique_routes === false,
11418
- homepage_link_count: numberValue(first?.home_game_link_count) ?? sourceLinkCount,
11419
- homepage_unique_link_count: numberValue(first?.home_unique_game_link_count) ?? sourceUniqueLinkCount,
11628
+ homepage_link_count: numberValue2(first?.home_game_link_count) ?? sourceLinkCount,
11629
+ homepage_unique_link_count: numberValue2(first?.home_unique_game_link_count) ?? sourceUniqueLinkCount,
11420
11630
  direct_route_count: directRoutes.length,
11421
11631
  clickthrough_count: clickthroughs.length,
11422
11632
  viewport_count: inventories.length,
@@ -17635,9 +17845,9 @@ function collectRiddleProfileArtifactRefs(input) {
17635
17845
  const priorities = /* @__PURE__ */ new Map();
17636
17846
  function add(item, source) {
17637
17847
  if (!isRecord(item)) return;
17638
- const url = stringValue2(item.url);
17639
- const path7 = stringValue2(item.path);
17640
- const rawName = stringValue2(item.name) || stringValue2(item.filename) || artifactNameFromPath(url || path7) || "";
17848
+ const url = stringValue3(item.url);
17849
+ const path7 = stringValue3(item.path);
17850
+ const rawName = stringValue3(item.name) || stringValue3(item.filename) || artifactNameFromPath(url || path7) || "";
17641
17851
  const name = normalizeRiddleProfileArtifactName(rawName);
17642
17852
  if (!name && !url && !path7) return;
17643
17853
  const key = profileArtifactDedupeKey(name, url || path7 || "");
@@ -17646,8 +17856,8 @@ function collectRiddleProfileArtifactRefs(input) {
17646
17856
  name,
17647
17857
  url,
17648
17858
  path: path7,
17649
- kind: stringValue2(item.kind) || stringValue2(item.type),
17650
- content_type: stringValue2(item.content_type) || stringValue2(item.contentType),
17859
+ kind: stringValue3(item.kind) || stringValue3(item.type),
17860
+ content_type: stringValue3(item.content_type) || stringValue3(item.contentType),
17651
17861
  source
17652
17862
  };
17653
17863
  const existingIndex = indexes.get(key);
@@ -17721,158 +17931,6 @@ function extractRiddleProofProfileResult(input) {
17721
17931
  return void 0;
17722
17932
  }
17723
17933
 
17724
- // src/public-state.ts
17725
- function asRecord(value) {
17726
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
17727
- }
17728
- function stringValue3(value) {
17729
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
17730
- }
17731
- function booleanValue2(value) {
17732
- return typeof value === "boolean" ? value : void 0;
17733
- }
17734
- function numberValue2(value) {
17735
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
17736
- }
17737
- function firstStringValue(...values) {
17738
- for (const value of values) {
17739
- const text = stringValue3(value);
17740
- if (text) return text;
17741
- }
17742
- return void 0;
17743
- }
17744
- function firstBooleanValue(...values) {
17745
- for (const value of values) {
17746
- const bool = booleanValue2(value);
17747
- if (typeof bool === "boolean") return bool;
17748
- }
17749
- return void 0;
17750
- }
17751
- function firstRecordValue(...values) {
17752
- for (const value of values) {
17753
- const record = asRecord(value);
17754
- if (Object.keys(record).length) return record;
17755
- }
17756
- return void 0;
17757
- }
17758
- function countValue(value) {
17759
- const number = numberValue2(value);
17760
- return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
17761
- }
17762
- function checkpointSummaryFrom(...values) {
17763
- const record = firstRecordValue(...values);
17764
- if (!record) return void 0;
17765
- const accepted = countValue(record.response_count);
17766
- const rejected = countValue(record.rejected_response_count);
17767
- const ignored = countValue(record.ignored_response_count);
17768
- const duplicate = countValue(record.duplicate_response_count);
17769
- const summary = {
17770
- pending: booleanValue2(record.pending),
17771
- accepted_response_count: accepted,
17772
- rejected_response_count: rejected,
17773
- ignored_response_count: ignored,
17774
- duplicate_response_count: duplicate,
17775
- latest_decision: stringValue3(record.latest_decision),
17776
- audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
17777
- };
17778
- return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
17779
- }
17780
- function uniqueStrings(values) {
17781
- return [...new Set(values.filter(Boolean))];
17782
- }
17783
- function summarizeRiddleProofPublicState(input) {
17784
- const record = asRecord(input);
17785
- const runCard = asRecord(record.run_card);
17786
- const stopCondition = asRecord(runCard.stop_condition);
17787
- const raw = asRecord(record.raw);
17788
- const request = asRecord(record.request);
17789
- const requestMetadata = asRecord(record.request_metadata);
17790
- const prState = asRecord(record.pr_state);
17791
- const handoff = asRecord(record.pr_handoff_policy);
17792
- const handoffState = stringValue3(handoff.state);
17793
- const status = firstStringValue(record.status, stopCondition.status);
17794
- const ok = booleanValue2(record.ok) ?? null;
17795
- const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
17796
- const explicitShippingDisabled = firstBooleanValue(
17797
- record.shipping_disabled,
17798
- stopCondition.shipping_disabled,
17799
- raw.shipping_disabled,
17800
- handoff.shipping_disabled
17801
- );
17802
- const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
17803
- const explicitShipAuthorized = firstBooleanValue(
17804
- record.ship_authorized,
17805
- stopCondition.ship_authorized,
17806
- raw.ship_authorized
17807
- );
17808
- const authorizationEvidence = Boolean(
17809
- status === "shipped" || record.marked_ready === true || stringValue3(prState.status) === "merged" || record.merge_commit || record.merged_at
17810
- );
17811
- const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
17812
- const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
17813
- const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
17814
- const shipHeld = explicitShipHeld === true || inferredHeld;
17815
- const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
17816
- const proofComplete = Boolean(
17817
- status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
17818
- );
17819
- const checkpointSummary = checkpointSummaryFrom(
17820
- record.checkpoint_summary,
17821
- stopCondition.checkpoint_summary,
17822
- asRecord(record.details).checkpoint_summary,
17823
- asRecord(raw.details).checkpoint_summary
17824
- );
17825
- const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
17826
- const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
17827
- const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
17828
- const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
17829
- const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
17830
- const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
17831
- const syncAllowed = mergeReady;
17832
- let policyState = "unknown";
17833
- if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
17834
- else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
17835
- else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
17836
- else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
17837
- else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
17838
- else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
17839
- else if (shipAuthorized) policyState = "ship_authorized";
17840
- else if (proofPassed) policyState = "proof_passed";
17841
- else if (status === "running") policyState = "proof_in_progress";
17842
- const requiredDisclosures = [];
17843
- if (shipHeld) requiredDisclosures.push("ship_held");
17844
- if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
17845
- if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
17846
- if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
17847
- const prohibitedClaims = [];
17848
- if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
17849
- if (!mergeReady) prohibitedClaims.push("merge_ready");
17850
- if (!syncAllowed) prohibitedClaims.push("sync_allowed");
17851
- if (blockedOrWaiting) {
17852
- prohibitedClaims.push("proof_passed", "ready_to_ship");
17853
- }
17854
- if (checkpointSummary?.audit_disclosure_required) {
17855
- prohibitedClaims.push("all_checkpoint_responses_accepted");
17856
- }
17857
- const resultLabel2 = policyState === "awaiting_checkpoint" ? "checkpoint required" : policyState === "proof_blocked" ? "blocked" : policyState === "proof_failed" ? "failed" : policyState === "proof_complete_ship_disabled" ? "proof complete; shipping disabled" : policyState === "proof_passed_ship_held" ? "proof passed; ship held" : policyState === "ship_authorized" ? status === "shipped" ? "shipped" : "ship authorized" : policyState === "proof_passed" ? "passed" : policyState === "proof_in_progress" ? "running" : status || "recorded";
17858
- return {
17859
- status,
17860
- ok,
17861
- policy_state: policyState,
17862
- result_label: resultLabel2,
17863
- proof_complete: proofComplete,
17864
- proof_passed: proofPassed,
17865
- ship_held: shipHeld,
17866
- shipping_disabled: shippingDisabled,
17867
- ship_authorized: shipAuthorized,
17868
- merge_ready: mergeReady,
17869
- sync_allowed: syncAllowed,
17870
- checkpoint_summary: checkpointSummary,
17871
- required_disclosures: uniqueStrings(requiredDisclosures),
17872
- prohibited_claims: uniqueStrings(prohibitedClaims)
17873
- };
17874
- }
17875
-
17876
17934
  // src/pr-comment.ts
17877
17935
  var RIDDLE_PROOF_PR_COMMENT_MARKER = "<!-- riddle-proof:pr-comment:v1 -->";
17878
17936
  function asRecord2(value) {
@@ -18037,6 +18095,8 @@ function summarizeRiddleProofPrComment(input) {
18037
18095
  ship_held: publicState.ship_held,
18038
18096
  shipping_disabled: publicState.shipping_disabled,
18039
18097
  ship_authorized: publicState.ship_authorized,
18098
+ merge_ready: publicState.merge_ready,
18099
+ sync_allowed: publicState.sync_allowed,
18040
18100
  proof_decision: firstStringValue2(result.proof_decision, stopCondition.proof_decision, resultRaw.proof_decision),
18041
18101
  merge_recommendation: firstStringValue2(result.merge_recommendation, stopCondition.merge_recommendation, resultRaw.merge_recommendation),
18042
18102
  checkpoint_summary: checkpointSummary,
@@ -18086,6 +18146,13 @@ function formatBool(value) {
18086
18146
  function hasShipControl(summary) {
18087
18147
  return typeof summary.ship_held === "boolean" || typeof summary.shipping_disabled === "boolean" || typeof summary.ship_authorized === "boolean";
18088
18148
  }
18149
+ function hasHandoffControl(summary) {
18150
+ return typeof summary.merge_ready === "boolean" || typeof summary.sync_allowed === "boolean";
18151
+ }
18152
+ function shouldRenderMergeRecommendation(summary) {
18153
+ if (!summary.merge_recommendation) return false;
18154
+ return riddleProofPublicStateAllowsMergeRecommendation(summary.public_state);
18155
+ }
18089
18156
  function checkpointSummaryLine(summary) {
18090
18157
  const accepted = summary.response_count ?? 0;
18091
18158
  const rejected = summary.rejected_response_count ?? 0;
@@ -18117,8 +18184,11 @@ function buildRiddleProofPrCommentMarkdown(input) {
18117
18184
  if (hasShipControl(summary)) {
18118
18185
  lines.push(`**Ship control:** held=${formatBool(summary.ship_held)}, shipping_disabled=${formatBool(summary.shipping_disabled)}, authorized=${formatBool(summary.ship_authorized)}`);
18119
18186
  }
18187
+ if (hasHandoffControl(summary)) {
18188
+ lines.push(`**Handoff:** merge_ready=${formatBool(summary.merge_ready)}, sync_allowed=${formatBool(summary.sync_allowed)}`);
18189
+ }
18120
18190
  if (summary.proof_decision) lines.push(`**Proof decision:** \`${summary.proof_decision}\``);
18121
- if (summary.merge_recommendation) lines.push(`**Merge recommendation:** ${summary.merge_recommendation}`);
18191
+ if (shouldRenderMergeRecommendation(summary)) lines.push(`**Merge recommendation:** ${summary.merge_recommendation}`);
18122
18192
  if (summary.checkpoint_summary) lines.push(`**Checkpoints:** ${checkpointSummaryLine(summary.checkpoint_summary)}`);
18123
18193
  if (summary.proof_url) lines.push(`**Proof URL:** ${markdownLink(summary.proof_url, summary.proof_url)}`);
18124
18194
  if (summary.preview_id || summary.preview_url) {