@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
@@ -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 {
@@ -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;
@@ -3664,12 +3682,13 @@ function statePathsForRunState(state, engineStatePath2) {
3664
3682
  function responseSchemaForAuthorPacket() {
3665
3683
  return {
3666
3684
  type: "object",
3667
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3685
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3668
3686
  additionalProperties: false,
3669
3687
  properties: {
3670
3688
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3671
3689
  run_id: { type: "string" },
3672
3690
  checkpoint: { type: "string" },
3691
+ packet_id: { type: "string" },
3673
3692
  resume_token: { type: "string" },
3674
3693
  decision: {
3675
3694
  type: "string",
@@ -3697,12 +3716,13 @@ function responseSchemaForAuthorPacket() {
3697
3716
  function responseSchemaForProofAssessmentPacket() {
3698
3717
  return {
3699
3718
  type: "object",
3700
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3719
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3701
3720
  additionalProperties: false,
3702
3721
  properties: {
3703
3722
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3704
3723
  run_id: { type: "string" },
3705
3724
  checkpoint: { type: "string" },
3725
+ packet_id: { type: "string" },
3706
3726
  resume_token: { type: "string" },
3707
3727
  decision: {
3708
3728
  type: "string",
@@ -3738,12 +3758,13 @@ function responseSchemaForProofAssessmentPacket() {
3738
3758
  function responseSchemaForReconPacket() {
3739
3759
  return {
3740
3760
  type: "object",
3741
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3761
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3742
3762
  additionalProperties: false,
3743
3763
  properties: {
3744
3764
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3745
3765
  run_id: { type: "string" },
3746
3766
  checkpoint: { type: "string" },
3767
+ packet_id: { type: "string" },
3747
3768
  resume_token: { type: "string" },
3748
3769
  decision: {
3749
3770
  type: "string",
@@ -3771,12 +3792,13 @@ function responseSchemaForReconPacket() {
3771
3792
  function responseSchemaForImplementationPacket() {
3772
3793
  return {
3773
3794
  type: "object",
3774
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3795
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3775
3796
  additionalProperties: false,
3776
3797
  properties: {
3777
3798
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3778
3799
  run_id: { type: "string" },
3779
3800
  checkpoint: { type: "string" },
3801
+ packet_id: { type: "string" },
3780
3802
  resume_token: { type: "string" },
3781
3803
  decision: {
3782
3804
  type: "string",
@@ -3804,12 +3826,13 @@ function responseSchemaForImplementationPacket() {
3804
3826
  function responseSchemaForAdvancePacket(stage) {
3805
3827
  return {
3806
3828
  type: "object",
3807
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3829
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3808
3830
  additionalProperties: false,
3809
3831
  properties: {
3810
3832
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3811
3833
  run_id: { type: "string" },
3812
3834
  checkpoint: { type: "string" },
3835
+ packet_id: { type: "string" },
3813
3836
  resume_token: { type: "string" },
3814
3837
  decision: {
3815
3838
  type: "string",
@@ -3835,6 +3858,20 @@ function resumeTokenFor(input) {
3835
3858
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3836
3859
  return `rpchk_${hash}`;
3837
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
+ }
3838
3875
  function artifactsFromState(state) {
3839
3876
  const artifacts = [];
3840
3877
  for (const role of ["before", "prod", "after"]) {
@@ -3907,7 +3944,7 @@ function buildStageCheckpointPacket(input) {
3907
3944
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3908
3945
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3909
3946
  const kind = packetKindForStage(stage, checkpoint);
3910
- return {
3947
+ return withPacketIdentity({
3911
3948
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3912
3949
  run_id: runId,
3913
3950
  state_path: input.runState.state_path,
@@ -3956,7 +3993,7 @@ function buildStageCheckpointPacket(input) {
3956
3993
  stage
3957
3994
  }),
3958
3995
  created_at: input.created_at || timestamp()
3959
- };
3996
+ });
3960
3997
  }
3961
3998
  function buildAuthorCheckpointPacket(input) {
3962
3999
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -3969,7 +4006,7 @@ function buildAuthorCheckpointPacket(input) {
3969
4006
  const reconResults = recordValue(fullState.recon_results);
3970
4007
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3971
4008
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
3972
- return {
4009
+ return withPacketIdentity({
3973
4010
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3974
4011
  run_id: runId,
3975
4012
  state_path: input.runState.state_path,
@@ -4018,7 +4055,7 @@ function buildAuthorCheckpointPacket(input) {
4018
4055
  stage
4019
4056
  }),
4020
4057
  created_at: input.created_at || timestamp()
4021
- };
4058
+ });
4022
4059
  }
4023
4060
  function visualDeltaFromState(fullState) {
4024
4061
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4089,7 +4126,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4089
4126
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4090
4127
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4091
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.";
4092
- return {
4129
+ return withPacketIdentity({
4093
4130
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4094
4131
  run_id: runId,
4095
4132
  state_path: input.runState.state_path,
@@ -4149,7 +4186,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4149
4186
  stage
4150
4187
  }),
4151
4188
  created_at: input.created_at || timestamp()
4152
- };
4189
+ });
4153
4190
  }
4154
4191
  function buildCheckpointPacketForEngineResult(input) {
4155
4192
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4178,6 +4215,7 @@ function normalizeCheckpointResponse(value) {
4178
4215
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4179
4216
  run_id: runId,
4180
4217
  checkpoint,
4218
+ packet_id: nonEmptyString(record.packet_id),
4181
4219
  resume_token: nonEmptyString(record.resume_token),
4182
4220
  decision,
4183
4221
  summary,
@@ -4209,6 +4247,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4209
4247
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4210
4248
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4211
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;
4212
4253
  const latestResumeToken = latestPacket?.resume_token || null;
4213
4254
  const latestResponseToken = latestResponse?.resume_token || null;
4214
4255
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4223,6 +4264,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4223
4264
  latest_decision: latestResponse?.decision || null,
4224
4265
  latest_packet_summary: latestPacket?.summary || null,
4225
4266
  latest_response_summary: latestResponse?.summary || null,
4267
+ latest_packet_id: latestPacketId,
4268
+ latest_response_packet_id: latestResponsePacketId,
4269
+ packet_id_matches: packetIdMatches,
4226
4270
  latest_resume_token: latestResumeToken,
4227
4271
  latest_response_token: latestResponseToken,
4228
4272
  token_matches: tokenMatches,
@@ -4239,6 +4283,7 @@ function checkpointResponseIdentity(response) {
4239
4283
  const logicalResponse = compactRecord({
4240
4284
  run_id: response.run_id,
4241
4285
  checkpoint: response.checkpoint,
4286
+ packet_id: response.packet_id,
4242
4287
  resume_token: response.resume_token,
4243
4288
  decision: response.decision,
4244
4289
  summary: response.summary,
@@ -5010,10 +5055,7 @@ function isReadyShipGate(result) {
5010
5055
  return Boolean(gate && gate.ok === true);
5011
5056
  }
5012
5057
  function proofAssessmentRequestsShip(payload) {
5013
- const decision = String(payload.decision || "");
5014
- const recommendedStage = String(payload.recommended_stage || "");
5015
- const continueStage = String(payload.continue_with_stage || "");
5016
- return decision === "ready_to_ship" || recommendedStage === "ship" || continueStage === "ship";
5058
+ return String(payload.decision || "").trim() === "ready_to_ship";
5017
5059
  }
5018
5060
  function proofAssessmentHardBlockers(state, payload) {
5019
5061
  const blockers = proofAssessmentHardBlockersForState(state || {});
@@ -5031,12 +5073,7 @@ function proofAssessmentContinuation(result, payload) {
5031
5073
  return { ...baseContinuation(result), proof_assessment_json };
5032
5074
  }
5033
5075
  function defaultStageForProofCheckpointDecision(decision) {
5034
- if (decision === "ready_to_ship") return "ship";
5035
- if (decision === "needs_implementation") return "implement";
5036
- if (decision === "needs_recon") return "recon";
5037
- if (decision === "revise_capture") return "verify";
5038
- if (decision === "needs_richer_proof") return "author";
5039
- return null;
5076
+ return canonicalProofAssessmentStageForDecision(decision);
5040
5077
  }
5041
5078
  function checkpointContractFromPacket(packet) {
5042
5079
  return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
@@ -5062,7 +5099,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5062
5099
  }
5063
5100
  const payload = recordValue(response.payload) || {};
5064
5101
  const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
5065
- return compactRecord({
5102
+ return normalizeProofAssessmentStageFields(compactRecord({
5066
5103
  ...payload,
5067
5104
  decision: response.decision,
5068
5105
  summary: response.summary,
@@ -5073,7 +5110,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5073
5110
  source: "supervising_agent",
5074
5111
  checkpoint_response_source: response.source || null,
5075
5112
  checkpoint_response_created_at: response.created_at
5076
- });
5113
+ }));
5077
5114
  }
5078
5115
  function reconAssessmentPayloadFromCheckpointResponse(response) {
5079
5116
  if (![
@@ -5397,6 +5434,22 @@ function checkpointResponseContinuation(state, value) {
5397
5434
  }
5398
5435
  };
5399
5436
  }
5437
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
5438
+ return {
5439
+ blocker: {
5440
+ code: "checkpoint_response_packet_id_mismatch",
5441
+ checkpoint: packet.checkpoint,
5442
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
5443
+ details: {
5444
+ stage: packet.stage,
5445
+ expected_packet_id: packet.packet_id,
5446
+ actual_packet_id: response.packet_id || null,
5447
+ expected_resume_token: packet.resume_token || null,
5448
+ actual_resume_token: response.resume_token || null
5449
+ }
5450
+ }
5451
+ };
5452
+ }
5400
5453
  if (!packet.allowed_decisions.includes(response.decision)) {
5401
5454
  return {
5402
5455
  blocker: {
@@ -6023,7 +6076,7 @@ async function routeCheckpoint(request, state, result, agent, input) {
6023
6076
  }
6024
6077
  return { blocker };
6025
6078
  }
6026
- const payload = assessment.payload;
6079
+ const payload = normalizeProofAssessmentStageFields(assessment.payload);
6027
6080
  recordEvent(state, {
6028
6081
  kind: "agent.proof_assessment.completed",
6029
6082
  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 {
@@ -39,6 +39,7 @@ __export(proof_run_core_exports, {
39
39
  WORKFLOW_STAGE_ORDER: () => WORKFLOW_STAGE_ORDER,
40
40
  buildCheckpointContract: () => buildCheckpointContract,
41
41
  buildSetupArgs: () => buildSetupArgs,
42
+ canonicalProofAssessmentStageForDecision: () => canonicalProofAssessmentStageForDecision,
42
43
  checkpointContinueStage: () => checkpointContinueStage,
43
44
  clearStageDecisionRequest: () => clearStageDecisionRequest,
44
45
  ensureAction: () => ensureAction,
@@ -46,6 +47,7 @@ __export(proof_run_core_exports, {
46
47
  invalidateVerifyEvidence: () => invalidateVerifyEvidence,
47
48
  mergeStateFromParams: () => mergeStateFromParams,
48
49
  noImplementationModeFor: () => noImplementationModeFor,
50
+ normalizeProofAssessmentStageFields: () => normalizeProofAssessmentStageFields,
49
51
  previewModeFromWorkflowMode: () => previewModeFromWorkflowMode,
50
52
  proofAssessmentHardBlockersForState: () => proofAssessmentHardBlockersForState,
51
53
  readState: () => readState,
@@ -62,6 +64,24 @@ __export(proof_run_core_exports, {
62
64
  workflowFile: () => workflowFile,
63
65
  writeState: () => writeState
64
66
  });
67
+ function canonicalProofAssessmentStageForDecision(decision) {
68
+ const normalized = typeof decision === "string" ? decision.trim() : "";
69
+ if (normalized === "ready_to_ship") return "ship";
70
+ if (normalized === "needs_richer_proof") return "author";
71
+ if (normalized === "revise_capture") return "verify";
72
+ if (normalized === "needs_recon") return "recon";
73
+ if (normalized === "needs_implementation") return "implement";
74
+ return null;
75
+ }
76
+ function normalizeProofAssessmentStageFields(assessment) {
77
+ const canonicalStage = canonicalProofAssessmentStageForDecision(assessment.decision);
78
+ if (!canonicalStage) return assessment;
79
+ return {
80
+ ...assessment,
81
+ recommended_stage: canonicalStage,
82
+ continue_with_stage: canonicalStage
83
+ };
84
+ }
65
85
  function normalizedMode(value) {
66
86
  return typeof value === "string" ? value.trim().toLowerCase() : "";
67
87
  }
@@ -897,10 +917,10 @@ function mergeStateFromParams(statePath, params) {
897
917
  state.proof_assessment_source = null;
898
918
  } else {
899
919
  const parsed = JSON.parse(raw);
900
- const assessment = {
920
+ const assessment = normalizeProofAssessmentStageFields({
901
921
  ...parsed,
902
922
  source: (parsed?.source || "supervising_agent").toString()
903
- };
923
+ });
904
924
  const readyBlocker = assessment?.decision === "ready_to_ship" ? visualDeltaShipGateReason({ ...state, proof_assessment: assessment, proof_assessment_source: assessment.source }) : null;
905
925
  if (readyBlocker) {
906
926
  assessment.blocked_decision = assessment.decision;
@@ -3696,12 +3716,13 @@ function statePathsForRunState(state, engineStatePath2) {
3696
3716
  function responseSchemaForAuthorPacket() {
3697
3717
  return {
3698
3718
  type: "object",
3699
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
3719
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
3700
3720
  additionalProperties: false,
3701
3721
  properties: {
3702
3722
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3703
3723
  run_id: { type: "string" },
3704
3724
  checkpoint: { type: "string" },
3725
+ packet_id: { type: "string" },
3705
3726
  resume_token: { type: "string" },
3706
3727
  decision: {
3707
3728
  type: "string",
@@ -3729,12 +3750,13 @@ function responseSchemaForAuthorPacket() {
3729
3750
  function responseSchemaForProofAssessmentPacket() {
3730
3751
  return {
3731
3752
  type: "object",
3732
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3753
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3733
3754
  additionalProperties: false,
3734
3755
  properties: {
3735
3756
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3736
3757
  run_id: { type: "string" },
3737
3758
  checkpoint: { type: "string" },
3759
+ packet_id: { type: "string" },
3738
3760
  resume_token: { type: "string" },
3739
3761
  decision: {
3740
3762
  type: "string",
@@ -3770,12 +3792,13 @@ function responseSchemaForProofAssessmentPacket() {
3770
3792
  function responseSchemaForReconPacket() {
3771
3793
  return {
3772
3794
  type: "object",
3773
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3795
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3774
3796
  additionalProperties: false,
3775
3797
  properties: {
3776
3798
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3777
3799
  run_id: { type: "string" },
3778
3800
  checkpoint: { type: "string" },
3801
+ packet_id: { type: "string" },
3779
3802
  resume_token: { type: "string" },
3780
3803
  decision: {
3781
3804
  type: "string",
@@ -3803,12 +3826,13 @@ function responseSchemaForReconPacket() {
3803
3826
  function responseSchemaForImplementationPacket() {
3804
3827
  return {
3805
3828
  type: "object",
3806
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3829
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3807
3830
  additionalProperties: false,
3808
3831
  properties: {
3809
3832
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3810
3833
  run_id: { type: "string" },
3811
3834
  checkpoint: { type: "string" },
3835
+ packet_id: { type: "string" },
3812
3836
  resume_token: { type: "string" },
3813
3837
  decision: {
3814
3838
  type: "string",
@@ -3836,12 +3860,13 @@ function responseSchemaForImplementationPacket() {
3836
3860
  function responseSchemaForAdvancePacket(stage) {
3837
3861
  return {
3838
3862
  type: "object",
3839
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
3863
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
3840
3864
  additionalProperties: false,
3841
3865
  properties: {
3842
3866
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
3843
3867
  run_id: { type: "string" },
3844
3868
  checkpoint: { type: "string" },
3869
+ packet_id: { type: "string" },
3845
3870
  resume_token: { type: "string" },
3846
3871
  decision: {
3847
3872
  type: "string",
@@ -3867,6 +3892,20 @@ function resumeTokenFor(input) {
3867
3892
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
3868
3893
  return `rpchk_${hash}`;
3869
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
+ }
3870
3909
  function artifactsFromState(state) {
3871
3910
  const artifacts = [];
3872
3911
  for (const role of ["before", "prod", "after"]) {
@@ -3939,7 +3978,7 @@ function buildStageCheckpointPacket(input) {
3939
3978
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
3940
3979
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
3941
3980
  const kind = packetKindForStage(stage, checkpoint);
3942
- return {
3981
+ return withPacketIdentity({
3943
3982
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
3944
3983
  run_id: runId,
3945
3984
  state_path: input.runState.state_path,
@@ -3988,7 +4027,7 @@ function buildStageCheckpointPacket(input) {
3988
4027
  stage
3989
4028
  }),
3990
4029
  created_at: input.created_at || timestamp()
3991
- };
4030
+ });
3992
4031
  }
3993
4032
  function buildAuthorCheckpointPacket(input) {
3994
4033
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -4001,7 +4040,7 @@ function buildAuthorCheckpointPacket(input) {
4001
4040
  const reconResults = recordValue(fullState.recon_results);
4002
4041
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
4003
4042
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
4004
- return {
4043
+ return withPacketIdentity({
4005
4044
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4006
4045
  run_id: runId,
4007
4046
  state_path: input.runState.state_path,
@@ -4050,7 +4089,7 @@ function buildAuthorCheckpointPacket(input) {
4050
4089
  stage
4051
4090
  }),
4052
4091
  created_at: input.created_at || timestamp()
4053
- };
4092
+ });
4054
4093
  }
4055
4094
  function visualDeltaFromState(fullState) {
4056
4095
  const bundle = recordValue(fullState.evidence_bundle);
@@ -4121,7 +4160,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4121
4160
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
4122
4161
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
4123
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.";
4124
- return {
4163
+ return withPacketIdentity({
4125
4164
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
4126
4165
  run_id: runId,
4127
4166
  state_path: input.runState.state_path,
@@ -4181,7 +4220,7 @@ function buildProofAssessmentCheckpointPacket(input) {
4181
4220
  stage
4182
4221
  }),
4183
4222
  created_at: input.created_at || timestamp()
4184
- };
4223
+ });
4185
4224
  }
4186
4225
  function buildCheckpointPacketForEngineResult(input) {
4187
4226
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -4210,6 +4249,7 @@ function normalizeCheckpointResponse(value) {
4210
4249
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
4211
4250
  run_id: runId,
4212
4251
  checkpoint,
4252
+ packet_id: nonEmptyString(record.packet_id),
4213
4253
  resume_token: nonEmptyString(record.resume_token),
4214
4254
  decision,
4215
4255
  summary,
@@ -4241,6 +4281,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4241
4281
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4242
4282
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4243
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;
4244
4287
  const latestResumeToken = latestPacket?.resume_token || null;
4245
4288
  const latestResponseToken = latestResponse?.resume_token || null;
4246
4289
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -4255,6 +4298,9 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4255
4298
  latest_decision: latestResponse?.decision || null,
4256
4299
  latest_packet_summary: latestPacket?.summary || null,
4257
4300
  latest_response_summary: latestResponse?.summary || null,
4301
+ latest_packet_id: latestPacketId,
4302
+ latest_response_packet_id: latestResponsePacketId,
4303
+ packet_id_matches: packetIdMatches,
4258
4304
  latest_resume_token: latestResumeToken,
4259
4305
  latest_response_token: latestResponseToken,
4260
4306
  token_matches: tokenMatches,
@@ -4271,6 +4317,7 @@ function checkpointResponseIdentity(response) {
4271
4317
  const logicalResponse = compactRecord({
4272
4318
  run_id: response.run_id,
4273
4319
  checkpoint: response.checkpoint,
4320
+ packet_id: response.packet_id,
4274
4321
  resume_token: response.resume_token,
4275
4322
  decision: response.decision,
4276
4323
  summary: response.summary,
@@ -5547,10 +5594,7 @@ function isReadyShipGate(result) {
5547
5594
  return Boolean(gate && gate.ok === true);
5548
5595
  }
5549
5596
  function proofAssessmentRequestsShip(payload) {
5550
- const decision = String(payload.decision || "");
5551
- const recommendedStage = String(payload.recommended_stage || "");
5552
- const continueStage = String(payload.continue_with_stage || "");
5553
- return decision === "ready_to_ship" || recommendedStage === "ship" || continueStage === "ship";
5597
+ return String(payload.decision || "").trim() === "ready_to_ship";
5554
5598
  }
5555
5599
  function proofAssessmentHardBlockers(state, payload) {
5556
5600
  const blockers = proofAssessmentHardBlockersForState(state || {});
@@ -5568,12 +5612,7 @@ function proofAssessmentContinuation(result, payload) {
5568
5612
  return { ...baseContinuation(result), proof_assessment_json };
5569
5613
  }
5570
5614
  function defaultStageForProofCheckpointDecision(decision) {
5571
- if (decision === "ready_to_ship") return "ship";
5572
- if (decision === "needs_implementation") return "implement";
5573
- if (decision === "needs_recon") return "recon";
5574
- if (decision === "revise_capture") return "verify";
5575
- if (decision === "needs_richer_proof") return "author";
5576
- return null;
5615
+ return canonicalProofAssessmentStageForDecision(decision);
5577
5616
  }
5578
5617
  function checkpointContractFromPacket(packet) {
5579
5618
  return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
@@ -5599,7 +5638,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5599
5638
  }
5600
5639
  const payload = recordValue(response.payload) || {};
5601
5640
  const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
5602
- return compactRecord({
5641
+ return normalizeProofAssessmentStageFields(compactRecord({
5603
5642
  ...payload,
5604
5643
  decision: response.decision,
5605
5644
  summary: response.summary,
@@ -5610,7 +5649,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5610
5649
  source: "supervising_agent",
5611
5650
  checkpoint_response_source: response.source || null,
5612
5651
  checkpoint_response_created_at: response.created_at
5613
- });
5652
+ }));
5614
5653
  }
5615
5654
  function reconAssessmentPayloadFromCheckpointResponse(response) {
5616
5655
  if (![
@@ -5934,6 +5973,22 @@ function checkpointResponseContinuation(state, value) {
5934
5973
  }
5935
5974
  };
5936
5975
  }
5976
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
5977
+ return {
5978
+ blocker: {
5979
+ code: "checkpoint_response_packet_id_mismatch",
5980
+ checkpoint: packet.checkpoint,
5981
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
5982
+ details: {
5983
+ stage: packet.stage,
5984
+ expected_packet_id: packet.packet_id,
5985
+ actual_packet_id: response.packet_id || null,
5986
+ expected_resume_token: packet.resume_token || null,
5987
+ actual_resume_token: response.resume_token || null
5988
+ }
5989
+ }
5990
+ };
5991
+ }
5937
5992
  if (!packet.allowed_decisions.includes(response.decision)) {
5938
5993
  return {
5939
5994
  blocker: {
@@ -6560,7 +6615,7 @@ async function routeCheckpoint(request, state, result, agent, input) {
6560
6615
  }
6561
6616
  return { blocker };
6562
6617
  }
6563
- const payload = assessment.payload;
6618
+ const payload = normalizeProofAssessmentStageFields(assessment.payload);
6564
6619
  recordEvent(state, {
6565
6620
  kind: "agent.proof_assessment.completed",
6566
6621
  checkpoint,
@@ -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
- export { p as proofRunCore } from '../proof-run-core-B1GeqkR8.cjs';
4
- export { p as proofRunEngine } from '../proof-run-engine-4dM37pEx.cjs';
3
+ export { p as proofRunCore } from '../proof-run-core-7Dqm7RKM.cjs';
4
+ export { p as proofRunEngine } from '../proof-run-engine-DpChFR5H.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
- export { p as proofRunCore } from '../proof-run-core-B1GeqkR8.js';
4
- export { p as proofRunEngine } from '../proof-run-engine-BqaeqAze.js';
3
+ export { p as proofRunCore } from '../proof-run-core-7Dqm7RKM.js';
4
+ export { p as proofRunEngine } from '../proof-run-engine-BqRoA3Do.js';
5
5
  import '../types.js';