@riddledc/riddle-proof 0.2.0 → 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/README.md +10 -3
- package/dist/{chunk-2ZQNXVQC.js → chunk-5DC6YXN4.js} +4 -0
- package/dist/{chunk-EPVZKWUS.js → chunk-IQIEOQZF.js} +59 -1
- package/dist/{chunk-GWGXPNON.js → chunk-P3FUU5X4.js} +92 -4
- package/dist/index.cjs +153 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -3
- package/dist/openclaw.js +2 -2
- package/dist/result.cjs +4 -0
- package/dist/result.js +1 -1
- package/dist/runner.cjs +130 -2
- package/dist/runner.d.cts +2 -1
- package/dist/runner.d.ts +2 -1
- package/dist/runner.js +3 -3
- package/dist/state.cjs +60 -0
- package/dist/state.d.cts +17 -2
- package/dist/state.d.ts +17 -2
- package/dist/state.js +6 -2
- package/dist/types.d.cts +46 -2
- package/dist/types.d.ts +46 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Proof standardizes evidence, proof assessment, ship gates, terminal results,
|
|
|
8
8
|
and integration metadata.
|
|
9
9
|
|
|
10
10
|
This package includes the reusable runner harness that drives a request through
|
|
11
|
-
setup, implementation, proof capture, judgment, shipping, and notification
|
|
11
|
+
preflight, setup, implementation, proof capture, judgment, shipping, and notification
|
|
12
12
|
adapters. The current OpenClaw `proofed_change_run` implementation remains the
|
|
13
13
|
reference workflow while adapter implementations are extracted behind parity
|
|
14
14
|
tests.
|
|
@@ -19,7 +19,9 @@ tests.
|
|
|
19
19
|
- Evidence bundle and proof assessment types
|
|
20
20
|
- Adapter interfaces
|
|
21
21
|
- State/event helpers for wrappers that need a stable run envelope
|
|
22
|
-
- Runner harness for setup -> implement -> prove -> judge -> ship -> notify
|
|
22
|
+
- Runner harness for preflight -> setup -> implement -> prove -> judge -> ship -> notify
|
|
23
|
+
- Stage heartbeat and run status snapshot helpers
|
|
24
|
+
- Worktree metadata and proof artifact role contracts
|
|
23
25
|
- Terminal ship metadata normalization
|
|
24
26
|
- Stable result helpers
|
|
25
27
|
- OpenClaw parameter normalization via `@riddledc/riddle-proof/openclaw`
|
|
@@ -59,9 +61,14 @@ credentials or a coding agent. It calls adapters supplied by the host
|
|
|
59
61
|
integration:
|
|
60
62
|
|
|
61
63
|
```text
|
|
62
|
-
setup -> implement -> prove -> judge -> ship -> notify
|
|
64
|
+
preflight -> setup -> implement -> prove -> judge -> ship -> notify
|
|
63
65
|
```
|
|
64
66
|
|
|
67
|
+
The preflight adapter checks model/tool availability before proof work starts.
|
|
68
|
+
The setup adapter should report the isolated worktree path, branch, and cleanup
|
|
69
|
+
policy it chose. During the run, wrappers can emit `appendStageHeartbeat`
|
|
70
|
+
events and return `createRunStatusSnapshot` for cheap observer status.
|
|
71
|
+
|
|
65
72
|
The proof adapter is where a host wires Riddle server-backed capture. The ship
|
|
66
73
|
adapter is where a host commits, pushes, opens or updates a PR, and waits for CI
|
|
67
74
|
when configured. The notification adapter is where a host updates Discord,
|
|
@@ -52,7 +52,11 @@ function createRunResult(input) {
|
|
|
52
52
|
return compactRecord({
|
|
53
53
|
ok,
|
|
54
54
|
status,
|
|
55
|
+
run_id: state.run_id,
|
|
55
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,
|
|
56
60
|
iterations: state.iterations,
|
|
57
61
|
last_checkpoint: state.last_checkpoint ?? null,
|
|
58
62
|
last_summary: input.last_summary ?? null,
|
|
@@ -2,13 +2,24 @@ import {
|
|
|
2
2
|
compactRecord,
|
|
3
3
|
nonEmptyString,
|
|
4
4
|
recordValue
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5DC6YXN4.js";
|
|
6
6
|
|
|
7
7
|
// src/state.ts
|
|
8
8
|
var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
|
|
9
9
|
function timestamp() {
|
|
10
10
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
11
11
|
}
|
|
12
|
+
function createRunId(createdAt) {
|
|
13
|
+
const stamp = createdAt.replace(/\D/g, "").slice(0, 14) || "unknown";
|
|
14
|
+
const entropy = Math.random().toString(36).slice(2, 8) || "run";
|
|
15
|
+
return `rp_${stamp}_${entropy}`;
|
|
16
|
+
}
|
|
17
|
+
function elapsedMs(start, end) {
|
|
18
|
+
const startMs = start ? Date.parse(start) : NaN;
|
|
19
|
+
const endMs = end ? Date.parse(end) : NaN;
|
|
20
|
+
if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
|
|
21
|
+
return Math.max(0, endMs - startMs);
|
|
22
|
+
}
|
|
12
23
|
function normalizeIntegrationContext(input, fallbackSource) {
|
|
13
24
|
const value = recordValue(input);
|
|
14
25
|
if (!value) {
|
|
@@ -59,7 +70,12 @@ function createRunState(input) {
|
|
|
59
70
|
const createdAt = input.created_at || timestamp();
|
|
60
71
|
return compactRecord({
|
|
61
72
|
version: RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
73
|
+
run_id: input.run_id || createRunId(createdAt),
|
|
62
74
|
state_path: input.state_path,
|
|
75
|
+
worktree_path: input.worktree_path,
|
|
76
|
+
branch: input.branch || input.request.branch,
|
|
77
|
+
current_stage: input.current_stage ?? null,
|
|
78
|
+
stage_started_at: input.stage_started_at ?? null,
|
|
63
79
|
status: input.status || "running",
|
|
64
80
|
created_at: createdAt,
|
|
65
81
|
updated_at: input.updated_at || createdAt,
|
|
@@ -87,9 +103,49 @@ function appendRunEvent(state, input) {
|
|
|
87
103
|
details: event.details
|
|
88
104
|
}));
|
|
89
105
|
if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
|
|
106
|
+
if (input.stage !== void 0) {
|
|
107
|
+
if (state.current_stage !== input.stage) state.stage_started_at = event.ts;
|
|
108
|
+
state.current_stage = input.stage;
|
|
109
|
+
}
|
|
90
110
|
state.updated_at = event.ts;
|
|
91
111
|
return state;
|
|
92
112
|
}
|
|
113
|
+
function appendStageHeartbeat(state, input) {
|
|
114
|
+
const at = input.ts || timestamp();
|
|
115
|
+
return appendRunEvent(state, {
|
|
116
|
+
ts: at,
|
|
117
|
+
kind: "stage.heartbeat",
|
|
118
|
+
checkpoint: input.checkpoint || `${input.stage}_heartbeat`,
|
|
119
|
+
stage: input.stage,
|
|
120
|
+
summary: input.summary || `${input.stage} stage is active.`,
|
|
121
|
+
details: compactRecord({
|
|
122
|
+
elapsed_ms: elapsedMs(state.created_at, at),
|
|
123
|
+
stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
|
|
124
|
+
wait_reason: input.wait_reason,
|
|
125
|
+
blocker: input.blocker,
|
|
126
|
+
...input.details
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function createRunStatusSnapshot(state, at = timestamp()) {
|
|
131
|
+
const latestEvent = state.events[state.events.length - 1];
|
|
132
|
+
const runId = state.run_id || "unknown";
|
|
133
|
+
return compactRecord({
|
|
134
|
+
run_id: runId,
|
|
135
|
+
status: state.status,
|
|
136
|
+
current_stage: state.current_stage ?? null,
|
|
137
|
+
state_path: state.state_path ?? null,
|
|
138
|
+
worktree_path: state.worktree_path ?? null,
|
|
139
|
+
branch: state.branch ?? null,
|
|
140
|
+
iterations: state.iterations,
|
|
141
|
+
last_checkpoint: state.last_checkpoint ?? null,
|
|
142
|
+
updated_at: state.updated_at,
|
|
143
|
+
elapsed_ms: elapsedMs(state.created_at, at),
|
|
144
|
+
stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
|
|
145
|
+
blocker: state.blocker,
|
|
146
|
+
latest_event: latestEvent
|
|
147
|
+
});
|
|
148
|
+
}
|
|
93
149
|
function setRunStatus(state, status, at = timestamp()) {
|
|
94
150
|
state.status = status;
|
|
95
151
|
state.ok = status !== "blocked" && status !== "failed";
|
|
@@ -103,5 +159,7 @@ export {
|
|
|
103
159
|
normalizeRunParams,
|
|
104
160
|
createRunState,
|
|
105
161
|
appendRunEvent,
|
|
162
|
+
appendStageHeartbeat,
|
|
163
|
+
createRunStatusSnapshot,
|
|
106
164
|
setRunStatus
|
|
107
165
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendRunEvent,
|
|
3
|
+
appendStageHeartbeat,
|
|
3
4
|
createRunState,
|
|
4
5
|
setRunStatus
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IQIEOQZF.js";
|
|
6
7
|
import {
|
|
7
8
|
createRunResult
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-5DC6YXN4.js";
|
|
9
10
|
|
|
10
11
|
// src/runner.ts
|
|
11
12
|
function errorDetails(error) {
|
|
@@ -84,7 +85,8 @@ async function notifyIfConfigured(input) {
|
|
|
84
85
|
async function runRiddleProof(input) {
|
|
85
86
|
const state = input.state || createRunState({
|
|
86
87
|
request: input.request,
|
|
87
|
-
state_path: input.state_path
|
|
88
|
+
state_path: input.state_path,
|
|
89
|
+
worktree_path: input.workdir
|
|
88
90
|
});
|
|
89
91
|
const adapters = input.adapters || {};
|
|
90
92
|
const maxIterations = Math.max(1, Math.trunc(input.max_iterations ?? 1));
|
|
@@ -94,12 +96,70 @@ async function runRiddleProof(input) {
|
|
|
94
96
|
stage: "setup",
|
|
95
97
|
summary: "Riddle Proof run started.",
|
|
96
98
|
details: {
|
|
99
|
+
run_id: state.run_id,
|
|
100
|
+
state_path: state.state_path,
|
|
101
|
+
worktree_path: state.worktree_path,
|
|
102
|
+
branch: state.branch,
|
|
97
103
|
max_iterations: maxIterations,
|
|
98
104
|
ship_mode: state.request.ship_mode || "none"
|
|
99
105
|
}
|
|
100
106
|
});
|
|
107
|
+
appendStageHeartbeat(state, {
|
|
108
|
+
stage: "setup",
|
|
109
|
+
summary: "Setup stage is active.",
|
|
110
|
+
details: {
|
|
111
|
+
run_id: state.run_id,
|
|
112
|
+
state_path: state.state_path,
|
|
113
|
+
worktree_path: state.worktree_path,
|
|
114
|
+
branch: state.branch
|
|
115
|
+
}
|
|
116
|
+
});
|
|
101
117
|
let workdir = input.workdir;
|
|
102
118
|
let evidenceContext;
|
|
119
|
+
if (adapters.preflight) {
|
|
120
|
+
appendRunEvent(state, {
|
|
121
|
+
kind: "preflight.started",
|
|
122
|
+
checkpoint: "preflight_started",
|
|
123
|
+
stage: "preflight",
|
|
124
|
+
summary: "Riddle Proof preflight adapter started."
|
|
125
|
+
});
|
|
126
|
+
try {
|
|
127
|
+
const preflight = await adapters.preflight.preflight({ request: state.request, state });
|
|
128
|
+
if (!preflight.ok) {
|
|
129
|
+
return blockRun({
|
|
130
|
+
state,
|
|
131
|
+
stage: "preflight",
|
|
132
|
+
blocker: adapterBlocker(
|
|
133
|
+
"preflight_failed",
|
|
134
|
+
"The preflight adapter found blocking tool or model configuration issues.",
|
|
135
|
+
"preflight_failed",
|
|
136
|
+
{
|
|
137
|
+
blockers: preflight.blockers,
|
|
138
|
+
warnings: preflight.warnings,
|
|
139
|
+
degraded_capabilities: preflight.degraded_capabilities
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
raw: { preflight }
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
appendRunEvent(state, {
|
|
146
|
+
kind: "preflight.completed",
|
|
147
|
+
checkpoint: "preflight_completed",
|
|
148
|
+
stage: "preflight",
|
|
149
|
+
summary: "Riddle Proof preflight adapter completed.",
|
|
150
|
+
details: {
|
|
151
|
+
warnings: preflight.warnings,
|
|
152
|
+
degraded_capabilities: preflight.degraded_capabilities
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return blockRun({
|
|
157
|
+
state,
|
|
158
|
+
stage: "preflight",
|
|
159
|
+
blocker: adapterBlocker("preflight_exception", "The preflight adapter threw an exception.", "preflight_failed", errorDetails(error))
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
103
163
|
if (adapters.setup) {
|
|
104
164
|
appendRunEvent(state, {
|
|
105
165
|
kind: "setup.started",
|
|
@@ -122,7 +182,9 @@ async function runRiddleProof(input) {
|
|
|
122
182
|
raw: { setup }
|
|
123
183
|
});
|
|
124
184
|
}
|
|
125
|
-
workdir = setup.workdir || workdir;
|
|
185
|
+
workdir = setup.worktree_path || setup.workdir || workdir;
|
|
186
|
+
state.worktree_path = setup.worktree_path || setup.workdir || state.worktree_path;
|
|
187
|
+
state.branch = setup.branch || state.branch;
|
|
126
188
|
evidenceContext = setup.evidence_context;
|
|
127
189
|
appendRunEvent(state, {
|
|
128
190
|
kind: "setup.completed",
|
|
@@ -131,6 +193,9 @@ async function runRiddleProof(input) {
|
|
|
131
193
|
summary: "Riddle Proof setup adapter completed.",
|
|
132
194
|
details: {
|
|
133
195
|
has_workdir: Boolean(workdir),
|
|
196
|
+
worktree_path: state.worktree_path,
|
|
197
|
+
branch: state.branch,
|
|
198
|
+
cleanup_policy: setup.cleanup_policy,
|
|
134
199
|
has_evidence_context: Boolean(evidenceContext)
|
|
135
200
|
}
|
|
136
201
|
});
|
|
@@ -183,6 +248,11 @@ async function runRiddleProof(input) {
|
|
|
183
248
|
let assessment;
|
|
184
249
|
for (let attempt = 0; attempt < maxIterations; attempt += 1) {
|
|
185
250
|
state.iterations += 1;
|
|
251
|
+
appendStageHeartbeat(state, {
|
|
252
|
+
stage: "implement",
|
|
253
|
+
summary: "Implementation stage is active.",
|
|
254
|
+
details: { iteration: state.iterations }
|
|
255
|
+
});
|
|
186
256
|
appendRunEvent(state, {
|
|
187
257
|
kind: "implementation.started",
|
|
188
258
|
checkpoint: "implementation_started",
|
|
@@ -229,6 +299,13 @@ async function runRiddleProof(input) {
|
|
|
229
299
|
tests_run: implementation.tests_run
|
|
230
300
|
}
|
|
231
301
|
});
|
|
302
|
+
appendStageHeartbeat(state, {
|
|
303
|
+
stage: "prove",
|
|
304
|
+
summary: "Proof capture stage is active.",
|
|
305
|
+
details: {
|
|
306
|
+
verification_mode: state.request.verification_mode
|
|
307
|
+
}
|
|
308
|
+
});
|
|
232
309
|
appendRunEvent(state, {
|
|
233
310
|
kind: "proof.started",
|
|
234
311
|
checkpoint: "proof_started",
|
|
@@ -278,6 +355,13 @@ async function runRiddleProof(input) {
|
|
|
278
355
|
stage: "verify",
|
|
279
356
|
summary: "Judge adapter started."
|
|
280
357
|
});
|
|
358
|
+
appendStageHeartbeat(state, {
|
|
359
|
+
stage: "verify",
|
|
360
|
+
summary: "Verification stage is active.",
|
|
361
|
+
details: {
|
|
362
|
+
verification_mode: evidenceBundle.verification_mode
|
|
363
|
+
}
|
|
364
|
+
});
|
|
281
365
|
try {
|
|
282
366
|
assessment = await adapters.judge.assessProof({ state, evidence_bundle: evidenceBundle });
|
|
283
367
|
state.proof_decision = assessment.decision;
|
|
@@ -367,6 +451,10 @@ async function runRiddleProof(input) {
|
|
|
367
451
|
stage: "ship",
|
|
368
452
|
summary: "Ship adapter started."
|
|
369
453
|
});
|
|
454
|
+
appendStageHeartbeat(state, {
|
|
455
|
+
stage: "ship",
|
|
456
|
+
summary: "Ship stage is active."
|
|
457
|
+
});
|
|
370
458
|
let metadata;
|
|
371
459
|
try {
|
|
372
460
|
metadata = await adapters.ship.ship({ state, assessment });
|
package/dist/index.cjs
CHANGED
|
@@ -22,10 +22,12 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
24
24
|
appendRunEvent: () => appendRunEvent,
|
|
25
|
+
appendStageHeartbeat: () => appendStageHeartbeat,
|
|
25
26
|
applyTerminalMetadata: () => applyTerminalMetadata,
|
|
26
27
|
compactRecord: () => compactRecord,
|
|
27
28
|
createRunResult: () => createRunResult,
|
|
28
29
|
createRunState: () => createRunState,
|
|
30
|
+
createRunStatusSnapshot: () => createRunStatusSnapshot,
|
|
29
31
|
isSuccessfulStatus: () => isSuccessfulStatus,
|
|
30
32
|
isTerminalStatus: () => isTerminalStatus,
|
|
31
33
|
nonEmptyString: () => nonEmptyString,
|
|
@@ -92,7 +94,11 @@ function createRunResult(input) {
|
|
|
92
94
|
return compactRecord({
|
|
93
95
|
ok,
|
|
94
96
|
status,
|
|
97
|
+
run_id: state.run_id,
|
|
95
98
|
state_path: input.state_path ?? state.state_path ?? null,
|
|
99
|
+
worktree_path: state.worktree_path ?? null,
|
|
100
|
+
branch: state.branch ?? null,
|
|
101
|
+
current_stage: state.current_stage ?? null,
|
|
96
102
|
iterations: state.iterations,
|
|
97
103
|
last_checkpoint: state.last_checkpoint ?? null,
|
|
98
104
|
last_summary: input.last_summary ?? null,
|
|
@@ -114,6 +120,17 @@ var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
|
|
|
114
120
|
function timestamp() {
|
|
115
121
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
116
122
|
}
|
|
123
|
+
function createRunId(createdAt) {
|
|
124
|
+
const stamp = createdAt.replace(/\D/g, "").slice(0, 14) || "unknown";
|
|
125
|
+
const entropy = Math.random().toString(36).slice(2, 8) || "run";
|
|
126
|
+
return `rp_${stamp}_${entropy}`;
|
|
127
|
+
}
|
|
128
|
+
function elapsedMs(start, end) {
|
|
129
|
+
const startMs = start ? Date.parse(start) : NaN;
|
|
130
|
+
const endMs = end ? Date.parse(end) : NaN;
|
|
131
|
+
if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
|
|
132
|
+
return Math.max(0, endMs - startMs);
|
|
133
|
+
}
|
|
117
134
|
function normalizeIntegrationContext(input, fallbackSource) {
|
|
118
135
|
const value = recordValue(input);
|
|
119
136
|
if (!value) {
|
|
@@ -164,7 +181,12 @@ function createRunState(input) {
|
|
|
164
181
|
const createdAt = input.created_at || timestamp();
|
|
165
182
|
return compactRecord({
|
|
166
183
|
version: RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
184
|
+
run_id: input.run_id || createRunId(createdAt),
|
|
167
185
|
state_path: input.state_path,
|
|
186
|
+
worktree_path: input.worktree_path,
|
|
187
|
+
branch: input.branch || input.request.branch,
|
|
188
|
+
current_stage: input.current_stage ?? null,
|
|
189
|
+
stage_started_at: input.stage_started_at ?? null,
|
|
168
190
|
status: input.status || "running",
|
|
169
191
|
created_at: createdAt,
|
|
170
192
|
updated_at: input.updated_at || createdAt,
|
|
@@ -192,9 +214,49 @@ function appendRunEvent(state, input) {
|
|
|
192
214
|
details: event.details
|
|
193
215
|
}));
|
|
194
216
|
if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
|
|
217
|
+
if (input.stage !== void 0) {
|
|
218
|
+
if (state.current_stage !== input.stage) state.stage_started_at = event.ts;
|
|
219
|
+
state.current_stage = input.stage;
|
|
220
|
+
}
|
|
195
221
|
state.updated_at = event.ts;
|
|
196
222
|
return state;
|
|
197
223
|
}
|
|
224
|
+
function appendStageHeartbeat(state, input) {
|
|
225
|
+
const at = input.ts || timestamp();
|
|
226
|
+
return appendRunEvent(state, {
|
|
227
|
+
ts: at,
|
|
228
|
+
kind: "stage.heartbeat",
|
|
229
|
+
checkpoint: input.checkpoint || `${input.stage}_heartbeat`,
|
|
230
|
+
stage: input.stage,
|
|
231
|
+
summary: input.summary || `${input.stage} stage is active.`,
|
|
232
|
+
details: compactRecord({
|
|
233
|
+
elapsed_ms: elapsedMs(state.created_at, at),
|
|
234
|
+
stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
|
|
235
|
+
wait_reason: input.wait_reason,
|
|
236
|
+
blocker: input.blocker,
|
|
237
|
+
...input.details
|
|
238
|
+
})
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
function createRunStatusSnapshot(state, at = timestamp()) {
|
|
242
|
+
const latestEvent = state.events[state.events.length - 1];
|
|
243
|
+
const runId = state.run_id || "unknown";
|
|
244
|
+
return compactRecord({
|
|
245
|
+
run_id: runId,
|
|
246
|
+
status: state.status,
|
|
247
|
+
current_stage: state.current_stage ?? null,
|
|
248
|
+
state_path: state.state_path ?? null,
|
|
249
|
+
worktree_path: state.worktree_path ?? null,
|
|
250
|
+
branch: state.branch ?? null,
|
|
251
|
+
iterations: state.iterations,
|
|
252
|
+
last_checkpoint: state.last_checkpoint ?? null,
|
|
253
|
+
updated_at: state.updated_at,
|
|
254
|
+
elapsed_ms: elapsedMs(state.created_at, at),
|
|
255
|
+
stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
|
|
256
|
+
blocker: state.blocker,
|
|
257
|
+
latest_event: latestEvent
|
|
258
|
+
});
|
|
259
|
+
}
|
|
198
260
|
function setRunStatus(state, status, at = timestamp()) {
|
|
199
261
|
state.status = status;
|
|
200
262
|
state.ok = status !== "blocked" && status !== "failed";
|
|
@@ -279,7 +341,8 @@ async function notifyIfConfigured(input) {
|
|
|
279
341
|
async function runRiddleProof(input) {
|
|
280
342
|
const state = input.state || createRunState({
|
|
281
343
|
request: input.request,
|
|
282
|
-
state_path: input.state_path
|
|
344
|
+
state_path: input.state_path,
|
|
345
|
+
worktree_path: input.workdir
|
|
283
346
|
});
|
|
284
347
|
const adapters = input.adapters || {};
|
|
285
348
|
const maxIterations = Math.max(1, Math.trunc(input.max_iterations ?? 1));
|
|
@@ -289,12 +352,70 @@ async function runRiddleProof(input) {
|
|
|
289
352
|
stage: "setup",
|
|
290
353
|
summary: "Riddle Proof run started.",
|
|
291
354
|
details: {
|
|
355
|
+
run_id: state.run_id,
|
|
356
|
+
state_path: state.state_path,
|
|
357
|
+
worktree_path: state.worktree_path,
|
|
358
|
+
branch: state.branch,
|
|
292
359
|
max_iterations: maxIterations,
|
|
293
360
|
ship_mode: state.request.ship_mode || "none"
|
|
294
361
|
}
|
|
295
362
|
});
|
|
363
|
+
appendStageHeartbeat(state, {
|
|
364
|
+
stage: "setup",
|
|
365
|
+
summary: "Setup stage is active.",
|
|
366
|
+
details: {
|
|
367
|
+
run_id: state.run_id,
|
|
368
|
+
state_path: state.state_path,
|
|
369
|
+
worktree_path: state.worktree_path,
|
|
370
|
+
branch: state.branch
|
|
371
|
+
}
|
|
372
|
+
});
|
|
296
373
|
let workdir = input.workdir;
|
|
297
374
|
let evidenceContext;
|
|
375
|
+
if (adapters.preflight) {
|
|
376
|
+
appendRunEvent(state, {
|
|
377
|
+
kind: "preflight.started",
|
|
378
|
+
checkpoint: "preflight_started",
|
|
379
|
+
stage: "preflight",
|
|
380
|
+
summary: "Riddle Proof preflight adapter started."
|
|
381
|
+
});
|
|
382
|
+
try {
|
|
383
|
+
const preflight = await adapters.preflight.preflight({ request: state.request, state });
|
|
384
|
+
if (!preflight.ok) {
|
|
385
|
+
return blockRun({
|
|
386
|
+
state,
|
|
387
|
+
stage: "preflight",
|
|
388
|
+
blocker: adapterBlocker(
|
|
389
|
+
"preflight_failed",
|
|
390
|
+
"The preflight adapter found blocking tool or model configuration issues.",
|
|
391
|
+
"preflight_failed",
|
|
392
|
+
{
|
|
393
|
+
blockers: preflight.blockers,
|
|
394
|
+
warnings: preflight.warnings,
|
|
395
|
+
degraded_capabilities: preflight.degraded_capabilities
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
raw: { preflight }
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
appendRunEvent(state, {
|
|
402
|
+
kind: "preflight.completed",
|
|
403
|
+
checkpoint: "preflight_completed",
|
|
404
|
+
stage: "preflight",
|
|
405
|
+
summary: "Riddle Proof preflight adapter completed.",
|
|
406
|
+
details: {
|
|
407
|
+
warnings: preflight.warnings,
|
|
408
|
+
degraded_capabilities: preflight.degraded_capabilities
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
} catch (error) {
|
|
412
|
+
return blockRun({
|
|
413
|
+
state,
|
|
414
|
+
stage: "preflight",
|
|
415
|
+
blocker: adapterBlocker("preflight_exception", "The preflight adapter threw an exception.", "preflight_failed", errorDetails(error))
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
298
419
|
if (adapters.setup) {
|
|
299
420
|
appendRunEvent(state, {
|
|
300
421
|
kind: "setup.started",
|
|
@@ -317,7 +438,9 @@ async function runRiddleProof(input) {
|
|
|
317
438
|
raw: { setup }
|
|
318
439
|
});
|
|
319
440
|
}
|
|
320
|
-
workdir = setup.workdir || workdir;
|
|
441
|
+
workdir = setup.worktree_path || setup.workdir || workdir;
|
|
442
|
+
state.worktree_path = setup.worktree_path || setup.workdir || state.worktree_path;
|
|
443
|
+
state.branch = setup.branch || state.branch;
|
|
321
444
|
evidenceContext = setup.evidence_context;
|
|
322
445
|
appendRunEvent(state, {
|
|
323
446
|
kind: "setup.completed",
|
|
@@ -326,6 +449,9 @@ async function runRiddleProof(input) {
|
|
|
326
449
|
summary: "Riddle Proof setup adapter completed.",
|
|
327
450
|
details: {
|
|
328
451
|
has_workdir: Boolean(workdir),
|
|
452
|
+
worktree_path: state.worktree_path,
|
|
453
|
+
branch: state.branch,
|
|
454
|
+
cleanup_policy: setup.cleanup_policy,
|
|
329
455
|
has_evidence_context: Boolean(evidenceContext)
|
|
330
456
|
}
|
|
331
457
|
});
|
|
@@ -378,6 +504,11 @@ async function runRiddleProof(input) {
|
|
|
378
504
|
let assessment;
|
|
379
505
|
for (let attempt = 0; attempt < maxIterations; attempt += 1) {
|
|
380
506
|
state.iterations += 1;
|
|
507
|
+
appendStageHeartbeat(state, {
|
|
508
|
+
stage: "implement",
|
|
509
|
+
summary: "Implementation stage is active.",
|
|
510
|
+
details: { iteration: state.iterations }
|
|
511
|
+
});
|
|
381
512
|
appendRunEvent(state, {
|
|
382
513
|
kind: "implementation.started",
|
|
383
514
|
checkpoint: "implementation_started",
|
|
@@ -424,6 +555,13 @@ async function runRiddleProof(input) {
|
|
|
424
555
|
tests_run: implementation.tests_run
|
|
425
556
|
}
|
|
426
557
|
});
|
|
558
|
+
appendStageHeartbeat(state, {
|
|
559
|
+
stage: "prove",
|
|
560
|
+
summary: "Proof capture stage is active.",
|
|
561
|
+
details: {
|
|
562
|
+
verification_mode: state.request.verification_mode
|
|
563
|
+
}
|
|
564
|
+
});
|
|
427
565
|
appendRunEvent(state, {
|
|
428
566
|
kind: "proof.started",
|
|
429
567
|
checkpoint: "proof_started",
|
|
@@ -473,6 +611,13 @@ async function runRiddleProof(input) {
|
|
|
473
611
|
stage: "verify",
|
|
474
612
|
summary: "Judge adapter started."
|
|
475
613
|
});
|
|
614
|
+
appendStageHeartbeat(state, {
|
|
615
|
+
stage: "verify",
|
|
616
|
+
summary: "Verification stage is active.",
|
|
617
|
+
details: {
|
|
618
|
+
verification_mode: evidenceBundle.verification_mode
|
|
619
|
+
}
|
|
620
|
+
});
|
|
476
621
|
try {
|
|
477
622
|
assessment = await adapters.judge.assessProof({ state, evidence_bundle: evidenceBundle });
|
|
478
623
|
state.proof_decision = assessment.decision;
|
|
@@ -562,6 +707,10 @@ async function runRiddleProof(input) {
|
|
|
562
707
|
stage: "ship",
|
|
563
708
|
summary: "Ship adapter started."
|
|
564
709
|
});
|
|
710
|
+
appendStageHeartbeat(state, {
|
|
711
|
+
stage: "ship",
|
|
712
|
+
summary: "Ship stage is active."
|
|
713
|
+
});
|
|
565
714
|
let metadata;
|
|
566
715
|
try {
|
|
567
716
|
metadata = await adapters.ship.ship({ state, assessment });
|
|
@@ -600,10 +749,12 @@ async function runRiddleProof(input) {
|
|
|
600
749
|
0 && (module.exports = {
|
|
601
750
|
RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
602
751
|
appendRunEvent,
|
|
752
|
+
appendStageHeartbeat,
|
|
603
753
|
applyTerminalMetadata,
|
|
604
754
|
compactRecord,
|
|
605
755
|
createRunResult,
|
|
606
756
|
createRunState,
|
|
757
|
+
createRunStatusSnapshot,
|
|
607
758
|
isSuccessfulStatus,
|
|
608
759
|
isTerminalStatus,
|
|
609
760
|
nonEmptyString,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { 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 } from './types.cjs';
|
|
1
|
+
export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from './types.cjs';
|
|
2
2
|
export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from './result.cjs';
|
|
3
|
-
export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.cjs';
|
|
3
|
+
export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.cjs';
|
|
4
4
|
export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { 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 } from './types.js';
|
|
1
|
+
export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from './types.js';
|
|
2
2
|
export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from './result.js';
|
|
3
|
-
export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.js';
|
|
3
|
+
export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus } from './state.js';
|
|
4
4
|
export { RiddleProofRunnerAdapters, RunRiddleProofInput, runRiddleProof } from './runner.js';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runRiddleProof
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P3FUU5X4.js";
|
|
4
4
|
import {
|
|
5
5
|
RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
6
6
|
appendRunEvent,
|
|
7
|
+
appendStageHeartbeat,
|
|
7
8
|
createRunState,
|
|
9
|
+
createRunStatusSnapshot,
|
|
8
10
|
normalizeIntegrationContext,
|
|
9
11
|
normalizeRunParams,
|
|
10
12
|
setRunStatus
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IQIEOQZF.js";
|
|
12
14
|
import {
|
|
13
15
|
applyTerminalMetadata,
|
|
14
16
|
compactRecord,
|
|
@@ -18,15 +20,17 @@ import {
|
|
|
18
20
|
nonEmptyString,
|
|
19
21
|
normalizeTerminalMetadata,
|
|
20
22
|
recordValue
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5DC6YXN4.js";
|
|
22
24
|
import "./chunk-6F4PWJZI.js";
|
|
23
25
|
export {
|
|
24
26
|
RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
25
27
|
appendRunEvent,
|
|
28
|
+
appendStageHeartbeat,
|
|
26
29
|
applyTerminalMetadata,
|
|
27
30
|
compactRecord,
|
|
28
31
|
createRunResult,
|
|
29
32
|
createRunState,
|
|
33
|
+
createRunStatusSnapshot,
|
|
30
34
|
isSuccessfulStatus,
|
|
31
35
|
isTerminalStatus,
|
|
32
36
|
nonEmptyString,
|
package/dist/openclaw.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeIntegrationContext,
|
|
3
3
|
normalizeRunParams
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IQIEOQZF.js";
|
|
5
5
|
import {
|
|
6
6
|
compactRecord
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5DC6YXN4.js";
|
|
8
8
|
|
|
9
9
|
// src/openclaw.ts
|
|
10
10
|
function parseOpenClawAssertions(value) {
|
package/dist/result.cjs
CHANGED
|
@@ -83,7 +83,11 @@ function createRunResult(input) {
|
|
|
83
83
|
return compactRecord({
|
|
84
84
|
ok,
|
|
85
85
|
status,
|
|
86
|
+
run_id: state.run_id,
|
|
86
87
|
state_path: input.state_path ?? state.state_path ?? null,
|
|
88
|
+
worktree_path: state.worktree_path ?? null,
|
|
89
|
+
branch: state.branch ?? null,
|
|
90
|
+
current_stage: state.current_stage ?? null,
|
|
87
91
|
iterations: state.iterations,
|
|
88
92
|
last_checkpoint: state.last_checkpoint ?? null,
|
|
89
93
|
last_summary: input.last_summary ?? null,
|