@riddledc/riddle-proof 0.8.52 → 0.8.54

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.
Files changed (51) hide show
  1. package/dist/adapters/openclaw.js +4 -4
  2. package/dist/advanced/engine-harness.cjs +117 -12
  3. package/dist/advanced/engine-harness.js +4 -4
  4. package/dist/advanced/index.cjs +117 -12
  5. package/dist/advanced/index.d.cts +1 -1
  6. package/dist/advanced/index.d.ts +1 -1
  7. package/dist/advanced/index.js +5 -5
  8. package/dist/advanced/proof-run-engine.d.cts +1 -1
  9. package/dist/advanced/proof-run-engine.d.ts +1 -1
  10. package/dist/advanced/runner.js +4 -4
  11. package/dist/checkpoint.cjs +41 -11
  12. package/dist/checkpoint.d.cts +2 -1
  13. package/dist/checkpoint.d.ts +2 -1
  14. package/dist/checkpoint.js +3 -1
  15. package/dist/{chunk-AXWJJ2LC.js → chunk-BLM5EIBA.js} +40 -11
  16. package/dist/{chunk-FWHJN3QG.js → chunk-ECLGGGAI.js} +3 -2
  17. package/dist/{chunk-WURLFN72.js → chunk-IV4DVWPR.js} +82 -4
  18. package/dist/{chunk-RBAU2M4S.js → chunk-JJ4IWRMJ.js} +1 -1
  19. package/dist/{chunk-OYWZGDTS.js → chunk-LNWJAHAQ.js} +1 -1
  20. package/dist/{chunk-2CZORYB7.js → chunk-S5DX7Z6X.js} +1 -1
  21. package/dist/{chunk-M3IE3VNC.js → chunk-WDIKPIMB.js} +1 -1
  22. package/dist/cli/index.js +5 -5
  23. package/dist/cli.cjs +119 -12
  24. package/dist/cli.js +5 -5
  25. package/dist/engine-harness.cjs +117 -12
  26. package/dist/engine-harness.js +4 -4
  27. package/dist/index.cjs +120 -12
  28. package/dist/index.d.cts +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +7 -5
  31. package/dist/openclaw.js +4 -4
  32. package/dist/{proof-run-engine-DpChFR5H.d.cts → proof-run-engine-Baiv6l3A.d.cts} +3 -3
  33. package/dist/{proof-run-engine-BqRoA3Do.d.ts → proof-run-engine-MiKZt9oY.d.ts} +3 -3
  34. package/dist/proof-run-engine.d.cts +1 -1
  35. package/dist/proof-run-engine.d.ts +1 -1
  36. package/dist/run-card.js +2 -2
  37. package/dist/runner.js +4 -4
  38. package/dist/spec/checkpoint.cjs +41 -11
  39. package/dist/spec/checkpoint.d.cts +1 -1
  40. package/dist/spec/checkpoint.d.ts +1 -1
  41. package/dist/spec/checkpoint.js +3 -1
  42. package/dist/spec/index.cjs +41 -11
  43. package/dist/spec/index.d.cts +1 -1
  44. package/dist/spec/index.d.ts +1 -1
  45. package/dist/spec/index.js +5 -3
  46. package/dist/spec/run-card.js +2 -2
  47. package/dist/spec/state.js +3 -3
  48. package/dist/state.js +3 -3
  49. package/dist/types.d.cts +5 -0
  50. package/dist/types.d.ts +5 -0
  51. package/package.json +1 -1
@@ -3,10 +3,10 @@ import {
3
3
  parseOpenClawAssertions,
4
4
  parseOpenClawJsonObjectOrArray,
5
5
  toRiddleProofRunParams
6
- } from "../chunk-OYWZGDTS.js";
7
- import "../chunk-M3IE3VNC.js";
8
- import "../chunk-RBAU2M4S.js";
9
- import "../chunk-AXWJJ2LC.js";
6
+ } from "../chunk-LNWJAHAQ.js";
7
+ import "../chunk-WDIKPIMB.js";
8
+ import "../chunk-JJ4IWRMJ.js";
9
+ import "../chunk-BLM5EIBA.js";
10
10
  import "../chunk-VY4Y5U57.js";
11
11
  import "../chunk-MLKGABMK.js";
12
12
  export {
@@ -3682,12 +3682,13 @@ function statePathsForRunState(state, engineStatePath2) {
3682
3682
  function responseSchemaForAuthorPacket() {
3683
3683
  return {
3684
3684
  type: "object",
3685
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3685
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3686
3686
  additionalProperties: false,
3687
3687
  properties: {
3688
3688
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3689
3689
  run_id: { type: "string" },
3690
3690
  checkpoint: { type: "string" },
3691
+ packet_id: { type: "string" },
3691
3692
  resume_token: { type: "string" },
3692
3693
  decision: {
3693
3694
  type: "string",
@@ -3715,12 +3716,13 @@ function responseSchemaForAuthorPacket() {
3715
3716
  function responseSchemaForProofAssessmentPacket() {
3716
3717
  return {
3717
3718
  type: "object",
3718
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3719
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3719
3720
  additionalProperties: false,
3720
3721
  properties: {
3721
3722
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3722
3723
  run_id: { type: "string" },
3723
3724
  checkpoint: { type: "string" },
3725
+ packet_id: { type: "string" },
3724
3726
  resume_token: { type: "string" },
3725
3727
  decision: {
3726
3728
  type: "string",
@@ -3756,12 +3758,13 @@ function responseSchemaForProofAssessmentPacket() {
3756
3758
  function responseSchemaForReconPacket() {
3757
3759
  return {
3758
3760
  type: "object",
3759
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3761
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3760
3762
  additionalProperties: false,
3761
3763
  properties: {
3762
3764
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3763
3765
  run_id: { type: "string" },
3764
3766
  checkpoint: { type: "string" },
3767
+ packet_id: { type: "string" },
3765
3768
  resume_token: { type: "string" },
3766
3769
  decision: {
3767
3770
  type: "string",
@@ -3789,12 +3792,13 @@ function responseSchemaForReconPacket() {
3789
3792
  function responseSchemaForImplementationPacket() {
3790
3793
  return {
3791
3794
  type: "object",
3792
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3795
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3793
3796
  additionalProperties: false,
3794
3797
  properties: {
3795
3798
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3796
3799
  run_id: { type: "string" },
3797
3800
  checkpoint: { type: "string" },
3801
+ packet_id: { type: "string" },
3798
3802
  resume_token: { type: "string" },
3799
3803
  decision: {
3800
3804
  type: "string",
@@ -3822,12 +3826,13 @@ function responseSchemaForImplementationPacket() {
3822
3826
  function responseSchemaForAdvancePacket(stage) {
3823
3827
  return {
3824
3828
  type: "object",
3825
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3829
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3826
3830
  additionalProperties: false,
3827
3831
  properties: {
3828
3832
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3829
3833
  run_id: { type: "string" },
3830
3834
  checkpoint: { type: "string" },
3835
+ packet_id: { type: "string" },
3831
3836
  resume_token: { type: "string" },
3832
3837
  decision: {
3833
3838
  type: "string",
@@ -3853,6 +3858,20 @@ function resumeTokenFor(input) {
3853
3858
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3854
3859
  return `rpchk_${hash}`;
3855
3860
  }
3861
+ function packetIdentityPayload(packet) {
3862
+ const { packet_id: _packetId, ...identityPayload } = packet;
3863
+ return identityPayload;
3864
+ }
3865
+ function checkpointPacketIdentity(packet) {
3866
+ const hash = import_node_crypto.default.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
3867
+ return `rppkt_${hash}`;
3868
+ }
3869
+ function withPacketIdentity(packet) {
3870
+ return {
3871
+ ...packet,
3872
+ packet_id: checkpointPacketIdentity(packet)
3873
+ };
3874
+ }
3856
3875
  function artifactsFromState(state) {
3857
3876
  const artifacts = [];
3858
3877
  for (const role of ["before", "prod", "after"]) {
@@ -3925,7 +3944,7 @@ function buildStageCheckpointPacket(input) {
3925
3944
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3926
3945
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3927
3946
  const kind = packetKindForStage(stage, checkpoint);
3928
- return {
3947
+ return withPacketIdentity({
3929
3948
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3930
3949
  run_id: runId,
3931
3950
  state_path: input.runState.state_path,
@@ -3974,7 +3993,7 @@ function buildStageCheckpointPacket(input) {
3974
3993
  stage
3975
3994
  }),
3976
3995
  created_at: input.created_at || timestamp()
3977
- };
3996
+ });
3978
3997
  }
3979
3998
  function buildAuthorCheckpointPacket(input) {
3980
3999
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -3987,7 +4006,7 @@ function buildAuthorCheckpointPacket(input) {
3987
4006
  const reconResults = recordValue(fullState.recon_results);
3988
4007
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3989
4008
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
3990
- return {
4009
+ return withPacketIdentity({
3991
4010
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3992
4011
  run_id: runId,
3993
4012
  state_path: input.runState.state_path,
@@ -4036,7 +4055,7 @@ function buildAuthorCheckpointPacket(input) {
4036
4055
  stage
4037
4056
  }),
4038
4057
  created_at: input.created_at || timestamp()
4039
- };
4058
+ });
4040
4059
  }
4041
4060
  function visualDeltaFromState(fullState) {
4042
4061
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4107,7 +4126,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4107
4126
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4108
4127
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4109
4128
  const recoveryHint = evidenceIssueCode2 ? "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.";
4110
- return {
4129
+ return withPacketIdentity({
4111
4130
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4112
4131
  run_id: runId,
4113
4132
  state_path: input.runState.state_path,
@@ -4167,7 +4186,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4167
4186
  stage
4168
4187
  }),
4169
4188
  created_at: input.created_at || timestamp()
4170
- };
4189
+ });
4171
4190
  }
4172
4191
  function buildCheckpointPacketForEngineResult(input) {
4173
4192
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4196,6 +4215,7 @@ function normalizeCheckpointResponse(value) {
4196
4215
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4197
4216
  run_id: runId,
4198
4217
  checkpoint,
4218
+ packet_id: nonEmptyString(record.packet_id),
4199
4219
  resume_token: nonEmptyString(record.resume_token),
4200
4220
  decision,
4201
4221
  summary,
@@ -4227,6 +4247,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4227
4247
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4228
4248
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4229
4249
  const latestResponse = latestResponseEntry?.response;
4250
+ const latestPacketId = latestPacket?.packet_id || null;
4251
+ const latestResponsePacketId = latestResponse?.packet_id || null;
4252
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
4230
4253
  const latestResumeToken = latestPacket?.resume_token || null;
4231
4254
  const latestResponseToken = latestResponse?.resume_token || null;
4232
4255
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4241,6 +4264,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4241
4264
  latest_decision: latestResponse?.decision || null,
4242
4265
  latest_packet_summary: latestPacket?.summary || null,
4243
4266
  latest_response_summary: latestResponse?.summary || null,
4267
+ latest_packet_id: latestPacketId,
4268
+ latest_response_packet_id: latestResponsePacketId,
4269
+ packet_id_matches: packetIdMatches,
4244
4270
  latest_resume_token: latestResumeToken,
4245
4271
  latest_response_token: latestResponseToken,
4246
4272
  token_matches: tokenMatches,
@@ -4257,6 +4283,7 @@ function checkpointResponseIdentity(response) {
4257
4283
  const logicalResponse = compactRecord({
4258
4284
  run_id: response.run_id,
4259
4285
  checkpoint: response.checkpoint,
4286
+ packet_id: response.packet_id,
4260
4287
  resume_token: response.resume_token,
4261
4288
  decision: response.decision,
4262
4289
  summary: response.summary,
@@ -5030,6 +5057,32 @@ function isReadyShipGate(result) {
5030
5057
  function proofAssessmentRequestsShip(payload) {
5031
5058
  return String(payload.decision || "").trim() === "ready_to_ship";
5032
5059
  }
5060
+ var TRUSTED_PROOF_ASSESSMENT_READY_SOURCES = /* @__PURE__ */ new Set([
5061
+ "supervising_agent",
5062
+ "supervisor",
5063
+ "openclaw_auto_ship_mode_none"
5064
+ ]);
5065
+ function proofAssessmentSourceTrustedForShip(payload) {
5066
+ const source = nonEmptyString(payload.source)?.toLowerCase();
5067
+ if (!source) return true;
5068
+ return TRUSTED_PROOF_ASSESSMENT_READY_SOURCES.has(source);
5069
+ }
5070
+ function proofAssessmentSourceBlocker(input) {
5071
+ if (!proofAssessmentRequestsShip(input.payload)) return null;
5072
+ if (proofAssessmentSourceTrustedForShip(input.payload)) return null;
5073
+ const source = nonEmptyString(input.payload.source) || "unknown";
5074
+ return {
5075
+ code: input.code || "proof_assessment_source_not_trusted",
5076
+ checkpoint: input.checkpoint || null,
5077
+ message: `Riddle Proof cannot mark ready_to_ship from untrusted proof assessment source: ${source}.`,
5078
+ details: compactRecord({
5079
+ stage: input.stage || null,
5080
+ proofAssessment: input.payload,
5081
+ checkpoint_response_source: input.response?.source || null,
5082
+ response: input.response || null
5083
+ })
5084
+ };
5085
+ }
5033
5086
  function proofAssessmentHardBlockers(state, payload) {
5034
5087
  const blockers = proofAssessmentHardBlockersForState(state || {});
5035
5088
  if (Array.isArray(payload.hard_blockers)) {
@@ -5060,6 +5113,15 @@ function stageFromCheckpointResponse(response, packet) {
5060
5113
  const stage = response.continue_with_stage || nonEmptyString(payload.continue_with_stage) || nonEmptyString(payload.recommended_stage) || nonEmptyString(resume?.continue_with_stage) || (response.decision === "retry_stage" ? packet.stage : "");
5061
5114
  return stage ? stage : null;
5062
5115
  }
5116
+ function proofAssessmentSourceFromCheckpointResponse(response) {
5117
+ const kind = nonEmptyString(response.source?.kind)?.toLowerCase();
5118
+ if (!kind) return "supervising_agent";
5119
+ if (kind === "human") return "supervisor";
5120
+ if (kind === "codex" || kind === "openclaw-main" || kind === "claude-code") {
5121
+ return "supervising_agent";
5122
+ }
5123
+ return `checkpoint_response:${kind}`;
5124
+ }
5063
5125
  function proofAssessmentPayloadFromCheckpointResponse(response) {
5064
5126
  if (![
5065
5127
  "ready_to_ship",
@@ -5080,7 +5142,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5080
5142
  continue_with_stage: stage || void 0,
5081
5143
  escalation_target: nonEmptyString(payload.escalation_target) || "agent",
5082
5144
  reasons: Array.isArray(response.reasons) ? response.reasons : Array.isArray(payload.reasons) ? payload.reasons : [],
5083
- source: "supervising_agent",
5145
+ source: proofAssessmentSourceFromCheckpointResponse(response),
5084
5146
  checkpoint_response_source: response.source || null,
5085
5147
  checkpoint_response_created_at: response.created_at
5086
5148
  }));
@@ -5407,6 +5469,22 @@ function checkpointResponseContinuation(state, value) {
5407
5469
  }
5408
5470
  };
5409
5471
  }
5472
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
5473
+ return {
5474
+ blocker: {
5475
+ code: "checkpoint_response_packet_id_mismatch",
5476
+ checkpoint: packet.checkpoint,
5477
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
5478
+ details: {
5479
+ stage: packet.stage,
5480
+ expected_packet_id: packet.packet_id,
5481
+ actual_packet_id: response.packet_id || null,
5482
+ expected_resume_token: packet.resume_token || null,
5483
+ actual_resume_token: response.resume_token || null
5484
+ }
5485
+ }
5486
+ };
5487
+ }
5410
5488
  if (!packet.allowed_decisions.includes(response.decision)) {
5411
5489
  return {
5412
5490
  blocker: {
@@ -5515,6 +5593,14 @@ function checkpointResponseContinuation(state, value) {
5515
5593
  if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
5516
5594
  const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
5517
5595
  if (assessment) {
5596
+ const sourceBlocker = proofAssessmentSourceBlocker({
5597
+ checkpoint: packet.checkpoint,
5598
+ stage: packet.stage,
5599
+ payload: assessment,
5600
+ response,
5601
+ code: "checkpoint_response_source_not_trusted"
5602
+ });
5603
+ if (sourceBlocker) return { blocker: sourceBlocker };
5518
5604
  appendCheckpointResponse(state, response);
5519
5605
  if (state.request.ship_mode !== "ship" && proofAssessmentRequestsShip(assessment)) {
5520
5606
  const result = {
@@ -6073,6 +6159,25 @@ async function routeCheckpoint(request, state, result, agent, input) {
6073
6159
  }
6074
6160
  };
6075
6161
  }
6162
+ const sourceBlocker = proofAssessmentSourceBlocker({
6163
+ checkpoint,
6164
+ stage: "verify",
6165
+ payload,
6166
+ code: "proof_assessment_source_not_trusted"
6167
+ });
6168
+ if (sourceBlocker) {
6169
+ recordEvent(state, {
6170
+ kind: "agent.proof_assessment.source_blocked",
6171
+ checkpoint,
6172
+ stage: "verify",
6173
+ summary: sourceBlocker.message,
6174
+ details: compactRecord({
6175
+ proof_assessment: payload,
6176
+ agent_duration_ms: durationMs
6177
+ })
6178
+ });
6179
+ return { blocker: sourceBlocker };
6180
+ }
6076
6181
  const visualBlocker = proofAssessmentVisualBlocker({
6077
6182
  ...context.fullRiddleState || {},
6078
6183
  verification_mode: context.fullRiddleState?.verification_mode || request.verification_mode
@@ -2,11 +2,11 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "../chunk-WURLFN72.js";
6
- import "../chunk-M3IE3VNC.js";
7
- import "../chunk-RBAU2M4S.js";
5
+ } from "../chunk-IV4DVWPR.js";
6
+ import "../chunk-WDIKPIMB.js";
7
+ import "../chunk-JJ4IWRMJ.js";
8
8
  import "../chunk-EKZXU6MU.js";
9
- import "../chunk-AXWJJ2LC.js";
9
+ import "../chunk-BLM5EIBA.js";
10
10
  import "../chunk-VY4Y5U57.js";
11
11
  import "../chunk-MLKGABMK.js";
12
12
  export {
@@ -3716,12 +3716,13 @@ function statePathsForRunState(state, engineStatePath2) {
3716
3716
  function responseSchemaForAuthorPacket() {
3717
3717
  return {
3718
3718
  type: "object",
3719
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3719
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3720
3720
  additionalProperties: false,
3721
3721
  properties: {
3722
3722
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3723
3723
  run_id: { type: "string" },
3724
3724
  checkpoint: { type: "string" },
3725
+ packet_id: { type: "string" },
3725
3726
  resume_token: { type: "string" },
3726
3727
  decision: {
3727
3728
  type: "string",
@@ -3749,12 +3750,13 @@ function responseSchemaForAuthorPacket() {
3749
3750
  function responseSchemaForProofAssessmentPacket() {
3750
3751
  return {
3751
3752
  type: "object",
3752
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3753
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3753
3754
  additionalProperties: false,
3754
3755
  properties: {
3755
3756
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3756
3757
  run_id: { type: "string" },
3757
3758
  checkpoint: { type: "string" },
3759
+ packet_id: { type: "string" },
3758
3760
  resume_token: { type: "string" },
3759
3761
  decision: {
3760
3762
  type: "string",
@@ -3790,12 +3792,13 @@ function responseSchemaForProofAssessmentPacket() {
3790
3792
  function responseSchemaForReconPacket() {
3791
3793
  return {
3792
3794
  type: "object",
3793
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3795
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3794
3796
  additionalProperties: false,
3795
3797
  properties: {
3796
3798
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3797
3799
  run_id: { type: "string" },
3798
3800
  checkpoint: { type: "string" },
3801
+ packet_id: { type: "string" },
3799
3802
  resume_token: { type: "string" },
3800
3803
  decision: {
3801
3804
  type: "string",
@@ -3823,12 +3826,13 @@ function responseSchemaForReconPacket() {
3823
3826
  function responseSchemaForImplementationPacket() {
3824
3827
  return {
3825
3828
  type: "object",
3826
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3829
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3827
3830
  additionalProperties: false,
3828
3831
  properties: {
3829
3832
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3830
3833
  run_id: { type: "string" },
3831
3834
  checkpoint: { type: "string" },
3835
+ packet_id: { type: "string" },
3832
3836
  resume_token: { type: "string" },
3833
3837
  decision: {
3834
3838
  type: "string",
@@ -3856,12 +3860,13 @@ function responseSchemaForImplementationPacket() {
3856
3860
  function responseSchemaForAdvancePacket(stage) {
3857
3861
  return {
3858
3862
  type: "object",
3859
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3863
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3860
3864
  additionalProperties: false,
3861
3865
  properties: {
3862
3866
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3863
3867
  run_id: { type: "string" },
3864
3868
  checkpoint: { type: "string" },
3869
+ packet_id: { type: "string" },
3865
3870
  resume_token: { type: "string" },
3866
3871
  decision: {
3867
3872
  type: "string",
@@ -3887,6 +3892,20 @@ function resumeTokenFor(input) {
3887
3892
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3888
3893
  return `rpchk_${hash}`;
3889
3894
  }
3895
+ function packetIdentityPayload(packet) {
3896
+ const { packet_id: _packetId, ...identityPayload } = packet;
3897
+ return identityPayload;
3898
+ }
3899
+ function checkpointPacketIdentity(packet) {
3900
+ const hash = import_node_crypto.default.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
3901
+ return `rppkt_${hash}`;
3902
+ }
3903
+ function withPacketIdentity(packet) {
3904
+ return {
3905
+ ...packet,
3906
+ packet_id: checkpointPacketIdentity(packet)
3907
+ };
3908
+ }
3890
3909
  function artifactsFromState(state) {
3891
3910
  const artifacts = [];
3892
3911
  for (const role of ["before", "prod", "after"]) {
@@ -3959,7 +3978,7 @@ function buildStageCheckpointPacket(input) {
3959
3978
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3960
3979
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3961
3980
  const kind = packetKindForStage(stage, checkpoint);
3962
- return {
3981
+ return withPacketIdentity({
3963
3982
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3964
3983
  run_id: runId,
3965
3984
  state_path: input.runState.state_path,
@@ -4008,7 +4027,7 @@ function buildStageCheckpointPacket(input) {
4008
4027
  stage
4009
4028
  }),
4010
4029
  created_at: input.created_at || timestamp()
4011
- };
4030
+ });
4012
4031
  }
4013
4032
  function buildAuthorCheckpointPacket(input) {
4014
4033
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -4021,7 +4040,7 @@ function buildAuthorCheckpointPacket(input) {
4021
4040
  const reconResults = recordValue(fullState.recon_results);
4022
4041
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
4023
4042
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
4024
- return {
4043
+ return withPacketIdentity({
4025
4044
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4026
4045
  run_id: runId,
4027
4046
  state_path: input.runState.state_path,
@@ -4070,7 +4089,7 @@ function buildAuthorCheckpointPacket(input) {
4070
4089
  stage
4071
4090
  }),
4072
4091
  created_at: input.created_at || timestamp()
4073
- };
4092
+ });
4074
4093
  }
4075
4094
  function visualDeltaFromState(fullState) {
4076
4095
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4141,7 +4160,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4141
4160
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4142
4161
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4143
4162
  const recoveryHint = evidenceIssueCode2 ? "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.";
4144
- return {
4163
+ return withPacketIdentity({
4145
4164
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4146
4165
  run_id: runId,
4147
4166
  state_path: input.runState.state_path,
@@ -4201,7 +4220,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4201
4220
  stage
4202
4221
  }),
4203
4222
  created_at: input.created_at || timestamp()
4204
- };
4223
+ });
4205
4224
  }
4206
4225
  function buildCheckpointPacketForEngineResult(input) {
4207
4226
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4230,6 +4249,7 @@ function normalizeCheckpointResponse(value) {
4230
4249
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4231
4250
  run_id: runId,
4232
4251
  checkpoint,
4252
+ packet_id: nonEmptyString(record.packet_id),
4233
4253
  resume_token: nonEmptyString(record.resume_token),
4234
4254
  decision,
4235
4255
  summary,
@@ -4261,6 +4281,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4261
4281
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4262
4282
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4263
4283
  const latestResponse = latestResponseEntry?.response;
4284
+ const latestPacketId = latestPacket?.packet_id || null;
4285
+ const latestResponsePacketId = latestResponse?.packet_id || null;
4286
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
4264
4287
  const latestResumeToken = latestPacket?.resume_token || null;
4265
4288
  const latestResponseToken = latestResponse?.resume_token || null;
4266
4289
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4275,6 +4298,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4275
4298
  latest_decision: latestResponse?.decision || null,
4276
4299
  latest_packet_summary: latestPacket?.summary || null,
4277
4300
  latest_response_summary: latestResponse?.summary || null,
4301
+ latest_packet_id: latestPacketId,
4302
+ latest_response_packet_id: latestResponsePacketId,
4303
+ packet_id_matches: packetIdMatches,
4278
4304
  latest_resume_token: latestResumeToken,
4279
4305
  latest_response_token: latestResponseToken,
4280
4306
  token_matches: tokenMatches,
@@ -4291,6 +4317,7 @@ function checkpointResponseIdentity(response) {
4291
4317
  const logicalResponse = compactRecord({
4292
4318
  run_id: response.run_id,
4293
4319
  checkpoint: response.checkpoint,
4320
+ packet_id: response.packet_id,
4294
4321
  resume_token: response.resume_token,
4295
4322
  decision: response.decision,
4296
4323
  summary: response.summary,
@@ -5569,6 +5596,32 @@ function isReadyShipGate(result) {
5569
5596
  function proofAssessmentRequestsShip(payload) {
5570
5597
  return String(payload.decision || "").trim() === "ready_to_ship";
5571
5598
  }
5599
+ var TRUSTED_PROOF_ASSESSMENT_READY_SOURCES = /* @__PURE__ */ new Set([
5600
+ "supervising_agent",
5601
+ "supervisor",
5602
+ "openclaw_auto_ship_mode_none"
5603
+ ]);
5604
+ function proofAssessmentSourceTrustedForShip(payload) {
5605
+ const source = nonEmptyString(payload.source)?.toLowerCase();
5606
+ if (!source) return true;
5607
+ return TRUSTED_PROOF_ASSESSMENT_READY_SOURCES.has(source);
5608
+ }
5609
+ function proofAssessmentSourceBlocker(input) {
5610
+ if (!proofAssessmentRequestsShip(input.payload)) return null;
5611
+ if (proofAssessmentSourceTrustedForShip(input.payload)) return null;
5612
+ const source = nonEmptyString(input.payload.source) || "unknown";
5613
+ return {
5614
+ code: input.code || "proof_assessment_source_not_trusted",
5615
+ checkpoint: input.checkpoint || null,
5616
+ message: `Riddle Proof cannot mark ready_to_ship from untrusted proof assessment source: ${source}.`,
5617
+ details: compactRecord({
5618
+ stage: input.stage || null,
5619
+ proofAssessment: input.payload,
5620
+ checkpoint_response_source: input.response?.source || null,
5621
+ response: input.response || null
5622
+ })
5623
+ };
5624
+ }
5572
5625
  function proofAssessmentHardBlockers(state, payload) {
5573
5626
  const blockers = proofAssessmentHardBlockersForState(state || {});
5574
5627
  if (Array.isArray(payload.hard_blockers)) {
@@ -5599,6 +5652,15 @@ function stageFromCheckpointResponse(response, packet) {
5599
5652
  const stage = response.continue_with_stage || nonEmptyString(payload.continue_with_stage) || nonEmptyString(payload.recommended_stage) || nonEmptyString(resume?.continue_with_stage) || (response.decision === "retry_stage" ? packet.stage : "");
5600
5653
  return stage ? stage : null;
5601
5654
  }
5655
+ function proofAssessmentSourceFromCheckpointResponse(response) {
5656
+ const kind = nonEmptyString(response.source?.kind)?.toLowerCase();
5657
+ if (!kind) return "supervising_agent";
5658
+ if (kind === "human") return "supervisor";
5659
+ if (kind === "codex" || kind === "openclaw-main" || kind === "claude-code") {
5660
+ return "supervising_agent";
5661
+ }
5662
+ return `checkpoint_response:${kind}`;
5663
+ }
5602
5664
  function proofAssessmentPayloadFromCheckpointResponse(response) {
5603
5665
  if (![
5604
5666
  "ready_to_ship",
@@ -5619,7 +5681,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5619
5681
  continue_with_stage: stage || void 0,
5620
5682
  escalation_target: nonEmptyString(payload.escalation_target) || "agent",
5621
5683
  reasons: Array.isArray(response.reasons) ? response.reasons : Array.isArray(payload.reasons) ? payload.reasons : [],
5622
- source: "supervising_agent",
5684
+ source: proofAssessmentSourceFromCheckpointResponse(response),
5623
5685
  checkpoint_response_source: response.source || null,
5624
5686
  checkpoint_response_created_at: response.created_at
5625
5687
  }));
@@ -5946,6 +6008,22 @@ function checkpointResponseContinuation(state, value) {
5946
6008
  }
5947
6009
  };
5948
6010
  }
6011
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
6012
+ return {
6013
+ blocker: {
6014
+ code: "checkpoint_response_packet_id_mismatch",
6015
+ checkpoint: packet.checkpoint,
6016
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
6017
+ details: {
6018
+ stage: packet.stage,
6019
+ expected_packet_id: packet.packet_id,
6020
+ actual_packet_id: response.packet_id || null,
6021
+ expected_resume_token: packet.resume_token || null,
6022
+ actual_resume_token: response.resume_token || null
6023
+ }
6024
+ }
6025
+ };
6026
+ }
5949
6027
  if (!packet.allowed_decisions.includes(response.decision)) {
5950
6028
  return {
5951
6029
  blocker: {
@@ -6054,6 +6132,14 @@ function checkpointResponseContinuation(state, value) {
6054
6132
  if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
6055
6133
  const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
6056
6134
  if (assessment) {
6135
+ const sourceBlocker = proofAssessmentSourceBlocker({
6136
+ checkpoint: packet.checkpoint,
6137
+ stage: packet.stage,
6138
+ payload: assessment,
6139
+ response,
6140
+ code: "checkpoint_response_source_not_trusted"
6141
+ });
6142
+ if (sourceBlocker) return { blocker: sourceBlocker };
6057
6143
  appendCheckpointResponse(state, response);
6058
6144
  if (state.request.ship_mode !== "ship" && proofAssessmentRequestsShip(assessment)) {
6059
6145
  const result = {
@@ -6612,6 +6698,25 @@ async function routeCheckpoint(request, state, result, agent, input) {
6612
6698
  }
6613
6699
  };
6614
6700
  }
6701
+ const sourceBlocker = proofAssessmentSourceBlocker({
6702
+ checkpoint,
6703
+ stage: "verify",
6704
+ payload,
6705
+ code: "proof_assessment_source_not_trusted"
6706
+ });
6707
+ if (sourceBlocker) {
6708
+ recordEvent(state, {
6709
+ kind: "agent.proof_assessment.source_blocked",
6710
+ checkpoint,
6711
+ stage: "verify",
6712
+ summary: sourceBlocker.message,
6713
+ details: compactRecord({
6714
+ proof_assessment: payload,
6715
+ agent_duration_ms: durationMs
6716
+ })
6717
+ });
6718
+ return { blocker: sourceBlocker };
6719
+ }
6615
6720
  const visualBlocker = proofAssessmentVisualBlocker({
6616
6721
  ...context.fullRiddleState || {},
6617
6722
  verification_mode: context.fullRiddleState?.verification_mode || request.verification_mode
@@ -1,5 +1,5 @@
1
1
  export { b as runner } from '../runner-4LJ5z0D-.cjs';
2
2
  export { l as engineHarness } from '../engine-harness-LBfqbFSe.cjs';
3
3
  export { p as proofRunCore } from '../proof-run-core-7Dqm7RKM.cjs';
4
- export { p as proofRunEngine } from '../proof-run-engine-DpChFR5H.cjs';
4
+ export { p as proofRunEngine } from '../proof-run-engine-Baiv6l3A.cjs';
5
5
  import '../types.cjs';
@@ -1,5 +1,5 @@
1
1
  export { b as runner } from '../runner-BdQpOkZD.js';
2
2
  export { l as engineHarness } from '../engine-harness-CMACHP6A.js';
3
3
  export { p as proofRunCore } from '../proof-run-core-7Dqm7RKM.js';
4
- export { p as proofRunEngine } from '../proof-run-engine-BqRoA3Do.js';
4
+ export { p as proofRunEngine } from '../proof-run-engine-MiKZt9oY.js';
5
5
  import '../types.js';
@@ -3,16 +3,16 @@ import {
3
3
  } from "../chunk-VYJD6XYF.js";
4
4
  import {
5
5
  runner_exports
6
- } from "../chunk-2CZORYB7.js";
6
+ } from "../chunk-S5DX7Z6X.js";
7
7
  import {
8
8
  engine_harness_exports
9
- } from "../chunk-WURLFN72.js";
10
- import "../chunk-M3IE3VNC.js";
11
- import "../chunk-RBAU2M4S.js";
9
+ } from "../chunk-IV4DVWPR.js";
10
+ import "../chunk-WDIKPIMB.js";
11
+ import "../chunk-JJ4IWRMJ.js";
12
12
  import {
13
13
  proof_run_core_exports
14
14
  } from "../chunk-EKZXU6MU.js";
15
- import "../chunk-AXWJJ2LC.js";
15
+ import "../chunk-BLM5EIBA.js";
16
16
  import "../chunk-VY4Y5U57.js";
17
17
  import "../chunk-MLKGABMK.js";
18
18
  export {