@riddledc/riddle-proof 0.4.2 → 0.4.3

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.
@@ -2,7 +2,7 @@ import {
2
2
  compactRecord,
3
3
  nonEmptyString,
4
4
  recordValue
5
- } from "./chunk-5DC6YXN4.js";
5
+ } from "./chunk-VFO5WY5X.js";
6
6
 
7
7
  // src/state.ts
8
8
  var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
@@ -3,10 +3,10 @@ import {
3
3
  appendStageHeartbeat,
4
4
  createRunState,
5
5
  setRunStatus
6
- } from "./chunk-3XJJ4JOB.js";
6
+ } from "./chunk-AHQIV5QN.js";
7
7
  import {
8
8
  createRunResult
9
- } from "./chunk-5DC6YXN4.js";
9
+ } from "./chunk-VFO5WY5X.js";
10
10
 
11
11
  // src/runner.ts
12
12
  function errorDetails(error) {
@@ -0,0 +1,162 @@
1
+ // src/result.ts
2
+ function isTerminalStatus(status) {
3
+ return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
4
+ }
5
+ function isSuccessfulStatus(status) {
6
+ return status !== "blocked" && status !== "failed";
7
+ }
8
+ function compactRecord(input) {
9
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
10
+ }
11
+ function nonEmptyString(value) {
12
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
13
+ }
14
+ function recordValue(value) {
15
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
16
+ }
17
+ function firstNonEmptyString(...values) {
18
+ for (const value of values) {
19
+ const normalized = nonEmptyString(value);
20
+ if (normalized) return normalized;
21
+ }
22
+ return void 0;
23
+ }
24
+ function firstBoolean(...values) {
25
+ for (const value of values) {
26
+ if (typeof value === "boolean") return value;
27
+ }
28
+ return void 0;
29
+ }
30
+ function normalizeTerminalMetadata(input) {
31
+ const riddleState = recordValue(input.riddleState) || {};
32
+ const result = recordValue(input.engineResult) || {};
33
+ const contract = recordValue(result.checkpointContract) || {};
34
+ const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
35
+ const shipReport = recordValue(riddleState.ship_report) || recordValue(result.ship_report) || recordValue(result.shipReport) || recordValue(details.ship_report) || recordValue(details.shipReport) || {};
36
+ const markedReady = firstBoolean(
37
+ riddleState.marked_ready,
38
+ result.marked_ready,
39
+ result.markedReady,
40
+ details.marked_ready,
41
+ details.markedReady,
42
+ shipReport.marked_ready
43
+ );
44
+ const leftDraft = firstBoolean(
45
+ riddleState.left_draft,
46
+ result.left_draft,
47
+ result.leftDraft,
48
+ details.left_draft,
49
+ details.leftDraft,
50
+ shipReport.left_draft
51
+ );
52
+ const finalized = firstBoolean(riddleState.finalized, result.finalized, details.finalized);
53
+ return compactRecord({
54
+ pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
55
+ pr_branch: firstNonEmptyString(
56
+ riddleState.pr_branch,
57
+ riddleState.target_branch,
58
+ result.pr_branch,
59
+ result.prBranch,
60
+ details.pr_branch,
61
+ details.prBranch,
62
+ shipReport.pr_branch,
63
+ shipReport.branch
64
+ ),
65
+ marked_ready: markedReady,
66
+ left_draft: leftDraft,
67
+ ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
68
+ ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
69
+ ship_remote_head: firstNonEmptyString(riddleState.ship_remote_head, result.ship_remote_head, result.shipRemoteHead, details.ship_remote_head, details.shipRemoteHead, shipReport.ship_remote_head),
70
+ proof_comment_url: firstNonEmptyString(riddleState.proof_comment_url, result.proof_comment_url, result.proofCommentUrl, details.proof_comment_url, details.proofCommentUrl, shipReport.proof_comment_url),
71
+ 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),
72
+ 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),
73
+ 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),
74
+ ship_report: Object.keys(shipReport).length ? shipReport : void 0,
75
+ notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
76
+ proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
77
+ merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
78
+ finalized: typeof finalized === "boolean" ? finalized : void 0
79
+ });
80
+ }
81
+ function applyTerminalMetadata(state, metadata) {
82
+ const prUrl = nonEmptyString(metadata.pr_url);
83
+ if (prUrl) state.pr_url = prUrl;
84
+ const prBranch = nonEmptyString(metadata.pr_branch);
85
+ if (prBranch) state.pr_branch = prBranch;
86
+ if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
87
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
88
+ const ciStatus = nonEmptyString(metadata.ci_status);
89
+ if (ciStatus) state.ci_status = ciStatus;
90
+ const shipCommit = nonEmptyString(metadata.ship_commit);
91
+ if (shipCommit) state.ship_commit = shipCommit;
92
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
93
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
94
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
95
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
96
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
97
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
98
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
99
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
100
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
101
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
102
+ const shipReport = recordValue(metadata.ship_report);
103
+ if (shipReport) state.ship_report = shipReport;
104
+ const notification = recordValue(metadata.notification);
105
+ if (notification) state.notification = notification;
106
+ const proofDecision = nonEmptyString(metadata.proof_decision);
107
+ if (proofDecision) state.proof_decision = proofDecision;
108
+ const mergeRecommendation = nonEmptyString(metadata.merge_recommendation);
109
+ if (mergeRecommendation) state.merge_recommendation = mergeRecommendation;
110
+ if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
111
+ return state;
112
+ }
113
+ function createRunResult(input) {
114
+ const status = input.status || input.state.status;
115
+ const ok = isSuccessfulStatus(status);
116
+ const state = input.metadata ? applyTerminalMetadata(input.state, input.metadata) : input.state;
117
+ state.status = status;
118
+ state.ok = ok;
119
+ return compactRecord({
120
+ ok,
121
+ status,
122
+ run_id: state.run_id,
123
+ state_path: input.state_path ?? state.state_path ?? null,
124
+ worktree_path: state.worktree_path ?? null,
125
+ branch: state.branch ?? null,
126
+ current_stage: state.current_stage ?? null,
127
+ iterations: state.iterations,
128
+ last_checkpoint: state.last_checkpoint ?? null,
129
+ last_summary: input.last_summary ?? null,
130
+ event_count: state.events.length,
131
+ pr_url: state.pr_url,
132
+ pr_branch: state.pr_branch,
133
+ marked_ready: state.marked_ready,
134
+ left_draft: state.left_draft,
135
+ ci_status: state.ci_status,
136
+ ship_commit: state.ship_commit,
137
+ ship_remote_head: state.ship_remote_head,
138
+ proof_comment_url: state.proof_comment_url,
139
+ before_artifact_url: state.before_artifact_url,
140
+ prod_artifact_url: state.prod_artifact_url,
141
+ after_artifact_url: state.after_artifact_url,
142
+ ship_report: state.ship_report,
143
+ notification: state.notification,
144
+ proof_decision: state.proof_decision,
145
+ merge_recommendation: state.merge_recommendation,
146
+ finalized: state.finalized,
147
+ blocker: state.blocker,
148
+ evidence_bundle: input.evidence_bundle,
149
+ raw: input.raw
150
+ });
151
+ }
152
+
153
+ export {
154
+ isTerminalStatus,
155
+ isSuccessfulStatus,
156
+ compactRecord,
157
+ nonEmptyString,
158
+ recordValue,
159
+ normalizeTerminalMetadata,
160
+ applyTerminalMetadata,
161
+ createRunResult
162
+ };
@@ -5,7 +5,7 @@ import {
5
5
  createRunStatusSnapshot,
6
6
  normalizeRunParams,
7
7
  setRunStatus
8
- } from "./chunk-3XJJ4JOB.js";
8
+ } from "./chunk-AHQIV5QN.js";
9
9
  import {
10
10
  applyTerminalMetadata,
11
11
  compactRecord,
@@ -13,7 +13,7 @@ import {
13
13
  nonEmptyString,
14
14
  normalizeTerminalMetadata,
15
15
  recordValue
16
- } from "./chunk-5DC6YXN4.js";
16
+ } from "./chunk-VFO5WY5X.js";
17
17
 
18
18
  // src/engine-harness.ts
19
19
  import { execFileSync } from "child_process";
@@ -53,16 +53,64 @@ function nonEmptyString(value) {
53
53
  function recordValue(value) {
54
54
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
55
55
  }
56
+ function firstNonEmptyString(...values) {
57
+ for (const value of values) {
58
+ const normalized = nonEmptyString(value);
59
+ if (normalized) return normalized;
60
+ }
61
+ return void 0;
62
+ }
63
+ function firstBoolean(...values) {
64
+ for (const value of values) {
65
+ if (typeof value === "boolean") return value;
66
+ }
67
+ return void 0;
68
+ }
56
69
  function normalizeTerminalMetadata(input) {
57
70
  const riddleState = recordValue(input.riddleState) || {};
58
71
  const result = recordValue(input.engineResult) || {};
59
72
  const contract = recordValue(result.checkpointContract) || {};
60
73
  const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
61
- const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
62
- const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
74
+ const shipReport = recordValue(riddleState.ship_report) || recordValue(result.ship_report) || recordValue(result.shipReport) || recordValue(details.ship_report) || recordValue(details.shipReport) || {};
75
+ const markedReady = firstBoolean(
76
+ riddleState.marked_ready,
77
+ result.marked_ready,
78
+ result.markedReady,
79
+ details.marked_ready,
80
+ details.markedReady,
81
+ shipReport.marked_ready
82
+ );
83
+ const leftDraft = firstBoolean(
84
+ riddleState.left_draft,
85
+ result.left_draft,
86
+ result.leftDraft,
87
+ details.left_draft,
88
+ details.leftDraft,
89
+ shipReport.left_draft
90
+ );
91
+ const finalized = firstBoolean(riddleState.finalized, result.finalized, details.finalized);
63
92
  return compactRecord({
64
- pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
65
- marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
93
+ pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
94
+ pr_branch: firstNonEmptyString(
95
+ riddleState.pr_branch,
96
+ riddleState.target_branch,
97
+ result.pr_branch,
98
+ result.prBranch,
99
+ details.pr_branch,
100
+ details.prBranch,
101
+ shipReport.pr_branch,
102
+ shipReport.branch
103
+ ),
104
+ marked_ready: markedReady,
105
+ left_draft: leftDraft,
106
+ ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
107
+ ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
108
+ ship_remote_head: firstNonEmptyString(riddleState.ship_remote_head, result.ship_remote_head, result.shipRemoteHead, details.ship_remote_head, details.shipRemoteHead, shipReport.ship_remote_head),
109
+ proof_comment_url: firstNonEmptyString(riddleState.proof_comment_url, result.proof_comment_url, result.proofCommentUrl, details.proof_comment_url, details.proofCommentUrl, shipReport.proof_comment_url),
110
+ 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),
111
+ 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),
112
+ 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),
113
+ ship_report: Object.keys(shipReport).length ? shipReport : void 0,
66
114
  notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
67
115
  proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
68
116
  merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
@@ -72,7 +120,26 @@ function normalizeTerminalMetadata(input) {
72
120
  function applyTerminalMetadata(state, metadata) {
73
121
  const prUrl = nonEmptyString(metadata.pr_url);
74
122
  if (prUrl) state.pr_url = prUrl;
123
+ const prBranch = nonEmptyString(metadata.pr_branch);
124
+ if (prBranch) state.pr_branch = prBranch;
75
125
  if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
126
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
127
+ const ciStatus = nonEmptyString(metadata.ci_status);
128
+ if (ciStatus) state.ci_status = ciStatus;
129
+ const shipCommit = nonEmptyString(metadata.ship_commit);
130
+ if (shipCommit) state.ship_commit = shipCommit;
131
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
132
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
133
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
134
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
135
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
136
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
137
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
138
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
139
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
140
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
141
+ const shipReport = recordValue(metadata.ship_report);
142
+ if (shipReport) state.ship_report = shipReport;
76
143
  const notification = recordValue(metadata.notification);
77
144
  if (notification) state.notification = notification;
78
145
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -101,7 +168,17 @@ function createRunResult(input) {
101
168
  last_summary: input.last_summary ?? null,
102
169
  event_count: state.events.length,
103
170
  pr_url: state.pr_url,
171
+ pr_branch: state.pr_branch,
104
172
  marked_ready: state.marked_ready,
173
+ left_draft: state.left_draft,
174
+ ci_status: state.ci_status,
175
+ ship_commit: state.ship_commit,
176
+ ship_remote_head: state.ship_remote_head,
177
+ proof_comment_url: state.proof_comment_url,
178
+ before_artifact_url: state.before_artifact_url,
179
+ prod_artifact_url: state.prod_artifact_url,
180
+ after_artifact_url: state.after_artifact_url,
181
+ ship_report: state.ship_report,
105
182
  notification: state.notification,
106
183
  proof_decision: state.proof_decision,
107
184
  merge_recommendation: state.merge_recommendation,
@@ -2,9 +2,9 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-7DED7LM3.js";
6
- import "./chunk-3XJJ4JOB.js";
7
- import "./chunk-5DC6YXN4.js";
5
+ } from "./chunk-YWJENUSI.js";
6
+ import "./chunk-AHQIV5QN.js";
7
+ import "./chunk-VFO5WY5X.js";
8
8
  export {
9
9
  createDisabledRiddleProofAgentAdapter,
10
10
  readRiddleProofRunStatus,
package/dist/index.cjs CHANGED
@@ -69,16 +69,64 @@ function nonEmptyString(value) {
69
69
  function recordValue(value) {
70
70
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
71
71
  }
72
+ function firstNonEmptyString(...values) {
73
+ for (const value of values) {
74
+ const normalized = nonEmptyString(value);
75
+ if (normalized) return normalized;
76
+ }
77
+ return void 0;
78
+ }
79
+ function firstBoolean(...values) {
80
+ for (const value of values) {
81
+ if (typeof value === "boolean") return value;
82
+ }
83
+ return void 0;
84
+ }
72
85
  function normalizeTerminalMetadata(input) {
73
86
  const riddleState = recordValue(input.riddleState) || {};
74
87
  const result = recordValue(input.engineResult) || {};
75
88
  const contract = recordValue(result.checkpointContract) || {};
76
89
  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;
90
+ const shipReport = recordValue(riddleState.ship_report) || recordValue(result.ship_report) || recordValue(result.shipReport) || recordValue(details.ship_report) || recordValue(details.shipReport) || {};
91
+ const markedReady = firstBoolean(
92
+ riddleState.marked_ready,
93
+ result.marked_ready,
94
+ result.markedReady,
95
+ details.marked_ready,
96
+ details.markedReady,
97
+ shipReport.marked_ready
98
+ );
99
+ const leftDraft = firstBoolean(
100
+ riddleState.left_draft,
101
+ result.left_draft,
102
+ result.leftDraft,
103
+ details.left_draft,
104
+ details.leftDraft,
105
+ shipReport.left_draft
106
+ );
107
+ const finalized = firstBoolean(riddleState.finalized, result.finalized, details.finalized);
79
108
  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,
109
+ pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
110
+ pr_branch: firstNonEmptyString(
111
+ riddleState.pr_branch,
112
+ riddleState.target_branch,
113
+ result.pr_branch,
114
+ result.prBranch,
115
+ details.pr_branch,
116
+ details.prBranch,
117
+ shipReport.pr_branch,
118
+ shipReport.branch
119
+ ),
120
+ marked_ready: markedReady,
121
+ left_draft: leftDraft,
122
+ ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
123
+ ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
124
+ ship_remote_head: firstNonEmptyString(riddleState.ship_remote_head, result.ship_remote_head, result.shipRemoteHead, details.ship_remote_head, details.shipRemoteHead, shipReport.ship_remote_head),
125
+ 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
+ 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
+ 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
+ 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
+ ship_report: Object.keys(shipReport).length ? shipReport : void 0,
82
130
  notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
83
131
  proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
84
132
  merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
@@ -88,7 +136,26 @@ function normalizeTerminalMetadata(input) {
88
136
  function applyTerminalMetadata(state, metadata) {
89
137
  const prUrl = nonEmptyString(metadata.pr_url);
90
138
  if (prUrl) state.pr_url = prUrl;
139
+ const prBranch = nonEmptyString(metadata.pr_branch);
140
+ if (prBranch) state.pr_branch = prBranch;
91
141
  if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
142
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
143
+ const ciStatus = nonEmptyString(metadata.ci_status);
144
+ if (ciStatus) state.ci_status = ciStatus;
145
+ const shipCommit = nonEmptyString(metadata.ship_commit);
146
+ if (shipCommit) state.ship_commit = shipCommit;
147
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
148
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
149
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
150
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
151
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
152
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
153
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
154
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
155
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
156
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
157
+ const shipReport = recordValue(metadata.ship_report);
158
+ if (shipReport) state.ship_report = shipReport;
92
159
  const notification = recordValue(metadata.notification);
93
160
  if (notification) state.notification = notification;
94
161
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -117,7 +184,17 @@ function createRunResult(input) {
117
184
  last_summary: input.last_summary ?? null,
118
185
  event_count: state.events.length,
119
186
  pr_url: state.pr_url,
187
+ pr_branch: state.pr_branch,
120
188
  marked_ready: state.marked_ready,
189
+ left_draft: state.left_draft,
190
+ ci_status: state.ci_status,
191
+ ship_commit: state.ship_commit,
192
+ ship_remote_head: state.ship_remote_head,
193
+ proof_comment_url: state.proof_comment_url,
194
+ before_artifact_url: state.before_artifact_url,
195
+ prod_artifact_url: state.prod_artifact_url,
196
+ after_artifact_url: state.after_artifact_url,
197
+ ship_report: state.ship_report,
121
198
  notification: state.notification,
122
199
  proof_decision: state.proof_decision,
123
200
  merge_recommendation: state.merge_recommendation,
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-7DED7LM3.js";
5
+ } from "./chunk-YWJENUSI.js";
6
6
  import {
7
7
  runRiddleProof
8
- } from "./chunk-CL2FOOXX.js";
8
+ } from "./chunk-RMY27ZEW.js";
9
9
  import {
10
10
  RIDDLE_PROOF_RUN_STATE_VERSION,
11
11
  appendRunEvent,
@@ -15,7 +15,7 @@ import {
15
15
  normalizeIntegrationContext,
16
16
  normalizeRunParams,
17
17
  setRunStatus
18
- } from "./chunk-3XJJ4JOB.js";
18
+ } from "./chunk-AHQIV5QN.js";
19
19
  import {
20
20
  applyTerminalMetadata,
21
21
  compactRecord,
@@ -25,7 +25,7 @@ import {
25
25
  nonEmptyString,
26
26
  normalizeTerminalMetadata,
27
27
  recordValue
28
- } from "./chunk-5DC6YXN4.js";
28
+ } from "./chunk-VFO5WY5X.js";
29
29
  import "./chunk-6F4PWJZI.js";
30
30
  export {
31
31
  RIDDLE_PROOF_RUN_STATE_VERSION,
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-AHQIV5QN.js";
5
5
  import {
6
6
  compactRecord
7
- } from "./chunk-5DC6YXN4.js";
7
+ } from "./chunk-VFO5WY5X.js";
8
8
 
9
9
  // src/openclaw.ts
10
10
  function parseOpenClawAssertions(value) {
package/dist/result.cjs CHANGED
@@ -45,16 +45,64 @@ 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
+ }
48
61
  function normalizeTerminalMetadata(input) {
49
62
  const riddleState = recordValue(input.riddleState) || {};
50
63
  const result = recordValue(input.engineResult) || {};
51
64
  const contract = recordValue(result.checkpointContract) || {};
52
65
  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;
66
+ const shipReport = recordValue(riddleState.ship_report) || recordValue(result.ship_report) || recordValue(result.shipReport) || recordValue(details.ship_report) || recordValue(details.shipReport) || {};
67
+ const markedReady = firstBoolean(
68
+ riddleState.marked_ready,
69
+ result.marked_ready,
70
+ result.markedReady,
71
+ details.marked_ready,
72
+ details.markedReady,
73
+ shipReport.marked_ready
74
+ );
75
+ const leftDraft = firstBoolean(
76
+ riddleState.left_draft,
77
+ result.left_draft,
78
+ result.leftDraft,
79
+ details.left_draft,
80
+ details.leftDraft,
81
+ shipReport.left_draft
82
+ );
83
+ const finalized = firstBoolean(riddleState.finalized, result.finalized, details.finalized);
55
84
  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,
85
+ pr_url: firstNonEmptyString(riddleState.pr_url, result.pr_url, result.prUrl, details.pr_url, details.prUrl, shipReport.pr_url),
86
+ pr_branch: firstNonEmptyString(
87
+ riddleState.pr_branch,
88
+ riddleState.target_branch,
89
+ result.pr_branch,
90
+ result.prBranch,
91
+ details.pr_branch,
92
+ details.prBranch,
93
+ shipReport.pr_branch,
94
+ shipReport.branch
95
+ ),
96
+ marked_ready: markedReady,
97
+ left_draft: leftDraft,
98
+ ci_status: firstNonEmptyString(riddleState.ci_status, result.ci_status, result.ciStatus, details.ci_status, details.ciStatus, shipReport.ci_status),
99
+ ship_commit: firstNonEmptyString(riddleState.ship_commit, result.ship_commit, result.shipCommit, details.ship_commit, details.shipCommit, shipReport.shipped_commit, shipReport.ship_commit),
100
+ ship_remote_head: firstNonEmptyString(riddleState.ship_remote_head, result.ship_remote_head, result.shipRemoteHead, details.ship_remote_head, details.shipRemoteHead, shipReport.ship_remote_head),
101
+ 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
+ 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
+ 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
+ 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
+ ship_report: Object.keys(shipReport).length ? shipReport : void 0,
58
106
  notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
59
107
  proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
60
108
  merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
@@ -64,7 +112,26 @@ function normalizeTerminalMetadata(input) {
64
112
  function applyTerminalMetadata(state, metadata) {
65
113
  const prUrl = nonEmptyString(metadata.pr_url);
66
114
  if (prUrl) state.pr_url = prUrl;
115
+ const prBranch = nonEmptyString(metadata.pr_branch);
116
+ if (prBranch) state.pr_branch = prBranch;
67
117
  if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
118
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
119
+ const ciStatus = nonEmptyString(metadata.ci_status);
120
+ if (ciStatus) state.ci_status = ciStatus;
121
+ const shipCommit = nonEmptyString(metadata.ship_commit);
122
+ if (shipCommit) state.ship_commit = shipCommit;
123
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
124
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
125
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
126
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
127
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
128
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
129
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
130
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
131
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
132
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
133
+ const shipReport = recordValue(metadata.ship_report);
134
+ if (shipReport) state.ship_report = shipReport;
68
135
  const notification = recordValue(metadata.notification);
69
136
  if (notification) state.notification = notification;
70
137
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -93,7 +160,17 @@ function createRunResult(input) {
93
160
  last_summary: input.last_summary ?? null,
94
161
  event_count: state.events.length,
95
162
  pr_url: state.pr_url,
163
+ pr_branch: state.pr_branch,
96
164
  marked_ready: state.marked_ready,
165
+ left_draft: state.left_draft,
166
+ ci_status: state.ci_status,
167
+ ship_commit: state.ship_commit,
168
+ ship_remote_head: state.ship_remote_head,
169
+ proof_comment_url: state.proof_comment_url,
170
+ before_artifact_url: state.before_artifact_url,
171
+ prod_artifact_url: state.prod_artifact_url,
172
+ after_artifact_url: state.after_artifact_url,
173
+ ship_report: state.ship_report,
97
174
  notification: state.notification,
98
175
  proof_decision: state.proof_decision,
99
176
  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-VFO5WY5X.js";
11
11
  export {
12
12
  applyTerminalMetadata,
13
13
  compactRecord,
package/dist/runner.cjs CHANGED
@@ -40,7 +40,26 @@ function recordValue(value) {
40
40
  function applyTerminalMetadata(state, metadata) {
41
41
  const prUrl = nonEmptyString(metadata.pr_url);
42
42
  if (prUrl) state.pr_url = prUrl;
43
+ const prBranch = nonEmptyString(metadata.pr_branch);
44
+ if (prBranch) state.pr_branch = prBranch;
43
45
  if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
46
+ if (typeof metadata.left_draft === "boolean") state.left_draft = metadata.left_draft;
47
+ const ciStatus = nonEmptyString(metadata.ci_status);
48
+ if (ciStatus) state.ci_status = ciStatus;
49
+ const shipCommit = nonEmptyString(metadata.ship_commit);
50
+ if (shipCommit) state.ship_commit = shipCommit;
51
+ const shipRemoteHead = nonEmptyString(metadata.ship_remote_head);
52
+ if (shipRemoteHead) state.ship_remote_head = shipRemoteHead;
53
+ const proofCommentUrl = nonEmptyString(metadata.proof_comment_url);
54
+ if (proofCommentUrl) state.proof_comment_url = proofCommentUrl;
55
+ const beforeArtifactUrl = nonEmptyString(metadata.before_artifact_url);
56
+ if (beforeArtifactUrl) state.before_artifact_url = beforeArtifactUrl;
57
+ const prodArtifactUrl = nonEmptyString(metadata.prod_artifact_url);
58
+ if (prodArtifactUrl) state.prod_artifact_url = prodArtifactUrl;
59
+ const afterArtifactUrl = nonEmptyString(metadata.after_artifact_url);
60
+ if (afterArtifactUrl) state.after_artifact_url = afterArtifactUrl;
61
+ const shipReport = recordValue(metadata.ship_report);
62
+ if (shipReport) state.ship_report = shipReport;
44
63
  const notification = recordValue(metadata.notification);
45
64
  if (notification) state.notification = notification;
46
65
  const proofDecision = nonEmptyString(metadata.proof_decision);
@@ -69,7 +88,17 @@ function createRunResult(input) {
69
88
  last_summary: input.last_summary ?? null,
70
89
  event_count: state.events.length,
71
90
  pr_url: state.pr_url,
91
+ pr_branch: state.pr_branch,
72
92
  marked_ready: state.marked_ready,
93
+ left_draft: state.left_draft,
94
+ ci_status: state.ci_status,
95
+ ship_commit: state.ship_commit,
96
+ ship_remote_head: state.ship_remote_head,
97
+ proof_comment_url: state.proof_comment_url,
98
+ before_artifact_url: state.before_artifact_url,
99
+ prod_artifact_url: state.prod_artifact_url,
100
+ after_artifact_url: state.after_artifact_url,
101
+ ship_report: state.ship_report,
73
102
  notification: state.notification,
74
103
  proof_decision: state.proof_decision,
75
104
  merge_recommendation: state.merge_recommendation,
package/dist/runner.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-CL2FOOXX.js";
4
- import "./chunk-3XJJ4JOB.js";
5
- import "./chunk-5DC6YXN4.js";
3
+ } from "./chunk-RMY27ZEW.js";
4
+ import "./chunk-AHQIV5QN.js";
5
+ import "./chunk-VFO5WY5X.js";
6
6
  export {
7
7
  runRiddleProof
8
8
  };
package/dist/state.js CHANGED
@@ -7,8 +7,8 @@ import {
7
7
  normalizeIntegrationContext,
8
8
  normalizeRunParams,
9
9
  setRunStatus
10
- } from "./chunk-3XJJ4JOB.js";
11
- import "./chunk-5DC6YXN4.js";
10
+ } from "./chunk-AHQIV5QN.js";
11
+ import "./chunk-VFO5WY5X.js";
12
12
  export {
13
13
  RIDDLE_PROOF_RUN_STATE_VERSION,
14
14
  appendRunEvent,
package/dist/types.d.cts CHANGED
@@ -81,7 +81,17 @@ interface RiddleProofRunState {
81
81
  iterations: number;
82
82
  last_checkpoint?: string | null;
83
83
  pr_url?: string;
84
+ pr_branch?: string;
84
85
  marked_ready?: boolean;
86
+ left_draft?: boolean;
87
+ ci_status?: string;
88
+ ship_commit?: string;
89
+ ship_remote_head?: string;
90
+ proof_comment_url?: string;
91
+ before_artifact_url?: string;
92
+ prod_artifact_url?: string;
93
+ after_artifact_url?: string;
94
+ ship_report?: Record<string, unknown>;
85
95
  notification?: Record<string, unknown>;
86
96
  proof_decision?: RiddleProofDecision;
87
97
  merge_recommendation?: string;
@@ -102,7 +112,17 @@ interface RiddleProofRunResult {
102
112
  last_summary?: string | null;
103
113
  event_count?: number;
104
114
  pr_url?: string;
115
+ pr_branch?: string;
105
116
  marked_ready?: boolean;
117
+ left_draft?: boolean;
118
+ ci_status?: string;
119
+ ship_commit?: string;
120
+ ship_remote_head?: string;
121
+ proof_comment_url?: string;
122
+ before_artifact_url?: string;
123
+ prod_artifact_url?: string;
124
+ after_artifact_url?: string;
125
+ ship_report?: Record<string, unknown>;
106
126
  notification?: Record<string, unknown>;
107
127
  proof_decision?: RiddleProofDecision;
108
128
  merge_recommendation?: string;
@@ -134,6 +154,7 @@ interface RiddleProofEvidenceBundle {
134
154
  proof_evidence?: unknown;
135
155
  proof_evidence_sample?: unknown;
136
156
  assertions?: JsonValue;
157
+ semantic_context?: Record<string, unknown>;
137
158
  summary?: string;
138
159
  notes?: string[];
139
160
  }
@@ -247,7 +268,17 @@ interface NotificationAdapter {
247
268
  }
248
269
  interface RiddleProofTerminalMetadata {
249
270
  pr_url?: string;
271
+ pr_branch?: string;
250
272
  marked_ready?: boolean;
273
+ left_draft?: boolean;
274
+ ci_status?: string;
275
+ ship_commit?: string;
276
+ ship_remote_head?: string;
277
+ proof_comment_url?: string;
278
+ before_artifact_url?: string;
279
+ prod_artifact_url?: string;
280
+ after_artifact_url?: string;
281
+ ship_report?: Record<string, unknown>;
251
282
  notification?: Record<string, unknown>;
252
283
  proof_decision?: RiddleProofDecision;
253
284
  merge_recommendation?: string;
package/dist/types.d.ts CHANGED
@@ -81,7 +81,17 @@ interface RiddleProofRunState {
81
81
  iterations: number;
82
82
  last_checkpoint?: string | null;
83
83
  pr_url?: string;
84
+ pr_branch?: string;
84
85
  marked_ready?: boolean;
86
+ left_draft?: boolean;
87
+ ci_status?: string;
88
+ ship_commit?: string;
89
+ ship_remote_head?: string;
90
+ proof_comment_url?: string;
91
+ before_artifact_url?: string;
92
+ prod_artifact_url?: string;
93
+ after_artifact_url?: string;
94
+ ship_report?: Record<string, unknown>;
85
95
  notification?: Record<string, unknown>;
86
96
  proof_decision?: RiddleProofDecision;
87
97
  merge_recommendation?: string;
@@ -102,7 +112,17 @@ interface RiddleProofRunResult {
102
112
  last_summary?: string | null;
103
113
  event_count?: number;
104
114
  pr_url?: string;
115
+ pr_branch?: string;
105
116
  marked_ready?: boolean;
117
+ left_draft?: boolean;
118
+ ci_status?: string;
119
+ ship_commit?: string;
120
+ ship_remote_head?: string;
121
+ proof_comment_url?: string;
122
+ before_artifact_url?: string;
123
+ prod_artifact_url?: string;
124
+ after_artifact_url?: string;
125
+ ship_report?: Record<string, unknown>;
106
126
  notification?: Record<string, unknown>;
107
127
  proof_decision?: RiddleProofDecision;
108
128
  merge_recommendation?: string;
@@ -134,6 +154,7 @@ interface RiddleProofEvidenceBundle {
134
154
  proof_evidence?: unknown;
135
155
  proof_evidence_sample?: unknown;
136
156
  assertions?: JsonValue;
157
+ semantic_context?: Record<string, unknown>;
137
158
  summary?: string;
138
159
  notes?: string[];
139
160
  }
@@ -247,7 +268,17 @@ interface NotificationAdapter {
247
268
  }
248
269
  interface RiddleProofTerminalMetadata {
249
270
  pr_url?: string;
271
+ pr_branch?: string;
250
272
  marked_ready?: boolean;
273
+ left_draft?: boolean;
274
+ ci_status?: string;
275
+ ship_commit?: string;
276
+ ship_remote_head?: string;
277
+ proof_comment_url?: string;
278
+ before_artifact_url?: string;
279
+ prod_artifact_url?: string;
280
+ after_artifact_url?: string;
281
+ ship_report?: Record<string, unknown>;
251
282
  notification?: Record<string, unknown>;
252
283
  proof_decision?: RiddleProofDecision;
253
284
  merge_recommendation?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",
@@ -1,85 +0,0 @@
1
- // src/result.ts
2
- function isTerminalStatus(status) {
3
- return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
4
- }
5
- function isSuccessfulStatus(status) {
6
- return status !== "blocked" && status !== "failed";
7
- }
8
- function compactRecord(input) {
9
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
10
- }
11
- function nonEmptyString(value) {
12
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
13
- }
14
- function recordValue(value) {
15
- return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
16
- }
17
- function normalizeTerminalMetadata(input) {
18
- const riddleState = recordValue(input.riddleState) || {};
19
- const result = recordValue(input.engineResult) || {};
20
- const contract = recordValue(result.checkpointContract) || {};
21
- const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
22
- const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
23
- const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
24
- return compactRecord({
25
- pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
26
- marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
27
- notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
28
- proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
29
- merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
30
- finalized: typeof finalized === "boolean" ? finalized : void 0
31
- });
32
- }
33
- function applyTerminalMetadata(state, metadata) {
34
- const prUrl = nonEmptyString(metadata.pr_url);
35
- if (prUrl) state.pr_url = prUrl;
36
- if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
37
- const notification = recordValue(metadata.notification);
38
- if (notification) state.notification = notification;
39
- const proofDecision = nonEmptyString(metadata.proof_decision);
40
- if (proofDecision) state.proof_decision = proofDecision;
41
- const mergeRecommendation = nonEmptyString(metadata.merge_recommendation);
42
- if (mergeRecommendation) state.merge_recommendation = mergeRecommendation;
43
- if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
44
- return state;
45
- }
46
- function createRunResult(input) {
47
- const status = input.status || input.state.status;
48
- const ok = isSuccessfulStatus(status);
49
- const state = input.metadata ? applyTerminalMetadata(input.state, input.metadata) : input.state;
50
- state.status = status;
51
- state.ok = ok;
52
- return compactRecord({
53
- ok,
54
- status,
55
- run_id: state.run_id,
56
- state_path: input.state_path ?? state.state_path ?? null,
57
- worktree_path: state.worktree_path ?? null,
58
- branch: state.branch ?? null,
59
- current_stage: state.current_stage ?? null,
60
- iterations: state.iterations,
61
- last_checkpoint: state.last_checkpoint ?? null,
62
- last_summary: input.last_summary ?? null,
63
- event_count: state.events.length,
64
- pr_url: state.pr_url,
65
- marked_ready: state.marked_ready,
66
- notification: state.notification,
67
- proof_decision: state.proof_decision,
68
- merge_recommendation: state.merge_recommendation,
69
- finalized: state.finalized,
70
- blocker: state.blocker,
71
- evidence_bundle: input.evidence_bundle,
72
- raw: input.raw
73
- });
74
- }
75
-
76
- export {
77
- isTerminalStatus,
78
- isSuccessfulStatus,
79
- compactRecord,
80
- nonEmptyString,
81
- recordValue,
82
- normalizeTerminalMetadata,
83
- applyTerminalMetadata,
84
- createRunResult
85
- };