@riddledc/riddle-proof 0.8.51 → 0.8.53

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 (67) hide show
  1. package/dist/adapters/openclaw.js +4 -4
  2. package/dist/advanced/engine-harness.cjs +79 -26
  3. package/dist/advanced/engine-harness.js +5 -5
  4. package/dist/advanced/index.cjs +81 -26
  5. package/dist/advanced/index.d.cts +2 -2
  6. package/dist/advanced/index.d.ts +2 -2
  7. package/dist/advanced/index.js +7 -7
  8. package/dist/advanced/proof-run-core.cjs +24 -2
  9. package/dist/advanced/proof-run-core.d.cts +1 -1
  10. package/dist/advanced/proof-run-core.d.ts +1 -1
  11. package/dist/advanced/proof-run-core.js +5 -1
  12. package/dist/advanced/proof-run-engine.cjs +20 -2
  13. package/dist/advanced/proof-run-engine.d.cts +2 -2
  14. package/dist/advanced/proof-run-engine.d.ts +2 -2
  15. package/dist/advanced/proof-run-engine.js +2 -2
  16. package/dist/advanced/runner.js +5 -5
  17. package/dist/checkpoint.cjs +41 -11
  18. package/dist/checkpoint.d.cts +2 -1
  19. package/dist/checkpoint.d.ts +2 -1
  20. package/dist/checkpoint.js +3 -1
  21. package/dist/{chunk-AWM2BKDF.js → chunk-2ALMXMFZ.js} +3 -2
  22. package/dist/{chunk-AXWJJ2LC.js → chunk-BLM5EIBA.js} +40 -11
  23. package/dist/{chunk-X7SQTCIQ.js → chunk-EKZXU6MU.js} +24 -2
  24. package/dist/{chunk-RBAU2M4S.js → chunk-JJ4IWRMJ.js} +1 -1
  25. package/dist/{chunk-OYWZGDTS.js → chunk-LNWJAHAQ.js} +1 -1
  26. package/dist/{chunk-DFQBQGSD.js → chunk-S5DX7Z6X.js} +2 -2
  27. package/dist/{chunk-IOI6QR3B.js → chunk-VYJD6XYF.js} +1 -1
  28. package/dist/{chunk-M3IE3VNC.js → chunk-WDIKPIMB.js} +1 -1
  29. package/dist/{chunk-ZHTJEZH5.js → chunk-ZLBOGPUL.js} +27 -17
  30. package/dist/cli/index.js +6 -6
  31. package/dist/cli.cjs +81 -26
  32. package/dist/cli.js +6 -6
  33. package/dist/engine-harness.cjs +79 -26
  34. package/dist/engine-harness.js +5 -5
  35. package/dist/index.cjs +82 -26
  36. package/dist/index.d.cts +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +8 -6
  39. package/dist/openclaw.js +4 -4
  40. package/dist/{proof-run-core-B1GeqkR8.d.ts → proof-run-core-7Dqm7RKM.d.cts} +6 -2
  41. package/dist/{proof-run-core-B1GeqkR8.d.cts → proof-run-core-7Dqm7RKM.d.ts} +6 -2
  42. package/dist/proof-run-core.cjs +24 -2
  43. package/dist/proof-run-core.d.cts +1 -1
  44. package/dist/proof-run-core.d.ts +1 -1
  45. package/dist/proof-run-core.js +5 -1
  46. package/dist/{proof-run-engine-BqaeqAze.d.ts → proof-run-engine-BqRoA3Do.d.ts} +1 -1
  47. package/dist/{proof-run-engine-4dM37pEx.d.cts → proof-run-engine-DpChFR5H.d.cts} +1 -1
  48. package/dist/proof-run-engine.cjs +20 -2
  49. package/dist/proof-run-engine.d.cts +2 -2
  50. package/dist/proof-run-engine.d.ts +2 -2
  51. package/dist/proof-run-engine.js +2 -2
  52. package/dist/run-card.js +2 -2
  53. package/dist/runner.js +5 -5
  54. package/dist/spec/checkpoint.cjs +41 -11
  55. package/dist/spec/checkpoint.d.cts +1 -1
  56. package/dist/spec/checkpoint.d.ts +1 -1
  57. package/dist/spec/checkpoint.js +3 -1
  58. package/dist/spec/index.cjs +41 -11
  59. package/dist/spec/index.d.cts +1 -1
  60. package/dist/spec/index.d.ts +1 -1
  61. package/dist/spec/index.js +5 -3
  62. package/dist/spec/run-card.js +2 -2
  63. package/dist/spec/state.js +3 -3
  64. package/dist/state.js +3 -3
  65. package/dist/types.d.cts +5 -0
  66. package/dist/types.d.ts +5 -0
  67. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -31,6 +31,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  ));
32
32
 
33
33
  // src/proof-run-core.ts
34
+ function canonicalProofAssessmentStageForDecision(decision) {
35
+ const normalized = typeof decision === "string" ? decision.trim() : "";
36
+ if (normalized === "ready_to_ship") return "ship";
37
+ if (normalized === "needs_richer_proof") return "author";
38
+ if (normalized === "revise_capture") return "verify";
39
+ if (normalized === "needs_recon") return "recon";
40
+ if (normalized === "needs_implementation") return "implement";
41
+ return null;
42
+ }
43
+ function normalizeProofAssessmentStageFields(assessment) {
44
+ const canonicalStage = canonicalProofAssessmentStageForDecision(assessment.decision);
45
+ if (!canonicalStage) return assessment;
46
+ return {
47
+ ...assessment,
48
+ recommended_stage: canonicalStage,
49
+ continue_with_stage: canonicalStage
50
+ };
51
+ }
34
52
  function normalizedMode(value) {
35
53
  return typeof value === "string" ? value.trim().toLowerCase() : "";
36
54
  }
@@ -866,10 +884,10 @@ function mergeStateFromParams(statePath, params) {
866
884
  state.proof_assessment_source = null;
867
885
  } else {
868
886
  const parsed = JSON.parse(raw);
869
- const assessment = {
887
+ const assessment = normalizeProofAssessmentStageFields({
870
888
  ...parsed,
871
889
  source: (parsed?.source || "supervising_agent").toString()
872
- };
890
+ });
873
891
  const readyBlocker = assessment?.decision === "ready_to_ship" ? visualDeltaShipGateReason({ ...state, proof_assessment: assessment, proof_assessment_source: assessment.source }) : null;
874
892
  if (readyBlocker) {
875
893
  assessment.blocked_decision = assessment.decision;
@@ -3660,12 +3678,13 @@ function statePathsForRunState(state, engineStatePath2) {
3660
3678
  function responseSchemaForAuthorPacket() {
3661
3679
  return {
3662
3680
  type: "object",
3663
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3681
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3664
3682
  additionalProperties: false,
3665
3683
  properties: {
3666
3684
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3667
3685
  run_id: { type: "string" },
3668
3686
  checkpoint: { type: "string" },
3687
+ packet_id: { type: "string" },
3669
3688
  resume_token: { type: "string" },
3670
3689
  decision: {
3671
3690
  type: "string",
@@ -3693,12 +3712,13 @@ function responseSchemaForAuthorPacket() {
3693
3712
  function responseSchemaForProofAssessmentPacket() {
3694
3713
  return {
3695
3714
  type: "object",
3696
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3715
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3697
3716
  additionalProperties: false,
3698
3717
  properties: {
3699
3718
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3700
3719
  run_id: { type: "string" },
3701
3720
  checkpoint: { type: "string" },
3721
+ packet_id: { type: "string" },
3702
3722
  resume_token: { type: "string" },
3703
3723
  decision: {
3704
3724
  type: "string",
@@ -3734,12 +3754,13 @@ function responseSchemaForProofAssessmentPacket() {
3734
3754
  function responseSchemaForReconPacket() {
3735
3755
  return {
3736
3756
  type: "object",
3737
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3757
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3738
3758
  additionalProperties: false,
3739
3759
  properties: {
3740
3760
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3741
3761
  run_id: { type: "string" },
3742
3762
  checkpoint: { type: "string" },
3763
+ packet_id: { type: "string" },
3743
3764
  resume_token: { type: "string" },
3744
3765
  decision: {
3745
3766
  type: "string",
@@ -3767,12 +3788,13 @@ function responseSchemaForReconPacket() {
3767
3788
  function responseSchemaForImplementationPacket() {
3768
3789
  return {
3769
3790
  type: "object",
3770
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3791
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3771
3792
  additionalProperties: false,
3772
3793
  properties: {
3773
3794
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3774
3795
  run_id: { type: "string" },
3775
3796
  checkpoint: { type: "string" },
3797
+ packet_id: { type: "string" },
3776
3798
  resume_token: { type: "string" },
3777
3799
  decision: {
3778
3800
  type: "string",
@@ -3800,12 +3822,13 @@ function responseSchemaForImplementationPacket() {
3800
3822
  function responseSchemaForAdvancePacket(stage) {
3801
3823
  return {
3802
3824
  type: "object",
3803
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3825
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3804
3826
  additionalProperties: false,
3805
3827
  properties: {
3806
3828
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3807
3829
  run_id: { type: "string" },
3808
3830
  checkpoint: { type: "string" },
3831
+ packet_id: { type: "string" },
3809
3832
  resume_token: { type: "string" },
3810
3833
  decision: {
3811
3834
  type: "string",
@@ -3831,6 +3854,20 @@ function resumeTokenFor(input) {
3831
3854
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3832
3855
  return `rpchk_${hash}`;
3833
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
+ }
3834
3871
  function artifactsFromState(state) {
3835
3872
  const artifacts = [];
3836
3873
  for (const role of ["before", "prod", "after"]) {
@@ -3903,7 +3940,7 @@ function buildStageCheckpointPacket(input) {
3903
3940
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3904
3941
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3905
3942
  const kind = packetKindForStage(stage, checkpoint);
3906
- return {
3943
+ return withPacketIdentity({
3907
3944
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3908
3945
  run_id: runId,
3909
3946
  state_path: input.runState.state_path,
@@ -3952,7 +3989,7 @@ function buildStageCheckpointPacket(input) {
3952
3989
  stage
3953
3990
  }),
3954
3991
  created_at: input.created_at || timestamp()
3955
- };
3992
+ });
3956
3993
  }
3957
3994
  function buildAuthorCheckpointPacket(input) {
3958
3995
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -3965,7 +4002,7 @@ function buildAuthorCheckpointPacket(input) {
3965
4002
  const reconResults = recordValue(fullState.recon_results);
3966
4003
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3967
4004
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
3968
- return {
4005
+ return withPacketIdentity({
3969
4006
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3970
4007
  run_id: runId,
3971
4008
  state_path: input.runState.state_path,
@@ -4014,7 +4051,7 @@ function buildAuthorCheckpointPacket(input) {
4014
4051
  stage
4015
4052
  }),
4016
4053
  created_at: input.created_at || timestamp()
4017
- };
4054
+ });
4018
4055
  }
4019
4056
  function visualDeltaFromState(fullState) {
4020
4057
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4085,7 +4122,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4085
4122
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4086
4123
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4087
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.";
4088
- return {
4125
+ return withPacketIdentity({
4089
4126
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4090
4127
  run_id: runId,
4091
4128
  state_path: input.runState.state_path,
@@ -4145,7 +4182,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4145
4182
  stage
4146
4183
  }),
4147
4184
  created_at: input.created_at || timestamp()
4148
- };
4185
+ });
4149
4186
  }
4150
4187
  function buildCheckpointPacketForEngineResult(input) {
4151
4188
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4174,6 +4211,7 @@ function normalizeCheckpointResponse(value) {
4174
4211
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4175
4212
  run_id: runId,
4176
4213
  checkpoint,
4214
+ packet_id: nonEmptyString(record.packet_id),
4177
4215
  resume_token: nonEmptyString(record.resume_token),
4178
4216
  decision,
4179
4217
  summary,
@@ -4261,6 +4299,7 @@ function createCheckpointResponseTemplate(packet, input = {}) {
4261
4299
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4262
4300
  run_id: packet.run_id,
4263
4301
  checkpoint: packet.checkpoint,
4302
+ packet_id: packet.packet_id,
4264
4303
  resume_token: packet.resume_token,
4265
4304
  decision,
4266
4305
  summary: input.summary || `TODO: explain checkpoint decision ${decision}.`,
@@ -4294,6 +4333,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4294
4333
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4295
4334
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4296
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;
4297
4339
  const latestResumeToken = latestPacket?.resume_token || null;
4298
4340
  const latestResponseToken = latestResponse?.resume_token || null;
4299
4341
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4308,6 +4350,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4308
4350
  latest_decision: latestResponse?.decision || null,
4309
4351
  latest_packet_summary: latestPacket?.summary || null,
4310
4352
  latest_response_summary: latestResponse?.summary || null,
4353
+ latest_packet_id: latestPacketId,
4354
+ latest_response_packet_id: latestResponsePacketId,
4355
+ packet_id_matches: packetIdMatches,
4311
4356
  latest_resume_token: latestResumeToken,
4312
4357
  latest_response_token: latestResponseToken,
4313
4358
  token_matches: tokenMatches,
@@ -4324,6 +4369,7 @@ function checkpointResponseIdentity(response) {
4324
4369
  const logicalResponse = compactRecord({
4325
4370
  run_id: response.run_id,
4326
4371
  checkpoint: response.checkpoint,
4372
+ packet_id: response.packet_id,
4327
4373
  resume_token: response.resume_token,
4328
4374
  decision: response.decision,
4329
4375
  summary: response.summary,
@@ -5095,10 +5141,7 @@ function isReadyShipGate(result) {
5095
5141
  return Boolean(gate && gate.ok === true);
5096
5142
  }
5097
5143
  function proofAssessmentRequestsShip(payload) {
5098
- const decision = String(payload.decision || "");
5099
- const recommendedStage = String(payload.recommended_stage || "");
5100
- const continueStage = String(payload.continue_with_stage || "");
5101
- return decision === "ready_to_ship" || recommendedStage === "ship" || continueStage === "ship";
5144
+ return String(payload.decision || "").trim() === "ready_to_ship";
5102
5145
  }
5103
5146
  function proofAssessmentHardBlockers(state, payload) {
5104
5147
  const blockers = proofAssessmentHardBlockersForState(state || {});
@@ -5116,12 +5159,7 @@ function proofAssessmentContinuation(result, payload) {
5116
5159
  return { ...baseContinuation(result), proof_assessment_json };
5117
5160
  }
5118
5161
  function defaultStageForProofCheckpointDecision(decision) {
5119
- if (decision === "ready_to_ship") return "ship";
5120
- if (decision === "needs_implementation") return "implement";
5121
- if (decision === "needs_recon") return "recon";
5122
- if (decision === "revise_capture") return "verify";
5123
- if (decision === "needs_richer_proof") return "author";
5124
- return null;
5162
+ return canonicalProofAssessmentStageForDecision(decision);
5125
5163
  }
5126
5164
  function checkpointContractFromPacket(packet) {
5127
5165
  return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
@@ -5147,7 +5185,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5147
5185
  }
5148
5186
  const payload = recordValue(response.payload) || {};
5149
5187
  const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
5150
- return compactRecord({
5188
+ return normalizeProofAssessmentStageFields(compactRecord({
5151
5189
  ...payload,
5152
5190
  decision: response.decision,
5153
5191
  summary: response.summary,
@@ -5158,7 +5196,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5158
5196
  source: "supervising_agent",
5159
5197
  checkpoint_response_source: response.source || null,
5160
5198
  checkpoint_response_created_at: response.created_at
5161
- });
5199
+ }));
5162
5200
  }
5163
5201
  function reconAssessmentPayloadFromCheckpointResponse(response) {
5164
5202
  if (![
@@ -5482,6 +5520,22 @@ function checkpointResponseContinuation(state, value) {
5482
5520
  }
5483
5521
  };
5484
5522
  }
5523
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
5524
+ return {
5525
+ blocker: {
5526
+ code: "checkpoint_response_packet_id_mismatch",
5527
+ checkpoint: packet.checkpoint,
5528
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
5529
+ details: {
5530
+ stage: packet.stage,
5531
+ expected_packet_id: packet.packet_id,
5532
+ actual_packet_id: response.packet_id || null,
5533
+ expected_resume_token: packet.resume_token || null,
5534
+ actual_resume_token: response.resume_token || null
5535
+ }
5536
+ }
5537
+ };
5538
+ }
5485
5539
  if (!packet.allowed_decisions.includes(response.decision)) {
5486
5540
  return {
5487
5541
  blocker: {
@@ -6108,7 +6162,7 @@ async function routeCheckpoint(request, state, result, agent, input) {
6108
6162
  }
6109
6163
  return { blocker };
6110
6164
  }
6111
- const payload = assessment.payload;
6165
+ const payload = normalizeProofAssessmentStageFields(assessment.payload);
6112
6166
  recordEvent(state, {
6113
6167
  kind: "agent.proof_assessment.completed",
6114
6168
  checkpoint,
@@ -18750,6 +18804,7 @@ function formatCheckpointMarkdown(input) {
18750
18804
  `Status: ${input.status || "awaiting_checkpoint"}`,
18751
18805
  `Stage: ${packet.stage}`,
18752
18806
  `Checkpoint: ${packet.checkpoint}`,
18807
+ `Packet ID: ${packet.packet_id || "legacy"}`,
18753
18808
  `Kind: ${packet.kind}`,
18754
18809
  "",
18755
18810
  "## Goal",
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-AWM2BKDF.js";
2
+ import "./chunk-2ALMXMFZ.js";
3
3
  import "./chunk-DI2XNGEZ.js";
4
4
  import "./chunk-6KYXX4OE.js";
5
5
  import "./chunk-EX7TO4I5.js";
6
- import "./chunk-ZHTJEZH5.js";
7
- import "./chunk-M3IE3VNC.js";
8
- import "./chunk-RBAU2M4S.js";
9
- import "./chunk-X7SQTCIQ.js";
10
- import "./chunk-AXWJJ2LC.js";
6
+ import "./chunk-ZLBOGPUL.js";
7
+ import "./chunk-WDIKPIMB.js";
8
+ import "./chunk-JJ4IWRMJ.js";
9
+ import "./chunk-EKZXU6MU.js";
10
+ import "./chunk-BLM5EIBA.js";
11
11
  import "./chunk-JFQXAJH2.js";
12
12
  import "./chunk-73EBR3YL.js";
13
13
  import "./chunk-VY4Y5U57.js";
@@ -31,6 +31,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
33
  // src/proof-run-core.ts
34
+ function canonicalProofAssessmentStageForDecision(decision) {
35
+ const normalized = typeof decision === "string" ? decision.trim() : "";
36
+ if (normalized === "ready_to_ship") return "ship";
37
+ if (normalized === "needs_richer_proof") return "author";
38
+ if (normalized === "revise_capture") return "verify";
39
+ if (normalized === "needs_recon") return "recon";
40
+ if (normalized === "needs_implementation") return "implement";
41
+ return null;
42
+ }
43
+ function normalizeProofAssessmentStageFields(assessment) {
44
+ const canonicalStage = canonicalProofAssessmentStageForDecision(assessment.decision);
45
+ if (!canonicalStage) return assessment;
46
+ return {
47
+ ...assessment,
48
+ recommended_stage: canonicalStage,
49
+ continue_with_stage: canonicalStage
50
+ };
51
+ }
34
52
  function normalizedMode(value) {
35
53
  return typeof value === "string" ? value.trim().toLowerCase() : "";
36
54
  }
@@ -866,10 +884,10 @@ function mergeStateFromParams(statePath, params) {
866
884
  state.proof_assessment_source = null;
867
885
  } else {
868
886
  const parsed = JSON.parse(raw);
869
- const assessment = {
887
+ const assessment = normalizeProofAssessmentStageFields({
870
888
  ...parsed,
871
889
  source: (parsed?.source || "supervising_agent").toString()
872
- };
890
+ });
873
891
  const readyBlocker = assessment?.decision === "ready_to_ship" ? visualDeltaShipGateReason({ ...state, proof_assessment: assessment, proof_assessment_source: assessment.source }) : null;
874
892
  if (readyBlocker) {
875
893
  assessment.blocked_decision = assessment.decision;
@@ -3662,12 +3680,13 @@ function statePathsForRunState(state, engineStatePath2) {
3662
3680
  function responseSchemaForAuthorPacket() {
3663
3681
  return {
3664
3682
  type: "object",
3665
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3683
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3666
3684
  additionalProperties: false,
3667
3685
  properties: {
3668
3686
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3669
3687
  run_id: { type: "string" },
3670
3688
  checkpoint: { type: "string" },
3689
+ packet_id: { type: "string" },
3671
3690
  resume_token: { type: "string" },
3672
3691
  decision: {
3673
3692
  type: "string",
@@ -3695,12 +3714,13 @@ function responseSchemaForAuthorPacket() {
3695
3714
  function responseSchemaForProofAssessmentPacket() {
3696
3715
  return {
3697
3716
  type: "object",
3698
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3717
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3699
3718
  additionalProperties: false,
3700
3719
  properties: {
3701
3720
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3702
3721
  run_id: { type: "string" },
3703
3722
  checkpoint: { type: "string" },
3723
+ packet_id: { type: "string" },
3704
3724
  resume_token: { type: "string" },
3705
3725
  decision: {
3706
3726
  type: "string",
@@ -3736,12 +3756,13 @@ function responseSchemaForProofAssessmentPacket() {
3736
3756
  function responseSchemaForReconPacket() {
3737
3757
  return {
3738
3758
  type: "object",
3739
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3759
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3740
3760
  additionalProperties: false,
3741
3761
  properties: {
3742
3762
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3743
3763
  run_id: { type: "string" },
3744
3764
  checkpoint: { type: "string" },
3765
+ packet_id: { type: "string" },
3745
3766
  resume_token: { type: "string" },
3746
3767
  decision: {
3747
3768
  type: "string",
@@ -3769,12 +3790,13 @@ function responseSchemaForReconPacket() {
3769
3790
  function responseSchemaForImplementationPacket() {
3770
3791
  return {
3771
3792
  type: "object",
3772
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3793
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3773
3794
  additionalProperties: false,
3774
3795
  properties: {
3775
3796
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3776
3797
  run_id: { type: "string" },
3777
3798
  checkpoint: { type: "string" },
3799
+ packet_id: { type: "string" },
3778
3800
  resume_token: { type: "string" },
3779
3801
  decision: {
3780
3802
  type: "string",
@@ -3802,12 +3824,13 @@ function responseSchemaForImplementationPacket() {
3802
3824
  function responseSchemaForAdvancePacket(stage) {
3803
3825
  return {
3804
3826
  type: "object",
3805
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3827
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3806
3828
  additionalProperties: false,
3807
3829
  properties: {
3808
3830
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3809
3831
  run_id: { type: "string" },
3810
3832
  checkpoint: { type: "string" },
3833
+ packet_id: { type: "string" },
3811
3834
  resume_token: { type: "string" },
3812
3835
  decision: {
3813
3836
  type: "string",
@@ -3833,6 +3856,20 @@ function resumeTokenFor(input) {
3833
3856
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3834
3857
  return `rpchk_${hash}`;
3835
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
+ }
3836
3873
  function artifactsFromState(state) {
3837
3874
  const artifacts = [];
3838
3875
  for (const role of ["before", "prod", "after"]) {
@@ -3905,7 +3942,7 @@ function buildStageCheckpointPacket(input) {
3905
3942
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3906
3943
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3907
3944
  const kind = packetKindForStage(stage, checkpoint);
3908
- return {
3945
+ return withPacketIdentity({
3909
3946
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3910
3947
  run_id: runId,
3911
3948
  state_path: input.runState.state_path,
@@ -3954,7 +3991,7 @@ function buildStageCheckpointPacket(input) {
3954
3991
  stage
3955
3992
  }),
3956
3993
  created_at: input.created_at || timestamp()
3957
- };
3994
+ });
3958
3995
  }
3959
3996
  function buildAuthorCheckpointPacket(input) {
3960
3997
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -3967,7 +4004,7 @@ function buildAuthorCheckpointPacket(input) {
3967
4004
  const reconResults = recordValue(fullState.recon_results);
3968
4005
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3969
4006
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
3970
- return {
4007
+ return withPacketIdentity({
3971
4008
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3972
4009
  run_id: runId,
3973
4010
  state_path: input.runState.state_path,
@@ -4016,7 +4053,7 @@ function buildAuthorCheckpointPacket(input) {
4016
4053
  stage
4017
4054
  }),
4018
4055
  created_at: input.created_at || timestamp()
4019
- };
4056
+ });
4020
4057
  }
4021
4058
  function visualDeltaFromState(fullState) {
4022
4059
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4087,7 +4124,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4087
4124
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4088
4125
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4089
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.";
4090
- return {
4127
+ return withPacketIdentity({
4091
4128
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4092
4129
  run_id: runId,
4093
4130
  state_path: input.runState.state_path,
@@ -4147,7 +4184,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4147
4184
  stage
4148
4185
  }),
4149
4186
  created_at: input.created_at || timestamp()
4150
- };
4187
+ });
4151
4188
  }
4152
4189
  function buildCheckpointPacketForEngineResult(input) {
4153
4190
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4176,6 +4213,7 @@ function normalizeCheckpointResponse(value) {
4176
4213
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4177
4214
  run_id: runId,
4178
4215
  checkpoint,
4216
+ packet_id: nonEmptyString(record.packet_id),
4179
4217
  resume_token: nonEmptyString(record.resume_token),
4180
4218
  decision,
4181
4219
  summary,
@@ -4207,6 +4245,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4207
4245
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4208
4246
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4209
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;
4210
4251
  const latestResumeToken = latestPacket?.resume_token || null;
4211
4252
  const latestResponseToken = latestResponse?.resume_token || null;
4212
4253
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4221,6 +4262,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4221
4262
  latest_decision: latestResponse?.decision || null,
4222
4263
  latest_packet_summary: latestPacket?.summary || null,
4223
4264
  latest_response_summary: latestResponse?.summary || null,
4265
+ latest_packet_id: latestPacketId,
4266
+ latest_response_packet_id: latestResponsePacketId,
4267
+ packet_id_matches: packetIdMatches,
4224
4268
  latest_resume_token: latestResumeToken,
4225
4269
  latest_response_token: latestResponseToken,
4226
4270
  token_matches: tokenMatches,
@@ -4237,6 +4281,7 @@ function checkpointResponseIdentity(response) {
4237
4281
  const logicalResponse = compactRecord({
4238
4282
  run_id: response.run_id,
4239
4283
  checkpoint: response.checkpoint,
4284
+ packet_id: response.packet_id,
4240
4285
  resume_token: response.resume_token,
4241
4286
  decision: response.decision,
4242
4287
  summary: response.summary,
@@ -5008,10 +5053,7 @@ function isReadyShipGate(result) {
5008
5053
  return Boolean(gate && gate.ok === true);
5009
5054
  }
5010
5055
  function proofAssessmentRequestsShip(payload) {
5011
- const decision = String(payload.decision || "");
5012
- const recommendedStage = String(payload.recommended_stage || "");
5013
- const continueStage = String(payload.continue_with_stage || "");
5014
- return decision === "ready_to_ship" || recommendedStage === "ship" || continueStage === "ship";
5056
+ return String(payload.decision || "").trim() === "ready_to_ship";
5015
5057
  }
5016
5058
  function proofAssessmentHardBlockers(state, payload) {
5017
5059
  const blockers = proofAssessmentHardBlockersForState(state || {});
@@ -5029,12 +5071,7 @@ function proofAssessmentContinuation(result, payload) {
5029
5071
  return { ...baseContinuation(result), proof_assessment_json };
5030
5072
  }
5031
5073
  function defaultStageForProofCheckpointDecision(decision) {
5032
- if (decision === "ready_to_ship") return "ship";
5033
- if (decision === "needs_implementation") return "implement";
5034
- if (decision === "needs_recon") return "recon";
5035
- if (decision === "revise_capture") return "verify";
5036
- if (decision === "needs_richer_proof") return "author";
5037
- return null;
5074
+ return canonicalProofAssessmentStageForDecision(decision);
5038
5075
  }
5039
5076
  function checkpointContractFromPacket(packet) {
5040
5077
  return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
@@ -5060,7 +5097,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5060
5097
  }
5061
5098
  const payload = recordValue(response.payload) || {};
5062
5099
  const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
5063
- return compactRecord({
5100
+ return normalizeProofAssessmentStageFields(compactRecord({
5064
5101
  ...payload,
5065
5102
  decision: response.decision,
5066
5103
  summary: response.summary,
@@ -5071,7 +5108,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5071
5108
  source: "supervising_agent",
5072
5109
  checkpoint_response_source: response.source || null,
5073
5110
  checkpoint_response_created_at: response.created_at
5074
- });
5111
+ }));
5075
5112
  }
5076
5113
  function reconAssessmentPayloadFromCheckpointResponse(response) {
5077
5114
  if (![
@@ -5395,6 +5432,22 @@ function checkpointResponseContinuation(state, value) {
5395
5432
  }
5396
5433
  };
5397
5434
  }
5435
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
5436
+ return {
5437
+ blocker: {
5438
+ code: "checkpoint_response_packet_id_mismatch",
5439
+ checkpoint: packet.checkpoint,
5440
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
5441
+ details: {
5442
+ stage: packet.stage,
5443
+ expected_packet_id: packet.packet_id,
5444
+ actual_packet_id: response.packet_id || null,
5445
+ expected_resume_token: packet.resume_token || null,
5446
+ actual_resume_token: response.resume_token || null
5447
+ }
5448
+ }
5449
+ };
5450
+ }
5398
5451
  if (!packet.allowed_decisions.includes(response.decision)) {
5399
5452
  return {
5400
5453
  blocker: {
@@ -6021,7 +6074,7 @@ async function routeCheckpoint(request, state, result, agent, input) {
6021
6074
  }
6022
6075
  return { blocker };
6023
6076
  }
6024
- const payload = assessment.payload;
6077
+ const payload = normalizeProofAssessmentStageFields(assessment.payload);
6025
6078
  recordEvent(state, {
6026
6079
  kind: "agent.proof_assessment.completed",
6027
6080
  checkpoint,
@@ -2,11 +2,11 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-ZHTJEZH5.js";
6
- import "./chunk-M3IE3VNC.js";
7
- import "./chunk-RBAU2M4S.js";
8
- import "./chunk-X7SQTCIQ.js";
9
- import "./chunk-AXWJJ2LC.js";
5
+ } from "./chunk-ZLBOGPUL.js";
6
+ import "./chunk-WDIKPIMB.js";
7
+ import "./chunk-JJ4IWRMJ.js";
8
+ import "./chunk-EKZXU6MU.js";
9
+ import "./chunk-BLM5EIBA.js";
10
10
  import "./chunk-VY4Y5U57.js";
11
11
  import "./chunk-MLKGABMK.js";
12
12
  export {