effect-start 0.27.0 → 0.28.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 (633) hide show
  1. package/dist/ChildProcess.d.ts +60 -0
  2. package/dist/ChildProcess.d.ts.map +1 -0
  3. package/dist/ChildProcess.js +30 -0
  4. package/dist/ChildProcess.js.map +1 -0
  5. package/dist/Commander.d.ts +101 -0
  6. package/dist/Commander.d.ts.map +1 -0
  7. package/dist/Commander.js +327 -0
  8. package/dist/Commander.js.map +1 -0
  9. package/dist/ContentNegotiation.d.ts +13 -0
  10. package/dist/ContentNegotiation.d.ts.map +1 -0
  11. package/dist/ContentNegotiation.js +360 -0
  12. package/dist/ContentNegotiation.js.map +1 -0
  13. package/dist/Cookies.d.ts +78 -0
  14. package/dist/Cookies.d.ts.map +1 -0
  15. package/dist/Cookies.js +303 -0
  16. package/dist/Cookies.js.map +1 -0
  17. package/dist/Development.d.ts +42 -0
  18. package/dist/Development.d.ts.map +1 -0
  19. package/dist/Development.js +60 -0
  20. package/dist/Development.js.map +1 -0
  21. package/dist/Docker.d.ts +51 -0
  22. package/dist/Docker.d.ts.map +1 -0
  23. package/dist/Docker.js +88 -0
  24. package/dist/Docker.js.map +1 -0
  25. package/dist/Effectify.d.ts +210 -0
  26. package/dist/Effectify.d.ts.map +1 -0
  27. package/dist/Effectify.js +20 -0
  28. package/dist/Effectify.js.map +1 -0
  29. package/dist/Entity.d.ts +48 -0
  30. package/dist/Entity.d.ts.map +1 -0
  31. package/dist/Entity.js +235 -0
  32. package/dist/Entity.js.map +1 -0
  33. package/dist/Fetch.d.ts +50 -0
  34. package/dist/Fetch.d.ts.map +1 -0
  35. package/dist/Fetch.js +136 -0
  36. package/dist/Fetch.js.map +1 -0
  37. package/dist/FilePathPattern.d.ts +30 -0
  38. package/dist/FilePathPattern.d.ts.map +1 -0
  39. package/dist/FilePathPattern.js +87 -0
  40. package/dist/FilePathPattern.js.map +1 -0
  41. package/dist/FileRouter.d.ts +57 -0
  42. package/dist/FileRouter.d.ts.map +1 -0
  43. package/dist/FileRouter.js +149 -0
  44. package/dist/FileRouter.js.map +1 -0
  45. package/dist/FileRouterCodegen.d.ts +19 -0
  46. package/dist/FileRouterCodegen.d.ts.map +1 -0
  47. package/dist/FileRouterCodegen.js +228 -0
  48. package/dist/FileRouterCodegen.js.map +1 -0
  49. package/dist/FileSystem.d.ts +159 -0
  50. package/dist/FileSystem.d.ts.map +1 -0
  51. package/dist/FileSystem.js +71 -0
  52. package/dist/FileSystem.js.map +1 -0
  53. package/dist/GlobalLayer.d.ts +4 -0
  54. package/dist/GlobalLayer.d.ts.map +1 -0
  55. package/dist/GlobalLayer.js +51 -0
  56. package/dist/GlobalLayer.js.map +1 -0
  57. package/dist/Http.d.ts +38 -0
  58. package/dist/Http.d.ts.map +1 -0
  59. package/dist/Http.js +89 -0
  60. package/dist/Http.js.map +1 -0
  61. package/dist/PathPattern.d.ts +135 -0
  62. package/dist/PathPattern.d.ts.map +1 -0
  63. package/dist/PathPattern.js +414 -0
  64. package/dist/PathPattern.js.map +1 -0
  65. package/dist/PlatformError.d.ts +39 -0
  66. package/dist/PlatformError.d.ts.map +1 -0
  67. package/dist/PlatformError.js +26 -0
  68. package/dist/PlatformError.js.map +1 -0
  69. package/dist/PlatformRuntime.d.ts +30 -0
  70. package/dist/PlatformRuntime.d.ts.map +1 -0
  71. package/dist/PlatformRuntime.js +50 -0
  72. package/dist/PlatformRuntime.js.map +1 -0
  73. package/dist/Route.d.ts +98 -0
  74. package/dist/Route.d.ts.map +1 -0
  75. package/dist/Route.js +101 -0
  76. package/dist/Route.js.map +1 -0
  77. package/dist/RouteBody.d.ts +48 -0
  78. package/dist/RouteBody.d.ts.map +1 -0
  79. package/dist/RouteBody.js +68 -0
  80. package/dist/RouteBody.js.map +1 -0
  81. package/dist/RouteError.d.ts +99 -0
  82. package/dist/RouteError.d.ts.map +1 -0
  83. package/dist/RouteError.js +56 -0
  84. package/dist/RouteError.js.map +1 -0
  85. package/dist/RouteHook.d.ts +13 -0
  86. package/dist/RouteHook.d.ts.map +1 -0
  87. package/dist/RouteHook.js +40 -0
  88. package/dist/RouteHook.js.map +1 -0
  89. package/dist/RouteHttp.d.ts +22 -0
  90. package/dist/RouteHttp.d.ts.map +1 -0
  91. package/dist/RouteHttp.js +259 -0
  92. package/dist/RouteHttp.js.map +1 -0
  93. package/dist/RouteHttpTracer.d.ts +11 -0
  94. package/dist/RouteHttpTracer.d.ts.map +1 -0
  95. package/dist/RouteHttpTracer.js +63 -0
  96. package/dist/RouteHttpTracer.js.map +1 -0
  97. package/dist/RouteMount.d.ts +87 -0
  98. package/dist/RouteMount.d.ts.map +1 -0
  99. package/dist/RouteMount.js +64 -0
  100. package/dist/RouteMount.js.map +1 -0
  101. package/dist/RouteSchema.d.ts +87 -0
  102. package/dist/RouteSchema.d.ts.map +1 -0
  103. package/dist/RouteSchema.js +189 -0
  104. package/dist/RouteSchema.js.map +1 -0
  105. package/dist/RouteSse.d.ts +22 -0
  106. package/dist/RouteSse.d.ts.map +1 -0
  107. package/dist/RouteSse.js +80 -0
  108. package/dist/RouteSse.js.map +1 -0
  109. package/dist/RouteTree.d.ts +58 -0
  110. package/dist/RouteTree.d.ts.map +1 -0
  111. package/dist/RouteTree.js +94 -0
  112. package/dist/RouteTree.js.map +1 -0
  113. package/dist/RouteTrie.d.ts +21 -0
  114. package/dist/RouteTrie.d.ts.map +1 -0
  115. package/dist/RouteTrie.js +153 -0
  116. package/dist/RouteTrie.js.map +1 -0
  117. package/dist/SchemaExtra.d.ts +8 -0
  118. package/dist/SchemaExtra.d.ts.map +1 -0
  119. package/dist/SchemaExtra.js +75 -0
  120. package/dist/SchemaExtra.js.map +1 -0
  121. package/dist/Socket.d.ts +28 -0
  122. package/dist/Socket.d.ts.map +1 -0
  123. package/dist/Socket.js +30 -0
  124. package/dist/Socket.js.map +1 -0
  125. package/dist/SqlIntrospect.d.ts +92 -0
  126. package/dist/SqlIntrospect.d.ts.map +1 -0
  127. package/dist/SqlIntrospect.js +478 -0
  128. package/dist/SqlIntrospect.js.map +1 -0
  129. package/dist/Start.d.ts +90 -0
  130. package/dist/Start.d.ts.map +1 -0
  131. package/dist/Start.js +91 -0
  132. package/dist/Start.js.map +1 -0
  133. package/dist/StartApp.d.ts +13 -0
  134. package/dist/StartApp.d.ts.map +1 -0
  135. package/dist/StartApp.js +4 -0
  136. package/dist/StartApp.js.map +1 -0
  137. package/dist/StreamExtra.d.ts +29 -0
  138. package/dist/StreamExtra.d.ts.map +1 -0
  139. package/dist/StreamExtra.js +101 -0
  140. package/dist/StreamExtra.js.map +1 -0
  141. package/dist/System.d.ts +9 -0
  142. package/dist/System.d.ts.map +1 -0
  143. package/dist/System.js +61 -0
  144. package/dist/System.js.map +1 -0
  145. package/dist/TuplePathPattern.d.ts +10 -0
  146. package/dist/TuplePathPattern.d.ts.map +1 -0
  147. package/dist/TuplePathPattern.js +69 -0
  148. package/dist/TuplePathPattern.js.map +1 -0
  149. package/dist/Unique.d.ts +68 -0
  150. package/dist/Unique.d.ts.map +1 -0
  151. package/dist/Unique.js +225 -0
  152. package/dist/Unique.js.map +1 -0
  153. package/dist/Values.d.ts +30 -0
  154. package/dist/Values.d.ts.map +1 -0
  155. package/dist/Values.js +46 -0
  156. package/dist/Values.js.map +1 -0
  157. package/dist/bun/BunBundle.d.ts +12 -0
  158. package/dist/bun/BunBundle.d.ts.map +1 -0
  159. package/dist/bun/BunBundle.js +138 -0
  160. package/dist/bun/BunBundle.js.map +1 -0
  161. package/dist/bun/BunChildProcessSpawner.d.ts +4 -0
  162. package/dist/bun/BunChildProcessSpawner.d.ts.map +1 -0
  163. package/dist/bun/BunChildProcessSpawner.js +99 -0
  164. package/dist/bun/BunChildProcessSpawner.js.map +1 -0
  165. package/dist/bun/BunImportTrackerPlugin.d.ts +14 -0
  166. package/dist/bun/BunImportTrackerPlugin.d.ts.map +1 -0
  167. package/dist/bun/BunImportTrackerPlugin.js +70 -0
  168. package/dist/bun/BunImportTrackerPlugin.js.map +1 -0
  169. package/dist/bun/BunRoute.d.ts +49 -0
  170. package/dist/bun/BunRoute.d.ts.map +1 -0
  171. package/dist/bun/BunRoute.js +122 -0
  172. package/dist/bun/BunRoute.js.map +1 -0
  173. package/dist/bun/BunRuntime.d.ts +3 -0
  174. package/dist/bun/BunRuntime.d.ts.map +1 -0
  175. package/dist/bun/BunRuntime.js +30 -0
  176. package/dist/bun/BunRuntime.js.map +1 -0
  177. package/dist/bun/BunServer.d.ts +52 -0
  178. package/dist/bun/BunServer.d.ts.map +1 -0
  179. package/dist/bun/BunServer.js +262 -0
  180. package/dist/bun/BunServer.js.map +1 -0
  181. package/dist/bun/BunVirtualFilesPlugin.d.ts +5 -0
  182. package/dist/bun/BunVirtualFilesPlugin.d.ts.map +1 -0
  183. package/dist/bun/BunVirtualFilesPlugin.js +41 -0
  184. package/dist/bun/BunVirtualFilesPlugin.js.map +1 -0
  185. package/dist/bun/_BunEnhancedResolve.d.ts +46 -0
  186. package/dist/bun/_BunEnhancedResolve.d.ts.map +1 -0
  187. package/dist/bun/_BunEnhancedResolve.js +103 -0
  188. package/dist/bun/_BunEnhancedResolve.js.map +1 -0
  189. package/dist/bun/index.d.ts +6 -0
  190. package/dist/bun/index.d.ts.map +1 -0
  191. package/dist/bun/index.js +6 -0
  192. package/dist/bun/index.js.map +1 -0
  193. package/dist/bundler/Bundle.d.ts +62 -0
  194. package/dist/bundler/Bundle.d.ts.map +1 -0
  195. package/dist/bundler/Bundle.js +49 -0
  196. package/dist/bundler/Bundle.js.map +1 -0
  197. package/dist/bundler/BundleFiles.d.ts +14 -0
  198. package/dist/bundler/BundleFiles.d.ts.map +1 -0
  199. package/dist/bundler/BundleFiles.js +97 -0
  200. package/dist/bundler/BundleFiles.js.map +1 -0
  201. package/dist/bundler/BundleRoute.d.ts +27 -0
  202. package/dist/bundler/BundleRoute.d.ts.map +1 -0
  203. package/dist/bundler/BundleRoute.js +52 -0
  204. package/dist/bundler/BundleRoute.js.map +1 -0
  205. package/dist/client/Overlay.d.ts +3 -0
  206. package/dist/client/Overlay.d.ts.map +1 -0
  207. package/dist/client/Overlay.js +33 -0
  208. package/dist/client/Overlay.js.map +1 -0
  209. package/dist/client/ScrollState.d.ts +7 -0
  210. package/dist/client/ScrollState.d.ts.map +1 -0
  211. package/dist/client/ScrollState.js +95 -0
  212. package/dist/client/ScrollState.js.map +1 -0
  213. package/dist/client/index.d.ts +7 -0
  214. package/dist/client/index.d.ts.map +1 -0
  215. package/dist/client/index.js +80 -0
  216. package/dist/client/index.js.map +1 -0
  217. package/dist/datastar/actions/fetch.d.ts +31 -0
  218. package/dist/datastar/actions/fetch.d.ts.map +1 -0
  219. package/dist/datastar/actions/fetch.js +404 -0
  220. package/dist/datastar/actions/fetch.js.map +1 -0
  221. package/dist/datastar/actions/peek.d.ts +2 -0
  222. package/dist/datastar/actions/peek.d.ts.map +1 -0
  223. package/dist/datastar/actions/peek.js +14 -0
  224. package/dist/datastar/actions/peek.js.map +1 -0
  225. package/dist/datastar/actions/setAll.d.ts +2 -0
  226. package/dist/datastar/actions/setAll.d.ts.map +1 -0
  227. package/dist/datastar/actions/setAll.js +13 -0
  228. package/dist/datastar/actions/setAll.js.map +1 -0
  229. package/dist/datastar/actions/toggleAll.d.ts +2 -0
  230. package/dist/datastar/actions/toggleAll.d.ts.map +1 -0
  231. package/dist/datastar/actions/toggleAll.js +13 -0
  232. package/dist/datastar/actions/toggleAll.js.map +1 -0
  233. package/dist/datastar/attributes/attr.d.ts +2 -0
  234. package/dist/datastar/attributes/attr.d.ts.map +1 -0
  235. package/dist/datastar/attributes/attr.js +49 -0
  236. package/dist/datastar/attributes/attr.js.map +1 -0
  237. package/dist/datastar/attributes/bind.d.ts +2 -0
  238. package/dist/datastar/attributes/bind.d.ts.map +1 -0
  239. package/dist/datastar/attributes/bind.js +176 -0
  240. package/dist/datastar/attributes/bind.js.map +1 -0
  241. package/dist/datastar/attributes/class.d.ts +2 -0
  242. package/dist/datastar/attributes/class.d.ts.map +1 -0
  243. package/dist/datastar/attributes/class.js +48 -0
  244. package/dist/datastar/attributes/class.js.map +1 -0
  245. package/dist/datastar/attributes/computed.d.ts +2 -0
  246. package/dist/datastar/attributes/computed.d.ts.map +1 -0
  247. package/dist/datastar/attributes/computed.js +27 -0
  248. package/dist/datastar/attributes/computed.js.map +1 -0
  249. package/dist/datastar/attributes/effect.d.ts +2 -0
  250. package/dist/datastar/attributes/effect.d.ts.map +1 -0
  251. package/dist/datastar/attributes/effect.js +10 -0
  252. package/dist/datastar/attributes/effect.js.map +1 -0
  253. package/dist/datastar/attributes/indicator.d.ts +2 -0
  254. package/dist/datastar/attributes/indicator.d.ts.map +1 -0
  255. package/dist/datastar/attributes/indicator.js +31 -0
  256. package/dist/datastar/attributes/indicator.js.map +1 -0
  257. package/dist/datastar/attributes/init.d.ts +2 -0
  258. package/dist/datastar/attributes/init.d.ts.map +1 -0
  259. package/dist/datastar/attributes/init.js +27 -0
  260. package/dist/datastar/attributes/init.js.map +1 -0
  261. package/dist/datastar/attributes/jsonSignals.d.ts +2 -0
  262. package/dist/datastar/attributes/jsonSignals.d.ts.map +1 -0
  263. package/dist/datastar/attributes/jsonSignals.js +31 -0
  264. package/dist/datastar/attributes/jsonSignals.js.map +1 -0
  265. package/dist/datastar/attributes/on.d.ts +2 -0
  266. package/dist/datastar/attributes/on.d.ts.map +1 -0
  267. package/dist/datastar/attributes/on.js +79 -0
  268. package/dist/datastar/attributes/on.js.map +1 -0
  269. package/dist/datastar/attributes/onIntersect.d.ts +2 -0
  270. package/dist/datastar/attributes/onIntersect.d.ts.map +1 -0
  271. package/dist/datastar/attributes/onIntersect.js +54 -0
  272. package/dist/datastar/attributes/onIntersect.js.map +1 -0
  273. package/dist/datastar/attributes/onInterval.d.ts +2 -0
  274. package/dist/datastar/attributes/onInterval.d.ts.map +1 -0
  275. package/dist/datastar/attributes/onInterval.js +31 -0
  276. package/dist/datastar/attributes/onInterval.js.map +1 -0
  277. package/dist/datastar/attributes/onSignalPatch.d.ts +2 -0
  278. package/dist/datastar/attributes/onSignalPatch.d.ts.map +1 -0
  279. package/dist/datastar/attributes/onSignalPatch.js +43 -0
  280. package/dist/datastar/attributes/onSignalPatch.js.map +1 -0
  281. package/dist/datastar/attributes/ref.d.ts +2 -0
  282. package/dist/datastar/attributes/ref.d.ts.map +1 -0
  283. package/dist/datastar/attributes/ref.js +11 -0
  284. package/dist/datastar/attributes/ref.js.map +1 -0
  285. package/dist/datastar/attributes/show.d.ts +2 -0
  286. package/dist/datastar/attributes/show.d.ts.map +1 -0
  287. package/dist/datastar/attributes/show.js +32 -0
  288. package/dist/datastar/attributes/show.js.map +1 -0
  289. package/dist/datastar/attributes/signals.d.ts +2 -0
  290. package/dist/datastar/attributes/signals.d.ts.map +1 -0
  291. package/dist/datastar/attributes/signals.js +18 -0
  292. package/dist/datastar/attributes/signals.js.map +1 -0
  293. package/dist/datastar/attributes/style.d.ts +2 -0
  294. package/dist/datastar/attributes/style.d.ts.map +1 -0
  295. package/dist/datastar/attributes/style.js +51 -0
  296. package/dist/datastar/attributes/style.js.map +1 -0
  297. package/dist/datastar/attributes/text.d.ts +2 -0
  298. package/dist/datastar/attributes/text.d.ts.map +1 -0
  299. package/dist/datastar/attributes/text.js +27 -0
  300. package/dist/datastar/attributes/text.js.map +1 -0
  301. package/dist/datastar/engine.d.ts +163 -0
  302. package/dist/datastar/engine.d.ts.map +1 -0
  303. package/dist/datastar/engine.js +1000 -0
  304. package/dist/datastar/engine.js.map +1 -0
  305. package/dist/datastar/index.d.ts +25 -0
  306. package/dist/datastar/index.d.ts.map +1 -0
  307. package/dist/datastar/index.js +25 -0
  308. package/dist/datastar/index.js.map +1 -0
  309. package/dist/datastar/utils.d.ts +52 -0
  310. package/dist/datastar/utils.d.ts.map +1 -0
  311. package/dist/datastar/utils.js +203 -0
  312. package/dist/datastar/utils.js.map +1 -0
  313. package/dist/datastar/watchers/patchElements.d.ts +2 -0
  314. package/dist/datastar/watchers/patchElements.d.ts.map +1 -0
  315. package/dist/datastar/watchers/patchElements.js +398 -0
  316. package/dist/datastar/watchers/patchElements.js.map +1 -0
  317. package/dist/datastar/watchers/patchSignals.d.ts +2 -0
  318. package/dist/datastar/watchers/patchSignals.d.ts.map +1 -0
  319. package/dist/datastar/watchers/patchSignals.js +15 -0
  320. package/dist/datastar/watchers/patchSignals.js.map +1 -0
  321. package/dist/experimental/EncryptedCookies.d.ts +49 -0
  322. package/dist/experimental/EncryptedCookies.d.ts.map +1 -0
  323. package/dist/experimental/EncryptedCookies.js +213 -0
  324. package/dist/experimental/EncryptedCookies.js.map +1 -0
  325. package/dist/experimental/index.d.ts +2 -0
  326. package/dist/experimental/index.d.ts.map +1 -0
  327. package/dist/experimental/index.js +2 -0
  328. package/dist/experimental/index.js.map +1 -0
  329. package/dist/hyper/Hyper.d.ts +26 -0
  330. package/dist/hyper/Hyper.d.ts.map +1 -0
  331. package/dist/hyper/Hyper.js +24 -0
  332. package/dist/hyper/Hyper.js.map +1 -0
  333. package/dist/hyper/HyperHtml.d.ts +24 -0
  334. package/dist/hyper/HyperHtml.d.ts.map +1 -0
  335. package/dist/hyper/HyperHtml.js +153 -0
  336. package/dist/hyper/HyperHtml.js.map +1 -0
  337. package/dist/hyper/HyperHtml.test.d.ts +2 -0
  338. package/dist/hyper/HyperHtml.test.d.ts.map +1 -0
  339. package/dist/hyper/HyperHtml.test.js +283 -0
  340. package/dist/hyper/HyperHtml.test.js.map +1 -0
  341. package/dist/hyper/HyperNode.d.ts +15 -0
  342. package/dist/hyper/HyperNode.d.ts.map +1 -0
  343. package/dist/hyper/HyperNode.js +12 -0
  344. package/dist/hyper/HyperNode.js.map +1 -0
  345. package/dist/hyper/HyperRoute.d.ts +9 -0
  346. package/dist/hyper/HyperRoute.d.ts.map +1 -0
  347. package/dist/hyper/HyperRoute.js +33 -0
  348. package/dist/hyper/HyperRoute.js.map +1 -0
  349. package/dist/hyper/HyperRoute.test.d.ts +2 -0
  350. package/dist/hyper/HyperRoute.test.d.ts.map +1 -0
  351. package/dist/hyper/HyperRoute.test.js +86 -0
  352. package/dist/hyper/HyperRoute.test.js.map +1 -0
  353. package/dist/hyper/html.d.ts +11 -0
  354. package/dist/hyper/html.d.ts.map +1 -0
  355. package/dist/hyper/html.js +31 -0
  356. package/dist/hyper/html.js.map +1 -0
  357. package/dist/hyper/index.d.ts +7 -0
  358. package/dist/hyper/index.d.ts.map +1 -0
  359. package/dist/hyper/index.js +6 -0
  360. package/dist/hyper/index.js.map +1 -0
  361. package/dist/hyper/jsx-runtime.d.ts +8 -0
  362. package/dist/hyper/jsx-runtime.d.ts.map +1 -0
  363. package/dist/hyper/jsx-runtime.js +9 -0
  364. package/dist/hyper/jsx-runtime.js.map +1 -0
  365. package/dist/index.d.ts +9 -0
  366. package/dist/index.d.ts.map +1 -0
  367. package/dist/index.js +9 -0
  368. package/dist/index.js.map +1 -0
  369. package/dist/lint/plugin.d.ts +121 -0
  370. package/dist/lint/plugin.d.ts.map +1 -0
  371. package/dist/lint/plugin.js +537 -0
  372. package/dist/lint/plugin.js.map +1 -0
  373. package/dist/node/NodeFileSystem.d.ts +8 -0
  374. package/dist/node/NodeFileSystem.d.ts.map +1 -0
  375. package/dist/node/NodeFileSystem.js +411 -0
  376. package/dist/node/NodeFileSystem.js.map +1 -0
  377. package/dist/node/NodeUtils.d.ts +3 -0
  378. package/dist/node/NodeUtils.d.ts.map +1 -0
  379. package/dist/node/NodeUtils.js +21 -0
  380. package/dist/node/NodeUtils.js.map +1 -0
  381. package/dist/sql/SqlCache.d.ts +18 -0
  382. package/dist/sql/SqlCache.d.ts.map +1 -0
  383. package/dist/sql/SqlCache.js +31 -0
  384. package/dist/sql/SqlCache.js.map +1 -0
  385. package/dist/sql/SqlClient.d.ts +88 -0
  386. package/dist/sql/SqlClient.d.ts.map +1 -0
  387. package/dist/sql/SqlClient.js +171 -0
  388. package/dist/sql/SqlClient.js.map +1 -0
  389. package/dist/sql/bun/index.d.ts +6 -0
  390. package/dist/sql/bun/index.d.ts.map +1 -0
  391. package/dist/sql/bun/index.js +132 -0
  392. package/dist/sql/bun/index.js.map +1 -0
  393. package/dist/sql/index.d.ts +3 -0
  394. package/dist/sql/index.d.ts.map +1 -0
  395. package/dist/sql/index.js +3 -0
  396. package/dist/sql/index.js.map +1 -0
  397. package/dist/sql/libsql/index.d.ts +15 -0
  398. package/dist/sql/libsql/index.d.ts.map +1 -0
  399. package/dist/sql/libsql/index.js +132 -0
  400. package/dist/sql/libsql/index.js.map +1 -0
  401. package/dist/sql/mssql/index.d.ts +8 -0
  402. package/dist/sql/mssql/index.d.ts.map +1 -0
  403. package/dist/sql/mssql/index.js +145 -0
  404. package/dist/sql/mssql/index.js.map +1 -0
  405. package/dist/sql/postgres/index.d.ts +7 -0
  406. package/dist/sql/postgres/index.d.ts.map +1 -0
  407. package/dist/sql/postgres/index.js +136 -0
  408. package/dist/sql/postgres/index.js.map +1 -0
  409. package/dist/testing/TestLogger.d.ts +14 -0
  410. package/dist/testing/TestLogger.d.ts.map +1 -0
  411. package/dist/testing/TestLogger.js +33 -0
  412. package/dist/testing/TestLogger.js.map +1 -0
  413. package/dist/testing/index.d.ts +3 -0
  414. package/dist/testing/index.d.ts.map +1 -0
  415. package/dist/testing/index.js +3 -0
  416. package/dist/testing/index.js.map +1 -0
  417. package/dist/testing/utils.d.ts +10 -0
  418. package/dist/testing/utils.d.ts.map +1 -0
  419. package/dist/testing/utils.js +40 -0
  420. package/dist/testing/utils.js.map +1 -0
  421. package/dist/tower/Simulation.d.ts +3 -0
  422. package/dist/tower/Simulation.d.ts.map +1 -0
  423. package/dist/tower/Simulation.js +606 -0
  424. package/dist/tower/Simulation.js.map +1 -0
  425. package/dist/tower/Tower.d.ts +11 -0
  426. package/dist/tower/Tower.d.ts.map +1 -0
  427. package/dist/tower/Tower.js +30 -0
  428. package/dist/tower/Tower.js.map +1 -0
  429. package/dist/tower/TowerErrors.d.ts +4 -0
  430. package/dist/tower/TowerErrors.d.ts.map +1 -0
  431. package/dist/tower/TowerErrors.js +200 -0
  432. package/dist/tower/TowerErrors.js.map +1 -0
  433. package/dist/tower/TowerLogger.d.ts +2 -0
  434. package/dist/tower/TowerLogger.d.ts.map +1 -0
  435. package/dist/tower/TowerLogger.js +46 -0
  436. package/dist/tower/TowerLogger.js.map +1 -0
  437. package/dist/tower/TowerMetrics.d.ts +4 -0
  438. package/dist/tower/TowerMetrics.d.ts.map +1 -0
  439. package/dist/tower/TowerMetrics.js +62 -0
  440. package/dist/tower/TowerMetrics.js.map +1 -0
  441. package/dist/tower/TowerProcess.d.ts +4 -0
  442. package/dist/tower/TowerProcess.d.ts.map +1 -0
  443. package/dist/tower/TowerProcess.js +50 -0
  444. package/dist/tower/TowerProcess.js.map +1 -0
  445. package/dist/tower/TowerStore.d.ts +199 -0
  446. package/dist/tower/TowerStore.d.ts.map +1 -0
  447. package/dist/tower/TowerStore.js +307 -0
  448. package/dist/tower/TowerStore.js.map +1 -0
  449. package/dist/tower/TowerTracer.d.ts +4 -0
  450. package/dist/tower/TowerTracer.d.ts.map +1 -0
  451. package/dist/tower/TowerTracer.js +111 -0
  452. package/dist/tower/TowerTracer.js.map +1 -0
  453. package/dist/tower/index.d.ts +4 -0
  454. package/dist/tower/index.d.ts.map +1 -0
  455. package/dist/tower/index.js +4 -0
  456. package/dist/tower/index.js.map +1 -0
  457. package/dist/tower/routes/errors/route.d.ts +11 -0
  458. package/dist/tower/routes/errors/route.d.ts.map +1 -0
  459. package/dist/tower/routes/errors/route.js +47 -0
  460. package/dist/tower/routes/errors/route.js.map +1 -0
  461. package/dist/tower/routes/fiberDetail.d.ts +17 -0
  462. package/dist/tower/routes/fiberDetail.d.ts.map +1 -0
  463. package/dist/tower/routes/fiberDetail.js +35 -0
  464. package/dist/tower/routes/fiberDetail.js.map +1 -0
  465. package/dist/tower/routes/fibers/route.d.ts +11 -0
  466. package/dist/tower/routes/fibers/route.d.ts.map +1 -0
  467. package/dist/tower/routes/fibers/route.js +27 -0
  468. package/dist/tower/routes/fibers/route.js.map +1 -0
  469. package/dist/tower/routes/layout.d.ts +10 -0
  470. package/dist/tower/routes/layout.d.ts.map +1 -0
  471. package/dist/tower/routes/layout.js +4 -0
  472. package/dist/tower/routes/layout.js.map +1 -0
  473. package/dist/tower/routes/logs/route.d.ts +11 -0
  474. package/dist/tower/routes/logs/route.d.ts.map +1 -0
  475. package/dist/tower/routes/logs/route.js +36 -0
  476. package/dist/tower/routes/logs/route.js.map +1 -0
  477. package/dist/tower/routes/metrics/route.d.ts +11 -0
  478. package/dist/tower/routes/metrics/route.d.ts.map +1 -0
  479. package/dist/tower/routes/metrics/route.js +20 -0
  480. package/dist/tower/routes/metrics/route.js.map +1 -0
  481. package/dist/tower/routes/route.d.ts +7 -0
  482. package/dist/tower/routes/route.d.ts.map +1 -0
  483. package/dist/tower/routes/route.js +6 -0
  484. package/dist/tower/routes/route.js.map +1 -0
  485. package/dist/tower/routes/routes/route.d.ts +7 -0
  486. package/dist/tower/routes/routes/route.d.ts.map +1 -0
  487. package/dist/tower/routes/routes/route.js +23 -0
  488. package/dist/tower/routes/routes/route.js.map +1 -0
  489. package/dist/tower/routes/services/route.d.ts +7 -0
  490. package/dist/tower/routes/services/route.d.ts.map +1 -0
  491. package/dist/tower/routes/services/route.js +15 -0
  492. package/dist/tower/routes/services/route.js.map +1 -0
  493. package/dist/tower/routes/system/route.d.ts +11 -0
  494. package/dist/tower/routes/system/route.d.ts.map +1 -0
  495. package/dist/tower/routes/system/route.js +21 -0
  496. package/dist/tower/routes/system/route.js.map +1 -0
  497. package/dist/tower/routes/traceDetail.d.ts +17 -0
  498. package/dist/tower/routes/traceDetail.d.ts.map +1 -0
  499. package/dist/tower/routes/traceDetail.js +20 -0
  500. package/dist/tower/routes/traceDetail.js.map +1 -0
  501. package/dist/tower/routes/traces/route.d.ts +11 -0
  502. package/dist/tower/routes/traces/route.d.ts.map +1 -0
  503. package/dist/tower/routes/traces/route.js +36 -0
  504. package/dist/tower/routes/traces/route.js.map +1 -0
  505. package/dist/tower/routes/tree.d.ts +142 -0
  506. package/dist/tower/routes/tree.d.ts.map +1 -0
  507. package/dist/tower/routes/tree.js +28 -0
  508. package/dist/tower/routes/tree.js.map +1 -0
  509. package/dist/tower/ui/Errors.d.ts +5 -0
  510. package/dist/tower/ui/Errors.d.ts.map +1 -0
  511. package/dist/tower/ui/Errors.js +30 -0
  512. package/dist/tower/ui/Errors.js.map +1 -0
  513. package/dist/tower/ui/Fibers.d.ts +25 -0
  514. package/dist/tower/ui/Fibers.d.ts.map +1 -0
  515. package/dist/tower/ui/Fibers.js +157 -0
  516. package/dist/tower/ui/Fibers.js.map +1 -0
  517. package/dist/tower/ui/Logs.d.ts +5 -0
  518. package/dist/tower/ui/Logs.d.ts.map +1 -0
  519. package/dist/tower/ui/Logs.js +28 -0
  520. package/dist/tower/ui/Logs.js.map +1 -0
  521. package/dist/tower/ui/Metrics.d.ts +5 -0
  522. package/dist/tower/ui/Metrics.d.ts.map +1 -0
  523. package/dist/tower/ui/Metrics.js +34 -0
  524. package/dist/tower/ui/Metrics.js.map +1 -0
  525. package/dist/tower/ui/Routes.d.ts +9 -0
  526. package/dist/tower/ui/Routes.d.ts.map +1 -0
  527. package/dist/tower/ui/Routes.js +79 -0
  528. package/dist/tower/ui/Routes.js.map +1 -0
  529. package/dist/tower/ui/Services.d.ts +11 -0
  530. package/dist/tower/ui/Services.d.ts.map +1 -0
  531. package/dist/tower/ui/Services.js +254 -0
  532. package/dist/tower/ui/Services.js.map +1 -0
  533. package/dist/tower/ui/Shell.d.ts +11 -0
  534. package/dist/tower/ui/Shell.d.ts.map +1 -0
  535. package/dist/tower/ui/Shell.js +12 -0
  536. package/dist/tower/ui/Shell.js.map +1 -0
  537. package/dist/tower/ui/System.d.ts +5 -0
  538. package/dist/tower/ui/System.d.ts.map +1 -0
  539. package/dist/tower/ui/System.js +65 -0
  540. package/dist/tower/ui/System.js.map +1 -0
  541. package/dist/tower/ui/Traces.d.ts +13 -0
  542. package/dist/tower/ui/Traces.d.ts.map +1 -0
  543. package/dist/tower/ui/Traces.js +219 -0
  544. package/dist/tower/ui/Traces.js.map +1 -0
  545. package/dist/x/cloudflare/CloudflareTunnel.d.ts +11 -0
  546. package/dist/x/cloudflare/CloudflareTunnel.d.ts.map +1 -0
  547. package/dist/x/cloudflare/CloudflareTunnel.js +31 -0
  548. package/dist/x/cloudflare/CloudflareTunnel.js.map +1 -0
  549. package/dist/x/cloudflare/index.d.ts +2 -0
  550. package/dist/x/cloudflare/index.d.ts.map +1 -0
  551. package/dist/x/cloudflare/index.js +2 -0
  552. package/dist/x/cloudflare/index.js.map +1 -0
  553. package/dist/x/tailscale/TailscaleTunnel.d.ts +16 -0
  554. package/dist/x/tailscale/TailscaleTunnel.d.ts.map +1 -0
  555. package/dist/x/tailscale/TailscaleTunnel.js +66 -0
  556. package/dist/x/tailscale/TailscaleTunnel.js.map +1 -0
  557. package/dist/x/tailscale/index.d.ts +2 -0
  558. package/dist/x/tailscale/index.d.ts.map +1 -0
  559. package/dist/x/tailscale/index.js +2 -0
  560. package/dist/x/tailscale/index.js.map +1 -0
  561. package/dist/x/tailwind/TailwindPlugin.d.ts +24 -0
  562. package/dist/x/tailwind/TailwindPlugin.d.ts.map +1 -0
  563. package/dist/x/tailwind/TailwindPlugin.js +220 -0
  564. package/dist/x/tailwind/TailwindPlugin.js.map +1 -0
  565. package/dist/x/tailwind/compile.d.ts +20 -0
  566. package/dist/x/tailwind/compile.d.ts.map +1 -0
  567. package/dist/x/tailwind/compile.js +155 -0
  568. package/dist/x/tailwind/compile.js.map +1 -0
  569. package/dist/x/tailwind/plugin.d.ts +3 -0
  570. package/dist/x/tailwind/plugin.d.ts.map +1 -0
  571. package/dist/x/tailwind/plugin.js +16 -0
  572. package/dist/x/tailwind/plugin.js.map +1 -0
  573. package/package.json +104 -23
  574. package/src/ChildProcess.ts +3 -6
  575. package/src/Docker.ts +190 -0
  576. package/src/Effectify.ts +7 -10
  577. package/src/FileSystem.ts +1 -4
  578. package/src/GlobalLayer.ts +85 -0
  579. package/src/PlatformRuntime.ts +8 -1
  580. package/src/RouteHook.ts +1 -1
  581. package/src/SqlIntrospect.ts +13 -11
  582. package/src/Start.ts +40 -29
  583. package/src/System.ts +60 -3
  584. package/src/Unique.ts +59 -0
  585. package/src/bun/BunChildProcessSpawner.ts +1 -8
  586. package/src/bun/BunRoute.ts +1 -0
  587. package/src/bun/BunRuntime.ts +2 -8
  588. package/src/bun/BunServer.ts +54 -2
  589. package/src/datastar/watchers/patchElements.ts +0 -1
  590. package/src/lint/plugin.js +146 -81
  591. package/src/sql/SqlCache.ts +50 -0
  592. package/src/sql/SqlClient.ts +59 -14
  593. package/src/sql/bun/index.ts +28 -26
  594. package/src/sql/index.ts +1 -0
  595. package/src/sql/libsql/index.ts +62 -28
  596. package/src/sql/mssql/index.ts +53 -57
  597. package/src/sql/postgres/index.ts +254 -0
  598. package/src/tower/Simulation.ts +776 -0
  599. package/src/tower/Tower.ts +47 -0
  600. package/src/tower/TowerErrors.ts +224 -0
  601. package/src/tower/TowerLogger.ts +52 -0
  602. package/src/tower/TowerMetrics.ts +72 -0
  603. package/src/tower/TowerProcess.ts +59 -0
  604. package/src/tower/TowerStore.ts +505 -0
  605. package/src/tower/TowerTracer.ts +128 -0
  606. package/src/tower/index.ts +3 -0
  607. package/src/tower/routes/errors/route.tsx +90 -0
  608. package/src/tower/routes/fiberDetail.tsx +51 -0
  609. package/src/tower/routes/fibers/route.tsx +46 -0
  610. package/src/tower/routes/layout.html +340 -0
  611. package/src/tower/routes/layout.tsx +4 -0
  612. package/src/tower/routes/logs/route.tsx +73 -0
  613. package/src/tower/routes/metrics/route.tsx +36 -0
  614. package/src/tower/routes/route.tsx +8 -0
  615. package/src/tower/routes/routes/route.tsx +30 -0
  616. package/src/tower/routes/services/route.tsx +21 -0
  617. package/src/tower/routes/system/route.tsx +43 -0
  618. package/src/tower/routes/traceDetail.tsx +30 -0
  619. package/src/tower/routes/traces/route.tsx +72 -0
  620. package/src/tower/routes/tree.ts +28 -0
  621. package/src/tower/ui/Errors.tsx +80 -0
  622. package/src/tower/ui/Fibers.tsx +336 -0
  623. package/src/tower/ui/Logs.tsx +50 -0
  624. package/src/tower/ui/Metrics.tsx +78 -0
  625. package/src/tower/ui/Routes.tsx +125 -0
  626. package/src/tower/ui/Services.tsx +273 -0
  627. package/src/tower/ui/Shell.tsx +74 -0
  628. package/src/tower/ui/System.tsx +141 -0
  629. package/src/tower/ui/Traces.tsx +419 -0
  630. package/src/x/cloudflare/CloudflareTunnel.ts +1 -1
  631. package/src/x/tailscale/TailscaleTunnel.ts +3 -3
  632. package/src/x/tailwind/compile.ts +6 -1
  633. package/src/sql/mssql/docker.ts +0 -117
@@ -0,0 +1,776 @@
1
+ import * as Data from "effect/Data"
2
+ import * as Duration from "effect/Duration"
3
+ import * as Effect from "effect/Effect"
4
+ import * as Layer from "effect/Layer"
5
+ import * as Metric from "effect/Metric"
6
+ import * as MetricBoundaries from "effect/MetricBoundaries"
7
+ import * as Random from "effect/Random"
8
+ import * as Schedule from "effect/Schedule"
9
+
10
+ const pick = <T>(arr: ReadonlyArray<T>): Effect.Effect<T> =>
11
+ Random.nextIntBetween(0, arr.length).pipe(Effect.map((i) => arr[i]))
12
+
13
+ const randomMs = (min: number, max: number) =>
14
+ Random.nextIntBetween(min, max).pipe(Effect.map((ms) => Duration.millis(ms)))
15
+
16
+ const maybe = (pct: number, op: Effect.Effect<void, any>) =>
17
+ Effect.gen(function* () {
18
+ if ((yield* Random.nextIntBetween(0, 100)) < pct) yield* op
19
+ })
20
+
21
+ const httpRequestsTotal = Metric.counter("http.requests.total")
22
+ const httpRequestDuration = Metric.histogram(
23
+ "http.request.duration_ms",
24
+ MetricBoundaries.linear({ start: 0, width: 50, count: 20 }),
25
+ )
26
+ const activeConnections = Metric.gauge("http.active_connections")
27
+ const dbQueryDuration = Metric.histogram(
28
+ "db.query.duration_ms",
29
+ MetricBoundaries.linear({ start: 0, width: 10, count: 25 }),
30
+ )
31
+ const dbPoolSize = Metric.gauge("db.pool.active")
32
+ const cacheHits = Metric.counter("cache.hits")
33
+ const cacheMisses = Metric.counter("cache.misses")
34
+ const queueDepth = Metric.gauge("queue.depth")
35
+ const eventCount = Metric.counter("events.processed")
36
+ const retryCount = Metric.counter("retry.total")
37
+ const circuitBreakerTrips = Metric.counter("circuit_breaker.trips")
38
+ const rateLimitRejections = Metric.counter("rate_limit.rejections")
39
+ const serializationDuration = Metric.histogram(
40
+ "serialization.duration_ms",
41
+ MetricBoundaries.linear({ start: 0, width: 5, count: 15 }),
42
+ )
43
+
44
+ const routes = [
45
+ { method: "GET", path: "/api/users", handler: "UserController.list" },
46
+ { method: "GET", path: "/api/users/:id", handler: "UserController.get" },
47
+ { method: "POST", path: "/api/users", handler: "UserController.create" },
48
+ { method: "PUT", path: "/api/users/:id", handler: "UserController.update" },
49
+ { method: "DELETE", path: "/api/users/:id", handler: "UserController.delete" },
50
+ { method: "GET", path: "/api/products", handler: "ProductController.list" },
51
+ { method: "GET", path: "/api/products/:id", handler: "ProductController.get" },
52
+ { method: "POST", path: "/api/orders", handler: "OrderController.create" },
53
+ { method: "GET", path: "/api/orders/:id", handler: "OrderController.get" },
54
+ { method: "PATCH", path: "/api/orders/:id/status", handler: "OrderController.updateStatus" },
55
+ { method: "POST", path: "/api/auth/login", handler: "AuthController.login" },
56
+ { method: "POST", path: "/api/auth/refresh", handler: "AuthController.refresh" },
57
+ { method: "POST", path: "/api/auth/logout", handler: "AuthController.logout" },
58
+ { method: "GET", path: "/api/search", handler: "SearchController.query" },
59
+ { method: "GET", path: "/api/analytics/dashboard", handler: "AnalyticsController.dashboard" },
60
+ { method: "POST", path: "/api/notifications/send", handler: "NotificationController.send" },
61
+ { method: "POST", path: "/api/uploads/image", handler: "UploadController.image" },
62
+ { method: "GET", path: "/api/health", handler: "HealthController.check" },
63
+ { method: "GET", path: "/api/config", handler: "ConfigController.get" },
64
+ { method: "POST", path: "/api/webhooks/stripe", handler: "WebhookController.stripe" },
65
+ ] as const
66
+
67
+ const dbQueries = [
68
+ "SELECT * FROM users WHERE id = $1",
69
+ "SELECT * FROM users ORDER BY created_at DESC LIMIT 20",
70
+ "INSERT INTO users (name, email) VALUES ($1, $2) RETURNING *",
71
+ "UPDATE users SET name = $1 WHERE id = $2",
72
+ "SELECT p.*, c.name AS category FROM products p JOIN categories c ON p.category_id = c.id",
73
+ "SELECT * FROM orders WHERE user_id = $1 ORDER BY created_at DESC",
74
+ "INSERT INTO orders (user_id, total, status) VALUES ($1, $2, $3)",
75
+ "SELECT u.*, COUNT(o.id) AS order_count FROM users u LEFT JOIN orders o ON u.id = o.id GROUP BY u.id",
76
+ "DELETE FROM sessions WHERE expires_at < NOW()",
77
+ "SELECT * FROM products WHERE tsv @@ plainto_tsquery($1) LIMIT 50",
78
+ "SELECT o.*, json_agg(oi.*) AS items FROM orders o JOIN order_items oi ON o.id = oi.order_id WHERE o.id = $1 GROUP BY o.id",
79
+ "WITH ranked AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY category_id ORDER BY sales DESC) rn FROM products) SELECT * FROM ranked WHERE rn <= 5",
80
+ "UPDATE inventory SET quantity = quantity - $1 WHERE product_id = $2 AND quantity >= $1 RETURNING quantity",
81
+ ]
82
+
83
+ const cacheKeys = [
84
+ "user:profile:42",
85
+ "user:profile:108",
86
+ "product:listing:page:1",
87
+ "product:detail:77",
88
+ "session:abc123",
89
+ "rate_limit:192.168.1.1",
90
+ "search:results:shoes",
91
+ "config:feature_flags",
92
+ "analytics:dashboard:daily",
93
+ "inventory:stock:sku_4421",
94
+ "cart:user:42",
95
+ ]
96
+
97
+ const errorMessages = [
98
+ "connection refused: upstream timeout after 30s",
99
+ "UNIQUE constraint failed: users.email",
100
+ "rate limit exceeded for client 10.0.3.44",
101
+ "invalid JWT: token expired at 2025-12-01T00:00:00Z",
102
+ "payment gateway returned 502",
103
+ "deadlock detected on table orders",
104
+ "request body exceeds 10MB limit",
105
+ "foreign key constraint: order references missing user",
106
+ "TLS handshake timeout with payment-service:443",
107
+ "DNS resolution failed for analytics.internal.svc",
108
+ ]
109
+
110
+ class DatabaseError extends Data.TaggedError("DatabaseError")<{
111
+ readonly query: string
112
+ readonly reason: string
113
+ }> {}
114
+
115
+ class AuthenticationError extends Data.TaggedError("AuthenticationError")<{
116
+ readonly reason: string
117
+ readonly userId?: string
118
+ }> {}
119
+
120
+ class ExternalServiceError extends Data.TaggedError("ExternalServiceError")<{
121
+ readonly service: string
122
+ readonly statusCode: number
123
+ readonly reason: string
124
+ }> {}
125
+
126
+ class TimeoutError extends Data.TaggedError("TimeoutError")<{
127
+ readonly operation: string
128
+ readonly durationMs: number
129
+ }> {}
130
+
131
+ class ValidationError extends Data.TaggedError("ValidationError")<{
132
+ readonly field: string
133
+ readonly message: string
134
+ }> {}
135
+
136
+ class TaskError extends Data.TaggedError("TaskError")<{
137
+ readonly task: string
138
+ readonly reason: string
139
+ }> {}
140
+
141
+ class HttpError extends Data.TaggedError("HttpError")<{
142
+ readonly method: string
143
+ readonly path: string
144
+ readonly statusCode: number
145
+ readonly message: string
146
+ }> {}
147
+
148
+ class RateLimitError extends Data.TaggedError("RateLimitError")<{
149
+ readonly clientIp: string
150
+ readonly limit: number
151
+ }> {}
152
+
153
+ class CircuitBreakerError extends Data.TaggedError("CircuitBreakerError")<{
154
+ readonly service: string
155
+ readonly failureCount: number
156
+ }> {}
157
+
158
+ const simulateDnsResolve = Effect.gen(function* () {
159
+ const hosts = [
160
+ "db-primary.internal",
161
+ "cache-01.internal",
162
+ "payment-service.prod",
163
+ "queue.internal",
164
+ "analytics.internal.svc",
165
+ ]
166
+ const host = yield* pick(hosts)
167
+ yield* Effect.annotateCurrentSpan("dns.host", host)
168
+ yield* Effect.sleep(yield* randomMs(0, 5))
169
+ if ((yield* Random.nextIntBetween(0, 100)) < 2) {
170
+ return yield* Effect.fail(
171
+ new TimeoutError({ operation: `dns.resolve(${host})`, durationMs: 5000 }),
172
+ )
173
+ }
174
+ }).pipe(Effect.withSpan("dns.resolve"))
175
+
176
+ const simulateTlsHandshake = Effect.gen(function* () {
177
+ yield* Effect.sleep(yield* randomMs(2, 20))
178
+ yield* Effect.annotateCurrentSpan("tls.version", "1.3")
179
+ yield* Effect.annotateCurrentSpan("tls.cipher", "TLS_AES_256_GCM_SHA384")
180
+ if ((yield* Random.nextIntBetween(0, 100)) < 1) {
181
+ return yield* Effect.fail(new TimeoutError({ operation: "tls.handshake", durationMs: 10000 }))
182
+ }
183
+ }).pipe(Effect.withSpan("tls.handshake"))
184
+
185
+ const simulateConnectionPoolAcquire = Effect.gen(function* () {
186
+ const pool = yield* Random.nextIntBetween(1, 20)
187
+ const maxPool = 20
188
+ yield* Effect.annotateCurrentSpan("pool.active", pool)
189
+ yield* Effect.annotateCurrentSpan("pool.max", maxPool)
190
+ yield* dbPoolSize.pipe(Metric.set(pool))
191
+ yield* Effect.sleep(yield* randomMs(0, pool > 15 ? 50 : 5))
192
+ if (pool >= 19 && (yield* Random.nextIntBetween(0, 100)) < 30) {
193
+ return yield* Effect.die(new DatabaseError({ query: "", reason: "connection pool exhausted" }))
194
+ }
195
+ }).pipe(Effect.withSpan("db.pool.acquire"))
196
+
197
+ const simulateConnectionPoolRelease = Effect.gen(function* () {
198
+ yield* Effect.sleep(yield* randomMs(0, 1))
199
+ }).pipe(Effect.withSpan("db.pool.release"))
200
+
201
+ const simulateQueryParse = Effect.gen(function* () {
202
+ yield* Effect.sleep(yield* randomMs(0, 3))
203
+ yield* Effect.annotateCurrentSpan("db.parse.cached", (yield* Random.nextIntBetween(0, 100)) < 80)
204
+ }).pipe(Effect.withSpan("db.query.parse"))
205
+
206
+ const simulateQueryExecute = Effect.gen(function* () {
207
+ const query = yield* pick(dbQueries)
208
+ const delay = yield* randomMs(1, 80)
209
+ yield* Effect.annotateCurrentSpan("db.statement", query)
210
+ yield* Metric.update(dbQueryDuration, Math.round(Duration.toMillis(delay)))
211
+ yield* Effect.sleep(delay)
212
+ const roll = yield* Random.nextIntBetween(0, 100)
213
+ if (roll < 2) {
214
+ return yield* Effect.fail(
215
+ new DatabaseError({ query, reason: "deadlock detected on table orders" }),
216
+ )
217
+ }
218
+ if (roll < 4) {
219
+ return yield* Effect.fail(
220
+ new TimeoutError({
221
+ operation: "db.query.execute",
222
+ durationMs: Math.round(Duration.toMillis(delay)),
223
+ }),
224
+ )
225
+ }
226
+ }).pipe(Effect.withSpan("db.query.execute"))
227
+
228
+ const simulateResultDeserialization = Effect.gen(function* () {
229
+ const rowCount = yield* Random.nextIntBetween(0, 500)
230
+ yield* Effect.annotateCurrentSpan("db.rows", rowCount)
231
+ yield* Effect.sleep(yield* randomMs(0, rowCount > 100 ? 15 : 3))
232
+ }).pipe(Effect.withSpan("db.result.deserialize"))
233
+
234
+ const simulateDbQuery = Effect.gen(function* () {
235
+ yield* simulateConnectionPoolAcquire
236
+ yield* simulateQueryParse
237
+ yield* simulateQueryExecute
238
+ yield* simulateResultDeserialization
239
+ yield* simulateConnectionPoolRelease
240
+ }).pipe(Effect.withSpan("db.query"))
241
+
242
+ const simulateCacheSerialize = Effect.gen(function* () {
243
+ const ms = yield* Random.nextIntBetween(0, 5)
244
+ yield* Metric.update(serializationDuration, ms)
245
+ yield* Effect.sleep(Duration.millis(ms))
246
+ }).pipe(Effect.withSpan("cache.serialize"))
247
+
248
+ const simulateCacheDeserialize = Effect.gen(function* () {
249
+ const ms = yield* Random.nextIntBetween(0, 4)
250
+ yield* Metric.update(serializationDuration, ms)
251
+ yield* Effect.sleep(Duration.millis(ms))
252
+ }).pipe(Effect.withSpan("cache.deserialize"))
253
+
254
+ const simulateCache = Effect.gen(function* () {
255
+ const key = yield* pick(cacheKeys)
256
+ const hit = (yield* Random.nextIntBetween(0, 100)) < 75
257
+ yield* Effect.annotateCurrentSpan("cache.key", key)
258
+ yield* Effect.annotateCurrentSpan("cache.hit", hit)
259
+ yield* Effect.sleep(yield* randomMs(0, 3))
260
+ if (hit) {
261
+ yield* Metric.increment(cacheHits)
262
+ yield* simulateCacheDeserialize
263
+ yield* Effect.logDebug(`cache hit: ${key}`)
264
+ } else {
265
+ yield* Metric.increment(cacheMisses)
266
+ yield* Effect.logDebug(`cache miss: ${key}`)
267
+ }
268
+ }).pipe(Effect.withSpan("cache.lookup"))
269
+
270
+ const simulateTokenDecode = Effect.gen(function* () {
271
+ yield* Effect.sleep(yield* randomMs(0, 2))
272
+ yield* Effect.annotateCurrentSpan("jwt.alg", "RS256")
273
+ }).pipe(Effect.withSpan("jwt.decode"))
274
+
275
+ const simulateTokenVerify = Effect.gen(function* () {
276
+ yield* Effect.sleep(yield* randomMs(1, 8))
277
+ const roll = yield* Random.nextIntBetween(0, 100)
278
+ if (roll < 3) {
279
+ return yield* Effect.fail(
280
+ new AuthenticationError({ reason: "JWT expired at 2025-12-01T00:00:00Z" }),
281
+ )
282
+ }
283
+ if (roll < 5) {
284
+ return yield* Effect.fail(
285
+ new AuthenticationError({
286
+ reason: "invalid signature",
287
+ userId: "user_" + (yield* Random.nextIntBetween(100, 999)),
288
+ }),
289
+ )
290
+ }
291
+ }).pipe(Effect.withSpan("jwt.verify"))
292
+
293
+ const simulatePermissionCheck = Effect.gen(function* () {
294
+ const roles = ["admin", "editor", "viewer", "moderator"]
295
+ const role = yield* pick(roles)
296
+ yield* Effect.annotateCurrentSpan("auth.role", role)
297
+ yield* Effect.sleep(yield* randomMs(0, 3))
298
+ if ((yield* Random.nextIntBetween(0, 100)) < 2) {
299
+ return yield* Effect.fail(
300
+ new AuthenticationError({ reason: `insufficient permissions for role: ${role}` }),
301
+ )
302
+ }
303
+ }).pipe(Effect.withSpan("auth.permission_check"))
304
+
305
+ const simulateAuth = Effect.gen(function* () {
306
+ yield* simulateTokenDecode
307
+ yield* simulateTokenVerify
308
+ yield* simulatePermissionCheck
309
+ yield* Effect.logDebug("token validated")
310
+ }).pipe(Effect.withSpan("auth.validate"))
311
+
312
+ const simulateRateLimit = Effect.gen(function* () {
313
+ const ips = ["10.0.3.44", "192.168.1.1", "172.16.0.55", "10.0.7.12", "203.0.113.42"]
314
+ const ip = yield* pick(ips)
315
+ const remaining = yield* Random.nextIntBetween(0, 100)
316
+ yield* Effect.annotateCurrentSpan("rate_limit.client_ip", ip)
317
+ yield* Effect.annotateCurrentSpan("rate_limit.remaining", remaining)
318
+ yield* Effect.sleep(yield* randomMs(0, 2))
319
+ if (remaining < 3) {
320
+ yield* Metric.increment(rateLimitRejections)
321
+ yield* Effect.logWarning(`rate limit near threshold for ${ip}`)
322
+ if ((yield* Random.nextIntBetween(0, 100)) < 40) {
323
+ return yield* Effect.fail(new RateLimitError({ clientIp: ip, limit: 100 }))
324
+ }
325
+ }
326
+ }).pipe(Effect.withSpan("middleware.rate_limit"))
327
+
328
+ const simulateCors = Effect.gen(function* () {
329
+ const origins = [
330
+ "https://app.example.com",
331
+ "https://admin.example.com",
332
+ "https://mobile.example.com",
333
+ "null",
334
+ ]
335
+ const origin = yield* pick(origins)
336
+ yield* Effect.annotateCurrentSpan("cors.origin", origin)
337
+ yield* Effect.sleep(yield* randomMs(0, 1))
338
+ if (origin === "null") {
339
+ yield* Effect.logWarning("CORS: rejected null origin")
340
+ }
341
+ }).pipe(Effect.withSpan("middleware.cors"))
342
+
343
+ const simulateRequestParsing = Effect.gen(function* () {
344
+ const contentTypes = [
345
+ "application/json",
346
+ "multipart/form-data",
347
+ "application/x-www-form-urlencoded",
348
+ "text/plain",
349
+ ]
350
+ const ct = yield* pick(contentTypes)
351
+ yield* Effect.annotateCurrentSpan("http.content_type", ct)
352
+ const bodySize = yield* Random.nextIntBetween(0, 50000)
353
+ yield* Effect.annotateCurrentSpan("http.body_size", bodySize)
354
+ yield* Effect.sleep(yield* randomMs(0, bodySize > 10000 ? 15 : 3))
355
+ if (bodySize > 40000) {
356
+ return yield* Effect.fail(
357
+ new ValidationError({ field: "body", message: "request body exceeds 10MB limit" }),
358
+ )
359
+ }
360
+ if ((yield* Random.nextIntBetween(0, 100)) < 3) {
361
+ return yield* Effect.fail(
362
+ new ValidationError({ field: "body", message: "malformed JSON at position 42" }),
363
+ )
364
+ }
365
+ }).pipe(Effect.withSpan("http.parse_body"))
366
+
367
+ const simulateInputValidation = Effect.gen(function* () {
368
+ yield* Effect.sleep(yield* randomMs(0, 3))
369
+ const fields = ["email", "name", "amount", "quantity", "phone", "address.zip"]
370
+ if ((yield* Random.nextIntBetween(0, 100)) < 5) {
371
+ const field = yield* pick(fields)
372
+ return yield* Effect.fail(
373
+ new ValidationError({ field, message: `invalid format for ${field}` }),
374
+ )
375
+ }
376
+ }).pipe(Effect.withSpan("validation.input"))
377
+
378
+ const simulateResponseSerialization = Effect.gen(function* () {
379
+ const formats = ["json", "msgpack", "protobuf"]
380
+ const format = yield* pick(formats)
381
+ yield* Effect.annotateCurrentSpan("serialization.format", format)
382
+ const ms = yield* Random.nextIntBetween(0, 10)
383
+ yield* Metric.update(serializationDuration, ms)
384
+ yield* Effect.sleep(Duration.millis(ms))
385
+ }).pipe(Effect.withSpan("http.serialize_response"))
386
+
387
+ const simulateCompression = Effect.gen(function* () {
388
+ const algos = ["gzip", "br", "none"]
389
+ const algo = yield* pick(algos)
390
+ yield* Effect.annotateCurrentSpan("compression.algorithm", algo)
391
+ yield* Effect.sleep(yield* randomMs(0, algo === "none" ? 1 : 8))
392
+ }).pipe(Effect.withSpan("http.compress"))
393
+
394
+ const simulateAccessLog = Effect.gen(function* () {
395
+ yield* Effect.sleep(yield* randomMs(0, 1))
396
+ }).pipe(Effect.withSpan("middleware.access_log"))
397
+
398
+ const simulateCircuitBreaker = (inner: Effect.Effect<void, any>, service: string) =>
399
+ Effect.gen(function* () {
400
+ const failures = yield* Random.nextIntBetween(0, 10)
401
+ yield* Effect.annotateCurrentSpan("circuit_breaker.service", service)
402
+ yield* Effect.annotateCurrentSpan("circuit_breaker.failure_count", failures)
403
+ if (failures >= 8) {
404
+ yield* Metric.increment(circuitBreakerTrips)
405
+ yield* Effect.logWarning(`circuit breaker OPEN for ${service}`)
406
+ return yield* Effect.fail(new CircuitBreakerError({ service, failureCount: failures }))
407
+ }
408
+ yield* inner
409
+ }).pipe(Effect.withSpan("circuit_breaker"))
410
+
411
+ const simulateRetry = (inner: Effect.Effect<void, any>, opName: string) =>
412
+ Effect.gen(function* () {
413
+ const maxRetries = 3
414
+ let attempt = 0
415
+ let succeeded = false
416
+ while (attempt < maxRetries && !succeeded) {
417
+ attempt++
418
+ yield* Effect.annotateCurrentSpan("retry.attempt", attempt)
419
+ const result = yield* inner.pipe(
420
+ Effect.map(() => true),
421
+ Effect.catchAll((e) => {
422
+ if (attempt < maxRetries) {
423
+ return Effect.gen(function* () {
424
+ yield* Metric.increment(retryCount)
425
+ yield* Effect.logWarning(`${opName} attempt ${attempt} failed, retrying`)
426
+ yield* Effect.sleep(yield* randomMs(10, 50 * attempt))
427
+ return false
428
+ })
429
+ }
430
+ return Effect.fail(e)
431
+ }),
432
+ )
433
+ succeeded = result
434
+ }
435
+ }).pipe(Effect.withSpan("retry"))
436
+
437
+ const simulateExternalCall = Effect.gen(function* () {
438
+ const services = [
439
+ "payment-service",
440
+ "email-service",
441
+ "notification-service",
442
+ "inventory-service",
443
+ "shipping-service",
444
+ "tax-service",
445
+ ]
446
+ const service = yield* pick(services)
447
+ yield* Effect.annotateCurrentSpan("peer.service", service)
448
+
449
+ yield* simulateDnsResolve
450
+ yield* simulateTlsHandshake
451
+
452
+ const delay = yield* randomMs(10, 300)
453
+ yield* Effect.annotateCurrentSpan(
454
+ "http.outgoing.duration_ms",
455
+ Math.round(Duration.toMillis(delay)),
456
+ )
457
+ yield* Effect.sleep(delay)
458
+
459
+ const roll = yield* Random.nextIntBetween(0, 100)
460
+ if (roll < 4) {
461
+ yield* Effect.logError(`${service} responded with 503`)
462
+ return yield* Effect.fail(
463
+ new ExternalServiceError({ service, statusCode: 503, reason: "service unavailable" }),
464
+ )
465
+ }
466
+ if (roll < 6) {
467
+ yield* Effect.logError(`${service} timed out after ${Math.round(Duration.toMillis(delay))}ms`)
468
+ return yield* Effect.fail(
469
+ new TimeoutError({
470
+ operation: `${service} call`,
471
+ durationMs: Math.round(Duration.toMillis(delay)),
472
+ }),
473
+ )
474
+ }
475
+ if (roll < 8) {
476
+ yield* Effect.logError(`${service} responded with 502`)
477
+ return yield* Effect.fail(
478
+ new ExternalServiceError({ service, statusCode: 502, reason: "bad gateway" }),
479
+ )
480
+ }
481
+ }).pipe(Effect.withSpan("http.outgoing"))
482
+
483
+ const simulateExternalCallWithResilience = Effect.gen(function* () {
484
+ const service = yield* pick([
485
+ "payment-service",
486
+ "email-service",
487
+ "notification-service",
488
+ "inventory-service",
489
+ ])
490
+ yield* simulateCircuitBreaker(simulateRetry(simulateExternalCall, `external.${service}`), service)
491
+ }).pipe(Effect.withSpan("external.resilient_call"))
492
+
493
+ const simulateSearchQuery = Effect.gen(function* () {
494
+ const terms = ["shoes", "laptop", "organic food", "headphones", "gift ideas"]
495
+ const term = yield* pick(terms)
496
+ yield* Effect.annotateCurrentSpan("search.query", term)
497
+
498
+ yield* simulateCache
499
+
500
+ yield* Effect.gen(function* () {
501
+ yield* Effect.sleep(yield* randomMs(5, 40))
502
+ yield* Effect.annotateCurrentSpan("search.engine", "elasticsearch")
503
+ yield* Effect.annotateCurrentSpan("search.index", "products_v3")
504
+ const hits = yield* Random.nextIntBetween(0, 200)
505
+ yield* Effect.annotateCurrentSpan("search.hits", hits)
506
+ }).pipe(Effect.withSpan("search.execute"))
507
+
508
+ yield* Effect.gen(function* () {
509
+ yield* Effect.sleep(yield* randomMs(1, 10))
510
+ yield* Effect.annotateCurrentSpan("search.boost", "relevance+recency")
511
+ }).pipe(Effect.withSpan("search.rank"))
512
+
513
+ yield* Effect.gen(function* () {
514
+ yield* Effect.sleep(yield* randomMs(0, 5))
515
+ }).pipe(Effect.withSpan("search.highlight"))
516
+ }).pipe(Effect.withSpan("search.pipeline"))
517
+
518
+ const simulateFileUpload = Effect.gen(function* () {
519
+ const fileSize = yield* Random.nextIntBetween(1000, 5_000_000)
520
+ yield* Effect.annotateCurrentSpan("upload.size_bytes", fileSize)
521
+
522
+ yield* Effect.gen(function* () {
523
+ yield* Effect.sleep(yield* randomMs(1, 10))
524
+ const types = ["image/jpeg", "image/png", "application/pdf", "image/webp"]
525
+ const mime = yield* pick(types)
526
+ yield* Effect.annotateCurrentSpan("upload.mime", mime)
527
+ if ((yield* Random.nextIntBetween(0, 100)) < 3) {
528
+ return yield* Effect.fail(
529
+ new ValidationError({ field: "file", message: "unsupported mime type" }),
530
+ )
531
+ }
532
+ }).pipe(Effect.withSpan("upload.validate_mime"))
533
+
534
+ yield* Effect.gen(function* () {
535
+ yield* Effect.sleep(yield* randomMs(0, 5))
536
+ }).pipe(Effect.withSpan("upload.virus_scan"))
537
+
538
+ yield* Effect.gen(function* () {
539
+ yield* Effect.sleep(yield* randomMs(5, 50))
540
+ yield* Effect.annotateCurrentSpan("upload.bucket", "user-uploads-prod")
541
+ }).pipe(Effect.withSpan("upload.store_s3"))
542
+
543
+ yield* Effect.gen(function* () {
544
+ yield* simulateDbQuery
545
+ }).pipe(Effect.withSpan("upload.persist_metadata"))
546
+ }).pipe(Effect.withSpan("upload.pipeline"))
547
+
548
+ const simulateOrderWorkflow = Effect.gen(function* () {
549
+ yield* Effect.annotateCurrentSpan("order.workflow", "create")
550
+
551
+ yield* simulateInputValidation
552
+
553
+ yield* Effect.gen(function* () {
554
+ yield* simulateDbQuery
555
+ yield* Effect.sleep(yield* randomMs(1, 10))
556
+ }).pipe(Effect.withSpan("order.check_inventory"))
557
+
558
+ yield* Effect.gen(function* () {
559
+ yield* simulateExternalCallWithResilience
560
+ }).pipe(Effect.withSpan("order.process_payment"))
561
+
562
+ yield* Effect.gen(function* () {
563
+ yield* simulateDbQuery
564
+ }).pipe(Effect.withSpan("order.persist"))
565
+
566
+ yield* Effect.gen(function* () {
567
+ yield* simulateCache
568
+ yield* simulateCacheSerialize
569
+ }).pipe(Effect.withSpan("order.invalidate_cache"))
570
+
571
+ yield* Effect.gen(function* () {
572
+ yield* Effect.sleep(yield* randomMs(1, 10))
573
+ yield* Effect.logInfo("order confirmation email queued")
574
+ }).pipe(Effect.withSpan("order.queue_notification"))
575
+ }).pipe(Effect.withSpan("order.workflow"))
576
+
577
+ const simulateAnalyticsPipeline = Effect.gen(function* () {
578
+ yield* Effect.gen(function* () {
579
+ yield* simulateDbQuery
580
+ yield* simulateDbQuery
581
+ }).pipe(Effect.withSpan("analytics.fetch_raw"))
582
+
583
+ yield* Effect.gen(function* () {
584
+ yield* Effect.sleep(yield* randomMs(5, 30))
585
+ yield* Effect.annotateCurrentSpan("analytics.aggregation", "time_series")
586
+ }).pipe(Effect.withSpan("analytics.aggregate"))
587
+
588
+ yield* Effect.gen(function* () {
589
+ yield* simulateCache
590
+ }).pipe(Effect.withSpan("analytics.cache_result"))
591
+
592
+ yield* Effect.gen(function* () {
593
+ yield* Effect.sleep(yield* randomMs(2, 15))
594
+ yield* Effect.annotateCurrentSpan("analytics.format", "dashboard_v2")
595
+ }).pipe(Effect.withSpan("analytics.transform"))
596
+ }).pipe(Effect.withSpan("analytics.pipeline"))
597
+
598
+ const simulateBackgroundTask = Effect.gen(function* () {
599
+ const tasks = [
600
+ "process-webhook",
601
+ "send-email",
602
+ "generate-report",
603
+ "sync-inventory",
604
+ "cleanup-sessions",
605
+ "rebuild-search-index",
606
+ "process-refund",
607
+ "generate-invoice-pdf",
608
+ "sync-crm",
609
+ ]
610
+ const task = yield* pick(tasks)
611
+ yield* Effect.logInfo(`starting background task: ${task}`)
612
+
613
+ yield* Effect.gen(function* () {
614
+ yield* Effect.sleep(yield* randomMs(0, 5))
615
+ yield* Effect.annotateCurrentSpan(
616
+ "task.priority",
617
+ yield* pick(["low", "normal", "high", "critical"]),
618
+ )
619
+ }).pipe(Effect.withSpan("task.dequeue"))
620
+
621
+ yield* Effect.gen(function* () {
622
+ yield* simulateDbQuery
623
+ }).pipe(Effect.withSpan("task.load_context"))
624
+
625
+ yield* Effect.gen(function* () {
626
+ yield* Effect.sleep(yield* randomMs(20, 300))
627
+ const roll = yield* Random.nextIntBetween(0, 100)
628
+ if (roll < 4) {
629
+ return yield* Effect.fail(new TaskError({ task, reason: "execution exceeded 30s deadline" }))
630
+ }
631
+ if (roll < 7) {
632
+ const err = yield* pick(errorMessages)
633
+ yield* Effect.logError(`task ${task} failed: ${err}`)
634
+ return yield* Effect.fail(new TaskError({ task, reason: err }))
635
+ }
636
+ if (roll < 9) {
637
+ return yield* Effect.die(new TaskError({ task, reason: "out of memory" }))
638
+ }
639
+ }).pipe(Effect.withSpan("task.execute"))
640
+
641
+ yield* maybe(
642
+ 60,
643
+ Effect.gen(function* () {
644
+ yield* simulateExternalCall
645
+ }).pipe(Effect.withSpan("task.external_dependency")),
646
+ )
647
+
648
+ yield* Effect.gen(function* () {
649
+ yield* simulateDbQuery
650
+ }).pipe(Effect.withSpan("task.persist_result"))
651
+
652
+ yield* Effect.gen(function* () {
653
+ yield* Effect.sleep(yield* randomMs(0, 3))
654
+ }).pipe(Effect.withSpan("task.ack"))
655
+
656
+ yield* Metric.increment(eventCount)
657
+ yield* Effect.logInfo(`completed background task: ${task}`)
658
+ }).pipe(Effect.withSpan("task.background"))
659
+
660
+ const simulateRequest = Effect.gen(function* () {
661
+ const route = yield* pick(routes)
662
+ const statusCodes = [200, 200, 200, 200, 200, 201, 204, 301, 400, 401, 404, 500]
663
+
664
+ yield* Metric.increment(httpRequestsTotal)
665
+ yield* Metric.increment(activeConnections)
666
+
667
+ const result = yield* Effect.gen(function* () {
668
+ yield* Effect.annotateCurrentSpan("http.method", route.method)
669
+ yield* Effect.annotateCurrentSpan("http.route", route.path)
670
+ yield* Effect.annotateCurrentSpan("handler", route.handler)
671
+
672
+ // middleware chain
673
+ yield* simulateAccessLog
674
+ yield* simulateCors
675
+ yield* simulateRateLimit
676
+ yield* simulateRequestParsing
677
+
678
+ // auth (most routes)
679
+ yield* maybe(70, simulateAuth)
680
+
681
+ // handler body — pick a complex workflow or simple CRUD based on the route
682
+ const handler = route.handler
683
+ if (handler === "OrderController.create" || handler === "OrderController.updateStatus") {
684
+ yield* simulateOrderWorkflow
685
+ } else if (handler === "SearchController.query") {
686
+ yield* simulateSearchQuery
687
+ } else if (handler === "UploadController.image") {
688
+ yield* simulateFileUpload
689
+ } else if (handler === "AnalyticsController.dashboard") {
690
+ yield* simulateAnalyticsPipeline
691
+ } else if (handler === "WebhookController.stripe") {
692
+ yield* simulateInputValidation
693
+ yield* simulateExternalCallWithResilience
694
+ yield* simulateDbQuery
695
+ } else {
696
+ // standard CRUD
697
+ yield* maybe(50, simulateCache)
698
+ yield* simulateDbQuery
699
+ yield* maybe(25, simulateExternalCall)
700
+ yield* maybe(30, simulateDbQuery) // secondary query
701
+ }
702
+
703
+ // response pipeline
704
+ yield* simulateResponseSerialization
705
+ yield* maybe(40, simulateCompression)
706
+
707
+ const status = yield* pick(statusCodes)
708
+ yield* Effect.annotateCurrentSpan("http.status_code", status)
709
+
710
+ if (status >= 500) {
711
+ const err = yield* pick(errorMessages)
712
+ yield* Effect.logError(`${route.method} ${route.path} → ${status}: ${err}`)
713
+ return yield* Effect.fail(
714
+ new HttpError({
715
+ method: route.method,
716
+ path: route.path,
717
+ statusCode: status,
718
+ message: err,
719
+ }),
720
+ )
721
+ }
722
+
723
+ if (status >= 400) {
724
+ yield* Effect.logWarning(`${route.method} ${route.path} → ${status}`)
725
+ } else {
726
+ yield* Effect.logInfo(`${route.method} ${route.path} → ${status}`)
727
+ }
728
+
729
+ return status
730
+ }).pipe(Effect.withSpan(`${route.method} ${route.path}`))
731
+
732
+ yield* activeConnections.pipe(Metric.set(0))
733
+
734
+ const durationMs = yield* Random.nextIntBetween(5, 500)
735
+ yield* Metric.update(httpRequestDuration, durationMs)
736
+
737
+ return result
738
+ })
739
+
740
+ const requestLoop = Effect.gen(function* () {
741
+ yield* Effect.logInfo("simulation: request loop started")
742
+ yield* Effect.schedule(
743
+ Effect.gen(function* () {
744
+ const burst = yield* Random.nextIntBetween(1, 4)
745
+ yield* Effect.forEach(
746
+ Array.from({ length: burst }, (_, i) => i),
747
+ () => simulateRequest.pipe(Effect.fork),
748
+ { concurrency: "unbounded" },
749
+ )
750
+ }),
751
+ Schedule.jittered(Schedule.spaced("500 millis")),
752
+ )
753
+ })
754
+
755
+ const backgroundLoop = Effect.gen(function* () {
756
+ yield* Effect.logInfo("simulation: background task loop started")
757
+ yield* Effect.schedule(
758
+ Effect.gen(function* () {
759
+ yield* Effect.fork(simulateBackgroundTask)
760
+ const depth = yield* Random.nextIntBetween(0, 25)
761
+ yield* queueDepth.pipe(Metric.set(depth))
762
+ }),
763
+ Schedule.jittered(Schedule.spaced("2 seconds")),
764
+ )
765
+ })
766
+
767
+ export function layer() {
768
+ return Layer.scopedDiscard(
769
+ Effect.gen(function* () {
770
+ yield* Effect.logInfo("simulation layer starting")
771
+ yield* Effect.forkScoped(requestLoop)
772
+ yield* Effect.forkScoped(backgroundLoop)
773
+ yield* Effect.logInfo("simulation layer ready")
774
+ }),
775
+ )
776
+ }