@riddledc/riddle-proof 0.5.44 → 0.5.46
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 +17 -0
- package/dist/checkpoint.cjs +366 -0
- package/dist/checkpoint.d.cts +44 -1
- package/dist/checkpoint.d.ts +44 -1
- package/dist/checkpoint.js +8 -2
- package/dist/{chunk-W7VTDN4T.js → chunk-DUFDZJOF.js} +1 -0
- package/dist/{chunk-7S7O3NKF.js → chunk-JTNMEH57.js} +6 -1
- package/dist/{chunk-MRSYJMF4.js → chunk-L26NTZOU.js} +2 -2
- package/dist/chunk-NOBFZDZG.js +754 -0
- package/dist/chunk-PLSGW2GI.js +161 -0
- package/dist/chunk-R6SCWJCI.js +656 -0
- package/dist/{chunk-MJD37CLH.js → chunk-X3AQ2WUM.js} +201 -18
- package/dist/cli.cjs +6129 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +160 -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 +1013 -323
- package/dist/engine-harness.js +5 -4
- package/dist/index.cjs +1702 -247
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +37 -17
- 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 +64 -2
- package/dist/types.d.ts +64 -2
- package/package.json +15 -2
- package/dist/chunk-RI25RGQP.js +0 -293
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
isDuplicateCheckpointResponse,
|
|
7
|
-
normalizeCheckpointResponse,
|
|
8
|
-
proofContractFromAuthorCheckpointResponse,
|
|
9
|
-
statePathsForRunState
|
|
10
|
-
} from "./chunk-RI25RGQP.js";
|
|
2
|
+
visualDeltaForState,
|
|
3
|
+
visualDeltaRequiredForState,
|
|
4
|
+
visualDeltaShipGateReason
|
|
5
|
+
} from "./chunk-4ASMX4R6.js";
|
|
11
6
|
import {
|
|
12
7
|
appendRunEvent,
|
|
13
8
|
appendStageHeartbeat,
|
|
@@ -15,7 +10,20 @@ import {
|
|
|
15
10
|
createRunStatusSnapshot,
|
|
16
11
|
normalizeRunParams,
|
|
17
12
|
setRunStatus
|
|
18
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JTNMEH57.js";
|
|
14
|
+
import {
|
|
15
|
+
createRiddleProofRunCard
|
|
16
|
+
} from "./chunk-PLSGW2GI.js";
|
|
17
|
+
import {
|
|
18
|
+
authorPacketPayloadFromCheckpointResponse,
|
|
19
|
+
buildCheckpointPacketForEngineResult,
|
|
20
|
+
checkpointResponseIdentity,
|
|
21
|
+
checkpointSummaryFromState,
|
|
22
|
+
isDuplicateCheckpointResponse,
|
|
23
|
+
normalizeCheckpointResponse,
|
|
24
|
+
proofContractFromAuthorCheckpointResponse,
|
|
25
|
+
statePathsForRunState
|
|
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);
|
|
@@ -308,6 +315,74 @@ function proofAssessmentContinuation(result, payload) {
|
|
|
308
315
|
const proof_assessment_json = jsonParam(payload);
|
|
309
316
|
return { ...baseContinuation(result), proof_assessment_json };
|
|
310
317
|
}
|
|
318
|
+
function defaultStageForProofCheckpointDecision(decision) {
|
|
319
|
+
if (decision === "ready_to_ship") return "ship";
|
|
320
|
+
if (decision === "needs_implementation") return "implement";
|
|
321
|
+
if (decision === "needs_recon") return "recon";
|
|
322
|
+
if (decision === "revise_capture") return "verify";
|
|
323
|
+
if (decision === "needs_richer_proof") return "author";
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
function proofAssessmentPayloadFromCheckpointResponse(response) {
|
|
327
|
+
if (![
|
|
328
|
+
"ready_to_ship",
|
|
329
|
+
"needs_richer_proof",
|
|
330
|
+
"revise_capture",
|
|
331
|
+
"needs_recon",
|
|
332
|
+
"needs_implementation"
|
|
333
|
+
].includes(response.decision)) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
const payload = recordValue(response.payload) || {};
|
|
337
|
+
const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
|
|
338
|
+
return compactRecord({
|
|
339
|
+
...payload,
|
|
340
|
+
decision: response.decision,
|
|
341
|
+
summary: response.summary,
|
|
342
|
+
recommended_stage: nonEmptyString(payload.recommended_stage) || stage || void 0,
|
|
343
|
+
continue_with_stage: stage || void 0,
|
|
344
|
+
escalation_target: nonEmptyString(payload.escalation_target) || "agent",
|
|
345
|
+
reasons: Array.isArray(response.reasons) ? response.reasons : Array.isArray(payload.reasons) ? payload.reasons : [],
|
|
346
|
+
source: "supervising_agent",
|
|
347
|
+
checkpoint_response_source: response.source || null,
|
|
348
|
+
checkpoint_response_created_at: response.created_at
|
|
349
|
+
});
|
|
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
|
+
}
|
|
311
386
|
function proofAssessmentVisualBlocker(state, payload) {
|
|
312
387
|
if (!proofAssessmentRequestsShip(payload)) return null;
|
|
313
388
|
const source = nonEmptyString(payload.source) || "supervising_agent";
|
|
@@ -446,7 +521,7 @@ function blockerResult(state, result, blocker) {
|
|
|
446
521
|
});
|
|
447
522
|
}
|
|
448
523
|
function checkpointAwaitingResult(state, result, visibility) {
|
|
449
|
-
const packet =
|
|
524
|
+
const packet = buildCheckpointPacketForEngineResult({
|
|
450
525
|
request: state.request,
|
|
451
526
|
runState: state,
|
|
452
527
|
engineResult: result,
|
|
@@ -609,10 +684,93 @@ function checkpointResponseContinuation(state, value) {
|
|
|
609
684
|
appendCheckpointResponse(state, response);
|
|
610
685
|
return { next: { ...base, author_packet_json: jsonParam(payload) } };
|
|
611
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
|
+
}
|
|
612
748
|
if (response.decision === "needs_recon") {
|
|
613
749
|
appendCheckpointResponse(state, response);
|
|
750
|
+
if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
|
|
751
|
+
const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
|
|
752
|
+
if (assessment) return { next: { ...base, proof_assessment_json: jsonParam(assessment) } };
|
|
753
|
+
}
|
|
614
754
|
return { next: { ...base, advance_stage: "recon" } };
|
|
615
755
|
}
|
|
756
|
+
if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
|
|
757
|
+
const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
|
|
758
|
+
if (assessment) {
|
|
759
|
+
appendCheckpointResponse(state, response);
|
|
760
|
+
return { next: { ...base, proof_assessment_json: jsonParam(assessment) } };
|
|
761
|
+
}
|
|
762
|
+
if (response.decision === "blocked" || response.decision === "human_review") {
|
|
763
|
+
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
764
|
+
return {
|
|
765
|
+
blocker: {
|
|
766
|
+
code: `checkpoint_response_${response.decision}`,
|
|
767
|
+
checkpoint: packet.checkpoint,
|
|
768
|
+
message: response.summary || `Checkpoint response stopped the run with decision=${response.decision}.`,
|
|
769
|
+
details: { stage: packet.stage, response }
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
}
|
|
616
774
|
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
617
775
|
return {
|
|
618
776
|
blocker: {
|
|
@@ -854,6 +1012,9 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
854
1012
|
};
|
|
855
1013
|
}
|
|
856
1014
|
if (checkpoint === "recon_supervisor_judgment") {
|
|
1015
|
+
if (input.checkpoint_mode === "yield") {
|
|
1016
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
1017
|
+
}
|
|
857
1018
|
const assessment = await agent.assessRecon(context);
|
|
858
1019
|
const blocker = requirePayload("recon_assessment", assessment, state, result);
|
|
859
1020
|
if (blocker) return { blocker };
|
|
@@ -889,15 +1050,37 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
889
1050
|
};
|
|
890
1051
|
}
|
|
891
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
|
+
}
|
|
892
1060
|
return handleImplementation(request, state, result, agent);
|
|
893
1061
|
}
|
|
894
1062
|
if (checkpoint === "implement_review") {
|
|
895
1063
|
return { next: { action: "run", state_path: String(result.state_path || ""), advance_stage: "verify" } };
|
|
896
1064
|
}
|
|
897
1065
|
if (checkpoint === "verify_supervisor_judgment") {
|
|
1066
|
+
if (input.checkpoint_mode === "yield") {
|
|
1067
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
1068
|
+
}
|
|
898
1069
|
const assessment = await agent.assessProof(context);
|
|
899
1070
|
const blocker = requirePayload("proof_assessment", assessment, state, result);
|
|
900
|
-
if (blocker)
|
|
1071
|
+
if (blocker) {
|
|
1072
|
+
if (blocker.code === "main_agent_proof_review_required") {
|
|
1073
|
+
recordEvent(state, {
|
|
1074
|
+
kind: "checkpoint.packet.requested",
|
|
1075
|
+
checkpoint,
|
|
1076
|
+
stage: "verify",
|
|
1077
|
+
summary: "Main-agent proof review is being converted to a portable checkpoint packet.",
|
|
1078
|
+
details: { blocker }
|
|
1079
|
+
});
|
|
1080
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
1081
|
+
}
|
|
1082
|
+
return { blocker };
|
|
1083
|
+
}
|
|
901
1084
|
const payload = assessment.payload;
|
|
902
1085
|
recordEvent(state, {
|
|
903
1086
|
kind: "agent.proof_assessment.completed",
|