@riddledc/riddle-proof 0.8.52 → 0.8.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/adapters/openclaw.js +4 -4
  2. package/dist/advanced/engine-harness.cjs +117 -12
  3. package/dist/advanced/engine-harness.js +4 -4
  4. package/dist/advanced/index.cjs +117 -12
  5. package/dist/advanced/index.d.cts +1 -1
  6. package/dist/advanced/index.d.ts +1 -1
  7. package/dist/advanced/index.js +5 -5
  8. package/dist/advanced/proof-run-engine.d.cts +1 -1
  9. package/dist/advanced/proof-run-engine.d.ts +1 -1
  10. package/dist/advanced/runner.js +4 -4
  11. package/dist/checkpoint.cjs +41 -11
  12. package/dist/checkpoint.d.cts +2 -1
  13. package/dist/checkpoint.d.ts +2 -1
  14. package/dist/checkpoint.js +3 -1
  15. package/dist/{chunk-AXWJJ2LC.js → chunk-BLM5EIBA.js} +40 -11
  16. package/dist/{chunk-FWHJN3QG.js → chunk-ECLGGGAI.js} +3 -2
  17. package/dist/{chunk-WURLFN72.js → chunk-IV4DVWPR.js} +82 -4
  18. package/dist/{chunk-RBAU2M4S.js → chunk-JJ4IWRMJ.js} +1 -1
  19. package/dist/{chunk-OYWZGDTS.js → chunk-LNWJAHAQ.js} +1 -1
  20. package/dist/{chunk-2CZORYB7.js → chunk-S5DX7Z6X.js} +1 -1
  21. package/dist/{chunk-M3IE3VNC.js → chunk-WDIKPIMB.js} +1 -1
  22. package/dist/cli/index.js +5 -5
  23. package/dist/cli.cjs +119 -12
  24. package/dist/cli.js +5 -5
  25. package/dist/engine-harness.cjs +117 -12
  26. package/dist/engine-harness.js +4 -4
  27. package/dist/index.cjs +120 -12
  28. package/dist/index.d.cts +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +7 -5
  31. package/dist/openclaw.js +4 -4
  32. package/dist/{proof-run-engine-DpChFR5H.d.cts → proof-run-engine-Baiv6l3A.d.cts} +3 -3
  33. package/dist/{proof-run-engine-BqRoA3Do.d.ts → proof-run-engine-MiKZt9oY.d.ts} +3 -3
  34. package/dist/proof-run-engine.d.cts +1 -1
  35. package/dist/proof-run-engine.d.ts +1 -1
  36. package/dist/run-card.js +2 -2
  37. package/dist/runner.js +4 -4
  38. package/dist/spec/checkpoint.cjs +41 -11
  39. package/dist/spec/checkpoint.d.cts +1 -1
  40. package/dist/spec/checkpoint.d.ts +1 -1
  41. package/dist/spec/checkpoint.js +3 -1
  42. package/dist/spec/index.cjs +41 -11
  43. package/dist/spec/index.d.cts +1 -1
  44. package/dist/spec/index.d.ts +1 -1
  45. package/dist/spec/index.js +5 -3
  46. package/dist/spec/run-card.js +2 -2
  47. package/dist/spec/state.js +3 -3
  48. package/dist/state.js +3 -3
  49. package/dist/types.d.cts +5 -0
  50. package/dist/types.d.ts +5 -0
  51. package/package.json +1 -1
@@ -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,
@@ -107,12 +108,13 @@ function statePathsForRunState(state, engineStatePath) {
107
108
  function responseSchemaForAuthorPacket() {
108
109
  return {
109
110
  type: "object",
110
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
111
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
111
112
  additionalProperties: false,
112
113
  properties: {
113
114
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
114
115
  run_id: { type: "string" },
115
116
  checkpoint: { type: "string" },
117
+ packet_id: { type: "string" },
116
118
  resume_token: { type: "string" },
117
119
  decision: {
118
120
  type: "string",
@@ -140,12 +142,13 @@ function responseSchemaForAuthorPacket() {
140
142
  function responseSchemaForProofAssessmentPacket() {
141
143
  return {
142
144
  type: "object",
143
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
145
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
144
146
  additionalProperties: false,
145
147
  properties: {
146
148
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
147
149
  run_id: { type: "string" },
148
150
  checkpoint: { type: "string" },
151
+ packet_id: { type: "string" },
149
152
  resume_token: { type: "string" },
150
153
  decision: {
151
154
  type: "string",
@@ -181,12 +184,13 @@ function responseSchemaForProofAssessmentPacket() {
181
184
  function responseSchemaForReconPacket() {
182
185
  return {
183
186
  type: "object",
184
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
187
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
185
188
  additionalProperties: false,
186
189
  properties: {
187
190
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
188
191
  run_id: { type: "string" },
189
192
  checkpoint: { type: "string" },
193
+ packet_id: { type: "string" },
190
194
  resume_token: { type: "string" },
191
195
  decision: {
192
196
  type: "string",
@@ -214,12 +218,13 @@ function responseSchemaForReconPacket() {
214
218
  function responseSchemaForImplementationPacket() {
215
219
  return {
216
220
  type: "object",
217
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
221
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
218
222
  additionalProperties: false,
219
223
  properties: {
220
224
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
221
225
  run_id: { type: "string" },
222
226
  checkpoint: { type: "string" },
227
+ packet_id: { type: "string" },
223
228
  resume_token: { type: "string" },
224
229
  decision: {
225
230
  type: "string",
@@ -247,12 +252,13 @@ function responseSchemaForImplementationPacket() {
247
252
  function responseSchemaForAdvancePacket(stage) {
248
253
  return {
249
254
  type: "object",
250
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
255
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
251
256
  additionalProperties: false,
252
257
  properties: {
253
258
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
254
259
  run_id: { type: "string" },
255
260
  checkpoint: { type: "string" },
261
+ packet_id: { type: "string" },
256
262
  resume_token: { type: "string" },
257
263
  decision: {
258
264
  type: "string",
@@ -278,6 +284,20 @@ function resumeTokenFor(input) {
278
284
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
279
285
  return `rpchk_${hash}`;
280
286
  }
287
+ function packetIdentityPayload(packet) {
288
+ const { packet_id: _packetId, ...identityPayload } = packet;
289
+ return identityPayload;
290
+ }
291
+ function checkpointPacketIdentity(packet) {
292
+ const hash = import_node_crypto.default.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
293
+ return `rppkt_${hash}`;
294
+ }
295
+ function withPacketIdentity(packet) {
296
+ return {
297
+ ...packet,
298
+ packet_id: checkpointPacketIdentity(packet)
299
+ };
300
+ }
281
301
  function artifactsFromState(state) {
282
302
  const artifacts = [];
283
303
  for (const role of ["before", "prod", "after"]) {
@@ -350,7 +370,7 @@ function buildStageCheckpointPacket(input) {
350
370
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
351
371
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
352
372
  const kind = packetKindForStage(stage, checkpoint);
353
- return {
373
+ return withPacketIdentity({
354
374
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
355
375
  run_id: runId,
356
376
  state_path: input.runState.state_path,
@@ -399,7 +419,7 @@ function buildStageCheckpointPacket(input) {
399
419
  stage
400
420
  }),
401
421
  created_at: input.created_at || timestamp()
402
- };
422
+ });
403
423
  }
404
424
  function buildAuthorCheckpointPacket(input) {
405
425
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -412,7 +432,7 @@ function buildAuthorCheckpointPacket(input) {
412
432
  const reconResults = recordValue(fullState.recon_results);
413
433
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
414
434
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
415
- return {
435
+ return withPacketIdentity({
416
436
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
417
437
  run_id: runId,
418
438
  state_path: input.runState.state_path,
@@ -461,7 +481,7 @@ function buildAuthorCheckpointPacket(input) {
461
481
  stage
462
482
  }),
463
483
  created_at: input.created_at || timestamp()
464
- };
484
+ });
465
485
  }
466
486
  function visualDeltaFromState(fullState) {
467
487
  const bundle = recordValue(fullState.evidence_bundle);
@@ -532,7 +552,7 @@ function buildProofAssessmentCheckpointPacket(input) {
532
552
  const evidenceIssueCode = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
533
553
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
534
554
  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.";
535
- return {
555
+ return withPacketIdentity({
536
556
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
537
557
  run_id: runId,
538
558
  state_path: input.runState.state_path,
@@ -592,7 +612,7 @@ function buildProofAssessmentCheckpointPacket(input) {
592
612
  stage
593
613
  }),
594
614
  created_at: input.created_at || timestamp()
595
- };
615
+ });
596
616
  }
597
617
  function buildCheckpointPacketForEngineResult(input) {
598
618
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -621,6 +641,7 @@ function normalizeCheckpointResponse(value) {
621
641
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
622
642
  run_id: runId,
623
643
  checkpoint,
644
+ packet_id: nonEmptyString(record.packet_id),
624
645
  resume_token: nonEmptyString(record.resume_token),
625
646
  decision,
626
647
  summary,
@@ -708,6 +729,7 @@ function createCheckpointResponseTemplate(packet, input = {}) {
708
729
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
709
730
  run_id: packet.run_id,
710
731
  checkpoint: packet.checkpoint,
732
+ packet_id: packet.packet_id,
711
733
  resume_token: packet.resume_token,
712
734
  decision,
713
735
  summary: input.summary || `TODO: explain checkpoint decision ${decision}.`,
@@ -741,6 +763,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
741
763
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
742
764
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
743
765
  const latestResponse = latestResponseEntry?.response;
766
+ const latestPacketId = latestPacket?.packet_id || null;
767
+ const latestResponsePacketId = latestResponse?.packet_id || null;
768
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
744
769
  const latestResumeToken = latestPacket?.resume_token || null;
745
770
  const latestResponseToken = latestResponse?.resume_token || null;
746
771
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -755,6 +780,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
755
780
  latest_decision: latestResponse?.decision || null,
756
781
  latest_packet_summary: latestPacket?.summary || null,
757
782
  latest_response_summary: latestResponse?.summary || null,
783
+ latest_packet_id: latestPacketId,
784
+ latest_response_packet_id: latestResponsePacketId,
785
+ packet_id_matches: packetIdMatches,
758
786
  latest_resume_token: latestResumeToken,
759
787
  latest_response_token: latestResponseToken,
760
788
  token_matches: tokenMatches,
@@ -771,6 +799,7 @@ function checkpointResponseIdentity(response) {
771
799
  const logicalResponse = compactRecord({
772
800
  run_id: response.run_id,
773
801
  checkpoint: response.checkpoint,
802
+ packet_id: response.packet_id,
774
803
  resume_token: response.resume_token,
775
804
  decision: response.decision,
776
805
  summary: response.summary,
@@ -832,6 +861,7 @@ function proofContractFromAuthorCheckpointResponse(response, packet, payload) {
832
861
  buildCheckpointPacketForEngineResult,
833
862
  buildProofAssessmentCheckpointPacket,
834
863
  buildStageCheckpointPacket,
864
+ checkpointPacketIdentity,
835
865
  checkpointResponseIdentity,
836
866
  checkpointSummaryFromState,
837
867
  createCheckpointResponseTemplate,
@@ -1,2 +1,2 @@
1
- export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.cjs';
1
+ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.cjs';
2
2
  import '../types.cjs';
@@ -1,2 +1,2 @@
1
- export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.js';
1
+ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.js';
2
2
  import '../types.js';
@@ -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,
@@ -43,6 +43,7 @@ __export(spec_exports, {
43
43
  buildCheckpointPacketForEngineResult: () => buildCheckpointPacketForEngineResult,
44
44
  buildProofAssessmentCheckpointPacket: () => buildProofAssessmentCheckpointPacket,
45
45
  buildStageCheckpointPacket: () => buildStageCheckpointPacket,
46
+ checkpointPacketIdentity: () => checkpointPacketIdentity,
46
47
  checkpointResponseIdentity: () => checkpointResponseIdentity,
47
48
  checkpointSummaryFromState: () => checkpointSummaryFromState,
48
49
  compactRecord: () => compactRecord,
@@ -330,12 +331,13 @@ function statePathsForRunState(state, engineStatePath) {
330
331
  function responseSchemaForAuthorPacket() {
331
332
  return {
332
333
  type: "object",
333
- required: ["version", "run_id", "checkpoint", "decision", "summary", "payload", "created_at"],
334
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "payload", "created_at"],
334
335
  additionalProperties: false,
335
336
  properties: {
336
337
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
337
338
  run_id: { type: "string" },
338
339
  checkpoint: { type: "string" },
340
+ packet_id: { type: "string" },
339
341
  resume_token: { type: "string" },
340
342
  decision: {
341
343
  type: "string",
@@ -363,12 +365,13 @@ function responseSchemaForAuthorPacket() {
363
365
  function responseSchemaForProofAssessmentPacket() {
364
366
  return {
365
367
  type: "object",
366
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
368
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
367
369
  additionalProperties: false,
368
370
  properties: {
369
371
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
370
372
  run_id: { type: "string" },
371
373
  checkpoint: { type: "string" },
374
+ packet_id: { type: "string" },
372
375
  resume_token: { type: "string" },
373
376
  decision: {
374
377
  type: "string",
@@ -404,12 +407,13 @@ function responseSchemaForProofAssessmentPacket() {
404
407
  function responseSchemaForReconPacket() {
405
408
  return {
406
409
  type: "object",
407
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
410
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
408
411
  additionalProperties: false,
409
412
  properties: {
410
413
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
411
414
  run_id: { type: "string" },
412
415
  checkpoint: { type: "string" },
416
+ packet_id: { type: "string" },
413
417
  resume_token: { type: "string" },
414
418
  decision: {
415
419
  type: "string",
@@ -437,12 +441,13 @@ function responseSchemaForReconPacket() {
437
441
  function responseSchemaForImplementationPacket() {
438
442
  return {
439
443
  type: "object",
440
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
444
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
441
445
  additionalProperties: false,
442
446
  properties: {
443
447
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
444
448
  run_id: { type: "string" },
445
449
  checkpoint: { type: "string" },
450
+ packet_id: { type: "string" },
446
451
  resume_token: { type: "string" },
447
452
  decision: {
448
453
  type: "string",
@@ -470,12 +475,13 @@ function responseSchemaForImplementationPacket() {
470
475
  function responseSchemaForAdvancePacket(stage) {
471
476
  return {
472
477
  type: "object",
473
- required: ["version", "run_id", "checkpoint", "decision", "summary", "created_at"],
478
+ required: ["version", "run_id", "checkpoint", "packet_id", "decision", "summary", "created_at"],
474
479
  additionalProperties: false,
475
480
  properties: {
476
481
  version: { const: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION },
477
482
  run_id: { type: "string" },
478
483
  checkpoint: { type: "string" },
484
+ packet_id: { type: "string" },
479
485
  resume_token: { type: "string" },
480
486
  decision: {
481
487
  type: "string",
@@ -501,6 +507,20 @@ function resumeTokenFor(input) {
501
507
  const hash = import_node_crypto.default.createHash("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24);
502
508
  return `rpchk_${hash}`;
503
509
  }
510
+ function packetIdentityPayload(packet) {
511
+ const { packet_id: _packetId, ...identityPayload } = packet;
512
+ return identityPayload;
513
+ }
514
+ function checkpointPacketIdentity(packet) {
515
+ const hash = import_node_crypto.default.createHash("sha256").update(stableJson(packetIdentityPayload(packet))).digest("hex").slice(0, 24);
516
+ return `rppkt_${hash}`;
517
+ }
518
+ function withPacketIdentity(packet) {
519
+ return {
520
+ ...packet,
521
+ packet_id: checkpointPacketIdentity(packet)
522
+ };
523
+ }
504
524
  function artifactsFromState(state) {
505
525
  const artifacts = [];
506
526
  for (const role of ["before", "prod", "after"]) {
@@ -573,7 +593,7 @@ function buildStageCheckpointPacket(input) {
573
593
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
574
594
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.stage_summary) || `${stage} checkpoint needs a supervising decision.`;
575
595
  const kind = packetKindForStage(stage, checkpoint);
576
- return {
596
+ return withPacketIdentity({
577
597
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
578
598
  run_id: runId,
579
599
  state_path: input.runState.state_path,
@@ -622,7 +642,7 @@ function buildStageCheckpointPacket(input) {
622
642
  stage
623
643
  }),
624
644
  created_at: input.created_at || timestamp()
625
- };
645
+ });
626
646
  }
627
647
  function buildAuthorCheckpointPacket(input) {
628
648
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "author_supervisor_judgment";
@@ -635,7 +655,7 @@ function buildAuthorCheckpointPacket(input) {
635
655
  const reconResults = recordValue(fullState.recon_results);
636
656
  const checkpointContract = recordValue(input.engineResult.checkpointContract);
637
657
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.author_summary) || "Author checkpoint needs a supervising proof packet.";
638
- return {
658
+ return withPacketIdentity({
639
659
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
640
660
  run_id: runId,
641
661
  state_path: input.runState.state_path,
@@ -684,7 +704,7 @@ function buildAuthorCheckpointPacket(input) {
684
704
  stage
685
705
  }),
686
706
  created_at: input.created_at || timestamp()
687
- };
707
+ });
688
708
  }
689
709
  function visualDeltaFromState(fullState) {
690
710
  const bundle = recordValue(fullState.evidence_bundle);
@@ -755,7 +775,7 @@ function buildProofAssessmentCheckpointPacket(input) {
755
775
  const evidenceIssueCode2 = visualDeltaIssueCode(visualDelta, visualDeltaRequired);
756
776
  const summary = nonEmptyString(input.engineResult.summary) || nonEmptyString(fullState.verify_summary) || "Verify captured evidence and needs a supervising proof assessment.";
757
777
  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.";
758
- return {
778
+ return withPacketIdentity({
759
779
  version: RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
760
780
  run_id: runId,
761
781
  state_path: input.runState.state_path,
@@ -815,7 +835,7 @@ function buildProofAssessmentCheckpointPacket(input) {
815
835
  stage
816
836
  }),
817
837
  created_at: input.created_at || timestamp()
818
- };
838
+ });
819
839
  }
820
840
  function buildCheckpointPacketForEngineResult(input) {
821
841
  const checkpoint = nonEmptyString(input.engineResult.checkpoint) || "";
@@ -844,6 +864,7 @@ function normalizeCheckpointResponse(value) {
844
864
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
845
865
  run_id: runId,
846
866
  checkpoint,
867
+ packet_id: nonEmptyString(record.packet_id),
847
868
  resume_token: nonEmptyString(record.resume_token),
848
869
  decision,
849
870
  summary,
@@ -931,6 +952,7 @@ function createCheckpointResponseTemplate(packet, input = {}) {
931
952
  version: RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
932
953
  run_id: packet.run_id,
933
954
  checkpoint: packet.checkpoint,
955
+ packet_id: packet.packet_id,
934
956
  resume_token: packet.resume_token,
935
957
  decision,
936
958
  summary: input.summary || `TODO: explain checkpoint decision ${decision}.`,
@@ -964,6 +986,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
964
986
  const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
965
987
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
966
988
  const latestResponse = latestResponseEntry?.response;
989
+ const latestPacketId = latestPacket?.packet_id || null;
990
+ const latestResponsePacketId = latestResponse?.packet_id || null;
991
+ const packetIdMatches = !latestResponse ? null : latestPacketId && latestResponsePacketId ? latestPacketId === latestResponsePacketId : latestPacketId || latestResponsePacketId ? false : null;
967
992
  const latestResumeToken = latestPacket?.resume_token || null;
968
993
  const latestResponseToken = latestResponse?.resume_token || null;
969
994
  const tokenMatches = !latestResponse ? null : latestResumeToken && latestResponseToken ? latestResumeToken === latestResponseToken : latestResumeToken || latestResponseToken ? false : null;
@@ -978,6 +1003,9 @@ function checkpointSummaryFromState(state, engineStatePath) {
978
1003
  latest_decision: latestResponse?.decision || null,
979
1004
  latest_packet_summary: latestPacket?.summary || null,
980
1005
  latest_response_summary: latestResponse?.summary || null,
1006
+ latest_packet_id: latestPacketId,
1007
+ latest_response_packet_id: latestResponsePacketId,
1008
+ packet_id_matches: packetIdMatches,
981
1009
  latest_resume_token: latestResumeToken,
982
1010
  latest_response_token: latestResponseToken,
983
1011
  token_matches: tokenMatches,
@@ -994,6 +1022,7 @@ function checkpointResponseIdentity(response) {
994
1022
  const logicalResponse = compactRecord({
995
1023
  run_id: response.run_id,
996
1024
  checkpoint: response.checkpoint,
1025
+ packet_id: response.packet_id,
997
1026
  resume_token: response.resume_token,
998
1027
  decision: response.decision,
999
1028
  summary: response.summary,
@@ -1523,6 +1552,7 @@ function applyPrLifecycleState(state, input, at = timestamp2()) {
1523
1552
  buildCheckpointPacketForEngineResult,
1524
1553
  buildProofAssessmentCheckpointPacket,
1525
1554
  buildStageCheckpointPacket,
1555
+ checkpointPacketIdentity,
1526
1556
  checkpointResponseIdentity,
1527
1557
  checkpointSummaryFromState,
1528
1558
  compactRecord,
@@ -1,5 +1,5 @@
1
1
  export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofCheckpointArtifact, RiddleProofCheckpointPacket, RiddleProofCheckpointResponse, RiddleProofCheckpointRole, RiddleProofCheckpointRoutingHint, RiddleProofCheckpointSummary, RiddleProofCheckpointVisibility, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofPrLifecycleState, RiddleProofPrLifecycleStatus, RiddleProofProofContract, RiddleProofRunCard, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatePaths, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, RiddleProofViewportCapture, RiddleProofViewportMatrixStatus, RiddleProofVisualSession, RiddleProofVisualSessionFingerprintBasis, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from '../types.cjs';
2
2
  export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from '../result.cjs';
3
3
  export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from '../state.cjs';
4
- export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.cjs';
4
+ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.cjs';
5
5
  export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from '../run-card.cjs';
@@ -1,5 +1,5 @@
1
1
  export { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofCheckpointArtifact, RiddleProofCheckpointPacket, RiddleProofCheckpointResponse, RiddleProofCheckpointRole, RiddleProofCheckpointRoutingHint, RiddleProofCheckpointSummary, RiddleProofCheckpointVisibility, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofPrLifecycleState, RiddleProofPrLifecycleStatus, RiddleProofProofContract, RiddleProofRunCard, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatePaths, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, RiddleProofViewportCapture, RiddleProofViewportMatrixStatus, RiddleProofVisualSession, RiddleProofVisualSessionFingerprintBasis, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter } from '../types.js';
2
2
  export { TerminalMetadataInput, applyTerminalMetadata, compactRecord, createRunResult, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue } from '../result.js';
3
3
  export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from '../state.js';
4
- export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.js';
4
+ export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.js';
5
5
  export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from '../run-card.js';
@@ -10,11 +10,11 @@ import {
10
10
  normalizePrLifecycleState,
11
11
  normalizeRunParams,
12
12
  setRunStatus
13
- } from "../chunk-M3IE3VNC.js";
13
+ } from "../chunk-WDIKPIMB.js";
14
14
  import {
15
15
  RIDDLE_PROOF_RUN_CARD_VERSION,
16
16
  createRiddleProofRunCard
17
- } from "../chunk-RBAU2M4S.js";
17
+ } from "../chunk-JJ4IWRMJ.js";
18
18
  import {
19
19
  RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
20
20
  RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION,
@@ -23,6 +23,7 @@ import {
23
23
  buildCheckpointPacketForEngineResult,
24
24
  buildProofAssessmentCheckpointPacket,
25
25
  buildStageCheckpointPacket,
26
+ checkpointPacketIdentity,
26
27
  checkpointResponseIdentity,
27
28
  checkpointSummaryFromState,
28
29
  createCheckpointResponseTemplate,
@@ -30,7 +31,7 @@ import {
30
31
  normalizeCheckpointResponse,
31
32
  proofContractFromAuthorCheckpointResponse,
32
33
  statePathsForRunState
33
- } from "../chunk-AXWJJ2LC.js";
34
+ } from "../chunk-BLM5EIBA.js";
34
35
  import {
35
36
  applyTerminalMetadata,
36
37
  compactRecord,
@@ -56,6 +57,7 @@ export {
56
57
  buildCheckpointPacketForEngineResult,
57
58
  buildProofAssessmentCheckpointPacket,
58
59
  buildStageCheckpointPacket,
60
+ checkpointPacketIdentity,
59
61
  checkpointResponseIdentity,
60
62
  checkpointSummaryFromState,
61
63
  compactRecord,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  RIDDLE_PROOF_RUN_CARD_VERSION,
3
3
  createRiddleProofRunCard
4
- } from "../chunk-RBAU2M4S.js";
5
- import "../chunk-AXWJJ2LC.js";
4
+ } from "../chunk-JJ4IWRMJ.js";
5
+ import "../chunk-BLM5EIBA.js";
6
6
  import "../chunk-VY4Y5U57.js";
7
7
  import "../chunk-MLKGABMK.js";
8
8
  export {
@@ -9,9 +9,9 @@ import {
9
9
  normalizePrLifecycleState,
10
10
  normalizeRunParams,
11
11
  setRunStatus
12
- } from "../chunk-M3IE3VNC.js";
13
- import "../chunk-RBAU2M4S.js";
14
- import "../chunk-AXWJJ2LC.js";
12
+ } from "../chunk-WDIKPIMB.js";
13
+ import "../chunk-JJ4IWRMJ.js";
14
+ import "../chunk-BLM5EIBA.js";
15
15
  import "../chunk-VY4Y5U57.js";
16
16
  import "../chunk-MLKGABMK.js";
17
17
  export {
package/dist/state.js CHANGED
@@ -9,9 +9,9 @@ import {
9
9
  normalizePrLifecycleState,
10
10
  normalizeRunParams,
11
11
  setRunStatus
12
- } from "./chunk-M3IE3VNC.js";
13
- import "./chunk-RBAU2M4S.js";
14
- import "./chunk-AXWJJ2LC.js";
12
+ } from "./chunk-WDIKPIMB.js";
13
+ import "./chunk-JJ4IWRMJ.js";
14
+ import "./chunk-BLM5EIBA.js";
15
15
  import "./chunk-VY4Y5U57.js";
16
16
  import "./chunk-MLKGABMK.js";
17
17
  export {
package/dist/types.d.cts CHANGED
@@ -90,6 +90,7 @@ interface RiddleProofCheckpointPacket {
90
90
  version: "riddle-proof.checkpoint.v1";
91
91
  run_id: string;
92
92
  state_path?: string;
93
+ packet_id?: string;
93
94
  stage: RiddleProofStage;
94
95
  checkpoint: string;
95
96
  kind: "assess_recon" | "author_proof" | "implement_change" | "assess_proof" | "recover_evidence" | "human_review" | "advance_decision" | (string & {});
@@ -111,6 +112,7 @@ interface RiddleProofCheckpointResponse {
111
112
  version: "riddle-proof.checkpoint_response.v1";
112
113
  run_id: string;
113
114
  checkpoint: string;
115
+ packet_id?: string;
114
116
  resume_token?: string;
115
117
  decision: string;
116
118
  summary: string;
@@ -140,6 +142,9 @@ interface RiddleProofCheckpointSummary {
140
142
  latest_decision?: string | null;
141
143
  latest_packet_summary?: string | null;
142
144
  latest_response_summary?: string | null;
145
+ latest_packet_id?: string | null;
146
+ latest_response_packet_id?: string | null;
147
+ packet_id_matches?: boolean | null;
143
148
  latest_resume_token?: string | null;
144
149
  latest_response_token?: string | null;
145
150
  token_matches?: boolean | null;
package/dist/types.d.ts CHANGED
@@ -90,6 +90,7 @@ interface RiddleProofCheckpointPacket {
90
90
  version: "riddle-proof.checkpoint.v1";
91
91
  run_id: string;
92
92
  state_path?: string;
93
+ packet_id?: string;
93
94
  stage: RiddleProofStage;
94
95
  checkpoint: string;
95
96
  kind: "assess_recon" | "author_proof" | "implement_change" | "assess_proof" | "recover_evidence" | "human_review" | "advance_decision" | (string & {});
@@ -111,6 +112,7 @@ interface RiddleProofCheckpointResponse {
111
112
  version: "riddle-proof.checkpoint_response.v1";
112
113
  run_id: string;
113
114
  checkpoint: string;
115
+ packet_id?: string;
114
116
  resume_token?: string;
115
117
  decision: string;
116
118
  summary: string;
@@ -140,6 +142,9 @@ interface RiddleProofCheckpointSummary {
140
142
  latest_decision?: string | null;
141
143
  latest_packet_summary?: string | null;
142
144
  latest_response_summary?: string | null;
145
+ latest_packet_id?: string | null;
146
+ latest_response_packet_id?: string | null;
147
+ packet_id_matches?: boolean | null;
143
148
  latest_resume_token?: string | null;
144
149
  latest_response_token?: string | null;
145
150
  token_matches?: boolean | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.8.52",
3
+ "version": "0.8.54",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",