@riddledc/riddle-proof 0.4.2 → 0.4.4

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.cjs CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
34
34
  appendRunEvent: () => appendRunEvent,
35
35
  appendStageHeartbeat: () => appendStageHeartbeat,
36
+ applyPrLifecycleState: () => applyPrLifecycleState,
36
37
  applyTerminalMetadata: () => applyTerminalMetadata,
37
38
  compactRecord: () => compactRecord,
38
39
  createDisabledRiddleProofAgentAdapter: () => createDisabledRiddleProofAgentAdapter,
@@ -43,6 +44,7 @@ __export(index_exports, {
43
44
  isTerminalStatus: () => isTerminalStatus,
44
45
  nonEmptyString: () => nonEmptyString,
45
46
  normalizeIntegrationContext: () => normalizeIntegrationContext,
47
+ normalizePrLifecycleState: () => normalizePrLifecycleState,
46
48
  normalizeRunParams: () => normalizeRunParams,
47
49
  normalizeTerminalMetadata: () => normalizeTerminalMetadata,
48
50
  readRiddleProofRunStatus: () => readRiddleProofRunStatus,
@@ -69,16 +71,102 @@ function nonEmptyString(value) {
69
71
  function recordValue(value) {
70
72
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
71
73
  }
74
+ function firstNonEmptyString(...values) {
75
+ for (const value of values) {
76
+ const normalized = nonEmptyString(value);
77
+ if (normalized) return normalized;
78
+ }
79
+ return void 0;
80
+ }
81
+ function firstBoolean(...values) {
82
+ for (const value of values) {
83
+ if (typeof value === "boolean") return value;
84
+ }
85
+ return void 0;
86
+ }
87
+ function normalizePrStatus(value) {
88
+ const status = nonEmptyString(value)?.toLowerCase();
89
+ if (status === "merged") return "merged";
90
+ if (status === "open") return "open";
91
+ if (status === "closed") return "closed";
92
+ if (status === "not_found" || status === "not-found") return "not_found";
93
+ if (status === "unavailable") return "unavailable";
94
+ return status || "unknown";
95
+ }
96
+ function normalizePrLifecycleStateInput(input) {
97
+ if (!input) return void 0;
98
+ const cleanup = recordValue(input.cleanup);
99
+ const mergeCommit = nonEmptyString(input.merge_commit) || nonEmptyString(input.mergeCommit) || nonEmptyString(recordValue(input.mergeCommit)?.oid);
100
+ return compactRecord({
101
+ status: normalizePrStatus(input.status || input.state),
102
+ pr_url: nonEmptyString(input.pr_url) || nonEmptyString(input.prUrl) || nonEmptyString(input.url),
103
+ pr_number: nonEmptyString(input.pr_number) || nonEmptyString(input.prNumber) || (typeof input.number === "number" ? String(input.number) : void 0),
104
+ repo: nonEmptyString(input.repo) || nonEmptyString(input.repository),
105
+ head_branch: nonEmptyString(input.head_branch) || nonEmptyString(input.headBranch) || nonEmptyString(input.headRefName),
106
+ base_branch: nonEmptyString(input.base_branch) || nonEmptyString(input.baseBranch) || nonEmptyString(input.baseRefName),
107
+ merge_commit: mergeCommit,
108
+ merged_at: nonEmptyString(input.merged_at) || nonEmptyString(input.mergedAt),
109
+ closed_at: nonEmptyString(input.closed_at) || nonEmptyString(input.closedAt),
110
+ checked_at: nonEmptyString(input.checked_at) || nonEmptyString(input.checkedAt),
111
+ source: nonEmptyString(input.source),
112
+ next_action: nonEmptyString(input.next_action) || nonEmptyString(input.nextAction),
113
+ cleanup: cleanup && Object.keys(cleanup).length ? cleanup : void 0
114
+ });
115
+ }
72
116
  function normalizeTerminalMetadata(input) {
73
117
  const riddleState = recordValue(input.riddleState) || {};
74
118
  const result = recordValue(input.engineResult) || {};
75
119
  const contract = recordValue(result.checkpointContract) || {};
76
120
  const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
77
- const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
78
- const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
121
+ const shipReport = recordValue(riddleState.ship_report) || recordValue(result.ship_report) || recordValue(result.shipReport) || recordValue(details.ship_report) || recordValue(details.shipReport) || {};
122
+ const markedReady = firstBoolean(
123
+ riddleState.marked_ready,
124
+ result.marked_ready,
125
+ result.markedReady,
126
+ details.marked_ready,
127
+ details.markedReady,
128
+ shipReport.marked_ready
129
+ );
130
+ const leftDraft = firstBoolean(
131
+ riddleState.left_draft,
132
+ result.left_draft,
133
+ result.leftDraft,
134
+ details.left_draft,
135
+ details.leftDraft,
136
+ shipReport.left_draft
137
+ );
138
+ const finalized = firstBoolean(riddleState.finalized, result.finalized, details.finalized);
139
+ const prState = normalizePrLifecycleStateInput(
140
+ recordValue(riddleState.pr_state) || recordValue(riddleState.prState) || recordValue(result.pr_state) || recordValue(result.prState) || recordValue(details.pr_state) || recordValue(details.prState) || recordValue(shipReport.pr_state) || recordValue(shipReport.prState)
141
+ );
142
+ const cleanupReport = recordValue(riddleState.cleanup_report) || recordValue(riddleState.cleanupReport) || recordValue(result.cleanup_report) || recordValue(result.cleanupReport) || recordValue(details.cleanup_report) || recordValue(details.cleanupReport) || recordValue(prState?.cleanup);
79
143
  return compactRecord({
80
- pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
81
- marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
144
+ pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
145
+ pr_branch: firstNonEmptyString(
146
+ riddleState.pr_branch,
147
+ riddleState.target_branch,
148
+ result.pr_branch,
149
+ result.prBranch,
150
+ details.pr_branch,
151
+ details.prBranch,
152
+ shipReport.pr_branch,
153
+ shipReport.branch,
154
+ prState?.head_branch
155
+ ),
156
+ pr_state: prState,
157
+ marked_ready: markedReady,
158
+ left_draft: leftDraft,
159
+ ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
160
+ ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
161
+ ship_remote_head: firstNonEmptyString(riddleState.ship_remote_head, result.ship_remote_head, result.shipRemoteHead, details.ship_remote_head, details.shipRemoteHead, shipReport.ship_remote_head),
162
+ merge_commit: firstNonEmptyString(riddleState.merge_commit, riddleState.mergeCommit, result.merge_commit, result.mergeCommit, details.merge_commit, details.mergeCommit, prState?.merge_commit),
163
+ merged_at: firstNonEmptyString(riddleState.merged_at, riddleState.mergedAt, result.merged_at, result.mergedAt, details.merged_at, details.mergedAt, prState?.merged_at),
164
+ proof_comment_url: firstNonEmptyString(riddleState.proof_comment_url, result.proof_comment_url, result.proofCommentUrl, details.proof_comment_url, details.proofCommentUrl, shipReport.proof_comment_url),
165
+ before_artifact_url: firstNonEmptyString(riddleState.before_artifact_url, riddleState.before_cdn, result.before_artifact_url, result.beforeArtifactUrl, details.before_artifact_url, details.beforeArtifactUrl, shipReport.before_artifact_url),
166
+ prod_artifact_url: firstNonEmptyString(riddleState.prod_artifact_url, riddleState.prod_cdn, result.prod_artifact_url, result.prodArtifactUrl, details.prod_artifact_url, details.prodArtifactUrl, shipReport.prod_artifact_url),
167
+ after_artifact_url: firstNonEmptyString(riddleState.after_artifact_url, riddleState.after_cdn, result.after_artifact_url, result.afterArtifactUrl, details.after_artifact_url, details.afterArtifactUrl, shipReport.after_artifact_url),
168
+ ship_report: Object.keys(shipReport).length ? shipReport : void 0,
169
+ cleanup_report: cleanupReport,
82
170
  notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
83
171
  proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
84
172
  merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
@@ -86,9 +174,43 @@ function normalizeTerminalMetadata(input) {
86
174
  });
87
175
  }
88
176
  function applyTerminalMetadata(state, metadata) {
177
+ if (metadata.pr_state) {
178
+ state.pr_state = metadata.pr_state;
179
+ if (metadata.pr_state.pr_url) state.pr_url = metadata.pr_state.pr_url;
180
+ if (metadata.pr_state.head_branch) state.pr_branch = metadata.pr_state.head_branch;
181
+ if (metadata.pr_state.merge_commit) state.merge_commit = metadata.pr_state.merge_commit;
182
+ if (metadata.pr_state.merged_at) state.merged_at = metadata.pr_state.merged_at;
183
+ if (metadata.pr_state.cleanup) state.cleanup_report = metadata.pr_state.cleanup;
184
+ if (metadata.pr_state.status === "merged") state.finalized = true;
185
+ }
89
186
  const prUrl = nonEmptyString(metadata.pr_url);
90
187
  if (prUrl) state.pr_url = prUrl;
188
+ const prBranch = nonEmptyString(metadata.pr_branch);
189
+ if (prBranch) state.pr_branch = prBranch;
91
190
  if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
191
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
192
+ const ciStatus = nonEmptyString(metadata.ci_status);
193
+ if (ciStatus) state.ci_status = ciStatus;
194
+ const shipCommit = nonEmptyString(metadata.ship_commit);
195
+ if (shipCommit) state.ship_commit = shipCommit;
196
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
197
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
198
+ const mergeCommit = nonEmptyString(metadata.merge_commit);
199
+ if (mergeCommit) state.merge_commit = mergeCommit;
200
+ const mergedAt = nonEmptyString(metadata.merged_at);
201
+ if (mergedAt) state.merged_at = mergedAt;
202
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
203
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
204
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
205
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
206
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
207
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
208
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
209
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
210
+ const shipReport = recordValue(metadata.ship_report);
211
+ if (shipReport) state.ship_report = shipReport;
212
+ const cleanupReport = recordValue(metadata.cleanup_report);
213
+ if (cleanupReport) state.cleanup_report = cleanupReport;
92
214
  const notification = recordValue(metadata.notification);
93
215
  if (notification) state.notification = notification;
94
216
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -117,7 +239,21 @@ function createRunResult(input) {
117
239
  last_summary: input.last_summary ?? null,
118
240
  event_count: state.events.length,
119
241
  pr_url: state.pr_url,
242
+ pr_branch: state.pr_branch,
243
+ pr_state: state.pr_state,
120
244
  marked_ready: state.marked_ready,
245
+ left_draft: state.left_draft,
246
+ ci_status: state.ci_status,
247
+ ship_commit: state.ship_commit,
248
+ ship_remote_head: state.ship_remote_head,
249
+ merge_commit: state.merge_commit,
250
+ merged_at: state.merged_at,
251
+ proof_comment_url: state.proof_comment_url,
252
+ before_artifact_url: state.before_artifact_url,
253
+ prod_artifact_url: state.prod_artifact_url,
254
+ after_artifact_url: state.after_artifact_url,
255
+ ship_report: state.ship_report,
256
+ cleanup_report: state.cleanup_report,
121
257
  notification: state.notification,
122
258
  proof_decision: state.proof_decision,
123
259
  merge_recommendation: state.merge_recommendation,
@@ -144,6 +280,36 @@ function elapsedMs(start, end) {
144
280
  if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
145
281
  return Math.max(0, endMs - startMs);
146
282
  }
283
+ function normalizePrStatus2(value) {
284
+ const status = nonEmptyString(value)?.toLowerCase();
285
+ if (status === "merged") return "merged";
286
+ if (status === "open") return "open";
287
+ if (status === "closed") return "closed";
288
+ if (status === "not_found" || status === "not-found") return "not_found";
289
+ if (status === "unavailable") return "unavailable";
290
+ return status || "unknown";
291
+ }
292
+ function normalizePrLifecycleState(input, checkedAt = timestamp()) {
293
+ const value = recordValue(input);
294
+ if (!value) return void 0;
295
+ const cleanup = recordValue(value.cleanup);
296
+ const mergeCommit = nonEmptyString(value.merge_commit) || nonEmptyString(value.mergeCommit) || nonEmptyString(recordValue(value.mergeCommit)?.oid);
297
+ return compactRecord({
298
+ status: normalizePrStatus2(value.status || value.state),
299
+ pr_url: nonEmptyString(value.pr_url) || nonEmptyString(value.prUrl) || nonEmptyString(value.url),
300
+ pr_number: nonEmptyString(value.pr_number) || nonEmptyString(value.prNumber) || (typeof value.number === "number" ? String(value.number) : void 0),
301
+ repo: nonEmptyString(value.repo) || nonEmptyString(value.repository),
302
+ head_branch: nonEmptyString(value.head_branch) || nonEmptyString(value.headBranch) || nonEmptyString(value.headRefName),
303
+ base_branch: nonEmptyString(value.base_branch) || nonEmptyString(value.baseBranch) || nonEmptyString(value.baseRefName),
304
+ merge_commit: mergeCommit,
305
+ merged_at: nonEmptyString(value.merged_at) || nonEmptyString(value.mergedAt),
306
+ closed_at: nonEmptyString(value.closed_at) || nonEmptyString(value.closedAt),
307
+ checked_at: nonEmptyString(value.checked_at) || nonEmptyString(value.checkedAt) || checkedAt,
308
+ source: nonEmptyString(value.source),
309
+ next_action: nonEmptyString(value.next_action) || nonEmptyString(value.nextAction),
310
+ cleanup: cleanup && Object.keys(cleanup).length ? cleanup : void 0
311
+ });
312
+ }
147
313
  function normalizeIntegrationContext(input, fallbackSource) {
148
314
  const value = recordValue(input);
149
315
  if (!value) {
@@ -267,6 +433,16 @@ function createRunStatusSnapshot(state, at = timestamp()) {
267
433
  state_path: state.state_path ?? null,
268
434
  worktree_path: state.worktree_path ?? null,
269
435
  branch: state.branch ?? null,
436
+ pr_url: state.pr_url ?? null,
437
+ pr_branch: state.pr_branch ?? null,
438
+ pr_state: state.pr_state,
439
+ ci_status: state.ci_status,
440
+ ship_commit: state.ship_commit,
441
+ ship_remote_head: state.ship_remote_head,
442
+ merge_commit: state.merge_commit,
443
+ merged_at: state.merged_at,
444
+ proof_comment_url: state.proof_comment_url,
445
+ cleanup_report: state.cleanup_report,
270
446
  iterations: state.iterations,
271
447
  last_checkpoint: state.last_checkpoint ?? null,
272
448
  updated_at: state.updated_at,
@@ -282,6 +458,23 @@ function setRunStatus(state, status, at = timestamp()) {
282
458
  state.updated_at = at;
283
459
  return state;
284
460
  }
461
+ function applyPrLifecycleState(state, input, at = timestamp()) {
462
+ const prState = normalizePrLifecycleState(input, at);
463
+ if (!prState) return state;
464
+ state.pr_state = prState;
465
+ if (prState.pr_url) state.pr_url = prState.pr_url;
466
+ if (prState.head_branch) state.pr_branch = prState.head_branch;
467
+ if (prState.merge_commit) state.merge_commit = prState.merge_commit;
468
+ if (prState.merged_at) state.merged_at = prState.merged_at;
469
+ if (prState.cleanup) state.cleanup_report = prState.cleanup;
470
+ if (prState.status === "merged") {
471
+ state.finalized = true;
472
+ state.status = "completed";
473
+ state.ok = true;
474
+ }
475
+ state.updated_at = at;
476
+ return state;
477
+ }
285
478
 
286
479
  // src/runner.ts
287
480
  function errorDetails(error) {
@@ -870,10 +1063,12 @@ function stageFromCheckpoint(result) {
870
1063
  if (checkpoint.startsWith("implement_")) return "implement";
871
1064
  if (checkpoint.startsWith("verify_")) return "verify";
872
1065
  if (checkpoint.startsWith("ship_")) return "ship";
1066
+ if (checkpoint.startsWith("pr_sync_")) return "notify";
873
1067
  if (checkpoint.includes("capture")) return "prove";
874
1068
  return "setup";
875
1069
  }
876
1070
  function stageFromWorkflowParams(params) {
1071
+ if (params.action === "sync") return "notify";
877
1072
  const stage = nonEmptyString(params.advance_stage);
878
1073
  if (stage) return stage;
879
1074
  if (params.ship_after_verify) return "ship";
@@ -1180,6 +1375,21 @@ async function routeCheckpoint(request, state, result, agent, input) {
1180
1375
  terminal: terminalResult(state, "shipped", result, result.summary || "Riddle Proof shipped.")
1181
1376
  };
1182
1377
  }
1378
+ if (checkpoint.startsWith("pr_sync_")) {
1379
+ const fullState = context.fullRiddleState || {};
1380
+ const prState = recordValue(result.pr_state) || recordValue(result.prState) || recordValue(fullState.pr_state) || {};
1381
+ const prStatus = nonEmptyString(prState.status);
1382
+ const status = prStatus === "merged" ? "completed" : prStatus === "open" ? "shipped" : result.ok === false ? "blocked" : "completed";
1383
+ return {
1384
+ terminal: terminalResult(
1385
+ state,
1386
+ status,
1387
+ result,
1388
+ result.summary || "Riddle Proof PR lifecycle sync completed.",
1389
+ { pr_sync: true }
1390
+ )
1391
+ };
1392
+ }
1183
1393
  if (checkpoint === "verify_ship_ready") {
1184
1394
  const shipMode = effectiveShipMode(request, input.config);
1185
1395
  if (shipMode === "ship") {
@@ -1429,6 +1639,7 @@ async function runRiddleProofEngineHarness(input) {
1429
1639
  RIDDLE_PROOF_RUN_STATE_VERSION,
1430
1640
  appendRunEvent,
1431
1641
  appendStageHeartbeat,
1642
+ applyPrLifecycleState,
1432
1643
  applyTerminalMetadata,
1433
1644
  compactRecord,
1434
1645
  createDisabledRiddleProofAgentAdapter,
@@ -1439,6 +1650,7 @@ async function runRiddleProofEngineHarness(input) {
1439
1650
  isTerminalStatus,
1440
1651
  nonEmptyString,
1441
1652
  normalizeIntegrationContext,
1653
+ normalizePrLifecycleState,
1442
1654
  normalizeRunParams,
1443
1655
  normalizeTerminalMetadata,
1444
1656
  readRiddleProofRunStatus,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from './types.cjs';
1
+ export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofPrLifecycleState, RiddleProofPrLifecycleStatus, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from './types.cjs';
2
2
  export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from './result.cjs';
3
- export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.cjs';
3
+ export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from './state.cjs';
4
4
  export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.cjs';
5
5
  export { RiddleProofAgentAdapter, RiddleProofAgentPayload, RiddleProofEngine, RiddleProofEngineHarnessConfig, RiddleProofEngineHarnessContext, RiddleProofEngineResult, RiddleProofShipMode, RiddleProofWorkflowParams, RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness } from './engine-harness.cjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from './types.js';
1
+ export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofPrLifecycleState, RiddleProofPrLifecycleStatus, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from './types.js';
2
2
  export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from './result.js';
3
- export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.js';
3
+ export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from './state.js';
4
4
  export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.js';
5
5
  export { RiddleProofAgentAdapter, RiddleProofAgentPayload, RiddleProofEngine, RiddleProofEngineHarnessConfig, RiddleProofEngineHarnessContext, RiddleProofEngineResult, RiddleProofShipMode, RiddleProofWorkflowParams, RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness } from './engine-harness.js';
package/dist/index.js CHANGED
@@ -2,20 +2,22 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-7DED7LM3.js";
5
+ } from "./chunk-75XY5SVT.js";
6
6
  import {
7
7
  runRiddleProof
8
- } from "./chunk-CL2FOOXX.js";
8
+ } from "./chunk-PM5Q26Q6.js";
9
9
  import {
10
10
  RIDDLE_PROOF_RUN_STATE_VERSION,
11
11
  appendRunEvent,
12
12
  appendStageHeartbeat,
13
+ applyPrLifecycleState,
13
14
  createRunState,
14
15
  createRunStatusSnapshot,
15
16
  normalizeIntegrationContext,
17
+ normalizePrLifecycleState,
16
18
  normalizeRunParams,
17
19
  setRunStatus
18
- } from "./chunk-3XJJ4JOB.js";
20
+ } from "./chunk-SIQG3N6F.js";
19
21
  import {
20
22
  applyTerminalMetadata,
21
23
  compactRecord,
@@ -25,12 +27,13 @@ import {
25
27
  nonEmptyString,
26
28
  normalizeTerminalMetadata,
27
29
  recordValue
28
- } from "./chunk-5DC6YXN4.js";
30
+ } from "./chunk-TMMKRKY5.js";
29
31
  import "./chunk-6F4PWJZI.js";
30
32
  export {
31
33
  RIDDLE_PROOF_RUN_STATE_VERSION,
32
34
  appendRunEvent,
33
35
  appendStageHeartbeat,
36
+ applyPrLifecycleState,
34
37
  applyTerminalMetadata,
35
38
  compactRecord,
36
39
  createDisabledRiddleProofAgentAdapter,
@@ -41,6 +44,7 @@ export {
41
44
  isTerminalStatus,
42
45
  nonEmptyString,
43
46
  normalizeIntegrationContext,
47
+ normalizePrLifecycleState,
44
48
  normalizeRunParams,
45
49
  normalizeTerminalMetadata,
46
50
  readRiddleProofRunStatus,
package/dist/openclaw.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  normalizeIntegrationContext,
3
3
  normalizeRunParams
4
- } from "./chunk-3XJJ4JOB.js";
4
+ } from "./chunk-SIQG3N6F.js";
5
5
  import {
6
6
  compactRecord
7
- } from "./chunk-5DC6YXN4.js";
7
+ } from "./chunk-TMMKRKY5.js";
8
8
 
9
9
  // src/openclaw.ts
10
10
  function parseOpenClawAssertions(value) {
package/dist/result.cjs CHANGED
@@ -45,16 +45,102 @@ function nonEmptyString(value) {
45
45
  function recordValue(value) {
46
46
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
47
47
  }
48
+ function firstNonEmptyString(...values) {
49
+ for (const value of values) {
50
+ const normalized = nonEmptyString(value);
51
+ if (normalized) return normalized;
52
+ }
53
+ return void 0;
54
+ }
55
+ function firstBoolean(...values) {
56
+ for (const value of values) {
57
+ if (typeof value === "boolean") return value;
58
+ }
59
+ return void 0;
60
+ }
61
+ function normalizePrStatus(value) {
62
+ const status = nonEmptyString(value)?.toLowerCase();
63
+ if (status === "merged") return "merged";
64
+ if (status === "open") return "open";
65
+ if (status === "closed") return "closed";
66
+ if (status === "not_found" || status === "not-found") return "not_found";
67
+ if (status === "unavailable") return "unavailable";
68
+ return status || "unknown";
69
+ }
70
+ function normalizePrLifecycleStateInput(input) {
71
+ if (!input) return void 0;
72
+ const cleanup = recordValue(input.cleanup);
73
+ const mergeCommit = nonEmptyString(input.merge_commit) || nonEmptyString(input.mergeCommit) || nonEmptyString(recordValue(input.mergeCommit)?.oid);
74
+ return compactRecord({
75
+ status: normalizePrStatus(input.status || input.state),
76
+ pr_url: nonEmptyString(input.pr_url) || nonEmptyString(input.prUrl) || nonEmptyString(input.url),
77
+ pr_number: nonEmptyString(input.pr_number) || nonEmptyString(input.prNumber) || (typeof input.number === "number" ? String(input.number) : void 0),
78
+ repo: nonEmptyString(input.repo) || nonEmptyString(input.repository),
79
+ head_branch: nonEmptyString(input.head_branch) || nonEmptyString(input.headBranch) || nonEmptyString(input.headRefName),
80
+ base_branch: nonEmptyString(input.base_branch) || nonEmptyString(input.baseBranch) || nonEmptyString(input.baseRefName),
81
+ merge_commit: mergeCommit,
82
+ merged_at: nonEmptyString(input.merged_at) || nonEmptyString(input.mergedAt),
83
+ closed_at: nonEmptyString(input.closed_at) || nonEmptyString(input.closedAt),
84
+ checked_at: nonEmptyString(input.checked_at) || nonEmptyString(input.checkedAt),
85
+ source: nonEmptyString(input.source),
86
+ next_action: nonEmptyString(input.next_action) || nonEmptyString(input.nextAction),
87
+ cleanup: cleanup && Object.keys(cleanup).length ? cleanup : void 0
88
+ });
89
+ }
48
90
  function normalizeTerminalMetadata(input) {
49
91
  const riddleState = recordValue(input.riddleState) || {};
50
92
  const result = recordValue(input.engineResult) || {};
51
93
  const contract = recordValue(result.checkpointContract) || {};
52
94
  const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
53
- const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
54
- const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
95
+ const shipReport = recordValue(riddleState.ship_report) || recordValue(result.ship_report) || recordValue(result.shipReport) || recordValue(details.ship_report) || recordValue(details.shipReport) || {};
96
+ const markedReady = firstBoolean(
97
+ riddleState.marked_ready,
98
+ result.marked_ready,
99
+ result.markedReady,
100
+ details.marked_ready,
101
+ details.markedReady,
102
+ shipReport.marked_ready
103
+ );
104
+ const leftDraft = firstBoolean(
105
+ riddleState.left_draft,
106
+ result.left_draft,
107
+ result.leftDraft,
108
+ details.left_draft,
109
+ details.leftDraft,
110
+ shipReport.left_draft
111
+ );
112
+ const finalized = firstBoolean(riddleState.finalized, result.finalized, details.finalized);
113
+ const prState = normalizePrLifecycleStateInput(
114
+ recordValue(riddleState.pr_state) || recordValue(riddleState.prState) || recordValue(result.pr_state) || recordValue(result.prState) || recordValue(details.pr_state) || recordValue(details.prState) || recordValue(shipReport.pr_state) || recordValue(shipReport.prState)
115
+ );
116
+ const cleanupReport = recordValue(riddleState.cleanup_report) || recordValue(riddleState.cleanupReport) || recordValue(result.cleanup_report) || recordValue(result.cleanupReport) || recordValue(details.cleanup_report) || recordValue(details.cleanupReport) || recordValue(prState?.cleanup);
55
117
  return compactRecord({
56
- pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
57
- marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
118
+ pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
119
+ pr_branch: firstNonEmptyString(
120
+ riddleState.pr_branch,
121
+ riddleState.target_branch,
122
+ result.pr_branch,
123
+ result.prBranch,
124
+ details.pr_branch,
125
+ details.prBranch,
126
+ shipReport.pr_branch,
127
+ shipReport.branch,
128
+ prState?.head_branch
129
+ ),
130
+ pr_state: prState,
131
+ marked_ready: markedReady,
132
+ left_draft: leftDraft,
133
+ ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
134
+ ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
135
+ ship_remote_head: firstNonEmptyString(riddleState.ship_remote_head, result.ship_remote_head, result.shipRemoteHead, details.ship_remote_head, details.shipRemoteHead, shipReport.ship_remote_head),
136
+ merge_commit: firstNonEmptyString(riddleState.merge_commit, riddleState.mergeCommit, result.merge_commit, result.mergeCommit, details.merge_commit, details.mergeCommit, prState?.merge_commit),
137
+ merged_at: firstNonEmptyString(riddleState.merged_at, riddleState.mergedAt, result.merged_at, result.mergedAt, details.merged_at, details.mergedAt, prState?.merged_at),
138
+ proof_comment_url: firstNonEmptyString(riddleState.proof_comment_url, result.proof_comment_url, result.proofCommentUrl, details.proof_comment_url, details.proofCommentUrl, shipReport.proof_comment_url),
139
+ before_artifact_url: firstNonEmptyString(riddleState.before_artifact_url, riddleState.before_cdn, result.before_artifact_url, result.beforeArtifactUrl, details.before_artifact_url, details.beforeArtifactUrl, shipReport.before_artifact_url),
140
+ prod_artifact_url: firstNonEmptyString(riddleState.prod_artifact_url, riddleState.prod_cdn, result.prod_artifact_url, result.prodArtifactUrl, details.prod_artifact_url, details.prodArtifactUrl, shipReport.prod_artifact_url),
141
+ after_artifact_url: firstNonEmptyString(riddleState.after_artifact_url, riddleState.after_cdn, result.after_artifact_url, result.afterArtifactUrl, details.after_artifact_url, details.afterArtifactUrl, shipReport.after_artifact_url),
142
+ ship_report: Object.keys(shipReport).length ? shipReport : void 0,
143
+ cleanup_report: cleanupReport,
58
144
  notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
59
145
  proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
60
146
  merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
@@ -62,9 +148,43 @@ function normalizeTerminalMetadata(input) {
62
148
  });
63
149
  }
64
150
  function applyTerminalMetadata(state, metadata) {
151
+ if (metadata.pr_state) {
152
+ state.pr_state = metadata.pr_state;
153
+ if (metadata.pr_state.pr_url) state.pr_url = metadata.pr_state.pr_url;
154
+ if (metadata.pr_state.head_branch) state.pr_branch = metadata.pr_state.head_branch;
155
+ if (metadata.pr_state.merge_commit) state.merge_commit = metadata.pr_state.merge_commit;
156
+ if (metadata.pr_state.merged_at) state.merged_at = metadata.pr_state.merged_at;
157
+ if (metadata.pr_state.cleanup) state.cleanup_report = metadata.pr_state.cleanup;
158
+ if (metadata.pr_state.status === "merged") state.finalized = true;
159
+ }
65
160
  const prUrl = nonEmptyString(metadata.pr_url);
66
161
  if (prUrl) state.pr_url = prUrl;
162
+ const prBranch = nonEmptyString(metadata.pr_branch);
163
+ if (prBranch) state.pr_branch = prBranch;
67
164
  if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
165
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
166
+ const ciStatus = nonEmptyString(metadata.ci_status);
167
+ if (ciStatus) state.ci_status = ciStatus;
168
+ const shipCommit = nonEmptyString(metadata.ship_commit);
169
+ if (shipCommit) state.ship_commit = shipCommit;
170
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
171
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
172
+ const mergeCommit = nonEmptyString(metadata.merge_commit);
173
+ if (mergeCommit) state.merge_commit = mergeCommit;
174
+ const mergedAt = nonEmptyString(metadata.merged_at);
175
+ if (mergedAt) state.merged_at = mergedAt;
176
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
177
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
178
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
179
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
180
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
181
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
182
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
183
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
184
+ const shipReport = recordValue(metadata.ship_report);
185
+ if (shipReport) state.ship_report = shipReport;
186
+ const cleanupReport = recordValue(metadata.cleanup_report);
187
+ if (cleanupReport) state.cleanup_report = cleanupReport;
68
188
  const notification = recordValue(metadata.notification);
69
189
  if (notification) state.notification = notification;
70
190
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -93,7 +213,21 @@ function createRunResult(input) {
93
213
  last_summary: input.last_summary ?? null,
94
214
  event_count: state.events.length,
95
215
  pr_url: state.pr_url,
216
+ pr_branch: state.pr_branch,
217
+ pr_state: state.pr_state,
96
218
  marked_ready: state.marked_ready,
219
+ left_draft: state.left_draft,
220
+ ci_status: state.ci_status,
221
+ ship_commit: state.ship_commit,
222
+ ship_remote_head: state.ship_remote_head,
223
+ merge_commit: state.merge_commit,
224
+ merged_at: state.merged_at,
225
+ proof_comment_url: state.proof_comment_url,
226
+ before_artifact_url: state.before_artifact_url,
227
+ prod_artifact_url: state.prod_artifact_url,
228
+ after_artifact_url: state.after_artifact_url,
229
+ ship_report: state.ship_report,
230
+ cleanup_report: state.cleanup_report,
97
231
  notification: state.notification,
98
232
  proof_decision: state.proof_decision,
99
233
  merge_recommendation: state.merge_recommendation,
package/dist/result.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  nonEmptyString,
8
8
  normalizeTerminalMetadata,
9
9
  recordValue
10
- } from "./chunk-5DC6YXN4.js";
10
+ } from "./chunk-TMMKRKY5.js";
11
11
  export {
12
12
  applyTerminalMetadata,
13
13
  compactRecord,
package/dist/runner.cjs CHANGED
@@ -38,9 +38,43 @@ function recordValue(value) {
38
38
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
39
39
  }
40
40
  function applyTerminalMetadata(state, metadata) {
41
+ if (metadata.pr_state) {
42
+ state.pr_state = metadata.pr_state;
43
+ if (metadata.pr_state.pr_url) state.pr_url = metadata.pr_state.pr_url;
44
+ if (metadata.pr_state.head_branch) state.pr_branch = metadata.pr_state.head_branch;
45
+ if (metadata.pr_state.merge_commit) state.merge_commit = metadata.pr_state.merge_commit;
46
+ if (metadata.pr_state.merged_at) state.merged_at = metadata.pr_state.merged_at;
47
+ if (metadata.pr_state.cleanup) state.cleanup_report = metadata.pr_state.cleanup;
48
+ if (metadata.pr_state.status === "merged") state.finalized = true;
49
+ }
41
50
  const prUrl = nonEmptyString(metadata.pr_url);
42
51
  if (prUrl) state.pr_url = prUrl;
52
+ const prBranch = nonEmptyString(metadata.pr_branch);
53
+ if (prBranch) state.pr_branch = prBranch;
43
54
  if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
55
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
56
+ const ciStatus = nonEmptyString(metadata.ci_status);
57
+ if (ciStatus) state.ci_status = ciStatus;
58
+ const shipCommit = nonEmptyString(metadata.ship_commit);
59
+ if (shipCommit) state.ship_commit = shipCommit;
60
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
61
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
62
+ const mergeCommit = nonEmptyString(metadata.merge_commit);
63
+ if (mergeCommit) state.merge_commit = mergeCommit;
64
+ const mergedAt = nonEmptyString(metadata.merged_at);
65
+ if (mergedAt) state.merged_at = mergedAt;
66
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
67
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
68
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
69
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
70
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
71
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
72
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
73
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
74
+ const shipReport = recordValue(metadata.ship_report);
75
+ if (shipReport) state.ship_report = shipReport;
76
+ const cleanupReport = recordValue(metadata.cleanup_report);
77
+ if (cleanupReport) state.cleanup_report = cleanupReport;
44
78
  const notification = recordValue(metadata.notification);
45
79
  if (notification) state.notification = notification;
46
80
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -69,7 +103,21 @@ function createRunResult(input) {
69
103
  last_summary: input.last_summary ?? null,
70
104
  event_count: state.events.length,
71
105
  pr_url: state.pr_url,
106
+ pr_branch: state.pr_branch,
107
+ pr_state: state.pr_state,
72
108
  marked_ready: state.marked_ready,
109
+ left_draft: state.left_draft,
110
+ ci_status: state.ci_status,
111
+ ship_commit: state.ship_commit,
112
+ ship_remote_head: state.ship_remote_head,
113
+ merge_commit: state.merge_commit,
114
+ merged_at: state.merged_at,
115
+ proof_comment_url: state.proof_comment_url,
116
+ before_artifact_url: state.before_artifact_url,
117
+ prod_artifact_url: state.prod_artifact_url,
118
+ after_artifact_url: state.after_artifact_url,
119
+ ship_report: state.ship_report,
120
+ cleanup_report: state.cleanup_report,
73
121
  notification: state.notification,
74
122
  proof_decision: state.proof_decision,
75
123
  merge_recommendation: state.merge_recommendation,