@riddledc/riddle-proof 0.8.50 → 0.8.52

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 (57) hide show
  1. package/dist/adapters/openclaw.js +4 -4
  2. package/dist/advanced/engine-harness.cjs +41 -23
  3. package/dist/advanced/engine-harness.js +5 -5
  4. package/dist/advanced/index.cjs +43 -23
  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 +16 -4
  18. package/dist/checkpoint.js +1 -1
  19. package/dist/{chunk-UKGDVNGI.js → chunk-2CZORYB7.js} +2 -2
  20. package/dist/{chunk-U46KE6JZ.js → chunk-AXWJJ2LC.js} +16 -4
  21. package/dist/{chunk-X7SQTCIQ.js → chunk-EKZXU6MU.js} +24 -2
  22. package/dist/{chunk-TO3VKAG2.js → chunk-FWHJN3QG.js} +2 -2
  23. package/dist/{chunk-EMWF2575.js → chunk-M3IE3VNC.js} +1 -1
  24. package/dist/{chunk-2PHYFVTY.js → chunk-OYWZGDTS.js} +1 -1
  25. package/dist/{chunk-L7U7QZYH.js → chunk-RBAU2M4S.js} +1 -1
  26. package/dist/{chunk-IOI6QR3B.js → chunk-VYJD6XYF.js} +1 -1
  27. package/dist/{chunk-2KEYWZY5.js → chunk-WURLFN72.js} +11 -21
  28. package/dist/cli/index.js +6 -6
  29. package/dist/cli.cjs +41 -23
  30. package/dist/cli.js +6 -6
  31. package/dist/engine-harness.cjs +41 -23
  32. package/dist/engine-harness.js +5 -5
  33. package/dist/index.cjs +41 -23
  34. package/dist/index.js +6 -6
  35. package/dist/openclaw.js +4 -4
  36. package/dist/{proof-run-core-B1GeqkR8.d.ts → proof-run-core-7Dqm7RKM.d.cts} +6 -2
  37. package/dist/{proof-run-core-B1GeqkR8.d.cts → proof-run-core-7Dqm7RKM.d.ts} +6 -2
  38. package/dist/proof-run-core.cjs +24 -2
  39. package/dist/proof-run-core.d.cts +1 -1
  40. package/dist/proof-run-core.d.ts +1 -1
  41. package/dist/proof-run-core.js +5 -1
  42. package/dist/{proof-run-engine-BqaeqAze.d.ts → proof-run-engine-BqRoA3Do.d.ts} +1 -1
  43. package/dist/{proof-run-engine-4dM37pEx.d.cts → proof-run-engine-DpChFR5H.d.cts} +1 -1
  44. package/dist/proof-run-engine.cjs +20 -2
  45. package/dist/proof-run-engine.d.cts +2 -2
  46. package/dist/proof-run-engine.d.ts +2 -2
  47. package/dist/proof-run-engine.js +2 -2
  48. package/dist/run-card.js +2 -2
  49. package/dist/runner.js +5 -5
  50. package/dist/spec/checkpoint.cjs +16 -4
  51. package/dist/spec/checkpoint.js +1 -1
  52. package/dist/spec/index.cjs +16 -4
  53. package/dist/spec/index.js +3 -3
  54. package/dist/spec/run-card.js +2 -2
  55. package/dist/spec/state.js +3 -3
  56. package/dist/state.js +3 -3
  57. package/package.json +1 -1
@@ -3,10 +3,10 @@ import {
3
3
  parseOpenClawAssertions,
4
4
  parseOpenClawJsonObjectOrArray,
5
5
  toRiddleProofRunParams
6
- } from "../chunk-2PHYFVTY.js";
7
- import "../chunk-EMWF2575.js";
8
- import "../chunk-L7U7QZYH.js";
9
- import "../chunk-U46KE6JZ.js";
6
+ } from "../chunk-OYWZGDTS.js";
7
+ import "../chunk-M3IE3VNC.js";
8
+ import "../chunk-RBAU2M4S.js";
9
+ import "../chunk-AXWJJ2LC.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;
@@ -4188,13 +4206,25 @@ function normalizeCheckpointResponse(value) {
4188
4206
  created_at: nonEmptyString(record.created_at) || timestamp()
4189
4207
  });
4190
4208
  }
4209
+ function acceptedCheckpointResponseEntries(state) {
4210
+ const history = state.checkpoint_history || [];
4211
+ const events = state.events || [];
4212
+ const acceptedResponseEvents = events.filter((event) => event.kind === "checkpoint.response.accepted");
4213
+ const hasCheckpointResponseEvents = events.some((event) => nonEmptyString(event.kind)?.startsWith("checkpoint.response."));
4214
+ return history.filter((entry) => {
4215
+ if (!entry.response) return false;
4216
+ if (!hasCheckpointResponseEvents) return true;
4217
+ return acceptedResponseEvents.some((event) => event.ts === entry.ts && (!event.checkpoint || event.checkpoint === entry.response?.checkpoint));
4218
+ });
4219
+ }
4191
4220
  function checkpointSummaryFromState(state, engineStatePath2) {
4192
4221
  const history = state.checkpoint_history || [];
4222
+ const events = state.events || [];
4193
4223
  const packets = history.filter((entry) => entry.packet);
4194
- const responses = history.filter((entry) => entry.response);
4195
- const duplicateResponses = (state.events || []).filter((event) => event.kind === "checkpoint.response.duplicate");
4224
+ const responses = acceptedCheckpointResponseEntries(state);
4225
+ const duplicateResponses = events.filter((event) => event.kind === "checkpoint.response.duplicate");
4196
4226
  const latestPacketEntry = [...history].reverse().find((entry) => entry.packet);
4197
- const latestResponseEntry = [...history].reverse().find((entry) => entry.response);
4227
+ const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4198
4228
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4199
4229
  const latestResponse = latestResponseEntry?.response;
4200
4230
  const latestResumeToken = latestPacket?.resume_token || null;
@@ -4221,7 +4251,7 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4221
4251
  }
4222
4252
  function isDuplicateCheckpointResponse(state, response) {
4223
4253
  const identity = checkpointResponseIdentity(response);
4224
- return (state.checkpoint_history || []).some((entry) => entry.response ? checkpointResponseIdentity(entry.response) === identity : false);
4254
+ return acceptedCheckpointResponseEntries(state).some((entry) => entry.response ? checkpointResponseIdentity(entry.response) === identity : false);
4225
4255
  }
4226
4256
  function checkpointResponseIdentity(response) {
4227
4257
  const logicalResponse = compactRecord({
@@ -4998,10 +5028,7 @@ function isReadyShipGate(result) {
4998
5028
  return Boolean(gate && gate.ok === true);
4999
5029
  }
5000
5030
  function proofAssessmentRequestsShip(payload) {
5001
- const decision = String(payload.decision || "");
5002
- const recommendedStage = String(payload.recommended_stage || "");
5003
- const continueStage = String(payload.continue_with_stage || "");
5004
- return decision === "ready_to_ship" || recommendedStage === "ship" || continueStage === "ship";
5031
+ return String(payload.decision || "").trim() === "ready_to_ship";
5005
5032
  }
5006
5033
  function proofAssessmentHardBlockers(state, payload) {
5007
5034
  const blockers = proofAssessmentHardBlockersForState(state || {});
@@ -5019,12 +5046,7 @@ function proofAssessmentContinuation(result, payload) {
5019
5046
  return { ...baseContinuation(result), proof_assessment_json };
5020
5047
  }
5021
5048
  function defaultStageForProofCheckpointDecision(decision) {
5022
- if (decision === "ready_to_ship") return "ship";
5023
- if (decision === "needs_implementation") return "implement";
5024
- if (decision === "needs_recon") return "recon";
5025
- if (decision === "revise_capture") return "verify";
5026
- if (decision === "needs_richer_proof") return "author";
5027
- return null;
5049
+ return canonicalProofAssessmentStageForDecision(decision);
5028
5050
  }
5029
5051
  function checkpointContractFromPacket(packet) {
5030
5052
  return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
@@ -5050,7 +5072,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5050
5072
  }
5051
5073
  const payload = recordValue(response.payload) || {};
5052
5074
  const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
5053
- return compactRecord({
5075
+ return normalizeProofAssessmentStageFields(compactRecord({
5054
5076
  ...payload,
5055
5077
  decision: response.decision,
5056
5078
  summary: response.summary,
@@ -5061,7 +5083,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5061
5083
  source: "supervising_agent",
5062
5084
  checkpoint_response_source: response.source || null,
5063
5085
  checkpoint_response_created_at: response.created_at
5064
- });
5086
+ }));
5065
5087
  }
5066
5088
  function reconAssessmentPayloadFromCheckpointResponse(response) {
5067
5089
  if (![
@@ -5558,10 +5580,6 @@ function finalizedCheckpointResponseWithoutPacketResult(state, value) {
5558
5580
  if (!response) return null;
5559
5581
  if (isDuplicateCheckpointResponse(state, response)) return null;
5560
5582
  const at = timestamp3();
5561
- state.checkpoint_history = [
5562
- ...state.checkpoint_history || [],
5563
- { ts: at, response }
5564
- ].slice(-25);
5565
5583
  appendRunEvent(state, {
5566
5584
  ts: at,
5567
5585
  kind: "checkpoint.response.ignored",
@@ -6015,7 +6033,7 @@ async function routeCheckpoint(request, state, result, agent, input) {
6015
6033
  }
6016
6034
  return { blocker };
6017
6035
  }
6018
- const payload = assessment.payload;
6036
+ const payload = normalizeProofAssessmentStageFields(assessment.payload);
6019
6037
  recordEvent(state, {
6020
6038
  kind: "agent.proof_assessment.completed",
6021
6039
  checkpoint,
@@ -2,11 +2,11 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "../chunk-2KEYWZY5.js";
6
- import "../chunk-EMWF2575.js";
7
- import "../chunk-L7U7QZYH.js";
8
- import "../chunk-X7SQTCIQ.js";
9
- import "../chunk-U46KE6JZ.js";
5
+ } from "../chunk-WURLFN72.js";
6
+ import "../chunk-M3IE3VNC.js";
7
+ import "../chunk-RBAU2M4S.js";
8
+ import "../chunk-EKZXU6MU.js";
9
+ import "../chunk-AXWJJ2LC.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;
@@ -4220,13 +4240,25 @@ function normalizeCheckpointResponse(value) {
4220
4240
  created_at: nonEmptyString(record.created_at) || timestamp()
4221
4241
  });
4222
4242
  }
4243
+ function acceptedCheckpointResponseEntries(state) {
4244
+ const history = state.checkpoint_history || [];
4245
+ const events = state.events || [];
4246
+ const acceptedResponseEvents = events.filter((event) => event.kind === "checkpoint.response.accepted");
4247
+ const hasCheckpointResponseEvents = events.some((event) => nonEmptyString(event.kind)?.startsWith("checkpoint.response."));
4248
+ return history.filter((entry) => {
4249
+ if (!entry.response) return false;
4250
+ if (!hasCheckpointResponseEvents) return true;
4251
+ return acceptedResponseEvents.some((event) => event.ts === entry.ts && (!event.checkpoint || event.checkpoint === entry.response?.checkpoint));
4252
+ });
4253
+ }
4223
4254
  function checkpointSummaryFromState(state, engineStatePath2) {
4224
4255
  const history = state.checkpoint_history || [];
4256
+ const events = state.events || [];
4225
4257
  const packets = history.filter((entry) => entry.packet);
4226
- const responses = history.filter((entry) => entry.response);
4227
- const duplicateResponses = (state.events || []).filter((event) => event.kind === "checkpoint.response.duplicate");
4258
+ const responses = acceptedCheckpointResponseEntries(state);
4259
+ const duplicateResponses = events.filter((event) => event.kind === "checkpoint.response.duplicate");
4228
4260
  const latestPacketEntry = [...history].reverse().find((entry) => entry.packet);
4229
- const latestResponseEntry = [...history].reverse().find((entry) => entry.response);
4261
+ const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
4230
4262
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
4231
4263
  const latestResponse = latestResponseEntry?.response;
4232
4264
  const latestResumeToken = latestPacket?.resume_token || null;
@@ -4253,7 +4285,7 @@ function checkpointSummaryFromState(state, engineStatePath2) {
4253
4285
  }
4254
4286
  function isDuplicateCheckpointResponse(state, response) {
4255
4287
  const identity = checkpointResponseIdentity(response);
4256
- return (state.checkpoint_history || []).some((entry) => entry.response ? checkpointResponseIdentity(entry.response) === identity : false);
4288
+ return acceptedCheckpointResponseEntries(state).some((entry) => entry.response ? checkpointResponseIdentity(entry.response) === identity : false);
4257
4289
  }
4258
4290
  function checkpointResponseIdentity(response) {
4259
4291
  const logicalResponse = compactRecord({
@@ -5535,10 +5567,7 @@ function isReadyShipGate(result) {
5535
5567
  return Boolean(gate && gate.ok === true);
5536
5568
  }
5537
5569
  function proofAssessmentRequestsShip(payload) {
5538
- const decision = String(payload.decision || "");
5539
- const recommendedStage = String(payload.recommended_stage || "");
5540
- const continueStage = String(payload.continue_with_stage || "");
5541
- return decision === "ready_to_ship" || recommendedStage === "ship" || continueStage === "ship";
5570
+ return String(payload.decision || "").trim() === "ready_to_ship";
5542
5571
  }
5543
5572
  function proofAssessmentHardBlockers(state, payload) {
5544
5573
  const blockers = proofAssessmentHardBlockersForState(state || {});
@@ -5556,12 +5585,7 @@ function proofAssessmentContinuation(result, payload) {
5556
5585
  return { ...baseContinuation(result), proof_assessment_json };
5557
5586
  }
5558
5587
  function defaultStageForProofCheckpointDecision(decision) {
5559
- if (decision === "ready_to_ship") return "ship";
5560
- if (decision === "needs_implementation") return "implement";
5561
- if (decision === "needs_recon") return "recon";
5562
- if (decision === "revise_capture") return "verify";
5563
- if (decision === "needs_richer_proof") return "author";
5564
- return null;
5588
+ return canonicalProofAssessmentStageForDecision(decision);
5565
5589
  }
5566
5590
  function checkpointContractFromPacket(packet) {
5567
5591
  return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
@@ -5587,7 +5611,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5587
5611
  }
5588
5612
  const payload = recordValue(response.payload) || {};
5589
5613
  const stage = nonEmptyString(payload.continue_with_stage) || response.continue_with_stage || nonEmptyString(payload.recommended_stage) || defaultStageForProofCheckpointDecision(response.decision);
5590
- return compactRecord({
5614
+ return normalizeProofAssessmentStageFields(compactRecord({
5591
5615
  ...payload,
5592
5616
  decision: response.decision,
5593
5617
  summary: response.summary,
@@ -5598,7 +5622,7 @@ function proofAssessmentPayloadFromCheckpointResponse(response) {
5598
5622
  source: "supervising_agent",
5599
5623
  checkpoint_response_source: response.source || null,
5600
5624
  checkpoint_response_created_at: response.created_at
5601
- });
5625
+ }));
5602
5626
  }
5603
5627
  function reconAssessmentPayloadFromCheckpointResponse(response) {
5604
5628
  if (![
@@ -6095,10 +6119,6 @@ function finalizedCheckpointResponseWithoutPacketResult(state, value) {
6095
6119
  if (!response) return null;
6096
6120
  if (isDuplicateCheckpointResponse(state, response)) return null;
6097
6121
  const at = timestamp3();
6098
- state.checkpoint_history = [
6099
- ...state.checkpoint_history || [],
6100
- { ts: at, response }
6101
- ].slice(-25);
6102
6122
  appendRunEvent(state, {
6103
6123
  ts: at,
6104
6124
  kind: "checkpoint.response.ignored",
@@ -6552,7 +6572,7 @@ async function routeCheckpoint(request, state, result, agent, input) {
6552
6572
  }
6553
6573
  return { blocker };
6554
6574
  }
6555
- const payload = assessment.payload;
6575
+ const payload = normalizeProofAssessmentStageFields(assessment.payload);
6556
6576
  recordEvent(state, {
6557
6577
  kind: "agent.proof_assessment.completed",
6558
6578
  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';
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  proof_run_engine_exports
3
- } from "../chunk-IOI6QR3B.js";
3
+ } from "../chunk-VYJD6XYF.js";
4
4
  import {
5
5
  runner_exports
6
- } from "../chunk-UKGDVNGI.js";
6
+ } from "../chunk-2CZORYB7.js";
7
7
  import {
8
8
  engine_harness_exports
9
- } from "../chunk-2KEYWZY5.js";
10
- import "../chunk-EMWF2575.js";
11
- import "../chunk-L7U7QZYH.js";
9
+ } from "../chunk-WURLFN72.js";
10
+ import "../chunk-M3IE3VNC.js";
11
+ import "../chunk-RBAU2M4S.js";
12
12
  import {
13
13
  proof_run_core_exports
14
- } from "../chunk-X7SQTCIQ.js";
15
- import "../chunk-U46KE6JZ.js";
14
+ } from "../chunk-EKZXU6MU.js";
15
+ import "../chunk-AXWJJ2LC.js";
16
16
  import "../chunk-VY4Y5U57.js";
17
17
  import "../chunk-MLKGABMK.js";
18
18
  export {
@@ -36,6 +36,7 @@ __export(proof_run_core_exports, {
36
36
  WORKFLOW_STAGE_ORDER: () => WORKFLOW_STAGE_ORDER,
37
37
  buildCheckpointContract: () => buildCheckpointContract,
38
38
  buildSetupArgs: () => buildSetupArgs,
39
+ canonicalProofAssessmentStageForDecision: () => canonicalProofAssessmentStageForDecision,
39
40
  checkpointContinueStage: () => checkpointContinueStage,
40
41
  clearStageDecisionRequest: () => clearStageDecisionRequest,
41
42
  ensureAction: () => ensureAction,
@@ -43,6 +44,7 @@ __export(proof_run_core_exports, {
43
44
  invalidateVerifyEvidence: () => invalidateVerifyEvidence,
44
45
  mergeStateFromParams: () => mergeStateFromParams,
45
46
  noImplementationModeFor: () => noImplementationModeFor,
47
+ normalizeProofAssessmentStageFields: () => normalizeProofAssessmentStageFields,
46
48
  previewModeFromWorkflowMode: () => previewModeFromWorkflowMode,
47
49
  proofAssessmentHardBlockersForState: () => proofAssessmentHardBlockersForState,
48
50
  readState: () => readState,
@@ -68,6 +70,24 @@ var import_node_path = __toESM(require("path"), 1);
68
70
  var import_node_url = require("url");
69
71
  var import_meta = {};
70
72
  var WORKFLOW_STAGE_ORDER = ["setup", "recon", "author", "implement", "verify", "ship"];
73
+ function canonicalProofAssessmentStageForDecision(decision) {
74
+ const normalized = typeof decision === "string" ? decision.trim() : "";
75
+ if (normalized === "ready_to_ship") return "ship";
76
+ if (normalized === "needs_richer_proof") return "author";
77
+ if (normalized === "revise_capture") return "verify";
78
+ if (normalized === "needs_recon") return "recon";
79
+ if (normalized === "needs_implementation") return "implement";
80
+ return null;
81
+ }
82
+ function normalizeProofAssessmentStageFields(assessment) {
83
+ const canonicalStage = canonicalProofAssessmentStageForDecision(assessment.decision);
84
+ if (!canonicalStage) return assessment;
85
+ return {
86
+ ...assessment,
87
+ recommended_stage: canonicalStage,
88
+ continue_with_stage: canonicalStage
89
+ };
90
+ }
71
91
  function normalizedMode(value) {
72
92
  return typeof value === "string" ? value.trim().toLowerCase() : "";
73
93
  }
@@ -1094,10 +1114,10 @@ function mergeStateFromParams(statePath, params) {
1094
1114
  state.proof_assessment_source = null;
1095
1115
  } else {
1096
1116
  const parsed = JSON.parse(raw);
1097
- const assessment = {
1117
+ const assessment = normalizeProofAssessmentStageFields({
1098
1118
  ...parsed,
1099
1119
  source: (parsed?.source || "supervising_agent").toString()
1100
- };
1120
+ });
1101
1121
  const readyBlocker = assessment?.decision === "ready_to_ship" ? visualDeltaShipGateReason({ ...state, proof_assessment: assessment, proof_assessment_source: assessment.source }) : null;
1102
1122
  if (readyBlocker) {
1103
1123
  assessment.blocked_decision = assessment.decision;
@@ -1267,6 +1287,7 @@ function summarizeState(state) {
1267
1287
  WORKFLOW_STAGE_ORDER,
1268
1288
  buildCheckpointContract,
1269
1289
  buildSetupArgs,
1290
+ canonicalProofAssessmentStageForDecision,
1270
1291
  checkpointContinueStage,
1271
1292
  clearStageDecisionRequest,
1272
1293
  ensureAction,
@@ -1274,6 +1295,7 @@ function summarizeState(state) {
1274
1295
  invalidateVerifyEvidence,
1275
1296
  mergeStateFromParams,
1276
1297
  noImplementationModeFor,
1298
+ normalizeProofAssessmentStageFields,
1277
1299
  previewModeFromWorkflowMode,
1278
1300
  proofAssessmentHardBlockersForState,
1279
1301
  readState,
@@ -1 +1 @@
1
- export { B as BUNDLED_RIDDLE_PROOF_DIR, C as CHECKPOINT_CONTRACT_VERSION, b as CheckpointInputContract, P as PluginConfig, R as RIDDLE_PROOF_DIR_CANDIDATES, S as ShipGateValidation, c as WORKFLOW_STAGE_ORDER, d as WorkflowAction, W as WorkflowParams, a as WorkflowStage, e as buildCheckpointContract, f as buildSetupArgs, g as checkpointContinueStage, h as clearStageDecisionRequest, i as ensureAction, j as ensureStageLoopState, k as invalidateVerifyEvidence, m as mergeStateFromParams, n as noImplementationModeFor, l as previewModeFromWorkflowMode, o as proofAssessmentHardBlockersForState, q as readState, s as recordStageAttempt, t as requiredBaselineLabelsForState, r as resolveConfig, u as resolveRiddleProofDir, v as setStageDecisionRequest, w as summarizeState, x as validateShipGate, y as visualDeltaForState, z as visualDeltaRequiredForState, A as visualDeltaShipGateReason, D as workflowFile, E as writeState } from '../proof-run-core-B1GeqkR8.cjs';
1
+ export { B as BUNDLED_RIDDLE_PROOF_DIR, C as CHECKPOINT_CONTRACT_VERSION, b as CheckpointInputContract, P as PluginConfig, R as RIDDLE_PROOF_DIR_CANDIDATES, S as ShipGateValidation, c as WORKFLOW_STAGE_ORDER, d as WorkflowAction, W as WorkflowParams, a as WorkflowStage, e as buildCheckpointContract, f as buildSetupArgs, g as canonicalProofAssessmentStageForDecision, h as checkpointContinueStage, i as clearStageDecisionRequest, j as ensureAction, k as ensureStageLoopState, l as invalidateVerifyEvidence, m as mergeStateFromParams, n as noImplementationModeFor, o as normalizeProofAssessmentStageFields, q as previewModeFromWorkflowMode, s as proofAssessmentHardBlockersForState, t as readState, u as recordStageAttempt, v as requiredBaselineLabelsForState, r as resolveConfig, w as resolveRiddleProofDir, x as setStageDecisionRequest, y as summarizeState, z as validateShipGate, A as visualDeltaForState, D as visualDeltaRequiredForState, E as visualDeltaShipGateReason, F as workflowFile, G as writeState } from '../proof-run-core-7Dqm7RKM.cjs';
@@ -1 +1 @@
1
- export { B as BUNDLED_RIDDLE_PROOF_DIR, C as CHECKPOINT_CONTRACT_VERSION, b as CheckpointInputContract, P as PluginConfig, R as RIDDLE_PROOF_DIR_CANDIDATES, S as ShipGateValidation, c as WORKFLOW_STAGE_ORDER, d as WorkflowAction, W as WorkflowParams, a as WorkflowStage, e as buildCheckpointContract, f as buildSetupArgs, g as checkpointContinueStage, h as clearStageDecisionRequest, i as ensureAction, j as ensureStageLoopState, k as invalidateVerifyEvidence, m as mergeStateFromParams, n as noImplementationModeFor, l as previewModeFromWorkflowMode, o as proofAssessmentHardBlockersForState, q as readState, s as recordStageAttempt, t as requiredBaselineLabelsForState, r as resolveConfig, u as resolveRiddleProofDir, v as setStageDecisionRequest, w as summarizeState, x as validateShipGate, y as visualDeltaForState, z as visualDeltaRequiredForState, A as visualDeltaShipGateReason, D as workflowFile, E as writeState } from '../proof-run-core-B1GeqkR8.js';
1
+ export { B as BUNDLED_RIDDLE_PROOF_DIR, C as CHECKPOINT_CONTRACT_VERSION, b as CheckpointInputContract, P as PluginConfig, R as RIDDLE_PROOF_DIR_CANDIDATES, S as ShipGateValidation, c as WORKFLOW_STAGE_ORDER, d as WorkflowAction, W as WorkflowParams, a as WorkflowStage, e as buildCheckpointContract, f as buildSetupArgs, g as canonicalProofAssessmentStageForDecision, h as checkpointContinueStage, i as clearStageDecisionRequest, j as ensureAction, k as ensureStageLoopState, l as invalidateVerifyEvidence, m as mergeStateFromParams, n as noImplementationModeFor, o as normalizeProofAssessmentStageFields, q as previewModeFromWorkflowMode, s as proofAssessmentHardBlockersForState, t as readState, u as recordStageAttempt, v as requiredBaselineLabelsForState, r as resolveConfig, w as resolveRiddleProofDir, x as setStageDecisionRequest, y as summarizeState, z as validateShipGate, A as visualDeltaForState, D as visualDeltaRequiredForState, E as visualDeltaShipGateReason, F as workflowFile, G as writeState } from '../proof-run-core-7Dqm7RKM.js';
@@ -5,6 +5,7 @@ import {
5
5
  WORKFLOW_STAGE_ORDER,
6
6
  buildCheckpointContract,
7
7
  buildSetupArgs,
8
+ canonicalProofAssessmentStageForDecision,
8
9
  checkpointContinueStage,
9
10
  clearStageDecisionRequest,
10
11
  ensureAction,
@@ -12,6 +13,7 @@ import {
12
13
  invalidateVerifyEvidence,
13
14
  mergeStateFromParams,
14
15
  noImplementationModeFor,
16
+ normalizeProofAssessmentStageFields,
15
17
  previewModeFromWorkflowMode,
16
18
  proofAssessmentHardBlockersForState,
17
19
  readState,
@@ -27,7 +29,7 @@ import {
27
29
  visualDeltaShipGateReason,
28
30
  workflowFile,
29
31
  writeState
30
- } from "../chunk-X7SQTCIQ.js";
32
+ } from "../chunk-EKZXU6MU.js";
31
33
  import "../chunk-MLKGABMK.js";
32
34
  export {
33
35
  BUNDLED_RIDDLE_PROOF_DIR,
@@ -36,6 +38,7 @@ export {
36
38
  WORKFLOW_STAGE_ORDER,
37
39
  buildCheckpointContract,
38
40
  buildSetupArgs,
41
+ canonicalProofAssessmentStageForDecision,
39
42
  checkpointContinueStage,
40
43
  clearStageDecisionRequest,
41
44
  ensureAction,
@@ -43,6 +46,7 @@ export {
43
46
  invalidateVerifyEvidence,
44
47
  mergeStateFromParams,
45
48
  noImplementationModeFor,
49
+ normalizeProofAssessmentStageFields,
46
50
  previewModeFromWorkflowMode,
47
51
  proofAssessmentHardBlockersForState,
48
52
  readState,
@@ -47,6 +47,24 @@ var import_node_path = __toESM(require("path"), 1);
47
47
  var import_node_url = require("url");
48
48
  var import_meta = {};
49
49
  var WORKFLOW_STAGE_ORDER = ["setup", "recon", "author", "implement", "verify", "ship"];
50
+ function canonicalProofAssessmentStageForDecision(decision) {
51
+ const normalized = typeof decision === "string" ? decision.trim() : "";
52
+ if (normalized === "ready_to_ship") return "ship";
53
+ if (normalized === "needs_richer_proof") return "author";
54
+ if (normalized === "revise_capture") return "verify";
55
+ if (normalized === "needs_recon") return "recon";
56
+ if (normalized === "needs_implementation") return "implement";
57
+ return null;
58
+ }
59
+ function normalizeProofAssessmentStageFields(assessment) {
60
+ const canonicalStage = canonicalProofAssessmentStageForDecision(assessment.decision);
61
+ if (!canonicalStage) return assessment;
62
+ return {
63
+ ...assessment,
64
+ recommended_stage: canonicalStage,
65
+ continue_with_stage: canonicalStage
66
+ };
67
+ }
50
68
  function normalizedMode(value) {
51
69
  return typeof value === "string" ? value.trim().toLowerCase() : "";
52
70
  }
@@ -1073,10 +1091,10 @@ function mergeStateFromParams(statePath, params) {
1073
1091
  state.proof_assessment_source = null;
1074
1092
  } else {
1075
1093
  const parsed = JSON.parse(raw);
1076
- const assessment = {
1094
+ const assessment = normalizeProofAssessmentStageFields({
1077
1095
  ...parsed,
1078
1096
  source: (parsed?.source || "supervising_agent").toString()
1079
- };
1097
+ });
1080
1098
  const readyBlocker = assessment?.decision === "ready_to_ship" ? visualDeltaShipGateReason({ ...state, proof_assessment: assessment, proof_assessment_source: assessment.source }) : null;
1081
1099
  if (readyBlocker) {
1082
1100
  assessment.blocked_decision = assessment.decision;
@@ -1,2 +1,2 @@
1
- export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-4dM37pEx.cjs';
2
- import '../proof-run-core-B1GeqkR8.cjs';
1
+ export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-DpChFR5H.cjs';
2
+ import '../proof-run-core-7Dqm7RKM.cjs';
@@ -1,2 +1,2 @@
1
- export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-BqaeqAze.js';
2
- import '../proof-run-core-B1GeqkR8.js';
1
+ export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from '../proof-run-engine-BqRoA3Do.js';
2
+ import '../proof-run-core-7Dqm7RKM.js';
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createRiddleProofEngine,
3
3
  executeWorkflow
4
- } from "../chunk-IOI6QR3B.js";
5
- import "../chunk-X7SQTCIQ.js";
4
+ } from "../chunk-VYJD6XYF.js";
5
+ import "../chunk-EKZXU6MU.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
  export {
8
8
  createRiddleProofEngine,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "../chunk-UKGDVNGI.js";
4
- import "../chunk-EMWF2575.js";
5
- import "../chunk-L7U7QZYH.js";
6
- import "../chunk-X7SQTCIQ.js";
7
- import "../chunk-U46KE6JZ.js";
3
+ } from "../chunk-2CZORYB7.js";
4
+ import "../chunk-M3IE3VNC.js";
5
+ import "../chunk-RBAU2M4S.js";
6
+ import "../chunk-EKZXU6MU.js";
7
+ import "../chunk-AXWJJ2LC.js";
8
8
  import "../chunk-VY4Y5U57.js";
9
9
  import "../chunk-MLKGABMK.js";
10
10
  export {
@@ -718,13 +718,25 @@ function createCheckpointResponseTemplate(packet, input = {}) {
718
718
  created_at: input.created_at || timestamp()
719
719
  });
720
720
  }
721
+ function acceptedCheckpointResponseEntries(state) {
722
+ const history = state.checkpoint_history || [];
723
+ const events = state.events || [];
724
+ const acceptedResponseEvents = events.filter((event) => event.kind === "checkpoint.response.accepted");
725
+ const hasCheckpointResponseEvents = events.some((event) => nonEmptyString(event.kind)?.startsWith("checkpoint.response."));
726
+ return history.filter((entry) => {
727
+ if (!entry.response) return false;
728
+ if (!hasCheckpointResponseEvents) return true;
729
+ return acceptedResponseEvents.some((event) => event.ts === entry.ts && (!event.checkpoint || event.checkpoint === entry.response?.checkpoint));
730
+ });
731
+ }
721
732
  function checkpointSummaryFromState(state, engineStatePath) {
722
733
  const history = state.checkpoint_history || [];
734
+ const events = state.events || [];
723
735
  const packets = history.filter((entry) => entry.packet);
724
- const responses = history.filter((entry) => entry.response);
725
- const duplicateResponses = (state.events || []).filter((event) => event.kind === "checkpoint.response.duplicate");
736
+ const responses = acceptedCheckpointResponseEntries(state);
737
+ const duplicateResponses = events.filter((event) => event.kind === "checkpoint.response.duplicate");
726
738
  const latestPacketEntry = [...history].reverse().find((entry) => entry.packet);
727
- const latestResponseEntry = [...history].reverse().find((entry) => entry.response);
739
+ const latestResponseEntry = [...responses].reverse().find((entry) => entry.response);
728
740
  const latestPacket = state.checkpoint_packet || latestPacketEntry?.packet;
729
741
  const latestResponse = latestResponseEntry?.response;
730
742
  const latestResumeToken = latestPacket?.resume_token || null;
@@ -751,7 +763,7 @@ function checkpointSummaryFromState(state, engineStatePath) {
751
763
  }
752
764
  function isDuplicateCheckpointResponse(state, response) {
753
765
  const identity = checkpointResponseIdentity(response);
754
- return (state.checkpoint_history || []).some((entry) => entry.response ? checkpointResponseIdentity(entry.response) === identity : false);
766
+ return acceptedCheckpointResponseEntries(state).some((entry) => entry.response ? checkpointResponseIdentity(entry.response) === identity : false);
755
767
  }
756
768
  function checkpointResponseIdentity(response) {
757
769
  const logicalResponse = compactRecord({
@@ -13,7 +13,7 @@ import {
13
13
  normalizeCheckpointResponse,
14
14
  proofContractFromAuthorCheckpointResponse,
15
15
  statePathsForRunState
16
- } from "./chunk-U46KE6JZ.js";
16
+ } from "./chunk-AXWJJ2LC.js";
17
17
  import "./chunk-VY4Y5U57.js";
18
18
  import "./chunk-MLKGABMK.js";
19
19
  export {
@@ -3,10 +3,10 @@ import {
3
3
  appendStageHeartbeat,
4
4
  createRunState,
5
5
  setRunStatus
6
- } from "./chunk-EMWF2575.js";
6
+ } from "./chunk-M3IE3VNC.js";
7
7
  import {
8
8
  noImplementationModeFor
9
- } from "./chunk-X7SQTCIQ.js";
9
+ } from "./chunk-EKZXU6MU.js";
10
10
  import {
11
11
  createRunResult
12
12
  } from "./chunk-VY4Y5U57.js";