@riddledc/riddle-proof 0.5.45 → 0.5.47
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 +22 -0
- package/dist/checkpoint.cjs +204 -1
- package/dist/checkpoint.d.cts +16 -1
- package/dist/checkpoint.d.ts +16 -1
- package/dist/checkpoint.js +4 -2
- package/dist/{chunk-CHRYLX6N.js → chunk-ALP5KOS2.js} +128 -15
- package/dist/{chunk-W7VTDN4T.js → chunk-DUFDZJOF.js} +1 -0
- package/dist/chunk-JFQXAJH2.js +0 -0
- package/dist/{chunk-7S7O3NKF.js → chunk-JOXTKWX6.js} +6 -1
- package/dist/{chunk-MRSYJMF4.js → chunk-N3ZNBRIG.js} +2 -2
- package/dist/chunk-NOBFZDZG.js +754 -0
- package/dist/chunk-PLSGW2GI.js +161 -0
- package/dist/{chunk-LXE5YUYY.js → chunk-R6SCWJCI.js} +204 -2
- package/dist/cli.cjs +6134 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +166 -0
- package/dist/codex-exec-agent.cjs +790 -0
- package/dist/codex-exec-agent.d.cts +91 -0
- package/dist/codex-exec-agent.d.ts +91 -0
- package/dist/codex-exec-agent.js +10 -0
- package/dist/engine-harness.cjs +740 -279
- package/dist/engine-harness.js +5 -4
- package/dist/index.cjs +1475 -247
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +45 -25
- package/dist/local-agent.cjs +792 -0
- package/dist/local-agent.d.cts +3 -0
- package/dist/local-agent.d.ts +3 -0
- package/dist/local-agent.js +11 -0
- package/dist/openclaw.js +4 -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/run-card.cjs +212 -0
- package/dist/run-card.d.cts +10 -0
- package/dist/run-card.d.ts +10 -0
- package/dist/run-card.js +10 -0
- package/dist/runner.cjs +2 -0
- package/dist/runner.js +5 -3
- package/dist/state.cjs +174 -5
- package/dist/state.d.cts +2 -1
- package/dist/state.d.ts +2 -1
- package/dist/state.js +4 -2
- package/dist/types.d.cts +63 -2
- package/dist/types.d.ts +63 -2
- package/package.json +20 -2
package/README.md
CHANGED
|
@@ -56,6 +56,28 @@ adapters are exposed through subpaths such as
|
|
|
56
56
|
`@riddledc/riddle-proof/openclaw`, so wrappers can reuse the mapping logic
|
|
57
57
|
without depending on another plugin runtime.
|
|
58
58
|
|
|
59
|
+
## Durable Loop CLI
|
|
60
|
+
|
|
61
|
+
The package publishes `riddle-proof-loop` as a host-agnostic runner surface for
|
|
62
|
+
Codex/CLI-style testing:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
riddle-proof-loop run --request-json request.json --checkpoint-mode yield
|
|
66
|
+
riddle-proof-loop run --request-json request.json --agent local
|
|
67
|
+
riddle-proof-loop status --state-path /tmp/riddle-proof-run.json
|
|
68
|
+
riddle-proof-loop respond --state-path /tmp/riddle-proof-run.json --response-json response.json
|
|
69
|
+
riddle-proof-loop doctor local
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
In yield mode, the harness returns portable checkpoint packets for recon,
|
|
73
|
+
authoring, implementation, proof assessment, and evidence recovery. A host can
|
|
74
|
+
answer those packets with `riddle-proof.checkpoint_response.v1` JSON without
|
|
75
|
+
needing OpenClaw-specific proof semantics.
|
|
76
|
+
|
|
77
|
+
`--agent local` is the generic CLI executor slot. The current implementation
|
|
78
|
+
uses the local Codex CLI adapter underneath, but the loop contract and CLI
|
|
79
|
+
surface are intentionally not Codex-specific.
|
|
80
|
+
|
|
59
81
|
## Runner Harness
|
|
60
82
|
|
|
61
83
|
`runRiddleProof` is the reusable idea-to-PR workflow driver. It does not ship
|
package/dist/checkpoint.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(checkpoint_exports, {
|
|
|
36
36
|
buildAuthorCheckpointPacket: () => buildAuthorCheckpointPacket,
|
|
37
37
|
buildCheckpointPacketForEngineResult: () => buildCheckpointPacketForEngineResult,
|
|
38
38
|
buildProofAssessmentCheckpointPacket: () => buildProofAssessmentCheckpointPacket,
|
|
39
|
+
buildStageCheckpointPacket: () => buildStageCheckpointPacket,
|
|
39
40
|
checkpointResponseIdentity: () => checkpointResponseIdentity,
|
|
40
41
|
checkpointSummaryFromState: () => checkpointSummaryFromState,
|
|
41
42
|
isDuplicateCheckpointResponse: () => isDuplicateCheckpointResponse,
|
|
@@ -174,6 +175,102 @@ function responseSchemaForProofAssessmentPacket() {
|
|
|
174
175
|
}
|
|
175
176
|
};
|
|
176
177
|
}
|
|
178
|
+
function responseSchemaForReconPacket() {
|
|
179
|
+
return {
|
|
180
|
+
type: "object",
|
|
181
|
+
required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
|
|
182
|
+
additionalProperties: false,
|
|
183
|
+
properties: {
|
|
184
|
+
version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
|
|
185
|
+
run_id: { type: "string" },
|
|
186
|
+
checkpoint: { type: "string" },
|
|
187
|
+
resume_token: { type: "string" },
|
|
188
|
+
decision: {
|
|
189
|
+
type: "string",
|
|
190
|
+
enum: ["ready_for_author", "retry_recon", "recon_stuck", "needs_recon", "blocked", "human_review"]
|
|
191
|
+
},
|
|
192
|
+
summary: { type: "string" },
|
|
193
|
+
payload: {
|
|
194
|
+
type: "object",
|
|
195
|
+
description: "Optional recon assessment details such as baseline_understanding, refined_inputs, reasons, or diagnostic blocker context."
|
|
196
|
+
},
|
|
197
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
198
|
+
continue_with_stage: { type: "string", enum: ["recon", "author"] },
|
|
199
|
+
source: {
|
|
200
|
+
type: "object",
|
|
201
|
+
properties: {
|
|
202
|
+
kind: { type: "string" },
|
|
203
|
+
session_id: { type: "string" },
|
|
204
|
+
user_id: { type: "string" }
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
created_at: { type: "string" }
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function responseSchemaForImplementationPacket() {
|
|
212
|
+
return {
|
|
213
|
+
type: "object",
|
|
214
|
+
required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
|
|
215
|
+
additionalProperties: false,
|
|
216
|
+
properties: {
|
|
217
|
+
version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
|
|
218
|
+
run_id: { type: "string" },
|
|
219
|
+
checkpoint: { type: "string" },
|
|
220
|
+
resume_token: { type: "string" },
|
|
221
|
+
decision: {
|
|
222
|
+
type: "string",
|
|
223
|
+
enum: ["implementation_complete", "needs_author", "needs_recon", "blocked", "human_review"]
|
|
224
|
+
},
|
|
225
|
+
summary: { type: "string" },
|
|
226
|
+
payload: {
|
|
227
|
+
type: "object",
|
|
228
|
+
description: "Implementation details such as changed_files, tests_run, and implementation_notes. The changed worktree must contain a real git diff before verify can advance."
|
|
229
|
+
},
|
|
230
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
231
|
+
continue_with_stage: { type: "string", enum: ["implement", "verify", "author", "recon"] },
|
|
232
|
+
source: {
|
|
233
|
+
type: "object",
|
|
234
|
+
properties: {
|
|
235
|
+
kind: { type: "string" },
|
|
236
|
+
session_id: { type: "string" },
|
|
237
|
+
user_id: { type: "string" }
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
created_at: { type: "string" }
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function responseSchemaForAdvancePacket(stage) {
|
|
245
|
+
return {
|
|
246
|
+
type: "object",
|
|
247
|
+
required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
|
|
248
|
+
additionalProperties: false,
|
|
249
|
+
properties: {
|
|
250
|
+
version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
|
|
251
|
+
run_id: { type: "string" },
|
|
252
|
+
checkpoint: { type: "string" },
|
|
253
|
+
resume_token: { type: "string" },
|
|
254
|
+
decision: {
|
|
255
|
+
type: "string",
|
|
256
|
+
enum: ["continue_stage", "retry_stage", "needs_recon", "needs_implementation", "blocked", "human_review"]
|
|
257
|
+
},
|
|
258
|
+
summary: { type: "string" },
|
|
259
|
+
payload: { type: "object" },
|
|
260
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
261
|
+
continue_with_stage: { type: "string", enum: ["recon", "author", "implement", "verify", "ship", stage] },
|
|
262
|
+
source: {
|
|
263
|
+
type: "object",
|
|
264
|
+
properties: {
|
|
265
|
+
kind: { type: "string" },
|
|
266
|
+
session_id: { type: "string" },
|
|
267
|
+
user_id: { type: "string" }
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
created_at: { type: "string" }
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
177
274
|
function resumeTokenFor(input) {
|
|
178
275
|
const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
|
|
179
276
|
return `rpchk_${hash}`;
|
|
@@ -201,6 +298,106 @@ function artifactsFromState(state) {
|
|
|
201
298
|
}
|
|
202
299
|
return artifacts.slice(0, 16);
|
|
203
300
|
}
|
|
301
|
+
function stageFromCheckpoint(checkpoint) {
|
|
302
|
+
if (checkpoint.startsWith("recon_")) return "recon";
|
|
303
|
+
if (checkpoint.startsWith("author_")) return "author";
|
|
304
|
+
if (checkpoint.startsWith("implement_")) return "implement";
|
|
305
|
+
if (checkpoint.startsWith("verify_")) return "verify";
|
|
306
|
+
if (checkpoint.startsWith("ship_")) return "ship";
|
|
307
|
+
if (checkpoint.startsWith("pr_sync_")) return "notify";
|
|
308
|
+
if (checkpoint.includes("capture")) return "prove";
|
|
309
|
+
return "setup";
|
|
310
|
+
}
|
|
311
|
+
function allowedDecisionsForStage(stage, checkpoint) {
|
|
312
|
+
if (stage === "recon") return ["ready_for_author", "retry_recon", "recon_stuck", "blocked", "human_review"];
|
|
313
|
+
if (stage === "implement") return ["implementation_complete", "needs_author", "needs_recon", "blocked", "human_review"];
|
|
314
|
+
if (stage === "ship") return ["continue_stage", "needs_implementation", "needs_recon", "blocked", "human_review"];
|
|
315
|
+
if (checkpoint === "awaiting_stage_advance") return ["continue_stage", "retry_stage", "blocked", "human_review"];
|
|
316
|
+
return ["continue_stage", "needs_recon", "needs_implementation", "blocked", "human_review"];
|
|
317
|
+
}
|
|
318
|
+
function packetKindForStage(stage, checkpoint) {
|
|
319
|
+
if (stage === "recon") return "assess_recon";
|
|
320
|
+
if (stage === "implement") return "implement_change";
|
|
321
|
+
if (checkpoint.includes("human")) return "human_review";
|
|
322
|
+
return "advance_decision";
|
|
323
|
+
}
|
|
324
|
+
function responseSchemaForStage(stage, checkpoint) {
|
|
325
|
+
if (stage === "recon") return responseSchemaForReconPacket();
|
|
326
|
+
if (stage === "implement") return responseSchemaForImplementationPacket();
|
|
327
|
+
return responseSchemaForAdvancePacket(stage);
|
|
328
|
+
}
|
|
329
|
+
function questionForStage(stage, checkpoint) {
|
|
330
|
+
if (stage === "recon") {
|
|
331
|
+
return "Assess the baseline/recon evidence. Return ready_for_author only when the baseline is trustworthy; otherwise choose retry_recon, recon_stuck, blocked, or human_review.";
|
|
332
|
+
}
|
|
333
|
+
if (stage === "implement") {
|
|
334
|
+
return "Implement the requested change in the after worktree, leave a real git diff, then return implementation_complete with changed_files/tests_run/implementation_notes. Choose blocked or human_review if implementation cannot honestly advance.";
|
|
335
|
+
}
|
|
336
|
+
if (stage === "ship") {
|
|
337
|
+
return "Assess whether the ship gate can continue. Return continue_stage only if proof, PR, and policy gates are satisfied; otherwise route to the appropriate earlier stage or block with a concrete reason.";
|
|
338
|
+
}
|
|
339
|
+
return "Choose the next Riddle Proof stage for this durable run, or block with a concrete reason if the run cannot honestly advance.";
|
|
340
|
+
}
|
|
341
|
+
function buildStageCheckpointPacket(input) {
|
|
342
|
+
const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "stage_checkpoint";
|
|
343
|
+
const stage = nonEmptyString(input.engineResult.stage) || stageFromCheckpoint(checkpoint);
|
|
344
|
+
const runId = input.runState.run_id || "unknown";
|
|
345
|
+
const fullState = input.fullRiddleState || {};
|
|
346
|
+
const decisionDetails = recordValue(input.engineResult.decisionRequest?.details);
|
|
347
|
+
const checkpointContract = recordValue(input.engineResult.checkpointContract);
|
|
348
|
+
const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
|
|
349
|
+
const kind = packetKindForStage(stage, checkpoint);
|
|
350
|
+
return {
|
|
351
|
+
version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
352
|
+
run_id: runId,
|
|
353
|
+
state_path: input.runState.state_path,
|
|
354
|
+
stage,
|
|
355
|
+
checkpoint,
|
|
356
|
+
kind,
|
|
357
|
+
summary,
|
|
358
|
+
question: questionForStage(stage, checkpoint),
|
|
359
|
+
change_request: input.request.change_request || nonEmptyString(fullState.change_request) || "",
|
|
360
|
+
context: input.request.context,
|
|
361
|
+
artifacts: artifactsFromState(fullState),
|
|
362
|
+
state_excerpt: compactRecord({
|
|
363
|
+
repo: input.request.repo || fullState.repo,
|
|
364
|
+
branch: input.request.branch || fullState.branch,
|
|
365
|
+
after_worktree: fullState.after_worktree || input.runState.worktree_path,
|
|
366
|
+
verification_mode: input.request.verification_mode || fullState.verification_mode,
|
|
367
|
+
reference: input.request.reference || fullState.reference,
|
|
368
|
+
server_path: fullState.server_path,
|
|
369
|
+
wait_for_selector: fullState.wait_for_selector,
|
|
370
|
+
recon_status: fullState.recon_status,
|
|
371
|
+
author_status: fullState.author_status,
|
|
372
|
+
implementation_status: fullState.implementation_status,
|
|
373
|
+
verify_status: fullState.verify_status,
|
|
374
|
+
stage_decision_request: jsonCloneRecord(fullState.stage_decision_request)
|
|
375
|
+
}),
|
|
376
|
+
evidence_excerpt: compactRecord({
|
|
377
|
+
before_cdn: fullState.before_cdn || null,
|
|
378
|
+
prod_cdn: fullState.prod_cdn || null,
|
|
379
|
+
after_cdn: fullState.after_cdn || null,
|
|
380
|
+
recon_results: jsonCloneRecord(fullState.recon_results),
|
|
381
|
+
checkpoint_contract: jsonCloneRecord(checkpointContract),
|
|
382
|
+
decision_details: jsonCloneRecord(decisionDetails)
|
|
383
|
+
}),
|
|
384
|
+
allowed_decisions: allowedDecisionsForStage(stage, checkpoint),
|
|
385
|
+
response_schema: responseSchemaForStage(stage, checkpoint),
|
|
386
|
+
routing_hint: {
|
|
387
|
+
suggested_role: stage === "implement" ? "builder_agent" : checkpoint.includes("human") ? "human" : "main_agent",
|
|
388
|
+
visibility: input.visibility || "quiet",
|
|
389
|
+
urgency: stage === "ship" ? "high" : "normal",
|
|
390
|
+
can_auto_answer: input.visibility !== "manual"
|
|
391
|
+
},
|
|
392
|
+
resume_token: resumeTokenFor({
|
|
393
|
+
runId,
|
|
394
|
+
statePath: input.engineResult.state_path || input.request.engine_state_path || null,
|
|
395
|
+
checkpoint,
|
|
396
|
+
stage
|
|
397
|
+
}),
|
|
398
|
+
created_at: input.created_at || timestamp()
|
|
399
|
+
};
|
|
400
|
+
}
|
|
204
401
|
function buildAuthorCheckpointPacket(input) {
|
|
205
402
|
const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
|
|
206
403
|
const stage = "author";
|
|
@@ -373,7 +570,12 @@ function buildCheckpointPacketForEngineResult(input) {
|
|
|
373
570
|
if (checkpoint === "verify_supervisor_judgment" || checkpoint === "verify_supervisor_judgment_required" || checkpoint === "verify_human_escalation") {
|
|
374
571
|
return buildProofAssessmentCheckpointPacket(input);
|
|
375
572
|
}
|
|
376
|
-
|
|
573
|
+
const resume = recordValue(input.engineResult.checkpointContract?.resume);
|
|
574
|
+
const continueStage = nonEmptyString(resume?.continue_with_stage);
|
|
575
|
+
if (checkpoint === "author_supervisor_judgment" || checkpoint === "verify_capture_retry" || checkpoint === "verify_agent_retry" && continueStage === "author") {
|
|
576
|
+
return buildAuthorCheckpointPacket(input);
|
|
577
|
+
}
|
|
578
|
+
return buildStageCheckpointPacket(input);
|
|
377
579
|
}
|
|
378
580
|
function normalizeCheckpointResponse(value) {
|
|
379
581
|
const record = recordValue(value);
|
|
@@ -497,6 +699,7 @@ function proofContractFromAuthorCheckpointResponse(response, packet, payload) {
|
|
|
497
699
|
buildAuthorCheckpointPacket,
|
|
498
700
|
buildCheckpointPacketForEngineResult,
|
|
499
701
|
buildProofAssessmentCheckpointPacket,
|
|
702
|
+
buildStageCheckpointPacket,
|
|
500
703
|
checkpointResponseIdentity,
|
|
501
704
|
checkpointSummaryFromState,
|
|
502
705
|
isDuplicateCheckpointResponse,
|
package/dist/checkpoint.d.cts
CHANGED
|
@@ -3,6 +3,21 @@ import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunStat
|
|
|
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
5
|
declare function statePathsForRunState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofStatePaths;
|
|
6
|
+
declare function buildStageCheckpointPacket(input: {
|
|
7
|
+
request: RiddleProofRunParams;
|
|
8
|
+
runState: RiddleProofRunState;
|
|
9
|
+
engineResult: {
|
|
10
|
+
state_path?: string | null;
|
|
11
|
+
checkpoint?: string | null;
|
|
12
|
+
checkpointContract?: Record<string, unknown> | null;
|
|
13
|
+
decisionRequest?: Record<string, unknown> | null;
|
|
14
|
+
summary?: string;
|
|
15
|
+
stage?: string | null;
|
|
16
|
+
};
|
|
17
|
+
fullRiddleState?: Record<string, unknown> | null;
|
|
18
|
+
visibility?: "liveblog" | "quiet" | "terminal_only" | "manual" | string;
|
|
19
|
+
created_at?: string;
|
|
20
|
+
}): RiddleProofCheckpointPacket;
|
|
6
21
|
declare function buildAuthorCheckpointPacket(input: {
|
|
7
22
|
request: RiddleProofRunParams;
|
|
8
23
|
runState: RiddleProofRunState;
|
|
@@ -52,4 +67,4 @@ declare function checkpointResponseIdentity(response: RiddleProofCheckpointRespo
|
|
|
52
67
|
declare function authorPacketPayloadFromCheckpointResponse(response: RiddleProofCheckpointResponse): Record<string, unknown> | null;
|
|
53
68
|
declare function proofContractFromAuthorCheckpointResponse(response: RiddleProofCheckpointResponse, packet: RiddleProofCheckpointPacket, payload: Record<string, unknown>): RiddleProofProofContract;
|
|
54
69
|
|
|
55
|
-
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
|
|
70
|
+
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
|
package/dist/checkpoint.d.ts
CHANGED
|
@@ -3,6 +3,21 @@ import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunStat
|
|
|
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
5
|
declare function statePathsForRunState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofStatePaths;
|
|
6
|
+
declare function buildStageCheckpointPacket(input: {
|
|
7
|
+
request: RiddleProofRunParams;
|
|
8
|
+
runState: RiddleProofRunState;
|
|
9
|
+
engineResult: {
|
|
10
|
+
state_path?: string | null;
|
|
11
|
+
checkpoint?: string | null;
|
|
12
|
+
checkpointContract?: Record<string, unknown> | null;
|
|
13
|
+
decisionRequest?: Record<string, unknown> | null;
|
|
14
|
+
summary?: string;
|
|
15
|
+
stage?: string | null;
|
|
16
|
+
};
|
|
17
|
+
fullRiddleState?: Record<string, unknown> | null;
|
|
18
|
+
visibility?: "liveblog" | "quiet" | "terminal_only" | "manual" | string;
|
|
19
|
+
created_at?: string;
|
|
20
|
+
}): RiddleProofCheckpointPacket;
|
|
6
21
|
declare function buildAuthorCheckpointPacket(input: {
|
|
7
22
|
request: RiddleProofRunParams;
|
|
8
23
|
runState: RiddleProofRunState;
|
|
@@ -52,4 +67,4 @@ declare function checkpointResponseIdentity(response: RiddleProofCheckpointRespo
|
|
|
52
67
|
declare function authorPacketPayloadFromCheckpointResponse(response: RiddleProofCheckpointResponse): Record<string, unknown> | null;
|
|
53
68
|
declare function proofContractFromAuthorCheckpointResponse(response: RiddleProofCheckpointResponse, packet: RiddleProofCheckpointPacket, payload: Record<string, unknown>): RiddleProofProofContract;
|
|
54
69
|
|
|
55
|
-
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
|
|
70
|
+
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
|
package/dist/checkpoint.js
CHANGED
|
@@ -5,14 +5,15 @@ import {
|
|
|
5
5
|
buildAuthorCheckpointPacket,
|
|
6
6
|
buildCheckpointPacketForEngineResult,
|
|
7
7
|
buildProofAssessmentCheckpointPacket,
|
|
8
|
+
buildStageCheckpointPacket,
|
|
8
9
|
checkpointResponseIdentity,
|
|
9
10
|
checkpointSummaryFromState,
|
|
10
11
|
isDuplicateCheckpointResponse,
|
|
11
12
|
normalizeCheckpointResponse,
|
|
12
13
|
proofContractFromAuthorCheckpointResponse,
|
|
13
14
|
statePathsForRunState
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-R6SCWJCI.js";
|
|
16
|
+
import "./chunk-DUFDZJOF.js";
|
|
16
17
|
export {
|
|
17
18
|
RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
18
19
|
RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
@@ -20,6 +21,7 @@ export {
|
|
|
20
21
|
buildAuthorCheckpointPacket,
|
|
21
22
|
buildCheckpointPacketForEngineResult,
|
|
22
23
|
buildProofAssessmentCheckpointPacket,
|
|
24
|
+
buildStageCheckpointPacket,
|
|
23
25
|
checkpointResponseIdentity,
|
|
24
26
|
checkpointSummaryFromState,
|
|
25
27
|
isDuplicateCheckpointResponse,
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
visualDeltaForState,
|
|
3
|
+
visualDeltaRequiredForState,
|
|
4
|
+
visualDeltaShipGateReason
|
|
5
|
+
} from "./chunk-4ASMX4R6.js";
|
|
6
|
+
import {
|
|
7
|
+
appendRunEvent,
|
|
8
|
+
appendStageHeartbeat,
|
|
9
|
+
createRunState,
|
|
10
|
+
createRunStatusSnapshot,
|
|
11
|
+
normalizeRunParams,
|
|
12
|
+
setRunStatus
|
|
13
|
+
} from "./chunk-JOXTKWX6.js";
|
|
14
|
+
import {
|
|
15
|
+
createRiddleProofRunCard
|
|
16
|
+
} from "./chunk-PLSGW2GI.js";
|
|
1
17
|
import {
|
|
2
18
|
authorPacketPayloadFromCheckpointResponse,
|
|
3
19
|
buildCheckpointPacketForEngineResult,
|
|
@@ -7,15 +23,7 @@ import {
|
|
|
7
23
|
normalizeCheckpointResponse,
|
|
8
24
|
proofContractFromAuthorCheckpointResponse,
|
|
9
25
|
statePathsForRunState
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
appendRunEvent,
|
|
13
|
-
appendStageHeartbeat,
|
|
14
|
-
createRunState,
|
|
15
|
-
createRunStatusSnapshot,
|
|
16
|
-
normalizeRunParams,
|
|
17
|
-
setRunStatus
|
|
18
|
-
} from "./chunk-7S7O3NKF.js";
|
|
26
|
+
} from "./chunk-R6SCWJCI.js";
|
|
19
27
|
import {
|
|
20
28
|
applyTerminalMetadata,
|
|
21
29
|
compactRecord,
|
|
@@ -23,12 +31,7 @@ import {
|
|
|
23
31
|
nonEmptyString,
|
|
24
32
|
normalizeTerminalMetadata,
|
|
25
33
|
recordValue
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import {
|
|
28
|
-
visualDeltaForState,
|
|
29
|
-
visualDeltaRequiredForState,
|
|
30
|
-
visualDeltaShipGateReason
|
|
31
|
-
} from "./chunk-4ASMX4R6.js";
|
|
34
|
+
} from "./chunk-DUFDZJOF.js";
|
|
32
35
|
|
|
33
36
|
// src/engine-harness.ts
|
|
34
37
|
import { execFileSync } from "child_process";
|
|
@@ -117,6 +120,10 @@ function shouldPreserveFinalizedRunState(filePath, incoming) {
|
|
|
117
120
|
function persist(state) {
|
|
118
121
|
state.state_paths = statePathsForRunState(state);
|
|
119
122
|
state.checkpoint_summary = checkpointSummaryFromState(state);
|
|
123
|
+
state.run_card = createRiddleProofRunCard(state, {
|
|
124
|
+
fullRiddleState: readJson(state.request.engine_state_path),
|
|
125
|
+
state_paths: state.state_paths
|
|
126
|
+
});
|
|
120
127
|
if (!state.state_path) return;
|
|
121
128
|
if (shouldPreserveFinalizedRunState(state.state_path, state)) return;
|
|
122
129
|
writeJson(state.state_path, state);
|
|
@@ -341,6 +348,41 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
|
|
|
341
348
|
checkpoint_response_created_at: response.created_at
|
|
342
349
|
});
|
|
343
350
|
}
|
|
351
|
+
function reconAssessmentPayloadFromCheckpointResponse(response) {
|
|
352
|
+
if (![
|
|
353
|
+
"ready_for_author",
|
|
354
|
+
"retry_recon",
|
|
355
|
+
"recon_stuck",
|
|
356
|
+
"needs_recon"
|
|
357
|
+
].includes(response.decision)) {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
const payload = recordValue(response.payload) || {};
|
|
361
|
+
const decision = response.decision === "needs_recon" ? "retry_recon" : response.decision;
|
|
362
|
+
const continueStage = response.continue_with_stage || nonEmptyString(payload.continue_with_stage) || (decision === "ready_for_author" ? "author" : "recon");
|
|
363
|
+
return compactRecord({
|
|
364
|
+
...payload,
|
|
365
|
+
decision,
|
|
366
|
+
summary: response.summary,
|
|
367
|
+
continue_with_stage: continueStage,
|
|
368
|
+
escalation_target: nonEmptyString(payload.escalation_target) || (decision === "recon_stuck" ? "human" : "agent"),
|
|
369
|
+
reasons: Array.isArray(response.reasons) ? response.reasons : Array.isArray(payload.reasons) ? payload.reasons : [],
|
|
370
|
+
source: "supervising_agent",
|
|
371
|
+
checkpoint_response_source: response.source || null,
|
|
372
|
+
checkpoint_response_created_at: response.created_at
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function implementationNotesFromCheckpointResponse(response) {
|
|
376
|
+
const payload = recordValue(response.payload) || {};
|
|
377
|
+
const notes = nonEmptyString(payload.implementation_notes) || nonEmptyString(payload.implementationNotes) || nonEmptyString(payload.summary) || response.summary;
|
|
378
|
+
const changedFiles = Array.isArray(payload.changed_files) ? payload.changed_files.filter((item) => typeof item === "string") : [];
|
|
379
|
+
const testsRun = Array.isArray(payload.tests_run) ? payload.tests_run.filter((item) => typeof item === "string") : [];
|
|
380
|
+
return [
|
|
381
|
+
notes,
|
|
382
|
+
changedFiles.length ? `changed_files=${changedFiles.join(", ")}` : "",
|
|
383
|
+
testsRun.length ? `tests_run=${testsRun.join(", ")}` : ""
|
|
384
|
+
].filter(Boolean).join("\n");
|
|
385
|
+
}
|
|
344
386
|
function proofAssessmentVisualBlocker(state, payload) {
|
|
345
387
|
if (!proofAssessmentRequestsShip(payload)) return null;
|
|
346
388
|
const source = nonEmptyString(payload.source) || "supervising_agent";
|
|
@@ -642,6 +684,67 @@ function checkpointResponseContinuation(state, value) {
|
|
|
642
684
|
appendCheckpointResponse(state, response);
|
|
643
685
|
return { next: { ...base, author_packet_json: jsonParam(payload) } };
|
|
644
686
|
}
|
|
687
|
+
if (packet.kind === "assess_recon" || packet.stage === "recon") {
|
|
688
|
+
const assessment = reconAssessmentPayloadFromCheckpointResponse(response);
|
|
689
|
+
if (assessment) {
|
|
690
|
+
appendCheckpointResponse(state, response);
|
|
691
|
+
return { next: { ...base, recon_assessment_json: jsonParam(assessment) } };
|
|
692
|
+
}
|
|
693
|
+
if (response.decision === "blocked" || response.decision === "human_review") {
|
|
694
|
+
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
695
|
+
return {
|
|
696
|
+
blocker: {
|
|
697
|
+
code: `checkpoint_response_${response.decision}`,
|
|
698
|
+
checkpoint: packet.checkpoint,
|
|
699
|
+
message: response.summary || `Checkpoint response stopped recon with decision=${response.decision}.`,
|
|
700
|
+
details: { stage: packet.stage, response }
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (packet.kind === "implement_change" || packet.stage === "implement") {
|
|
706
|
+
if (response.decision === "implementation_complete") {
|
|
707
|
+
const workdir = nonEmptyString(packet.state_excerpt?.after_worktree) || state.worktree_path;
|
|
708
|
+
if (workdir) state.worktree_path = workdir;
|
|
709
|
+
if (!hasGitDiff(workdir)) {
|
|
710
|
+
return {
|
|
711
|
+
blocker: {
|
|
712
|
+
code: "implementation_diff_missing",
|
|
713
|
+
checkpoint: packet.checkpoint,
|
|
714
|
+
message: "Checkpoint response claimed implementation_complete, but the after worktree has no detectable git diff.",
|
|
715
|
+
details: { stage: packet.stage, worktree_path: workdir || null, response }
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
appendCheckpointResponse(state, response);
|
|
720
|
+
return {
|
|
721
|
+
next: {
|
|
722
|
+
...base,
|
|
723
|
+
advance_stage: "implement",
|
|
724
|
+
implementation_notes: implementationNotesFromCheckpointResponse(response)
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
if (response.decision === "needs_author") {
|
|
729
|
+
appendCheckpointResponse(state, response);
|
|
730
|
+
return { next: { ...base, advance_stage: "author" } };
|
|
731
|
+
}
|
|
732
|
+
if (response.decision === "needs_recon") {
|
|
733
|
+
appendCheckpointResponse(state, response);
|
|
734
|
+
return { next: { ...base, advance_stage: "recon" } };
|
|
735
|
+
}
|
|
736
|
+
if (response.decision === "blocked" || response.decision === "human_review") {
|
|
737
|
+
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
738
|
+
return {
|
|
739
|
+
blocker: {
|
|
740
|
+
code: `checkpoint_response_${response.decision}`,
|
|
741
|
+
checkpoint: packet.checkpoint,
|
|
742
|
+
message: response.summary || `Checkpoint response stopped implementation with decision=${response.decision}.`,
|
|
743
|
+
details: { stage: packet.stage, response }
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
}
|
|
645
748
|
if (response.decision === "needs_recon") {
|
|
646
749
|
appendCheckpointResponse(state, response);
|
|
647
750
|
if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
|
|
@@ -909,6 +1012,9 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
909
1012
|
};
|
|
910
1013
|
}
|
|
911
1014
|
if (checkpoint === "recon_supervisor_judgment") {
|
|
1015
|
+
if (input.checkpoint_mode === "yield") {
|
|
1016
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
1017
|
+
}
|
|
912
1018
|
const assessment = await agent.assessRecon(context);
|
|
913
1019
|
const blocker = requirePayload("recon_assessment", assessment, state, result);
|
|
914
1020
|
if (blocker) return { blocker };
|
|
@@ -944,6 +1050,13 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
944
1050
|
};
|
|
945
1051
|
}
|
|
946
1052
|
if (checkpoint === "implement_changes_missing" || checkpoint === "implement_required" || checkpoint === "verify_agent_retry" && continueStage === "implement") {
|
|
1053
|
+
if (input.checkpoint_mode === "yield") {
|
|
1054
|
+
const fullState = context.fullRiddleState || {};
|
|
1055
|
+
state.worktree_path = workdirFromState(fullState) || state.worktree_path;
|
|
1056
|
+
state.branch = nonEmptyString(fullState.branch) || state.branch;
|
|
1057
|
+
persist(state);
|
|
1058
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
1059
|
+
}
|
|
947
1060
|
return handleImplementation(request, state, result, agent);
|
|
948
1061
|
}
|
|
949
1062
|
if (checkpoint === "implement_review") {
|
|
@@ -206,6 +206,7 @@ function createRunResult(input) {
|
|
|
206
206
|
checkpoint_summary: state.checkpoint_summary,
|
|
207
207
|
state_paths: state.state_paths,
|
|
208
208
|
proof_contract: state.proof_contract,
|
|
209
|
+
run_card: state.run_card,
|
|
209
210
|
proof_session: state.proof_session,
|
|
210
211
|
evidence_bundle: input.evidence_bundle,
|
|
211
212
|
raw: input.raw
|
|
File without changes
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRiddleProofRunCard
|
|
3
|
+
} from "./chunk-PLSGW2GI.js";
|
|
1
4
|
import {
|
|
2
5
|
compactRecord,
|
|
3
6
|
isTerminalStatus,
|
|
4
7
|
nonEmptyString,
|
|
5
8
|
recordValue
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DUFDZJOF.js";
|
|
7
10
|
|
|
8
11
|
// src/state.ts
|
|
9
12
|
var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
|
|
@@ -131,6 +134,7 @@ function createRunState(input) {
|
|
|
131
134
|
checkpoint_summary: input.checkpoint_summary,
|
|
132
135
|
state_paths: input.state_paths,
|
|
133
136
|
proof_contract: input.proof_contract,
|
|
137
|
+
run_card: input.run_card,
|
|
134
138
|
checkpoint_history: input.checkpoint_history,
|
|
135
139
|
events: input.events ? [...input.events] : []
|
|
136
140
|
});
|
|
@@ -209,6 +213,7 @@ function createRunStatusSnapshot(state, at = timestamp()) {
|
|
|
209
213
|
checkpoint_summary: state.checkpoint_summary,
|
|
210
214
|
state_paths: state.state_paths,
|
|
211
215
|
proof_contract: state.proof_contract,
|
|
216
|
+
run_card: state.run_card || createRiddleProofRunCard(state, { at }),
|
|
212
217
|
latest_event: latestEvent
|
|
213
218
|
});
|
|
214
219
|
}
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
appendStageHeartbeat,
|
|
4
4
|
createRunState,
|
|
5
5
|
setRunStatus
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JOXTKWX6.js";
|
|
7
7
|
import {
|
|
8
8
|
createRunResult
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DUFDZJOF.js";
|
|
10
10
|
|
|
11
11
|
// src/runner.ts
|
|
12
12
|
function errorDetails(error) {
|