@smthrs/control 0.0.0-stage → 1.0.0-rc.3

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 (418) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/LICENSE +21 -0
  3. package/README.md +168 -2
  4. package/dist/cjs/ApprovalAuthority.d.ts +73 -0
  5. package/dist/cjs/ApprovalAuthority.d.ts.map +1 -0
  6. package/dist/cjs/ApprovalAuthority.js +62 -0
  7. package/dist/cjs/ApprovalAuthority.js.map +7 -0
  8. package/dist/cjs/Cancellation.d.ts +107 -0
  9. package/dist/cjs/Cancellation.d.ts.map +1 -0
  10. package/dist/cjs/Cancellation.js +72 -0
  11. package/dist/cjs/Cancellation.js.map +7 -0
  12. package/dist/cjs/Channels.d.ts +170 -0
  13. package/dist/cjs/Channels.d.ts.map +1 -0
  14. package/dist/cjs/Channels.js +278 -0
  15. package/dist/cjs/Channels.js.map +7 -0
  16. package/dist/cjs/Control.d.ts +202 -0
  17. package/dist/cjs/Control.d.ts.map +1 -0
  18. package/dist/cjs/Control.js +47 -0
  19. package/dist/cjs/Control.js.map +7 -0
  20. package/dist/cjs/ControlClient.d.ts +52 -0
  21. package/dist/cjs/ControlClient.d.ts.map +1 -0
  22. package/dist/cjs/ControlClient.js +191 -0
  23. package/dist/cjs/ControlClient.js.map +7 -0
  24. package/dist/cjs/ControlError.d.ts +318 -0
  25. package/dist/cjs/ControlError.d.ts.map +1 -0
  26. package/dist/cjs/ControlError.js +249 -0
  27. package/dist/cjs/ControlError.js.map +7 -0
  28. package/dist/cjs/ControlExecutor.d.ts +372 -0
  29. package/dist/cjs/ControlExecutor.d.ts.map +1 -0
  30. package/dist/cjs/ControlExecutor.js +123 -0
  31. package/dist/cjs/ControlExecutor.js.map +7 -0
  32. package/dist/cjs/ControlFacts.d.ts +454 -0
  33. package/dist/cjs/ControlFacts.d.ts.map +1 -0
  34. package/dist/cjs/ControlFacts.js +261 -0
  35. package/dist/cjs/ControlFacts.js.map +7 -0
  36. package/dist/cjs/ControlLive.d.ts +23 -0
  37. package/dist/cjs/ControlLive.d.ts.map +1 -0
  38. package/dist/cjs/ControlLive.js +1280 -0
  39. package/dist/cjs/ControlLive.js.map +7 -0
  40. package/dist/cjs/ControlRpcs.d.ts +1204 -0
  41. package/dist/cjs/ControlRpcs.d.ts.map +1 -0
  42. package/dist/cjs/ControlRpcs.js +247 -0
  43. package/dist/cjs/ControlRpcs.js.map +7 -0
  44. package/dist/cjs/ControlRuntime.d.ts +635 -0
  45. package/dist/cjs/ControlRuntime.d.ts.map +1 -0
  46. package/dist/cjs/ControlRuntime.js +740 -0
  47. package/dist/cjs/ControlRuntime.js.map +7 -0
  48. package/dist/cjs/ControlSchema.d.ts +2642 -0
  49. package/dist/cjs/ControlSchema.d.ts.map +1 -0
  50. package/dist/cjs/ControlSchema.js +634 -0
  51. package/dist/cjs/ControlSchema.js.map +7 -0
  52. package/dist/cjs/ControlServer.d.ts +51 -0
  53. package/dist/cjs/ControlServer.d.ts.map +1 -0
  54. package/dist/cjs/ControlServer.js +121 -0
  55. package/dist/cjs/ControlServer.js.map +7 -0
  56. package/dist/cjs/Credential.d.ts +136 -0
  57. package/dist/cjs/Credential.d.ts.map +1 -0
  58. package/dist/cjs/Credential.js +168 -0
  59. package/dist/cjs/Credential.js.map +7 -0
  60. package/dist/cjs/CredentialCipher.d.ts +90 -0
  61. package/dist/cjs/CredentialCipher.d.ts.map +1 -0
  62. package/dist/cjs/CredentialCipher.js +45 -0
  63. package/dist/cjs/CredentialCipher.js.map +7 -0
  64. package/dist/cjs/CredentialStore.d.ts +97 -0
  65. package/dist/cjs/CredentialStore.d.ts.map +1 -0
  66. package/dist/cjs/CredentialStore.js +81 -0
  67. package/dist/cjs/CredentialStore.js.map +7 -0
  68. package/dist/cjs/DispatchReader.d.ts +112 -0
  69. package/dist/cjs/DispatchReader.d.ts.map +1 -0
  70. package/dist/cjs/DispatchReader.js +45 -0
  71. package/dist/cjs/DispatchReader.js.map +7 -0
  72. package/dist/cjs/Health.d.ts +333 -0
  73. package/dist/cjs/Health.d.ts.map +1 -0
  74. package/dist/cjs/Health.js +311 -0
  75. package/dist/cjs/Health.js.map +7 -0
  76. package/dist/cjs/JevSessionChecker.d.ts +57 -0
  77. package/dist/cjs/JevSessionChecker.d.ts.map +1 -0
  78. package/dist/cjs/JevSessionChecker.js +113 -0
  79. package/dist/cjs/JevSessionChecker.js.map +7 -0
  80. package/dist/cjs/Lineage.d.ts +131 -0
  81. package/dist/cjs/Lineage.d.ts.map +1 -0
  82. package/dist/cjs/Lineage.js +81 -0
  83. package/dist/cjs/Lineage.js.map +7 -0
  84. package/dist/cjs/Migrations.d.ts +34 -0
  85. package/dist/cjs/Migrations.d.ts.map +1 -0
  86. package/dist/cjs/Migrations.js +60 -0
  87. package/dist/cjs/Migrations.js.map +7 -0
  88. package/dist/cjs/Monitor.d.ts +282 -0
  89. package/dist/cjs/Monitor.d.ts.map +1 -0
  90. package/dist/cjs/Monitor.js +283 -0
  91. package/dist/cjs/Monitor.js.map +7 -0
  92. package/dist/cjs/ScopedToken.d.ts +193 -0
  93. package/dist/cjs/ScopedToken.d.ts.map +1 -0
  94. package/dist/cjs/ScopedToken.js +135 -0
  95. package/dist/cjs/ScopedToken.js.map +7 -0
  96. package/dist/cjs/SqlControlRuntime.d.ts +161 -0
  97. package/dist/cjs/SqlControlRuntime.d.ts.map +1 -0
  98. package/dist/cjs/SqlControlRuntime.js +1521 -0
  99. package/dist/cjs/SqlControlRuntime.js.map +7 -0
  100. package/dist/cjs/SqlCredentialStore.d.ts +43 -0
  101. package/dist/cjs/SqlCredentialStore.d.ts.map +1 -0
  102. package/dist/cjs/SqlCredentialStore.js +113 -0
  103. package/dist/cjs/SqlCredentialStore.js.map +7 -0
  104. package/dist/cjs/Steering.d.ts +69 -0
  105. package/dist/cjs/Steering.d.ts.map +1 -0
  106. package/dist/cjs/Steering.js +49 -0
  107. package/dist/cjs/Steering.js.map +7 -0
  108. package/dist/cjs/SystemFlows.d.ts +223 -0
  109. package/dist/cjs/SystemFlows.d.ts.map +1 -0
  110. package/dist/cjs/SystemFlows.js +195 -0
  111. package/dist/cjs/SystemFlows.js.map +7 -0
  112. package/dist/cjs/WebCryptoCipher.d.ts +49 -0
  113. package/dist/cjs/WebCryptoCipher.d.ts.map +1 -0
  114. package/dist/cjs/WebCryptoCipher.js +129 -0
  115. package/dist/cjs/WebCryptoCipher.js.map +7 -0
  116. package/dist/cjs/WebhookChannel.d.ts +113 -0
  117. package/dist/cjs/WebhookChannel.d.ts.map +1 -0
  118. package/dist/cjs/WebhookChannel.js +98 -0
  119. package/dist/cjs/WebhookChannel.js.map +7 -0
  120. package/dist/cjs/index.d.ts +160 -0
  121. package/dist/cjs/index.d.ts.map +1 -0
  122. package/dist/cjs/index.js +91 -0
  123. package/dist/cjs/index.js.map +7 -0
  124. package/dist/cjs/internal/MutationBoundary.d.ts +27 -0
  125. package/dist/cjs/internal/MutationBoundary.d.ts.map +1 -0
  126. package/dist/cjs/internal/MutationBoundary.js +50 -0
  127. package/dist/cjs/internal/MutationBoundary.js.map +7 -0
  128. package/dist/cjs/internal/activeFibers.d.ts +12 -0
  129. package/dist/cjs/internal/activeFibers.d.ts.map +1 -0
  130. package/dist/cjs/internal/activeFibers.js +30 -0
  131. package/dist/cjs/internal/activeFibers.js.map +7 -0
  132. package/dist/cjs/internal/issues.d.ts +28 -0
  133. package/dist/cjs/internal/issues.d.ts.map +1 -0
  134. package/dist/cjs/internal/issues.js +34 -0
  135. package/dist/cjs/internal/issues.js.map +7 -0
  136. package/dist/cjs/internal/planning.d.ts +347 -0
  137. package/dist/cjs/internal/planning.d.ts.map +1 -0
  138. package/dist/cjs/internal/planning.js +137 -0
  139. package/dist/cjs/internal/planning.js.map +7 -0
  140. package/dist/cjs/internal/sqlSchemaErrors.d.ts +18 -0
  141. package/dist/cjs/internal/sqlSchemaErrors.d.ts.map +1 -0
  142. package/dist/cjs/internal/sqlSchemaErrors.js +40 -0
  143. package/dist/cjs/internal/sqlSchemaErrors.js.map +7 -0
  144. package/dist/cjs/migrations/0001_control_tables.d.ts +18 -0
  145. package/dist/cjs/migrations/0001_control_tables.d.ts.map +1 -0
  146. package/dist/cjs/migrations/0001_control_tables.js +115 -0
  147. package/dist/cjs/migrations/0001_control_tables.js.map +7 -0
  148. package/dist/cjs/migrations/0002_run_keys.d.ts +15 -0
  149. package/dist/cjs/migrations/0002_run_keys.d.ts.map +1 -0
  150. package/dist/cjs/migrations/0002_run_keys.js +44 -0
  151. package/dist/cjs/migrations/0002_run_keys.js.map +7 -0
  152. package/dist/cjs/migrations/0003_signal_commands.d.ts +13 -0
  153. package/dist/cjs/migrations/0003_signal_commands.d.ts.map +1 -0
  154. package/dist/cjs/migrations/0003_signal_commands.js +50 -0
  155. package/dist/cjs/migrations/0003_signal_commands.js.map +7 -0
  156. package/dist/cjs/migrations/0004_approval_decisions.d.ts +13 -0
  157. package/dist/cjs/migrations/0004_approval_decisions.d.ts.map +1 -0
  158. package/dist/cjs/migrations/0004_approval_decisions.js +45 -0
  159. package/dist/cjs/migrations/0004_approval_decisions.js.map +7 -0
  160. package/dist/cjs/migrations/0005_signal_principals.d.ts +18 -0
  161. package/dist/cjs/migrations/0005_signal_principals.d.ts.map +1 -0
  162. package/dist/cjs/migrations/0005_signal_principals.js +45 -0
  163. package/dist/cjs/migrations/0005_signal_principals.js.map +7 -0
  164. package/dist/cjs/migrations/0006_run_principals.d.ts +18 -0
  165. package/dist/cjs/migrations/0006_run_principals.d.ts.map +1 -0
  166. package/dist/cjs/migrations/0006_run_principals.js +49 -0
  167. package/dist/cjs/migrations/0006_run_principals.js.map +7 -0
  168. package/dist/cjs/migrations/0007_resume_consent.d.ts +18 -0
  169. package/dist/cjs/migrations/0007_resume_consent.d.ts.map +1 -0
  170. package/dist/cjs/migrations/0007_resume_consent.js +46 -0
  171. package/dist/cjs/migrations/0007_resume_consent.js.map +7 -0
  172. package/dist/cjs/package.json +1 -0
  173. package/dist/cjs/test/TestControl.d.ts +19 -0
  174. package/dist/cjs/test/TestControl.d.ts.map +1 -0
  175. package/dist/cjs/test/TestControl.js +62 -0
  176. package/dist/cjs/test/TestControl.js.map +7 -0
  177. package/dist/esm/ApprovalAuthority.d.ts +73 -0
  178. package/dist/esm/ApprovalAuthority.d.ts.map +1 -0
  179. package/dist/esm/ApprovalAuthority.js +72 -0
  180. package/dist/esm/ApprovalAuthority.js.map +1 -0
  181. package/dist/esm/Cancellation.d.ts +107 -0
  182. package/dist/esm/Cancellation.d.ts.map +1 -0
  183. package/dist/esm/Cancellation.js +116 -0
  184. package/dist/esm/Cancellation.js.map +1 -0
  185. package/dist/esm/Channels.d.ts +170 -0
  186. package/dist/esm/Channels.d.ts.map +1 -0
  187. package/dist/esm/Channels.js +312 -0
  188. package/dist/esm/Channels.js.map +1 -0
  189. package/dist/esm/Control.d.ts +202 -0
  190. package/dist/esm/Control.d.ts.map +1 -0
  191. package/dist/esm/Control.js +42 -0
  192. package/dist/esm/Control.js.map +1 -0
  193. package/dist/esm/ControlClient.d.ts +52 -0
  194. package/dist/esm/ControlClient.d.ts.map +1 -0
  195. package/dist/esm/ControlClient.js +217 -0
  196. package/dist/esm/ControlClient.js.map +1 -0
  197. package/dist/esm/ControlError.d.ts +318 -0
  198. package/dist/esm/ControlError.d.ts.map +1 -0
  199. package/dist/esm/ControlError.js +359 -0
  200. package/dist/esm/ControlError.js.map +1 -0
  201. package/dist/esm/ControlExecutor.d.ts +372 -0
  202. package/dist/esm/ControlExecutor.d.ts.map +1 -0
  203. package/dist/esm/ControlExecutor.js +212 -0
  204. package/dist/esm/ControlExecutor.js.map +1 -0
  205. package/dist/esm/ControlFacts.d.ts +454 -0
  206. package/dist/esm/ControlFacts.d.ts.map +1 -0
  207. package/dist/esm/ControlFacts.js +324 -0
  208. package/dist/esm/ControlFacts.js.map +1 -0
  209. package/dist/esm/ControlLive.d.ts +23 -0
  210. package/dist/esm/ControlLive.d.ts.map +1 -0
  211. package/dist/esm/ControlLive.js +1585 -0
  212. package/dist/esm/ControlLive.js.map +1 -0
  213. package/dist/esm/ControlRpcs.d.ts +1204 -0
  214. package/dist/esm/ControlRpcs.d.ts.map +1 -0
  215. package/dist/esm/ControlRpcs.js +299 -0
  216. package/dist/esm/ControlRpcs.js.map +1 -0
  217. package/dist/esm/ControlRuntime.d.ts +635 -0
  218. package/dist/esm/ControlRuntime.d.ts.map +1 -0
  219. package/dist/esm/ControlRuntime.js +807 -0
  220. package/dist/esm/ControlRuntime.js.map +1 -0
  221. package/dist/esm/ControlSchema.d.ts +2642 -0
  222. package/dist/esm/ControlSchema.d.ts.map +1 -0
  223. package/dist/esm/ControlSchema.js +1030 -0
  224. package/dist/esm/ControlSchema.js.map +1 -0
  225. package/dist/esm/ControlServer.d.ts +51 -0
  226. package/dist/esm/ControlServer.d.ts.map +1 -0
  227. package/dist/esm/ControlServer.js +145 -0
  228. package/dist/esm/ControlServer.js.map +1 -0
  229. package/dist/esm/Credential.d.ts +136 -0
  230. package/dist/esm/Credential.d.ts.map +1 -0
  231. package/dist/esm/Credential.js +190 -0
  232. package/dist/esm/Credential.js.map +1 -0
  233. package/dist/esm/CredentialCipher.d.ts +90 -0
  234. package/dist/esm/CredentialCipher.d.ts.map +1 -0
  235. package/dist/esm/CredentialCipher.js +56 -0
  236. package/dist/esm/CredentialCipher.js.map +1 -0
  237. package/dist/esm/CredentialStore.d.ts +97 -0
  238. package/dist/esm/CredentialStore.d.ts.map +1 -0
  239. package/dist/esm/CredentialStore.js +101 -0
  240. package/dist/esm/CredentialStore.js.map +1 -0
  241. package/dist/esm/DispatchReader.d.ts +112 -0
  242. package/dist/esm/DispatchReader.d.ts.map +1 -0
  243. package/dist/esm/DispatchReader.js +76 -0
  244. package/dist/esm/DispatchReader.js.map +1 -0
  245. package/dist/esm/Health.d.ts +333 -0
  246. package/dist/esm/Health.d.ts.map +1 -0
  247. package/dist/esm/Health.js +400 -0
  248. package/dist/esm/Health.js.map +1 -0
  249. package/dist/esm/JevSessionChecker.d.ts +57 -0
  250. package/dist/esm/JevSessionChecker.d.ts.map +1 -0
  251. package/dist/esm/JevSessionChecker.js +108 -0
  252. package/dist/esm/JevSessionChecker.js.map +1 -0
  253. package/dist/esm/Lineage.d.ts +131 -0
  254. package/dist/esm/Lineage.d.ts.map +1 -0
  255. package/dist/esm/Lineage.js +174 -0
  256. package/dist/esm/Lineage.js.map +1 -0
  257. package/dist/esm/Migrations.d.ts +34 -0
  258. package/dist/esm/Migrations.d.ts.map +1 -0
  259. package/dist/esm/Migrations.js +53 -0
  260. package/dist/esm/Migrations.js.map +1 -0
  261. package/dist/esm/Monitor.d.ts +282 -0
  262. package/dist/esm/Monitor.d.ts.map +1 -0
  263. package/dist/esm/Monitor.js +415 -0
  264. package/dist/esm/Monitor.js.map +1 -0
  265. package/dist/esm/ScopedToken.d.ts +193 -0
  266. package/dist/esm/ScopedToken.d.ts.map +1 -0
  267. package/dist/esm/ScopedToken.js +224 -0
  268. package/dist/esm/ScopedToken.js.map +1 -0
  269. package/dist/esm/SqlControlRuntime.d.ts +161 -0
  270. package/dist/esm/SqlControlRuntime.d.ts.map +1 -0
  271. package/dist/esm/SqlControlRuntime.js +1756 -0
  272. package/dist/esm/SqlControlRuntime.js.map +1 -0
  273. package/dist/esm/SqlCredentialStore.d.ts +43 -0
  274. package/dist/esm/SqlCredentialStore.d.ts.map +1 -0
  275. package/dist/esm/SqlCredentialStore.js +97 -0
  276. package/dist/esm/SqlCredentialStore.js.map +1 -0
  277. package/dist/esm/Steering.d.ts +69 -0
  278. package/dist/esm/Steering.d.ts.map +1 -0
  279. package/dist/esm/Steering.js +89 -0
  280. package/dist/esm/Steering.js.map +1 -0
  281. package/dist/esm/SystemFlows.d.ts +223 -0
  282. package/dist/esm/SystemFlows.d.ts.map +1 -0
  283. package/dist/esm/SystemFlows.js +198 -0
  284. package/dist/esm/SystemFlows.js.map +1 -0
  285. package/dist/esm/WebCryptoCipher.d.ts +49 -0
  286. package/dist/esm/WebCryptoCipher.d.ts.map +1 -0
  287. package/dist/esm/WebCryptoCipher.js +123 -0
  288. package/dist/esm/WebCryptoCipher.js.map +1 -0
  289. package/dist/esm/WebhookChannel.d.ts +113 -0
  290. package/dist/esm/WebhookChannel.d.ts.map +1 -0
  291. package/dist/esm/WebhookChannel.js +109 -0
  292. package/dist/esm/WebhookChannel.js.map +1 -0
  293. package/dist/esm/index.d.ts +160 -0
  294. package/dist/esm/index.d.ts.map +1 -0
  295. package/dist/esm/index.js +160 -0
  296. package/dist/esm/index.js.map +1 -0
  297. package/dist/esm/internal/MutationBoundary.d.ts +27 -0
  298. package/dist/esm/internal/MutationBoundary.d.ts.map +1 -0
  299. package/dist/esm/internal/MutationBoundary.js +40 -0
  300. package/dist/esm/internal/MutationBoundary.js.map +1 -0
  301. package/dist/esm/internal/activeFibers.d.ts +12 -0
  302. package/dist/esm/internal/activeFibers.d.ts.map +1 -0
  303. package/dist/esm/internal/activeFibers.js +17 -0
  304. package/dist/esm/internal/activeFibers.js.map +1 -0
  305. package/dist/esm/internal/issues.d.ts +28 -0
  306. package/dist/esm/internal/issues.d.ts.map +1 -0
  307. package/dist/esm/internal/issues.js +35 -0
  308. package/dist/esm/internal/issues.js.map +1 -0
  309. package/dist/esm/internal/planning.d.ts +347 -0
  310. package/dist/esm/internal/planning.d.ts.map +1 -0
  311. package/dist/esm/internal/planning.js +199 -0
  312. package/dist/esm/internal/planning.js.map +1 -0
  313. package/dist/esm/internal/sqlSchemaErrors.d.ts +18 -0
  314. package/dist/esm/internal/sqlSchemaErrors.d.ts.map +1 -0
  315. package/dist/esm/internal/sqlSchemaErrors.js +38 -0
  316. package/dist/esm/internal/sqlSchemaErrors.js.map +1 -0
  317. package/dist/esm/migrations/0001_control_tables.d.ts +18 -0
  318. package/dist/esm/migrations/0001_control_tables.d.ts.map +1 -0
  319. package/dist/esm/migrations/0001_control_tables.js +96 -0
  320. package/dist/esm/migrations/0001_control_tables.js.map +1 -0
  321. package/dist/esm/migrations/0002_run_keys.d.ts +15 -0
  322. package/dist/esm/migrations/0002_run_keys.d.ts.map +1 -0
  323. package/dist/esm/migrations/0002_run_keys.js +22 -0
  324. package/dist/esm/migrations/0002_run_keys.js.map +1 -0
  325. package/dist/esm/migrations/0003_signal_commands.d.ts +13 -0
  326. package/dist/esm/migrations/0003_signal_commands.d.ts.map +1 -0
  327. package/dist/esm/migrations/0003_signal_commands.js +26 -0
  328. package/dist/esm/migrations/0003_signal_commands.js.map +1 -0
  329. package/dist/esm/migrations/0004_approval_decisions.d.ts +13 -0
  330. package/dist/esm/migrations/0004_approval_decisions.d.ts.map +1 -0
  331. package/dist/esm/migrations/0004_approval_decisions.js +25 -0
  332. package/dist/esm/migrations/0004_approval_decisions.js.map +1 -0
  333. package/dist/esm/migrations/0005_signal_principals.d.ts +18 -0
  334. package/dist/esm/migrations/0005_signal_principals.d.ts.map +1 -0
  335. package/dist/esm/migrations/0005_signal_principals.js +27 -0
  336. package/dist/esm/migrations/0005_signal_principals.js.map +1 -0
  337. package/dist/esm/migrations/0006_run_principals.d.ts +18 -0
  338. package/dist/esm/migrations/0006_run_principals.d.ts.map +1 -0
  339. package/dist/esm/migrations/0006_run_principals.js +30 -0
  340. package/dist/esm/migrations/0006_run_principals.js.map +1 -0
  341. package/dist/esm/migrations/0007_resume_consent.d.ts +18 -0
  342. package/dist/esm/migrations/0007_resume_consent.d.ts.map +1 -0
  343. package/dist/esm/migrations/0007_resume_consent.js +27 -0
  344. package/dist/esm/migrations/0007_resume_consent.js.map +1 -0
  345. package/dist/esm/test/TestControl.d.ts +19 -0
  346. package/dist/esm/test/TestControl.d.ts.map +1 -0
  347. package/dist/esm/test/TestControl.js +30 -0
  348. package/dist/esm/test/TestControl.js.map +1 -0
  349. package/docs/README.md +189 -0
  350. package/docs/api.md +982 -0
  351. package/docs/concepts/authority.md +109 -0
  352. package/docs/concepts/cancellation.md +129 -0
  353. package/docs/concepts/lineage.md +132 -0
  354. package/docs/concepts/ownership.md +139 -0
  355. package/docs/concepts/projections.md +203 -0
  356. package/docs/concepts/receipts.md +128 -0
  357. package/docs/guides/approvals.md +284 -0
  358. package/docs/guides/cancel-and-resume.md +162 -0
  359. package/docs/guides/durable-storage.md +147 -0
  360. package/docs/guides/implement-an-executor.md +173 -0
  361. package/docs/guides/ingest-a-webhook.md +177 -0
  362. package/docs/guides/list-runs.md +160 -0
  363. package/docs/guides/monitor-runs.md +176 -0
  364. package/docs/guides/observe-health.md +147 -0
  365. package/docs/guides/postgres-tests.md +5 -0
  366. package/docs/guides/serve-over-rpc.md +220 -0
  367. package/docs/guides/signal-a-run.md +53 -0
  368. package/docs/guides/steer-a-run.md +138 -0
  369. package/docs/guides/store-credentials.md +164 -0
  370. package/docs/guides/testing.md +139 -0
  371. package/docs/guides/watch-a-run.md +154 -0
  372. package/docs/installation.md +106 -0
  373. package/docs/quickstart.md +163 -0
  374. package/docs/troubleshooting.md +208 -0
  375. package/package.json +405 -3
  376. package/src/ApprovalAuthority.ts +114 -0
  377. package/src/Cancellation.ts +172 -0
  378. package/src/Channels.ts +493 -0
  379. package/src/Control.ts +337 -0
  380. package/src/ControlClient.ts +319 -0
  381. package/src/ControlError.ts +378 -0
  382. package/src/ControlExecutor.ts +490 -0
  383. package/src/ControlFacts.ts +383 -0
  384. package/src/ControlLive.ts +2113 -0
  385. package/src/ControlRpcs.ts +443 -0
  386. package/src/ControlRuntime.ts +1597 -0
  387. package/src/ControlSchema.ts +1380 -0
  388. package/src/ControlServer.ts +182 -0
  389. package/src/Credential.ts +310 -0
  390. package/src/CredentialCipher.ts +110 -0
  391. package/src/CredentialStore.ts +152 -0
  392. package/src/DispatchReader.ts +122 -0
  393. package/src/Health.ts +591 -0
  394. package/src/JevSessionChecker.ts +127 -0
  395. package/src/Lineage.ts +203 -0
  396. package/src/Migrations.ts +56 -0
  397. package/src/Monitor.ts +600 -0
  398. package/src/ScopedToken.ts +306 -0
  399. package/src/SqlControlRuntime.ts +2476 -0
  400. package/src/SqlCredentialStore.ts +148 -0
  401. package/src/Steering.ts +96 -0
  402. package/src/SystemFlows.ts +225 -0
  403. package/src/WebCryptoCipher.ts +169 -0
  404. package/src/WebhookChannel.ts +166 -0
  405. package/src/index.ts +188 -0
  406. package/src/internal/MutationBoundary.ts +46 -0
  407. package/src/internal/activeFibers.ts +22 -0
  408. package/src/internal/issues.ts +40 -0
  409. package/src/internal/planning.ts +262 -0
  410. package/src/internal/sqlSchemaErrors.ts +37 -0
  411. package/src/migrations/0001_control_tables.ts +99 -0
  412. package/src/migrations/0002_run_keys.ts +23 -0
  413. package/src/migrations/0003_signal_commands.ts +27 -0
  414. package/src/migrations/0004_approval_decisions.ts +25 -0
  415. package/src/migrations/0005_signal_principals.ts +27 -0
  416. package/src/migrations/0006_run_principals.ts +31 -0
  417. package/src/migrations/0007_resume_consent.ts +28 -0
  418. package/src/test/TestControl.ts +47 -0
@@ -0,0 +1,359 @@
1
+ /**
2
+ * Stable, schema-backed control-plane failures.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Fault from "@smthrs/flow/Fault";
7
+ import { NotificationError } from "@smthrs/notifications/NotificationQueue";
8
+ import { Effect, Schema } from "effect";
9
+ import { FlowId, RunHost, RunId } from "./ControlSchema.js";
10
+ const constantCode = (code) => Schema.Literal(code).pipe(Schema.withConstructorDefault(Effect.succeed(code)));
11
+ /**
12
+ * No run with this id exists.
13
+ *
14
+ * @category errors
15
+ * @since 0.1.0
16
+ */
17
+ export class RunNotFound extends Schema.TaggedError()("/control/RunNotFound", {
18
+ code: constantCode("run_not_found"),
19
+ runId: RunId
20
+ }) {
21
+ /**
22
+ * The sentence an operator reads. Without one the CLI printed the bare
23
+ * fields, `run_not_found runId=nope`, which names no next action.
24
+ */
25
+ get message() {
26
+ return `Run ${this.runId} was not found. Run \`smthrs runs list\` to see the runs you can read.`;
27
+ }
28
+ }
29
+ /**
30
+ * No plan with this id exists.
31
+ *
32
+ * @category errors
33
+ * @since 0.1.0
34
+ */
35
+ export class PlanNotFound extends Schema.TaggedError()("/control/PlanNotFound", {
36
+ code: constantCode("plan_not_found"),
37
+ planId: Schema.String
38
+ }) {
39
+ /**
40
+ * The sentence an operator reads. Every renderer in the tree prints
41
+ * `message`, so a refusal without one does not explain the next action.
42
+ */
43
+ get message() {
44
+ return `Plan ${this.planId} was not found. Create the plan again before approving or launching it.`;
45
+ }
46
+ }
47
+ /**
48
+ * The plan was denied and cannot be launched.
49
+ *
50
+ * @category errors
51
+ * @since 0.1.0
52
+ */
53
+ export class PlanDenied extends Schema.TaggedError()("/control/PlanDenied", {
54
+ code: constantCode("plan_denied"),
55
+ planId: Schema.String
56
+ }) {
57
+ /**
58
+ * The sentence an operator reads. Every renderer in the tree prints
59
+ * `message`, so a denial must state how to make a later launch possible.
60
+ */
61
+ get message() {
62
+ return `Plan ${this.planId} was denied and cannot be launched. Create and approve a new plan before running it.`;
63
+ }
64
+ }
65
+ /**
66
+ * No flow with this id is registered.
67
+ *
68
+ * @category errors
69
+ * @since 0.1.0
70
+ */
71
+ export class FlowNotFound extends Schema.TaggedError()("/control/FlowNotFound", {
72
+ code: constantCode("flow_not_found"),
73
+ flowId: FlowId
74
+ }) {
75
+ /**
76
+ * The sentence an operator reads, which names the command that lists the
77
+ * flows a caller can start.
78
+ */
79
+ get message() {
80
+ return `Flow ${this.flowId} is not registered. Run \`smthrs flow list\` to see the flows you can start.`;
81
+ }
82
+ }
83
+ /**
84
+ * The submitted plan does not hash to the digest the caller declared, so
85
+ * the control plane refuses to store it.
86
+ *
87
+ * @category errors
88
+ * @since 0.1.0
89
+ */
90
+ export class PlanDigestMismatch extends Schema.TaggedError()("/control/PlanDigestMismatch", {
91
+ code: constantCode("plan_digest_mismatch"),
92
+ planId: Schema.String,
93
+ expected: Schema.String,
94
+ actual: Schema.String
95
+ }) {
96
+ }
97
+ /**
98
+ * The plan's effect envelope differs from the one the caller declared.
99
+ *
100
+ * @category errors
101
+ * @since 0.1.0
102
+ */
103
+ export class EnvelopeMismatch extends Schema.TaggedError()("/control/EnvelopeMismatch", {
104
+ code: constantCode("envelope_mismatch"),
105
+ planId: Schema.String,
106
+ expected: Schema.String,
107
+ actual: Schema.String
108
+ }) {
109
+ }
110
+ /**
111
+ * The caller's claim on this run lapsed or was fenced by a newer owner.
112
+ *
113
+ * `parkedBy` names the live process that parked the run: it, not the caller,
114
+ * drives the run, so `Control.resume` hands the resume to it.
115
+ *
116
+ * @category errors
117
+ * @since 0.1.0
118
+ */
119
+ export class ClaimLost extends Schema.TaggedError()("/control/ClaimLost", {
120
+ code: constantCode("claim_lost"),
121
+ runId: RunId,
122
+ reason: Schema.optional(Schema.String),
123
+ parkedBy: Schema.optional(RunHost)
124
+ }) {
125
+ }
126
+ /**
127
+ * The run's flow or engine changed since the run started, so resuming it would
128
+ * run code the run did not start with. Pass `allowCodeDrift` to resume it
129
+ * anyway; the run then records the code it resumed on.
130
+ *
131
+ * @category errors
132
+ * @since 1.0.0
133
+ */
134
+ export class CodeDrift extends Schema.TaggedError()("/control/CodeDrift", {
135
+ code: constantCode("code_drift"),
136
+ runId: RunId,
137
+ flowId: FlowId,
138
+ /** The execution digest the run started with; absent when only the engine changed. */
139
+ recorded: Schema.optional(Schema.String),
140
+ /** The flow's execution digest now; absent when the flow is gone or declares none. */
141
+ current: Schema.optional(Schema.String),
142
+ /** The engine version the run started on, when the engine changed. */
143
+ recordedEngine: Schema.optional(Schema.String),
144
+ /** The engine version resuming it, when the engine changed. */
145
+ currentEngine: Schema.optional(Schema.String)
146
+ }) {
147
+ get message() {
148
+ const changes = [
149
+ ...(this.recorded === undefined
150
+ ? []
151
+ : [`${this.flowId} ${this.recorded}, which is now ${this.current ?? "gone"}`]),
152
+ ...(this.recordedEngine === undefined
153
+ ? []
154
+ : [`engine ${this.recordedEngine}, which is now ${this.currentEngine ?? "unknown"}`])
155
+ ];
156
+ // A flow that is gone has no code to adopt, so the flag would not help.
157
+ const next = this.recorded !== undefined && this.current === undefined
158
+ ? "Restore the flow to resume it."
159
+ : "Resume with --allow-code-drift to run the changed code.";
160
+ return `Run ${this.runId} started on ${changes.join(" and ")}. ${next}`;
161
+ }
162
+ }
163
+ /**
164
+ * This request was already answered; a second answer is refused rather
165
+ * than overwriting the first.
166
+ *
167
+ * @category errors
168
+ * @since 0.1.0
169
+ */
170
+ export class AlreadyResolved extends Schema.TaggedError()("/control/AlreadyResolved", {
171
+ code: constantCode("already_resolved"),
172
+ requestId: Schema.String
173
+ }) {
174
+ }
175
+ /**
176
+ * The request did not satisfy its schema or a stated precondition.
177
+ *
178
+ * @category errors
179
+ * @since 0.1.0
180
+ */
181
+ export class InvalidInput extends Schema.TaggedError()("/control/InvalidInput", {
182
+ code: constantCode("invalid_input"),
183
+ issue: Schema.String
184
+ }) {
185
+ }
186
+ /**
187
+ * The caller lacks a usable credential or authority for this operation.
188
+ *
189
+ * @category errors
190
+ * @since 0.1.0
191
+ */
192
+ export class Unauthorized extends Schema.TaggedError()("/control/Unauthorized", {
193
+ code: constantCode("unauthorized"),
194
+ message: Schema.String
195
+ }) {
196
+ }
197
+ /**
198
+ * The operation is not implemented in this deployment. `ticket` names the
199
+ * issue that tracks it, per `Concepts/Tickets Not Exceptions.md`.
200
+ *
201
+ * @category errors
202
+ * @since 0.1.0
203
+ */
204
+ export class Unavailable extends Schema.TaggedError()("/control/Unavailable", {
205
+ code: constantCode("unavailable"),
206
+ feature: Schema.String,
207
+ ticket: Schema.String
208
+ }) {
209
+ }
210
+ /**
211
+ * The request failed before a declared control response reached the caller.
212
+ *
213
+ * `retryable` classifies only the transport phase. Connection failures and
214
+ * HTTP 5xx responses are retryable; local encode failures, response decode
215
+ * failures, and HTTP 4xx responses are not. A caller may resend a retryable
216
+ * mutation only when its idempotency key makes replay safe. A keyless request
217
+ * can have reached the server even when its response was lost.
218
+ *
219
+ * `message` is a fixed operator-facing sentence. `cause` retains the original
220
+ * client failure for diagnostics without copying its raw text into output.
221
+ *
222
+ * @category errors
223
+ * @since 0.1.0
224
+ */
225
+ export class TransportError extends Schema.TaggedError()("/control/TransportError", {
226
+ code: constantCode("transport_error"),
227
+ message: Schema.String,
228
+ retryable: Schema.Boolean,
229
+ cause: Schema.optional(Schema.Defect())
230
+ }) {
231
+ }
232
+ /**
233
+ * A control-plane store operation failed.
234
+ *
235
+ * @category errors
236
+ * @since 0.1.0
237
+ */
238
+ export class PersistenceError extends Schema.TaggedError()("/control/PersistenceError", {
239
+ code: constantCode("persistence_failed"),
240
+ operation: Schema.String,
241
+ message: Schema.String,
242
+ cause: Schema.optional(Schema.Defect())
243
+ }) {
244
+ }
245
+ /**
246
+ * The executor refused or could not start the run.
247
+ *
248
+ * @category errors
249
+ * @since 0.1.0
250
+ */
251
+ export class LaunchFailed extends Schema.TaggedError()("/control/LaunchFailed", {
252
+ code: constantCode("launch_failed"),
253
+ runId: RunId,
254
+ message: Schema.String,
255
+ cause: Schema.optional(Schema.Defect())
256
+ }) {
257
+ }
258
+ /**
259
+ * A signal named a wait point the run does not have open.
260
+ *
261
+ * `Control.signal` completes the `WaitFor` deferred a run is parked on. A
262
+ * signal whose name matches no open wait point completes nothing, and recording
263
+ * it anyway would leave an operator watching a delivery that never lands, so it
264
+ * is refused where it arrives.
265
+ *
266
+ * The signal's name is `waitName`, not `name`. A field spelled `name` on an
267
+ * `Error` subclass shadows `Error.prototype.name`, which every renderer in the
268
+ * tree reads: `smithers signal run-3 '{"name":"go"}'` against a timer-parked
269
+ * run printed `go: ` to stderr and exited 1, because `bin.ts` reports
270
+ * `${error.name}: ${error.message}` and this class had overwritten one and
271
+ * defined neither (release validation, defect D3).
272
+ *
273
+ * @category errors
274
+ * @since 0.1.0
275
+ */
276
+ export class NoMatchingWait extends Schema.TaggedError()("/control/NoMatchingWait", {
277
+ code: constantCode("no_matching_wait"),
278
+ runId: RunId,
279
+ waitName: Schema.String
280
+ }) {
281
+ /**
282
+ * The sentence an operator reads. Every other renderer in the tree prints
283
+ * `message`, so a refusal with none is a refusal with no reason.
284
+ */
285
+ get message() {
286
+ return `no wait point named "${this.waitName}" is open on run ${this.runId}. ` +
287
+ `Read \`smthrs runs show ${this.runId}\` to see what that run is waiting for.`;
288
+ }
289
+ }
290
+ /**
291
+ * A credential write lost a race: the record moved on before this writer
292
+ * committed, so the update is refused rather than silently overwriting the
293
+ * winner.
294
+ *
295
+ * @since 0.1.0
296
+ * @category errors
297
+ */
298
+ export class CredentialConflict extends Schema.TaggedError()("/control/CredentialConflict", {
299
+ code: constantCode("credential_conflict"),
300
+ id: Schema.String,
301
+ expectedVersion: Schema.Number,
302
+ actualVersion: Schema.Number
303
+ }) {
304
+ }
305
+ /**
306
+ * Every stable failure emitted by the control plane, as one schema.
307
+ *
308
+ * This is the single membership list. The exported union type is derived from
309
+ * it and `ControlClient.isControlError` is `Schema.is` of it, so an error class
310
+ * added here reaches both. Two hand-maintained lists drifted: `ControlError`
311
+ * omitted `CredentialConflict` while the README documented it as a member, and
312
+ * `isControlError` repeated the same thirteen names a second time.
313
+ *
314
+ * @since 0.1.0
315
+ * @category errors
316
+ */
317
+ export const ControlErrorSchema = Schema.Union([
318
+ RunNotFound,
319
+ PlanNotFound,
320
+ PlanDenied,
321
+ FlowNotFound,
322
+ PlanDigestMismatch,
323
+ EnvelopeMismatch,
324
+ ClaimLost,
325
+ CodeDrift,
326
+ AlreadyResolved,
327
+ InvalidInput,
328
+ Unauthorized,
329
+ Unavailable,
330
+ TransportError,
331
+ PersistenceError,
332
+ LaunchFailed,
333
+ NoMatchingWait,
334
+ CredentialConflict,
335
+ NotificationError
336
+ ]);
337
+ // Whose problem each control refusal is when it ends a run.
338
+ for (const [tag, kind] of [
339
+ ["RunNotFound", "user"],
340
+ ["PlanNotFound", "user"],
341
+ ["PlanDenied", "user"],
342
+ ["FlowNotFound", "user"],
343
+ ["PlanDigestMismatch", "user"],
344
+ ["EnvelopeMismatch", "user"],
345
+ ["AlreadyResolved", "user"],
346
+ ["InvalidInput", "user"],
347
+ ["Unauthorized", "user"],
348
+ ["NoMatchingWait", "user"],
349
+ ["CredentialConflict", "user"],
350
+ // A flow without a model or an approved executable identity: the person's to fix.
351
+ ["LaunchFailed", "user"],
352
+ ["ClaimLost", "infra"],
353
+ ["CodeDrift", "infra"],
354
+ ["Unavailable", "infra"],
355
+ ["TransportError", "infra"],
356
+ ["PersistenceError", "infra"]
357
+ ])
358
+ Fault.register(`/control/${tag}`, kind);
359
+ //# sourceMappingURL=ControlError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ControlError.js","sourceRoot":"","sources":["../../src/ControlError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,YAAY,GAAG,CAA4B,IAAU,EAAE,EAAE,CAC7D,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAEhF;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,WAAW,EAAe,CAAC,sBAAsB,EAAE;IACzF,IAAI,EAAE,YAAY,CAAC,eAAe,CAAC;IACnC,KAAK,EAAE,KAAK;CACb,CAAC;IACA;;;OAGG;IACH,IAAa,OAAO;QAClB,OAAO,OAAO,IAAI,CAAC,KAAK,wEAAwE,CAAA;IAClG,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,EAAgB,CAAC,uBAAuB,EAAE;IAC5F,IAAI,EAAE,YAAY,CAAC,gBAAgB,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM;CACtB,CAAC;IACA;;;OAGG;IACH,I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AC,YAAY,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA","sourcesContent":["/**\n * Stable, schema-backed control-plane failures.\n *\n * @since 0.1.0\n */\n\nimport * as Fault from \"@smthrs/flow/Fault\"\nimport { NotificationError } from \"@smthrs/notifications/NotificationQueue\"\nimport { Effect, Schema } from \"effect\"\nimport { FlowId, RunHost, RunId } from \"./ControlSchema.ts\"\n\nconst constantCode = <const Code extends string>(code: Code) =>\n Schema.Literal(code).pipe(Schema.withConstructorDefault(Effect.succeed(code)))\n\n/**\n * No run with this id exists.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class RunNotFound extends Schema.TaggedError<RunNotFound>()(\"/control/RunNotFound\", {\n code: constantCode(\"run_not_found\"),\n runId: RunId\n}) {\n /**\n * The sentence an operator reads. Without one the CLI printed the bare\n * fields, `run_not_found runId=nope`, which names no next action.\n */\n override get message(): string {\n return `Run ${this.runId} was not found. Run \\`smthrs runs list\\` to see the runs you can read.`\n }\n}\n\n/**\n * No plan with this id exists.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class PlanNotFound extends Schema.TaggedError<PlanNotFound>()(\"/control/PlanNotFound\", {\n code: constantCode(\"plan_not_found\"),\n planId: Schema.String\n}) {\n /**\n * The sentence an operator reads. Every renderer in the tree prints\n * `message`, so a refusal without one does not explain the next action.\n */\n override get message(): string {\n return `Plan ${this.planId} was not found. Create the plan again before approving or launching it.`\n }\n}\n\n/**\n * The plan was denied and cannot be launched.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class PlanDenied extends Schema.TaggedError<PlanDenied>()(\"/control/PlanDenied\", {\n code: constantCode(\"plan_denied\"),\n planId: Schema.String\n}) {\n /**\n * The sentence an operator reads. Every renderer in the tree prints\n * `message`, so a denial must state how to make a later launch possible.\n */\n override get message(): string {\n return `Plan ${this.planId} was denied and cannot be launched. Create and approve a new plan before running it.`\n }\n}\n\n/**\n * No flow with this id is registered.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class FlowNotFound extends Schema.TaggedError<FlowNotFound>()(\"/control/FlowNotFound\", {\n code: constantCode(\"flow_not_found\"),\n flowId: FlowId\n}) {\n /**\n * The sentence an operator reads, which names the command that lists the\n * flows a caller can start.\n */\n override get message(): string {\n return `Flow ${this.flowId} is not registered. Run \\`smthrs flow list\\` to see the flows you can start.`\n }\n}\n\n/**\n * The submitted plan does not hash to the digest the caller declared, so\n * the control plane refuses to store it.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class PlanDigestMismatch extends Schema.TaggedError<PlanDigestMismatch>()(\"/control/PlanDigestMismatch\", {\n code: constantCode(\"plan_digest_mismatch\"),\n planId: Schema.String,\n expected: Schema.String,\n actual: Schema.String\n}) {}\n\n/**\n * The plan's effect envelope differs from the one the caller declared.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class EnvelopeMismatch extends Schema.TaggedError<EnvelopeMismatch>()(\"/control/EnvelopeMismatch\", {\n code: constantCode(\"envelope_mismatch\"),\n planId: Schema.String,\n expected: Schema.String,\n actual: Schema.String\n}) {}\n\n/**\n * The caller's claim on this run lapsed or was fenced by a newer owner.\n *\n * `parkedBy` names the live process that parked the run: it, not the caller,\n * drives the run, so `Control.resume` hands the resume to it.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class ClaimLost extends Schema.TaggedError<ClaimLost>()(\"/control/ClaimLost\", {\n code: constantCode(\"claim_lost\"),\n runId: RunId,\n reason: Schema.optional(Schema.String),\n parkedBy: Schema.optional(RunHost)\n}) {}\n\n/**\n * The run's flow or engine changed since the run started, so resuming it would\n * run code the run did not start with. Pass `allowCodeDrift` to resume it\n * anyway; the run then records the code it resumed on.\n *\n * @category errors\n * @since 1.0.0\n */\nexport class CodeDrift extends Schema.TaggedError<CodeDrift>()(\"/control/CodeDrift\", {\n code: constantCode(\"code_drift\"),\n runId: RunId,\n flowId: FlowId,\n /** The execution digest the run started with; absent when only the engine changed. */\n recorded: Schema.optional(Schema.String),\n /** The flow's execution digest now; absent when the flow is gone or declares none. */\n current: Schema.optional(Schema.String),\n /** The engine version the run started on, when the engine changed. */\n recordedEngine: Schema.optional(Schema.String),\n /** The engine version resuming it, when the engine changed. */\n currentEngine: Schema.optional(Schema.String)\n}) {\n override get message(): string {\n const changes = [\n ...(this.recorded === undefined\n ? []\n : [`${this.flowId} ${this.recorded}, which is now ${this.current ?? \"gone\"}`]),\n ...(this.recordedEngine === undefined\n ? []\n : [`engine ${this.recordedEngine}, which is now ${this.currentEngine ?? \"unknown\"}`])\n ]\n // A flow that is gone has no code to adopt, so the flag would not help.\n const next = this.recorded !== undefined && this.current === undefined\n ? \"Restore the flow to resume it.\"\n : \"Resume with --allow-code-drift to run the changed code.\"\n return `Run ${this.runId} started on ${changes.join(\" and \")}. ${next}`\n }\n}\n\n/**\n * This request was already answered; a second answer is refused rather\n * than overwriting the first.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class AlreadyResolved extends Schema.TaggedError<AlreadyResolved>()(\"/control/AlreadyResolved\", {\n code: constantCode(\"already_resolved\"),\n requestId: Schema.String\n}) {}\n\n/**\n * The request did not satisfy its schema or a stated precondition.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class InvalidInput extends Schema.TaggedError<InvalidInput>()(\"/control/InvalidInput\", {\n code: constantCode(\"invalid_input\"),\n issue: Schema.String\n}) {}\n\n/**\n * The caller lacks a usable credential or authority for this operation.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class Unauthorized extends Schema.TaggedError<Unauthorized>()(\"/control/Unauthorized\", {\n code: constantCode(\"unauthorized\"),\n message: Schema.String\n}) {}\n\n/**\n * The operation is not implemented in this deployment. `ticket` names the\n * issue that tracks it, per `Concepts/Tickets Not Exceptions.md`.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class Unavailable extends Schema.TaggedError<Unavailable>()(\"/control/Unavailable\", {\n code: constantCode(\"unavailable\"),\n feature: Schema.String,\n ticket: Schema.String\n}) {}\n\n/**\n * The request failed before a declared control response reached the caller.\n *\n * `retryable` classifies only the transport phase. Connection failures and\n * HTTP 5xx responses are retryable; local encode failures, response decode\n * failures, and HTTP 4xx responses are not. A caller may resend a retryable\n * mutation only when its idempotency key makes replay safe. A keyless request\n * can have reached the server even when its response was lost.\n *\n * `message` is a fixed operator-facing sentence. `cause` retains the original\n * client failure for diagnostics without copying its raw text into output.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class TransportError extends Schema.TaggedError<TransportError>()(\"/control/TransportError\", {\n code: constantCode(\"transport_error\"),\n message: Schema.String,\n retryable: Schema.Boolean,\n cause: Schema.optional(Schema.Defect())\n}) {}\n\n/**\n * A control-plane store operation failed.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class PersistenceError extends Schema.TaggedError<PersistenceError>()(\"/control/PersistenceError\", {\n code: constantCode(\"persistence_failed\"),\n operation: Schema.String,\n message: Schema.String,\n cause: Schema.optional(Schema.Defect())\n}) {}\n\n/**\n * The executor refused or could not start the run.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class LaunchFailed extends Schema.TaggedError<LaunchFailed>()(\"/control/LaunchFailed\", {\n code: constantCode(\"launch_failed\"),\n runId: RunId,\n message: Schema.String,\n cause: Schema.optional(Schema.Defect())\n}) {}\n\n/**\n * A signal named a wait point the run does not have open.\n *\n * `Control.signal` completes the `WaitFor` deferred a run is parked on. A\n * signal whose name matches no open wait point completes nothing, and recording\n * it anyway would leave an operator watching a delivery that never lands, so it\n * is refused where it arrives.\n *\n * The signal's name is `waitName`, not `name`. A field spelled `name` on an\n * `Error` subclass shadows `Error.prototype.name`, which every renderer in the\n * tree reads: `smithers signal run-3 '{\"name\":\"go\"}'` against a timer-parked\n * run printed `go: ` to stderr and exited 1, because `bin.ts` reports\n * `${error.name}: ${error.message}` and this class had overwritten one and\n * defined neither (release validation, defect D3).\n *\n * @category errors\n * @since 0.1.0\n */\nexport class NoMatchingWait extends Schema.TaggedError<NoMatchingWait>()(\"/control/NoMatchingWait\", {\n code: constantCode(\"no_matching_wait\"),\n runId: RunId,\n waitName: Schema.String\n}) {\n /**\n * The sentence an operator reads. Every other renderer in the tree prints\n * `message`, so a refusal with none is a refusal with no reason.\n */\n override get message(): string {\n return `no wait point named \"${this.waitName}\" is open on run ${this.runId}. ` +\n `Read \\`smthrs runs show ${this.runId}\\` to see what that run is waiting for.`\n }\n}\n\n/**\n * A credential write lost a race: the record moved on before this writer\n * committed, so the update is refused rather than silently overwriting the\n * winner.\n *\n * @since 0.1.0\n * @category errors\n */\nexport class CredentialConflict extends Schema.TaggedError<CredentialConflict>()(\"/control/CredentialConflict\", {\n code: constantCode(\"credential_conflict\"),\n id: Schema.String,\n expectedVersion: Schema.Number,\n actualVersion: Schema.Number\n}) {}\n\n/**\n * Every stable failure emitted by the control plane, as one schema.\n *\n * This is the single membership list. The exported union type is derived from\n * it and `ControlClient.isControlError` is `Schema.is` of it, so an error class\n * added here reaches both. Two hand-maintained lists drifted: `ControlError`\n * omitted `CredentialConflict` while the README documented it as a member, and\n * `isControlError` repeated the same thirteen names a second time.\n *\n * @since 0.1.0\n * @category errors\n */\nexport const ControlErrorSchema = Schema.Union([\n RunNotFound,\n PlanNotFound,\n PlanDenied,\n FlowNotFound,\n PlanDigestMismatch,\n EnvelopeMismatch,\n ClaimLost,\n CodeDrift,\n AlreadyResolved,\n InvalidInput,\n Unauthorized,\n Unavailable,\n TransportError,\n PersistenceError,\n LaunchFailed,\n NoMatchingWait,\n CredentialConflict,\n NotificationError\n])\n\n/**\n * Every stable failure emitted by the control plane.\n *\n * @since 0.1.0\n * @category errors\n */\nexport type ControlError = typeof ControlErrorSchema.Type\n\n// Whose problem each control refusal is when it ends a run.\nfor (\n const [tag, kind] of [\n [\"RunNotFound\", \"user\"],\n [\"PlanNotFound\", \"user\"],\n [\"PlanDenied\", \"user\"],\n [\"FlowNotFound\", \"user\"],\n [\"PlanDigestMismatch\", \"user\"],\n [\"EnvelopeMismatch\", \"user\"],\n [\"AlreadyResolved\", \"user\"],\n [\"InvalidInput\", \"user\"],\n [\"Unauthorized\", \"user\"],\n [\"NoMatchingWait\", \"user\"],\n [\"CredentialConflict\", \"user\"],\n // A flow without a model or an approved executable identity: the person's to fix.\n [\"LaunchFailed\", \"user\"],\n [\"ClaimLost\", \"infra\"],\n [\"CodeDrift\", \"infra\"],\n [\"Unavailable\", \"infra\"],\n [\"TransportError\", \"infra\"],\n [\"PersistenceError\", \"infra\"]\n ] as const\n) Fault.register(`/control/${tag}`, kind)\n"]}