@riddledc/riddle-proof 0.7.192 → 0.7.194

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 (3) hide show
  1. package/dist/cli.cjs +88 -11
  2. package/dist/cli.js +88 -11
  3. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -15956,7 +15956,7 @@ function usage() {
15956
15956
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
15957
15957
  " riddle-proof-loop respond --state-path <path> --decision <decision> --summary <text> [--payload-json <file|json|->]",
15958
15958
  " riddle-proof-loop status --state-path <path>",
15959
- " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false; default false] [--split-viewports true|false; default false] [--poll-attempts n] [--output <dir>|--output-dir <dir>] [--result-format json|summary|none; default json] [--quiet]",
15959
+ " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false; default false] [--split-viewports true|false; default false] [--poll-attempts n] [--output <dir>|--output-dir <dir>] [--result-format json|compact-json|summary|none; default json] [--quiet]",
15960
15960
  " riddle-proof-loop profile-body-assertions --artifact <file|url|-> --candidates-json <file|json|-> [--required-json <file|json|->] [--format json|body-contains]",
15961
15961
  " riddle-proof-loop profile-http-status-preflight --profile <file|json|-> --url <base-url> [--format json|summary]",
15962
15962
  " riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static]",
@@ -16035,8 +16035,53 @@ function profileOutputDirOption(options) {
16035
16035
  }
16036
16036
  function runProfileResultFormatOption(options) {
16037
16037
  const format = optionString(options, "resultFormat") ?? "json";
16038
- if (format === "json" || format === "summary" || format === "none") return format;
16039
- throw new Error("--result-format must be json, summary, or none.");
16038
+ if (format === "compact") return "compact-json";
16039
+ if (format === "json" || format === "compact-json" || format === "summary" || format === "none") return format;
16040
+ throw new Error("--result-format must be json, compact-json, summary, or none.");
16041
+ }
16042
+ function compactProfileCheckCounts(result) {
16043
+ return result.checks.reduce((counts, check) => {
16044
+ const status = String(check.status || "unknown");
16045
+ counts[status] = (counts[status] || 0) + 1;
16046
+ counts.total = (counts.total || 0) + 1;
16047
+ return counts;
16048
+ }, { total: 0 });
16049
+ }
16050
+ function compactProfileChecks(result) {
16051
+ return result.checks.map((check) => ({
16052
+ type: check.type,
16053
+ label: check.label,
16054
+ status: check.status,
16055
+ message: check.message
16056
+ }));
16057
+ }
16058
+ function compactRunProfileResult(result, options) {
16059
+ const outputDir = profileOutputDirOption(options);
16060
+ return {
16061
+ version: "riddle-proof.profile-compact-result.v1",
16062
+ profile_name: result.profile_name,
16063
+ runner: result.runner,
16064
+ status: result.status,
16065
+ summary: result.summary,
16066
+ captured_at: result.captured_at,
16067
+ baseline_policy: result.baseline_policy,
16068
+ route: result.route,
16069
+ check_counts: compactProfileCheckCounts(result),
16070
+ checks: compactProfileChecks(result),
16071
+ warnings: result.warnings,
16072
+ environment_blocker: result.environment_blocker,
16073
+ metadata: result.metadata,
16074
+ riddle: result.riddle,
16075
+ artifacts: result.artifacts,
16076
+ output_dir: outputDir,
16077
+ output_files: outputDir ? {
16078
+ profile_result: "profile-result.json",
16079
+ summary: "summary.md",
16080
+ proof_json: result.evidence ? "proof.json" : void 0,
16081
+ console: result.evidence?.console ? "console.json" : void 0,
16082
+ dom_summary: result.evidence?.dom_summary ? "dom-summary.json" : void 0
16083
+ } : void 0
16084
+ };
16040
16085
  }
16041
16086
  function writeRunProfileResult(result, options) {
16042
16087
  const format = runProfileResultFormatOption(options);
@@ -16045,6 +16090,11 @@ function writeRunProfileResult(result, options) {
16045
16090
  process.stdout.write(profileResultMarkdown(result));
16046
16091
  return;
16047
16092
  }
16093
+ if (format === "compact-json") {
16094
+ process.stdout.write(`${JSON.stringify(compactRunProfileResult(result, options), null, 2)}
16095
+ `);
16096
+ return;
16097
+ }
16048
16098
  process.stdout.write(`${JSON.stringify(result, null, 2)}
16049
16099
  `);
16050
16100
  }
@@ -16479,6 +16529,17 @@ function compactProfileReceiptReason(value, limit = 180) {
16479
16529
  if (!text) return void 0;
16480
16530
  return text.length <= limit ? text : `${text.slice(0, Math.max(0, limit - 3)).trimEnd()}...`;
16481
16531
  }
16532
+ function profileCleanupInventoryHaystack(receipt) {
16533
+ const returnStoredTo = cliString(receipt.return_stored_to) || "";
16534
+ const reason = cliString(receipt.reason) || "";
16535
+ const error = cliString(receipt.error) || "";
16536
+ const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
16537
+ return `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
16538
+ }
16539
+ function profileIsCleanupInventoryReceipt(receipt) {
16540
+ const haystack = profileCleanupInventoryHaystack(receipt);
16541
+ 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");
16542
+ }
16482
16543
  function profileFailedCleanupInventoryReason(setupViewports) {
16483
16544
  const receipts = setupViewports.flatMap((viewport) => [
16484
16545
  ...setupReceiptArray(viewport, "window_eval"),
@@ -16486,17 +16547,28 @@ function profileFailedCleanupInventoryReason(setupViewports) {
16486
16547
  ]);
16487
16548
  for (const receipt of receipts) {
16488
16549
  if (receipt.ok !== false) continue;
16489
- const returnStoredTo = cliString(receipt.return_stored_to) || "";
16490
- const reason = cliString(receipt.reason) || "";
16491
- const error = cliString(receipt.error) || "";
16492
- const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
16493
- const haystack = `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
16494
- 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");
16495
- if (!isCleanupReceipt) continue;
16550
+ if (!profileIsCleanupInventoryReceipt(receipt)) continue;
16551
+ const error = cliString(receipt.error);
16552
+ const reason = cliString(receipt.reason);
16496
16553
  return compactProfileReceiptReason(error) || compactProfileReceiptReason(reason) || "cleanup inventory failed";
16497
16554
  }
16498
16555
  return void 0;
16499
16556
  }
16557
+ function profilePassedCleanupInventoryReason(setupViewports) {
16558
+ const receipts = setupViewports.flatMap((viewport) => [
16559
+ ...setupReceiptArray(viewport, "window_eval"),
16560
+ ...setupReceiptArray(viewport, "window_call")
16561
+ ]);
16562
+ for (const receipt of receipts) {
16563
+ if (receipt.ok === false || !profileIsCleanupInventoryReceipt(receipt)) continue;
16564
+ if (setupReturnSummaryValue(receipt, ["ok"]) === false) continue;
16565
+ const staleCount = cliFiniteNumber(setupReturnSummaryValue(receipt, ["staleCount"]));
16566
+ const staleNames = setupReturnSummaryValue(receipt, ["staleNames"]);
16567
+ if (staleCount !== 0 || !Array.isArray(staleNames) || staleNames.length !== 0) continue;
16568
+ return "staleCount=0, staleNames=[]";
16569
+ }
16570
+ return void 0;
16571
+ }
16500
16572
  function profileHasRouteExitAffordanceReceipt(receipts) {
16501
16573
  const affordanceFields = [
16502
16574
  "navVisibleBeforeExit",
@@ -16690,6 +16762,7 @@ function profilePackReceiptStatus(result, metadata, receipt) {
16690
16762
  const hasRouteContinuationReceipt = profileHasRouteContinuationReceipt(valueReceipts);
16691
16763
  const hasRecoveredStateReceipt = profileHasRecoveredStateReceipt(valueReceipts);
16692
16764
  const failedCleanupInventoryReason = profileFailedCleanupInventoryReason(setupViewports);
16765
+ const passedCleanupInventoryReason = profilePassedCleanupInventoryReason(setupViewports);
16693
16766
  if (text.includes("artifact link") || text.includes("artifact path")) {
16694
16767
  return profileReceiptSignalStatus(profileResultHasArtifact(result), "artifact references listed", "no artifact references found");
16695
16768
  }
@@ -16715,9 +16788,13 @@ function profilePackReceiptStatus(result, metadata, receipt) {
16715
16788
  return profileReceiptSignalStatus(hasStateContract, "state contract metadata or receipts present", "state contract evidence missing");
16716
16789
  }
16717
16790
  if (text.includes("stale") || text.includes("absence")) {
16718
- if (failedCleanupInventoryReason && (text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state"))) {
16791
+ const expectsCleanupInventory = text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state") || text.includes("inventory");
16792
+ if (failedCleanupInventoryReason && expectsCleanupInventory) {
16719
16793
  return { status: "failed", reason: `cleanup inventory failed: ${failedCleanupInventoryReason}` };
16720
16794
  }
16795
+ if (passedCleanupInventoryReason && expectsCleanupInventory) {
16796
+ return { status: "present", reason: `cleanup inventory passed: ${passedCleanupInventoryReason}` };
16797
+ }
16721
16798
  return profileReceiptSignalStatus(hasTextAbsence, "absence check passed", "absence check missing");
16722
16799
  }
16723
16800
  if (text.includes("recovered") || text.includes("final state")) {
package/dist/cli.js CHANGED
@@ -48,7 +48,7 @@ function usage() {
48
48
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
49
49
  " riddle-proof-loop respond --state-path <path> --decision <decision> --summary <text> [--payload-json <file|json|->]",
50
50
  " riddle-proof-loop status --state-path <path>",
51
- " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false; default false] [--split-viewports true|false; default false] [--poll-attempts n] [--output <dir>|--output-dir <dir>] [--result-format json|summary|none; default json] [--quiet]",
51
+ " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false; default false] [--split-viewports true|false; default false] [--poll-attempts n] [--output <dir>|--output-dir <dir>] [--result-format json|compact-json|summary|none; default json] [--quiet]",
52
52
  " riddle-proof-loop profile-body-assertions --artifact <file|url|-> --candidates-json <file|json|-> [--required-json <file|json|->] [--format json|body-contains]",
53
53
  " riddle-proof-loop profile-http-status-preflight --profile <file|json|-> --url <base-url> [--format json|summary]",
54
54
  " riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static]",
@@ -127,8 +127,53 @@ function profileOutputDirOption(options) {
127
127
  }
128
128
  function runProfileResultFormatOption(options) {
129
129
  const format = optionString(options, "resultFormat") ?? "json";
130
- if (format === "json" || format === "summary" || format === "none") return format;
131
- throw new Error("--result-format must be json, summary, or none.");
130
+ if (format === "compact") return "compact-json";
131
+ if (format === "json" || format === "compact-json" || format === "summary" || format === "none") return format;
132
+ throw new Error("--result-format must be json, compact-json, summary, or none.");
133
+ }
134
+ function compactProfileCheckCounts(result) {
135
+ return result.checks.reduce((counts, check) => {
136
+ const status = String(check.status || "unknown");
137
+ counts[status] = (counts[status] || 0) + 1;
138
+ counts.total = (counts.total || 0) + 1;
139
+ return counts;
140
+ }, { total: 0 });
141
+ }
142
+ function compactProfileChecks(result) {
143
+ return result.checks.map((check) => ({
144
+ type: check.type,
145
+ label: check.label,
146
+ status: check.status,
147
+ message: check.message
148
+ }));
149
+ }
150
+ function compactRunProfileResult(result, options) {
151
+ const outputDir = profileOutputDirOption(options);
152
+ return {
153
+ version: "riddle-proof.profile-compact-result.v1",
154
+ profile_name: result.profile_name,
155
+ runner: result.runner,
156
+ status: result.status,
157
+ summary: result.summary,
158
+ captured_at: result.captured_at,
159
+ baseline_policy: result.baseline_policy,
160
+ route: result.route,
161
+ check_counts: compactProfileCheckCounts(result),
162
+ checks: compactProfileChecks(result),
163
+ warnings: result.warnings,
164
+ environment_blocker: result.environment_blocker,
165
+ metadata: result.metadata,
166
+ riddle: result.riddle,
167
+ artifacts: result.artifacts,
168
+ output_dir: outputDir,
169
+ output_files: outputDir ? {
170
+ profile_result: "profile-result.json",
171
+ summary: "summary.md",
172
+ proof_json: result.evidence ? "proof.json" : void 0,
173
+ console: result.evidence?.console ? "console.json" : void 0,
174
+ dom_summary: result.evidence?.dom_summary ? "dom-summary.json" : void 0
175
+ } : void 0
176
+ };
132
177
  }
133
178
  function writeRunProfileResult(result, options) {
134
179
  const format = runProfileResultFormatOption(options);
@@ -137,6 +182,11 @@ function writeRunProfileResult(result, options) {
137
182
  process.stdout.write(profileResultMarkdown(result));
138
183
  return;
139
184
  }
185
+ if (format === "compact-json") {
186
+ process.stdout.write(`${JSON.stringify(compactRunProfileResult(result, options), null, 2)}
187
+ `);
188
+ return;
189
+ }
140
190
  process.stdout.write(`${JSON.stringify(result, null, 2)}
141
191
  `);
142
192
  }
@@ -571,6 +621,17 @@ function compactProfileReceiptReason(value, limit = 180) {
571
621
  if (!text) return void 0;
572
622
  return text.length <= limit ? text : `${text.slice(0, Math.max(0, limit - 3)).trimEnd()}...`;
573
623
  }
624
+ function profileCleanupInventoryHaystack(receipt) {
625
+ const returnStoredTo = cliString(receipt.return_stored_to) || "";
626
+ const reason = cliString(receipt.reason) || "";
627
+ const error = cliString(receipt.error) || "";
628
+ const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
629
+ return `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
630
+ }
631
+ function profileIsCleanupInventoryReceipt(receipt) {
632
+ const haystack = profileCleanupInventoryHaystack(receipt);
633
+ 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");
634
+ }
574
635
  function profileFailedCleanupInventoryReason(setupViewports) {
575
636
  const receipts = setupViewports.flatMap((viewport) => [
576
637
  ...setupReceiptArray(viewport, "window_eval"),
@@ -578,17 +639,28 @@ function profileFailedCleanupInventoryReason(setupViewports) {
578
639
  ]);
579
640
  for (const receipt of receipts) {
580
641
  if (receipt.ok !== false) continue;
581
- const returnStoredTo = cliString(receipt.return_stored_to) || "";
582
- const reason = cliString(receipt.reason) || "";
583
- const error = cliString(receipt.error) || "";
584
- const summary = cliReturnSummaryLabel(receipt.return_summary) || "";
585
- const haystack = `${returnStoredTo} ${reason} ${error} ${summary}`.toLowerCase();
586
- 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");
587
- if (!isCleanupReceipt) continue;
642
+ if (!profileIsCleanupInventoryReceipt(receipt)) continue;
643
+ const error = cliString(receipt.error);
644
+ const reason = cliString(receipt.reason);
588
645
  return compactProfileReceiptReason(error) || compactProfileReceiptReason(reason) || "cleanup inventory failed";
589
646
  }
590
647
  return void 0;
591
648
  }
649
+ function profilePassedCleanupInventoryReason(setupViewports) {
650
+ const receipts = setupViewports.flatMap((viewport) => [
651
+ ...setupReceiptArray(viewport, "window_eval"),
652
+ ...setupReceiptArray(viewport, "window_call")
653
+ ]);
654
+ for (const receipt of receipts) {
655
+ if (receipt.ok === false || !profileIsCleanupInventoryReceipt(receipt)) continue;
656
+ if (setupReturnSummaryValue(receipt, ["ok"]) === false) continue;
657
+ const staleCount = cliFiniteNumber(setupReturnSummaryValue(receipt, ["staleCount"]));
658
+ const staleNames = setupReturnSummaryValue(receipt, ["staleNames"]);
659
+ if (staleCount !== 0 || !Array.isArray(staleNames) || staleNames.length !== 0) continue;
660
+ return "staleCount=0, staleNames=[]";
661
+ }
662
+ return void 0;
663
+ }
592
664
  function profileHasRouteExitAffordanceReceipt(receipts) {
593
665
  const affordanceFields = [
594
666
  "navVisibleBeforeExit",
@@ -782,6 +854,7 @@ function profilePackReceiptStatus(result, metadata, receipt) {
782
854
  const hasRouteContinuationReceipt = profileHasRouteContinuationReceipt(valueReceipts);
783
855
  const hasRecoveredStateReceipt = profileHasRecoveredStateReceipt(valueReceipts);
784
856
  const failedCleanupInventoryReason = profileFailedCleanupInventoryReason(setupViewports);
857
+ const passedCleanupInventoryReason = profilePassedCleanupInventoryReason(setupViewports);
785
858
  if (text.includes("artifact link") || text.includes("artifact path")) {
786
859
  return profileReceiptSignalStatus(profileResultHasArtifact(result), "artifact references listed", "no artifact references found");
787
860
  }
@@ -807,9 +880,13 @@ function profilePackReceiptStatus(result, metadata, receipt) {
807
880
  return profileReceiptSignalStatus(hasStateContract, "state contract metadata or receipts present", "state contract evidence missing");
808
881
  }
809
882
  if (text.includes("stale") || text.includes("absence")) {
810
- if (failedCleanupInventoryReason && (text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state"))) {
883
+ const expectsCleanupInventory = text.includes("cleanup") || text.includes("post-cleanup") || text.includes("stale-state") || text.includes("stale state") || text.includes("inventory");
884
+ if (failedCleanupInventoryReason && expectsCleanupInventory) {
811
885
  return { status: "failed", reason: `cleanup inventory failed: ${failedCleanupInventoryReason}` };
812
886
  }
887
+ if (passedCleanupInventoryReason && expectsCleanupInventory) {
888
+ return { status: "present", reason: `cleanup inventory passed: ${passedCleanupInventoryReason}` };
889
+ }
813
890
  return profileReceiptSignalStatus(hasTextAbsence, "absence check passed", "absence check missing");
814
891
  }
815
892
  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.192",
3
+ "version": "0.7.194",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",