@riddledc/riddle-proof 0.8.52 → 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 (43) hide show
  1. package/dist/adapters/openclaw.js +4 -4
  2. package/dist/advanced/engine-harness.cjs +54 -11
  3. package/dist/advanced/engine-harness.js +4 -4
  4. package/dist/advanced/index.cjs +54 -11
  5. package/dist/advanced/index.js +5 -5
  6. package/dist/advanced/runner.js +4 -4
  7. package/dist/checkpoint.cjs +41 -11
  8. package/dist/checkpoint.d.cts +2 -1
  9. package/dist/checkpoint.d.ts +2 -1
  10. package/dist/checkpoint.js +3 -1
  11. package/dist/{chunk-FWHJN3QG.js → chunk-2ALMXMFZ.js} +3 -2
  12. package/dist/{chunk-AXWJJ2LC.js → chunk-BLM5EIBA.js} +40 -11
  13. package/dist/{chunk-RBAU2M4S.js → chunk-JJ4IWRMJ.js} +1 -1
  14. package/dist/{chunk-OYWZGDTS.js → chunk-LNWJAHAQ.js} +1 -1
  15. package/dist/{chunk-2CZORYB7.js → chunk-S5DX7Z6X.js} +1 -1
  16. package/dist/{chunk-M3IE3VNC.js → chunk-WDIKPIMB.js} +1 -1
  17. package/dist/{chunk-WURLFN72.js → chunk-ZLBOGPUL.js} +19 -3
  18. package/dist/cli/index.js +5 -5
  19. package/dist/cli.cjs +56 -11
  20. package/dist/cli.js +5 -5
  21. package/dist/engine-harness.cjs +54 -11
  22. package/dist/engine-harness.js +4 -4
  23. package/dist/index.cjs +57 -11
  24. package/dist/index.d.cts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +7 -5
  27. package/dist/openclaw.js +4 -4
  28. package/dist/run-card.js +2 -2
  29. package/dist/runner.js +4 -4
  30. package/dist/spec/checkpoint.cjs +41 -11
  31. package/dist/spec/checkpoint.d.cts +1 -1
  32. package/dist/spec/checkpoint.d.ts +1 -1
  33. package/dist/spec/checkpoint.js +3 -1
  34. package/dist/spec/index.cjs +41 -11
  35. package/dist/spec/index.d.cts +1 -1
  36. package/dist/spec/index.d.ts +1 -1
  37. package/dist/spec/index.js +5 -3
  38. package/dist/spec/run-card.js +2 -2
  39. package/dist/spec/state.js +3 -3
  40. package/dist/state.js +3 -3
  41. package/dist/types.d.cts +5 -0
  42. package/dist/types.d.ts +5 -0
  43. package/package.json +1 -1
@@ -37,6 +37,7 @@ __export(checkpoint_exports, {
37
37
  buildCheckpointPacketForEngineResult: () => buildCheckpointPacketForEngineResult,
38
38
  buildProofAssessmentCheckpointPacket: () => buildProofAssessmentCheckpointPacket,
39
39
  buildStageCheckpointPacket: () => buildStageCheckpointPacket,
40
+ checkpointPacketIdentity: () => checkpointPacketIdentity,
40
41
  checkpointResponseIdentity: () => checkpointResponseIdentity,
41
42
  checkpointSummaryFromState: () => checkpointSummaryFromState,
42
43
  createCheckpointResponseTemplate: () => createCheckpointResponseTemplate,
@@ -105,12 +106,13 @@ function statePathsForRunState(state, engineStatePath) {
105
106
  function responseSchemaForAuthorPacket() {
106
107
  return {
107
108
  type: "object",
108
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
109
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
109
110
  additionalProperties: false,
110
111
  properties: {
111
112
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
112
113
  run_id: { type: "string" },
113
114
  checkpoint: { type: "string" },
115
+ packet_id: { type: "string" },
114
116
  resume_token: { type: "string" },
115
117
  decision: {
116
118
  type: "string",
@@ -138,12 +140,13 @@ function responseSchemaForAuthorPacket() {
138
140
  function responseSchemaForProofAssessmentPacket() {
139
141
  return {
140
142
  type: "object",
141
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
143
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
142
144
  additionalProperties: false,
143
145
  properties: {
144
146
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
145
147
  run_id: { type: "string" },
146
148
  checkpoint: { type: "string" },
149
+ packet_id: { type: "string" },
147
150
  resume_token: { type: "string" },
148
151
  decision: {
149
152
  type: "string",
@@ -179,12 +182,13 @@ function responseSchemaForProofAssessmentPacket() {
179
182
  function responseSchemaForReconPacket() {
180
183
  return {
181
184
  type: "object",
182
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
185
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
183
186
  additionalProperties: false,
184
187
  properties: {
185
188
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
186
189
  run_id: { type: "string" },
187
190
  checkpoint: { type: "string" },
191
+ packet_id: { type: "string" },
188
192
  resume_token: { type: "string" },
189
193
  decision: {
190
194
  type: "string",
@@ -212,12 +216,13 @@ function responseSchemaForReconPacket() {
212
216
  function responseSchemaForImplementationPacket() {
213
217
  return {
214
218
  type: "object",
215
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
219
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
216
220
  additionalProperties: false,
217
221
  properties: {
218
222
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
219
223
  run_id: { type: "string" },
220
224
  checkpoint: { type: "string" },
225
+ packet_id: { type: "string" },
221
226
  resume_token: { type: "string" },
222
227
  decision: {
223
228
  type: "string",
@@ -245,12 +250,13 @@ function responseSchemaForImplementationPacket() {
245
250
  function responseSchemaForAdvancePacket(stage) {
246
251
  return {
247
252
  type: "object",
248
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
253
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
249
254
  additionalProperties: false,
250
255
  properties: {
251
256
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
252
257
  run_id: { type: "string" },
253
258
  checkpoint: { type: "string" },
259
+ packet_id: { type: "string" },
254
260
  resume_token: { type: "string" },
255
261
  decision: {
256
262
  type: "string",
@@ -276,6 +282,20 @@ function resumeTokenFor(input) {
276
282
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
277
283
  return `rpchk_${hash}`;
278
284
  }
285
+ function packetIdentityPayload(packet) {
286
+ const { packet_id: _packetId, ...identityPayload } = packet;
287
+ return identityPayload;
288
+ }
289
+ function checkpointPacketIdentity(packet) {
290
+ const hash = import_node_crypto.default.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
291
+ return `rppkt_${hash}`;
292
+ }
293
+ function withPacketIdentity(packet) {
294
+ return {
295
+ ...packet,
296
+ packet_id: checkpointPacketIdentity(packet)
297
+ };
298
+ }
279
299
  function artifactsFromState(state) {
280
300
  const artifacts = [];
281
301
  for (const role of ["before", "prod", "after"]) {
@@ -348,7 +368,7 @@ function buildStageCheckpointPacket(input) {
348
368
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
349
369
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
350
370
  const kind = packetKindForStage(stage, checkpoint);
351
- return {
371
+ return withPacketIdentity({
352
372
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
353
373
  run_id: runId,
354
374
  state_path: input.runState.state_path,
@@ -397,7 +417,7 @@ function buildStageCheckpointPacket(input) {
397
417
  stage
398
418
  }),
399
419
  created_at: input.created_at || timestamp()
400
- };
420
+ });
401
421
  }
402
422
  function buildAuthorCheckpointPacket(input) {
403
423
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -410,7 +430,7 @@ function buildAuthorCheckpointPacket(input) {
410
430
  const reconResults = recordValue(fullState.recon_results);
411
431
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
412
432
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
413
- return {
433
+ return withPacketIdentity({
414
434
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
415
435
  run_id: runId,
416
436
  state_path: input.runState.state_path,
@@ -459,7 +479,7 @@ function buildAuthorCheckpointPacket(input) {
459
479
  stage
460
480
  }),
461
481
  created_at: input.created_at || timestamp()
462
- };
482
+ });
463
483
  }
464
484
  function visualDeltaFromState(fullState) {
465
485
  const bundle = recordValue(fullState.evidence_bundle);
@@ -530,7 +550,7 @@ function buildProofAssessmentCheckpointPacket(input) {
530
550
  const evidenceIssueCode = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
531
551
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
532
552
  const recoveryHint = evidenceIssueCode ? "Required visual_delta evidence is incomplete. Keep this same run in verify/evidence recovery with decision=revise_capture and continue_with_stage=verify unless the evidence proves an implementation or recon problem." : "Assess whether the current artifacts prove the requested change, then choose the next stage.";
533
- return {
553
+ return withPacketIdentity({
534
554
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
535
555
  run_id: runId,
536
556
  state_path: input.runState.state_path,
@@ -590,7 +610,7 @@ function buildProofAssessmentCheckpointPacket(input) {
590
610
  stage
591
611
  }),
592
612
  created_at: input.created_at || timestamp()
593
- };
613
+ });
594
614
  }
595
615
  function buildCheckpointPacketForEngineResult(input) {
596
616
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -619,6 +639,7 @@ function normalizeCheckpointResponse(value) {
619
639
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
620
640
  run_id: runId,
621
641
  checkpoint,
642
+ packet_id: nonEmptyString(record.packet_id),
622
643
  resume_token: nonEmptyString(record.resume_token),
623
644
  decision,
624
645
  summary,
@@ -706,6 +727,7 @@ function createCheckpointResponseTemplate(packet, input = {}) {
706
727
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
707
728
  run_id: packet.run_id,
708
729
  checkpoint: packet.checkpoint,
730
+ packet_id: packet.packet_id,
709
731
  resume_token: packet.resume_token,
710
732
  decision,
711
733
  summary: input.summary || `TODO: explain checkpoint decision ${decision}.`,
@@ -739,6 +761,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
739
761
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
740
762
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
741
763
  const latestResponse = latestResponseEntry?.response;
764
+ const latestPacketId = latestPacket?.packet_id || null;
765
+ const latestResponsePacketId = latestResponse?.packet_id || null;
766
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
742
767
  const latestResumeToken = latestPacket?.resume_token || null;
743
768
  const latestResponseToken = latestResponse?.resume_token || null;
744
769
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -753,6 +778,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
753
778
  latest_decision: latestResponse?.decision || null,
754
779
  latest_packet_summary: latestPacket?.summary || null,
755
780
  latest_response_summary: latestResponse?.summary || null,
781
+ latest_packet_id: latestPacketId,
782
+ latest_response_packet_id: latestResponsePacketId,
783
+ packet_id_matches: packetIdMatches,
756
784
  latest_resume_token: latestResumeToken,
757
785
  latest_response_token: latestResponseToken,
758
786
  token_matches: tokenMatches,
@@ -769,6 +797,7 @@ function checkpointResponseIdentity(response) {
769
797
  const logicalResponse = compactRecord({
770
798
  run_id: response.run_id,
771
799
  checkpoint: response.checkpoint,
800
+ packet_id: response.packet_id,
772
801
  resume_token: response.resume_token,
773
802
  decision: response.decision,
774
803
  summary: response.summary,
@@ -830,6 +859,7 @@ function proofContractFromAuthorCheckpointResponse(response, packet, payload) {
830
859
  buildCheckpointPacketForEngineResult,
831
860
  buildProofAssessmentCheckpointPacket,
832
861
  buildStageCheckpointPacket,
862
+ checkpointPacketIdentity,
833
863
  checkpointResponseIdentity,
834
864
  checkpointSummaryFromState,
835
865
  createCheckpointResponseTemplate,
@@ -3,6 +3,7 @@ import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunStat
3
3
  declare const RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION: "riddle-proof.checkpoint.v1";
4
4
  declare const RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION: "riddle-proof.checkpoint_response.v1";
5
5
  declare function statePathsForRunState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofStatePaths;
6
+ declare function checkpointPacketIdentity(packet: RiddleProofCheckpointPacket): string;
6
7
  declare function buildStageCheckpointPacket(input: {
7
8
  request: RiddleProofRunParams;
8
9
  runState: RiddleProofRunState;
@@ -76,4 +77,4 @@ declare function checkpointResponseIdentity(response: RiddleProofCheckpointRespo
76
77
  declare function authorPacketPayloadFromCheckpointResponse(response: RiddleProofCheckpointResponse): Record<string, unknown> | null;
77
78
  declare function proofContractFromAuthorCheckpointResponse(response: RiddleProofCheckpointResponse, packet: RiddleProofCheckpointPacket, payload: Record<string, unknown>): RiddleProofProofContract;
78
79
 
79
- export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
80
+ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
@@ -3,6 +3,7 @@ import { RiddleProofCheckpointResponse, RiddleProofRunParams, RiddleProofRunStat
3
3
  declare const RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION: "riddle-proof.checkpoint.v1";
4
4
  declare const RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION: "riddle-proof.checkpoint_response.v1";
5
5
  declare function statePathsForRunState(state: RiddleProofRunState, engineStatePath?: string | null): RiddleProofStatePaths;
6
+ declare function checkpointPacketIdentity(packet: RiddleProofCheckpointPacket): string;
6
7
  declare function buildStageCheckpointPacket(input: {
7
8
  request: RiddleProofRunParams;
8
9
  runState: RiddleProofRunState;
@@ -76,4 +77,4 @@ declare function checkpointResponseIdentity(response: RiddleProofCheckpointRespo
76
77
  declare function authorPacketPayloadFromCheckpointResponse(response: RiddleProofCheckpointResponse): Record<string, unknown> | null;
77
78
  declare function proofContractFromAuthorCheckpointResponse(response: RiddleProofCheckpointResponse, packet: RiddleProofCheckpointPacket, payload: Record<string, unknown>): RiddleProofProofContract;
78
79
 
79
- export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
80
+ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState };
@@ -6,6 +6,7 @@ import {
6
6
  buildCheckpointPacketForEngineResult,
7
7
  buildProofAssessmentCheckpointPacket,
8
8
  buildStageCheckpointPacket,
9
+ checkpointPacketIdentity,
9
10
  checkpointResponseIdentity,
10
11
  checkpointSummaryFromState,
11
12
  createCheckpointResponseTemplate,
@@ -13,7 +14,7 @@ import {
13
14
  normalizeCheckpointResponse,
14
15
  proofContractFromAuthorCheckpointResponse,
15
16
  statePathsForRunState
16
- } from "./chunk-AXWJJ2LC.js";
17
+ } from "./chunk-BLM5EIBA.js";
17
18
  import "./chunk-VY4Y5U57.js";
18
19
  import "./chunk-MLKGABMK.js";
19
20
  export {
@@ -24,6 +25,7 @@ export {
24
25
  buildCheckpointPacketForEngineResult,
25
26
  buildProofAssessmentCheckpointPacket,
26
27
  buildStageCheckpointPacket,
28
+ checkpointPacketIdentity,
27
29
  checkpointResponseIdentity,
28
30
  checkpointSummaryFromState,
29
31
  createCheckpointResponseTemplate,
@@ -28,10 +28,10 @@ import {
28
28
  createDisabledRiddleProofAgentAdapter,
29
29
  readRiddleProofRunStatus,
30
30
  runRiddleProofEngineHarness
31
- } from "./chunk-WURLFN72.js";
31
+ } from "./chunk-ZLBOGPUL.js";
32
32
  import {
33
33
  createCheckpointResponseTemplate
34
- } from "./chunk-AXWJJ2LC.js";
34
+ } from "./chunk-BLM5EIBA.js";
35
35
  import {
36
36
  createCodexExecAgentAdapter,
37
37
  runCodexExecAgentDoctor
@@ -1088,6 +1088,7 @@ function formatCheckpointMarkdown(input) {
1088
1088
  `Status: ${input.status || "awaiting_checkpoint"}`,
1089
1089
  `Stage: ${packet.stage}`,
1090
1090
  `Checkpoint: ${packet.checkpoint}`,
1091
+ `Packet ID: ${packet.packet_id || "legacy"}`,
1091
1092
  `Kind: ${packet.kind}`,
1092
1093
  "",
1093
1094
  "## Goal",
@@ -51,12 +51,13 @@ function statePathsForRunState(state, engineStatePath) {
51
51
  function responseSchemaForAuthorPacket() {
52
52
  return {
53
53
  type: "object",
54
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
54
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
55
55
  additionalProperties: false,
56
56
  properties: {
57
57
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
58
58
  run_id: { type: "string" },
59
59
  checkpoint: { type: "string" },
60
+ packet_id: { type: "string" },
60
61
  resume_token: { type: "string" },
61
62
  decision: {
62
63
  type: "string",
@@ -84,12 +85,13 @@ function responseSchemaForAuthorPacket() {
84
85
  function responseSchemaForProofAssessmentPacket() {
85
86
  return {
86
87
  type: "object",
87
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
88
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
88
89
  additionalProperties: false,
89
90
  properties: {
90
91
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
91
92
  run_id: { type: "string" },
92
93
  checkpoint: { type: "string" },
94
+ packet_id: { type: "string" },
93
95
  resume_token: { type: "string" },
94
96
  decision: {
95
97
  type: "string",
@@ -125,12 +127,13 @@ function responseSchemaForProofAssessmentPacket() {
125
127
  function responseSchemaForReconPacket() {
126
128
  return {
127
129
  type: "object",
128
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
130
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
129
131
  additionalProperties: false,
130
132
  properties: {
131
133
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
132
134
  run_id: { type: "string" },
133
135
  checkpoint: { type: "string" },
136
+ packet_id: { type: "string" },
134
137
  resume_token: { type: "string" },
135
138
  decision: {
136
139
  type: "string",
@@ -158,12 +161,13 @@ function responseSchemaForReconPacket() {
158
161
  function responseSchemaForImplementationPacket() {
159
162
  return {
160
163
  type: "object",
161
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
164
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
162
165
  additionalProperties: false,
163
166
  properties: {
164
167
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
165
168
  run_id: { type: "string" },
166
169
  checkpoint: { type: "string" },
170
+ packet_id: { type: "string" },
167
171
  resume_token: { type: "string" },
168
172
  decision: {
169
173
  type: "string",
@@ -191,12 +195,13 @@ function responseSchemaForImplementationPacket() {
191
195
  function responseSchemaForAdvancePacket(stage) {
192
196
  return {
193
197
  type: "object",
194
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
198
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
195
199
  additionalProperties: false,
196
200
  properties: {
197
201
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
198
202
  run_id: { type: "string" },
199
203
  checkpoint: { type: "string" },
204
+ packet_id: { type: "string" },
200
205
  resume_token: { type: "string" },
201
206
  decision: {
202
207
  type: "string",
@@ -222,6 +227,20 @@ function resumeTokenFor(input) {
222
227
  const hash = crypto.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
223
228
  return `rpchk_${hash}`;
224
229
  }
230
+ function packetIdentityPayload(packet) {
231
+ const { packet_id: _packetId, ...identityPayload } = packet;
232
+ return identityPayload;
233
+ }
234
+ function checkpointPacketIdentity(packet) {
235
+ const hash = crypto.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
236
+ return `rppkt_${hash}`;
237
+ }
238
+ function withPacketIdentity(packet) {
239
+ return {
240
+ ...packet,
241
+ packet_id: checkpointPacketIdentity(packet)
242
+ };
243
+ }
225
244
  function artifactsFromState(state) {
226
245
  const artifacts = [];
227
246
  for (const role of ["before", "prod", "after"]) {
@@ -294,7 +313,7 @@ function buildStageCheckpointPacket(input) {
294
313
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
295
314
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
296
315
  const kind = packetKindForStage(stage, checkpoint);
297
- return {
316
+ return withPacketIdentity({
298
317
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
299
318
  run_id: runId,
300
319
  state_path: input.runState.state_path,
@@ -343,7 +362,7 @@ function buildStageCheckpointPacket(input) {
343
362
  stage
344
363
  }),
345
364
  created_at: input.created_at || timestamp()
346
- };
365
+ });
347
366
  }
348
367
  function buildAuthorCheckpointPacket(input) {
349
368
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -356,7 +375,7 @@ function buildAuthorCheckpointPacket(input) {
356
375
  const reconResults = recordValue(fullState.recon_results);
357
376
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
358
377
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
359
- return {
378
+ return withPacketIdentity({
360
379
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
361
380
  run_id: runId,
362
381
  state_path: input.runState.state_path,
@@ -405,7 +424,7 @@ function buildAuthorCheckpointPacket(input) {
405
424
  stage
406
425
  }),
407
426
  created_at: input.created_at || timestamp()
408
- };
427
+ });
409
428
  }
410
429
  function visualDeltaFromState(fullState) {
411
430
  const bundle = recordValue(fullState.evidence_bundle);
@@ -476,7 +495,7 @@ function buildProofAssessmentCheckpointPacket(input) {
476
495
  const evidenceIssueCode = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
477
496
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
478
497
  const recoveryHint = evidenceIssueCode ? "Required visual_delta evidence is incomplete. Keep this same run in verify/evidence recovery with decision=revise_capture and continue_with_stage=verify unless the evidence proves an implementation or recon problem." : "Assess whether the current artifacts prove the requested change, then choose the next stage.";
479
- return {
498
+ return withPacketIdentity({
480
499
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
481
500
  run_id: runId,
482
501
  state_path: input.runState.state_path,
@@ -536,7 +555,7 @@ function buildProofAssessmentCheckpointPacket(input) {
536
555
  stage
537
556
  }),
538
557
  created_at: input.created_at || timestamp()
539
- };
558
+ });
540
559
  }
541
560
  function buildCheckpointPacketForEngineResult(input) {
542
561
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -565,6 +584,7 @@ function normalizeCheckpointResponse(value) {
565
584
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
566
585
  run_id: runId,
567
586
  checkpoint,
587
+ packet_id: nonEmptyString(record.packet_id),
568
588
  resume_token: nonEmptyString(record.resume_token),
569
589
  decision,
570
590
  summary,
@@ -652,6 +672,7 @@ function createCheckpointResponseTemplate(packet, input = {}) {
652
672
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
653
673
  run_id: packet.run_id,
654
674
  checkpoint: packet.checkpoint,
675
+ packet_id: packet.packet_id,
655
676
  resume_token: packet.resume_token,
656
677
  decision,
657
678
  summary: input.summary || `TODO: explain checkpoint decision ${decision}.`,
@@ -685,6 +706,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
685
706
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
686
707
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
687
708
  const latestResponse = latestResponseEntry?.response;
709
+ const latestPacketId = latestPacket?.packet_id || null;
710
+ const latestResponsePacketId = latestResponse?.packet_id || null;
711
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
688
712
  const latestResumeToken = latestPacket?.resume_token || null;
689
713
  const latestResponseToken = latestResponse?.resume_token || null;
690
714
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -699,6 +723,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
699
723
  latest_decision: latestResponse?.decision || null,
700
724
  latest_packet_summary: latestPacket?.summary || null,
701
725
  latest_response_summary: latestResponse?.summary || null,
726
+ latest_packet_id: latestPacketId,
727
+ latest_response_packet_id: latestResponsePacketId,
728
+ packet_id_matches: packetIdMatches,
702
729
  latest_resume_token: latestResumeToken,
703
730
  latest_response_token: latestResponseToken,
704
731
  token_matches: tokenMatches,
@@ -715,6 +742,7 @@ function checkpointResponseIdentity(response) {
715
742
  const logicalResponse = compactRecord({
716
743
  run_id: response.run_id,
717
744
  checkpoint: response.checkpoint,
745
+ packet_id: response.packet_id,
718
746
  resume_token: response.resume_token,
719
747
  decision: response.decision,
720
748
  summary: response.summary,
@@ -772,6 +800,7 @@ export {
772
800
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
773
801
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
774
802
  statePathsForRunState,
803
+ checkpointPacketIdentity,
775
804
  buildStageCheckpointPacket,
776
805
  buildAuthorCheckpointPacket,
777
806
  buildProofAssessmentCheckpointPacket,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  statePathsForRunState
3
- } from "./chunk-AXWJJ2LC.js";
3
+ } from "./chunk-BLM5EIBA.js";
4
4
  import {
5
5
  compactRecord,
6
6
  isTerminalStatus,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  normalizeIntegrationContext,
3
3
  normalizeRunParams
4
- } from "./chunk-M3IE3VNC.js";
4
+ } from "./chunk-WDIKPIMB.js";
5
5
  import {
6
6
  compactRecord
7
7
  } from "./chunk-VY4Y5U57.js";
@@ -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,
@@ -5,10 +5,10 @@ import {
5
5
  createRunStatusSnapshot,
6
6
  normalizeRunParams,
7
7
  setRunStatus
8
- } from "./chunk-M3IE3VNC.js";
8
+ } from "./chunk-WDIKPIMB.js";
9
9
  import {
10
10
  createRiddleProofRunCard
11
- } from "./chunk-RBAU2M4S.js";
11
+ } from "./chunk-JJ4IWRMJ.js";
12
12
  import {
13
13
  canonicalProofAssessmentStageForDecision,
14
14
  noImplementationModeFor,
@@ -27,7 +27,7 @@ import {
27
27
  normalizeCheckpointResponse,
28
28
  proofContractFromAuthorCheckpointResponse,
29
29
  statePathsForRunState
30
- } from "./chunk-AXWJJ2LC.js";
30
+ } from "./chunk-BLM5EIBA.js";
31
31
  import {
32
32
  applyTerminalMetadata,
33
33
  compactRecord,
@@ -738,6 +738,22 @@ function checkpointResponseContinuation(state, value) {
738
738
  }
739
739
  };
740
740
  }
741
+ if (packet.packet_id && response.packet_id !== packet.packet_id) {
742
+ return {
743
+ blocker: {
744
+ code: "checkpoint_response_packet_id_mismatch",
745
+ checkpoint: packet.checkpoint,
746
+ message: "Checkpoint response packet_id does not match the pending checkpoint packet.",
747
+ details: {
748
+ stage: packet.stage,
749
+ expected_packet_id: packet.packet_id,
750
+ actual_packet_id: response.packet_id || null,
751
+ expected_resume_token: packet.resume_token || null,
752
+ actual_resume_token: response.resume_token || null
753
+ }
754
+ }
755
+ };
756
+ }
741
757
  if (!packet.allowed_decisions.includes(response.decision)) {
742
758
  return {
743
759
  blocker: {
package/dist/cli/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import "../chunk-FWHJN3QG.js";
1
+ import "../chunk-2ALMXMFZ.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-ZLBOGPUL.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";