@riddledc/riddle-proof 0.1.0 → 0.2.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/README.md +40 -3
- package/dist/chunk-GWGXPNON.js +407 -0
- package/dist/index.cjs +397 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -0
- package/dist/runner.cjs +569 -0
- package/dist/runner.d.cts +21 -0
- package/dist/runner.d.ts +21 -0
- package/dist/runner.js +8 -0
- package/dist/types.d.cts +30 -2
- package/dist/types.d.ts +30 -2
- package/package.json +7 -2
package/dist/runner.cjs
ADDED
|
@@ -0,0 +1,569 @@
|
|
|
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
|
+
state_path: input.state_path ?? state.state_path ?? null,
|
|
63
|
+
iterations: state.iterations,
|
|
64
|
+
last_checkpoint: state.last_checkpoint ?? null,
|
|
65
|
+
last_summary: input.last_summary ?? null,
|
|
66
|
+
event_count: state.events.length,
|
|
67
|
+
pr_url: state.pr_url,
|
|
68
|
+
marked_ready: state.marked_ready,
|
|
69
|
+
notification: state.notification,
|
|
70
|
+
proof_decision: state.proof_decision,
|
|
71
|
+
merge_recommendation: state.merge_recommendation,
|
|
72
|
+
finalized: state.finalized,
|
|
73
|
+
blocker: state.blocker,
|
|
74
|
+
evidence_bundle: input.evidence_bundle,
|
|
75
|
+
raw: input.raw
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/state.ts
|
|
80
|
+
var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
|
|
81
|
+
function timestamp() {
|
|
82
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
83
|
+
}
|
|
84
|
+
function normalizeIntegrationContext(input, fallbackSource) {
|
|
85
|
+
const value = recordValue(input);
|
|
86
|
+
if (!value) {
|
|
87
|
+
return fallbackSource ? { source: fallbackSource } : void 0;
|
|
88
|
+
}
|
|
89
|
+
const metadata = recordValue(value.metadata);
|
|
90
|
+
return compactRecord({
|
|
91
|
+
source: nonEmptyString(value.source) || fallbackSource,
|
|
92
|
+
channel_id: nonEmptyString(value.channel_id),
|
|
93
|
+
thread_id: nonEmptyString(value.thread_id),
|
|
94
|
+
message_id: nonEmptyString(value.message_id),
|
|
95
|
+
source_url: nonEmptyString(value.source_url),
|
|
96
|
+
metadata: metadata && Object.keys(metadata).length ? metadata : void 0
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function normalizeRunParams(input) {
|
|
100
|
+
return compactRecord({
|
|
101
|
+
repo: input.repo,
|
|
102
|
+
branch: input.branch,
|
|
103
|
+
change_request: input.change_request,
|
|
104
|
+
commit_message: input.commit_message,
|
|
105
|
+
prod_url: input.prod_url,
|
|
106
|
+
capture_script: input.capture_script,
|
|
107
|
+
success_criteria: input.success_criteria,
|
|
108
|
+
assertions: input.assertions,
|
|
109
|
+
verification_mode: input.verification_mode,
|
|
110
|
+
reference: input.reference,
|
|
111
|
+
base_branch: input.base_branch,
|
|
112
|
+
before_ref: input.before_ref,
|
|
113
|
+
allow_static_preview_fallback: input.allow_static_preview_fallback,
|
|
114
|
+
context: input.context,
|
|
115
|
+
reviewer: input.reviewer,
|
|
116
|
+
mode: input.mode,
|
|
117
|
+
build_command: input.build_command,
|
|
118
|
+
build_output: input.build_output,
|
|
119
|
+
server_image: input.server_image,
|
|
120
|
+
server_command: input.server_command,
|
|
121
|
+
server_port: input.server_port,
|
|
122
|
+
server_path: input.server_path,
|
|
123
|
+
use_auth: input.use_auth,
|
|
124
|
+
color_scheme: input.color_scheme,
|
|
125
|
+
wait_for_selector: input.wait_for_selector,
|
|
126
|
+
ship_mode: input.ship_mode,
|
|
127
|
+
integration_context: normalizeIntegrationContext(input.integration_context)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function createRunState(input) {
|
|
131
|
+
const createdAt = input.created_at || timestamp();
|
|
132
|
+
return compactRecord({
|
|
133
|
+
version: RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
134
|
+
state_path: input.state_path,
|
|
135
|
+
status: input.status || "running",
|
|
136
|
+
created_at: createdAt,
|
|
137
|
+
updated_at: input.updated_at || createdAt,
|
|
138
|
+
request: normalizeRunParams(input.request),
|
|
139
|
+
iterations: input.iterations ?? 0,
|
|
140
|
+
last_checkpoint: input.last_checkpoint ?? null,
|
|
141
|
+
events: input.events ? [...input.events] : []
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function appendRunEvent(state, input) {
|
|
145
|
+
const event = {
|
|
146
|
+
ts: input.ts || timestamp(),
|
|
147
|
+
kind: input.kind,
|
|
148
|
+
checkpoint: input.checkpoint,
|
|
149
|
+
stage: input.stage,
|
|
150
|
+
summary: input.summary,
|
|
151
|
+
details: input.details
|
|
152
|
+
};
|
|
153
|
+
state.events.push(compactRecord({
|
|
154
|
+
ts: event.ts,
|
|
155
|
+
kind: event.kind,
|
|
156
|
+
checkpoint: event.checkpoint,
|
|
157
|
+
stage: event.stage,
|
|
158
|
+
summary: event.summary,
|
|
159
|
+
details: event.details
|
|
160
|
+
}));
|
|
161
|
+
if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
|
|
162
|
+
state.updated_at = event.ts;
|
|
163
|
+
return state;
|
|
164
|
+
}
|
|
165
|
+
function setRunStatus(state, status, at = timestamp()) {
|
|
166
|
+
state.status = status;
|
|
167
|
+
state.ok = status !== "blocked" && status !== "failed";
|
|
168
|
+
state.updated_at = at;
|
|
169
|
+
return state;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/runner.ts
|
|
173
|
+
function errorDetails(error) {
|
|
174
|
+
if (error instanceof Error) {
|
|
175
|
+
return {
|
|
176
|
+
name: error.name,
|
|
177
|
+
message: error.message
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
return { message: String(error) };
|
|
181
|
+
}
|
|
182
|
+
function adapterBlocker(code, message, checkpoint, details) {
|
|
183
|
+
return {
|
|
184
|
+
code,
|
|
185
|
+
message,
|
|
186
|
+
checkpoint,
|
|
187
|
+
details
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function blockRun(input) {
|
|
191
|
+
input.state.blocker = input.blocker;
|
|
192
|
+
appendRunEvent(input.state, {
|
|
193
|
+
kind: "run.blocked",
|
|
194
|
+
checkpoint: input.blocker.checkpoint,
|
|
195
|
+
stage: input.stage,
|
|
196
|
+
summary: input.blocker.message,
|
|
197
|
+
details: {
|
|
198
|
+
code: input.blocker.code,
|
|
199
|
+
...input.blocker.details
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
setRunStatus(input.state, "blocked");
|
|
203
|
+
return createRunResult({
|
|
204
|
+
state: input.state,
|
|
205
|
+
status: "blocked",
|
|
206
|
+
last_summary: input.blocker.message,
|
|
207
|
+
evidence_bundle: input.evidence_bundle,
|
|
208
|
+
raw: input.raw
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function shouldIterate(assessment) {
|
|
212
|
+
const nextStage = assessment.continue_with_stage || assessment.recommended_stage;
|
|
213
|
+
return nextStage === "implement" || nextStage === "author";
|
|
214
|
+
}
|
|
215
|
+
async function notifyIfConfigured(input) {
|
|
216
|
+
if (!input.notification) return input.result;
|
|
217
|
+
try {
|
|
218
|
+
const notification = await input.notification.notify({
|
|
219
|
+
state: input.state,
|
|
220
|
+
result: input.result
|
|
221
|
+
});
|
|
222
|
+
input.state.notification = notification;
|
|
223
|
+
appendRunEvent(input.state, {
|
|
224
|
+
kind: "notification.completed",
|
|
225
|
+
checkpoint: "notification_completed",
|
|
226
|
+
stage: "notify",
|
|
227
|
+
summary: "Integration notification completed."
|
|
228
|
+
});
|
|
229
|
+
} catch (error) {
|
|
230
|
+
appendRunEvent(input.state, {
|
|
231
|
+
kind: "notification.failed",
|
|
232
|
+
checkpoint: "notification_failed",
|
|
233
|
+
stage: "notify",
|
|
234
|
+
summary: "Integration notification failed.",
|
|
235
|
+
details: errorDetails(error)
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return createRunResult({
|
|
239
|
+
state: input.state,
|
|
240
|
+
status: input.state.status,
|
|
241
|
+
last_summary: input.result.last_summary,
|
|
242
|
+
evidence_bundle: input.result.evidence_bundle,
|
|
243
|
+
raw: input.result.raw
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
async function runRiddleProof(input) {
|
|
247
|
+
const state = input.state || createRunState({
|
|
248
|
+
request: input.request,
|
|
249
|
+
state_path: input.state_path
|
|
250
|
+
});
|
|
251
|
+
const adapters = input.adapters || {};
|
|
252
|
+
const maxIterations = Math.max(1, Math.trunc(input.max_iterations ?? 1));
|
|
253
|
+
appendRunEvent(state, {
|
|
254
|
+
kind: "run.started",
|
|
255
|
+
checkpoint: "run_started",
|
|
256
|
+
stage: "setup",
|
|
257
|
+
summary: "Riddle Proof run started.",
|
|
258
|
+
details: {
|
|
259
|
+
max_iterations: maxIterations,
|
|
260
|
+
ship_mode: state.request.ship_mode || "none"
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
let workdir = input.workdir;
|
|
264
|
+
let evidenceContext;
|
|
265
|
+
if (adapters.setup) {
|
|
266
|
+
appendRunEvent(state, {
|
|
267
|
+
kind: "setup.started",
|
|
268
|
+
checkpoint: "setup_started",
|
|
269
|
+
stage: "setup",
|
|
270
|
+
summary: "Riddle Proof setup adapter started."
|
|
271
|
+
});
|
|
272
|
+
try {
|
|
273
|
+
const setup = await adapters.setup.setup({ request: state.request, state });
|
|
274
|
+
if (!setup.ok) {
|
|
275
|
+
return blockRun({
|
|
276
|
+
state,
|
|
277
|
+
stage: "setup",
|
|
278
|
+
blocker: adapterBlocker(
|
|
279
|
+
"setup_failed",
|
|
280
|
+
"The setup adapter did not complete successfully.",
|
|
281
|
+
"setup_failed",
|
|
282
|
+
{ blockers: setup.blockers }
|
|
283
|
+
),
|
|
284
|
+
raw: { setup }
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
workdir = setup.workdir || workdir;
|
|
288
|
+
evidenceContext = setup.evidence_context;
|
|
289
|
+
appendRunEvent(state, {
|
|
290
|
+
kind: "setup.completed",
|
|
291
|
+
checkpoint: "setup_completed",
|
|
292
|
+
stage: "setup",
|
|
293
|
+
summary: "Riddle Proof setup adapter completed.",
|
|
294
|
+
details: {
|
|
295
|
+
has_workdir: Boolean(workdir),
|
|
296
|
+
has_evidence_context: Boolean(evidenceContext)
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
} catch (error) {
|
|
300
|
+
return blockRun({
|
|
301
|
+
state,
|
|
302
|
+
stage: "setup",
|
|
303
|
+
blocker: adapterBlocker("setup_exception", "The setup adapter threw an exception.", "setup_failed", errorDetails(error))
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const changeRequest = state.request.change_request?.trim();
|
|
308
|
+
if (!changeRequest) {
|
|
309
|
+
return blockRun({
|
|
310
|
+
state,
|
|
311
|
+
stage: "setup",
|
|
312
|
+
blocker: adapterBlocker("change_request_required", "A change request is required before implementation.", "request_invalid")
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
if (!workdir) {
|
|
316
|
+
return blockRun({
|
|
317
|
+
state,
|
|
318
|
+
stage: "setup",
|
|
319
|
+
blocker: adapterBlocker("workdir_not_configured", "A workdir or setup adapter result is required before implementation.", "setup_required")
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (!adapters.implementation) {
|
|
323
|
+
return blockRun({
|
|
324
|
+
state,
|
|
325
|
+
stage: "implement",
|
|
326
|
+
blocker: adapterBlocker("implementation_adapter_not_configured", "An implementation adapter is required to change code.", "implementation_required")
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
if (!adapters.proof) {
|
|
330
|
+
return blockRun({
|
|
331
|
+
state,
|
|
332
|
+
stage: "prove",
|
|
333
|
+
blocker: adapterBlocker("proof_adapter_not_configured", "A proof adapter is required to capture evidence.", "proof_required")
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
if (!adapters.judge) {
|
|
337
|
+
return blockRun({
|
|
338
|
+
state,
|
|
339
|
+
stage: "verify",
|
|
340
|
+
blocker: adapterBlocker("judge_adapter_not_configured", "A judge adapter is required to assess proof.", "judge_required")
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
let implementation;
|
|
344
|
+
let evidenceBundle;
|
|
345
|
+
let assessment;
|
|
346
|
+
for (let attempt = 0; attempt < maxIterations; attempt += 1) {
|
|
347
|
+
state.iterations += 1;
|
|
348
|
+
appendRunEvent(state, {
|
|
349
|
+
kind: "implementation.started",
|
|
350
|
+
checkpoint: "implementation_started",
|
|
351
|
+
stage: "implement",
|
|
352
|
+
summary: "Implementation adapter started.",
|
|
353
|
+
details: { iteration: state.iterations }
|
|
354
|
+
});
|
|
355
|
+
try {
|
|
356
|
+
implementation = await adapters.implementation.implement({
|
|
357
|
+
workdir,
|
|
358
|
+
change_request: changeRequest,
|
|
359
|
+
evidence_context: evidenceContext,
|
|
360
|
+
state
|
|
361
|
+
});
|
|
362
|
+
} catch (error) {
|
|
363
|
+
return blockRun({
|
|
364
|
+
state,
|
|
365
|
+
stage: "implement",
|
|
366
|
+
blocker: adapterBlocker("implementation_exception", "The implementation adapter threw an exception.", "implementation_failed", errorDetails(error)),
|
|
367
|
+
evidence_bundle: evidenceBundle
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (!implementation.ok) {
|
|
371
|
+
return blockRun({
|
|
372
|
+
state,
|
|
373
|
+
stage: "implement",
|
|
374
|
+
blocker: adapterBlocker(
|
|
375
|
+
"implementation_failed",
|
|
376
|
+
"The implementation adapter did not complete successfully.",
|
|
377
|
+
"implementation_failed",
|
|
378
|
+
{ blockers: implementation.blockers }
|
|
379
|
+
),
|
|
380
|
+
evidence_bundle: evidenceBundle,
|
|
381
|
+
raw: { implementation }
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
appendRunEvent(state, {
|
|
385
|
+
kind: "implementation.completed",
|
|
386
|
+
checkpoint: "implementation_completed",
|
|
387
|
+
stage: "implement",
|
|
388
|
+
summary: "Implementation adapter completed.",
|
|
389
|
+
details: {
|
|
390
|
+
changed_files: implementation.changed_files,
|
|
391
|
+
tests_run: implementation.tests_run
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
appendRunEvent(state, {
|
|
395
|
+
kind: "proof.started",
|
|
396
|
+
checkpoint: "proof_started",
|
|
397
|
+
stage: "prove",
|
|
398
|
+
summary: "Proof adapter started."
|
|
399
|
+
});
|
|
400
|
+
try {
|
|
401
|
+
const proof = await adapters.proof.prove({
|
|
402
|
+
state,
|
|
403
|
+
implementation,
|
|
404
|
+
evidence_context: evidenceContext
|
|
405
|
+
});
|
|
406
|
+
if (!proof.ok || !proof.evidence_bundle) {
|
|
407
|
+
return blockRun({
|
|
408
|
+
state,
|
|
409
|
+
stage: "prove",
|
|
410
|
+
blocker: adapterBlocker(
|
|
411
|
+
"proof_failed",
|
|
412
|
+
"The proof adapter did not produce a usable evidence bundle.",
|
|
413
|
+
"proof_failed",
|
|
414
|
+
{ blockers: proof.blockers }
|
|
415
|
+
),
|
|
416
|
+
raw: { proof }
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
evidenceBundle = proof.evidence_bundle;
|
|
420
|
+
appendRunEvent(state, {
|
|
421
|
+
kind: "proof.completed",
|
|
422
|
+
checkpoint: "proof_completed",
|
|
423
|
+
stage: "prove",
|
|
424
|
+
summary: "Proof adapter completed.",
|
|
425
|
+
details: {
|
|
426
|
+
verification_mode: evidenceBundle.verification_mode,
|
|
427
|
+
artifact_count: evidenceBundle.artifacts?.length ?? 0
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
} catch (error) {
|
|
431
|
+
return blockRun({
|
|
432
|
+
state,
|
|
433
|
+
stage: "prove",
|
|
434
|
+
blocker: adapterBlocker("proof_exception", "The proof adapter threw an exception.", "proof_failed", errorDetails(error))
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
appendRunEvent(state, {
|
|
438
|
+
kind: "judge.started",
|
|
439
|
+
checkpoint: "judge_started",
|
|
440
|
+
stage: "verify",
|
|
441
|
+
summary: "Judge adapter started."
|
|
442
|
+
});
|
|
443
|
+
try {
|
|
444
|
+
assessment = await adapters.judge.assessProof({ state, evidence_bundle: evidenceBundle });
|
|
445
|
+
state.proof_decision = assessment.decision;
|
|
446
|
+
appendRunEvent(state, {
|
|
447
|
+
kind: "judge.completed",
|
|
448
|
+
checkpoint: "judge_completed",
|
|
449
|
+
stage: "verify",
|
|
450
|
+
summary: assessment.summary,
|
|
451
|
+
details: {
|
|
452
|
+
decision: assessment.decision,
|
|
453
|
+
recommended_stage: assessment.recommended_stage,
|
|
454
|
+
continue_with_stage: assessment.continue_with_stage,
|
|
455
|
+
reasons: assessment.reasons
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
} catch (error) {
|
|
459
|
+
return blockRun({
|
|
460
|
+
state,
|
|
461
|
+
stage: "verify",
|
|
462
|
+
blocker: adapterBlocker("judge_exception", "The judge adapter threw an exception.", "judge_failed", errorDetails(error)),
|
|
463
|
+
evidence_bundle: evidenceBundle
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
if (assessment.decision === "ready_to_ship") break;
|
|
467
|
+
if (attempt + 1 < maxIterations && shouldIterate(assessment)) {
|
|
468
|
+
evidenceContext = evidenceBundle;
|
|
469
|
+
appendRunEvent(state, {
|
|
470
|
+
kind: "run.iterating",
|
|
471
|
+
checkpoint: "iteration_requested",
|
|
472
|
+
stage: "implement",
|
|
473
|
+
summary: "Judge requested another implementation iteration.",
|
|
474
|
+
details: {
|
|
475
|
+
decision: assessment.decision,
|
|
476
|
+
next_iteration: state.iterations + 1
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
return blockRun({
|
|
482
|
+
state,
|
|
483
|
+
stage: "verify",
|
|
484
|
+
blocker: adapterBlocker(
|
|
485
|
+
"proof_not_ready",
|
|
486
|
+
assessment.summary || "Proof is not ready to ship.",
|
|
487
|
+
"judge_completed",
|
|
488
|
+
{
|
|
489
|
+
decision: assessment.decision,
|
|
490
|
+
recommended_stage: assessment.recommended_stage,
|
|
491
|
+
continue_with_stage: assessment.continue_with_stage,
|
|
492
|
+
reasons: assessment.reasons
|
|
493
|
+
}
|
|
494
|
+
),
|
|
495
|
+
evidence_bundle: evidenceBundle,
|
|
496
|
+
raw: { assessment }
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
if (!assessment || !evidenceBundle) {
|
|
500
|
+
return blockRun({
|
|
501
|
+
state,
|
|
502
|
+
stage: "verify",
|
|
503
|
+
blocker: adapterBlocker("runner_incomplete", "The runner ended without proof assessment.", "runner_incomplete")
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
if (state.request.ship_mode !== "ship") {
|
|
507
|
+
setRunStatus(state, "ready_to_ship");
|
|
508
|
+
const result2 = createRunResult({
|
|
509
|
+
state,
|
|
510
|
+
status: "ready_to_ship",
|
|
511
|
+
last_summary: assessment.summary,
|
|
512
|
+
evidence_bundle: evidenceBundle,
|
|
513
|
+
raw: { implementation, assessment }
|
|
514
|
+
});
|
|
515
|
+
return notifyIfConfigured({ state, result: result2, notification: adapters.notification });
|
|
516
|
+
}
|
|
517
|
+
if (!adapters.ship) {
|
|
518
|
+
return blockRun({
|
|
519
|
+
state,
|
|
520
|
+
stage: "ship",
|
|
521
|
+
blocker: adapterBlocker("ship_adapter_not_configured", "A ship adapter is required when ship_mode is ship.", "ship_required"),
|
|
522
|
+
evidence_bundle: evidenceBundle,
|
|
523
|
+
raw: { implementation, assessment }
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
appendRunEvent(state, {
|
|
527
|
+
kind: "ship.started",
|
|
528
|
+
checkpoint: "ship_started",
|
|
529
|
+
stage: "ship",
|
|
530
|
+
summary: "Ship adapter started."
|
|
531
|
+
});
|
|
532
|
+
let metadata;
|
|
533
|
+
try {
|
|
534
|
+
metadata = await adapters.ship.ship({ state, assessment });
|
|
535
|
+
} catch (error) {
|
|
536
|
+
return blockRun({
|
|
537
|
+
state,
|
|
538
|
+
stage: "ship",
|
|
539
|
+
blocker: adapterBlocker("ship_exception", "The ship adapter threw an exception.", "ship_failed", errorDetails(error)),
|
|
540
|
+
evidence_bundle: evidenceBundle,
|
|
541
|
+
raw: { implementation, assessment }
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
appendRunEvent(state, {
|
|
545
|
+
kind: "ship.completed",
|
|
546
|
+
checkpoint: "ship_completed",
|
|
547
|
+
stage: "ship",
|
|
548
|
+
summary: "Ship adapter completed.",
|
|
549
|
+
details: {
|
|
550
|
+
pr_url: metadata.pr_url,
|
|
551
|
+
marked_ready: metadata.marked_ready,
|
|
552
|
+
finalized: metadata.finalized
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
setRunStatus(state, "shipped");
|
|
556
|
+
const result = createRunResult({
|
|
557
|
+
state,
|
|
558
|
+
status: "shipped",
|
|
559
|
+
last_summary: "Riddle Proof shipped.",
|
|
560
|
+
metadata,
|
|
561
|
+
evidence_bundle: evidenceBundle,
|
|
562
|
+
raw: { implementation, assessment }
|
|
563
|
+
});
|
|
564
|
+
return notifyIfConfigured({ state, result, notification: adapters.notification });
|
|
565
|
+
}
|
|
566
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
567
|
+
0 && (module.exports = {
|
|
568
|
+
runRiddleProof
|
|
569
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SetupAdapter, ImplementationAdapter, ProofAdapter, JudgeAdapter, ShipAdapter, NotificationAdapter, RiddleProofRunParams, RiddleProofRunState, RiddleProofRunResult } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
interface RiddleProofRunnerAdapters {
|
|
4
|
+
setup?: SetupAdapter;
|
|
5
|
+
implementation?: ImplementationAdapter;
|
|
6
|
+
proof?: ProofAdapter;
|
|
7
|
+
judge?: JudgeAdapter;
|
|
8
|
+
ship?: ShipAdapter;
|
|
9
|
+
notification?: NotificationAdapter;
|
|
10
|
+
}
|
|
11
|
+
interface RunRiddleProofInput {
|
|
12
|
+
request: RiddleProofRunParams;
|
|
13
|
+
adapters: RiddleProofRunnerAdapters;
|
|
14
|
+
state?: RiddleProofRunState;
|
|
15
|
+
state_path?: string;
|
|
16
|
+
workdir?: string;
|
|
17
|
+
max_iterations?: number;
|
|
18
|
+
}
|
|
19
|
+
declare function runRiddleProof(input: RunRiddleProofInput): Promise<RiddleProofRunResult>;
|
|
20
|
+
|
|
21
|
+
export { type RiddleProofRunnerAdapters, type RunRiddleProofInput, runRiddleProof };
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SetupAdapter, ImplementationAdapter, ProofAdapter, JudgeAdapter, ShipAdapter, NotificationAdapter, RiddleProofRunParams, RiddleProofRunState, RiddleProofRunResult } from './types.js';
|
|
2
|
+
|
|
3
|
+
interface RiddleProofRunnerAdapters {
|
|
4
|
+
setup?: SetupAdapter;
|
|
5
|
+
implementation?: ImplementationAdapter;
|
|
6
|
+
proof?: ProofAdapter;
|
|
7
|
+
judge?: JudgeAdapter;
|
|
8
|
+
ship?: ShipAdapter;
|
|
9
|
+
notification?: NotificationAdapter;
|
|
10
|
+
}
|
|
11
|
+
interface RunRiddleProofInput {
|
|
12
|
+
request: RiddleProofRunParams;
|
|
13
|
+
adapters: RiddleProofRunnerAdapters;
|
|
14
|
+
state?: RiddleProofRunState;
|
|
15
|
+
state_path?: string;
|
|
16
|
+
workdir?: string;
|
|
17
|
+
max_iterations?: number;
|
|
18
|
+
}
|
|
19
|
+
declare function runRiddleProof(input: RunRiddleProofInput): Promise<RiddleProofRunResult>;
|
|
20
|
+
|
|
21
|
+
export { type RiddleProofRunnerAdapters, type RunRiddleProofInput, runRiddleProof };
|
package/dist/runner.js
ADDED
package/dist/types.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ type JsonObject = {
|
|
|
6
6
|
type RiddleProofStatus = "running" | "blocked" | "failed" | "ready_to_ship" | "shipped" | "completed";
|
|
7
7
|
type RiddleProofVerificationMode = "proof" | "visual" | "interaction" | "render" | "data" | "json" | "audio" | "log" | "logs" | "metric" | "metrics" | (string & {});
|
|
8
8
|
type RiddleProofDecision = "ready_to_ship" | "needs_richer_proof" | "revise_capture" | "needs_recon" | "needs_implementation" | (string & {});
|
|
9
|
-
type RiddleProofStage = "setup" | "recon" | "author" | "implement" | "verify" | "ship" | (string & {});
|
|
9
|
+
type RiddleProofStage = "setup" | "recon" | "author" | "implement" | "prove" | "verify" | "ship" | "notify" | (string & {});
|
|
10
10
|
interface RiddleProofRunParams {
|
|
11
11
|
repo?: string;
|
|
12
12
|
branch?: string;
|
|
@@ -132,6 +132,20 @@ interface RiddleProofAssessment {
|
|
|
132
132
|
reasons?: string[];
|
|
133
133
|
source?: "supervising_agent" | "supervisor" | "human" | (string & {});
|
|
134
134
|
}
|
|
135
|
+
interface SetupAdapterInput {
|
|
136
|
+
request: RiddleProofRunParams;
|
|
137
|
+
state: RiddleProofRunState;
|
|
138
|
+
}
|
|
139
|
+
interface SetupAdapterResult {
|
|
140
|
+
ok: boolean;
|
|
141
|
+
workdir?: string;
|
|
142
|
+
evidence_context?: RiddleProofEvidenceBundle;
|
|
143
|
+
blockers?: string[];
|
|
144
|
+
raw?: Record<string, unknown>;
|
|
145
|
+
}
|
|
146
|
+
interface SetupAdapter {
|
|
147
|
+
setup(input: SetupAdapterInput): Promise<SetupAdapterResult>;
|
|
148
|
+
}
|
|
135
149
|
interface ImplementationAdapterInput {
|
|
136
150
|
workdir: string;
|
|
137
151
|
change_request: string;
|
|
@@ -149,6 +163,20 @@ interface ImplementationAdapterResult {
|
|
|
149
163
|
interface ImplementationAdapter {
|
|
150
164
|
implement(input: ImplementationAdapterInput): Promise<ImplementationAdapterResult>;
|
|
151
165
|
}
|
|
166
|
+
interface ProofAdapterInput {
|
|
167
|
+
state: RiddleProofRunState;
|
|
168
|
+
implementation?: ImplementationAdapterResult;
|
|
169
|
+
evidence_context?: RiddleProofEvidenceBundle;
|
|
170
|
+
}
|
|
171
|
+
interface ProofAdapterResult {
|
|
172
|
+
ok: boolean;
|
|
173
|
+
evidence_bundle?: RiddleProofEvidenceBundle;
|
|
174
|
+
blockers?: string[];
|
|
175
|
+
raw?: Record<string, unknown>;
|
|
176
|
+
}
|
|
177
|
+
interface ProofAdapter {
|
|
178
|
+
prove(input: ProofAdapterInput): Promise<ProofAdapterResult>;
|
|
179
|
+
}
|
|
152
180
|
interface JudgeAdapter {
|
|
153
181
|
assessProof(input: {
|
|
154
182
|
state: RiddleProofRunState;
|
|
@@ -176,4 +204,4 @@ interface RiddleProofTerminalMetadata {
|
|
|
176
204
|
finalized?: boolean;
|
|
177
205
|
}
|
|
178
206
|
|
|
179
|
-
export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, ShipAdapter };
|
|
207
|
+
export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter };
|