@riddledc/riddle-proof 0.5.43 → 0.5.45
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 +163 -0
- package/dist/checkpoint.d.cts +29 -1
- package/dist/checkpoint.d.ts +29 -1
- package/dist/checkpoint.js +5 -1
- package/dist/{chunk-U4VNN2CT.js → chunk-4ASMX4R6.js} +26 -5
- package/dist/{chunk-VSLU6XNI.js → chunk-CHRYLX6N.js} +116 -12
- package/dist/{chunk-RI25RGQP.js → chunk-LXE5YUYY.js} +161 -0
- package/dist/engine-harness.cjs +298 -16
- package/dist/engine-harness.js +3 -3
- package/dist/index.cjs +302 -16
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- package/dist/proof-run-core.cjs +26 -5
- package/dist/proof-run-core.js +1 -1
- package/dist/proof-run-engine.cjs +28 -7
- package/dist/proof-run-engine.js +3 -3
- package/dist/types.d.cts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -81,6 +81,47 @@ function responseSchemaForAuthorPacket() {
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
+
function responseSchemaForProofAssessmentPacket() {
|
|
85
|
+
return {
|
|
86
|
+
type: "object",
|
|
87
|
+
required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
properties: {
|
|
90
|
+
version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
|
|
91
|
+
run_id: { type: "string" },
|
|
92
|
+
checkpoint: { type: "string" },
|
|
93
|
+
resume_token: { type: "string" },
|
|
94
|
+
decision: {
|
|
95
|
+
type: "string",
|
|
96
|
+
enum: [
|
|
97
|
+
"ready_to_ship",
|
|
98
|
+
"needs_richer_proof",
|
|
99
|
+
"revise_capture",
|
|
100
|
+
"needs_recon",
|
|
101
|
+
"needs_implementation",
|
|
102
|
+
"blocked",
|
|
103
|
+
"human_review"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
summary: { type: "string" },
|
|
107
|
+
payload: {
|
|
108
|
+
type: "object",
|
|
109
|
+
description: "Optional structured assessment details, including recommended_stage, continue_with_stage, visual_delta notes, or blocker diagnostics."
|
|
110
|
+
},
|
|
111
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
112
|
+
continue_with_stage: { type: "string", enum: ["ship", "author", "implement", "recon", "verify"] },
|
|
113
|
+
source: {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
kind: { type: "string" },
|
|
117
|
+
session_id: { type: "string" },
|
|
118
|
+
user_id: { type: "string" }
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
created_at: { type: "string" }
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
84
125
|
function resumeTokenFor(input) {
|
|
85
126
|
const hash = crypto.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
|
|
86
127
|
return `rpchk_${hash}`;
|
|
@@ -164,6 +205,124 @@ function buildAuthorCheckpointPacket(input) {
|
|
|
164
205
|
created_at: input.created_at || timestamp()
|
|
165
206
|
};
|
|
166
207
|
}
|
|
208
|
+
function visualDeltaFromState(fullState) {
|
|
209
|
+
const bundle = recordValue(fullState.evidence_bundle);
|
|
210
|
+
const after = recordValue(bundle?.after);
|
|
211
|
+
const afterDelta = recordValue(after?.visual_delta);
|
|
212
|
+
if (afterDelta && Object.keys(afterDelta).length) return afterDelta;
|
|
213
|
+
const proofAssessmentRequest = recordValue(fullState.proof_assessment_request);
|
|
214
|
+
return recordValue(proofAssessmentRequest?.visual_delta) || null;
|
|
215
|
+
}
|
|
216
|
+
function verificationModeRequiresVisualDelta(value) {
|
|
217
|
+
const mode = String(value || "proof").trim().toLowerCase();
|
|
218
|
+
return [
|
|
219
|
+
"visual",
|
|
220
|
+
"render",
|
|
221
|
+
"interaction",
|
|
222
|
+
"ui",
|
|
223
|
+
"layout",
|
|
224
|
+
"screenshot",
|
|
225
|
+
"canvas",
|
|
226
|
+
"animation"
|
|
227
|
+
].includes(mode);
|
|
228
|
+
}
|
|
229
|
+
function visualDeltaIssueCode(visualDelta, required) {
|
|
230
|
+
const status = String(visualDelta?.status || "").trim();
|
|
231
|
+
const reason = String(visualDelta?.reason || "").toLowerCase();
|
|
232
|
+
if (status === "unmeasured") {
|
|
233
|
+
if (reason.includes("fetch") || reason.includes("allowlist") || reason.includes("registered domain") || reason.includes("high risk") || reason.includes("comparator")) {
|
|
234
|
+
return "comparator_fetch_blocked";
|
|
235
|
+
}
|
|
236
|
+
return "visual_delta_unmeasured";
|
|
237
|
+
}
|
|
238
|
+
if (status === "measured" && visualDelta?.passed === false) return "semantic_proof_failed";
|
|
239
|
+
if (required && status !== "measured") return "visual_delta_unmeasured";
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
function buildProofAssessmentCheckpointPacket(input) {
|
|
243
|
+
const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "verify_supervisor_judgment";
|
|
244
|
+
const stage = "verify";
|
|
245
|
+
const runId = input.runState.run_id || "unknown";
|
|
246
|
+
const fullState = input.fullRiddleState || {};
|
|
247
|
+
const proofAssessmentRequest = recordValue(fullState.proof_assessment_request) || recordValue(recordValue(fullState.verify_decision_request)?.assessment_request) || recordValue(input.engineResult.decisionRequest?.details) || {};
|
|
248
|
+
const bundle = recordValue(fullState.evidence_bundle);
|
|
249
|
+
const artifactContract = recordValue(proofAssessmentRequest.artifact_contract) || recordValue(bundle?.artifact_contract);
|
|
250
|
+
const requiredSignals = recordValue(recordValue(artifactContract)?.required);
|
|
251
|
+
const visualDelta = visualDeltaFromState(fullState);
|
|
252
|
+
const verificationMode = nonEmptyString(input.request.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(bundle?.verification_mode) || "proof";
|
|
253
|
+
const visualDeltaRequired = requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode);
|
|
254
|
+
const evidenceIssueCode = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
|
|
255
|
+
const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
|
|
256
|
+
const recoveryHint = evidenceIssueCode ? "Required visual_delta evidence is incomplete. Keep this same run in verify/evidence recovery with decision=revise_capture and continue_with_stage=verify unless the evidence proves an implementation or recon problem." : "Assess whether the current artifacts prove the requested change, then choose the next stage.";
|
|
257
|
+
return {
|
|
258
|
+
version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
259
|
+
run_id: runId,
|
|
260
|
+
state_path: input.runState.state_path,
|
|
261
|
+
stage,
|
|
262
|
+
checkpoint,
|
|
263
|
+
kind: evidenceIssueCode ? "recover_evidence" : "assess_proof",
|
|
264
|
+
summary,
|
|
265
|
+
question: `Assess the current Riddle Proof evidence. ${recoveryHint} Return a CheckpointResponse using one allowed decision.`,
|
|
266
|
+
change_request: input.request.change_request || nonEmptyString(fullState.change_request) || "",
|
|
267
|
+
context: input.request.context,
|
|
268
|
+
artifacts: artifactsFromState(fullState),
|
|
269
|
+
state_excerpt: compactRecord({
|
|
270
|
+
repo: input.request.repo || fullState.repo,
|
|
271
|
+
branch: input.request.branch || fullState.branch,
|
|
272
|
+
verification_mode: verificationMode,
|
|
273
|
+
reference: input.request.reference || fullState.reference,
|
|
274
|
+
server_path: fullState.server_path,
|
|
275
|
+
wait_for_selector: fullState.wait_for_selector,
|
|
276
|
+
implementation_status: fullState.implementation_status,
|
|
277
|
+
implementation_summary: fullState.implementation_summary,
|
|
278
|
+
changed_files: jsonCloneValue(fullState.changed_files),
|
|
279
|
+
proof_plan: compactText(fullState.proof_plan, 1200)
|
|
280
|
+
}),
|
|
281
|
+
evidence_excerpt: compactRecord({
|
|
282
|
+
before_cdn: fullState.before_cdn || null,
|
|
283
|
+
prod_cdn: fullState.prod_cdn || null,
|
|
284
|
+
after_cdn: fullState.after_cdn || null,
|
|
285
|
+
visual_delta_required: visualDeltaRequired,
|
|
286
|
+
visual_delta_ready: visualDelta?.status === "measured" && visualDelta?.passed === true,
|
|
287
|
+
visual_delta: jsonCloneRecord(visualDelta),
|
|
288
|
+
evidence_issue_code: evidenceIssueCode,
|
|
289
|
+
proof_assessment_request: jsonCloneRecord(proofAssessmentRequest),
|
|
290
|
+
verify_decision_request: jsonCloneRecord(fullState.verify_decision_request),
|
|
291
|
+
checkpoint_contract: jsonCloneRecord(input.engineResult.checkpointContract)
|
|
292
|
+
}),
|
|
293
|
+
artifact_contract: jsonCloneRecord(artifactContract),
|
|
294
|
+
allowed_decisions: [
|
|
295
|
+
"ready_to_ship",
|
|
296
|
+
"needs_richer_proof",
|
|
297
|
+
"revise_capture",
|
|
298
|
+
"needs_recon",
|
|
299
|
+
"needs_implementation",
|
|
300
|
+
"blocked",
|
|
301
|
+
"human_review"
|
|
302
|
+
],
|
|
303
|
+
response_schema: responseSchemaForProofAssessmentPacket(),
|
|
304
|
+
routing_hint: {
|
|
305
|
+
suggested_role: evidenceIssueCode ? "proof_judge" : "proof_judge",
|
|
306
|
+
visibility: input.visibility || "quiet",
|
|
307
|
+
urgency: evidenceIssueCode ? "high" : "normal",
|
|
308
|
+
can_auto_answer: input.visibility !== "manual"
|
|
309
|
+
},
|
|
310
|
+
resume_token: resumeTokenFor({
|
|
311
|
+
runId,
|
|
312
|
+
statePath: input.engineResult.state_path || input.request.engine_state_path || null,
|
|
313
|
+
checkpoint,
|
|
314
|
+
stage
|
|
315
|
+
}),
|
|
316
|
+
created_at: input.created_at || timestamp()
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function buildCheckpointPacketForEngineResult(input) {
|
|
320
|
+
const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
|
|
321
|
+
if (checkpoint === "verify_supervisor_judgment" || checkpoint === "verify_supervisor_judgment_required" || checkpoint === "verify_human_escalation") {
|
|
322
|
+
return buildProofAssessmentCheckpointPacket(input);
|
|
323
|
+
}
|
|
324
|
+
return buildAuthorCheckpointPacket(input);
|
|
325
|
+
}
|
|
167
326
|
function normalizeCheckpointResponse(value) {
|
|
168
327
|
const record = recordValue(value);
|
|
169
328
|
if (!record) return null;
|
|
@@ -284,6 +443,8 @@ export {
|
|
|
284
443
|
RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
|
|
285
444
|
statePathsForRunState,
|
|
286
445
|
buildAuthorCheckpointPacket,
|
|
446
|
+
buildProofAssessmentCheckpointPacket,
|
|
447
|
+
buildCheckpointPacketForEngineResult,
|
|
287
448
|
normalizeCheckpointResponse,
|
|
288
449
|
checkpointSummaryFromState,
|
|
289
450
|
isDuplicateCheckpointResponse,
|
package/dist/engine-harness.cjs
CHANGED
|
@@ -389,6 +389,21 @@ function visualDeltaShipGateReason(state = {}) {
|
|
|
389
389
|
if (reason) return `visual_delta.status=${status} blocks ready_to_ship for visual/UI proof: ${reason}`;
|
|
390
390
|
return `visual_delta.status=${status} blocks ready_to_ship for visual/UI proof`;
|
|
391
391
|
}
|
|
392
|
+
function visualDeltaEvidenceIssueCode(state = {}, blocker = "") {
|
|
393
|
+
const visualDelta = visualDeltaForState(state || {});
|
|
394
|
+
const status = String(visualDelta.status || "").trim();
|
|
395
|
+
const reason = `${String(visualDelta.reason || "")}
|
|
396
|
+
${blocker}`.toLowerCase();
|
|
397
|
+
if (status === "unmeasured") {
|
|
398
|
+
if (reason.includes("fetch") || reason.includes("allowlist") || reason.includes("registered domain") || reason.includes("high risk") || reason.includes("comparator")) {
|
|
399
|
+
return "comparator_fetch_blocked";
|
|
400
|
+
}
|
|
401
|
+
return "visual_delta_unmeasured";
|
|
402
|
+
}
|
|
403
|
+
if (status === "measured" && visualDelta.passed === false) return "semantic_proof_failed";
|
|
404
|
+
if (visualDeltaRequiredForState(state || {})) return "visual_delta_unmeasured";
|
|
405
|
+
return "semantic_proof_failed";
|
|
406
|
+
}
|
|
392
407
|
function requiredBaselineLabelsForState(state = {}) {
|
|
393
408
|
const reference = normalizedReference(state);
|
|
394
409
|
const labels = [];
|
|
@@ -613,9 +628,15 @@ function mergeStateFromParams(statePath, params) {
|
|
|
613
628
|
const readyBlocker = assessment?.decision === "ready_to_ship" ? visualDeltaShipGateReason({ ...state, proof_assessment: assessment, proof_assessment_source: assessment.source }) : null;
|
|
614
629
|
if (readyBlocker) {
|
|
615
630
|
assessment.blocked_decision = assessment.decision;
|
|
616
|
-
assessment.decision = "
|
|
617
|
-
|
|
618
|
-
|
|
631
|
+
assessment.decision = "revise_capture";
|
|
632
|
+
assessment.recommended_stage = "verify";
|
|
633
|
+
assessment.continue_with_stage = "verify";
|
|
634
|
+
assessment.evidence_collection_incomplete = true;
|
|
635
|
+
assessment.recovery_stage = "verify";
|
|
636
|
+
assessment.recovery_reason = readyBlocker;
|
|
637
|
+
assessment.evidence_issue_code = visualDeltaEvidenceIssueCode(state, readyBlocker);
|
|
638
|
+
assessment.visual_delta = visualDeltaForState(state);
|
|
639
|
+
assessment.suggested_repair = "Keep the same Riddle Proof run in evidence/comparison recovery: repair or retry the visual comparator/fetch path, wait for artifact readiness if applicable, or produce a measured visual_delta artifact before proof review can mark ready_to_ship.";
|
|
619
640
|
const blockers = Array.isArray(assessment.blockers) ? assessment.blockers : [];
|
|
620
641
|
assessment.blockers = [...blockers, readyBlocker];
|
|
621
642
|
}
|
|
@@ -634,7 +655,7 @@ function mergeStateFromParams(statePath, params) {
|
|
|
634
655
|
}
|
|
635
656
|
appendProofSummaryLine(state, `Supervising proof assessment: ${state.proof_assessment.decision || "unknown"}`);
|
|
636
657
|
if (readyBlocker) {
|
|
637
|
-
appendProofSummaryLine(state, `Ready-to-ship assessment
|
|
658
|
+
appendProofSummaryLine(state, `Ready-to-ship assessment routed to evidence recovery: ${readyBlocker}`);
|
|
638
659
|
}
|
|
639
660
|
if (state.proof_assessment_summary) {
|
|
640
661
|
appendProofSummaryLine(state, `Assessment summary: ${state.proof_assessment_summary}`);
|
|
@@ -908,7 +929,7 @@ var init_proof_run_core = __esm({
|
|
|
908
929
|
description: "JSON assessment with decision, summary, recommended_stage, continue_with_stage, escalation_target, and reasons."
|
|
909
930
|
}],
|
|
910
931
|
response_schema: {
|
|
911
|
-
decision: ["ready_to_ship", "needs_richer_proof"],
|
|
932
|
+
decision: ["ready_to_ship", "needs_richer_proof", "revise_capture"],
|
|
912
933
|
summary: "string",
|
|
913
934
|
recommended_stage: ["ship", "author", "implement", "recon", "verify"],
|
|
914
935
|
continue_with_stage: ["ship", "author", "implement", "recon", "verify"],
|
|
@@ -1713,10 +1734,10 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
|
|
|
1713
1734
|
const primaryShipGateNextAction = (shipGate) => {
|
|
1714
1735
|
const reasons = shipGate.reasons || [];
|
|
1715
1736
|
if (reasons.some((reason) => reason.includes("proof_assessment"))) {
|
|
1716
|
-
return "resume with riddle_proof_review using decision=ready_to_ship only after
|
|
1737
|
+
return "resume with riddle_proof_review using decision=ready_to_ship only after screenshots, semantic evidence, and required comparison metrics prove the request; otherwise choose needs_implementation, revise_capture, or needs_richer_proof for the specific missing stage";
|
|
1717
1738
|
}
|
|
1718
1739
|
if (reasons.some((reason) => reason.includes("visual_delta"))) {
|
|
1719
|
-
return "
|
|
1740
|
+
return "keep the run in verify/evidence recovery until a measured before/after visual_delta exists; choose revise_capture rather than ready_to_ship or generic needs_richer_proof for this visual proof";
|
|
1720
1741
|
}
|
|
1721
1742
|
if (reasons.some((reason) => reason.includes("after_cdn") || reason.includes("verify_status"))) {
|
|
1722
1743
|
return "rerun verify with stronger proof framing so after evidence is captured before shipping";
|
|
@@ -3217,6 +3238,47 @@ function responseSchemaForAuthorPacket() {
|
|
|
3217
3238
|
}
|
|
3218
3239
|
};
|
|
3219
3240
|
}
|
|
3241
|
+
function responseSchemaForProofAssessmentPacket() {
|
|
3242
|
+
return {
|
|
3243
|
+
type: "object",
|
|
3244
|
+
required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
|
|
3245
|
+
additionalProperties: false,
|
|
3246
|
+
properties: {
|
|
3247
|
+
version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
|
|
3248
|
+
run_id: { type: "string" },
|
|
3249
|
+
checkpoint: { type: "string" },
|
|
3250
|
+
resume_token: { type: "string" },
|
|
3251
|
+
decision: {
|
|
3252
|
+
type: "string",
|
|
3253
|
+
enum: [
|
|
3254
|
+
"ready_to_ship",
|
|
3255
|
+
"needs_richer_proof",
|
|
3256
|
+
"revise_capture",
|
|
3257
|
+
"needs_recon",
|
|
3258
|
+
"needs_implementation",
|
|
3259
|
+
"blocked",
|
|
3260
|
+
"human_review"
|
|
3261
|
+
]
|
|
3262
|
+
},
|
|
3263
|
+
summary: { type: "string" },
|
|
3264
|
+
payload: {
|
|
3265
|
+
type: "object",
|
|
3266
|
+
description: "Optional structured assessment details, including recommended_stage, continue_with_stage, visual_delta notes, or blocker diagnostics."
|
|
3267
|
+
},
|
|
3268
|
+
reasons: { type: "array", items: { type: "string" } },
|
|
3269
|
+
continue_with_stage: { type: "string", enum: ["ship", "author", "implement", "recon", "verify"] },
|
|
3270
|
+
source: {
|
|
3271
|
+
type: "object",
|
|
3272
|
+
properties: {
|
|
3273
|
+
kind: { type: "string" },
|
|
3274
|
+
session_id: { type: "string" },
|
|
3275
|
+
user_id: { type: "string" }
|
|
3276
|
+
}
|
|
3277
|
+
},
|
|
3278
|
+
created_at: { type: "string" }
|
|
3279
|
+
}
|
|
3280
|
+
};
|
|
3281
|
+
}
|
|
3220
3282
|
function resumeTokenFor(input) {
|
|
3221
3283
|
const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
|
|
3222
3284
|
return `rpchk_${hash}`;
|
|
@@ -3300,6 +3362,124 @@ function buildAuthorCheckpointPacket(input) {
|
|
|
3300
3362
|
created_at: input.created_at || timestamp2()
|
|
3301
3363
|
};
|
|
3302
3364
|
}
|
|
3365
|
+
function visualDeltaFromState(fullState) {
|
|
3366
|
+
const bundle = recordValue(fullState.evidence_bundle);
|
|
3367
|
+
const after = recordValue(bundle?.after);
|
|
3368
|
+
const afterDelta = recordValue(after?.visual_delta);
|
|
3369
|
+
if (afterDelta && Object.keys(afterDelta).length) return afterDelta;
|
|
3370
|
+
const proofAssessmentRequest = recordValue(fullState.proof_assessment_request);
|
|
3371
|
+
return recordValue(proofAssessmentRequest?.visual_delta) || null;
|
|
3372
|
+
}
|
|
3373
|
+
function verificationModeRequiresVisualDelta(value) {
|
|
3374
|
+
const mode = String(value || "proof").trim().toLowerCase();
|
|
3375
|
+
return [
|
|
3376
|
+
"visual",
|
|
3377
|
+
"render",
|
|
3378
|
+
"interaction",
|
|
3379
|
+
"ui",
|
|
3380
|
+
"layout",
|
|
3381
|
+
"screenshot",
|
|
3382
|
+
"canvas",
|
|
3383
|
+
"animation"
|
|
3384
|
+
].includes(mode);
|
|
3385
|
+
}
|
|
3386
|
+
function visualDeltaIssueCode(visualDelta, required) {
|
|
3387
|
+
const status = String(visualDelta?.status || "").trim();
|
|
3388
|
+
const reason = String(visualDelta?.reason || "").toLowerCase();
|
|
3389
|
+
if (status === "unmeasured") {
|
|
3390
|
+
if (reason.includes("fetch") || reason.includes("allowlist") || reason.includes("registered domain") || reason.includes("high risk") || reason.includes("comparator")) {
|
|
3391
|
+
return "comparator_fetch_blocked";
|
|
3392
|
+
}
|
|
3393
|
+
return "visual_delta_unmeasured";
|
|
3394
|
+
}
|
|
3395
|
+
if (status === "measured" && visualDelta?.passed === false) return "semantic_proof_failed";
|
|
3396
|
+
if (required && status !== "measured") return "visual_delta_unmeasured";
|
|
3397
|
+
return null;
|
|
3398
|
+
}
|
|
3399
|
+
function buildProofAssessmentCheckpointPacket(input) {
|
|
3400
|
+
const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "verify_supervisor_judgment";
|
|
3401
|
+
const stage = "verify";
|
|
3402
|
+
const runId = input.runState.run_id || "unknown";
|
|
3403
|
+
const fullState = input.fullRiddleState || {};
|
|
3404
|
+
const proofAssessmentRequest = recordValue(fullState.proof_assessment_request) || recordValue(recordValue(fullState.verify_decision_request)?.assessment_request) || recordValue(input.engineResult.decisionRequest?.details) || {};
|
|
3405
|
+
const bundle = recordValue(fullState.evidence_bundle);
|
|
3406
|
+
const artifactContract = recordValue(proofAssessmentRequest.artifact_contract) || recordValue(bundle?.artifact_contract);
|
|
3407
|
+
const requiredSignals = recordValue(recordValue(artifactContract)?.required);
|
|
3408
|
+
const visualDelta = visualDeltaFromState(fullState);
|
|
3409
|
+
const verificationMode = nonEmptyString(input.request.verification_mode) || nonEmptyString(fullState.verification_mode) || nonEmptyString(bundle?.verification_mode) || "proof";
|
|
3410
|
+
const visualDeltaRequired = requiredSignals?.visual_delta === true || verificationModeRequiresVisualDelta(verificationMode);
|
|
3411
|
+
const evidenceIssueCode = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
|
|
3412
|
+
const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
|
|
3413
|
+
const recoveryHint = evidenceIssueCode ? "Required visual_delta evidence is incomplete. Keep this same run in verify/evidence recovery with decision=revise_capture and continue_with_stage=verify unless the evidence proves an implementation or recon problem." : "Assess whether the current artifacts prove the requested change, then choose the next stage.";
|
|
3414
|
+
return {
|
|
3415
|
+
version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
3416
|
+
run_id: runId,
|
|
3417
|
+
state_path: input.runState.state_path,
|
|
3418
|
+
stage,
|
|
3419
|
+
checkpoint,
|
|
3420
|
+
kind: evidenceIssueCode ? "recover_evidence" : "assess_proof",
|
|
3421
|
+
summary,
|
|
3422
|
+
question: `Assess the current Riddle Proof evidence. ${recoveryHint} Return a CheckpointResponse using one allowed decision.`,
|
|
3423
|
+
change_request: input.request.change_request || nonEmptyString(fullState.change_request) || "",
|
|
3424
|
+
context: input.request.context,
|
|
3425
|
+
artifacts: artifactsFromState(fullState),
|
|
3426
|
+
state_excerpt: compactRecord({
|
|
3427
|
+
repo: input.request.repo || fullState.repo,
|
|
3428
|
+
branch: input.request.branch || fullState.branch,
|
|
3429
|
+
verification_mode: verificationMode,
|
|
3430
|
+
reference: input.request.reference || fullState.reference,
|
|
3431
|
+
server_path: fullState.server_path,
|
|
3432
|
+
wait_for_selector: fullState.wait_for_selector,
|
|
3433
|
+
implementation_status: fullState.implementation_status,
|
|
3434
|
+
implementation_summary: fullState.implementation_summary,
|
|
3435
|
+
changed_files: jsonCloneValue(fullState.changed_files),
|
|
3436
|
+
proof_plan: compactText(fullState.proof_plan, 1200)
|
|
3437
|
+
}),
|
|
3438
|
+
evidence_excerpt: compactRecord({
|
|
3439
|
+
before_cdn: fullState.before_cdn || null,
|
|
3440
|
+
prod_cdn: fullState.prod_cdn || null,
|
|
3441
|
+
after_cdn: fullState.after_cdn || null,
|
|
3442
|
+
visual_delta_required: visualDeltaRequired,
|
|
3443
|
+
visual_delta_ready: visualDelta?.status === "measured" && visualDelta?.passed === true,
|
|
3444
|
+
visual_delta: jsonCloneRecord(visualDelta),
|
|
3445
|
+
evidence_issue_code: evidenceIssueCode,
|
|
3446
|
+
proof_assessment_request: jsonCloneRecord(proofAssessmentRequest),
|
|
3447
|
+
verify_decision_request: jsonCloneRecord(fullState.verify_decision_request),
|
|
3448
|
+
checkpoint_contract: jsonCloneRecord(input.engineResult.checkpointContract)
|
|
3449
|
+
}),
|
|
3450
|
+
artifact_contract: jsonCloneRecord(artifactContract),
|
|
3451
|
+
allowed_decisions: [
|
|
3452
|
+
"ready_to_ship",
|
|
3453
|
+
"needs_richer_proof",
|
|
3454
|
+
"revise_capture",
|
|
3455
|
+
"needs_recon",
|
|
3456
|
+
"needs_implementation",
|
|
3457
|
+
"blocked",
|
|
3458
|
+
"human_review"
|
|
3459
|
+
],
|
|
3460
|
+
response_schema: responseSchemaForProofAssessmentPacket(),
|
|
3461
|
+
routing_hint: {
|
|
3462
|
+
suggested_role: evidenceIssueCode ? "proof_judge" : "proof_judge",
|
|
3463
|
+
visibility: input.visibility || "quiet",
|
|
3464
|
+
urgency: evidenceIssueCode ? "high" : "normal",
|
|
3465
|
+
can_auto_answer: input.visibility !== "manual"
|
|
3466
|
+
},
|
|
3467
|
+
resume_token: resumeTokenFor({
|
|
3468
|
+
runId,
|
|
3469
|
+
statePath: input.engineResult.state_path || input.request.engine_state_path || null,
|
|
3470
|
+
checkpoint,
|
|
3471
|
+
stage
|
|
3472
|
+
}),
|
|
3473
|
+
created_at: input.created_at || timestamp2()
|
|
3474
|
+
};
|
|
3475
|
+
}
|
|
3476
|
+
function buildCheckpointPacketForEngineResult(input) {
|
|
3477
|
+
const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
|
|
3478
|
+
if (checkpoint === "verify_supervisor_judgment" || checkpoint === "verify_supervisor_judgment_required" || checkpoint === "verify_human_escalation") {
|
|
3479
|
+
return buildProofAssessmentCheckpointPacket(input);
|
|
3480
|
+
}
|
|
3481
|
+
return buildAuthorCheckpointPacket(input);
|
|
3482
|
+
}
|
|
3303
3483
|
function normalizeCheckpointResponse(value) {
|
|
3304
3484
|
const record = recordValue(value);
|
|
3305
3485
|
if (!record) return null;
|
|
@@ -3683,6 +3863,39 @@ function proofAssessmentContinuation(result, payload) {
|
|
|
3683
3863
|
const proof_assessment_json = jsonParam(payload);
|
|
3684
3864
|
return { ...baseContinuation(result), proof_assessment_json };
|
|
3685
3865
|
}
|
|
3866
|
+
function defaultStageForProofCheckpointDecision(decision) {
|
|
3867
|
+
if (decision === "ready_to_ship") return "ship";
|
|
3868
|
+
if (decision === "needs_implementation") return "implement";
|
|
3869
|
+
if (decision === "needs_recon") return "recon";
|
|
3870
|
+
if (decision === "revise_capture") return "verify";
|
|
3871
|
+
if (decision === "needs_richer_proof") return "author";
|
|
3872
|
+
return null;
|
|
3873
|
+
}
|
|
3874
|
+
function proofAssessmentPayloadFromCheckpointResponse(response) {
|
|
3875
|
+
if (![
|
|
3876
|
+
"ready_to_ship",
|
|
3877
|
+
"needs_richer_proof",
|
|
3878
|
+
"revise_capture",
|
|
3879
|
+
"needs_recon",
|
|
3880
|
+
"needs_implementation"
|
|
3881
|
+
].includes(response.decision)) {
|
|
3882
|
+
return null;
|
|
3883
|
+
}
|
|
3884
|
+
const payload = recordValue(response.payload) || {};
|
|
3885
|
+
const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
|
|
3886
|
+
return compactRecord({
|
|
3887
|
+
...payload,
|
|
3888
|
+
decision: response.decision,
|
|
3889
|
+
summary: response.summary,
|
|
3890
|
+
recommended_stage: nonEmptyString(payload.recommended_stage) || stage || void 0,
|
|
3891
|
+
continue_with_stage: stage || void 0,
|
|
3892
|
+
escalation_target: nonEmptyString(payload.escalation_target) || "agent",
|
|
3893
|
+
reasons: Array.isArray(response.reasons) ? response.reasons : Array.isArray(payload.reasons) ? payload.reasons : [],
|
|
3894
|
+
source: "supervising_agent",
|
|
3895
|
+
checkpoint_response_source: response.source || null,
|
|
3896
|
+
checkpoint_response_created_at: response.created_at
|
|
3897
|
+
});
|
|
3898
|
+
}
|
|
3686
3899
|
function proofAssessmentVisualBlocker(state, payload) {
|
|
3687
3900
|
if (!proofAssessmentRequestsShip(payload)) return null;
|
|
3688
3901
|
const source = nonEmptyString(payload.source) || "supervising_agent";
|
|
@@ -3692,14 +3905,36 @@ function proofAssessmentVisualBlocker(state, payload) {
|
|
|
3692
3905
|
proof_assessment_source: source
|
|
3693
3906
|
});
|
|
3694
3907
|
}
|
|
3695
|
-
function
|
|
3908
|
+
function visualDeltaBlockerCode(state, blocker) {
|
|
3909
|
+
const visualDelta = visualDeltaForState(state || {});
|
|
3910
|
+
const status = nonEmptyString(visualDelta.status);
|
|
3911
|
+
const reason = `${nonEmptyString(visualDelta.reason) || ""}
|
|
3912
|
+
${blocker}`.toLowerCase();
|
|
3913
|
+
if (status === "unmeasured") {
|
|
3914
|
+
if (reason.includes("fetch") || reason.includes("allowlist") || reason.includes("registered domain") || reason.includes("high risk") || reason.includes("comparator")) {
|
|
3915
|
+
return "comparator_fetch_blocked";
|
|
3916
|
+
}
|
|
3917
|
+
return "visual_delta_unmeasured";
|
|
3918
|
+
}
|
|
3919
|
+
if (status === "measured" && visualDelta.passed === false) return "semantic_proof_failed";
|
|
3920
|
+
if (visualDeltaRequiredForState(state || {})) return "visual_delta_unmeasured";
|
|
3921
|
+
return "semantic_proof_failed";
|
|
3922
|
+
}
|
|
3923
|
+
function visualDeltaEvidenceRecoveryAssessment(state, payload, blocker) {
|
|
3924
|
+
const visualDelta = visualDeltaForState(state || {});
|
|
3696
3925
|
const blockers = Array.isArray(payload.blockers) ? payload.blockers.filter((item) => typeof item === "string") : [];
|
|
3697
3926
|
return {
|
|
3698
3927
|
...payload,
|
|
3699
3928
|
blocked_decision: payload.decision || "ready_to_ship",
|
|
3700
|
-
decision: "
|
|
3701
|
-
recommended_stage:
|
|
3702
|
-
continue_with_stage:
|
|
3929
|
+
decision: "revise_capture",
|
|
3930
|
+
recommended_stage: "verify",
|
|
3931
|
+
continue_with_stage: "verify",
|
|
3932
|
+
evidence_collection_incomplete: true,
|
|
3933
|
+
recovery_stage: "verify",
|
|
3934
|
+
recovery_reason: blocker,
|
|
3935
|
+
evidence_issue_code: visualDeltaBlockerCode(state, blocker),
|
|
3936
|
+
visual_delta: Object.keys(visualDelta).length ? visualDelta : null,
|
|
3937
|
+
suggested_repair: "Keep the same Riddle Proof run in evidence/comparison recovery: repair or retry the visual comparator/fetch path, wait for artifact readiness if applicable, or produce a measured visual_delta artifact before proof review can mark ready_to_ship.",
|
|
3703
3938
|
blockers: [...blockers, blocker]
|
|
3704
3939
|
};
|
|
3705
3940
|
}
|
|
@@ -3799,7 +4034,7 @@ function blockerResult(state, result, blocker) {
|
|
|
3799
4034
|
});
|
|
3800
4035
|
}
|
|
3801
4036
|
function checkpointAwaitingResult(state, result, visibility) {
|
|
3802
|
-
const packet =
|
|
4037
|
+
const packet = buildCheckpointPacketForEngineResult({
|
|
3803
4038
|
request: state.request,
|
|
3804
4039
|
runState: state,
|
|
3805
4040
|
engineResult: result,
|
|
@@ -3964,8 +4199,30 @@ function checkpointResponseContinuation(state, value) {
|
|
|
3964
4199
|
}
|
|
3965
4200
|
if (response.decision === "needs_recon") {
|
|
3966
4201
|
appendCheckpointResponse(state, response);
|
|
4202
|
+
if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
|
|
4203
|
+
const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
|
|
4204
|
+
if (assessment) return { next: { ...base, proof_assessment_json: jsonParam(assessment) } };
|
|
4205
|
+
}
|
|
3967
4206
|
return { next: { ...base, advance_stage: "recon" } };
|
|
3968
4207
|
}
|
|
4208
|
+
if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
|
|
4209
|
+
const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
|
|
4210
|
+
if (assessment) {
|
|
4211
|
+
appendCheckpointResponse(state, response);
|
|
4212
|
+
return { next: { ...base, proof_assessment_json: jsonParam(assessment) } };
|
|
4213
|
+
}
|
|
4214
|
+
if (response.decision === "blocked" || response.decision === "human_review") {
|
|
4215
|
+
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
4216
|
+
return {
|
|
4217
|
+
blocker: {
|
|
4218
|
+
code: `checkpoint_response_${response.decision}`,
|
|
4219
|
+
checkpoint: packet.checkpoint,
|
|
4220
|
+
message: response.summary || `Checkpoint response stopped the run with decision=${response.decision}.`,
|
|
4221
|
+
details: { stage: packet.stage, response }
|
|
4222
|
+
}
|
|
4223
|
+
};
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
3969
4226
|
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
3970
4227
|
return {
|
|
3971
4228
|
blocker: {
|
|
@@ -4248,9 +4505,24 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
4248
4505
|
return { next: { action: "run", state_path: String(result.state_path || ""), advance_stage: "verify" } };
|
|
4249
4506
|
}
|
|
4250
4507
|
if (checkpoint === "verify_supervisor_judgment") {
|
|
4508
|
+
if (input.checkpoint_mode === "yield") {
|
|
4509
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
4510
|
+
}
|
|
4251
4511
|
const assessment = await agent.assessProof(context);
|
|
4252
4512
|
const blocker = requirePayload("proof_assessment", assessment, state, result);
|
|
4253
|
-
if (blocker)
|
|
4513
|
+
if (blocker) {
|
|
4514
|
+
if (blocker.code === "main_agent_proof_review_required") {
|
|
4515
|
+
recordEvent(state, {
|
|
4516
|
+
kind: "checkpoint.packet.requested",
|
|
4517
|
+
checkpoint,
|
|
4518
|
+
stage: "verify",
|
|
4519
|
+
summary: "Main-agent proof review is being converted to a portable checkpoint packet.",
|
|
4520
|
+
details: { blocker }
|
|
4521
|
+
});
|
|
4522
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
4523
|
+
}
|
|
4524
|
+
return { blocker };
|
|
4525
|
+
}
|
|
4254
4526
|
const payload = assessment.payload;
|
|
4255
4527
|
recordEvent(state, {
|
|
4256
4528
|
kind: "agent.proof_assessment.completed",
|
|
@@ -4264,14 +4536,24 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
4264
4536
|
verification_mode: context.fullRiddleState?.verification_mode || request.verification_mode
|
|
4265
4537
|
}, payload);
|
|
4266
4538
|
if (visualBlocker) {
|
|
4539
|
+
const recoveryAssessment = visualDeltaEvidenceRecoveryAssessment({
|
|
4540
|
+
...context.fullRiddleState || {},
|
|
4541
|
+
verification_mode: context.fullRiddleState?.verification_mode || request.verification_mode
|
|
4542
|
+
}, payload, visualBlocker);
|
|
4267
4543
|
recordEvent(state, {
|
|
4268
|
-
kind: "agent.proof_assessment.
|
|
4544
|
+
kind: "agent.proof_assessment.evidence_recovery_required",
|
|
4269
4545
|
checkpoint,
|
|
4270
4546
|
stage: "verify",
|
|
4271
4547
|
summary: visualBlocker,
|
|
4272
|
-
details: {
|
|
4548
|
+
details: compactRecord({
|
|
4549
|
+
evidence_collection_incomplete: true,
|
|
4550
|
+
recovery_stage: "verify",
|
|
4551
|
+
evidence_issue_code: recoveryAssessment.evidence_issue_code || null,
|
|
4552
|
+
visual_delta: recoveryAssessment.visual_delta || null,
|
|
4553
|
+
proof_assessment: recoveryAssessment
|
|
4554
|
+
})
|
|
4273
4555
|
});
|
|
4274
|
-
return { next: proofAssessmentContinuation(result,
|
|
4556
|
+
return { next: proofAssessmentContinuation(result, recoveryAssessment) };
|
|
4275
4557
|
}
|
|
4276
4558
|
if (effectiveShipMode(request, input.config) !== "ship" && proofAssessmentRequestsShip(payload)) {
|
|
4277
4559
|
return {
|
package/dist/engine-harness.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
createDisabledRiddleProofAgentAdapter,
|
|
3
3
|
readRiddleProofRunStatus,
|
|
4
4
|
runRiddleProofEngineHarness
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-CHRYLX6N.js";
|
|
6
|
+
import "./chunk-LXE5YUYY.js";
|
|
7
7
|
import "./chunk-7S7O3NKF.js";
|
|
8
8
|
import "./chunk-W7VTDN4T.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-4ASMX4R6.js";
|
|
10
10
|
export {
|
|
11
11
|
createDisabledRiddleProofAgentAdapter,
|
|
12
12
|
readRiddleProofRunStatus,
|