@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,7 +3,7 @@ import {
3
3
  appendStageHeartbeat,
4
4
  createRunState,
5
5
  setRunStatus
6
- } from "./chunk-M3IE3VNC.js";
6
+ } from "./chunk-WDIKPIMB.js";
7
7
  import {
8
8
  noImplementationModeFor
9
9
  } from "./chunk-EKZXU6MU.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRiddleProofRunCard
3
- } from "./chunk-RBAU2M4S.js";
3
+ } from "./chunk-JJ4IWRMJ.js";
4
4
  import {
5
5
  compactRecord,
6
6
  isTerminalStatus,
package/dist/cli/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import "../chunk-FWHJN3QG.js";
1
+ import "../chunk-ECLGGGAI.js";
2
2
  import "../chunk-DI2XNGEZ.js";
3
3
  import "../chunk-6KYXX4OE.js";
4
4
  import "../chunk-EX7TO4I5.js";
5
- import "../chunk-WURLFN72.js";
6
- import "../chunk-M3IE3VNC.js";
7
- import "../chunk-RBAU2M4S.js";
5
+ import "../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-JFQXAJH2.js";
11
11
  import "../chunk-73EBR3YL.js";
12
12
  import "../chunk-VY4Y5U57.js";
package/dist/cli.cjs CHANGED
@@ -3678,12 +3678,13 @@ function statePathsForRunState(state, engineStatePath2) {
3678
3678
  function responseSchemaForAuthorPacket() {
3679
3679
  return {
3680
3680
  type: "object",
3681
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3681
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3682
3682
  additionalProperties: false,
3683
3683
  properties: {
3684
3684
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3685
3685
  run_id: { type: "string" },
3686
3686
  checkpoint: { type: "string" },
3687
+ packet_id: { type: "string" },
3687
3688
  resume_token: { type: "string" },
3688
3689
  decision: {
3689
3690
  type: "string",
@@ -3711,12 +3712,13 @@ function responseSchemaForAuthorPacket() {
3711
3712
  function responseSchemaForProofAssessmentPacket() {
3712
3713
  return {
3713
3714
  type: "object",
3714
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3715
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3715
3716
  additionalProperties: false,
3716
3717
  properties: {
3717
3718
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3718
3719
  run_id: { type: "string" },
3719
3720
  checkpoint: { type: "string" },
3721
+ packet_id: { type: "string" },
3720
3722
  resume_token: { type: "string" },
3721
3723
  decision: {
3722
3724
  type: "string",
@@ -3752,12 +3754,13 @@ function responseSchemaForProofAssessmentPacket() {
3752
3754
  function responseSchemaForReconPacket() {
3753
3755
  return {
3754
3756
  type: "object",
3755
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3757
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3756
3758
  additionalProperties: false,
3757
3759
  properties: {
3758
3760
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3759
3761
  run_id: { type: "string" },
3760
3762
  checkpoint: { type: "string" },
3763
+ packet_id: { type: "string" },
3761
3764
  resume_token: { type: "string" },
3762
3765
  decision: {
3763
3766
  type: "string",
@@ -3785,12 +3788,13 @@ function responseSchemaForReconPacket() {
3785
3788
  function responseSchemaForImplementationPacket() {
3786
3789
  return {
3787
3790
  type: "object",
3788
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3791
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3789
3792
  additionalProperties: false,
3790
3793
  properties: {
3791
3794
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3792
3795
  run_id: { type: "string" },
3793
3796
  checkpoint: { type: "string" },
3797
+ packet_id: { type: "string" },
3794
3798
  resume_token: { type: "string" },
3795
3799
  decision: {
3796
3800
  type: "string",
@@ -3818,12 +3822,13 @@ function responseSchemaForImplementationPacket() {
3818
3822
  function responseSchemaForAdvancePacket(stage) {
3819
3823
  return {
3820
3824
  type: "object",
3821
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3825
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3822
3826
  additionalProperties: false,
3823
3827
  properties: {
3824
3828
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3825
3829
  run_id: { type: "string" },
3826
3830
  checkpoint: { type: "string" },
3831
+ packet_id: { type: "string" },
3827
3832
  resume_token: { type: "string" },
3828
3833
  decision: {
3829
3834
  type: "string",
@@ -3849,6 +3854,20 @@ function resumeTokenFor(input) {
3849
3854
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3850
3855
  return `rpchk_${hash}`;
3851
3856
  }
3857
+ function packetIdentityPayload(packet) {
3858
+ const { packet_id: _packetId, ...identityPayload } = packet;
3859
+ return identityPayload;
3860
+ }
3861
+ function checkpointPacketIdentity(packet) {
3862
+ const hash = import_node_crypto.default.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
3863
+ return `rppkt_${hash}`;
3864
+ }
3865
+ function withPacketIdentity(packet) {
3866
+ return {
3867
+ ...packet,
3868
+ packet_id: checkpointPacketIdentity(packet)
3869
+ };
3870
+ }
3852
3871
  function artifactsFromState(state) {
3853
3872
  const artifacts = [];
3854
3873
  for (const role of ["before", "prod", "after"]) {
@@ -3921,7 +3940,7 @@ function buildStageCheckpointPacket(input) {
3921
3940
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3922
3941
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3923
3942
  const kind = packetKindForStage(stage, checkpoint);
3924
- return {
3943
+ return withPacketIdentity({
3925
3944
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3926
3945
  run_id: runId,
3927
3946
  state_path: input.runState.state_path,
@@ -3970,7 +3989,7 @@ function buildStageCheckpointPacket(input) {
3970
3989
  stage
3971
3990
  }),
3972
3991
  created_at: input.created_at || timestamp()
3973
- };
3992
+ });
3974
3993
  }
3975
3994
  function buildAuthorCheckpointPacket(input) {
3976
3995
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -3983,7 +4002,7 @@ function buildAuthorCheckpointPacket(input) {
3983
4002
  const reconResults = recordValue(fullState.recon_results);
3984
4003
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3985
4004
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
3986
- return {
4005
+ return withPacketIdentity({
3987
4006
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3988
4007
  run_id: runId,
3989
4008
  state_path: input.runState.state_path,
@@ -4032,7 +4051,7 @@ function buildAuthorCheckpointPacket(input) {
4032
4051
  stage
4033
4052
  }),
4034
4053
  created_at: input.created_at || timestamp()
4035
- };
4054
+ });
4036
4055
  }
4037
4056
  function visualDeltaFromState(fullState) {
4038
4057
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4103,7 +4122,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4103
4122
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4104
4123
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4105
4124
  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.";
4106
- return {
4125
+ return withPacketIdentity({
4107
4126
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4108
4127
  run_id: runId,
4109
4128
  state_path: input.runState.state_path,
@@ -4163,7 +4182,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4163
4182
  stage
4164
4183
  }),
4165
4184
  created_at: input.created_at || timestamp()
4166
- };
4185
+ });
4167
4186
  }
4168
4187
  function buildCheckpointPacketForEngineResult(input) {
4169
4188
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4192,6 +4211,7 @@ function normalizeCheckpointResponse(value) {
4192
4211
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4193
4212
  run_id: runId,
4194
4213
  checkpoint,
4214
+ packet_id: nonEmptyString(record.packet_id),
4195
4215
  resume_token: nonEmptyString(record.resume_token),
4196
4216
  decision,
4197
4217
  summary,
@@ -4279,6 +4299,7 @@ function createCheckpointResponseTemplate(packet, input = {}) {
4279
4299
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4280
4300
  run_id: packet.run_id,
4281
4301
  checkpoint: packet.checkpoint,
4302
+ packet_id: packet.packet_id,
4282
4303
  resume_token: packet.resume_token,
4283
4304
  decision,
4284
4305
  summary: input.summary || `TODO: explain checkpoint decision ${decision}.`,
@@ -4312,6 +4333,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4312
4333
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4313
4334
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4314
4335
  const latestResponse = latestResponseEntry?.response;
4336
+ const latestPacketId = latestPacket?.packet_id || null;
4337
+ const latestResponsePacketId = latestResponse?.packet_id || null;
4338
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
4315
4339
  const latestResumeToken = latestPacket?.resume_token || null;
4316
4340
  const latestResponseToken = latestResponse?.resume_token || null;
4317
4341
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4326,6 +4350,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4326
4350
  latest_decision: latestResponse?.decision || null,
4327
4351
  latest_packet_summary: latestPacket?.summary || null,
4328
4352
  latest_response_summary: latestResponse?.summary || null,
4353
+ latest_packet_id: latestPacketId,
4354
+ latest_response_packet_id: latestResponsePacketId,
4355
+ packet_id_matches: packetIdMatches,
4329
4356
  latest_resume_token: latestResumeToken,
4330
4357
  latest_response_token: latestResponseToken,
4331
4358
  token_matches: tokenMatches,
@@ -4342,6 +4369,7 @@ function checkpointResponseIdentity(response) {
4342
4369
  const logicalResponse = compactRecord({
4343
4370
  run_id: response.run_id,
4344
4371
  checkpoint: response.checkpoint,
4372
+ packet_id: response.packet_id,
4345
4373
  resume_token: response.resume_token,
4346
4374
  decision: response.decision,
4347
4375
  summary: response.summary,
@@ -5115,6 +5143,32 @@ function isReadyShipGate(result) {
5115
5143
  function proofAssessmentRequestsShip(payload) {
5116
5144
  return String(payload.decision || "").trim() === "ready_to_ship";
5117
5145
  }
5146
+ var TRUSTED_PROOF_ASSESSMENT_READY_SOURCES = /* @__PURE__ */ new Set([
5147
+ "supervising_agent",
5148
+ "supervisor",
5149
+ "openclaw_auto_ship_mode_none"
5150
+ ]);
5151
+ function proofAssessmentSourceTrustedForShip(payload) {
5152
+ const source = nonEmptyString(payload.source)?.toLowerCase();
5153
+ if (!source) return true;
5154
+ return TRUSTED_PROOF_ASSESSMENT_READY_SOURCES.has(source);
5155
+ }
5156
+ function proofAssessmentSourceBlocker(input) {
5157
+ if (!proofAssessmentRequestsShip(input.payload)) return null;
5158
+ if (proofAssessmentSourceTrustedForShip(input.payload)) return null;
5159
+ const source = nonEmptyString(input.payload.source) || "unknown";
5160
+ return {
5161
+ code: input.code || "proof_assessment_source_not_trusted",
5162
+ checkpoint: input.checkpoint || null,
5163
+ message: `Riddle Proof cannot mark ready_to_ship from untrusted proof assessment source: ${source}.`,
5164
+ details: compactRecord({
5165
+ stage: input.stage || null,
5166
+ proofAssessment: input.payload,
5167
+ checkpoint_response_source: input.response?.source || null,
5168
+ response: input.response || null
5169
+ })
5170
+ };
5171
+ }
5118
5172
  function proofAssessmentHardBlockers(state, payload) {
5119
5173
  const blockers = proofAssessmentHardBlockersForState(state || {});
5120
5174
  if (Array.isArray(payload.hard_blockers)) {
@@ -5145,6 +5199,15 @@ function stageFromCheckpointResponse(response, packet) {
5145
5199
  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 : "");
5146
5200
  return stage ? stage : null;
5147
5201
  }
5202
+ function proofAssessmentSourceFromCheckpointResponse(response) {
5203
+ const kind = nonEmptyString(response.source?.kind)?.toLowerCase();
5204
+ if (!kind) return "supervising_agent";
5205
+ if (kind === "human") return "supervisor";
5206
+ if (kind === "codex" || kind === "openclaw-main" || kind === "claude-code") {
5207
+ return "supervising_agent";
5208
+ }
5209
+ return `checkpoint_response:${kind}`;
5210
+ }
5148
5211
  function proofAssessmentPayloadFromCheckpointResponse(response) {
5149
5212
  if (![
5150
5213
  "ready_to_ship",
@@ -5165,7 +5228,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5165
5228
  continue_with_stage: stage || void 0,
5166
5229
  escalation_target: nonEmptyString(payload.escalation_target) || "agent",
5167
5230
  reasons: Array.isArray(response.reasons) ? response.reasons : Array.isArray(payload.reasons) ? payload.reasons : [],
5168
- source: "supervising_agent",
5231
+ source: proofAssessmentSourceFromCheckpointResponse(response),
5169
5232
  checkpoint_response_source: response.source || null,
5170
5233
  checkpoint_response_created_at: response.created_at
5171
5234
  }));
@@ -5492,6 +5555,22 @@ function checkpointResponseContinuation(state, value) {
5492
5555
  }
5493
5556
  };
5494
5557
  }
5558
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
5559
+ return {
5560
+ blocker: {
5561
+ code: "checkpoint_response_packet_id_mismatch",
5562
+ checkpoint: packet.checkpoint,
5563
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
5564
+ details: {
5565
+ stage: packet.stage,
5566
+ expected_packet_id: packet.packet_id,
5567
+ actual_packet_id: response.packet_id || null,
5568
+ expected_resume_token: packet.resume_token || null,
5569
+ actual_resume_token: response.resume_token || null
5570
+ }
5571
+ }
5572
+ };
5573
+ }
5495
5574
  if (!packet.allowed_decisions.includes(response.decision)) {
5496
5575
  return {
5497
5576
  blocker: {
@@ -5600,6 +5679,14 @@ function checkpointResponseContinuation(state, value) {
5600
5679
  if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
5601
5680
  const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
5602
5681
  if (assessment) {
5682
+ const sourceBlocker = proofAssessmentSourceBlocker({
5683
+ checkpoint: packet.checkpoint,
5684
+ stage: packet.stage,
5685
+ payload: assessment,
5686
+ response,
5687
+ code: "checkpoint_response_source_not_trusted"
5688
+ });
5689
+ if (sourceBlocker) return { blocker: sourceBlocker };
5603
5690
  appendCheckpointResponse(state, response);
5604
5691
  if (state.request.ship_mode !== "ship" && proofAssessmentRequestsShip(assessment)) {
5605
5692
  const result = {
@@ -6158,6 +6245,25 @@ async function routeCheckpoint(request, state, result, agent, input) {
6158
6245
  }
6159
6246
  };
6160
6247
  }
6248
+ const sourceBlocker = proofAssessmentSourceBlocker({
6249
+ checkpoint,
6250
+ stage: "verify",
6251
+ payload,
6252
+ code: "proof_assessment_source_not_trusted"
6253
+ });
6254
+ if (sourceBlocker) {
6255
+ recordEvent(state, {
6256
+ kind: "agent.proof_assessment.source_blocked",
6257
+ checkpoint,
6258
+ stage: "verify",
6259
+ summary: sourceBlocker.message,
6260
+ details: compactRecord({
6261
+ proof_assessment: payload,
6262
+ agent_duration_ms: durationMs
6263
+ })
6264
+ });
6265
+ return { blocker: sourceBlocker };
6266
+ }
6161
6267
  const visualBlocker = proofAssessmentVisualBlocker({
6162
6268
  ...context.fullRiddleState || {},
6163
6269
  verification_mode: context.fullRiddleState?.verification_mode || request.verification_mode
@@ -18760,6 +18866,7 @@ function formatCheckpointMarkdown(input) {
18760
18866
  `Status: ${input.status || "awaiting_checkpoint"}`,
18761
18867
  `Stage: ${packet.stage}`,
18762
18868
  `Checkpoint: ${packet.checkpoint}`,
18869
+ `Packet ID: ${packet.packet_id || "legacy"}`,
18763
18870
  `Kind: ${packet.kind}`,
18764
18871
  "",
18765
18872
  "## Goal",
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-FWHJN3QG.js";
2
+ import "./chunk-ECLGGGAI.js";
3
3
  import "./chunk-DI2XNGEZ.js";
4
4
  import "./chunk-6KYXX4OE.js";
5
5
  import "./chunk-EX7TO4I5.js";
6
- import "./chunk-WURLFN72.js";
7
- import "./chunk-M3IE3VNC.js";
8
- import "./chunk-RBAU2M4S.js";
6
+ import "./chunk-IV4DVWPR.js";
7
+ import "./chunk-WDIKPIMB.js";
8
+ import "./chunk-JJ4IWRMJ.js";
9
9
  import "./chunk-EKZXU6MU.js";
10
- import "./chunk-AXWJJ2LC.js";
10
+ import "./chunk-BLM5EIBA.js";
11
11
  import "./chunk-JFQXAJH2.js";
12
12
  import "./chunk-73EBR3YL.js";
13
13
  import "./chunk-VY4Y5U57.js";
@@ -3680,12 +3680,13 @@ function statePathsForRunState(state, engineStatePath2) {
3680
3680
  function responseSchemaForAuthorPacket() {
3681
3681
  return {
3682
3682
  type: "object",
3683
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3683
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3684
3684
  additionalProperties: false,
3685
3685
  properties: {
3686
3686
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3687
3687
  run_id: { type: "string" },
3688
3688
  checkpoint: { type: "string" },
3689
+ packet_id: { type: "string" },
3689
3690
  resume_token: { type: "string" },
3690
3691
  decision: {
3691
3692
  type: "string",
@@ -3713,12 +3714,13 @@ function responseSchemaForAuthorPacket() {
3713
3714
  function responseSchemaForProofAssessmentPacket() {
3714
3715
  return {
3715
3716
  type: "object",
3716
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3717
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3717
3718
  additionalProperties: false,
3718
3719
  properties: {
3719
3720
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3720
3721
  run_id: { type: "string" },
3721
3722
  checkpoint: { type: "string" },
3723
+ packet_id: { type: "string" },
3722
3724
  resume_token: { type: "string" },
3723
3725
  decision: {
3724
3726
  type: "string",
@@ -3754,12 +3756,13 @@ function responseSchemaForProofAssessmentPacket() {
3754
3756
  function responseSchemaForReconPacket() {
3755
3757
  return {
3756
3758
  type: "object",
3757
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3759
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3758
3760
  additionalProperties: false,
3759
3761
  properties: {
3760
3762
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3761
3763
  run_id: { type: "string" },
3762
3764
  checkpoint: { type: "string" },
3765
+ packet_id: { type: "string" },
3763
3766
  resume_token: { type: "string" },
3764
3767
  decision: {
3765
3768
  type: "string",
@@ -3787,12 +3790,13 @@ function responseSchemaForReconPacket() {
3787
3790
  function responseSchemaForImplementationPacket() {
3788
3791
  return {
3789
3792
  type: "object",
3790
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3793
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3791
3794
  additionalProperties: false,
3792
3795
  properties: {
3793
3796
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3794
3797
  run_id: { type: "string" },
3795
3798
  checkpoint: { type: "string" },
3799
+ packet_id: { type: "string" },
3796
3800
  resume_token: { type: "string" },
3797
3801
  decision: {
3798
3802
  type: "string",
@@ -3820,12 +3824,13 @@ function responseSchemaForImplementationPacket() {
3820
3824
  function responseSchemaForAdvancePacket(stage) {
3821
3825
  return {
3822
3826
  type: "object",
3823
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3827
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3824
3828
  additionalProperties: false,
3825
3829
  properties: {
3826
3830
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3827
3831
  run_id: { type: "string" },
3828
3832
  checkpoint: { type: "string" },
3833
+ packet_id: { type: "string" },
3829
3834
  resume_token: { type: "string" },
3830
3835
  decision: {
3831
3836
  type: "string",
@@ -3851,6 +3856,20 @@ function resumeTokenFor(input) {
3851
3856
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3852
3857
  return `rpchk_${hash}`;
3853
3858
  }
3859
+ function packetIdentityPayload(packet) {
3860
+ const { packet_id: _packetId, ...identityPayload } = packet;
3861
+ return identityPayload;
3862
+ }
3863
+ function checkpointPacketIdentity(packet) {
3864
+ const hash = import_node_crypto.default.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
3865
+ return `rppkt_${hash}`;
3866
+ }
3867
+ function withPacketIdentity(packet) {
3868
+ return {
3869
+ ...packet,
3870
+ packet_id: checkpointPacketIdentity(packet)
3871
+ };
3872
+ }
3854
3873
  function artifactsFromState(state) {
3855
3874
  const artifacts = [];
3856
3875
  for (const role of ["before", "prod", "after"]) {
@@ -3923,7 +3942,7 @@ function buildStageCheckpointPacket(input) {
3923
3942
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3924
3943
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3925
3944
  const kind = packetKindForStage(stage, checkpoint);
3926
- return {
3945
+ return withPacketIdentity({
3927
3946
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3928
3947
  run_id: runId,
3929
3948
  state_path: input.runState.state_path,
@@ -3972,7 +3991,7 @@ function buildStageCheckpointPacket(input) {
3972
3991
  stage
3973
3992
  }),
3974
3993
  created_at: input.created_at || timestamp()
3975
- };
3994
+ });
3976
3995
  }
3977
3996
  function buildAuthorCheckpointPacket(input) {
3978
3997
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -3985,7 +4004,7 @@ function buildAuthorCheckpointPacket(input) {
3985
4004
  const reconResults = recordValue(fullState.recon_results);
3986
4005
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3987
4006
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
3988
- return {
4007
+ return withPacketIdentity({
3989
4008
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3990
4009
  run_id: runId,
3991
4010
  state_path: input.runState.state_path,
@@ -4034,7 +4053,7 @@ function buildAuthorCheckpointPacket(input) {
4034
4053
  stage
4035
4054
  }),
4036
4055
  created_at: input.created_at || timestamp()
4037
- };
4056
+ });
4038
4057
  }
4039
4058
  function visualDeltaFromState(fullState) {
4040
4059
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4105,7 +4124,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4105
4124
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4106
4125
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4107
4126
  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.";
4108
- return {
4127
+ return withPacketIdentity({
4109
4128
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4110
4129
  run_id: runId,
4111
4130
  state_path: input.runState.state_path,
@@ -4165,7 +4184,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4165
4184
  stage
4166
4185
  }),
4167
4186
  created_at: input.created_at || timestamp()
4168
- };
4187
+ });
4169
4188
  }
4170
4189
  function buildCheckpointPacketForEngineResult(input) {
4171
4190
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4194,6 +4213,7 @@ function normalizeCheckpointResponse(value) {
4194
4213
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4195
4214
  run_id: runId,
4196
4215
  checkpoint,
4216
+ packet_id: nonEmptyString(record.packet_id),
4197
4217
  resume_token: nonEmptyString(record.resume_token),
4198
4218
  decision,
4199
4219
  summary,
@@ -4225,6 +4245,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4225
4245
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4226
4246
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4227
4247
  const latestResponse = latestResponseEntry?.response;
4248
+ const latestPacketId = latestPacket?.packet_id || null;
4249
+ const latestResponsePacketId = latestResponse?.packet_id || null;
4250
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
4228
4251
  const latestResumeToken = latestPacket?.resume_token || null;
4229
4252
  const latestResponseToken = latestResponse?.resume_token || null;
4230
4253
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4239,6 +4262,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4239
4262
  latest_decision: latestResponse?.decision || null,
4240
4263
  latest_packet_summary: latestPacket?.summary || null,
4241
4264
  latest_response_summary: latestResponse?.summary || null,
4265
+ latest_packet_id: latestPacketId,
4266
+ latest_response_packet_id: latestResponsePacketId,
4267
+ packet_id_matches: packetIdMatches,
4242
4268
  latest_resume_token: latestResumeToken,
4243
4269
  latest_response_token: latestResponseToken,
4244
4270
  token_matches: tokenMatches,
@@ -4255,6 +4281,7 @@ function checkpointResponseIdentity(response) {
4255
4281
  const logicalResponse = compactRecord({
4256
4282
  run_id: response.run_id,
4257
4283
  checkpoint: response.checkpoint,
4284
+ packet_id: response.packet_id,
4258
4285
  resume_token: response.resume_token,
4259
4286
  decision: response.decision,
4260
4287
  summary: response.summary,
@@ -5028,6 +5055,32 @@ function isReadyShipGate(result) {
5028
5055
  function proofAssessmentRequestsShip(payload) {
5029
5056
  return String(payload.decision || "").trim() === "ready_to_ship";
5030
5057
  }
5058
+ var TRUSTED_PROOF_ASSESSMENT_READY_SOURCES = /* @__PURE__ */ new Set([
5059
+ "supervising_agent",
5060
+ "supervisor",
5061
+ "openclaw_auto_ship_mode_none"
5062
+ ]);
5063
+ function proofAssessmentSourceTrustedForShip(payload) {
5064
+ const source = nonEmptyString(payload.source)?.toLowerCase();
5065
+ if (!source) return true;
5066
+ return TRUSTED_PROOF_ASSESSMENT_READY_SOURCES.has(source);
5067
+ }
5068
+ function proofAssessmentSourceBlocker(input) {
5069
+ if (!proofAssessmentRequestsShip(input.payload)) return null;
5070
+ if (proofAssessmentSourceTrustedForShip(input.payload)) return null;
5071
+ const source = nonEmptyString(input.payload.source) || "unknown";
5072
+ return {
5073
+ code: input.code || "proof_assessment_source_not_trusted",
5074
+ checkpoint: input.checkpoint || null,
5075
+ message: `Riddle Proof cannot mark ready_to_ship from untrusted proof assessment source: ${source}.`,
5076
+ details: compactRecord({
5077
+ stage: input.stage || null,
5078
+ proofAssessment: input.payload,
5079
+ checkpoint_response_source: input.response?.source || null,
5080
+ response: input.response || null
5081
+ })
5082
+ };
5083
+ }
5031
5084
  function proofAssessmentHardBlockers(state, payload) {
5032
5085
  const blockers = proofAssessmentHardBlockersForState(state || {});
5033
5086
  if (Array.isArray(payload.hard_blockers)) {
@@ -5058,6 +5111,15 @@ function stageFromCheckpointResponse(response, packet) {
5058
5111
  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 : "");
5059
5112
  return stage ? stage : null;
5060
5113
  }
5114
+ function proofAssessmentSourceFromCheckpointResponse(response) {
5115
+ const kind = nonEmptyString(response.source?.kind)?.toLowerCase();
5116
+ if (!kind) return "supervising_agent";
5117
+ if (kind === "human") return "supervisor";
5118
+ if (kind === "codex" || kind === "openclaw-main" || kind === "claude-code") {
5119
+ return "supervising_agent";
5120
+ }
5121
+ return `checkpoint_response:${kind}`;
5122
+ }
5061
5123
  function proofAssessmentPayloadFromCheckpointResponse(response) {
5062
5124
  if (![
5063
5125
  "ready_to_ship",
@@ -5078,7 +5140,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5078
5140
  continue_with_stage: stage || void 0,
5079
5141
  escalation_target: nonEmptyString(payload.escalation_target) || "agent",
5080
5142
  reasons: Array.isArray(response.reasons) ? response.reasons : Array.isArray(payload.reasons) ? payload.reasons : [],
5081
- source: "supervising_agent",
5143
+ source: proofAssessmentSourceFromCheckpointResponse(response),
5082
5144
  checkpoint_response_source: response.source || null,
5083
5145
  checkpoint_response_created_at: response.created_at
5084
5146
  }));
@@ -5405,6 +5467,22 @@ function checkpointResponseContinuation(state, value) {
5405
5467
  }
5406
5468
  };
5407
5469
  }
5470
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
5471
+ return {
5472
+ blocker: {
5473
+ code: "checkpoint_response_packet_id_mismatch",
5474
+ checkpoint: packet.checkpoint,
5475
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
5476
+ details: {
5477
+ stage: packet.stage,
5478
+ expected_packet_id: packet.packet_id,
5479
+ actual_packet_id: response.packet_id || null,
5480
+ expected_resume_token: packet.resume_token || null,
5481
+ actual_resume_token: response.resume_token || null
5482
+ }
5483
+ }
5484
+ };
5485
+ }
5408
5486
  if (!packet.allowed_decisions.includes(response.decision)) {
5409
5487
  return {
5410
5488
  blocker: {
@@ -5513,6 +5591,14 @@ function checkpointResponseContinuation(state, value) {
5513
5591
  if (packet.kind === "assess_proof" || packet.kind === "recover_evidence" || packet.stage === "verify") {
5514
5592
  const assessment = proofAssessmentPayloadFromCheckpointResponse(response);
5515
5593
  if (assessment) {
5594
+ const sourceBlocker = proofAssessmentSourceBlocker({
5595
+ checkpoint: packet.checkpoint,
5596
+ stage: packet.stage,
5597
+ payload: assessment,
5598
+ response,
5599
+ code: "checkpoint_response_source_not_trusted"
5600
+ });
5601
+ if (sourceBlocker) return { blocker: sourceBlocker };
5516
5602
  appendCheckpointResponse(state, response);
5517
5603
  if (state.request.ship_mode !== "ship" && proofAssessmentRequestsShip(assessment)) {
5518
5604
  const result = {
@@ -6071,6 +6157,25 @@ async function routeCheckpoint(request, state, result, agent, input) {
6071
6157
  }
6072
6158
  };
6073
6159
  }
6160
+ const sourceBlocker = proofAssessmentSourceBlocker({
6161
+ checkpoint,
6162
+ stage: "verify",
6163
+ payload,
6164
+ code: "proof_assessment_source_not_trusted"
6165
+ });
6166
+ if (sourceBlocker) {
6167
+ recordEvent(state, {
6168
+ kind: "agent.proof_assessment.source_blocked",
6169
+ checkpoint,
6170
+ stage: "verify",
6171
+ summary: sourceBlocker.message,
6172
+ details: compactRecord({
6173
+ proof_assessment: payload,
6174
+ agent_duration_ms: durationMs
6175
+ })
6176
+ });
6177
+ return { blocker: sourceBlocker };
6178
+ }
6074
6179
  const visualBlocker = proofAssessmentVisualBlocker({
6075
6180
  ...context.fullRiddleState || {},
6076
6181
  verification_mode: context.fullRiddleState?.verification_mode || request.verification_mode