@riddledc/riddle-proof 0.7.193 → 0.7.195

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.
package/dist/cli.cjs CHANGED
@@ -16524,11 +16524,47 @@ function profileResultHasArtifact(result) {
16524
16524
  function profileReceiptSignalStatus(hasSignal, presentReason, missingReason) {
16525
16525
  return hasSignal ? { status: "present", reason: presentReason } : { status: "missing", reason: missingReason };
16526
16526
  }
16527
+ function profileViewportNameList(viewports) {
16528
+ const names = [...new Set(viewports.map((viewport) => cliString(viewport.name) || cliString(viewport.viewport)).filter((name) => Boolean(name)))];
16529
+ if (!names.length) return "unnamed";
16530
+ const shown = names.slice(0, 6).join(", ");
16531
+ return names.length > 6 ? `${shown}, +${names.length - 6} more` : shown;
16532
+ }
16533
+ function profileEveryRouteViewportStatus(result, setupSummary, setupViewports, evidenceViewports) {
16534
+ const evidenceViewportRecords = evidenceViewports.map(cliRecord).filter((viewport) => Boolean(viewport));
16535
+ const domSummary = cliRecord(result.evidence?.dom_summary);
16536
+ const expectedViewportCount = cliFiniteNumber(domSummary?.expected_viewport_count) ?? cliFiniteNumber(setupSummary?.viewport_count) ?? cliFiniteNumber(domSummary?.viewport_count) ?? Math.max(evidenceViewportRecords.length, setupViewports.length);
16537
+ const evidenceWithRoute = evidenceViewportRecords.filter((viewport) => Boolean(cliRecord(viewport.route)) || Boolean(result.route) && Boolean(cliString(viewport.screenshot_label)));
16538
+ const setupOkCount = setupViewports.filter((viewport) => viewport.ok !== false).length;
16539
+ const setupComplete = !setupViewports.length || setupOkCount >= expectedViewportCount;
16540
+ if (expectedViewportCount > 0 && evidenceWithRoute.length >= expectedViewportCount && setupComplete) {
16541
+ return {
16542
+ status: "present",
16543
+ reason: `route/setup evidence present for all ${expectedViewportCount} viewport(s): ${profileViewportNameList(evidenceWithRoute)}`
16544
+ };
16545
+ }
16546
+ const setupPart = setupViewports.length ? `, setup ok ${setupOkCount}/${expectedViewportCount}` : "";
16547
+ return {
16548
+ status: "missing",
16549
+ reason: `route/viewport evidence incomplete: expected ${expectedViewportCount}, route evidence ${evidenceWithRoute.length}${setupPart}`
16550
+ };
16551
+ }
16527
16552
  function compactProfileReceiptReason(value, limit = 180) {
16528
16553
  const text = cliString(value)?.replace(/\s+/g, " ").trim();
16529
16554
  if (!text) return void 0;
16530
16555
  return text.length <= limit ? text : `${text.slice(0, Math.max(0, limit - 3)).trimEnd()}...`;
16531
16556
  }
16557
+ function profileCleanupInventoryHaystack(receipt) {
16558
+ const returnStoredTo = cliString(receipt.return_stored_to) || "";
16559
+ const reason = cliString(receipt.reason) || "";
16560
+ const error = cliString(receipt.error) || "";
16561
+ const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
16562
+ return `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
16563
+ }
16564
+ function profileIsCleanupInventoryReceipt(receipt) {
16565
+ const haystack = profileCleanupInventoryHaystack(receipt);
16566
+ return haystack.includes("cleanup") || haystack.includes("post-cleanup") || haystack.includes("stale") || haystack.includes("statehygiene") || haystack.includes("state hygiene") || haystack.includes("remained after") || haystack.includes("still present");
16567
+ }
16532
16568
  function profileFailedCleanupInventoryReason(setupViewports) {
16533
16569
  const receipts = setupViewports.flatMap((viewport) => [
16534
16570
  ...setupReceiptArray(viewport, "window_eval"),
@@ -16536,17 +16572,28 @@ function profileFailedCleanupInventoryReason(setupViewports) {
16536
16572
  ]);
16537
16573
  for (const receipt of receipts) {
16538
16574
  if (receipt.ok !== false) continue;
16539
- const returnStoredTo = cliString(receipt.return_stored_to) || "";
16540
- const reason = cliString(receipt.reason) || "";
16541
- const error = cliString(receipt.error) || "";
16542
- const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
16543
- const haystack = `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
16544
- const isCleanupReceipt = haystack.includes("cleanup") || haystack.includes("post-cleanup") || haystack.includes("stale") || haystack.includes("statehygiene") || haystack.includes("state hygiene") || haystack.includes("remained after") || haystack.includes("still present");
16545
- if (!isCleanupReceipt) continue;
16575
+ if (!profileIsCleanupInventoryReceipt(receipt)) continue;
16576
+ const error = cliString(receipt.error);
16577
+ const reason = cliString(receipt.reason);
16546
16578
  return compactProfileReceiptReason(error) || compactProfileReceiptReason(reason) || "cleanup inventory failed";
16547
16579
  }
16548
16580
  return void 0;
16549
16581
  }
16582
+ function profilePassedCleanupInventoryReason(setupViewports) {
16583
+ const receipts = setupViewports.flatMap((viewport) => [
16584
+ ...setupReceiptArray(viewport, "window_eval"),
16585
+ ...setupReceiptArray(viewport, "window_call")
16586
+ ]);
16587
+ for (const receipt of receipts) {
16588
+ if (receipt.ok === false || !profileIsCleanupInventoryReceipt(receipt)) continue;
16589
+ if (setupReturnSummaryValue(receipt, ["ok"]) === false) continue;
16590
+ const staleCount = cliFiniteNumber(setupReturnSummaryValue(receipt, ["staleCount"]));
16591
+ const staleNames = setupReturnSummaryValue(receipt, ["staleNames"]);
16592
+ if (staleCount !== 0 || !Array.isArray(staleNames) || staleNames.length !== 0) continue;
16593
+ return "staleCount=0, staleNames=[]";
16594
+ }
16595
+ return void 0;
16596
+ }
16550
16597
  function profileHasRouteExitAffordanceReceipt(receipts) {
16551
16598
  const affordanceFields = [
16552
16599
  "navVisibleBeforeExit",
@@ -16740,6 +16787,7 @@ function profilePackReceiptStatus(result, metadata, receipt) {
16740
16787
  const hasRouteContinuationReceipt = profileHasRouteContinuationReceipt(valueReceipts);
16741
16788
  const hasRecoveredStateReceipt = profileHasRecoveredStateReceipt(valueReceipts);
16742
16789
  const failedCleanupInventoryReason = profileFailedCleanupInventoryReason(setupViewports);
16790
+ const passedCleanupInventoryReason = profilePassedCleanupInventoryReason(setupViewports);
16743
16791
  if (text.includes("artifact link") || text.includes("artifact path")) {
16744
16792
  return profileReceiptSignalStatus(profileResultHasArtifact(result), "artifact references listed", "no artifact references found");
16745
16793
  }
@@ -16749,6 +16797,9 @@ function profilePackReceiptStatus(result, metadata, receipt) {
16749
16797
  return profileReceiptSignalStatus(hasConsoleAccounting, "console checks or evidence present", "console accounting evidence missing");
16750
16798
  }
16751
16799
  if (text.includes("route") && text.includes("viewport")) {
16800
+ if (text.includes("every target viewport") || text.includes("all target viewport") || text.includes("every") && text.includes("viewport")) {
16801
+ return profileEveryRouteViewportStatus(result, setupSummary, setupViewports, evidenceViewports);
16802
+ }
16752
16803
  return profileReceiptSignalStatus(hasRouteViewport, "route and viewport evidence present", "route or viewport evidence missing");
16753
16804
  }
16754
16805
  if (text.includes("setup action")) {
@@ -16765,9 +16816,13 @@ function profilePackReceiptStatus(result, metadata, receipt) {
16765
16816
  return profileReceiptSignalStatus(hasStateContract, "state contract metadata or receipts present", "state contract evidence missing");
16766
16817
  }
16767
16818
  if (text.includes("stale") || text.includes("absence")) {
16768
- if (failedCleanupInventoryReason && (text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state"))) {
16819
+ const expectsCleanupInventory = text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state") || text.includes("inventory");
16820
+ if (failedCleanupInventoryReason && expectsCleanupInventory) {
16769
16821
  return { status: "failed", reason: `cleanup inventory failed: ${failedCleanupInventoryReason}` };
16770
16822
  }
16823
+ if (passedCleanupInventoryReason && expectsCleanupInventory) {
16824
+ return { status: "present", reason: `cleanup inventory passed: ${passedCleanupInventoryReason}` };
16825
+ }
16771
16826
  return profileReceiptSignalStatus(hasTextAbsence, "absence check passed", "absence check missing");
16772
16827
  }
16773
16828
  if (text.includes("recovered") || text.includes("final state")) {
package/dist/cli.js CHANGED
@@ -616,11 +616,47 @@ function profileResultHasArtifact(result) {
616
616
  function profileReceiptSignalStatus(hasSignal, presentReason, missingReason) {
617
617
  return hasSignal ? { status: "present", reason: presentReason } : { status: "missing", reason: missingReason };
618
618
  }
619
+ function profileViewportNameList(viewports) {
620
+ const names = [...new Set(viewports.map((viewport) => cliString(viewport.name) || cliString(viewport.viewport)).filter((name) => Boolean(name)))];
621
+ if (!names.length) return "unnamed";
622
+ const shown = names.slice(0, 6).join(", ");
623
+ return names.length > 6 ? `${shown}, +${names.length - 6} more` : shown;
624
+ }
625
+ function profileEveryRouteViewportStatus(result, setupSummary, setupViewports, evidenceViewports) {
626
+ const evidenceViewportRecords = evidenceViewports.map(cliRecord).filter((viewport) => Boolean(viewport));
627
+ const domSummary = cliRecord(result.evidence?.dom_summary);
628
+ const expectedViewportCount = cliFiniteNumber(domSummary?.expected_viewport_count) ?? cliFiniteNumber(setupSummary?.viewport_count) ?? cliFiniteNumber(domSummary?.viewport_count) ?? Math.max(evidenceViewportRecords.length, setupViewports.length);
629
+ const evidenceWithRoute = evidenceViewportRecords.filter((viewport) => Boolean(cliRecord(viewport.route)) || Boolean(result.route) && Boolean(cliString(viewport.screenshot_label)));
630
+ const setupOkCount = setupViewports.filter((viewport) => viewport.ok !== false).length;
631
+ const setupComplete = !setupViewports.length || setupOkCount >= expectedViewportCount;
632
+ if (expectedViewportCount > 0 && evidenceWithRoute.length >= expectedViewportCount && setupComplete) {
633
+ return {
634
+ status: "present",
635
+ reason: `route/setup evidence present for all ${expectedViewportCount} viewport(s): ${profileViewportNameList(evidenceWithRoute)}`
636
+ };
637
+ }
638
+ const setupPart = setupViewports.length ? `, setup ok ${setupOkCount}/${expectedViewportCount}` : "";
639
+ return {
640
+ status: "missing",
641
+ reason: `route/viewport evidence incomplete: expected ${expectedViewportCount}, route evidence ${evidenceWithRoute.length}${setupPart}`
642
+ };
643
+ }
619
644
  function compactProfileReceiptReason(value, limit = 180) {
620
645
  const text = cliString(value)?.replace(/\s+/g, " ").trim();
621
646
  if (!text) return void 0;
622
647
  return text.length <= limit ? text : `${text.slice(0, Math.max(0, limit - 3)).trimEnd()}...`;
623
648
  }
649
+ function profileCleanupInventoryHaystack(receipt) {
650
+ const returnStoredTo = cliString(receipt.return_stored_to) || "";
651
+ const reason = cliString(receipt.reason) || "";
652
+ const error = cliString(receipt.error) || "";
653
+ const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
654
+ return `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
655
+ }
656
+ function profileIsCleanupInventoryReceipt(receipt) {
657
+ const haystack = profileCleanupInventoryHaystack(receipt);
658
+ return haystack.includes("cleanup") || haystack.includes("post-cleanup") || haystack.includes("stale") || haystack.includes("statehygiene") || haystack.includes("state hygiene") || haystack.includes("remained after") || haystack.includes("still present");
659
+ }
624
660
  function profileFailedCleanupInventoryReason(setupViewports) {
625
661
  const receipts = setupViewports.flatMap((viewport) => [
626
662
  ...setupReceiptArray(viewport, "window_eval"),
@@ -628,17 +664,28 @@ function profileFailedCleanupInventoryReason(setupViewports) {
628
664
  ]);
629
665
  for (const receipt of receipts) {
630
666
  if (receipt.ok !== false) continue;
631
- const returnStoredTo = cliString(receipt.return_stored_to) || "";
632
- const reason = cliString(receipt.reason) || "";
633
- const error = cliString(receipt.error) || "";
634
- const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
635
- const haystack = `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
636
- const isCleanupReceipt = haystack.includes("cleanup") || haystack.includes("post-cleanup") || haystack.includes("stale") || haystack.includes("statehygiene") || haystack.includes("state hygiene") || haystack.includes("remained after") || haystack.includes("still present");
637
- if (!isCleanupReceipt) continue;
667
+ if (!profileIsCleanupInventoryReceipt(receipt)) continue;
668
+ const error = cliString(receipt.error);
669
+ const reason = cliString(receipt.reason);
638
670
  return compactProfileReceiptReason(error) || compactProfileReceiptReason(reason) || "cleanup inventory failed";
639
671
  }
640
672
  return void 0;
641
673
  }
674
+ function profilePassedCleanupInventoryReason(setupViewports) {
675
+ const receipts = setupViewports.flatMap((viewport) => [
676
+ ...setupReceiptArray(viewport, "window_eval"),
677
+ ...setupReceiptArray(viewport, "window_call")
678
+ ]);
679
+ for (const receipt of receipts) {
680
+ if (receipt.ok === false || !profileIsCleanupInventoryReceipt(receipt)) continue;
681
+ if (setupReturnSummaryValue(receipt, ["ok"]) === false) continue;
682
+ const staleCount = cliFiniteNumber(setupReturnSummaryValue(receipt, ["staleCount"]));
683
+ const staleNames = setupReturnSummaryValue(receipt, ["staleNames"]);
684
+ if (staleCount !== 0 || !Array.isArray(staleNames) || staleNames.length !== 0) continue;
685
+ return "staleCount=0, staleNames=[]";
686
+ }
687
+ return void 0;
688
+ }
642
689
  function profileHasRouteExitAffordanceReceipt(receipts) {
643
690
  const affordanceFields = [
644
691
  "navVisibleBeforeExit",
@@ -832,6 +879,7 @@ function profilePackReceiptStatus(result, metadata, receipt) {
832
879
  const hasRouteContinuationReceipt = profileHasRouteContinuationReceipt(valueReceipts);
833
880
  const hasRecoveredStateReceipt = profileHasRecoveredStateReceipt(valueReceipts);
834
881
  const failedCleanupInventoryReason = profileFailedCleanupInventoryReason(setupViewports);
882
+ const passedCleanupInventoryReason = profilePassedCleanupInventoryReason(setupViewports);
835
883
  if (text.includes("artifact link") || text.includes("artifact path")) {
836
884
  return profileReceiptSignalStatus(profileResultHasArtifact(result), "artifact references listed", "no artifact references found");
837
885
  }
@@ -841,6 +889,9 @@ function profilePackReceiptStatus(result, metadata, receipt) {
841
889
  return profileReceiptSignalStatus(hasConsoleAccounting, "console checks or evidence present", "console accounting evidence missing");
842
890
  }
843
891
  if (text.includes("route") && text.includes("viewport")) {
892
+ if (text.includes("every target viewport") || text.includes("all target viewport") || text.includes("every") && text.includes("viewport")) {
893
+ return profileEveryRouteViewportStatus(result, setupSummary, setupViewports, evidenceViewports);
894
+ }
844
895
  return profileReceiptSignalStatus(hasRouteViewport, "route and viewport evidence present", "route or viewport evidence missing");
845
896
  }
846
897
  if (text.includes("setup action")) {
@@ -857,9 +908,13 @@ function profilePackReceiptStatus(result, metadata, receipt) {
857
908
  return profileReceiptSignalStatus(hasStateContract, "state contract metadata or receipts present", "state contract evidence missing");
858
909
  }
859
910
  if (text.includes("stale") || text.includes("absence")) {
860
- if (failedCleanupInventoryReason && (text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state"))) {
911
+ const expectsCleanupInventory = text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state") || text.includes("inventory");
912
+ if (failedCleanupInventoryReason && expectsCleanupInventory) {
861
913
  return { status: "failed", reason: `cleanup inventory failed: ${failedCleanupInventoryReason}` };
862
914
  }
915
+ if (passedCleanupInventoryReason && expectsCleanupInventory) {
916
+ return { status: "present", reason: `cleanup inventory passed: ${passedCleanupInventoryReason}` };
917
+ }
863
918
  return profileReceiptSignalStatus(hasTextAbsence, "absence check passed", "absence check missing");
864
919
  }
865
920
  if (text.includes("recovered") || text.includes("final state")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.193",
3
+ "version": "0.7.195",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",