@riddledc/riddle-proof 0.5.23 → 0.5.24

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.
@@ -89,8 +89,20 @@ function loadRunState(input) {
89
89
  state_path: statePath
90
90
  });
91
91
  }
92
+ function isProtectedFinalStatus(status) {
93
+ return status === "ready_to_ship" || status === "shipped" || status === "completed";
94
+ }
95
+ function shouldPreserveFinalizedRunState(filePath, incoming) {
96
+ const existing = readJson(filePath);
97
+ if (!existing?.finalized || !isProtectedFinalStatus(existing.status)) return false;
98
+ if (!incoming.finalized) return true;
99
+ if (existing.status === incoming.status) return false;
100
+ return !(existing.status === "ready_to_ship" && incoming.status === "shipped");
101
+ }
92
102
  function persist(state) {
93
- if (state.state_path) writeJson(state.state_path, state);
103
+ if (!state.state_path) return;
104
+ if (shouldPreserveFinalizedRunState(state.state_path, state)) return;
105
+ writeJson(state.state_path, state);
94
106
  }
95
107
  function recordEvent(state, event) {
96
108
  appendRunEvent(state, event);
@@ -325,6 +337,7 @@ function engineFailureBlocker(result, checkpoint) {
325
337
  }
326
338
  function terminalResult(state, status, result, summary, raw = {}) {
327
339
  setRunStatus(state, status);
340
+ if (isProtectedFinalStatus(status)) state.finalized = true;
328
341
  const metadata = normalizeTerminalMetadata({
329
342
  riddleState: result ? fullRiddleState(result, state) : null,
330
343
  engineResult: result
@@ -3091,8 +3091,20 @@ function loadRunState(input) {
3091
3091
  state_path: statePath
3092
3092
  });
3093
3093
  }
3094
+ function isProtectedFinalStatus(status) {
3095
+ return status === "ready_to_ship" || status === "shipped" || status === "completed";
3096
+ }
3097
+ function shouldPreserveFinalizedRunState(filePath, incoming) {
3098
+ const existing = readJson(filePath);
3099
+ if (!existing?.finalized || !isProtectedFinalStatus(existing.status)) return false;
3100
+ if (!incoming.finalized) return true;
3101
+ if (existing.status === incoming.status) return false;
3102
+ return !(existing.status === "ready_to_ship" && incoming.status === "shipped");
3103
+ }
3094
3104
  function persist(state) {
3095
- if (state.state_path) writeJson(state.state_path, state);
3105
+ if (!state.state_path) return;
3106
+ if (shouldPreserveFinalizedRunState(state.state_path, state)) return;
3107
+ writeJson(state.state_path, state);
3096
3108
  }
3097
3109
  function recordEvent(state, event) {
3098
3110
  appendRunEvent(state, event);
@@ -3327,6 +3339,7 @@ function engineFailureBlocker(result, checkpoint) {
3327
3339
  }
3328
3340
  function terminalResult(state, status, result, summary, raw = {}) {
3329
3341
  setRunStatus(state, status);
3342
+ if (isProtectedFinalStatus(status)) state.finalized = true;
3330
3343
  const metadata = normalizeTerminalMetadata({
3331
3344
  riddleState: result ? fullRiddleState(result, state) : null,
3332
3345
  engineResult: result
@@ -2,7 +2,7 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-M4MISBQV.js";
5
+ } from "./chunk-46355FJD.js";
6
6
  import "./chunk-7ZJAUEUN.js";
7
7
  import "./chunk-TMMKRKY5.js";
8
8
  export {
package/dist/index.cjs CHANGED
@@ -3647,8 +3647,20 @@ function loadRunState(input) {
3647
3647
  state_path: statePath
3648
3648
  });
3649
3649
  }
3650
+ function isProtectedFinalStatus(status) {
3651
+ return status === "ready_to_ship" || status === "shipped" || status === "completed";
3652
+ }
3653
+ function shouldPreserveFinalizedRunState(filePath, incoming) {
3654
+ const existing = readJson(filePath);
3655
+ if (!existing?.finalized || !isProtectedFinalStatus(existing.status)) return false;
3656
+ if (!incoming.finalized) return true;
3657
+ if (existing.status === incoming.status) return false;
3658
+ return !(existing.status === "ready_to_ship" && incoming.status === "shipped");
3659
+ }
3650
3660
  function persist(state) {
3651
- if (state.state_path) writeJson(state.state_path, state);
3661
+ if (!state.state_path) return;
3662
+ if (shouldPreserveFinalizedRunState(state.state_path, state)) return;
3663
+ writeJson(state.state_path, state);
3652
3664
  }
3653
3665
  function recordEvent(state, event) {
3654
3666
  appendRunEvent(state, event);
@@ -3883,6 +3895,7 @@ function engineFailureBlocker(result, checkpoint) {
3883
3895
  }
3884
3896
  function terminalResult(state, status, result, summary, raw = {}) {
3885
3897
  setRunStatus(state, status);
3898
+ if (isProtectedFinalStatus(status)) state.finalized = true;
3886
3899
  const metadata = normalizeTerminalMetadata({
3887
3900
  riddleState: result ? fullRiddleState(result, state) : null,
3888
3901
  engineResult: result
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  createDisabledRiddleProofAgentAdapter,
14
14
  readRiddleProofRunStatus,
15
15
  runRiddleProofEngineHarness
16
- } from "./chunk-M4MISBQV.js";
16
+ } from "./chunk-46355FJD.js";
17
17
  import {
18
18
  runRiddleProof
19
19
  } from "./chunk-F6VFKS7K.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.5.23",
3
+ "version": "0.5.24",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",