@riddledc/riddle-proof 0.4.1 → 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.
package/README.md CHANGED
@@ -71,15 +71,19 @@ events and return `createRunStatusSnapshot` for cheap observer status.
71
71
 
72
72
  The proof adapter is where a host wires Riddle server-backed capture. The ship
73
73
  adapter is where a host commits, pushes, opens or updates a PR, and waits for CI
74
- when configured. The notification adapter is where a host updates Discord,
75
- OpenClaw, GitHub, or another integration.
74
+ when configured. `ship_mode: "ship"` is expected to drive the happy path all the
75
+ way to a ready PR after proof and CI; `leave_draft: true` is only an explicit
76
+ debug or user-request escape hatch. The notification adapter is where a host
77
+ updates Discord, OpenClaw, GitHub, or another integration.
76
78
 
77
79
  ## OpenClaw Adapter Boundary
78
80
 
79
81
  `@riddledc/riddle-proof/openclaw` translates the current
80
82
  `proofed_change_run`-style tool params into generic `RiddleProofRunParams`.
81
83
  It preserves Discord routing metadata as `integration_context` and parses
82
- `assertions_json` into the shared assertions field.
84
+ `assertions_json` into the shared assertions field. Compatibility params such as
85
+ `ship_after_verify` and the explicit `leave_draft` escape hatch are preserved so
86
+ the underlying runtime can distinguish "do not merge" from "keep this draft."
83
87
 
84
88
  The adapter does not invoke another OpenClaw plugin and does not supply a
85
89
  coding agent. It is the reusable mapping layer a future OpenClaw wrapper can
@@ -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";
@@ -63,6 +63,7 @@ function normalizeRunParams(input) {
63
63
  color_scheme: input.color_scheme,
64
64
  wait_for_selector: input.wait_for_selector,
65
65
  ship_mode: input.ship_mode,
66
+ leave_draft: input.leave_draft,
66
67
  engine_state_path: input.engine_state_path,
67
68
  harness_state_path: input.harness_state_path,
68
69
  max_iterations: input.max_iterations,
@@ -3,10 +3,10 @@ import {
3
3
  appendStageHeartbeat,
4
4
  createRunState,
5
5
  setRunStatus
6
- } from "./chunk-5FHUOSNO.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-5FHUOSNO.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";
@@ -175,6 +175,7 @@ function initialRunParams(request, input, state) {
175
175
  use_auth: request.use_auth,
176
176
  color_scheme: request.color_scheme,
177
177
  wait_for_selector: request.wait_for_selector,
178
+ leave_draft: request.leave_draft || void 0,
178
179
  discord_channel: request.integration_context?.channel_id,
179
180
  discord_thread_id: request.integration_context?.thread_id,
180
181
  discord_message_id: request.integration_context?.message_id,
@@ -577,7 +578,8 @@ async function runRiddleProofEngineHarness(input) {
577
578
  state_path: state.state_path,
578
579
  engine_state_path: request.engine_state_path || null,
579
580
  max_iterations: maxIterations,
580
- ship_mode: effectiveShipMode(request, input.config)
581
+ ship_mode: effectiveShipMode(request, input.config),
582
+ leave_draft: request.leave_draft || false
581
583
  }
582
584
  });
583
585
  let engine;
@@ -594,6 +596,9 @@ async function runRiddleProofEngineHarness(input) {
594
596
  let nextParams = input.resume_params || initialRunParams(request, input, state);
595
597
  let lastResult = null;
596
598
  for (let index = 0; index < maxIterations; index += 1) {
599
+ if (request.leave_draft && nextParams.leave_draft === void 0) {
600
+ nextParams = { ...nextParams, leave_draft: true };
601
+ }
597
602
  state.iterations += 1;
598
603
  const stage = stageFromWorkflowParams(nextParams);
599
604
  heartbeat(state, {
@@ -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,
@@ -171,6 +248,7 @@ function normalizeRunParams(input) {
171
248
  color_scheme: input.color_scheme,
172
249
  wait_for_selector: input.wait_for_selector,
173
250
  ship_mode: input.ship_mode,
251
+ leave_draft: input.leave_draft,
174
252
  engine_state_path: input.engine_state_path,
175
253
  harness_state_path: input.harness_state_path,
176
254
  max_iterations: input.max_iterations,
@@ -415,6 +493,7 @@ function initialRunParams(request, input, state) {
415
493
  use_auth: request.use_auth,
416
494
  color_scheme: request.color_scheme,
417
495
  wait_for_selector: request.wait_for_selector,
496
+ leave_draft: request.leave_draft || void 0,
418
497
  discord_channel: request.integration_context?.channel_id,
419
498
  discord_thread_id: request.integration_context?.thread_id,
420
499
  discord_message_id: request.integration_context?.message_id,
@@ -817,7 +896,8 @@ async function runRiddleProofEngineHarness(input) {
817
896
  state_path: state.state_path,
818
897
  engine_state_path: request.engine_state_path || null,
819
898
  max_iterations: maxIterations,
820
- ship_mode: effectiveShipMode(request, input.config)
899
+ ship_mode: effectiveShipMode(request, input.config),
900
+ leave_draft: request.leave_draft || false
821
901
  }
822
902
  });
823
903
  let engine;
@@ -834,6 +914,9 @@ async function runRiddleProofEngineHarness(input) {
834
914
  let nextParams = input.resume_params || initialRunParams(request, input, state);
835
915
  let lastResult = null;
836
916
  for (let index = 0; index < maxIterations; index += 1) {
917
+ if (request.leave_draft && nextParams.leave_draft === void 0) {
918
+ nextParams = { ...nextParams, leave_draft: true };
919
+ }
837
920
  state.iterations += 1;
838
921
  const stage = stageFromWorkflowParams(nextParams);
839
922
  heartbeat(state, {
@@ -4,6 +4,7 @@ type RiddleProofShipMode = "none" | "ship";
4
4
  interface RiddleProofWorkflowParams extends Record<string, unknown> {
5
5
  action: string;
6
6
  state_path?: string;
7
+ leave_draft?: boolean;
7
8
  }
8
9
  interface RiddleProofEngineResult extends Record<string, unknown> {
9
10
  ok?: boolean;
@@ -4,6 +4,7 @@ type RiddleProofShipMode = "none" | "ship";
4
4
  interface RiddleProofWorkflowParams extends Record<string, unknown> {
5
5
  action: string;
6
6
  state_path?: string;
7
+ leave_draft?: boolean;
7
8
  }
8
9
  interface RiddleProofEngineResult extends Record<string, unknown> {
9
10
  ok?: boolean;
@@ -2,9 +2,9 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-UON7C6N4.js";
6
- import "./chunk-5FHUOSNO.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,
@@ -187,6 +264,7 @@ function normalizeRunParams(input) {
187
264
  color_scheme: input.color_scheme,
188
265
  wait_for_selector: input.wait_for_selector,
189
266
  ship_mode: input.ship_mode,
267
+ leave_draft: input.leave_draft,
190
268
  engine_state_path: input.engine_state_path,
191
269
  harness_state_path: input.harness_state_path,
192
270
  max_iterations: input.max_iterations,
@@ -917,6 +995,7 @@ function initialRunParams(request, input, state) {
917
995
  use_auth: request.use_auth,
918
996
  color_scheme: request.color_scheme,
919
997
  wait_for_selector: request.wait_for_selector,
998
+ leave_draft: request.leave_draft || void 0,
920
999
  discord_channel: request.integration_context?.channel_id,
921
1000
  discord_thread_id: request.integration_context?.thread_id,
922
1001
  discord_message_id: request.integration_context?.message_id,
@@ -1319,7 +1398,8 @@ async function runRiddleProofEngineHarness(input) {
1319
1398
  state_path: state.state_path,
1320
1399
  engine_state_path: request.engine_state_path || null,
1321
1400
  max_iterations: maxIterations,
1322
- ship_mode: effectiveShipMode(request, input.config)
1401
+ ship_mode: effectiveShipMode(request, input.config),
1402
+ leave_draft: request.leave_draft || false
1323
1403
  }
1324
1404
  });
1325
1405
  let engine;
@@ -1336,6 +1416,9 @@ async function runRiddleProofEngineHarness(input) {
1336
1416
  let nextParams = input.resume_params || initialRunParams(request, input, state);
1337
1417
  let lastResult = null;
1338
1418
  for (let index = 0; index < maxIterations; index += 1) {
1419
+ if (request.leave_draft && nextParams.leave_draft === void 0) {
1420
+ nextParams = { ...nextParams, leave_draft: true };
1421
+ }
1339
1422
  state.iterations += 1;
1340
1423
  const stage = stageFromWorkflowParams(nextParams);
1341
1424
  heartbeat(state, {
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-UON7C6N4.js";
5
+ } from "./chunk-YWJENUSI.js";
6
6
  import {
7
7
  runRiddleProof
8
- } from "./chunk-F65YYXVO.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-5FHUOSNO.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.cjs CHANGED
@@ -81,6 +81,7 @@ function normalizeRunParams(input) {
81
81
  color_scheme: input.color_scheme,
82
82
  wait_for_selector: input.wait_for_selector,
83
83
  ship_mode: input.ship_mode,
84
+ leave_draft: input.leave_draft,
84
85
  engine_state_path: input.engine_state_path,
85
86
  harness_state_path: input.harness_state_path,
86
87
  max_iterations: input.max_iterations,
@@ -144,6 +145,7 @@ function toRiddleProofRunParams(params) {
144
145
  color_scheme: params.color_scheme,
145
146
  wait_for_selector: params.wait_for_selector,
146
147
  ship_mode: params.ship_mode || (params.ship_after_verify ? "ship" : void 0),
148
+ leave_draft: params.leave_draft,
147
149
  engine_state_path: params.state_path,
148
150
  harness_state_path: params.harness_state_path,
149
151
  max_iterations: params.max_iterations,
@@ -28,6 +28,7 @@ interface OpenClawProofedChangeParams {
28
28
  wait_for_selector?: string;
29
29
  ship_after_verify?: boolean;
30
30
  ship_mode?: "none" | "ship";
31
+ leave_draft?: boolean;
31
32
  state_path?: string;
32
33
  harness_state_path?: string;
33
34
  max_iterations?: number;
@@ -28,6 +28,7 @@ interface OpenClawProofedChangeParams {
28
28
  wait_for_selector?: string;
29
29
  ship_after_verify?: boolean;
30
30
  ship_mode?: "none" | "ship";
31
+ leave_draft?: boolean;
31
32
  state_path?: string;
32
33
  harness_state_path?: string;
33
34
  max_iterations?: number;
package/dist/openclaw.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  normalizeIntegrationContext,
3
3
  normalizeRunParams
4
- } from "./chunk-5FHUOSNO.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) {
@@ -60,6 +60,7 @@ function toRiddleProofRunParams(params) {
60
60
  color_scheme: params.color_scheme,
61
61
  wait_for_selector: params.wait_for_selector,
62
62
  ship_mode: params.ship_mode || (params.ship_after_verify ? "ship" : void 0),
63
+ leave_draft: params.leave_draft,
63
64
  engine_state_path: params.state_path,
64
65
  harness_state_path: params.harness_state_path,
65
66
  max_iterations: params.max_iterations,
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,
@@ -139,6 +168,7 @@ function normalizeRunParams(input) {
139
168
  color_scheme: input.color_scheme,
140
169
  wait_for_selector: input.wait_for_selector,
141
170
  ship_mode: input.ship_mode,
171
+ leave_draft: input.leave_draft,
142
172
  engine_state_path: input.engine_state_path,
143
173
  harness_state_path: input.harness_state_path,
144
174
  max_iterations: input.max_iterations,
package/dist/runner.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-F65YYXVO.js";
4
- import "./chunk-5FHUOSNO.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.cjs CHANGED
@@ -101,6 +101,7 @@ function normalizeRunParams(input) {
101
101
  color_scheme: input.color_scheme,
102
102
  wait_for_selector: input.wait_for_selector,
103
103
  ship_mode: input.ship_mode,
104
+ leave_draft: input.leave_draft,
104
105
  engine_state_path: input.engine_state_path,
105
106
  harness_state_path: input.harness_state_path,
106
107
  max_iterations: input.max_iterations,
package/dist/state.js CHANGED
@@ -7,8 +7,8 @@ import {
7
7
  normalizeIntegrationContext,
8
8
  normalizeRunParams,
9
9
  setRunStatus
10
- } from "./chunk-5FHUOSNO.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
@@ -35,6 +35,7 @@ interface RiddleProofRunParams {
35
35
  color_scheme?: "dark" | "light" | (string & {});
36
36
  wait_for_selector?: string;
37
37
  ship_mode?: "none" | "ship";
38
+ leave_draft?: boolean;
38
39
  engine_state_path?: string;
39
40
  harness_state_path?: string;
40
41
  max_iterations?: number;
@@ -80,7 +81,17 @@ interface RiddleProofRunState {
80
81
  iterations: number;
81
82
  last_checkpoint?: string | null;
82
83
  pr_url?: string;
84
+ pr_branch?: string;
83
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>;
84
95
  notification?: Record<string, unknown>;
85
96
  proof_decision?: RiddleProofDecision;
86
97
  merge_recommendation?: string;
@@ -101,7 +112,17 @@ interface RiddleProofRunResult {
101
112
  last_summary?: string | null;
102
113
  event_count?: number;
103
114
  pr_url?: string;
115
+ pr_branch?: string;
104
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>;
105
126
  notification?: Record<string, unknown>;
106
127
  proof_decision?: RiddleProofDecision;
107
128
  merge_recommendation?: string;
@@ -133,6 +154,7 @@ interface RiddleProofEvidenceBundle {
133
154
  proof_evidence?: unknown;
134
155
  proof_evidence_sample?: unknown;
135
156
  assertions?: JsonValue;
157
+ semantic_context?: Record<string, unknown>;
136
158
  summary?: string;
137
159
  notes?: string[];
138
160
  }
@@ -246,7 +268,17 @@ interface NotificationAdapter {
246
268
  }
247
269
  interface RiddleProofTerminalMetadata {
248
270
  pr_url?: string;
271
+ pr_branch?: string;
249
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>;
250
282
  notification?: Record<string, unknown>;
251
283
  proof_decision?: RiddleProofDecision;
252
284
  merge_recommendation?: string;
package/dist/types.d.ts CHANGED
@@ -35,6 +35,7 @@ interface RiddleProofRunParams {
35
35
  color_scheme?: "dark" | "light" | (string & {});
36
36
  wait_for_selector?: string;
37
37
  ship_mode?: "none" | "ship";
38
+ leave_draft?: boolean;
38
39
  engine_state_path?: string;
39
40
  harness_state_path?: string;
40
41
  max_iterations?: number;
@@ -80,7 +81,17 @@ interface RiddleProofRunState {
80
81
  iterations: number;
81
82
  last_checkpoint?: string | null;
82
83
  pr_url?: string;
84
+ pr_branch?: string;
83
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>;
84
95
  notification?: Record<string, unknown>;
85
96
  proof_decision?: RiddleProofDecision;
86
97
  merge_recommendation?: string;
@@ -101,7 +112,17 @@ interface RiddleProofRunResult {
101
112
  last_summary?: string | null;
102
113
  event_count?: number;
103
114
  pr_url?: string;
115
+ pr_branch?: string;
104
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>;
105
126
  notification?: Record<string, unknown>;
106
127
  proof_decision?: RiddleProofDecision;
107
128
  merge_recommendation?: string;
@@ -133,6 +154,7 @@ interface RiddleProofEvidenceBundle {
133
154
  proof_evidence?: unknown;
134
155
  proof_evidence_sample?: unknown;
135
156
  assertions?: JsonValue;
157
+ semantic_context?: Record<string, unknown>;
136
158
  summary?: string;
137
159
  notes?: string[];
138
160
  }
@@ -246,7 +268,17 @@ interface NotificationAdapter {
246
268
  }
247
269
  interface RiddleProofTerminalMetadata {
248
270
  pr_url?: string;
271
+ pr_branch?: string;
249
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>;
250
282
  notification?: Record<string, unknown>;
251
283
  proof_decision?: RiddleProofDecision;
252
284
  merge_recommendation?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.4.1",
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
- };