@riddledc/riddle-proof 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/result.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  nonEmptyString,
8
8
  normalizeTerminalMetadata,
9
9
  recordValue
10
- } from "./chunk-2ZQNXVQC.js";
10
+ } from "./chunk-5DC6YXN4.js";
11
11
  export {
12
12
  applyTerminalMetadata,
13
13
  compactRecord,
@@ -0,0 +1,697 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/runner.ts
21
+ var runner_exports = {};
22
+ __export(runner_exports, {
23
+ runRiddleProof: () => runRiddleProof
24
+ });
25
+ module.exports = __toCommonJS(runner_exports);
26
+
27
+ // src/result.ts
28
+ function isSuccessfulStatus(status) {
29
+ return status !== "blocked" && status !== "failed";
30
+ }
31
+ function compactRecord(input) {
32
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
33
+ }
34
+ function nonEmptyString(value) {
35
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
36
+ }
37
+ function recordValue(value) {
38
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
39
+ }
40
+ function applyTerminalMetadata(state, metadata) {
41
+ const prUrl = nonEmptyString(metadata.pr_url);
42
+ if (prUrl) state.pr_url = prUrl;
43
+ if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
44
+ const notification = recordValue(metadata.notification);
45
+ if (notification) state.notification = notification;
46
+ const proofDecision = nonEmptyString(metadata.proof_decision);
47
+ if (proofDecision) state.proof_decision = proofDecision;
48
+ const mergeRecommendation = nonEmptyString(metadata.merge_recommendation);
49
+ if (mergeRecommendation) state.merge_recommendation = mergeRecommendation;
50
+ if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
51
+ return state;
52
+ }
53
+ function createRunResult(input) {
54
+ const status = input.status || input.state.status;
55
+ const ok = isSuccessfulStatus(status);
56
+ const state = input.metadata ? applyTerminalMetadata(input.state, input.metadata) : input.state;
57
+ state.status = status;
58
+ state.ok = ok;
59
+ return compactRecord({
60
+ ok,
61
+ status,
62
+ run_id: state.run_id,
63
+ state_path: input.state_path ?? state.state_path ?? null,
64
+ worktree_path: state.worktree_path ?? null,
65
+ branch: state.branch ?? null,
66
+ current_stage: state.current_stage ?? null,
67
+ iterations: state.iterations,
68
+ last_checkpoint: state.last_checkpoint ?? null,
69
+ last_summary: input.last_summary ?? null,
70
+ event_count: state.events.length,
71
+ pr_url: state.pr_url,
72
+ marked_ready: state.marked_ready,
73
+ notification: state.notification,
74
+ proof_decision: state.proof_decision,
75
+ merge_recommendation: state.merge_recommendation,
76
+ finalized: state.finalized,
77
+ blocker: state.blocker,
78
+ evidence_bundle: input.evidence_bundle,
79
+ raw: input.raw
80
+ });
81
+ }
82
+
83
+ // src/state.ts
84
+ var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
85
+ function timestamp() {
86
+ return (/* @__PURE__ */ new Date()).toISOString();
87
+ }
88
+ function createRunId(createdAt) {
89
+ const stamp = createdAt.replace(/\D/g, "").slice(0, 14) || "unknown";
90
+ const entropy = Math.random().toString(36).slice(2, 8) || "run";
91
+ return `rp_${stamp}_${entropy}`;
92
+ }
93
+ function elapsedMs(start, end) {
94
+ const startMs = start ? Date.parse(start) : NaN;
95
+ const endMs = end ? Date.parse(end) : NaN;
96
+ if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
97
+ return Math.max(0, endMs - startMs);
98
+ }
99
+ function normalizeIntegrationContext(input, fallbackSource) {
100
+ const value = recordValue(input);
101
+ if (!value) {
102
+ return fallbackSource ? { source: fallbackSource } : void 0;
103
+ }
104
+ const metadata = recordValue(value.metadata);
105
+ return compactRecord({
106
+ source: nonEmptyString(value.source) || fallbackSource,
107
+ channel_id: nonEmptyString(value.channel_id),
108
+ thread_id: nonEmptyString(value.thread_id),
109
+ message_id: nonEmptyString(value.message_id),
110
+ source_url: nonEmptyString(value.source_url),
111
+ metadata: metadata && Object.keys(metadata).length ? metadata : void 0
112
+ });
113
+ }
114
+ function normalizeRunParams(input) {
115
+ return compactRecord({
116
+ repo: input.repo,
117
+ branch: input.branch,
118
+ change_request: input.change_request,
119
+ commit_message: input.commit_message,
120
+ prod_url: input.prod_url,
121
+ capture_script: input.capture_script,
122
+ success_criteria: input.success_criteria,
123
+ assertions: input.assertions,
124
+ verification_mode: input.verification_mode,
125
+ reference: input.reference,
126
+ base_branch: input.base_branch,
127
+ before_ref: input.before_ref,
128
+ allow_static_preview_fallback: input.allow_static_preview_fallback,
129
+ context: input.context,
130
+ reviewer: input.reviewer,
131
+ mode: input.mode,
132
+ build_command: input.build_command,
133
+ build_output: input.build_output,
134
+ server_image: input.server_image,
135
+ server_command: input.server_command,
136
+ server_port: input.server_port,
137
+ server_path: input.server_path,
138
+ use_auth: input.use_auth,
139
+ color_scheme: input.color_scheme,
140
+ wait_for_selector: input.wait_for_selector,
141
+ ship_mode: input.ship_mode,
142
+ integration_context: normalizeIntegrationContext(input.integration_context)
143
+ });
144
+ }
145
+ function createRunState(input) {
146
+ const createdAt = input.created_at || timestamp();
147
+ return compactRecord({
148
+ version: RIDDLE_PROOF_RUN_STATE_VERSION,
149
+ run_id: input.run_id || createRunId(createdAt),
150
+ state_path: input.state_path,
151
+ worktree_path: input.worktree_path,
152
+ branch: input.branch || input.request.branch,
153
+ current_stage: input.current_stage ?? null,
154
+ stage_started_at: input.stage_started_at ?? null,
155
+ status: input.status || "running",
156
+ created_at: createdAt,
157
+ updated_at: input.updated_at || createdAt,
158
+ request: normalizeRunParams(input.request),
159
+ iterations: input.iterations ?? 0,
160
+ last_checkpoint: input.last_checkpoint ?? null,
161
+ events: input.events ? [...input.events] : []
162
+ });
163
+ }
164
+ function appendRunEvent(state, input) {
165
+ const event = {
166
+ ts: input.ts || timestamp(),
167
+ kind: input.kind,
168
+ checkpoint: input.checkpoint,
169
+ stage: input.stage,
170
+ summary: input.summary,
171
+ details: input.details
172
+ };
173
+ state.events.push(compactRecord({
174
+ ts: event.ts,
175
+ kind: event.kind,
176
+ checkpoint: event.checkpoint,
177
+ stage: event.stage,
178
+ summary: event.summary,
179
+ details: event.details
180
+ }));
181
+ if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
182
+ if (input.stage !== void 0) {
183
+ if (state.current_stage !== input.stage) state.stage_started_at = event.ts;
184
+ state.current_stage = input.stage;
185
+ }
186
+ state.updated_at = event.ts;
187
+ return state;
188
+ }
189
+ function appendStageHeartbeat(state, input) {
190
+ const at = input.ts || timestamp();
191
+ return appendRunEvent(state, {
192
+ ts: at,
193
+ kind: "stage.heartbeat",
194
+ checkpoint: input.checkpoint || `${input.stage}_heartbeat`,
195
+ stage: input.stage,
196
+ summary: input.summary || `${input.stage} stage is active.`,
197
+ details: compactRecord({
198
+ elapsed_ms: elapsedMs(state.created_at, at),
199
+ stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
200
+ wait_reason: input.wait_reason,
201
+ blocker: input.blocker,
202
+ ...input.details
203
+ })
204
+ });
205
+ }
206
+ function setRunStatus(state, status, at = timestamp()) {
207
+ state.status = status;
208
+ state.ok = status !== "blocked" && status !== "failed";
209
+ state.updated_at = at;
210
+ return state;
211
+ }
212
+
213
+ // src/runner.ts
214
+ function errorDetails(error) {
215
+ if (error instanceof Error) {
216
+ return {
217
+ name: error.name,
218
+ message: error.message
219
+ };
220
+ }
221
+ return { message: String(error) };
222
+ }
223
+ function adapterBlocker(code, message, checkpoint, details) {
224
+ return {
225
+ code,
226
+ message,
227
+ checkpoint,
228
+ details
229
+ };
230
+ }
231
+ function blockRun(input) {
232
+ input.state.blocker = input.blocker;
233
+ appendRunEvent(input.state, {
234
+ kind: "run.blocked",
235
+ checkpoint: input.blocker.checkpoint,
236
+ stage: input.stage,
237
+ summary: input.blocker.message,
238
+ details: {
239
+ code: input.blocker.code,
240
+ ...input.blocker.details
241
+ }
242
+ });
243
+ setRunStatus(input.state, "blocked");
244
+ return createRunResult({
245
+ state: input.state,
246
+ status: "blocked",
247
+ last_summary: input.blocker.message,
248
+ evidence_bundle: input.evidence_bundle,
249
+ raw: input.raw
250
+ });
251
+ }
252
+ function shouldIterate(assessment) {
253
+ const nextStage = assessment.continue_with_stage || assessment.recommended_stage;
254
+ return nextStage === "implement" || nextStage === "author";
255
+ }
256
+ async function notifyIfConfigured(input) {
257
+ if (!input.notification) return input.result;
258
+ try {
259
+ const notification = await input.notification.notify({
260
+ state: input.state,
261
+ result: input.result
262
+ });
263
+ input.state.notification = notification;
264
+ appendRunEvent(input.state, {
265
+ kind: "notification.completed",
266
+ checkpoint: "notification_completed",
267
+ stage: "notify",
268
+ summary: "Integration notification completed."
269
+ });
270
+ } catch (error) {
271
+ appendRunEvent(input.state, {
272
+ kind: "notification.failed",
273
+ checkpoint: "notification_failed",
274
+ stage: "notify",
275
+ summary: "Integration notification failed.",
276
+ details: errorDetails(error)
277
+ });
278
+ }
279
+ return createRunResult({
280
+ state: input.state,
281
+ status: input.state.status,
282
+ last_summary: input.result.last_summary,
283
+ evidence_bundle: input.result.evidence_bundle,
284
+ raw: input.result.raw
285
+ });
286
+ }
287
+ async function runRiddleProof(input) {
288
+ const state = input.state || createRunState({
289
+ request: input.request,
290
+ state_path: input.state_path,
291
+ worktree_path: input.workdir
292
+ });
293
+ const adapters = input.adapters || {};
294
+ const maxIterations = Math.max(1, Math.trunc(input.max_iterations ?? 1));
295
+ appendRunEvent(state, {
296
+ kind: "run.started",
297
+ checkpoint: "run_started",
298
+ stage: "setup",
299
+ summary: "Riddle Proof run started.",
300
+ details: {
301
+ run_id: state.run_id,
302
+ state_path: state.state_path,
303
+ worktree_path: state.worktree_path,
304
+ branch: state.branch,
305
+ max_iterations: maxIterations,
306
+ ship_mode: state.request.ship_mode || "none"
307
+ }
308
+ });
309
+ appendStageHeartbeat(state, {
310
+ stage: "setup",
311
+ summary: "Setup stage is active.",
312
+ details: {
313
+ run_id: state.run_id,
314
+ state_path: state.state_path,
315
+ worktree_path: state.worktree_path,
316
+ branch: state.branch
317
+ }
318
+ });
319
+ let workdir = input.workdir;
320
+ let evidenceContext;
321
+ if (adapters.preflight) {
322
+ appendRunEvent(state, {
323
+ kind: "preflight.started",
324
+ checkpoint: "preflight_started",
325
+ stage: "preflight",
326
+ summary: "Riddle Proof preflight adapter started."
327
+ });
328
+ try {
329
+ const preflight = await adapters.preflight.preflight({ request: state.request, state });
330
+ if (!preflight.ok) {
331
+ return blockRun({
332
+ state,
333
+ stage: "preflight",
334
+ blocker: adapterBlocker(
335
+ "preflight_failed",
336
+ "The preflight adapter found blocking tool or model configuration issues.",
337
+ "preflight_failed",
338
+ {
339
+ blockers: preflight.blockers,
340
+ warnings: preflight.warnings,
341
+ degraded_capabilities: preflight.degraded_capabilities
342
+ }
343
+ ),
344
+ raw: { preflight }
345
+ });
346
+ }
347
+ appendRunEvent(state, {
348
+ kind: "preflight.completed",
349
+ checkpoint: "preflight_completed",
350
+ stage: "preflight",
351
+ summary: "Riddle Proof preflight adapter completed.",
352
+ details: {
353
+ warnings: preflight.warnings,
354
+ degraded_capabilities: preflight.degraded_capabilities
355
+ }
356
+ });
357
+ } catch (error) {
358
+ return blockRun({
359
+ state,
360
+ stage: "preflight",
361
+ blocker: adapterBlocker("preflight_exception", "The preflight adapter threw an exception.", "preflight_failed", errorDetails(error))
362
+ });
363
+ }
364
+ }
365
+ if (adapters.setup) {
366
+ appendRunEvent(state, {
367
+ kind: "setup.started",
368
+ checkpoint: "setup_started",
369
+ stage: "setup",
370
+ summary: "Riddle Proof setup adapter started."
371
+ });
372
+ try {
373
+ const setup = await adapters.setup.setup({ request: state.request, state });
374
+ if (!setup.ok) {
375
+ return blockRun({
376
+ state,
377
+ stage: "setup",
378
+ blocker: adapterBlocker(
379
+ "setup_failed",
380
+ "The setup adapter did not complete successfully.",
381
+ "setup_failed",
382
+ { blockers: setup.blockers }
383
+ ),
384
+ raw: { setup }
385
+ });
386
+ }
387
+ workdir = setup.worktree_path || setup.workdir || workdir;
388
+ state.worktree_path = setup.worktree_path || setup.workdir || state.worktree_path;
389
+ state.branch = setup.branch || state.branch;
390
+ evidenceContext = setup.evidence_context;
391
+ appendRunEvent(state, {
392
+ kind: "setup.completed",
393
+ checkpoint: "setup_completed",
394
+ stage: "setup",
395
+ summary: "Riddle Proof setup adapter completed.",
396
+ details: {
397
+ has_workdir: Boolean(workdir),
398
+ worktree_path: state.worktree_path,
399
+ branch: state.branch,
400
+ cleanup_policy: setup.cleanup_policy,
401
+ has_evidence_context: Boolean(evidenceContext)
402
+ }
403
+ });
404
+ } catch (error) {
405
+ return blockRun({
406
+ state,
407
+ stage: "setup",
408
+ blocker: adapterBlocker("setup_exception", "The setup adapter threw an exception.", "setup_failed", errorDetails(error))
409
+ });
410
+ }
411
+ }
412
+ const changeRequest = state.request.change_request?.trim();
413
+ if (!changeRequest) {
414
+ return blockRun({
415
+ state,
416
+ stage: "setup",
417
+ blocker: adapterBlocker("change_request_required", "A change request is required before implementation.", "request_invalid")
418
+ });
419
+ }
420
+ if (!workdir) {
421
+ return blockRun({
422
+ state,
423
+ stage: "setup",
424
+ blocker: adapterBlocker("workdir_not_configured", "A workdir or setup adapter result is required before implementation.", "setup_required")
425
+ });
426
+ }
427
+ if (!adapters.implementation) {
428
+ return blockRun({
429
+ state,
430
+ stage: "implement",
431
+ blocker: adapterBlocker("implementation_adapter_not_configured", "An implementation adapter is required to change code.", "implementation_required")
432
+ });
433
+ }
434
+ if (!adapters.proof) {
435
+ return blockRun({
436
+ state,
437
+ stage: "prove",
438
+ blocker: adapterBlocker("proof_adapter_not_configured", "A proof adapter is required to capture evidence.", "proof_required")
439
+ });
440
+ }
441
+ if (!adapters.judge) {
442
+ return blockRun({
443
+ state,
444
+ stage: "verify",
445
+ blocker: adapterBlocker("judge_adapter_not_configured", "A judge adapter is required to assess proof.", "judge_required")
446
+ });
447
+ }
448
+ let implementation;
449
+ let evidenceBundle;
450
+ let assessment;
451
+ for (let attempt = 0; attempt < maxIterations; attempt += 1) {
452
+ state.iterations += 1;
453
+ appendStageHeartbeat(state, {
454
+ stage: "implement",
455
+ summary: "Implementation stage is active.",
456
+ details: { iteration: state.iterations }
457
+ });
458
+ appendRunEvent(state, {
459
+ kind: "implementation.started",
460
+ checkpoint: "implementation_started",
461
+ stage: "implement",
462
+ summary: "Implementation adapter started.",
463
+ details: { iteration: state.iterations }
464
+ });
465
+ try {
466
+ implementation = await adapters.implementation.implement({
467
+ workdir,
468
+ change_request: changeRequest,
469
+ evidence_context: evidenceContext,
470
+ state
471
+ });
472
+ } catch (error) {
473
+ return blockRun({
474
+ state,
475
+ stage: "implement",
476
+ blocker: adapterBlocker("implementation_exception", "The implementation adapter threw an exception.", "implementation_failed", errorDetails(error)),
477
+ evidence_bundle: evidenceBundle
478
+ });
479
+ }
480
+ if (!implementation.ok) {
481
+ return blockRun({
482
+ state,
483
+ stage: "implement",
484
+ blocker: adapterBlocker(
485
+ "implementation_failed",
486
+ "The implementation adapter did not complete successfully.",
487
+ "implementation_failed",
488
+ { blockers: implementation.blockers }
489
+ ),
490
+ evidence_bundle: evidenceBundle,
491
+ raw: { implementation }
492
+ });
493
+ }
494
+ appendRunEvent(state, {
495
+ kind: "implementation.completed",
496
+ checkpoint: "implementation_completed",
497
+ stage: "implement",
498
+ summary: "Implementation adapter completed.",
499
+ details: {
500
+ changed_files: implementation.changed_files,
501
+ tests_run: implementation.tests_run
502
+ }
503
+ });
504
+ appendStageHeartbeat(state, {
505
+ stage: "prove",
506
+ summary: "Proof capture stage is active.",
507
+ details: {
508
+ verification_mode: state.request.verification_mode
509
+ }
510
+ });
511
+ appendRunEvent(state, {
512
+ kind: "proof.started",
513
+ checkpoint: "proof_started",
514
+ stage: "prove",
515
+ summary: "Proof adapter started."
516
+ });
517
+ try {
518
+ const proof = await adapters.proof.prove({
519
+ state,
520
+ implementation,
521
+ evidence_context: evidenceContext
522
+ });
523
+ if (!proof.ok || !proof.evidence_bundle) {
524
+ return blockRun({
525
+ state,
526
+ stage: "prove",
527
+ blocker: adapterBlocker(
528
+ "proof_failed",
529
+ "The proof adapter did not produce a usable evidence bundle.",
530
+ "proof_failed",
531
+ { blockers: proof.blockers }
532
+ ),
533
+ raw: { proof }
534
+ });
535
+ }
536
+ evidenceBundle = proof.evidence_bundle;
537
+ appendRunEvent(state, {
538
+ kind: "proof.completed",
539
+ checkpoint: "proof_completed",
540
+ stage: "prove",
541
+ summary: "Proof adapter completed.",
542
+ details: {
543
+ verification_mode: evidenceBundle.verification_mode,
544
+ artifact_count: evidenceBundle.artifacts?.length ?? 0
545
+ }
546
+ });
547
+ } catch (error) {
548
+ return blockRun({
549
+ state,
550
+ stage: "prove",
551
+ blocker: adapterBlocker("proof_exception", "The proof adapter threw an exception.", "proof_failed", errorDetails(error))
552
+ });
553
+ }
554
+ appendRunEvent(state, {
555
+ kind: "judge.started",
556
+ checkpoint: "judge_started",
557
+ stage: "verify",
558
+ summary: "Judge adapter started."
559
+ });
560
+ appendStageHeartbeat(state, {
561
+ stage: "verify",
562
+ summary: "Verification stage is active.",
563
+ details: {
564
+ verification_mode: evidenceBundle.verification_mode
565
+ }
566
+ });
567
+ try {
568
+ assessment = await adapters.judge.assessProof({ state, evidence_bundle: evidenceBundle });
569
+ state.proof_decision = assessment.decision;
570
+ appendRunEvent(state, {
571
+ kind: "judge.completed",
572
+ checkpoint: "judge_completed",
573
+ stage: "verify",
574
+ summary: assessment.summary,
575
+ details: {
576
+ decision: assessment.decision,
577
+ recommended_stage: assessment.recommended_stage,
578
+ continue_with_stage: assessment.continue_with_stage,
579
+ reasons: assessment.reasons
580
+ }
581
+ });
582
+ } catch (error) {
583
+ return blockRun({
584
+ state,
585
+ stage: "verify",
586
+ blocker: adapterBlocker("judge_exception", "The judge adapter threw an exception.", "judge_failed", errorDetails(error)),
587
+ evidence_bundle: evidenceBundle
588
+ });
589
+ }
590
+ if (assessment.decision === "ready_to_ship") break;
591
+ if (attempt + 1 < maxIterations && shouldIterate(assessment)) {
592
+ evidenceContext = evidenceBundle;
593
+ appendRunEvent(state, {
594
+ kind: "run.iterating",
595
+ checkpoint: "iteration_requested",
596
+ stage: "implement",
597
+ summary: "Judge requested another implementation iteration.",
598
+ details: {
599
+ decision: assessment.decision,
600
+ next_iteration: state.iterations + 1
601
+ }
602
+ });
603
+ continue;
604
+ }
605
+ return blockRun({
606
+ state,
607
+ stage: "verify",
608
+ blocker: adapterBlocker(
609
+ "proof_not_ready",
610
+ assessment.summary || "Proof is not ready to ship.",
611
+ "judge_completed",
612
+ {
613
+ decision: assessment.decision,
614
+ recommended_stage: assessment.recommended_stage,
615
+ continue_with_stage: assessment.continue_with_stage,
616
+ reasons: assessment.reasons
617
+ }
618
+ ),
619
+ evidence_bundle: evidenceBundle,
620
+ raw: { assessment }
621
+ });
622
+ }
623
+ if (!assessment || !evidenceBundle) {
624
+ return blockRun({
625
+ state,
626
+ stage: "verify",
627
+ blocker: adapterBlocker("runner_incomplete", "The runner ended without proof assessment.", "runner_incomplete")
628
+ });
629
+ }
630
+ if (state.request.ship_mode !== "ship") {
631
+ setRunStatus(state, "ready_to_ship");
632
+ const result2 = createRunResult({
633
+ state,
634
+ status: "ready_to_ship",
635
+ last_summary: assessment.summary,
636
+ evidence_bundle: evidenceBundle,
637
+ raw: { implementation, assessment }
638
+ });
639
+ return notifyIfConfigured({ state, result: result2, notification: adapters.notification });
640
+ }
641
+ if (!adapters.ship) {
642
+ return blockRun({
643
+ state,
644
+ stage: "ship",
645
+ blocker: adapterBlocker("ship_adapter_not_configured", "A ship adapter is required when ship_mode is ship.", "ship_required"),
646
+ evidence_bundle: evidenceBundle,
647
+ raw: { implementation, assessment }
648
+ });
649
+ }
650
+ appendRunEvent(state, {
651
+ kind: "ship.started",
652
+ checkpoint: "ship_started",
653
+ stage: "ship",
654
+ summary: "Ship adapter started."
655
+ });
656
+ appendStageHeartbeat(state, {
657
+ stage: "ship",
658
+ summary: "Ship stage is active."
659
+ });
660
+ let metadata;
661
+ try {
662
+ metadata = await adapters.ship.ship({ state, assessment });
663
+ } catch (error) {
664
+ return blockRun({
665
+ state,
666
+ stage: "ship",
667
+ blocker: adapterBlocker("ship_exception", "The ship adapter threw an exception.", "ship_failed", errorDetails(error)),
668
+ evidence_bundle: evidenceBundle,
669
+ raw: { implementation, assessment }
670
+ });
671
+ }
672
+ appendRunEvent(state, {
673
+ kind: "ship.completed",
674
+ checkpoint: "ship_completed",
675
+ stage: "ship",
676
+ summary: "Ship adapter completed.",
677
+ details: {
678
+ pr_url: metadata.pr_url,
679
+ marked_ready: metadata.marked_ready,
680
+ finalized: metadata.finalized
681
+ }
682
+ });
683
+ setRunStatus(state, "shipped");
684
+ const result = createRunResult({
685
+ state,
686
+ status: "shipped",
687
+ last_summary: "Riddle Proof shipped.",
688
+ metadata,
689
+ evidence_bundle: evidenceBundle,
690
+ raw: { implementation, assessment }
691
+ });
692
+ return notifyIfConfigured({ state, result, notification: adapters.notification });
693
+ }
694
+ // Annotate the CommonJS export names for ESM import in node:
695
+ 0 && (module.exports = {
696
+ runRiddleProof
697
+ });