@riddledc/riddle-proof 0.5.37 → 0.5.39
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 +12 -8
- package/dist/checkpoint.cjs +230 -0
- package/dist/checkpoint.d.cts +22 -0
- package/dist/checkpoint.d.ts +22 -0
- package/dist/checkpoint.js +15 -0
- package/dist/{chunk-GN7HSZ6G.js → chunk-ORRP7CXT.js} +161 -3
- package/dist/{chunk-MQ2BHHLX.js → chunk-RDTMR7XR.js} +2 -2
- package/dist/chunk-UQPTCP4D.js +185 -0
- package/dist/{chunk-OASB3CYU.js → chunk-Z3BWCHFV.js} +4 -1
- package/dist/{chunk-J2MERROF.js → chunk-Z7QUCDPT.js} +1 -0
- package/dist/engine-harness.cjs +342 -13
- package/dist/engine-harness.d.cts +6 -2
- package/dist/engine-harness.d.ts +6 -2
- package/dist/engine-harness.js +4 -3
- package/dist/index.cjs +356 -17
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +25 -13
- package/dist/openclaw.js +2 -2
- package/dist/proof-run-engine.d.cts +3 -3
- package/dist/proof-run-engine.d.ts +3 -3
- package/dist/result.cjs +1 -0
- package/dist/result.js +1 -1
- package/dist/runner.cjs +3 -0
- package/dist/runner.js +3 -3
- package/dist/state.cjs +3 -0
- package/dist/state.d.cts +7 -1
- package/dist/state.d.ts +7 -1
- package/dist/state.js +2 -2
- package/dist/types.d.cts +63 -2
- package/dist/types.d.ts +63 -2
- package/lib/workspace-core.mjs +32 -1
- package/package.json +7 -2
- package/runtime/lib/setup.py +55 -9
package/dist/engine-harness.cjs
CHANGED
|
@@ -41,7 +41,7 @@ function currentDistDir() {
|
|
|
41
41
|
}
|
|
42
42
|
function createWorkflowStatePath() {
|
|
43
43
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.TZ]/g, "").slice(0, 14);
|
|
44
|
-
return `/tmp/riddle-proof-state-${stamp}-${(0,
|
|
44
|
+
return `/tmp/riddle-proof-state-${stamp}-${(0, import_node_crypto2.randomUUID)().slice(0, 8)}.json`;
|
|
45
45
|
}
|
|
46
46
|
function argsPathForStatePath(statePath) {
|
|
47
47
|
const base = import_node_path.default.basename(statePath);
|
|
@@ -759,12 +759,12 @@ function summarizeState(state) {
|
|
|
759
759
|
state: selected
|
|
760
760
|
};
|
|
761
761
|
}
|
|
762
|
-
var import_node_fs,
|
|
762
|
+
var import_node_fs, import_node_crypto2, import_node_path, import_node_url, import_meta, WORKFLOW_STAGE_ORDER, CHECKPOINT_CONTRACT_VERSION, BUNDLED_RIDDLE_PROOF_DIR, RIDDLE_PROOF_DIR_CANDIDATES, VISUAL_FIRST_MODES, CHECKPOINT_CONTRACT_SPECS;
|
|
763
763
|
var init_proof_run_core = __esm({
|
|
764
764
|
"src/proof-run-core.ts"() {
|
|
765
765
|
"use strict";
|
|
766
766
|
import_node_fs = require("fs");
|
|
767
|
-
|
|
767
|
+
import_node_crypto2 = require("crypto");
|
|
768
768
|
import_node_path = __toESM(require("path"), 1);
|
|
769
769
|
import_node_url = require("url");
|
|
770
770
|
import_meta = {};
|
|
@@ -2739,7 +2739,7 @@ module.exports = __toCommonJS(engine_harness_exports);
|
|
|
2739
2739
|
var import_node_child_process2 = require("child_process");
|
|
2740
2740
|
var import_node_fs3 = require("fs");
|
|
2741
2741
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
2742
|
-
var
|
|
2742
|
+
var import_node_crypto3 = __toESM(require("crypto"), 1);
|
|
2743
2743
|
|
|
2744
2744
|
// src/result.ts
|
|
2745
2745
|
function isTerminalStatus(status) {
|
|
@@ -2945,6 +2945,7 @@ function createRunResult(input) {
|
|
|
2945
2945
|
merge_recommendation: state.merge_recommendation,
|
|
2946
2946
|
finalized: state.finalized,
|
|
2947
2947
|
blocker: state.blocker,
|
|
2948
|
+
checkpoint_packet: state.checkpoint_packet,
|
|
2948
2949
|
proof_session: state.proof_session,
|
|
2949
2950
|
evidence_bundle: input.evidence_bundle,
|
|
2950
2951
|
raw: input.raw
|
|
@@ -3043,6 +3044,8 @@ function createRunState(input) {
|
|
|
3043
3044
|
request: normalizeRunParams(input.request),
|
|
3044
3045
|
iterations: input.iterations ?? 0,
|
|
3045
3046
|
last_checkpoint: input.last_checkpoint ?? null,
|
|
3047
|
+
checkpoint_packet: input.checkpoint_packet,
|
|
3048
|
+
checkpoint_history: input.checkpoint_history,
|
|
3046
3049
|
events: input.events ? [...input.events] : []
|
|
3047
3050
|
});
|
|
3048
3051
|
}
|
|
@@ -3116,6 +3119,7 @@ function createRunStatusSnapshot(state, at = timestamp()) {
|
|
|
3116
3119
|
elapsed_ms: elapsedMs(state.created_at, at),
|
|
3117
3120
|
stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
|
|
3118
3121
|
blocker: state.blocker,
|
|
3122
|
+
checkpoint_packet: state.checkpoint_packet,
|
|
3119
3123
|
latest_event: latestEvent
|
|
3120
3124
|
});
|
|
3121
3125
|
}
|
|
@@ -3126,6 +3130,178 @@ function setRunStatus(state, status, at = timestamp()) {
|
|
|
3126
3130
|
return state;
|
|
3127
3131
|
}
|
|
3128
3132
|
|
|
3133
|
+
// src/checkpoint.ts
|
|
3134
|
+
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
3135
|
+
var RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION = "riddle-proof.checkpoint.v1";
|
|
3136
|
+
var RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION = "riddle-proof.checkpoint_response.v1";
|
|
3137
|
+
function timestamp2() {
|
|
3138
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3139
|
+
}
|
|
3140
|
+
function jsonCloneRecord(value) {
|
|
3141
|
+
const record = recordValue(value);
|
|
3142
|
+
if (!record) return void 0;
|
|
3143
|
+
try {
|
|
3144
|
+
return JSON.parse(JSON.stringify(record));
|
|
3145
|
+
} catch {
|
|
3146
|
+
return { ...record };
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
function compactText(value, limit = 1600) {
|
|
3150
|
+
const text = nonEmptyString(value);
|
|
3151
|
+
if (!text) return void 0;
|
|
3152
|
+
return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
|
|
3153
|
+
}
|
|
3154
|
+
function responseSchemaForAuthorPacket() {
|
|
3155
|
+
return {
|
|
3156
|
+
type: "object",
|
|
3157
|
+
required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
|
|
3158
|
+
additionalProperties: false,
|
|
3159
|
+
properties: {
|
|
3160
|
+
version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
|
|
3161
|
+
run_id: { type: "string" },
|
|
3162
|
+
checkpoint: { type: "string" },
|
|
3163
|
+
resume_token: { type: "string" },
|
|
3164
|
+
decision: {
|
|
3165
|
+
type: "string",
|
|
3166
|
+
enum: ["author_packet", "needs_recon", "blocked", "human_review"]
|
|
3167
|
+
},
|
|
3168
|
+
summary: { type: "string" },
|
|
3169
|
+
payload: {
|
|
3170
|
+
type: "object",
|
|
3171
|
+
description: "For decision=author_packet, provide the proof packet itself or {author_packet:{...}} with proof_plan and capture_script."
|
|
3172
|
+
},
|
|
3173
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
3174
|
+
continue_with_stage: { type: "string", enum: ["author", "recon"] },
|
|
3175
|
+
source: {
|
|
3176
|
+
type: "object",
|
|
3177
|
+
properties: {
|
|
3178
|
+
kind: { type: "string" },
|
|
3179
|
+
session_id: { type: "string" },
|
|
3180
|
+
user_id: { type: "string" }
|
|
3181
|
+
}
|
|
3182
|
+
},
|
|
3183
|
+
created_at: { type: "string" }
|
|
3184
|
+
}
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
3187
|
+
function resumeTokenFor(input) {
|
|
3188
|
+
const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
|
|
3189
|
+
return `rpchk_${hash}`;
|
|
3190
|
+
}
|
|
3191
|
+
function artifactsFromState(state) {
|
|
3192
|
+
const artifacts = [];
|
|
3193
|
+
for (const role of ["before", "prod", "after"]) {
|
|
3194
|
+
const url = nonEmptyString(state?.[`${role}_cdn`]);
|
|
3195
|
+
if (url) artifacts.push({ role, url, name: `${role}.png`, mime_type: "image/png" });
|
|
3196
|
+
}
|
|
3197
|
+
const authorRequest = recordValue(state?.author_request);
|
|
3198
|
+
const latestAttempt = recordValue(authorRequest?.latest_attempt);
|
|
3199
|
+
const observations = recordValue(latestAttempt?.observations);
|
|
3200
|
+
for (const [label, observation] of Object.entries(observations || {})) {
|
|
3201
|
+
const record = recordValue(observation);
|
|
3202
|
+
const url = nonEmptyString(record?.url);
|
|
3203
|
+
if (url && !artifacts.some((artifact) => artifact.url === url)) {
|
|
3204
|
+
artifacts.push({
|
|
3205
|
+
role: label === "before" || label === "prod" ? label : "json",
|
|
3206
|
+
url,
|
|
3207
|
+
name: `${label}-observation`,
|
|
3208
|
+
summary: compactText(record?.reason, 240)
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
return artifacts.slice(0, 16);
|
|
3213
|
+
}
|
|
3214
|
+
function buildAuthorCheckpointPacket(input) {
|
|
3215
|
+
const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
|
|
3216
|
+
const stage = "author";
|
|
3217
|
+
const runId = input.runState.run_id || "unknown";
|
|
3218
|
+
const fullState = input.fullRiddleState || {};
|
|
3219
|
+
const decisionDetails = recordValue(input.engineResult.decisionRequest?.details);
|
|
3220
|
+
const authorRequest = recordValue(fullState.author_request) || recordValue(fullState.proof_plan_request) || recordValue(decisionDetails?.authorRequest) || {};
|
|
3221
|
+
const fallbackDefaults = recordValue(authorRequest.fallback_defaults) || {};
|
|
3222
|
+
const reconResults = recordValue(fullState.recon_results);
|
|
3223
|
+
const checkpointContract = recordValue(input.engineResult.checkpointContract);
|
|
3224
|
+
const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
|
|
3225
|
+
return {
|
|
3226
|
+
version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
3227
|
+
run_id: runId,
|
|
3228
|
+
state_path: input.runState.state_path,
|
|
3229
|
+
stage,
|
|
3230
|
+
checkpoint,
|
|
3231
|
+
kind: "author_proof",
|
|
3232
|
+
summary,
|
|
3233
|
+
question: "Author the proof packet for this Riddle Proof run. Return a CheckpointResponse with decision=author_packet and payload containing proof_plan and capture_script.",
|
|
3234
|
+
change_request: input.request.change_request || nonEmptyString(fullState.change_request) || "",
|
|
3235
|
+
context: input.request.context,
|
|
3236
|
+
artifacts: artifactsFromState(fullState),
|
|
3237
|
+
state_excerpt: compactRecord({
|
|
3238
|
+
repo: input.request.repo || fullState.repo,
|
|
3239
|
+
branch: input.request.branch || fullState.branch,
|
|
3240
|
+
verification_mode: input.request.verification_mode || fullState.verification_mode,
|
|
3241
|
+
reference: input.request.reference || fullState.reference,
|
|
3242
|
+
server_path: fullState.server_path,
|
|
3243
|
+
wait_for_selector: fullState.wait_for_selector,
|
|
3244
|
+
author_summary: fullState.author_summary,
|
|
3245
|
+
author_request: jsonCloneRecord(authorRequest),
|
|
3246
|
+
recon_baseline_understanding: jsonCloneRecord(fullState.recon_baseline_understanding),
|
|
3247
|
+
fallback_defaults: jsonCloneRecord(fallbackDefaults)
|
|
3248
|
+
}),
|
|
3249
|
+
evidence_excerpt: compactRecord({
|
|
3250
|
+
recon_results: jsonCloneRecord(reconResults),
|
|
3251
|
+
checkpoint_contract: jsonCloneRecord(checkpointContract)
|
|
3252
|
+
}),
|
|
3253
|
+
allowed_decisions: ["author_packet", "needs_recon", "blocked", "human_review"],
|
|
3254
|
+
response_schema: responseSchemaForAuthorPacket(),
|
|
3255
|
+
routing_hint: {
|
|
3256
|
+
suggested_role: "proof_author",
|
|
3257
|
+
visibility: input.visibility || "quiet",
|
|
3258
|
+
urgency: "normal",
|
|
3259
|
+
can_auto_answer: input.visibility !== "manual"
|
|
3260
|
+
},
|
|
3261
|
+
resume_token: resumeTokenFor({
|
|
3262
|
+
runId,
|
|
3263
|
+
statePath: input.engineResult.state_path || input.request.engine_state_path || null,
|
|
3264
|
+
checkpoint,
|
|
3265
|
+
stage
|
|
3266
|
+
}),
|
|
3267
|
+
created_at: input.created_at || timestamp2()
|
|
3268
|
+
};
|
|
3269
|
+
}
|
|
3270
|
+
function normalizeCheckpointResponse(value) {
|
|
3271
|
+
const record = recordValue(value);
|
|
3272
|
+
if (!record) return null;
|
|
3273
|
+
const version = nonEmptyString(record.version);
|
|
3274
|
+
const runId = nonEmptyString(record.run_id);
|
|
3275
|
+
const checkpoint = nonEmptyString(record.checkpoint);
|
|
3276
|
+
const decision = nonEmptyString(record.decision);
|
|
3277
|
+
const summary = nonEmptyString(record.summary);
|
|
3278
|
+
if (version !== RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION || !runId || !checkpoint || !decision || !summary) {
|
|
3279
|
+
return null;
|
|
3280
|
+
}
|
|
3281
|
+
return compactRecord({
|
|
3282
|
+
version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
3283
|
+
run_id: runId,
|
|
3284
|
+
checkpoint,
|
|
3285
|
+
resume_token: nonEmptyString(record.resume_token),
|
|
3286
|
+
decision,
|
|
3287
|
+
summary,
|
|
3288
|
+
payload: jsonCloneRecord(record.payload),
|
|
3289
|
+
reasons: Array.isArray(record.reasons) ? record.reasons.filter((item) => typeof item === "string") : void 0,
|
|
3290
|
+
continue_with_stage: nonEmptyString(record.continue_with_stage),
|
|
3291
|
+
source: jsonCloneRecord(record.source),
|
|
3292
|
+
created_at: nonEmptyString(record.created_at) || timestamp2()
|
|
3293
|
+
});
|
|
3294
|
+
}
|
|
3295
|
+
function authorPacketPayloadFromCheckpointResponse(response) {
|
|
3296
|
+
if (response.decision !== "author_packet") return null;
|
|
3297
|
+
const payload = recordValue(response.payload);
|
|
3298
|
+
if (!payload) return null;
|
|
3299
|
+
const nested = recordValue(payload.author_packet);
|
|
3300
|
+
const candidate = nested || payload;
|
|
3301
|
+
if (!nonEmptyString(candidate.proof_plan) || !nonEmptyString(candidate.capture_script)) return null;
|
|
3302
|
+
return candidate;
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3129
3305
|
// src/engine-harness.ts
|
|
3130
3306
|
init_proof_run_core();
|
|
3131
3307
|
var DEFAULT_MAX_ITERATIONS = 12;
|
|
@@ -3139,12 +3315,12 @@ var DEFAULT_STAGE_ITERATION_LIMITS = {
|
|
|
3139
3315
|
ship: 2,
|
|
3140
3316
|
notify: 2
|
|
3141
3317
|
};
|
|
3142
|
-
function
|
|
3318
|
+
function timestamp3() {
|
|
3143
3319
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3144
3320
|
}
|
|
3145
3321
|
function createHarnessStatePath(stateDir) {
|
|
3146
|
-
const stamp =
|
|
3147
|
-
return import_node_path3.default.join(stateDir, `riddle-proof-run-${stamp}-${
|
|
3322
|
+
const stamp = timestamp3().replace(/\D/g, "").slice(0, 14) || "unknown";
|
|
3323
|
+
return import_node_path3.default.join(stateDir, `riddle-proof-run-${stamp}-${import_node_crypto3.default.randomUUID().slice(0, 8)}.json`);
|
|
3148
3324
|
}
|
|
3149
3325
|
function createEngineStatePath(state, config) {
|
|
3150
3326
|
const existing = nonEmptyString(state.request.engine_state_path);
|
|
@@ -3159,8 +3335,8 @@ function createEngineStatePath(state, config) {
|
|
|
3159
3335
|
return import_node_path3.default.join(dir, `${base}.engine-state.json`);
|
|
3160
3336
|
}
|
|
3161
3337
|
const stateDir = config?.stateDir || "/tmp";
|
|
3162
|
-
const stamp =
|
|
3163
|
-
return import_node_path3.default.join(stateDir, `riddle-proof-state-${stamp}-${
|
|
3338
|
+
const stamp = timestamp3().replace(/\D/g, "").slice(0, 14) || "unknown";
|
|
3339
|
+
return import_node_path3.default.join(stateDir, `riddle-proof-state-${stamp}-${import_node_crypto3.default.randomUUID().slice(0, 8)}.json`);
|
|
3164
3340
|
}
|
|
3165
3341
|
function ensureParent(filePath) {
|
|
3166
3342
|
(0, import_node_fs3.mkdirSync)(import_node_path3.default.dirname(filePath), { recursive: true });
|
|
@@ -3501,6 +3677,150 @@ function blockerResult(state, result, blocker) {
|
|
|
3501
3677
|
}
|
|
3502
3678
|
});
|
|
3503
3679
|
}
|
|
3680
|
+
function checkpointAwaitingResult(state, result, visibility) {
|
|
3681
|
+
const packet = buildAuthorCheckpointPacket({
|
|
3682
|
+
request: state.request,
|
|
3683
|
+
runState: state,
|
|
3684
|
+
engineResult: result,
|
|
3685
|
+
fullRiddleState: fullRiddleState(result, state),
|
|
3686
|
+
visibility
|
|
3687
|
+
});
|
|
3688
|
+
const at = timestamp3();
|
|
3689
|
+
state.checkpoint_packet = packet;
|
|
3690
|
+
state.checkpoint_history = [
|
|
3691
|
+
...state.checkpoint_history || [],
|
|
3692
|
+
{ ts: at, packet }
|
|
3693
|
+
].slice(-25);
|
|
3694
|
+
appendRunEvent(state, {
|
|
3695
|
+
ts: at,
|
|
3696
|
+
kind: "checkpoint.packet.created",
|
|
3697
|
+
checkpoint: packet.checkpoint,
|
|
3698
|
+
stage: packet.stage,
|
|
3699
|
+
summary: packet.summary,
|
|
3700
|
+
details: compactRecord({
|
|
3701
|
+
kind: packet.kind,
|
|
3702
|
+
routing_hint: packet.routing_hint,
|
|
3703
|
+
resume_token: packet.resume_token
|
|
3704
|
+
})
|
|
3705
|
+
});
|
|
3706
|
+
setRunStatus(state, "awaiting_checkpoint", at);
|
|
3707
|
+
persist(state);
|
|
3708
|
+
return createRunResult({
|
|
3709
|
+
state,
|
|
3710
|
+
status: "awaiting_checkpoint",
|
|
3711
|
+
last_summary: packet.summary,
|
|
3712
|
+
raw: {
|
|
3713
|
+
engine_state_path: result.state_path || state.request.engine_state_path || null,
|
|
3714
|
+
last_result: result,
|
|
3715
|
+
checkpoint_packet: packet
|
|
3716
|
+
}
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3719
|
+
function appendCheckpointResponse(state, response, input = {}) {
|
|
3720
|
+
const at = timestamp3();
|
|
3721
|
+
state.checkpoint_history = [
|
|
3722
|
+
...state.checkpoint_history || [],
|
|
3723
|
+
{ ts: at, response }
|
|
3724
|
+
].slice(-25);
|
|
3725
|
+
if (input.clear_packet !== false) {
|
|
3726
|
+
state.checkpoint_packet = void 0;
|
|
3727
|
+
}
|
|
3728
|
+
appendRunEvent(state, {
|
|
3729
|
+
ts: at,
|
|
3730
|
+
kind: "checkpoint.response.accepted",
|
|
3731
|
+
checkpoint: response.checkpoint,
|
|
3732
|
+
stage: state.current_stage || "author",
|
|
3733
|
+
summary: input.summary || response.summary,
|
|
3734
|
+
details: compactRecord({
|
|
3735
|
+
decision: response.decision,
|
|
3736
|
+
resume_token: response.resume_token,
|
|
3737
|
+
source: response.source
|
|
3738
|
+
})
|
|
3739
|
+
});
|
|
3740
|
+
setRunStatus(state, "running", at);
|
|
3741
|
+
persist(state);
|
|
3742
|
+
}
|
|
3743
|
+
function checkpointResponseContinuation(state, value) {
|
|
3744
|
+
if (!value) return {};
|
|
3745
|
+
const packet = state.checkpoint_packet;
|
|
3746
|
+
const response = normalizeCheckpointResponse(value);
|
|
3747
|
+
if (!response) {
|
|
3748
|
+
return {
|
|
3749
|
+
blocker: {
|
|
3750
|
+
code: "checkpoint_response_invalid",
|
|
3751
|
+
checkpoint: packet?.checkpoint || state.last_checkpoint || null,
|
|
3752
|
+
message: "Checkpoint response was not a valid riddle-proof.checkpoint_response.v1 object.",
|
|
3753
|
+
details: { checkpoint_packet: packet || null }
|
|
3754
|
+
}
|
|
3755
|
+
};
|
|
3756
|
+
}
|
|
3757
|
+
if (!packet) {
|
|
3758
|
+
return {
|
|
3759
|
+
blocker: {
|
|
3760
|
+
code: "checkpoint_response_without_packet",
|
|
3761
|
+
checkpoint: response.checkpoint,
|
|
3762
|
+
message: "A checkpoint response was supplied, but the run state has no pending checkpoint packet.",
|
|
3763
|
+
details: { response }
|
|
3764
|
+
}
|
|
3765
|
+
};
|
|
3766
|
+
}
|
|
3767
|
+
if (response.run_id !== packet.run_id || response.checkpoint !== packet.checkpoint) {
|
|
3768
|
+
return {
|
|
3769
|
+
blocker: {
|
|
3770
|
+
code: "checkpoint_response_mismatch",
|
|
3771
|
+
checkpoint: packet.checkpoint,
|
|
3772
|
+
message: "Checkpoint response does not match the pending checkpoint packet.",
|
|
3773
|
+
details: {
|
|
3774
|
+
expected: { run_id: packet.run_id, checkpoint: packet.checkpoint },
|
|
3775
|
+
actual: { run_id: response.run_id, checkpoint: response.checkpoint }
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
};
|
|
3779
|
+
}
|
|
3780
|
+
if (packet.resume_token && response.resume_token !== packet.resume_token) {
|
|
3781
|
+
return {
|
|
3782
|
+
blocker: {
|
|
3783
|
+
code: "checkpoint_response_resume_token_mismatch",
|
|
3784
|
+
checkpoint: packet.checkpoint,
|
|
3785
|
+
message: "Checkpoint response resume_token does not match the pending checkpoint packet.",
|
|
3786
|
+
details: { expected_resume_token: packet.resume_token, actual_resume_token: response.resume_token || null }
|
|
3787
|
+
}
|
|
3788
|
+
};
|
|
3789
|
+
}
|
|
3790
|
+
const base = {
|
|
3791
|
+
action: "run",
|
|
3792
|
+
state_path: state.request.engine_state_path || packet.state_path || "",
|
|
3793
|
+
continue_from_checkpoint: true
|
|
3794
|
+
};
|
|
3795
|
+
if (response.decision === "author_packet") {
|
|
3796
|
+
const payload = authorPacketPayloadFromCheckpointResponse(response);
|
|
3797
|
+
if (!payload) {
|
|
3798
|
+
return {
|
|
3799
|
+
blocker: {
|
|
3800
|
+
code: "checkpoint_author_packet_missing",
|
|
3801
|
+
checkpoint: packet.checkpoint,
|
|
3802
|
+
message: "Checkpoint response decision=author_packet did not include a proof_plan and capture_script payload.",
|
|
3803
|
+
details: { response }
|
|
3804
|
+
}
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
appendCheckpointResponse(state, response);
|
|
3808
|
+
return { next: { ...base, author_packet_json: jsonParam(payload) } };
|
|
3809
|
+
}
|
|
3810
|
+
if (response.decision === "needs_recon") {
|
|
3811
|
+
appendCheckpointResponse(state, response);
|
|
3812
|
+
return { next: { ...base, advance_stage: "recon" } };
|
|
3813
|
+
}
|
|
3814
|
+
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
3815
|
+
return {
|
|
3816
|
+
blocker: {
|
|
3817
|
+
code: `checkpoint_response_${response.decision}`,
|
|
3818
|
+
checkpoint: packet.checkpoint,
|
|
3819
|
+
message: response.summary || `Checkpoint response stopped the run with decision=${response.decision}.`,
|
|
3820
|
+
details: { response }
|
|
3821
|
+
}
|
|
3822
|
+
};
|
|
3823
|
+
}
|
|
3504
3824
|
function disabledAdapterPayload(action, context) {
|
|
3505
3825
|
return {
|
|
3506
3826
|
ok: false,
|
|
@@ -3749,6 +4069,9 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
3749
4069
|
const continueStage = checkpointContinueStage2(result);
|
|
3750
4070
|
const checkpointContinuesToAuthor = continueStage === "author";
|
|
3751
4071
|
if (checkpoint === "author_supervisor_judgment" || checkpoint === "verify_capture_retry" || checkpoint === "verify_agent_retry" && checkpointContinuesToAuthor) {
|
|
4072
|
+
if (input.checkpoint_mode === "yield") {
|
|
4073
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
4074
|
+
}
|
|
3752
4075
|
const packet = await agent.authorProofPacket(context);
|
|
3753
4076
|
const blocker = requirePayload("author_packet", packet, state, result);
|
|
3754
4077
|
if (blocker) return { blocker };
|
|
@@ -3850,6 +4173,10 @@ async function runRiddleProofEngineHarness(input) {
|
|
|
3850
4173
|
const state = loadRunState(input);
|
|
3851
4174
|
state.request = normalizeRunParams({ ...state.request, ...input.request });
|
|
3852
4175
|
state.request.engine_state_path = nonEmptyString(input.resume_params?.state_path) || nonEmptyString(state.request.engine_state_path) || createEngineStatePath(state, input.config);
|
|
4176
|
+
const checkpointContinuation = checkpointResponseContinuation(state, input.checkpoint_response);
|
|
4177
|
+
if (checkpointContinuation.blocker) {
|
|
4178
|
+
return blockerResult(state, null, checkpointContinuation.blocker);
|
|
4179
|
+
}
|
|
3853
4180
|
const request = state.request;
|
|
3854
4181
|
const agent = input.agent || createDisabledRiddleProofAgentAdapter();
|
|
3855
4182
|
const maxIterations = Math.max(
|
|
@@ -3871,6 +4198,8 @@ async function runRiddleProofEngineHarness(input) {
|
|
|
3871
4198
|
engine_state_path: request.engine_state_path || null,
|
|
3872
4199
|
max_iterations: maxIterations,
|
|
3873
4200
|
ship_mode: effectiveShipMode(request, input.config),
|
|
4201
|
+
checkpoint_mode: input.checkpoint_mode || "auto",
|
|
4202
|
+
checkpoint_visibility: input.checkpoint_visibility || null,
|
|
3874
4203
|
leave_draft: request.leave_draft || false
|
|
3875
4204
|
}
|
|
3876
4205
|
});
|
|
@@ -3885,7 +4214,7 @@ async function runRiddleProofEngineHarness(input) {
|
|
|
3885
4214
|
message
|
|
3886
4215
|
});
|
|
3887
4216
|
}
|
|
3888
|
-
let nextParams = input.resume_params || initialRunParams(request, input, state);
|
|
4217
|
+
let nextParams = input.resume_params || checkpointContinuation.next || initialRunParams(request, input, state);
|
|
3889
4218
|
let lastResult = null;
|
|
3890
4219
|
const stageIterations = {};
|
|
3891
4220
|
for (let index = 0; index < maxIterations; index += 1) {
|
|
@@ -3906,7 +4235,7 @@ async function runRiddleProofEngineHarness(input) {
|
|
|
3906
4235
|
branch: state.branch || null
|
|
3907
4236
|
}
|
|
3908
4237
|
});
|
|
3909
|
-
const engineCallStartedAt =
|
|
4238
|
+
const engineCallStartedAt = timestamp3();
|
|
3910
4239
|
const engineCallStartedMs = Date.now();
|
|
3911
4240
|
recordEvent(state, {
|
|
3912
4241
|
kind: "engine.call",
|
|
@@ -3931,7 +4260,7 @@ async function runRiddleProofEngineHarness(input) {
|
|
|
3931
4260
|
details: {
|
|
3932
4261
|
duration_ms: Date.now() - engineCallStartedMs,
|
|
3933
4262
|
started_at: engineCallStartedAt,
|
|
3934
|
-
finished_at:
|
|
4263
|
+
finished_at: timestamp3()
|
|
3935
4264
|
}
|
|
3936
4265
|
});
|
|
3937
4266
|
return blockerResult(state, lastResult, {
|
|
@@ -3969,7 +4298,7 @@ async function runRiddleProofEngineHarness(input) {
|
|
|
3969
4298
|
checkpoint: result.checkpoint || null,
|
|
3970
4299
|
duration_ms: engineCallDurationMs,
|
|
3971
4300
|
started_at: engineCallStartedAt,
|
|
3972
|
-
finished_at:
|
|
4301
|
+
finished_at: timestamp3()
|
|
3973
4302
|
}
|
|
3974
4303
|
});
|
|
3975
4304
|
const stageLimit = DEFAULT_STAGE_ITERATION_LIMITS[resultStage];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { RiddleProofRunParams, RiddleProofRunState, RiddleProofBlocker, RiddleProofRunStatusSnapshot, RiddleProofRunResult } from './types.cjs';
|
|
1
|
+
import { RiddleProofRunParams, RiddleProofRunState, RiddleProofBlocker, RiddleProofCheckpointVisibility, RiddleProofCheckpointResponse, RiddleProofRunStatusSnapshot, RiddleProofRunResult } from './types.cjs';
|
|
2
2
|
|
|
3
3
|
type RiddleProofShipMode = "none" | "ship";
|
|
4
|
+
type RiddleProofCheckpointMode = "auto" | "yield";
|
|
4
5
|
interface RiddleProofWorkflowParams extends Record<string, unknown> {
|
|
5
6
|
action: string;
|
|
6
7
|
state_path?: string;
|
|
@@ -64,6 +65,9 @@ interface RunRiddleProofEngineHarnessInput {
|
|
|
64
65
|
state?: RiddleProofRunState;
|
|
65
66
|
state_path?: string;
|
|
66
67
|
resume_params?: RiddleProofWorkflowParams;
|
|
68
|
+
checkpoint_mode?: RiddleProofCheckpointMode;
|
|
69
|
+
checkpoint_visibility?: RiddleProofCheckpointVisibility;
|
|
70
|
+
checkpoint_response?: RiddleProofCheckpointResponse | Record<string, unknown>;
|
|
67
71
|
max_iterations?: number;
|
|
68
72
|
dry_run?: boolean;
|
|
69
73
|
auto_approve?: boolean;
|
|
@@ -72,4 +76,4 @@ declare function createDisabledRiddleProofAgentAdapter(): RiddleProofAgentAdapte
|
|
|
72
76
|
declare function readRiddleProofRunStatus(state_path: string): RiddleProofRunStatusSnapshot | null;
|
|
73
77
|
declare function runRiddleProofEngineHarness(input: RunRiddleProofEngineHarnessInput): Promise<RiddleProofRunResult>;
|
|
74
78
|
|
|
75
|
-
export { type RiddleProofAgentAdapter, type RiddleProofAgentPayload, type RiddleProofEngine, type RiddleProofEngineHarnessConfig, type RiddleProofEngineHarnessContext, type RiddleProofEngineResult, type RiddleProofShipMode, type RiddleProofWorkflowParams, type RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness };
|
|
79
|
+
export { type RiddleProofAgentAdapter, type RiddleProofAgentPayload, type RiddleProofCheckpointMode, type RiddleProofEngine, type RiddleProofEngineHarnessConfig, type RiddleProofEngineHarnessContext, type RiddleProofEngineResult, type RiddleProofShipMode, type RiddleProofWorkflowParams, type RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness };
|
package/dist/engine-harness.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { RiddleProofRunParams, RiddleProofRunState, RiddleProofBlocker, RiddleProofRunStatusSnapshot, RiddleProofRunResult } from './types.js';
|
|
1
|
+
import { RiddleProofRunParams, RiddleProofRunState, RiddleProofBlocker, RiddleProofCheckpointVisibility, RiddleProofCheckpointResponse, RiddleProofRunStatusSnapshot, RiddleProofRunResult } from './types.js';
|
|
2
2
|
|
|
3
3
|
type RiddleProofShipMode = "none" | "ship";
|
|
4
|
+
type RiddleProofCheckpointMode = "auto" | "yield";
|
|
4
5
|
interface RiddleProofWorkflowParams extends Record<string, unknown> {
|
|
5
6
|
action: string;
|
|
6
7
|
state_path?: string;
|
|
@@ -64,6 +65,9 @@ interface RunRiddleProofEngineHarnessInput {
|
|
|
64
65
|
state?: RiddleProofRunState;
|
|
65
66
|
state_path?: string;
|
|
66
67
|
resume_params?: RiddleProofWorkflowParams;
|
|
68
|
+
checkpoint_mode?: RiddleProofCheckpointMode;
|
|
69
|
+
checkpoint_visibility?: RiddleProofCheckpointVisibility;
|
|
70
|
+
checkpoint_response?: RiddleProofCheckpointResponse | Record<string, unknown>;
|
|
67
71
|
max_iterations?: number;
|
|
68
72
|
dry_run?: boolean;
|
|
69
73
|
auto_approve?: boolean;
|
|
@@ -72,4 +76,4 @@ declare function createDisabledRiddleProofAgentAdapter(): RiddleProofAgentAdapte
|
|
|
72
76
|
declare function readRiddleProofRunStatus(state_path: string): RiddleProofRunStatusSnapshot | null;
|
|
73
77
|
declare function runRiddleProofEngineHarness(input: RunRiddleProofEngineHarnessInput): Promise<RiddleProofRunResult>;
|
|
74
78
|
|
|
75
|
-
export { type RiddleProofAgentAdapter, type RiddleProofAgentPayload, type RiddleProofEngine, type RiddleProofEngineHarnessConfig, type RiddleProofEngineHarnessContext, type RiddleProofEngineResult, type RiddleProofShipMode, type RiddleProofWorkflowParams, type RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness };
|
|
79
|
+
export { type RiddleProofAgentAdapter, type RiddleProofAgentPayload, type RiddleProofCheckpointMode, type RiddleProofEngine, type RiddleProofEngineHarnessConfig, type RiddleProofEngineHarnessContext, type RiddleProofEngineResult, type RiddleProofShipMode, type RiddleProofWorkflowParams, type RunRiddleProofEngineHarnessInput, createDisabledRiddleProofAgentAdapter, readRiddleProofRunStatus, runRiddleProofEngineHarness };
|
package/dist/engine-harness.js
CHANGED
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
createDisabledRiddleProofAgentAdapter,
|
|
3
3
|
readRiddleProofRunStatus,
|
|
4
4
|
runRiddleProofEngineHarness
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-ORRP7CXT.js";
|
|
6
|
+
import "./chunk-UQPTCP4D.js";
|
|
7
|
+
import "./chunk-Z3BWCHFV.js";
|
|
8
|
+
import "./chunk-Z7QUCDPT.js";
|
|
8
9
|
import "./chunk-4YCWZVBN.js";
|
|
9
10
|
export {
|
|
10
11
|
createDisabledRiddleProofAgentAdapter,
|