@paraharness/sqlite 0.0.0-stage → 0.2.0

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 (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -2
  3. package/dist/builders/compaction-config-builder.d.ts +66 -0
  4. package/dist/builders/compaction-config-builder.d.ts.map +1 -0
  5. package/dist/builders/compaction-config-builder.js +2 -0
  6. package/dist/builders/compaction-config-builder.js.map +1 -0
  7. package/dist/builders/create-compaction-config-builder.d.ts +14 -0
  8. package/dist/builders/create-compaction-config-builder.d.ts.map +1 -0
  9. package/dist/builders/create-compaction-config-builder.js +66 -0
  10. package/dist/builders/create-compaction-config-builder.js.map +1 -0
  11. package/dist/builders/create-sqlite-global-rules-builder.d.ts +15 -0
  12. package/dist/builders/create-sqlite-global-rules-builder.d.ts.map +1 -0
  13. package/dist/builders/create-sqlite-global-rules-builder.js +30 -0
  14. package/dist/builders/create-sqlite-global-rules-builder.js.map +1 -0
  15. package/dist/builders/create-sqlite-ledger-builder.d.ts +15 -0
  16. package/dist/builders/create-sqlite-ledger-builder.d.ts.map +1 -0
  17. package/dist/builders/create-sqlite-ledger-builder.js +31 -0
  18. package/dist/builders/create-sqlite-ledger-builder.js.map +1 -0
  19. package/dist/builders/create-sqlite-lessons-builder.d.ts +12 -0
  20. package/dist/builders/create-sqlite-lessons-builder.d.ts.map +1 -0
  21. package/dist/builders/create-sqlite-lessons-builder.js +23 -0
  22. package/dist/builders/create-sqlite-lessons-builder.js.map +1 -0
  23. package/dist/builders/create-sqlite-topology-builder.d.ts +12 -0
  24. package/dist/builders/create-sqlite-topology-builder.d.ts.map +1 -0
  25. package/dist/builders/create-sqlite-topology-builder.js +23 -0
  26. package/dist/builders/create-sqlite-topology-builder.js.map +1 -0
  27. package/dist/builders/internal/compaction-config-builder-state.d.ts +16 -0
  28. package/dist/builders/internal/compaction-config-builder-state.d.ts.map +1 -0
  29. package/dist/builders/internal/compaction-config-builder-state.js +2 -0
  30. package/dist/builders/internal/compaction-config-builder-state.js.map +1 -0
  31. package/dist/builders/sqlite-global-rules-builder.d.ts +17 -0
  32. package/dist/builders/sqlite-global-rules-builder.d.ts.map +1 -0
  33. package/dist/builders/sqlite-global-rules-builder.js +2 -0
  34. package/dist/builders/sqlite-global-rules-builder.js.map +1 -0
  35. package/dist/builders/sqlite-ledger-builder.d.ts +21 -0
  36. package/dist/builders/sqlite-ledger-builder.d.ts.map +1 -0
  37. package/dist/builders/sqlite-ledger-builder.js +2 -0
  38. package/dist/builders/sqlite-ledger-builder.js.map +1 -0
  39. package/dist/builders/sqlite-lessons-builder.d.ts +18 -0
  40. package/dist/builders/sqlite-lessons-builder.d.ts.map +1 -0
  41. package/dist/builders/sqlite-lessons-builder.js +2 -0
  42. package/dist/builders/sqlite-lessons-builder.js.map +1 -0
  43. package/dist/builders/sqlite-namespace-contract.d.ts +64 -0
  44. package/dist/builders/sqlite-namespace-contract.d.ts.map +1 -0
  45. package/dist/builders/sqlite-namespace-contract.js +2 -0
  46. package/dist/builders/sqlite-namespace-contract.js.map +1 -0
  47. package/dist/builders/sqlite-namespace.d.ts +9 -0
  48. package/dist/builders/sqlite-namespace.d.ts.map +1 -0
  49. package/dist/builders/sqlite-namespace.js +17 -0
  50. package/dist/builders/sqlite-namespace.js.map +1 -0
  51. package/dist/builders/sqlite-topology-builder.d.ts +18 -0
  52. package/dist/builders/sqlite-topology-builder.d.ts.map +1 -0
  53. package/dist/builders/sqlite-topology-builder.js +2 -0
  54. package/dist/builders/sqlite-topology-builder.js.map +1 -0
  55. package/dist/ddl/internal/open-sqlite-connection.d.ts +24 -0
  56. package/dist/ddl/internal/open-sqlite-connection.d.ts.map +1 -0
  57. package/dist/ddl/internal/open-sqlite-connection.js +65 -0
  58. package/dist/ddl/internal/open-sqlite-connection.js.map +1 -0
  59. package/dist/ddl/sqlite-schema.constants.d.ts +21 -0
  60. package/dist/ddl/sqlite-schema.constants.d.ts.map +1 -0
  61. package/dist/ddl/sqlite-schema.constants.js +134 -0
  62. package/dist/ddl/sqlite-schema.constants.js.map +1 -0
  63. package/dist/executors/create-sqlite-executors.d.ts +11 -0
  64. package/dist/executors/create-sqlite-executors.d.ts.map +1 -0
  65. package/dist/executors/create-sqlite-executors.js +38 -0
  66. package/dist/executors/create-sqlite-executors.js.map +1 -0
  67. package/dist/executors/sqlite-executors.constants.d.ts +9 -0
  68. package/dist/executors/sqlite-executors.constants.d.ts.map +1 -0
  69. package/dist/executors/sqlite-executors.constants.js +9 -0
  70. package/dist/executors/sqlite-executors.constants.js.map +1 -0
  71. package/dist/executors/sqlite-rules-source-executor.d.ts +15 -0
  72. package/dist/executors/sqlite-rules-source-executor.d.ts.map +1 -0
  73. package/dist/executors/sqlite-rules-source-executor.js +47 -0
  74. package/dist/executors/sqlite-rules-source-executor.js.map +1 -0
  75. package/dist/index.d.ts +23 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +16 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/stores/internal/admit-lesson-params.d.ts +16 -0
  80. package/dist/stores/internal/admit-lesson-params.d.ts.map +1 -0
  81. package/dist/stores/internal/admit-lesson-params.js +2 -0
  82. package/dist/stores/internal/admit-lesson-params.js.map +1 -0
  83. package/dist/stores/internal/compute-normalized-relevance.d.ts +47 -0
  84. package/dist/stores/internal/compute-normalized-relevance.d.ts.map +1 -0
  85. package/dist/stores/internal/compute-normalized-relevance.js +63 -0
  86. package/dist/stores/internal/compute-normalized-relevance.js.map +1 -0
  87. package/dist/stores/internal/mark-frame-tombstone-params.d.ts +16 -0
  88. package/dist/stores/internal/mark-frame-tombstone-params.d.ts.map +1 -0
  89. package/dist/stores/internal/mark-frame-tombstone-params.js +2 -0
  90. package/dist/stores/internal/mark-frame-tombstone-params.js.map +1 -0
  91. package/dist/stores/internal/record-terminal-receipt-params.d.ts +16 -0
  92. package/dist/stores/internal/record-terminal-receipt-params.d.ts.map +1 -0
  93. package/dist/stores/internal/record-terminal-receipt-params.js +2 -0
  94. package/dist/stores/internal/record-terminal-receipt-params.js.map +1 -0
  95. package/dist/stores/internal/sqlite-ledger-compaction-ops.d.ts +14 -0
  96. package/dist/stores/internal/sqlite-ledger-compaction-ops.d.ts.map +1 -0
  97. package/dist/stores/internal/sqlite-ledger-compaction-ops.js +29 -0
  98. package/dist/stores/internal/sqlite-ledger-compaction-ops.js.map +1 -0
  99. package/dist/stores/internal/sqlite-ledger-fork-operations.d.ts +33 -0
  100. package/dist/stores/internal/sqlite-ledger-fork-operations.d.ts.map +1 -0
  101. package/dist/stores/internal/sqlite-ledger-fork-operations.js +44 -0
  102. package/dist/stores/internal/sqlite-ledger-fork-operations.js.map +1 -0
  103. package/dist/stores/internal/sqlite-ledger-frame-operations.d.ts +24 -0
  104. package/dist/stores/internal/sqlite-ledger-frame-operations.d.ts.map +1 -0
  105. package/dist/stores/internal/sqlite-ledger-frame-operations.js +40 -0
  106. package/dist/stores/internal/sqlite-ledger-frame-operations.js.map +1 -0
  107. package/dist/stores/internal/sqlite-ledger-frame-ops.d.ts +50 -0
  108. package/dist/stores/internal/sqlite-ledger-frame-ops.d.ts.map +1 -0
  109. package/dist/stores/internal/sqlite-ledger-frame-ops.js +90 -0
  110. package/dist/stores/internal/sqlite-ledger-frame-ops.js.map +1 -0
  111. package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.d.ts +59 -0
  112. package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.d.ts.map +1 -0
  113. package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.js +90 -0
  114. package/dist/stores/internal/sqlite-ledger-plan-and-fork-ops.js.map +1 -0
  115. package/dist/stores/internal/sqlite-ledger-plan-operations.d.ts +40 -0
  116. package/dist/stores/internal/sqlite-ledger-plan-operations.d.ts.map +1 -0
  117. package/dist/stores/internal/sqlite-ledger-plan-operations.js +39 -0
  118. package/dist/stores/internal/sqlite-ledger-plan-operations.js.map +1 -0
  119. package/dist/stores/internal/sqlite-ledger-run-operations.d.ts +41 -0
  120. package/dist/stores/internal/sqlite-ledger-run-operations.d.ts.map +1 -0
  121. package/dist/stores/internal/sqlite-ledger-run-operations.js +89 -0
  122. package/dist/stores/internal/sqlite-ledger-run-operations.js.map +1 -0
  123. package/dist/stores/internal/sqlite-ledger-run-ops.d.ts +58 -0
  124. package/dist/stores/internal/sqlite-ledger-run-ops.d.ts.map +1 -0
  125. package/dist/stores/internal/sqlite-ledger-run-ops.js +80 -0
  126. package/dist/stores/internal/sqlite-ledger-run-ops.js.map +1 -0
  127. package/dist/stores/internal/sqlite-ledger-step-operations.d.ts +28 -0
  128. package/dist/stores/internal/sqlite-ledger-step-operations.d.ts.map +1 -0
  129. package/dist/stores/internal/sqlite-ledger-step-operations.js +53 -0
  130. package/dist/stores/internal/sqlite-ledger-step-operations.js.map +1 -0
  131. package/dist/stores/internal/sqlite-ledger-step-ops.d.ts +47 -0
  132. package/dist/stores/internal/sqlite-ledger-step-ops.d.ts.map +1 -0
  133. package/dist/stores/internal/sqlite-ledger-step-ops.js +89 -0
  134. package/dist/stores/internal/sqlite-ledger-step-ops.js.map +1 -0
  135. package/dist/stores/internal/sqlite-lesson-ops.d.ts +100 -0
  136. package/dist/stores/internal/sqlite-lesson-ops.d.ts.map +1 -0
  137. package/dist/stores/internal/sqlite-lesson-ops.js +178 -0
  138. package/dist/stores/internal/sqlite-lesson-ops.js.map +1 -0
  139. package/dist/stores/internal/sqlite-lesson-row.d.ts +28 -0
  140. package/dist/stores/internal/sqlite-lesson-row.d.ts.map +1 -0
  141. package/dist/stores/internal/sqlite-lesson-row.js +2 -0
  142. package/dist/stores/internal/sqlite-lesson-row.js.map +1 -0
  143. package/dist/stores/internal/sqlite-overlay-step-mutation-entry.d.ts +21 -0
  144. package/dist/stores/internal/sqlite-overlay-step-mutation-entry.d.ts.map +1 -0
  145. package/dist/stores/internal/sqlite-overlay-step-mutation-entry.js +2 -0
  146. package/dist/stores/internal/sqlite-overlay-step-mutation-entry.js.map +1 -0
  147. package/dist/stores/internal/sqlite-run-row.d.ts +36 -0
  148. package/dist/stores/internal/sqlite-run-row.d.ts.map +1 -0
  149. package/dist/stores/internal/sqlite-run-row.js +2 -0
  150. package/dist/stores/internal/sqlite-run-row.js.map +1 -0
  151. package/dist/stores/internal/sqlite-step-row.d.ts +32 -0
  152. package/dist/stores/internal/sqlite-step-row.d.ts.map +1 -0
  153. package/dist/stores/internal/sqlite-step-row.js +2 -0
  154. package/dist/stores/internal/sqlite-step-row.js.map +1 -0
  155. package/dist/stores/internal/sqlite-suspended-fork-row.d.ts +22 -0
  156. package/dist/stores/internal/sqlite-suspended-fork-row.d.ts.map +1 -0
  157. package/dist/stores/internal/sqlite-suspended-fork-row.js +2 -0
  158. package/dist/stores/internal/sqlite-suspended-fork-row.js.map +1 -0
  159. package/dist/stores/internal/sqlite-topology-base-row.d.ts +18 -0
  160. package/dist/stores/internal/sqlite-topology-base-row.d.ts.map +1 -0
  161. package/dist/stores/internal/sqlite-topology-base-row.js +2 -0
  162. package/dist/stores/internal/sqlite-topology-base-row.js.map +1 -0
  163. package/dist/stores/internal/sqlite-topology-commit-ops.d.ts +37 -0
  164. package/dist/stores/internal/sqlite-topology-commit-ops.d.ts.map +1 -0
  165. package/dist/stores/internal/sqlite-topology-commit-ops.js +58 -0
  166. package/dist/stores/internal/sqlite-topology-commit-ops.js.map +1 -0
  167. package/dist/stores/internal/sqlite-topology-overlay-commit.d.ts +25 -0
  168. package/dist/stores/internal/sqlite-topology-overlay-commit.d.ts.map +1 -0
  169. package/dist/stores/internal/sqlite-topology-overlay-commit.js +51 -0
  170. package/dist/stores/internal/sqlite-topology-overlay-commit.js.map +1 -0
  171. package/dist/stores/internal/sqlite-topology-overlay-ops.d.ts +61 -0
  172. package/dist/stores/internal/sqlite-topology-overlay-ops.d.ts.map +1 -0
  173. package/dist/stores/internal/sqlite-topology-overlay-ops.js +156 -0
  174. package/dist/stores/internal/sqlite-topology-overlay-ops.js.map +1 -0
  175. package/dist/stores/internal/sqlite-topology-overlay-row.d.ts +40 -0
  176. package/dist/stores/internal/sqlite-topology-overlay-row.d.ts.map +1 -0
  177. package/dist/stores/internal/sqlite-topology-overlay-row.js +2 -0
  178. package/dist/stores/internal/sqlite-topology-overlay-row.js.map +1 -0
  179. package/dist/stores/internal/sqlite-topology-overlay-sync.d.ts +72 -0
  180. package/dist/stores/internal/sqlite-topology-overlay-sync.d.ts.map +1 -0
  181. package/dist/stores/internal/sqlite-topology-overlay-sync.js +116 -0
  182. package/dist/stores/internal/sqlite-topology-overlay-sync.js.map +1 -0
  183. package/dist/stores/internal/sqlite-wire-frame-row.d.ts +26 -0
  184. package/dist/stores/internal/sqlite-wire-frame-row.d.ts.map +1 -0
  185. package/dist/stores/internal/sqlite-wire-frame-row.js +2 -0
  186. package/dist/stores/internal/sqlite-wire-frame-row.js.map +1 -0
  187. package/dist/stores/internal/three-way-merge-contract.d.ts +25 -0
  188. package/dist/stores/internal/three-way-merge-contract.d.ts.map +1 -0
  189. package/dist/stores/internal/three-way-merge-contract.js +76 -0
  190. package/dist/stores/internal/three-way-merge-contract.js.map +1 -0
  191. package/dist/stores/internal/update-continuation-stack-params.d.ts +17 -0
  192. package/dist/stores/internal/update-continuation-stack-params.d.ts.map +1 -0
  193. package/dist/stores/internal/update-continuation-stack-params.js +2 -0
  194. package/dist/stores/internal/update-continuation-stack-params.js.map +1 -0
  195. package/dist/stores/internal/update-contract-in-overlay-params.d.ts +16 -0
  196. package/dist/stores/internal/update-contract-in-overlay-params.d.ts.map +1 -0
  197. package/dist/stores/internal/update-contract-in-overlay-params.js +2 -0
  198. package/dist/stores/internal/update-contract-in-overlay-params.js.map +1 -0
  199. package/dist/stores/internal/validate-lane-dag.d.ts +59 -0
  200. package/dist/stores/internal/validate-lane-dag.d.ts.map +1 -0
  201. package/dist/stores/internal/validate-lane-dag.js +117 -0
  202. package/dist/stores/internal/validate-lane-dag.js.map +1 -0
  203. package/dist/stores/sqlite-ledger-store.d.ts +222 -0
  204. package/dist/stores/sqlite-ledger-store.d.ts.map +1 -0
  205. package/dist/stores/sqlite-ledger-store.js +295 -0
  206. package/dist/stores/sqlite-ledger-store.js.map +1 -0
  207. package/dist/stores/sqlite-lesson-store.d.ts +96 -0
  208. package/dist/stores/sqlite-lesson-store.d.ts.map +1 -0
  209. package/dist/stores/sqlite-lesson-store.js +121 -0
  210. package/dist/stores/sqlite-lesson-store.js.map +1 -0
  211. package/dist/stores/sqlite-topology-store.d.ts +112 -0
  212. package/dist/stores/sqlite-topology-store.d.ts.map +1 -0
  213. package/dist/stores/sqlite-topology-store.js +137 -0
  214. package/dist/stores/sqlite-topology-store.js.map +1 -0
  215. package/package.json +70 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-ledger-step-operations.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-ledger-step-operations.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mCAAmC,CACjD,oBAA4B,EAC5B,gBAAwB;IAExB,IAAI,oBAAoB,KAAK,WAAW,EAAE,CAAC;QACzC,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kCAAkC,CAChD,MAAoB,EACpB,OAAkC;IAElC,MAAM,YAAY,GAChB,OAAO,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC;IAC5F,MAAM,KAAK,GAAiC,YAAY;QACtD,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAyB;QACtE,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAa,CAAC;IACjE,OAAO,MAAM,CAAC,MAAM,CAA4B;QAC9C,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,MAAM,EAAE,MAAM,CAAC,OAAO;QACtB,OAAO,EAAE,MAAM,CAAC,QAAQ;QACxB,SAAS,EAAE,MAAM,CAAC,UAAU;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAwD;QACvE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;QACtD,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;QAC7C,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7E,mBAAmB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;QAC5F,mBAAmB,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;QAC5F,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;KACxC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { InterruptedStepBootRecord, RecordStepStartInput, RecordStepTransitionInput } from '@paraharness/core';
2
+ import type Database from 'better-sqlite3';
3
+ import type { UpdateContinuationStackParams } from './update-continuation-stack-params.js';
4
+ /**
5
+ * Persists a step execution start record in `harness_step_executions` and updates `harness_runs`.
6
+ *
7
+ * Allocates a monotonic `seq_id` and records `baseScopeCheckpoint` and `continuationStack`.
8
+ *
9
+ * @param {Database.Database} db - Active SQLite database handle.
10
+ * @param {RecordStepStartInput} step - Step start metadata and initial continuation stack.
11
+ *
12
+ * @returns {void} Returns nothing once the step start is committed.
13
+ */
14
+ export declare function recordStepStartInSqlite(db: Database.Database, step: RecordStepStartInput): void;
15
+ /**
16
+ * Updates `continuation_stack_json` and optional `base_scope_checkpoint` for `stepExecId`.
17
+ *
18
+ * Preserves serialized call-stack state across turns, tool batches, and child forks.
19
+ *
20
+ * @param {Database.Database} db - Active SQLite database handle.
21
+ * @param {UpdateContinuationStackParams} params - Step continuation stack update parameters.
22
+ *
23
+ * @returns {void} Returns nothing once the continuation stack is updated.
24
+ */
25
+ export declare function updateContinuationStackInSqlite(db: Database.Database, params: UpdateContinuationStackParams): void;
26
+ /**
27
+ * Records a step lifecycle status transition and updates `completed_step_outputs_json` on completion.
28
+ *
29
+ * Synchronizes the parent run status when transitioning to `'SUSPENDED'` or `'RUNNING'`.
30
+ *
31
+ * @param {Database.Database} db - Active SQLite database handle.
32
+ * @param {RecordStepTransitionInput} transition - Step transition metadata and telemetry JSON.
33
+ *
34
+ * @returns {void} Returns nothing once the step transition is persisted.
35
+ */
36
+ export declare function recordStepTransitionInSqlite(db: Database.Database, transition: RecordStepTransitionInput): void;
37
+ /**
38
+ * Queries all non-terminal runs (`'QUEUED' | 'RUNNING' | 'WAITING' | 'SUSPENDED'`) on startup.
39
+ *
40
+ * Joins each active run with its latest active step execution to reconstruct `InterruptedStepBootRecord`s.
41
+ *
42
+ * @param {Database.Database} db - Active SQLite database handle.
43
+ *
44
+ * @returns {readonly InterruptedStepBootRecord[]} Non-terminal runs requiring crash recovery.
45
+ */
46
+ export declare function getInterruptedStepsOnBootFromSqlite(db: Database.Database): readonly InterruptedStepBootRecord[];
47
+ //# sourceMappingURL=sqlite-ledger-step-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-ledger-step-ops.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-ledger-step-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAO3C,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAE3F;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAmB/F;AAED;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,MAAM,EAAE,6BAA6B,GACpC,IAAI,CAWN;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,UAAU,EAAE,yBAAyB,GACpC,IAAI,CAmCN;AAED;;;;;;;;GAQG;AACH,wBAAgB,mCAAmC,CACjD,EAAE,EAAE,QAAQ,CAAC,QAAQ,GACpB,SAAS,yBAAyB,EAAE,CAetC"}
@@ -0,0 +1,89 @@
1
+ import { mapInterruptedBootRecordFromSqlite, resolveRunStatusAfterStepTransition, } from './sqlite-ledger-step-operations.js';
2
+ /**
3
+ * Persists a step execution start record in `harness_step_executions` and updates `harness_runs`.
4
+ *
5
+ * Allocates a monotonic `seq_id` and records `baseScopeCheckpoint` and `continuationStack`.
6
+ *
7
+ * @param {Database.Database} db - Active SQLite database handle.
8
+ * @param {RecordStepStartInput} step - Step start metadata and initial continuation stack.
9
+ *
10
+ * @returns {void} Returns nothing once the step start is committed.
11
+ */
12
+ export function recordStepStartInSqlite(db, step) {
13
+ const seqRow = db
14
+ .prepare('SELECT COALESCE(MAX(seq_id), 0) + 1 AS next_seq FROM harness_step_executions')
15
+ .get();
16
+ db.prepare("INSERT OR REPLACE INTO harness_step_executions (step_exec_id, run_id, step_id, executable_id, input_msg_id, status, output_json, base_scope_checkpoint, head_scope_checkpoint, continuation_stack_json, telemetry_json, seq_id) VALUES (?, ?, ?, ?, ?, 'RUNNING', NULL, ?, NULL, ?, NULL, ?)").run(step.stepExecId, step.runId, step.stepId, step.executableId ?? null, step.inputMsgId, step.baseScopeCheckpoint ?? null, JSON.stringify(step.continuationStack), seqRow.next_seq);
17
+ db.prepare("UPDATE harness_runs SET current_step_id = ?, status = 'RUNNING', updated_at = ? WHERE run_id = ?").run(step.stepId, new Date().toISOString(), step.runId);
18
+ }
19
+ /**
20
+ * Updates `continuation_stack_json` and optional `base_scope_checkpoint` for `stepExecId`.
21
+ *
22
+ * Preserves serialized call-stack state across turns, tool batches, and child forks.
23
+ *
24
+ * @param {Database.Database} db - Active SQLite database handle.
25
+ * @param {UpdateContinuationStackParams} params - Step continuation stack update parameters.
26
+ *
27
+ * @returns {void} Returns nothing once the continuation stack is updated.
28
+ */
29
+ export function updateContinuationStackInSqlite(db, params) {
30
+ const stackJson = JSON.stringify(params.continuationStack);
31
+ if (params.baseScopeCheckpoint !== undefined) {
32
+ db.prepare('UPDATE harness_step_executions SET continuation_stack_json = ?, base_scope_checkpoint = ? WHERE step_exec_id = ? AND run_id = ?').run(stackJson, params.baseScopeCheckpoint, params.stepExecId, params.runId);
33
+ return;
34
+ }
35
+ db.prepare('UPDATE harness_step_executions SET continuation_stack_json = ? WHERE step_exec_id = ? AND run_id = ?').run(stackJson, params.stepExecId, params.runId);
36
+ }
37
+ /**
38
+ * Records a step lifecycle status transition and updates `completed_step_outputs_json` on completion.
39
+ *
40
+ * Synchronizes the parent run status when transitioning to `'SUSPENDED'` or `'RUNNING'`.
41
+ *
42
+ * @param {Database.Database} db - Active SQLite database handle.
43
+ * @param {RecordStepTransitionInput} transition - Step transition metadata and telemetry JSON.
44
+ *
45
+ * @returns {void} Returns nothing once the step transition is persisted.
46
+ */
47
+ export function recordStepTransitionInSqlite(db, transition) {
48
+ const existing = db
49
+ .prepare('SELECT * FROM harness_step_executions WHERE step_exec_id = ?')
50
+ .get(transition.stepExecId);
51
+ if (existing === undefined) {
52
+ throw new Error(`Cannot transition unknown stepExecId '${transition.stepExecId}' in SQLite ledger.`);
53
+ }
54
+ db.prepare('UPDATE harness_step_executions SET status = ?, output_json = ?, base_scope_checkpoint = ?, head_scope_checkpoint = ?, telemetry_json = ? WHERE step_exec_id = ?').run(transition.status, transition.outputJson ?? existing.output_json, transition.baseScopeCheckpoint ?? existing.base_scope_checkpoint, transition.headScopeCheckpoint ?? existing.head_scope_checkpoint, transition.telemetryJson, transition.stepExecId);
55
+ const runRow = db
56
+ .prepare('SELECT completed_step_outputs_json, status FROM harness_runs WHERE run_id = ?')
57
+ .get(existing.run_id);
58
+ if (runRow === undefined) {
59
+ return;
60
+ }
61
+ const outputs = JSON.parse(runRow.completed_step_outputs_json);
62
+ if (transition.status === 'COMPLETED' && transition.outputJson !== undefined) {
63
+ outputs[existing.step_id] = transition.outputJson;
64
+ }
65
+ const nextRunStatus = resolveRunStatusAfterStepTransition(transition.status, runRow.status);
66
+ db.prepare('UPDATE harness_runs SET completed_step_outputs_json = ?, status = ?, updated_at = ? WHERE run_id = ?').run(JSON.stringify(outputs), nextRunStatus, new Date().toISOString(), existing.run_id);
67
+ }
68
+ /**
69
+ * Queries all non-terminal runs (`'QUEUED' | 'RUNNING' | 'WAITING' | 'SUSPENDED'`) on startup.
70
+ *
71
+ * Joins each active run with its latest active step execution to reconstruct `InterruptedStepBootRecord`s.
72
+ *
73
+ * @param {Database.Database} db - Active SQLite database handle.
74
+ *
75
+ * @returns {readonly InterruptedStepBootRecord[]} Non-terminal runs requiring crash recovery.
76
+ */
77
+ export function getInterruptedStepsOnBootFromSqlite(db) {
78
+ const runs = db
79
+ .prepare("SELECT * FROM harness_runs WHERE status IN ('QUEUED', 'RUNNING', 'WAITING', 'SUSPENDED') ORDER BY rowid ASC")
80
+ .all();
81
+ const latestStepStmt = db.prepare('SELECT * FROM harness_step_executions WHERE run_id = ? ORDER BY seq_id DESC LIMIT 1');
82
+ const results = [];
83
+ for (const runRow of runs) {
84
+ const stepRow = latestStepStmt.get(runRow.run_id);
85
+ results.push(mapInterruptedBootRecordFromSqlite(runRow, stepRow));
86
+ }
87
+ return Object.freeze(results);
88
+ }
89
+ //# sourceMappingURL=sqlite-ledger-step-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-ledger-step-ops.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-ledger-step-ops.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kCAAkC,EAClC,mCAAmC,GACpC,MAAM,oCAAoC,CAAC;AAK5C;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,EAAqB,EAAE,IAA0B;IACvF,MAAM,MAAM,GAAG,EAAE;SACd,OAAO,CAAC,8EAA8E,CAAC;SACvF,GAAG,EAAmC,CAAC;IAC1C,EAAE,CAAC,OAAO,CACR,8RAA8R,CAC/R,CAAC,GAAG,CACH,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,YAAY,IAAI,IAAI,EACzB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,mBAAmB,IAAI,IAAI,EAChC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,EACtC,MAAM,CAAC,QAAQ,CAChB,CAAC;IACF,EAAE,CAAC,OAAO,CACR,kGAAkG,CACnG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,+BAA+B,CAC7C,EAAqB,EACrB,MAAqC;IAErC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC3D,IAAI,MAAM,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;QAC7C,EAAE,CAAC,OAAO,CACR,iIAAiI,CAClI,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,mBAAmB,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AAU,CAAC,UAAU,CAAC;IACpD,CAAC;IACD,MAAM,aAAa,GAAG,mCAAmC,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5F,EAAE,CAAC,OAAO,CACR,sGAAsG,CACvG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mCAAmC,CACjD,EAAqB;IAErB,MAAM,IAAI,GAAG,EAAE;SACZ,OAAO,CACN,6GAA6G,CAC9G;SACA,GAAG,EAAoB,CAAC;IAC3B,MAAM,cAAc,GAAG,EAAE,CAAC,OAAO,CAC/B,qFAAqF,CACtF,CAAC;IACF,MAAM,OAAO,GAAgC,EAAE,CAAC;IAChD,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAA8B,CAAC;QAC/E,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,100 @@
1
+ import type { LessonOutcome, LessonRecord } from '@paraharness/core';
2
+ import type Database from 'better-sqlite3';
3
+ import type { AdmitLessonParams } from './admit-lesson-params.js';
4
+ /**
5
+ * Parameters for querying candidate lessons in `queryCandidates`.
6
+ */
7
+ export interface QueryLessonCandidatesParams {
8
+ /** Free-text search query $Q$ for BM25 relevance scoring. */
9
+ readonly queryText: string;
10
+ /** Active topology partition identifiers for filtering partition-scoped lessons. */
11
+ readonly partitions: readonly string[];
12
+ }
13
+ /**
14
+ * Single `(lessonId, outcome)` entry passed to `recordOutcomes`.
15
+ */
16
+ export interface LessonOutcomeEntryParams {
17
+ /** Target lesson identifier. */
18
+ readonly lessonId: string;
19
+ /** Recorded 4-state execution outcome. */
20
+ readonly outcome: LessonOutcome;
21
+ }
22
+ /**
23
+ * Parameters for recording a promotion signal emission timestamp in `markLessonSignalEmittedInSqlite`.
24
+ */
25
+ export interface MarkLessonSignalEmittedParams {
26
+ /** Identifier of the lesson that triggered the promotion signal. */
27
+ readonly lessonId: string;
28
+ /** Identifier of the emitted signal. */
29
+ readonly signalId: string;
30
+ /** ISO-8601 timestamp string of the emission. */
31
+ readonly emittedAt: string;
32
+ }
33
+ /**
34
+ * Queries non-retired candidate lessons matching `req.partitions` and computes `relevanceScore` $R(L, Q) \in [0, 1]$.
35
+ *
36
+ * Includes global lessons (`partition IS NULL`) and lessons whose `partition` is in `req.partitions`.
37
+ *
38
+ * @param {Database.Database} db - Active SQLite database handle.
39
+ * @param {QueryLessonCandidatesParams} req - Search query and active partitions.
40
+ *
41
+ * @returns {readonly LessonRecord[]} Candidate lessons sorted by descending `relevanceScore`.
42
+ */
43
+ export declare function queryLessonCandidatesInSqlite(db: Database.Database, req: QueryLessonCandidatesParams): readonly LessonRecord[];
44
+ /**
45
+ * Persists a distilled lesson into `harness_lessons` and returns its content-addressed `lessonId`.
46
+ *
47
+ * Deduplicates identical `(partition, directive)` pairs while updating `epochAtCreation` and `createdByRunId`.
48
+ *
49
+ * @param {Database.Database} db - Active SQLite database handle.
50
+ * @param {AdmitLessonParams} lesson - Lesson candidate to admit.
51
+ *
52
+ * @returns {string} Assigned content-addressed `lessonId`.
53
+ */
54
+ export declare function admitLessonInSqlite(db: Database.Database, lesson: AdmitLessonParams): string;
55
+ /**
56
+ * Appends deduplicated step execution outcomes to the specified lessons in `harness_lessons`.
57
+ *
58
+ * Increments `total_clean_passes` on `'clean_pass'` and `total_violated` on `'violated'`.
59
+ *
60
+ * @param {Database.Database} db - Active SQLite database handle.
61
+ * @param {readonly LessonOutcomeEntryParams[]} outcomes - Recorded outcomes batch.
62
+ *
63
+ * @returns {readonly LessonRecord[]} Updated lesson records for the affected lessons.
64
+ */
65
+ export declare function recordLessonOutcomesInSqlite(db: Database.Database, outcomes: readonly LessonOutcomeEntryParams[]): readonly LessonRecord[];
66
+ /**
67
+ * Aligns `epoch_at_creation` for lessons created by `runIds` when their topology overlays commit to the base store.
68
+ *
69
+ * Updates `epoch_at_creation = newEpoch` for each `(runId, partitionId)` pair in `updatedEpochs`.
70
+ *
71
+ * @param {Database.Database} db - Active SQLite database handle.
72
+ * @param {readonly string[]} runIds - Committed run identifiers.
73
+ * @param {ReadonlyMap<string, number>} updatedEpochs - Map of `partitionId` to newly committed base epoch.
74
+ *
75
+ * @returns {void} Returns nothing once creation epochs are synchronized.
76
+ */
77
+ export declare function syncLessonEpochsInSqlite(db: Database.Database, runIds: readonly string[], updatedEpochs: ReadonlyMap<string, number>): void;
78
+ /**
79
+ * Records the ISO-8601 timestamp when a promotion signal was emitted for `params.lessonId` in SQLite.
80
+ *
81
+ * Updates `signal_last_emitted_at_json[signalId] = emittedAt` on `harness_lessons`.
82
+ *
83
+ * @param {Database.Database} db - Active SQLite database handle.
84
+ * @param {MarkLessonSignalEmittedParams} params - Lesson ID, signal ID, and emission timestamp.
85
+ *
86
+ * @returns {void} Returns nothing once the timestamp is persisted.
87
+ */
88
+ export declare function markLessonSignalEmittedInSqlite(db: Database.Database, params: MarkLessonSignalEmittedParams): void;
89
+ /**
90
+ * Permanently marks the specified `lessonIds` as retired (`retired = 1`) in `harness_lessons`.
91
+ *
92
+ * Excludes retired lessons from all subsequent `queryCandidates()` recalls.
93
+ *
94
+ * @param {Database.Database} db - Active SQLite database handle.
95
+ * @param {readonly string[]} lessonIds - Identifiers of lessons to retire.
96
+ *
97
+ * @returns {void} Returns nothing once all specified lessons are retired.
98
+ */
99
+ export declare function retireLessonsInSqlite(db: Database.Database, lessonIds: readonly string[]): void;
100
+ //# sourceMappingURL=sqlite-lesson-ops.d.ts.map
@@ -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AAE,GAC5C,SAAS,YAAY,EAAE,CAyBzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,IAAI,CASN;AAED;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,MAAM,EAAE,6BAA6B,GACpC,IAAI,CAgBN;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAK/F"}
@@ -0,0 +1,178 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { computeNormalizedRelevanceScores } from './compute-normalized-relevance.js';
3
+ /**
4
+ * Maps a persisted `SqliteLessonRow` into an immutable `LessonRecord` with optional `relevanceScore`.
5
+ *
6
+ * Parses `recent_outcomes_json` and `signal_last_emitted_at_json` into frozen structures.
7
+ *
8
+ * @param {SqliteLessonRow} row - Persisted lesson row from `harness_lessons`.
9
+ * @param {number | undefined} relevanceScore - Optional normalized relevance score $R(L, Q) \in [0, 1]$.
10
+ *
11
+ * @returns {LessonRecord} Frozen lesson record.
12
+ */
13
+ function mapSqliteRowToLessonRecord(row, relevanceScore) {
14
+ const signalMap = row.signal_last_emitted_at_json !== null
15
+ ? Object.freeze(JSON.parse(row.signal_last_emitted_at_json))
16
+ : undefined;
17
+ return Object.freeze({
18
+ id: row.id,
19
+ partition: row.partition ?? undefined,
20
+ directive: row.directive,
21
+ epochAtCreation: row.epoch_at_creation,
22
+ createdByRunId: row.created_by_run_id ?? undefined,
23
+ recentOutcomes: Object.freeze(JSON.parse(row.recent_outcomes_json)),
24
+ totalCleanPasses: row.total_clean_passes,
25
+ totalViolated: row.total_violated,
26
+ relevanceScore,
27
+ signalLastEmittedAt: signalMap,
28
+ });
29
+ }
30
+ /**
31
+ * Queries non-retired candidate lessons matching `req.partitions` and computes `relevanceScore` $R(L, Q) \in [0, 1]$.
32
+ *
33
+ * Includes global lessons (`partition IS NULL`) and lessons whose `partition` is in `req.partitions`.
34
+ *
35
+ * @param {Database.Database} db - Active SQLite database handle.
36
+ * @param {QueryLessonCandidatesParams} req - Search query and active partitions.
37
+ *
38
+ * @returns {readonly LessonRecord[]} Candidate lessons sorted by descending `relevanceScore`.
39
+ */
40
+ export function queryLessonCandidatesInSqlite(db, req) {
41
+ const rows = db
42
+ .prepare('SELECT * FROM harness_lessons WHERE retired = 0 ORDER BY id ASC')
43
+ .all();
44
+ const partitionSet = new Set(req.partitions);
45
+ const eligibleRows = [];
46
+ for (const row of rows) {
47
+ if (row.partition === null || partitionSet.has(row.partition)) {
48
+ eligibleRows.push(row);
49
+ }
50
+ }
51
+ const scoresById = computeNormalizedRelevanceScores(eligibleRows, req.queryText);
52
+ const candidates = [];
53
+ for (const row of eligibleRows) {
54
+ const relevanceScore = scoresById.get(row.id) ?? 0;
55
+ candidates.push(mapSqliteRowToLessonRecord(row, relevanceScore));
56
+ }
57
+ candidates.sort((left, right) => (right.relevanceScore ?? 0) - (left.relevanceScore ?? 0));
58
+ return Object.freeze(candidates);
59
+ }
60
+ /**
61
+ * Persists a distilled lesson into `harness_lessons` and returns its content-addressed `lessonId`.
62
+ *
63
+ * Deduplicates identical `(partition, directive)` pairs while updating `epochAtCreation` and `createdByRunId`.
64
+ *
65
+ * @param {Database.Database} db - Active SQLite database handle.
66
+ * @param {AdmitLessonParams} lesson - Lesson candidate to admit.
67
+ *
68
+ * @returns {string} Assigned content-addressed `lessonId`.
69
+ */
70
+ export function admitLessonInSqlite(db, lesson) {
71
+ const hashHex = createHash('sha256')
72
+ .update(`${lesson.partition ?? ''}:${lesson.directive}`, 'utf8')
73
+ .digest('hex')
74
+ .slice(0, 16);
75
+ const lessonId = `lesson_${hashHex}`;
76
+ const existing = db
77
+ .prepare('SELECT id FROM harness_lessons WHERE id = ?')
78
+ .get(lessonId);
79
+ if (existing !== undefined) {
80
+ db.prepare('UPDATE harness_lessons SET epoch_at_creation = ?, created_by_run_id = COALESCE(?, created_by_run_id), retired = 0 WHERE id = ?').run(lesson.epochAtCreation, lesson.createdByRunId ?? null, lessonId);
81
+ return lessonId;
82
+ }
83
+ db.prepare("INSERT INTO harness_lessons (id, partition, directive, epoch_at_creation, created_by_run_id, recent_outcomes_json, total_clean_passes, total_violated, signal_last_emitted_at_json, retired) VALUES (?, ?, ?, ?, ?, '[]', 0, 0, NULL, 0)").run(lessonId, lesson.partition ?? null, lesson.directive, lesson.epochAtCreation, lesson.createdByRunId ?? null);
84
+ return lessonId;
85
+ }
86
+ /**
87
+ * Appends deduplicated step execution outcomes to the specified lessons in `harness_lessons`.
88
+ *
89
+ * Increments `total_clean_passes` on `'clean_pass'` and `total_violated` on `'violated'`.
90
+ *
91
+ * @param {Database.Database} db - Active SQLite database handle.
92
+ * @param {readonly LessonOutcomeEntryParams[]} outcomes - Recorded outcomes batch.
93
+ *
94
+ * @returns {readonly LessonRecord[]} Updated lesson records for the affected lessons.
95
+ */
96
+ export function recordLessonOutcomesInSqlite(db, outcomes) {
97
+ const selectStmt = db.prepare('SELECT * FROM harness_lessons WHERE id = ?');
98
+ const updateStmt = db.prepare('UPDATE harness_lessons SET recent_outcomes_json = ?, total_clean_passes = ?, total_violated = ? WHERE id = ?');
99
+ const touchedIds = new Set();
100
+ for (const entry of outcomes) {
101
+ const row = selectStmt.get(entry.lessonId);
102
+ if (row !== undefined) {
103
+ const recent = JSON.parse(row.recent_outcomes_json);
104
+ recent.push(entry.outcome);
105
+ const cleanPasses = row.total_clean_passes + (entry.outcome === 'clean_pass' ? 1 : 0);
106
+ const violated = row.total_violated + (entry.outcome === 'violated' ? 1 : 0);
107
+ updateStmt.run(JSON.stringify(recent), cleanPasses, violated, entry.lessonId);
108
+ touchedIds.add(entry.lessonId);
109
+ }
110
+ }
111
+ const updatedRecords = [];
112
+ for (const id of touchedIds) {
113
+ const row = selectStmt.get(id);
114
+ if (row !== undefined) {
115
+ updatedRecords.push(mapSqliteRowToLessonRecord(row, undefined));
116
+ }
117
+ }
118
+ return Object.freeze(updatedRecords);
119
+ }
120
+ /**
121
+ * Aligns `epoch_at_creation` for lessons created by `runIds` when their topology overlays commit to the base store.
122
+ *
123
+ * Updates `epoch_at_creation = newEpoch` for each `(runId, partitionId)` pair in `updatedEpochs`.
124
+ *
125
+ * @param {Database.Database} db - Active SQLite database handle.
126
+ * @param {readonly string[]} runIds - Committed run identifiers.
127
+ * @param {ReadonlyMap<string, number>} updatedEpochs - Map of `partitionId` to newly committed base epoch.
128
+ *
129
+ * @returns {void} Returns nothing once creation epochs are synchronized.
130
+ */
131
+ export function syncLessonEpochsInSqlite(db, runIds, updatedEpochs) {
132
+ const stmt = db.prepare('UPDATE harness_lessons SET epoch_at_creation = ? WHERE created_by_run_id = ? AND partition = ?');
133
+ for (const [partitionId, newEpoch] of updatedEpochs.entries()) {
134
+ for (const runId of runIds) {
135
+ stmt.run(newEpoch, runId, partitionId);
136
+ }
137
+ }
138
+ }
139
+ /**
140
+ * Records the ISO-8601 timestamp when a promotion signal was emitted for `params.lessonId` in SQLite.
141
+ *
142
+ * Updates `signal_last_emitted_at_json[signalId] = emittedAt` on `harness_lessons`.
143
+ *
144
+ * @param {Database.Database} db - Active SQLite database handle.
145
+ * @param {MarkLessonSignalEmittedParams} params - Lesson ID, signal ID, and emission timestamp.
146
+ *
147
+ * @returns {void} Returns nothing once the timestamp is persisted.
148
+ */
149
+ export function markLessonSignalEmittedInSqlite(db, params) {
150
+ const row = db
151
+ .prepare('SELECT signal_last_emitted_at_json FROM harness_lessons WHERE id = ?')
152
+ .get(params.lessonId);
153
+ if (row === undefined) {
154
+ return;
155
+ }
156
+ const map = row.signal_last_emitted_at_json !== null
157
+ ? JSON.parse(row.signal_last_emitted_at_json)
158
+ : {};
159
+ map[params.signalId] = params.emittedAt;
160
+ db.prepare('UPDATE harness_lessons SET signal_last_emitted_at_json = ? WHERE id = ?').run(JSON.stringify(map), params.lessonId);
161
+ }
162
+ /**
163
+ * Permanently marks the specified `lessonIds` as retired (`retired = 1`) in `harness_lessons`.
164
+ *
165
+ * Excludes retired lessons from all subsequent `queryCandidates()` recalls.
166
+ *
167
+ * @param {Database.Database} db - Active SQLite database handle.
168
+ * @param {readonly string[]} lessonIds - Identifiers of lessons to retire.
169
+ *
170
+ * @returns {void} Returns nothing once all specified lessons are retired.
171
+ */
172
+ export function retireLessonsInSqlite(db, lessonIds) {
173
+ const stmt = db.prepare('UPDATE harness_lessons SET retired = 1 WHERE id = ?');
174
+ for (const lessonId of lessonIds) {
175
+ stmt.run(lessonId);
176
+ }
177
+ }
178
+ //# sourceMappingURL=sqlite-lesson-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-lesson-ops.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-lesson-ops.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAmCrF;;;;;;;;;GASG;AACH,SAAS,0BAA0B,CACjC,GAAoB,EACpB,cAAkC;IAElC,MAAM,SAAS,GACb,GAAG,CAAC,2BAA2B,KAAK,IAAI;QACtC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,2BAA2B,CAA2B,CAAC;QACtF,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO,MAAM,CAAC,MAAM,CAAe;QACjC,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,SAAS;QACrC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,eAAe,EAAE,GAAG,CAAC,iBAAiB;QACtC,cAAc,EAAE,GAAG,CAAC,iBAAiB,IAAI,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jC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Raw SQLite row shape for `harness_lessons`.
3
+ *
4
+ * Maps persisted empirical lesson fields, outcome counters, and retirement state.
5
+ */
6
+ export interface SqliteLessonRow {
7
+ /** Content-addressed lesson identifier. */
8
+ readonly id: string;
9
+ /** Optional logical partition identifier, or `null`. */
10
+ readonly partition: string | null;
11
+ /** Preventative rule or architectural directive text. */
12
+ readonly directive: string;
13
+ /** Partition topology epoch at creation or last sync. */
14
+ readonly epoch_at_creation: number;
15
+ /** Optional creator run ID (`lastMutatedByRunId ?? runId`), or `null`. */
16
+ readonly created_by_run_id: string | null;
17
+ /** JSON-serialized `LessonOutcome[]` array. */
18
+ readonly recent_outcomes_json: string;
19
+ /** Lifetime count of `'clean_pass'` outcomes. */
20
+ readonly total_clean_passes: number;
21
+ /** Lifetime count of `'violated'` outcomes. */
22
+ readonly total_violated: number;
23
+ /** Optional JSON-serialized `Record<string, string>` of signal emission timestamps. */
24
+ readonly signal_last_emitted_at_json: string | null;
25
+ /** Retirement flag (`1` when retired, `0` when active). */
26
+ readonly retired: number;
27
+ }
28
+ //# sourceMappingURL=sqlite-lesson-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-lesson-row.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-lesson-row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,+CAA+C;IAC/C,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,iDAAiD;IACjD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,uFAAuF;IACvF,QAAQ,CAAC,2BAA2B,EAAE,MAAM,GAAG,IAAI,CAAC;IACpD,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sqlite-lesson-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-lesson-row.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-lesson-row.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Step-scoped contract mutation history entry stored inside `harness_topology_overlays.step_mutations_json`.
3
+ *
4
+ * Captures the pre-mutation overlay state so `resetRunOverlay(runId, { scope: 'step', stepExecId })`
5
+ * can revert uncommitted edits from a single failed/aborted step while preserving prior steps.
6
+ */
7
+ export interface SqliteOverlayStepMutationEntry {
8
+ /** Step execution identifier that performed the mutation, or `null`. */
9
+ readonly stepExecId: string | null;
10
+ /** Contract text prior to this mutation. */
11
+ readonly prevContractText: string;
12
+ /** Overlay epoch prior to this mutation. */
13
+ readonly prevEpoch: number;
14
+ /** `mutated_in_run` flag (`0` or `1`) prior to this mutation. */
15
+ readonly prevMutatedInRun: number;
16
+ /** `has_uncommitted_changes` flag (`0` or `1`) prior to this mutation. */
17
+ readonly prevHasUncommittedChanges: number;
18
+ /** `last_mutated_by_run_id` value prior to this mutation. */
19
+ readonly prevLastMutatedByRunId: string | null;
20
+ }
21
+ //# sourceMappingURL=sqlite-overlay-step-mutation-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-overlay-step-mutation-entry.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-overlay-step-mutation-entry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,8BAA8B;IAC7C,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,4CAA4C;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,6DAA6D;IAC7D,QAAQ,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sqlite-overlay-step-mutation-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-overlay-step-mutation-entry.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-overlay-step-mutation-entry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Raw SQLite row shape for `harness_runs` and `harness_terminal_receipts` queries.
3
+ *
4
+ * Maps snake_case database columns to typed properties for `SqliteLedgerStore` run operations.
5
+ */
6
+ export interface SqliteRunRow {
7
+ /** Unique flow run identifier. */
8
+ readonly run_id: string;
9
+ /** Enclosing lane identifier. */
10
+ readonly lane_id: string;
11
+ /** Work item deduplication key. */
12
+ readonly item_key: string;
13
+ /** Persisted run lifecycle status string. */
14
+ readonly status: string;
15
+ /** Currently executing step ID, or `null`. */
16
+ readonly current_step_id: string | null;
17
+ /** JSON-serialized flow input payload. */
18
+ readonly input_json: string;
19
+ /** Pending rewind target step ID, or `null`. */
20
+ readonly rewind_pending_to_step_id: string | null;
21
+ /** JSON-serialized map of pinned wire prefixes, or `null`. */
22
+ readonly compiled_prefixes_json: string | null;
23
+ /** Cumulative run cost in USD. */
24
+ readonly cost_usd: number;
25
+ /** Human-approved maximum cost in USD, or `null`. */
26
+ readonly approved_max_cost_usd: number | null;
27
+ /** JSON-serialized map of completed step IDs to output JSON. */
28
+ readonly completed_step_outputs_json: string;
29
+ /** JSON-serialized array of prerequisite item keys. */
30
+ readonly depends_on_json: string;
31
+ /** Terminal state string when recorded, or `null`. */
32
+ readonly terminal_state: string | null;
33
+ /** JSON-serialized final scope receipt, or `null`. */
34
+ readonly scope_receipt_json: string | null;
35
+ }
36
+ //# sourceMappingURL=sqlite-run-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-run-row.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-run-row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,8DAA8D;IAC9D,QAAQ,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,kCAAkC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,gEAAgE;IAChE,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IAC7C,uDAAuD;IACvD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,sDAAsD;IACtD,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,sDAAsD;IACtD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sqlite-run-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-run-row.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-run-row.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Raw SQLite row shape for `harness_step_executions`.
3
+ *
4
+ * Maps snake_case database columns to typed properties for `SqliteLedgerStore` step operations.
5
+ */
6
+ export interface SqliteStepRow {
7
+ /** Unique step execution identifier. */
8
+ readonly step_exec_id: string;
9
+ /** Enclosing flow run identifier. */
10
+ readonly run_id: string;
11
+ /** Logical flow step identifier. */
12
+ readonly step_id: string;
13
+ /** Optional promoted executable identifier, or `null`. */
14
+ readonly executable_id: string | null;
15
+ /** Optional input message frame ID, or `null`. */
16
+ readonly input_msg_id: string | null;
17
+ /** Step execution lifecycle status. */
18
+ readonly status: string;
19
+ /** JSON-serialized step output when completed, or `null`. */
20
+ readonly output_json: string | null;
21
+ /** Serialized base scope checkpoint, or `null`. */
22
+ readonly base_scope_checkpoint: string | null;
23
+ /** Serialized head scope checkpoint on suspension, or `null`. */
24
+ readonly head_scope_checkpoint: string | null;
25
+ /** JSON-serialized `ContinuationFrame[]` call stack. */
26
+ readonly continuation_stack_json: string;
27
+ /** JSON-serialized `UniversalStepTelemetry` payload, or `null`. */
28
+ readonly telemetry_json: string | null;
29
+ /** Monotonic sequence integer within the ledger. */
30
+ readonly seq_id: number;
31
+ }
32
+ //# sourceMappingURL=sqlite-step-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-step-row.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-step-row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0DAA0D;IAC1D,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,kDAAkD;IAClD,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,mDAAmD;IACnD,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,iEAAiE;IACjE,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,wDAAwD;IACxD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,mEAAmE;IACnE,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sqlite-step-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-step-row.js","sourceRoot":"","sources":["../../../src/stores/internal/sqlite-step-row.ts"],"names":[],"mappings":""}