@riddledc/riddle-proof 0.5.39 → 0.5.40
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/checkpoint.cjs +90 -2
- package/dist/checkpoint.d.cts +6 -2
- package/dist/checkpoint.d.ts +6 -2
- package/dist/checkpoint.js +12 -4
- package/dist/{chunk-UQPTCP4D.js → chunk-5LVCGDSD.js} +86 -2
- package/dist/{chunk-Z3BWCHFV.js → chunk-7S7O3NKF.js} +7 -1
- package/dist/{chunk-ORRP7CXT.js → chunk-COFOLRUW.js} +41 -10
- package/dist/{chunk-RDTMR7XR.js → chunk-MRSYJMF4.js} +2 -2
- package/dist/{chunk-Z7QUCDPT.js → chunk-W7VTDN4T.js} +3 -0
- package/dist/engine-harness.cjs +122 -6
- package/dist/engine-harness.js +4 -4
- package/dist/index.cjs +130 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -6
- package/dist/openclaw.js +2 -2
- package/dist/result.cjs +3 -0
- package/dist/result.js +1 -1
- package/dist/runner.cjs +6 -0
- package/dist/runner.js +3 -3
- package/dist/state.cjs +6 -0
- package/dist/state.d.cts +4 -1
- package/dist/state.d.ts +4 -1
- package/dist/state.js +2 -2
- package/dist/types.d.cts +55 -1
- package/dist/types.d.ts +55 -1
- package/package.json +1 -1
package/dist/checkpoint.cjs
CHANGED
|
@@ -34,7 +34,11 @@ __export(checkpoint_exports, {
|
|
|
34
34
|
RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION: () => RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
35
35
|
authorPacketPayloadFromCheckpointResponse: () => authorPacketPayloadFromCheckpointResponse,
|
|
36
36
|
buildAuthorCheckpointPacket: () => buildAuthorCheckpointPacket,
|
|
37
|
-
|
|
37
|
+
checkpointSummaryFromState: () => checkpointSummaryFromState,
|
|
38
|
+
isDuplicateCheckpointResponse: () => isDuplicateCheckpointResponse,
|
|
39
|
+
normalizeCheckpointResponse: () => normalizeCheckpointResponse,
|
|
40
|
+
proofContractFromAuthorCheckpointResponse: () => proofContractFromAuthorCheckpointResponse,
|
|
41
|
+
statePathsForRunState: () => statePathsForRunState
|
|
38
42
|
});
|
|
39
43
|
module.exports = __toCommonJS(checkpoint_exports);
|
|
40
44
|
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
@@ -65,11 +69,26 @@ function jsonCloneRecord(value) {
|
|
|
65
69
|
return { ...record };
|
|
66
70
|
}
|
|
67
71
|
}
|
|
72
|
+
function jsonCloneValue(value) {
|
|
73
|
+
if (value === void 0 || value === null) return void 0;
|
|
74
|
+
try {
|
|
75
|
+
return JSON.parse(JSON.stringify(value));
|
|
76
|
+
} catch {
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
68
80
|
function compactText(value, limit = 1600) {
|
|
69
81
|
const text = nonEmptyString(value);
|
|
70
82
|
if (!text) return void 0;
|
|
71
83
|
return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
|
|
72
84
|
}
|
|
85
|
+
function statePathsForRunState(state, engineStatePath) {
|
|
86
|
+
return compactRecord({
|
|
87
|
+
wrapper_state_path: state.state_path || state.request.harness_state_path || null,
|
|
88
|
+
engine_state_path: engineStatePath || state.request.engine_state_path || null,
|
|
89
|
+
resume_state_path: engineStatePath || state.request.engine_state_path || null
|
|
90
|
+
});
|
|
91
|
+
}
|
|
73
92
|
function responseSchemaForAuthorPacket() {
|
|
74
93
|
return {
|
|
75
94
|
type: "object",
|
|
@@ -211,6 +230,40 @@ function normalizeCheckpointResponse(value) {
|
|
|
211
230
|
created_at: nonEmptyString(record.created_at) || timestamp()
|
|
212
231
|
});
|
|
213
232
|
}
|
|
233
|
+
function checkpointSummaryFromState(state, engineStatePath) {
|
|
234
|
+
const history = state.checkpoint_history || [];
|
|
235
|
+
const packets = history.filter((entry) => entry.packet);
|
|
236
|
+
const responses = history.filter((entry) => entry.response);
|
|
237
|
+
const latestPacketEntry = [...history].reverse().find((entry) => entry.packet);
|
|
238
|
+
const latestResponseEntry = [...history].reverse().find((entry) => entry.response);
|
|
239
|
+
const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
|
|
240
|
+
const latestResponse = latestResponseEntry?.response;
|
|
241
|
+
const latestResumeToken = latestPacket?.resume_token || null;
|
|
242
|
+
const latestResponseToken = latestResponse?.resume_token || null;
|
|
243
|
+
const tokenMatches = latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
|
|
244
|
+
return compactRecord({
|
|
245
|
+
pending: Boolean(state.checkpoint_packet),
|
|
246
|
+
packet_count: packets.length,
|
|
247
|
+
response_count: responses.length,
|
|
248
|
+
latest_checkpoint: state.checkpoint_packet?.checkpoint || latestResponse?.checkpoint || state.last_checkpoint || null,
|
|
249
|
+
latest_stage: state.checkpoint_packet?.stage || latestResponse?.continue_with_stage || state.current_stage || null,
|
|
250
|
+
latest_kind: state.checkpoint_packet?.kind || latestPacket?.kind || null,
|
|
251
|
+
latest_decision: latestResponse?.decision || null,
|
|
252
|
+
latest_packet_summary: latestPacket?.summary || null,
|
|
253
|
+
latest_response_summary: latestResponse?.summary || null,
|
|
254
|
+
latest_resume_token: latestResumeToken,
|
|
255
|
+
latest_response_token: latestResponseToken,
|
|
256
|
+
token_matches: tokenMatches,
|
|
257
|
+
last_packet_at: latestPacketEntry?.ts || null,
|
|
258
|
+
last_response_at: latestResponseEntry?.ts || null,
|
|
259
|
+
state_paths: statePathsForRunState(state, engineStatePath)
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function isDuplicateCheckpointResponse(state, response) {
|
|
263
|
+
const latestResponse = [...state.checkpoint_history || []].reverse().find((entry) => entry.response)?.response;
|
|
264
|
+
if (!latestResponse) return false;
|
|
265
|
+
return latestResponse.run_id === response.run_id && latestResponse.checkpoint === response.checkpoint && latestResponse.resume_token === response.resume_token && latestResponse.decision === response.decision;
|
|
266
|
+
}
|
|
214
267
|
function authorPacketPayloadFromCheckpointResponse(response) {
|
|
215
268
|
if (response.decision !== "author_packet") return null;
|
|
216
269
|
const payload = recordValue(response.payload);
|
|
@@ -220,11 +273,46 @@ function authorPacketPayloadFromCheckpointResponse(response) {
|
|
|
220
273
|
if (!nonEmptyString(candidate.proof_plan) || !nonEmptyString(candidate.capture_script)) return null;
|
|
221
274
|
return candidate;
|
|
222
275
|
}
|
|
276
|
+
function proofContractFromAuthorCheckpointResponse(response, packet, payload) {
|
|
277
|
+
const refinedInputs = recordValue(payload.refined_inputs) || {};
|
|
278
|
+
return compactRecord({
|
|
279
|
+
version: "riddle-proof.proof-contract.v1",
|
|
280
|
+
checkpoint: packet.checkpoint,
|
|
281
|
+
source_response: compactRecord({
|
|
282
|
+
run_id: response.run_id,
|
|
283
|
+
checkpoint: response.checkpoint,
|
|
284
|
+
resume_token: response.resume_token,
|
|
285
|
+
decision: response.decision,
|
|
286
|
+
summary: response.summary,
|
|
287
|
+
created_at: response.created_at
|
|
288
|
+
}),
|
|
289
|
+
proof_plan: nonEmptyString(payload.proof_plan),
|
|
290
|
+
capture_script: nonEmptyString(payload.capture_script),
|
|
291
|
+
artifact_contract: jsonCloneRecord(payload.artifact_contract),
|
|
292
|
+
assertions: jsonCloneValue(payload.assertions),
|
|
293
|
+
baseline_understanding: jsonCloneRecord(payload.baseline_understanding) || jsonCloneRecord(payload.recon_baseline_understanding) || jsonCloneRecord(packet.state_excerpt?.recon_baseline_understanding),
|
|
294
|
+
route_assumptions: compactRecord({
|
|
295
|
+
server_path: nonEmptyString(refinedInputs.server_path) || nonEmptyString(payload.server_path) || nonEmptyString(packet.state_excerpt?.server_path),
|
|
296
|
+
wait_for_selector: nonEmptyString(refinedInputs.wait_for_selector) || nonEmptyString(payload.wait_for_selector) || nonEmptyString(packet.state_excerpt?.wait_for_selector),
|
|
297
|
+
reference: nonEmptyString(refinedInputs.reference) || nonEmptyString(payload.reference),
|
|
298
|
+
expected_path: nonEmptyString(payload.expected_path) || nonEmptyString(refinedInputs.expected_path)
|
|
299
|
+
}),
|
|
300
|
+
stop_condition: nonEmptyString(payload.stop_condition),
|
|
301
|
+
rationale: jsonCloneValue(payload.rationale),
|
|
302
|
+
verdict_dimensions: jsonCloneRecord(payload.verdict_dimensions),
|
|
303
|
+
payload: jsonCloneRecord(payload),
|
|
304
|
+
created_at: timestamp()
|
|
305
|
+
});
|
|
306
|
+
}
|
|
223
307
|
// Annotate the CommonJS export names for ESM import in node:
|
|
224
308
|
0 && (module.exports = {
|
|
225
309
|
RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
226
310
|
RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
227
311
|
authorPacketPayloadFromCheckpointResponse,
|
|
228
312
|
buildAuthorCheckpointPacket,
|
|
229
|
-
|
|
313
|
+
checkpointSummaryFromState,
|
|
314
|
+
isDuplicateCheckpointResponse,
|
|
315
|
+
normalizeCheckpointResponse,
|
|
316
|
+
proofContractFromAuthorCheckpointResponse,
|
|
317
|
+
statePathsForRunState
|
|
230
318
|
});
|
package/dist/checkpoint.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunState, RiddleProofCheckpointPacket } from './types.cjs';
|
|
1
|
+
import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunState, RiddleProofCheckpointPacket, RiddleProofCheckpointSummary, RiddleProofProofContract, RiddleProofStatePaths } from './types.cjs';
|
|
2
2
|
|
|
3
3
|
declare const RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION: "riddle-proof.checkpoint.v1";
|
|
4
4
|
declare const RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION: "riddle-proof.checkpoint_response.v1";
|
|
5
|
+
declare function statePathsForRunState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofStatePaths;
|
|
5
6
|
declare function buildAuthorCheckpointPacket(input: {
|
|
6
7
|
request: RiddleProofRunParams;
|
|
7
8
|
runState: RiddleProofRunState;
|
|
@@ -17,6 +18,9 @@ declare function buildAuthorCheckpointPacket(input: {
|
|
|
17
18
|
created_at?: string;
|
|
18
19
|
}): RiddleProofCheckpointPacket;
|
|
19
20
|
declare function normalizeCheckpointResponse(value: unknown): RiddleProofCheckpointResponse | null;
|
|
21
|
+
declare function checkpointSummaryFromState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofCheckpointSummary;
|
|
22
|
+
declare function isDuplicateCheckpointResponse(state: RiddleProofRunState, response: RiddleProofCheckpointResponse): boolean;
|
|
20
23
|
declare function authorPacketPayloadFromCheckpointResponse(response: RiddleProofCheckpointResponse): Record<string, unknown> | null;
|
|
24
|
+
declare function proofContractFromAuthorCheckpointResponse(response: RiddleProofCheckpointResponse, packet: RiddleProofCheckpointPacket, payload: Record<string, unknown>): RiddleProofProofContract;
|
|
21
25
|
|
|
22
|
-
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, normalizeCheckpointResponse };
|
|
26
|
+
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, checkpointSummaryFromState, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
|
package/dist/checkpoint.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunState, RiddleProofCheckpointPacket } from './types.js';
|
|
1
|
+
import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunState, RiddleProofCheckpointPacket, RiddleProofCheckpointSummary, RiddleProofProofContract, RiddleProofStatePaths } from './types.js';
|
|
2
2
|
|
|
3
3
|
declare const RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION: "riddle-proof.checkpoint.v1";
|
|
4
4
|
declare const RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION: "riddle-proof.checkpoint_response.v1";
|
|
5
|
+
declare function statePathsForRunState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofStatePaths;
|
|
5
6
|
declare function buildAuthorCheckpointPacket(input: {
|
|
6
7
|
request: RiddleProofRunParams;
|
|
7
8
|
runState: RiddleProofRunState;
|
|
@@ -17,6 +18,9 @@ declare function buildAuthorCheckpointPacket(input: {
|
|
|
17
18
|
created_at?: string;
|
|
18
19
|
}): RiddleProofCheckpointPacket;
|
|
19
20
|
declare function normalizeCheckpointResponse(value: unknown): RiddleProofCheckpointResponse | null;
|
|
21
|
+
declare function checkpointSummaryFromState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofCheckpointSummary;
|
|
22
|
+
declare function isDuplicateCheckpointResponse(state: RiddleProofRunState, response: RiddleProofCheckpointResponse): boolean;
|
|
20
23
|
declare function authorPacketPayloadFromCheckpointResponse(response: RiddleProofCheckpointResponse): Record<string, unknown> | null;
|
|
24
|
+
declare function proofContractFromAuthorCheckpointResponse(response: RiddleProofCheckpointResponse, packet: RiddleProofCheckpointPacket, payload: Record<string, unknown>): RiddleProofProofContract;
|
|
21
25
|
|
|
22
|
-
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, normalizeCheckpointResponse };
|
|
26
|
+
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, checkpointSummaryFromState, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
|
package/dist/checkpoint.js
CHANGED
|
@@ -3,13 +3,21 @@ import {
|
|
|
3
3
|
RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
4
4
|
authorPacketPayloadFromCheckpointResponse,
|
|
5
5
|
buildAuthorCheckpointPacket,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
checkpointSummaryFromState,
|
|
7
|
+
isDuplicateCheckpointResponse,
|
|
8
|
+
normalizeCheckpointResponse,
|
|
9
|
+
proofContractFromAuthorCheckpointResponse,
|
|
10
|
+
statePathsForRunState
|
|
11
|
+
} from "./chunk-5LVCGDSD.js";
|
|
12
|
+
import "./chunk-W7VTDN4T.js";
|
|
9
13
|
export {
|
|
10
14
|
RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
11
15
|
RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
12
16
|
authorPacketPayloadFromCheckpointResponse,
|
|
13
17
|
buildAuthorCheckpointPacket,
|
|
14
|
-
|
|
18
|
+
checkpointSummaryFromState,
|
|
19
|
+
isDuplicateCheckpointResponse,
|
|
20
|
+
normalizeCheckpointResponse,
|
|
21
|
+
proofContractFromAuthorCheckpointResponse,
|
|
22
|
+
statePathsForRunState
|
|
15
23
|
};
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
compactRecord,
|
|
3
3
|
nonEmptyString,
|
|
4
4
|
recordValue
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-W7VTDN4T.js";
|
|
6
6
|
|
|
7
7
|
// src/checkpoint.ts
|
|
8
8
|
import crypto from "crypto";
|
|
@@ -20,11 +20,26 @@ function jsonCloneRecord(value) {
|
|
|
20
20
|
return { ...record };
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
function jsonCloneValue(value) {
|
|
24
|
+
if (value === void 0 || value === null) return void 0;
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(JSON.stringify(value));
|
|
27
|
+
} catch {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
23
31
|
function compactText(value, limit = 1600) {
|
|
24
32
|
const text = nonEmptyString(value);
|
|
25
33
|
if (!text) return void 0;
|
|
26
34
|
return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
|
|
27
35
|
}
|
|
36
|
+
function statePathsForRunState(state, engineStatePath) {
|
|
37
|
+
return compactRecord({
|
|
38
|
+
wrapper_state_path: state.state_path || state.request.harness_state_path || null,
|
|
39
|
+
engine_state_path: engineStatePath || state.request.engine_state_path || null,
|
|
40
|
+
resume_state_path: engineStatePath || state.request.engine_state_path || null
|
|
41
|
+
});
|
|
42
|
+
}
|
|
28
43
|
function responseSchemaForAuthorPacket() {
|
|
29
44
|
return {
|
|
30
45
|
type: "object",
|
|
@@ -166,6 +181,40 @@ function normalizeCheckpointResponse(value) {
|
|
|
166
181
|
created_at: nonEmptyString(record.created_at) || timestamp()
|
|
167
182
|
});
|
|
168
183
|
}
|
|
184
|
+
function checkpointSummaryFromState(state, engineStatePath) {
|
|
185
|
+
const history = state.checkpoint_history || [];
|
|
186
|
+
const packets = history.filter((entry) => entry.packet);
|
|
187
|
+
const responses = history.filter((entry) => entry.response);
|
|
188
|
+
const latestPacketEntry = [...history].reverse().find((entry) => entry.packet);
|
|
189
|
+
const latestResponseEntry = [...history].reverse().find((entry) => entry.response);
|
|
190
|
+
const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
|
|
191
|
+
const latestResponse = latestResponseEntry?.response;
|
|
192
|
+
const latestResumeToken = latestPacket?.resume_token || null;
|
|
193
|
+
const latestResponseToken = latestResponse?.resume_token || null;
|
|
194
|
+
const tokenMatches = latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
|
|
195
|
+
return compactRecord({
|
|
196
|
+
pending: Boolean(state.checkpoint_packet),
|
|
197
|
+
packet_count: packets.length,
|
|
198
|
+
response_count: responses.length,
|
|
199
|
+
latest_checkpoint: state.checkpoint_packet?.checkpoint || latestResponse?.checkpoint || state.last_checkpoint || null,
|
|
200
|
+
latest_stage: state.checkpoint_packet?.stage || latestResponse?.continue_with_stage || state.current_stage || null,
|
|
201
|
+
latest_kind: state.checkpoint_packet?.kind || latestPacket?.kind || null,
|
|
202
|
+
latest_decision: latestResponse?.decision || null,
|
|
203
|
+
latest_packet_summary: latestPacket?.summary || null,
|
|
204
|
+
latest_response_summary: latestResponse?.summary || null,
|
|
205
|
+
latest_resume_token: latestResumeToken,
|
|
206
|
+
latest_response_token: latestResponseToken,
|
|
207
|
+
token_matches: tokenMatches,
|
|
208
|
+
last_packet_at: latestPacketEntry?.ts || null,
|
|
209
|
+
last_response_at: latestResponseEntry?.ts || null,
|
|
210
|
+
state_paths: statePathsForRunState(state, engineStatePath)
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function isDuplicateCheckpointResponse(state, response) {
|
|
214
|
+
const latestResponse = [...state.checkpoint_history || []].reverse().find((entry) => entry.response)?.response;
|
|
215
|
+
if (!latestResponse) return false;
|
|
216
|
+
return latestResponse.run_id === response.run_id && latestResponse.checkpoint === response.checkpoint && latestResponse.resume_token === response.resume_token && latestResponse.decision === response.decision;
|
|
217
|
+
}
|
|
169
218
|
function authorPacketPayloadFromCheckpointResponse(response) {
|
|
170
219
|
if (response.decision !== "author_packet") return null;
|
|
171
220
|
const payload = recordValue(response.payload);
|
|
@@ -175,11 +224,46 @@ function authorPacketPayloadFromCheckpointResponse(response) {
|
|
|
175
224
|
if (!nonEmptyString(candidate.proof_plan) || !nonEmptyString(candidate.capture_script)) return null;
|
|
176
225
|
return candidate;
|
|
177
226
|
}
|
|
227
|
+
function proofContractFromAuthorCheckpointResponse(response, packet, payload) {
|
|
228
|
+
const refinedInputs = recordValue(payload.refined_inputs) || {};
|
|
229
|
+
return compactRecord({
|
|
230
|
+
version: "riddle-proof.proof-contract.v1",
|
|
231
|
+
checkpoint: packet.checkpoint,
|
|
232
|
+
source_response: compactRecord({
|
|
233
|
+
run_id: response.run_id,
|
|
234
|
+
checkpoint: response.checkpoint,
|
|
235
|
+
resume_token: response.resume_token,
|
|
236
|
+
decision: response.decision,
|
|
237
|
+
summary: response.summary,
|
|
238
|
+
created_at: response.created_at
|
|
239
|
+
}),
|
|
240
|
+
proof_plan: nonEmptyString(payload.proof_plan),
|
|
241
|
+
capture_script: nonEmptyString(payload.capture_script),
|
|
242
|
+
artifact_contract: jsonCloneRecord(payload.artifact_contract),
|
|
243
|
+
assertions: jsonCloneValue(payload.assertions),
|
|
244
|
+
baseline_understanding: jsonCloneRecord(payload.baseline_understanding) || jsonCloneRecord(payload.recon_baseline_understanding) || jsonCloneRecord(packet.state_excerpt?.recon_baseline_understanding),
|
|
245
|
+
route_assumptions: compactRecord({
|
|
246
|
+
server_path: nonEmptyString(refinedInputs.server_path) || nonEmptyString(payload.server_path) || nonEmptyString(packet.state_excerpt?.server_path),
|
|
247
|
+
wait_for_selector: nonEmptyString(refinedInputs.wait_for_selector) || nonEmptyString(payload.wait_for_selector) || nonEmptyString(packet.state_excerpt?.wait_for_selector),
|
|
248
|
+
reference: nonEmptyString(refinedInputs.reference) || nonEmptyString(payload.reference),
|
|
249
|
+
expected_path: nonEmptyString(payload.expected_path) || nonEmptyString(refinedInputs.expected_path)
|
|
250
|
+
}),
|
|
251
|
+
stop_condition: nonEmptyString(payload.stop_condition),
|
|
252
|
+
rationale: jsonCloneValue(payload.rationale),
|
|
253
|
+
verdict_dimensions: jsonCloneRecord(payload.verdict_dimensions),
|
|
254
|
+
payload: jsonCloneRecord(payload),
|
|
255
|
+
created_at: timestamp()
|
|
256
|
+
});
|
|
257
|
+
}
|
|
178
258
|
|
|
179
259
|
export {
|
|
180
260
|
RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
181
261
|
RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
262
|
+
statePathsForRunState,
|
|
182
263
|
buildAuthorCheckpointPacket,
|
|
183
264
|
normalizeCheckpointResponse,
|
|
184
|
-
|
|
265
|
+
checkpointSummaryFromState,
|
|
266
|
+
isDuplicateCheckpointResponse,
|
|
267
|
+
authorPacketPayloadFromCheckpointResponse,
|
|
268
|
+
proofContractFromAuthorCheckpointResponse
|
|
185
269
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isTerminalStatus,
|
|
4
4
|
nonEmptyString,
|
|
5
5
|
recordValue
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-W7VTDN4T.js";
|
|
7
7
|
|
|
8
8
|
// src/state.ts
|
|
9
9
|
var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
|
|
@@ -128,6 +128,9 @@ function createRunState(input) {
|
|
|
128
128
|
iterations: input.iterations ?? 0,
|
|
129
129
|
last_checkpoint: input.last_checkpoint ?? null,
|
|
130
130
|
checkpoint_packet: input.checkpoint_packet,
|
|
131
|
+
checkpoint_summary: input.checkpoint_summary,
|
|
132
|
+
state_paths: input.state_paths,
|
|
133
|
+
proof_contract: input.proof_contract,
|
|
131
134
|
checkpoint_history: input.checkpoint_history,
|
|
132
135
|
events: input.events ? [...input.events] : []
|
|
133
136
|
});
|
|
@@ -203,6 +206,9 @@ function createRunStatusSnapshot(state, at = timestamp()) {
|
|
|
203
206
|
stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
|
|
204
207
|
blocker: state.blocker,
|
|
205
208
|
checkpoint_packet: state.checkpoint_packet,
|
|
209
|
+
checkpoint_summary: state.checkpoint_summary,
|
|
210
|
+
state_paths: state.state_paths,
|
|
211
|
+
proof_contract: state.proof_contract,
|
|
206
212
|
latest_event: latestEvent
|
|
207
213
|
});
|
|
208
214
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
authorPacketPayloadFromCheckpointResponse,
|
|
3
3
|
buildAuthorCheckpointPacket,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
checkpointSummaryFromState,
|
|
5
|
+
isDuplicateCheckpointResponse,
|
|
6
|
+
normalizeCheckpointResponse,
|
|
7
|
+
proofContractFromAuthorCheckpointResponse,
|
|
8
|
+
statePathsForRunState
|
|
9
|
+
} from "./chunk-5LVCGDSD.js";
|
|
6
10
|
import {
|
|
7
11
|
appendRunEvent,
|
|
8
12
|
appendStageHeartbeat,
|
|
@@ -10,7 +14,7 @@ import {
|
|
|
10
14
|
createRunStatusSnapshot,
|
|
11
15
|
normalizeRunParams,
|
|
12
16
|
setRunStatus
|
|
13
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7S7O3NKF.js";
|
|
14
18
|
import {
|
|
15
19
|
applyTerminalMetadata,
|
|
16
20
|
compactRecord,
|
|
@@ -18,7 +22,7 @@ import {
|
|
|
18
22
|
nonEmptyString,
|
|
19
23
|
normalizeTerminalMetadata,
|
|
20
24
|
recordValue
|
|
21
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-W7VTDN4T.js";
|
|
22
26
|
import {
|
|
23
27
|
visualDeltaShipGateReason
|
|
24
28
|
} from "./chunk-4YCWZVBN.js";
|
|
@@ -108,6 +112,8 @@ function shouldPreserveFinalizedRunState(filePath, incoming) {
|
|
|
108
112
|
return !(existing.status === "ready_to_ship" && incoming.status === "shipped");
|
|
109
113
|
}
|
|
110
114
|
function persist(state) {
|
|
115
|
+
state.state_paths = statePathsForRunState(state);
|
|
116
|
+
state.checkpoint_summary = checkpointSummaryFromState(state);
|
|
111
117
|
if (!state.state_path) return;
|
|
112
118
|
if (shouldPreserveFinalizedRunState(state.state_path, state)) return;
|
|
113
119
|
writeJson(state.state_path, state);
|
|
@@ -364,6 +370,10 @@ function engineFailureBlocker(result, checkpoint) {
|
|
|
364
370
|
};
|
|
365
371
|
}
|
|
366
372
|
function terminalResult(state, status, result, summary, raw = {}) {
|
|
373
|
+
if (result) {
|
|
374
|
+
const terminalStage = stageFromCheckpoint(result);
|
|
375
|
+
if (terminalStage !== "setup") state.current_stage = terminalStage;
|
|
376
|
+
}
|
|
367
377
|
setRunStatus(state, status);
|
|
368
378
|
if (isProtectedFinalStatus(status)) state.finalized = true;
|
|
369
379
|
const metadata = normalizeTerminalMetadata({
|
|
@@ -386,10 +396,12 @@ function terminalResult(state, status, result, summary, raw = {}) {
|
|
|
386
396
|
}
|
|
387
397
|
function blockerResult(state, result, blocker) {
|
|
388
398
|
state.blocker = blocker;
|
|
399
|
+
const blockerStage = nonEmptyString(recordValue(blocker.details)?.stage);
|
|
400
|
+
const stage = blockerStage || stageFromCheckpoint(result || { checkpoint: blocker.checkpoint || void 0 });
|
|
389
401
|
recordEvent(state, {
|
|
390
402
|
kind: "run.blocked",
|
|
391
403
|
checkpoint: blocker.checkpoint || result?.checkpoint || null,
|
|
392
|
-
stage
|
|
404
|
+
stage,
|
|
393
405
|
summary: blocker.message,
|
|
394
406
|
details: {
|
|
395
407
|
code: blocker.code,
|
|
@@ -481,17 +493,30 @@ function checkpointResponseContinuation(state, value) {
|
|
|
481
493
|
code: "checkpoint_response_invalid",
|
|
482
494
|
checkpoint: packet?.checkpoint || state.last_checkpoint || null,
|
|
483
495
|
message: "Checkpoint response was not a valid riddle-proof.checkpoint_response.v1 object.",
|
|
484
|
-
details: { checkpoint_packet: packet || null }
|
|
496
|
+
details: { checkpoint_packet: packet || null, checkpoint_summary: checkpointSummaryFromState(state) }
|
|
485
497
|
}
|
|
486
498
|
};
|
|
487
499
|
}
|
|
488
500
|
if (!packet) {
|
|
501
|
+
if (isDuplicateCheckpointResponse(state, response)) {
|
|
502
|
+
return {
|
|
503
|
+
blocker: {
|
|
504
|
+
code: "checkpoint_response_duplicate",
|
|
505
|
+
checkpoint: response.checkpoint,
|
|
506
|
+
message: "Checkpoint response was already accepted and there is no pending checkpoint packet to resume.",
|
|
507
|
+
details: {
|
|
508
|
+
response,
|
|
509
|
+
checkpoint_summary: checkpointSummaryFromState(state)
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
}
|
|
489
514
|
return {
|
|
490
515
|
blocker: {
|
|
491
516
|
code: "checkpoint_response_without_packet",
|
|
492
517
|
checkpoint: response.checkpoint,
|
|
493
518
|
message: "A checkpoint response was supplied, but the run state has no pending checkpoint packet.",
|
|
494
|
-
details: { response }
|
|
519
|
+
details: { response, checkpoint_summary: checkpointSummaryFromState(state) }
|
|
495
520
|
}
|
|
496
521
|
};
|
|
497
522
|
}
|
|
@@ -502,6 +527,7 @@ function checkpointResponseContinuation(state, value) {
|
|
|
502
527
|
checkpoint: packet.checkpoint,
|
|
503
528
|
message: "Checkpoint response does not match the pending checkpoint packet.",
|
|
504
529
|
details: {
|
|
530
|
+
stage: packet.stage,
|
|
505
531
|
expected: { run_id: packet.run_id, checkpoint: packet.checkpoint },
|
|
506
532
|
actual: { run_id: response.run_id, checkpoint: response.checkpoint }
|
|
507
533
|
}
|
|
@@ -514,7 +540,11 @@ function checkpointResponseContinuation(state, value) {
|
|
|
514
540
|
code: "checkpoint_response_resume_token_mismatch",
|
|
515
541
|
checkpoint: packet.checkpoint,
|
|
516
542
|
message: "Checkpoint response resume_token does not match the pending checkpoint packet.",
|
|
517
|
-
details: {
|
|
543
|
+
details: {
|
|
544
|
+
stage: packet.stage,
|
|
545
|
+
expected_resume_token: packet.resume_token,
|
|
546
|
+
actual_resume_token: response.resume_token || null
|
|
547
|
+
}
|
|
518
548
|
}
|
|
519
549
|
};
|
|
520
550
|
}
|
|
@@ -531,10 +561,11 @@ function checkpointResponseContinuation(state, value) {
|
|
|
531
561
|
code: "checkpoint_author_packet_missing",
|
|
532
562
|
checkpoint: packet.checkpoint,
|
|
533
563
|
message: "Checkpoint response decision=author_packet did not include a proof_plan and capture_script payload.",
|
|
534
|
-
details: { response }
|
|
564
|
+
details: { stage: packet.stage, response }
|
|
535
565
|
}
|
|
536
566
|
};
|
|
537
567
|
}
|
|
568
|
+
state.proof_contract = proofContractFromAuthorCheckpointResponse(response, packet, payload);
|
|
538
569
|
appendCheckpointResponse(state, response);
|
|
539
570
|
return { next: { ...base, author_packet_json: jsonParam(payload) } };
|
|
540
571
|
}
|
|
@@ -548,7 +579,7 @@ function checkpointResponseContinuation(state, value) {
|
|
|
548
579
|
code: `checkpoint_response_${response.decision}`,
|
|
549
580
|
checkpoint: packet.checkpoint,
|
|
550
581
|
message: response.summary || `Checkpoint response stopped the run with decision=${response.decision}.`,
|
|
551
|
-
details: { response }
|
|
582
|
+
details: { stage: packet.stage, response }
|
|
552
583
|
}
|
|
553
584
|
};
|
|
554
585
|
}
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
appendStageHeartbeat,
|
|
4
4
|
createRunState,
|
|
5
5
|
setRunStatus
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7S7O3NKF.js";
|
|
7
7
|
import {
|
|
8
8
|
createRunResult
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-W7VTDN4T.js";
|
|
10
10
|
|
|
11
11
|
// src/runner.ts
|
|
12
12
|
function errorDetails(error) {
|
|
@@ -203,6 +203,9 @@ function createRunResult(input) {
|
|
|
203
203
|
finalized: state.finalized,
|
|
204
204
|
blocker: state.blocker,
|
|
205
205
|
checkpoint_packet: state.checkpoint_packet,
|
|
206
|
+
checkpoint_summary: state.checkpoint_summary,
|
|
207
|
+
state_paths: state.state_paths,
|
|
208
|
+
proof_contract: state.proof_contract,
|
|
206
209
|
proof_session: state.proof_session,
|
|
207
210
|
evidence_bundle: input.evidence_bundle,
|
|
208
211
|
raw: input.raw
|