@riddledc/riddle-proof 0.8.57 → 0.8.58

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/index.d.cts CHANGED
@@ -3,6 +3,7 @@ export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlSta
3
3
  export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from './state.cjs';
4
4
  export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from './checkpoint.cjs';
5
5
  export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from './run-card.cjs';
6
+ export { RiddleProofPublicCheckpointSummary, RiddleProofPublicPolicyState, RiddleProofPublicStateSummary, summarizeRiddleProofPublicState } from './public-state.cjs';
6
7
  export { R as RiddleProofRunnerAdapters, a as RunRiddleProofInput, r as runRiddleProof } from './runner-4LJ5z0D-.cjs';
7
8
  export { R as RiddleProofAgentAdapter, a as RiddleProofAgentPayload, b as RiddleProofCheckpointMode, c as RiddleProofEngine, d as RiddleProofEngineHarnessConfig, e as RiddleProofEngineHarnessContext, f as RiddleProofEngineResult, g as RiddleProofShipMode, h as RiddleProofWorkflowParams, i as RunRiddleProofEngineHarnessInput, j as createDisabledRiddleProofAgentAdapter, r as readRiddleProofRunStatus, k as runRiddleProofEngineHarness } from './engine-harness-LBfqbFSe.cjs';
8
9
  export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunner, CodexExecAgentConfig as LocalAgentConfig, CodexJsonRequest as LocalAgentJsonRequest, CodexJsonResult as LocalAgentJsonResult, CodexJsonRunner as LocalAgentJsonRunner, createCodexExecAgentAdapter, createCodexExecJsonRunner, createCodexExecAgentAdapter as createLocalAgentAdapter, createCodexExecJsonRunner as createLocalAgentJsonRunner, runCodexExecAgentDoctor, runCodexExecAgentDoctor as runLocalAgentDoctor } from './codex-exec-agent.cjs';
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlSta
3
3
  export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from './state.js';
4
4
  export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from './checkpoint.js';
5
5
  export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from './run-card.js';
6
+ export { RiddleProofPublicCheckpointSummary, RiddleProofPublicPolicyState, RiddleProofPublicStateSummary, summarizeRiddleProofPublicState } from './public-state.js';
6
7
  export { R as RiddleProofRunnerAdapters, a as RunRiddleProofInput, r as runRiddleProof } from './runner-BdQpOkZD.js';
7
8
  export { R as RiddleProofAgentAdapter, a as RiddleProofAgentPayload, b as RiddleProofCheckpointMode, c as RiddleProofEngine, d as RiddleProofEngineHarnessConfig, e as RiddleProofEngineHarnessContext, f as RiddleProofEngineResult, g as RiddleProofShipMode, h as RiddleProofWorkflowParams, i as RunRiddleProofEngineHarnessInput, j as createDisabledRiddleProofAgentAdapter, r as readRiddleProofRunStatus, k as runRiddleProofEngineHarness } from './engine-harness-CMACHP6A.js';
8
9
  export { CodexExecAgentConfig, CodexJsonRequest, CodexJsonResult, CodexJsonRunner, CodexExecAgentConfig as LocalAgentConfig, CodexJsonRequest as LocalAgentJsonRequest, CodexJsonResult as LocalAgentJsonResult, CodexJsonRunner as LocalAgentJsonRunner, createCodexExecAgentAdapter, createCodexExecJsonRunner, createCodexExecAgentAdapter as createLocalAgentAdapter, createCodexExecJsonRunner as createLocalAgentJsonRunner, runCodexExecAgentDoctor, runCodexExecAgentDoctor as runLocalAgentDoctor } from './codex-exec-agent.js';
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ import {
59
59
  RIDDLE_PROOF_PR_COMMENT_MARKER,
60
60
  buildRiddleProofPrCommentMarkdown,
61
61
  summarizeRiddleProofPrComment
62
- } from "./chunk-JR7GFTLS.js";
62
+ } from "./chunk-62XLYPMS.js";
63
63
  import {
64
64
  RIDDLE_PROOF_PROFILE_CHECK_TYPES,
65
65
  RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
@@ -88,6 +88,9 @@ import {
88
88
  slugifyRiddleProofProfileName,
89
89
  summarizeRiddleProofProfileResult
90
90
  } from "./chunk-EX7TO4I5.js";
91
+ import {
92
+ summarizeRiddleProofPublicState
93
+ } from "./chunk-KG64Y5MC.js";
91
94
  import {
92
95
  DEFAULT_DIAGNOSTIC_ARRAY_LIMIT,
93
96
  DEFAULT_DIAGNOSTIC_HISTORY_LIMIT,
@@ -286,6 +289,7 @@ export {
286
289
  summarizeCaptureArtifacts,
287
290
  summarizeRiddleProofPrComment,
288
291
  summarizeRiddleProofProfileResult,
292
+ summarizeRiddleProofPublicState,
289
293
  visualSessionFingerprint,
290
294
  visualSessionFingerprintBasis
291
295
  };
@@ -25,22 +25,20 @@ __export(pr_comment_exports, {
25
25
  summarizeRiddleProofPrComment: () => summarizeRiddleProofPrComment
26
26
  });
27
27
  module.exports = __toCommonJS(pr_comment_exports);
28
- var RIDDLE_PROOF_PR_COMMENT_MARKER = "<!-- riddle-proof:pr-comment:v1 -->";
28
+
29
+ // src/public-state.ts
29
30
  function asRecord(value) {
30
31
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
31
32
  }
32
- function asArray(value) {
33
- return Array.isArray(value) ? value : [];
34
- }
35
33
  function stringValue(value) {
36
34
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
37
35
  }
38
- function numberValue(value) {
39
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
40
- }
41
36
  function booleanValue(value) {
42
37
  return typeof value === "boolean" ? value : void 0;
43
38
  }
39
+ function numberValue(value) {
40
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
41
+ }
44
42
  function firstStringValue(...values) {
45
43
  for (const value of values) {
46
44
  const text = stringValue(value);
@@ -55,6 +53,155 @@ function firstBooleanValue(...values) {
55
53
  }
56
54
  return void 0;
57
55
  }
56
+ function firstRecordValue(...values) {
57
+ for (const value of values) {
58
+ const record = asRecord(value);
59
+ if (Object.keys(record).length) return record;
60
+ }
61
+ return void 0;
62
+ }
63
+ function countValue(value) {
64
+ const number = numberValue(value);
65
+ return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
66
+ }
67
+ function checkpointSummaryFrom(...values) {
68
+ const record = firstRecordValue(...values);
69
+ if (!record) return void 0;
70
+ const accepted = countValue(record.response_count);
71
+ const rejected = countValue(record.rejected_response_count);
72
+ const ignored = countValue(record.ignored_response_count);
73
+ const duplicate = countValue(record.duplicate_response_count);
74
+ const summary = {
75
+ pending: booleanValue(record.pending),
76
+ accepted_response_count: accepted,
77
+ rejected_response_count: rejected,
78
+ ignored_response_count: ignored,
79
+ duplicate_response_count: duplicate,
80
+ latest_decision: stringValue(record.latest_decision),
81
+ audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
82
+ };
83
+ return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
84
+ }
85
+ function uniqueStrings(values) {
86
+ return [...new Set(values.filter(Boolean))];
87
+ }
88
+ function summarizeRiddleProofPublicState(input) {
89
+ const record = asRecord(input);
90
+ const runCard = asRecord(record.run_card);
91
+ const stopCondition = asRecord(runCard.stop_condition);
92
+ const raw = asRecord(record.raw);
93
+ const request = asRecord(record.request);
94
+ const requestMetadata = asRecord(record.request_metadata);
95
+ const prState = asRecord(record.pr_state);
96
+ const handoff = asRecord(record.pr_handoff_policy);
97
+ const handoffState = stringValue(handoff.state);
98
+ const status = firstStringValue(record.status, stopCondition.status);
99
+ const ok = booleanValue(record.ok) ?? null;
100
+ const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
101
+ const explicitShippingDisabled = firstBooleanValue(
102
+ record.shipping_disabled,
103
+ stopCondition.shipping_disabled,
104
+ raw.shipping_disabled,
105
+ handoff.shipping_disabled
106
+ );
107
+ const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
108
+ const explicitShipAuthorized = firstBooleanValue(
109
+ record.ship_authorized,
110
+ stopCondition.ship_authorized,
111
+ raw.ship_authorized
112
+ );
113
+ const authorizationEvidence = Boolean(
114
+ status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
115
+ );
116
+ const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
117
+ const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
118
+ const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
119
+ const shipHeld = explicitShipHeld === true || inferredHeld;
120
+ const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
121
+ const proofComplete = Boolean(
122
+ status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
123
+ );
124
+ const checkpointSummary = checkpointSummaryFrom(
125
+ record.checkpoint_summary,
126
+ stopCondition.checkpoint_summary,
127
+ asRecord(record.details).checkpoint_summary,
128
+ asRecord(raw.details).checkpoint_summary
129
+ );
130
+ const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
131
+ const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
132
+ const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
133
+ const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
134
+ const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
135
+ const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
136
+ const syncAllowed = mergeReady;
137
+ let policyState = "unknown";
138
+ if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
139
+ else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
140
+ else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
141
+ else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
142
+ else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
143
+ else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
144
+ else if (shipAuthorized) policyState = "ship_authorized";
145
+ else if (proofPassed) policyState = "proof_passed";
146
+ else if (status === "running") policyState = "proof_in_progress";
147
+ const requiredDisclosures = [];
148
+ if (shipHeld) requiredDisclosures.push("ship_held");
149
+ if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
150
+ if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
151
+ if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
152
+ const prohibitedClaims = [];
153
+ if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
154
+ if (!mergeReady) prohibitedClaims.push("merge_ready");
155
+ if (!syncAllowed) prohibitedClaims.push("sync_allowed");
156
+ if (blockedOrWaiting) {
157
+ prohibitedClaims.push("proof_passed", "ready_to_ship");
158
+ }
159
+ if (checkpointSummary?.audit_disclosure_required) {
160
+ prohibitedClaims.push("all_checkpoint_responses_accepted");
161
+ }
162
+ 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";
163
+ return {
164
+ status,
165
+ ok,
166
+ policy_state: policyState,
167
+ result_label: resultLabel2,
168
+ proof_complete: proofComplete,
169
+ proof_passed: proofPassed,
170
+ ship_held: shipHeld,
171
+ shipping_disabled: shippingDisabled,
172
+ ship_authorized: shipAuthorized,
173
+ merge_ready: mergeReady,
174
+ sync_allowed: syncAllowed,
175
+ checkpoint_summary: checkpointSummary,
176
+ required_disclosures: uniqueStrings(requiredDisclosures),
177
+ prohibited_claims: uniqueStrings(prohibitedClaims)
178
+ };
179
+ }
180
+
181
+ // src/pr-comment.ts
182
+ var RIDDLE_PROOF_PR_COMMENT_MARKER = "<!-- riddle-proof:pr-comment:v1 -->";
183
+ function asRecord2(value) {
184
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
185
+ }
186
+ function asArray(value) {
187
+ return Array.isArray(value) ? value : [];
188
+ }
189
+ function stringValue2(value) {
190
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
191
+ }
192
+ function numberValue2(value) {
193
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
194
+ }
195
+ function booleanValue2(value) {
196
+ return typeof value === "boolean" ? value : void 0;
197
+ }
198
+ function firstStringValue2(...values) {
199
+ for (const value of values) {
200
+ const text = stringValue2(value);
201
+ if (text) return text;
202
+ }
203
+ return void 0;
204
+ }
58
205
  function artifactKind(name, url) {
59
206
  const target = `${name} ${url}`.toLowerCase();
60
207
  if (/\.(png|jpe?g|gif|webp|avif|svg)(\?|#|$)/.test(target)) return "image";
@@ -62,18 +209,18 @@ function artifactKind(name, url) {
62
209
  return "artifact";
63
210
  }
64
211
  function artifactDisplayName(value, fallback) {
65
- const raw = stringValue(value);
212
+ const raw = stringValue2(value);
66
213
  if (raw) return raw;
67
214
  return fallback;
68
215
  }
69
216
  function collectArtifacts(runResponse) {
70
- const proofResult = asRecord(runResponse.proofResult);
217
+ const proofResult = asRecord2(runResponse.proofResult);
71
218
  const outputs = asArray(proofResult.outputs);
72
219
  const artifacts = [];
73
220
  const seen = /* @__PURE__ */ new Set();
74
221
  for (const [index, item] of outputs.entries()) {
75
- const artifact = asRecord(item);
76
- const url = stringValue(artifact.url);
222
+ const artifact = asRecord2(item);
223
+ const url = stringValue2(artifact.url);
77
224
  if (!url || seen.has(url)) continue;
78
225
  seen.add(url);
79
226
  const name = artifactDisplayName(artifact.name, `artifact-${index + 1}`);
@@ -81,7 +228,7 @@ function collectArtifacts(runResponse) {
81
228
  name,
82
229
  url,
83
230
  kind: artifactKind(name, url),
84
- size_bytes: numberValue(artifact.size)
231
+ size_bytes: numberValue2(artifact.size)
85
232
  });
86
233
  }
87
234
  return artifacts;
@@ -89,9 +236,9 @@ function collectArtifacts(runResponse) {
89
236
  function pageSummaries(result) {
90
237
  const pages = [];
91
238
  for (const page of asArray(result.pages)) {
92
- const record = asRecord(page);
93
- const route = stringValue(record.route) || stringValue(record.url) || "page";
94
- const checks = asRecord(record.checks);
239
+ const record = asRecord2(page);
240
+ const route = stringValue2(record.route) || stringValue2(record.url) || "page";
241
+ const checks = asRecord2(record.checks);
95
242
  let passed = 0;
96
243
  let failed = 0;
97
244
  for (const value of Object.values(checks)) {
@@ -131,68 +278,74 @@ function selectPrimaryImage(artifacts) {
131
278
  const images = artifacts.filter((artifact) => artifact.kind === "image");
132
279
  return images.find((artifact) => /after|proof|screenshot/i.test(artifact.name)) || images[0];
133
280
  }
134
- function firstRecordValue(...values) {
281
+ function firstRecordValue2(...values) {
135
282
  for (const value of values) {
136
- const record = asRecord(value);
283
+ const record = asRecord2(value);
137
284
  if (Object.keys(record).length) return record;
138
285
  }
139
286
  return void 0;
140
287
  }
141
- function checkpointSummaryFrom(...values) {
142
- const record = firstRecordValue(...values);
288
+ function checkpointSummaryFrom2(...values) {
289
+ const record = firstRecordValue2(...values);
143
290
  if (!record) return void 0;
144
291
  const summary = {
145
- pending: booleanValue(record.pending),
146
- response_count: numberValue(record.response_count),
147
- rejected_response_count: numberValue(record.rejected_response_count),
148
- ignored_response_count: numberValue(record.ignored_response_count),
149
- duplicate_response_count: numberValue(record.duplicate_response_count),
150
- latest_decision: stringValue(record.latest_decision),
151
- latest_packet_id: stringValue(record.latest_packet_id),
152
- latest_resume_token: stringValue(record.latest_resume_token)
292
+ pending: booleanValue2(record.pending),
293
+ response_count: numberValue2(record.response_count),
294
+ rejected_response_count: numberValue2(record.rejected_response_count),
295
+ ignored_response_count: numberValue2(record.ignored_response_count),
296
+ duplicate_response_count: numberValue2(record.duplicate_response_count),
297
+ latest_decision: stringValue2(record.latest_decision),
298
+ latest_packet_id: stringValue2(record.latest_packet_id),
299
+ latest_resume_token: stringValue2(record.latest_resume_token)
153
300
  };
154
301
  return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
155
302
  }
156
303
  function summarizeRiddleProofPrComment(input) {
157
- const runResponse = asRecord(input.runResponse);
158
- const result = asRecord(input.result);
159
- const proofResult = asRecord(runResponse.proofResult);
160
- const preview = asRecord(runResponse.preview);
161
- const resultRunCard = asRecord(result.run_card);
162
- const stopCondition = asRecord(resultRunCard.stop_condition);
163
- const resultDetails = asRecord(result.details);
164
- const resultRaw = asRecord(result.raw);
165
- const rawDetails = asRecord(resultRaw.details);
304
+ const runResponse = asRecord2(input.runResponse);
305
+ const result = asRecord2(input.result);
306
+ const proofResult = asRecord2(runResponse.proofResult);
307
+ const preview = asRecord2(runResponse.preview);
308
+ const resultRunCard = asRecord2(result.run_card);
309
+ const stopCondition = asRecord2(resultRunCard.stop_condition);
310
+ const resultDetails = asRecord2(result.details);
311
+ const resultRaw = asRecord2(result.raw);
312
+ const rawDetails = asRecord2(resultRaw.details);
166
313
  const artifacts = collectArtifacts(runResponse);
167
314
  const pages = pageSummaries(result);
168
315
  const checkSource = { ...result };
169
316
  delete checkSource.ok;
170
317
  const nestedChecks = summarizeExplicitChecks(checkSource);
171
- const ok = booleanValue(result.ok) ?? booleanValue(runResponse.ok) ?? null;
172
- const checkpointSummary = checkpointSummaryFrom(
318
+ const ok = booleanValue2(result.ok) ?? booleanValue2(runResponse.ok) ?? null;
319
+ const checkpointSummary = checkpointSummaryFrom2(
173
320
  result.checkpoint_summary,
174
321
  stopCondition.checkpoint_summary,
175
322
  resultDetails.checkpoint_summary,
176
323
  rawDetails.checkpoint_summary,
177
324
  proofResult.checkpoint_summary
178
325
  );
326
+ const publicState = summarizeRiddleProofPublicState({
327
+ ...result,
328
+ status: firstStringValue2(result.status, stopCondition.status),
329
+ checkpoint_summary: checkpointSummary || result.checkpoint_summary
330
+ });
179
331
  return {
180
332
  ok,
181
- status: stringValue(proofResult.status),
182
- result_status: firstStringValue(result.status, stopCondition.status),
183
- job_id: stringValue(proofResult.job_id),
184
- duration_ms: numberValue(proofResult.duration_ms),
185
- proof_url: stringValue(runResponse.proofUrl),
186
- preview_id: stringValue(preview.id),
187
- preview_url: stringValue(preview.preview_url) || stringValue(preview.url),
188
- preview_publish_recovered: booleanValue(preview.publish_recovered),
189
- preview_publish_error: stringValue(preview.publish_error),
190
- ship_held: firstBooleanValue(result.ship_held, stopCondition.ship_held, resultRaw.ship_held),
191
- shipping_disabled: firstBooleanValue(result.shipping_disabled, stopCondition.shipping_disabled, resultRaw.shipping_disabled),
192
- ship_authorized: firstBooleanValue(result.ship_authorized, stopCondition.ship_authorized, resultRaw.ship_authorized),
193
- proof_decision: firstStringValue(result.proof_decision, stopCondition.proof_decision, resultRaw.proof_decision),
194
- merge_recommendation: firstStringValue(result.merge_recommendation, stopCondition.merge_recommendation, resultRaw.merge_recommendation),
333
+ status: stringValue2(proofResult.status),
334
+ result_status: publicState.status,
335
+ job_id: stringValue2(proofResult.job_id),
336
+ duration_ms: numberValue2(proofResult.duration_ms),
337
+ proof_url: stringValue2(runResponse.proofUrl),
338
+ preview_id: stringValue2(preview.id),
339
+ preview_url: stringValue2(preview.preview_url) || stringValue2(preview.url),
340
+ preview_publish_recovered: booleanValue2(preview.publish_recovered),
341
+ preview_publish_error: stringValue2(preview.publish_error),
342
+ ship_held: publicState.ship_held,
343
+ shipping_disabled: publicState.shipping_disabled,
344
+ ship_authorized: publicState.ship_authorized,
345
+ proof_decision: firstStringValue2(result.proof_decision, stopCondition.proof_decision, resultRaw.proof_decision),
346
+ merge_recommendation: firstStringValue2(result.merge_recommendation, stopCondition.merge_recommendation, resultRaw.merge_recommendation),
195
347
  checkpoint_summary: checkpointSummary,
348
+ public_state: publicState,
196
349
  passed_checks: nestedChecks.passed,
197
350
  failed_checks: nestedChecks.failed,
198
351
  pages,
@@ -211,6 +364,7 @@ function markdownLink(label, url) {
211
364
  return `[${label.replace(/\]/g, "\\]")}](${url})`;
212
365
  }
213
366
  function resultLabel(summary) {
367
+ if (summary.public_state?.result_label) return summary.public_state.result_label;
214
368
  if (summary.ok === true) {
215
369
  if (summary.result_status === "shipped") return "shipped";
216
370
  if (summary.result_status === "completed") return "completed";
@@ -1,3 +1,5 @@
1
+ import { RiddleProofPublicStateSummary } from './public-state.cjs';
2
+
1
3
  declare const RIDDLE_PROOF_PR_COMMENT_MARKER = "<!-- riddle-proof:pr-comment:v1 -->";
2
4
  type RiddleProofPrCommentArtifactKind = "image" | "data" | "artifact";
3
5
  interface RiddleProofPrCommentArtifact {
@@ -38,6 +40,7 @@ interface RiddleProofPrCommentSummary {
38
40
  proof_decision?: string;
39
41
  merge_recommendation?: string;
40
42
  checkpoint_summary?: RiddleProofPrCommentCheckpointSummary;
43
+ public_state?: RiddleProofPublicStateSummary;
41
44
  passed_checks: number;
42
45
  failed_checks: number;
43
46
  pages: RiddleProofPrCommentPageSummary[];
@@ -1,3 +1,5 @@
1
+ import { RiddleProofPublicStateSummary } from './public-state.js';
2
+
1
3
  declare const RIDDLE_PROOF_PR_COMMENT_MARKER = "<!-- riddle-proof:pr-comment:v1 -->";
2
4
  type RiddleProofPrCommentArtifactKind = "image" | "data" | "artifact";
3
5
  interface RiddleProofPrCommentArtifact {
@@ -38,6 +40,7 @@ interface RiddleProofPrCommentSummary {
38
40
  proof_decision?: string;
39
41
  merge_recommendation?: string;
40
42
  checkpoint_summary?: RiddleProofPrCommentCheckpointSummary;
43
+ public_state?: RiddleProofPublicStateSummary;
41
44
  passed_checks: number;
42
45
  failed_checks: number;
43
46
  pages: RiddleProofPrCommentPageSummary[];
@@ -2,7 +2,8 @@ import {
2
2
  RIDDLE_PROOF_PR_COMMENT_MARKER,
3
3
  buildRiddleProofPrCommentMarkdown,
4
4
  summarizeRiddleProofPrComment
5
- } from "./chunk-JR7GFTLS.js";
5
+ } from "./chunk-62XLYPMS.js";
6
+ import "./chunk-KG64Y5MC.js";
6
7
  import "./chunk-MLKGABMK.js";
7
8
  export {
8
9
  RIDDLE_PROOF_PR_COMMENT_MARKER,
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/public-state.ts
21
+ var public_state_exports = {};
22
+ __export(public_state_exports, {
23
+ summarizeRiddleProofPublicState: () => summarizeRiddleProofPublicState
24
+ });
25
+ module.exports = __toCommonJS(public_state_exports);
26
+ function asRecord(value) {
27
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
28
+ }
29
+ function stringValue(value) {
30
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
31
+ }
32
+ function booleanValue(value) {
33
+ return typeof value === "boolean" ? value : void 0;
34
+ }
35
+ function numberValue(value) {
36
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
37
+ }
38
+ function firstStringValue(...values) {
39
+ for (const value of values) {
40
+ const text = stringValue(value);
41
+ if (text) return text;
42
+ }
43
+ return void 0;
44
+ }
45
+ function firstBooleanValue(...values) {
46
+ for (const value of values) {
47
+ const bool = booleanValue(value);
48
+ if (typeof bool === "boolean") return bool;
49
+ }
50
+ return void 0;
51
+ }
52
+ function firstRecordValue(...values) {
53
+ for (const value of values) {
54
+ const record = asRecord(value);
55
+ if (Object.keys(record).length) return record;
56
+ }
57
+ return void 0;
58
+ }
59
+ function countValue(value) {
60
+ const number = numberValue(value);
61
+ return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
62
+ }
63
+ function checkpointSummaryFrom(...values) {
64
+ const record = firstRecordValue(...values);
65
+ if (!record) return void 0;
66
+ const accepted = countValue(record.response_count);
67
+ const rejected = countValue(record.rejected_response_count);
68
+ const ignored = countValue(record.ignored_response_count);
69
+ const duplicate = countValue(record.duplicate_response_count);
70
+ const summary = {
71
+ pending: booleanValue(record.pending),
72
+ accepted_response_count: accepted,
73
+ rejected_response_count: rejected,
74
+ ignored_response_count: ignored,
75
+ duplicate_response_count: duplicate,
76
+ latest_decision: stringValue(record.latest_decision),
77
+ audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
78
+ };
79
+ return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
80
+ }
81
+ function uniqueStrings(values) {
82
+ return [...new Set(values.filter(Boolean))];
83
+ }
84
+ function summarizeRiddleProofPublicState(input) {
85
+ const record = asRecord(input);
86
+ const runCard = asRecord(record.run_card);
87
+ const stopCondition = asRecord(runCard.stop_condition);
88
+ const raw = asRecord(record.raw);
89
+ const request = asRecord(record.request);
90
+ const requestMetadata = asRecord(record.request_metadata);
91
+ const prState = asRecord(record.pr_state);
92
+ const handoff = asRecord(record.pr_handoff_policy);
93
+ const handoffState = stringValue(handoff.state);
94
+ const status = firstStringValue(record.status, stopCondition.status);
95
+ const ok = booleanValue(record.ok) ?? null;
96
+ const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
97
+ const explicitShippingDisabled = firstBooleanValue(
98
+ record.shipping_disabled,
99
+ stopCondition.shipping_disabled,
100
+ raw.shipping_disabled,
101
+ handoff.shipping_disabled
102
+ );
103
+ const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
104
+ const explicitShipAuthorized = firstBooleanValue(
105
+ record.ship_authorized,
106
+ stopCondition.ship_authorized,
107
+ raw.ship_authorized
108
+ );
109
+ const authorizationEvidence = Boolean(
110
+ status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
111
+ );
112
+ const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
113
+ const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
114
+ const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
115
+ const shipHeld = explicitShipHeld === true || inferredHeld;
116
+ const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
117
+ const proofComplete = Boolean(
118
+ status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
119
+ );
120
+ const checkpointSummary = checkpointSummaryFrom(
121
+ record.checkpoint_summary,
122
+ stopCondition.checkpoint_summary,
123
+ asRecord(record.details).checkpoint_summary,
124
+ asRecord(raw.details).checkpoint_summary
125
+ );
126
+ const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
127
+ const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
128
+ const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
129
+ const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
130
+ const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
131
+ const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
132
+ const syncAllowed = mergeReady;
133
+ let policyState = "unknown";
134
+ if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
135
+ else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
136
+ else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
137
+ else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
138
+ else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
139
+ else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
140
+ else if (shipAuthorized) policyState = "ship_authorized";
141
+ else if (proofPassed) policyState = "proof_passed";
142
+ else if (status === "running") policyState = "proof_in_progress";
143
+ const requiredDisclosures = [];
144
+ if (shipHeld) requiredDisclosures.push("ship_held");
145
+ if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
146
+ if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
147
+ if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
148
+ const prohibitedClaims = [];
149
+ if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
150
+ if (!mergeReady) prohibitedClaims.push("merge_ready");
151
+ if (!syncAllowed) prohibitedClaims.push("sync_allowed");
152
+ if (blockedOrWaiting) {
153
+ prohibitedClaims.push("proof_passed", "ready_to_ship");
154
+ }
155
+ if (checkpointSummary?.audit_disclosure_required) {
156
+ prohibitedClaims.push("all_checkpoint_responses_accepted");
157
+ }
158
+ const resultLabel = 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";
159
+ return {
160
+ status,
161
+ ok,
162
+ policy_state: policyState,
163
+ result_label: resultLabel,
164
+ proof_complete: proofComplete,
165
+ proof_passed: proofPassed,
166
+ ship_held: shipHeld,
167
+ shipping_disabled: shippingDisabled,
168
+ ship_authorized: shipAuthorized,
169
+ merge_ready: mergeReady,
170
+ sync_allowed: syncAllowed,
171
+ checkpoint_summary: checkpointSummary,
172
+ required_disclosures: uniqueStrings(requiredDisclosures),
173
+ prohibited_claims: uniqueStrings(prohibitedClaims)
174
+ };
175
+ }
176
+ // Annotate the CommonJS export names for ESM import in node:
177
+ 0 && (module.exports = {
178
+ summarizeRiddleProofPublicState
179
+ });
@@ -0,0 +1,29 @@
1
+ type RiddleProofPublicPolicyState = "awaiting_checkpoint" | "proof_blocked" | "proof_failed" | "proof_complete_ship_disabled" | "proof_passed_ship_held" | "ship_authorized" | "proof_passed" | "proof_in_progress" | "unknown";
2
+ interface RiddleProofPublicCheckpointSummary {
3
+ pending?: boolean;
4
+ accepted_response_count: number;
5
+ rejected_response_count: number;
6
+ ignored_response_count: number;
7
+ duplicate_response_count: number;
8
+ latest_decision?: string;
9
+ audit_disclosure_required: boolean;
10
+ }
11
+ interface RiddleProofPublicStateSummary {
12
+ status?: string;
13
+ ok: boolean | null;
14
+ policy_state: RiddleProofPublicPolicyState;
15
+ result_label: string;
16
+ proof_complete: boolean;
17
+ proof_passed: boolean;
18
+ ship_held: boolean;
19
+ shipping_disabled: boolean;
20
+ ship_authorized: boolean;
21
+ merge_ready: boolean;
22
+ sync_allowed: boolean;
23
+ checkpoint_summary?: RiddleProofPublicCheckpointSummary;
24
+ required_disclosures: string[];
25
+ prohibited_claims: string[];
26
+ }
27
+ declare function summarizeRiddleProofPublicState(input: unknown): RiddleProofPublicStateSummary;
28
+
29
+ export { type RiddleProofPublicCheckpointSummary, type RiddleProofPublicPolicyState, type RiddleProofPublicStateSummary, summarizeRiddleProofPublicState };