@riddledc/riddle-proof 0.4.3 → 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,
@@ -82,6 +84,35 @@ function firstBoolean(...values) {
82
84
  }
83
85
  return void 0;
84
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
+ }
85
116
  function normalizeTerminalMetadata(input) {
86
117
  const riddleState = recordValue(input.riddleState) || {};
87
118
  const result = recordValue(input.engineResult) || {};
@@ -105,6 +136,10 @@ function normalizeTerminalMetadata(input) {
105
136
  shipReport.left_draft
106
137
  );
107
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);
108
143
  return compactRecord({
109
144
  pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
110
145
  pr_branch: firstNonEmptyString(
@@ -115,18 +150,23 @@ function normalizeTerminalMetadata(input) {
115
150
  details.pr_branch,
116
151
  details.prBranch,
117
152
  shipReport.pr_branch,
118
- shipReport.branch
153
+ shipReport.branch,
154
+ prState?.head_branch
119
155
  ),
156
+ pr_state: prState,
120
157
  marked_ready: markedReady,
121
158
  left_draft: leftDraft,
122
159
  ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
123
160
  ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
124
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),
125
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),
126
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),
127
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),
128
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),
129
168
  ship_report: Object.keys(shipReport).length ? shipReport : void 0,
169
+ cleanup_report: cleanupReport,
130
170
  notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
131
171
  proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
132
172
  merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
@@ -134,6 +174,15 @@ function normalizeTerminalMetadata(input) {
134
174
  });
135
175
  }
136
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
+ }
137
186
  const prUrl = nonEmptyString(metadata.pr_url);
138
187
  if (prUrl) state.pr_url = prUrl;
139
188
  const prBranch = nonEmptyString(metadata.pr_branch);
@@ -146,6 +195,10 @@ function applyTerminalMetadata(state, metadata) {
146
195
  if (shipCommit) state.ship_commit = shipCommit;
147
196
  const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
148
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;
149
202
  const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
150
203
  if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
151
204
  const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
@@ -156,6 +209,8 @@ function applyTerminalMetadata(state, metadata) {
156
209
  if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
157
210
  const shipReport = recordValue(metadata.ship_report);
158
211
  if (shipReport) state.ship_report = shipReport;
212
+ const cleanupReport = recordValue(metadata.cleanup_report);
213
+ if (cleanupReport) state.cleanup_report = cleanupReport;
159
214
  const notification = recordValue(metadata.notification);
160
215
  if (notification) state.notification = notification;
161
216
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -185,16 +240,20 @@ function createRunResult(input) {
185
240
  event_count: state.events.length,
186
241
  pr_url: state.pr_url,
187
242
  pr_branch: state.pr_branch,
243
+ pr_state: state.pr_state,
188
244
  marked_ready: state.marked_ready,
189
245
  left_draft: state.left_draft,
190
246
  ci_status: state.ci_status,
191
247
  ship_commit: state.ship_commit,
192
248
  ship_remote_head: state.ship_remote_head,
249
+ merge_commit: state.merge_commit,
250
+ merged_at: state.merged_at,
193
251
  proof_comment_url: state.proof_comment_url,
194
252
  before_artifact_url: state.before_artifact_url,
195
253
  prod_artifact_url: state.prod_artifact_url,
196
254
  after_artifact_url: state.after_artifact_url,
197
255
  ship_report: state.ship_report,
256
+ cleanup_report: state.cleanup_report,
198
257
  notification: state.notification,
199
258
  proof_decision: state.proof_decision,
200
259
  merge_recommendation: state.merge_recommendation,
@@ -221,6 +280,36 @@ function elapsedMs(start, end) {
221
280
  if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
222
281
  return Math.max(0, endMs - startMs);
223
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
+ }
224
313
  function normalizeIntegrationContext(input, fallbackSource) {
225
314
  const value = recordValue(input);
226
315
  if (!value) {
@@ -344,6 +433,16 @@ function createRunStatusSnapshot(state, at = timestamp()) {
344
433
  state_path: state.state_path ?? null,
345
434
  worktree_path: state.worktree_path ?? null,
346
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,
347
446
  iterations: state.iterations,
348
447
  last_checkpoint: state.last_checkpoint ?? null,
349
448
  updated_at: state.updated_at,
@@ -359,6 +458,23 @@ function setRunStatus(state, status, at = timestamp()) {
359
458
  state.updated_at = at;
360
459
  return state;
361
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
+ }
362
478
 
363
479
  // src/runner.ts
364
480
  function errorDetails(error) {
@@ -947,10 +1063,12 @@ function stageFromCheckpoint(result) {
947
1063
  if (checkpoint.startsWith("implement_")) return "implement";
948
1064
  if (checkpoint.startsWith("verify_")) return "verify";
949
1065
  if (checkpoint.startsWith("ship_")) return "ship";
1066
+ if (checkpoint.startsWith("pr_sync_")) return "notify";
950
1067
  if (checkpoint.includes("capture")) return "prove";
951
1068
  return "setup";
952
1069
  }
953
1070
  function stageFromWorkflowParams(params) {
1071
+ if (params.action === "sync") return "notify";
954
1072
  const stage = nonEmptyString(params.advance_stage);
955
1073
  if (stage) return stage;
956
1074
  if (params.ship_after_verify) return "ship";
@@ -1257,6 +1375,21 @@ async function routeCheckpoint(request, state, result, agent, input) {
1257
1375
  terminal: terminalResult(state, "shipped", result, result.summary || "Riddle Proof shipped.")
1258
1376
  };
1259
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
+ }
1260
1393
  if (checkpoint === "verify_ship_ready") {
1261
1394
  const shipMode = effectiveShipMode(request, input.config);
1262
1395
  if (shipMode === "ship") {
@@ -1506,6 +1639,7 @@ async function runRiddleProofEngineHarness(input) {
1506
1639
  RIDDLE_PROOF_RUN_STATE_VERSION,
1507
1640
  appendRunEvent,
1508
1641
  appendStageHeartbeat,
1642
+ applyPrLifecycleState,
1509
1643
  applyTerminalMetadata,
1510
1644
  compactRecord,
1511
1645
  createDisabledRiddleProofAgentAdapter,
@@ -1516,6 +1650,7 @@ async function runRiddleProofEngineHarness(input) {
1516
1650
  isTerminalStatus,
1517
1651
  nonEmptyString,
1518
1652
  normalizeIntegrationContext,
1653
+ normalizePrLifecycleState,
1519
1654
  normalizeRunParams,
1520
1655
  normalizeTerminalMetadata,
1521
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-YWJENUSI.js";
5
+ } from "./chunk-75XY5SVT.js";
6
6
  import {
7
7
  runRiddleProof
8
- } from "./chunk-RMY27ZEW.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-AHQIV5QN.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-VFO5WY5X.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-AHQIV5QN.js";
4
+ } from "./chunk-SIQG3N6F.js";
5
5
  import {
6
6
  compactRecord
7
- } from "./chunk-VFO5WY5X.js";
7
+ } from "./chunk-TMMKRKY5.js";
8
8
 
9
9
  // src/openclaw.ts
10
10
  function parseOpenClawAssertions(value) {
package/dist/result.cjs CHANGED
@@ -58,6 +58,35 @@ function firstBoolean(...values) {
58
58
  }
59
59
  return void 0;
60
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
+ }
61
90
  function normalizeTerminalMetadata(input) {
62
91
  const riddleState = recordValue(input.riddleState) || {};
63
92
  const result = recordValue(input.engineResult) || {};
@@ -81,6 +110,10 @@ function normalizeTerminalMetadata(input) {
81
110
  shipReport.left_draft
82
111
  );
83
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);
84
117
  return compactRecord({
85
118
  pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
86
119
  pr_branch: firstNonEmptyString(
@@ -91,18 +124,23 @@ function normalizeTerminalMetadata(input) {
91
124
  details.pr_branch,
92
125
  details.prBranch,
93
126
  shipReport.pr_branch,
94
- shipReport.branch
127
+ shipReport.branch,
128
+ prState?.head_branch
95
129
  ),
130
+ pr_state: prState,
96
131
  marked_ready: markedReady,
97
132
  left_draft: leftDraft,
98
133
  ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
99
134
  ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
100
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),
101
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),
102
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),
103
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),
104
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),
105
142
  ship_report: Object.keys(shipReport).length ? shipReport : void 0,
143
+ cleanup_report: cleanupReport,
106
144
  notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
107
145
  proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
108
146
  merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
@@ -110,6 +148,15 @@ function normalizeTerminalMetadata(input) {
110
148
  });
111
149
  }
112
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
+ }
113
160
  const prUrl = nonEmptyString(metadata.pr_url);
114
161
  if (prUrl) state.pr_url = prUrl;
115
162
  const prBranch = nonEmptyString(metadata.pr_branch);
@@ -122,6 +169,10 @@ function applyTerminalMetadata(state, metadata) {
122
169
  if (shipCommit) state.ship_commit = shipCommit;
123
170
  const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
124
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;
125
176
  const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
126
177
  if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
127
178
  const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
@@ -132,6 +183,8 @@ function applyTerminalMetadata(state, metadata) {
132
183
  if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
133
184
  const shipReport = recordValue(metadata.ship_report);
134
185
  if (shipReport) state.ship_report = shipReport;
186
+ const cleanupReport = recordValue(metadata.cleanup_report);
187
+ if (cleanupReport) state.cleanup_report = cleanupReport;
135
188
  const notification = recordValue(metadata.notification);
136
189
  if (notification) state.notification = notification;
137
190
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -161,16 +214,20 @@ function createRunResult(input) {
161
214
  event_count: state.events.length,
162
215
  pr_url: state.pr_url,
163
216
  pr_branch: state.pr_branch,
217
+ pr_state: state.pr_state,
164
218
  marked_ready: state.marked_ready,
165
219
  left_draft: state.left_draft,
166
220
  ci_status: state.ci_status,
167
221
  ship_commit: state.ship_commit,
168
222
  ship_remote_head: state.ship_remote_head,
223
+ merge_commit: state.merge_commit,
224
+ merged_at: state.merged_at,
169
225
  proof_comment_url: state.proof_comment_url,
170
226
  before_artifact_url: state.before_artifact_url,
171
227
  prod_artifact_url: state.prod_artifact_url,
172
228
  after_artifact_url: state.after_artifact_url,
173
229
  ship_report: state.ship_report,
230
+ cleanup_report: state.cleanup_report,
174
231
  notification: state.notification,
175
232
  proof_decision: state.proof_decision,
176
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-VFO5WY5X.js";
10
+ } from "./chunk-TMMKRKY5.js";
11
11
  export {
12
12
  applyTerminalMetadata,
13
13
  compactRecord,
package/dist/runner.cjs CHANGED
@@ -38,6 +38,15 @@ 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;
43
52
  const prBranch = nonEmptyString(metadata.pr_branch);
@@ -50,6 +59,10 @@ function applyTerminalMetadata(state, metadata) {
50
59
  if (shipCommit) state.ship_commit = shipCommit;
51
60
  const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
52
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;
53
66
  const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
54
67
  if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
55
68
  const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
@@ -60,6 +73,8 @@ function applyTerminalMetadata(state, metadata) {
60
73
  if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
61
74
  const shipReport = recordValue(metadata.ship_report);
62
75
  if (shipReport) state.ship_report = shipReport;
76
+ const cleanupReport = recordValue(metadata.cleanup_report);
77
+ if (cleanupReport) state.cleanup_report = cleanupReport;
63
78
  const notification = recordValue(metadata.notification);
64
79
  if (notification) state.notification = notification;
65
80
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -89,16 +104,20 @@ function createRunResult(input) {
89
104
  event_count: state.events.length,
90
105
  pr_url: state.pr_url,
91
106
  pr_branch: state.pr_branch,
107
+ pr_state: state.pr_state,
92
108
  marked_ready: state.marked_ready,
93
109
  left_draft: state.left_draft,
94
110
  ci_status: state.ci_status,
95
111
  ship_commit: state.ship_commit,
96
112
  ship_remote_head: state.ship_remote_head,
113
+ merge_commit: state.merge_commit,
114
+ merged_at: state.merged_at,
97
115
  proof_comment_url: state.proof_comment_url,
98
116
  before_artifact_url: state.before_artifact_url,
99
117
  prod_artifact_url: state.prod_artifact_url,
100
118
  after_artifact_url: state.after_artifact_url,
101
119
  ship_report: state.ship_report,
120
+ cleanup_report: state.cleanup_report,
102
121
  notification: state.notification,
103
122
  proof_decision: state.proof_decision,
104
123
  merge_recommendation: state.merge_recommendation,
package/dist/runner.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-RMY27ZEW.js";
4
- import "./chunk-AHQIV5QN.js";
5
- import "./chunk-VFO5WY5X.js";
3
+ } from "./chunk-PM5Q26Q6.js";
4
+ import "./chunk-SIQG3N6F.js";
5
+ import "./chunk-TMMKRKY5.js";
6
6
  export {
7
7
  runRiddleProof
8
8
  };