effect 4.0.0-beta.103 → 4.0.0-beta.105

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 (667) hide show
  1. package/AGENTS.md +381 -0
  2. package/CLAUDE.md +381 -0
  3. package/ai-docs/README.md +44 -0
  4. package/ai-docs/package.json +36 -0
  5. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  6. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
  7. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  8. package/ai-docs/src/01_effect/01_basics/index.md +5 -0
  9. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  10. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  11. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  12. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  13. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  14. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  15. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  16. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  17. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  18. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  19. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  20. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  21. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  22. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  23. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  24. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  25. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  26. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  27. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  28. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  29. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  30. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  31. package/ai-docs/src/03_stream/30_encoding.ts +165 -0
  32. package/ai-docs/src/03_stream/index.md +4 -0
  33. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  34. package/ai-docs/src/04_integration/index.md +5 -0
  35. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  36. package/ai-docs/src/05_batching/index.md +3 -0
  37. package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
  38. package/ai-docs/src/06_schedule/index.md +3 -0
  39. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  40. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  41. package/ai-docs/src/07_datetime/index.md +5 -0
  42. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  43. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  44. package/ai-docs/src/08_observability/index.md +7 -0
  45. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  46. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  47. package/ai-docs/src/09_testing/index.md +1 -0
  48. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  49. package/ai-docs/src/10_predicate/index.md +9 -0
  50. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  51. package/ai-docs/src/50_http-client/index.md +3 -0
  52. package/ai-docs/src/51_http-server/10_basics.ts +116 -0
  53. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  54. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  55. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  56. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
  57. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
  58. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  59. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
  60. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
  61. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
  62. package/ai-docs/src/51_http-server/index.md +3 -0
  63. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  64. package/ai-docs/src/60_child-process/index.md +3 -0
  65. package/ai-docs/src/70_cli/10_basics.ts +136 -0
  66. package/ai-docs/src/70_cli/index.md +5 -0
  67. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  68. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  69. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  70. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  71. package/ai-docs/src/71_ai/index.md +5 -0
  72. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  73. package/ai-docs/src/80_cluster/index.md +4 -0
  74. package/ai-docs/src/index.md +10 -0
  75. package/ai-docs/tsconfig.json +24 -0
  76. package/dist/Brand.d.ts +3 -3
  77. package/dist/Brand.d.ts.map +1 -1
  78. package/dist/Brand.js +4 -3
  79. package/dist/Brand.js.map +1 -1
  80. package/dist/Cache.js +1 -1
  81. package/dist/Cache.js.map +1 -1
  82. package/dist/Channel.d.ts +1 -1
  83. package/dist/Channel.d.ts.map +1 -1
  84. package/dist/Channel.js.map +1 -1
  85. package/dist/Config.d.ts.map +1 -1
  86. package/dist/Config.js +30 -8
  87. package/dist/Config.js.map +1 -1
  88. package/dist/ConfigProvider.d.ts.map +1 -1
  89. package/dist/ConfigProvider.js +2 -1
  90. package/dist/ConfigProvider.js.map +1 -1
  91. package/dist/Context.d.ts +2 -3
  92. package/dist/Context.d.ts.map +1 -1
  93. package/dist/Context.js +1 -22
  94. package/dist/Context.js.map +1 -1
  95. package/dist/Cron.d.ts +31 -0
  96. package/dist/Cron.d.ts.map +1 -1
  97. package/dist/Cron.js +58 -2
  98. package/dist/Cron.js.map +1 -1
  99. package/dist/Crypto.d.ts.map +1 -1
  100. package/dist/Crypto.js +13 -5
  101. package/dist/Crypto.js.map +1 -1
  102. package/dist/Duration.d.ts.map +1 -1
  103. package/dist/Duration.js +12 -1
  104. package/dist/Duration.js.map +1 -1
  105. package/dist/Effect.d.ts +132 -14
  106. package/dist/Effect.d.ts.map +1 -1
  107. package/dist/Effect.js +38 -0
  108. package/dist/Effect.js.map +1 -1
  109. package/dist/Equal.d.ts.map +1 -1
  110. package/dist/Equal.js +10 -2
  111. package/dist/Equal.js.map +1 -1
  112. package/dist/ExecutionPlan.d.ts +73 -0
  113. package/dist/ExecutionPlan.d.ts.map +1 -1
  114. package/dist/ExecutionPlan.js +1 -1
  115. package/dist/ExecutionPlan.js.map +1 -1
  116. package/dist/FiberSet.js +1 -1
  117. package/dist/FileSystem.d.ts +2 -2
  118. package/dist/Function.d.ts +4 -3
  119. package/dist/Function.d.ts.map +1 -1
  120. package/dist/Function.js +5 -5
  121. package/dist/Function.js.map +1 -1
  122. package/dist/Iterable.d.ts.map +1 -1
  123. package/dist/Iterable.js +11 -10
  124. package/dist/Iterable.js.map +1 -1
  125. package/dist/Layer.d.ts.map +1 -1
  126. package/dist/Layer.js +7 -5
  127. package/dist/Layer.js.map +1 -1
  128. package/dist/Optic.d.ts +35 -21
  129. package/dist/Optic.d.ts.map +1 -1
  130. package/dist/Optic.js +33 -34
  131. package/dist/Optic.js.map +1 -1
  132. package/dist/Schedule.d.ts +8 -8
  133. package/dist/Schedule.d.ts.map +1 -1
  134. package/dist/Schedule.js +4 -4
  135. package/dist/Schedule.js.map +1 -1
  136. package/dist/Schema.d.ts +105 -57
  137. package/dist/Schema.d.ts.map +1 -1
  138. package/dist/Schema.js +105 -67
  139. package/dist/Schema.js.map +1 -1
  140. package/dist/SchemaAST.d.ts +33 -3
  141. package/dist/SchemaAST.d.ts.map +1 -1
  142. package/dist/SchemaAST.js +87 -63
  143. package/dist/SchemaAST.js.map +1 -1
  144. package/dist/SchemaError.d.ts +8 -8
  145. package/dist/SchemaError.d.ts.map +1 -1
  146. package/dist/SchemaError.js +7 -6
  147. package/dist/SchemaError.js.map +1 -1
  148. package/dist/SchemaGetter.d.ts +8 -5
  149. package/dist/SchemaGetter.d.ts.map +1 -1
  150. package/dist/SchemaGetter.js +41 -37
  151. package/dist/SchemaGetter.js.map +1 -1
  152. package/dist/SchemaIssue.d.ts +195 -38
  153. package/dist/SchemaIssue.d.ts.map +1 -1
  154. package/dist/SchemaIssue.js +243 -68
  155. package/dist/SchemaIssue.js.map +1 -1
  156. package/dist/SchemaParser.d.ts +30 -0
  157. package/dist/SchemaParser.d.ts.map +1 -1
  158. package/dist/SchemaParser.js +74 -62
  159. package/dist/SchemaParser.js.map +1 -1
  160. package/dist/SchemaTransformation.d.ts +2 -2
  161. package/dist/SchemaTransformation.d.ts.map +1 -1
  162. package/dist/SchemaTransformation.js +26 -26
  163. package/dist/SchemaTransformation.js.map +1 -1
  164. package/dist/ScopedCache.js +1 -1
  165. package/dist/ScopedCache.js.map +1 -1
  166. package/dist/Sink.d.ts +1 -1
  167. package/dist/Sink.d.ts.map +1 -1
  168. package/dist/Stdio.d.ts +17 -4
  169. package/dist/Stdio.d.ts.map +1 -1
  170. package/dist/Stdio.js +6 -3
  171. package/dist/Stdio.js.map +1 -1
  172. package/dist/Stream.d.ts +27 -4
  173. package/dist/Stream.d.ts.map +1 -1
  174. package/dist/Stream.js +27 -2
  175. package/dist/Stream.js.map +1 -1
  176. package/dist/SynchronizedRef.js +1 -1
  177. package/dist/SynchronizedRef.js.map +1 -1
  178. package/dist/Terminal.js +1 -1
  179. package/dist/Terminal.js.map +1 -1
  180. package/dist/Tuple.d.ts +6 -4
  181. package/dist/Tuple.d.ts.map +1 -1
  182. package/dist/Tuple.js.map +1 -1
  183. package/dist/TxReentrantLock.d.ts +0 -56
  184. package/dist/TxReentrantLock.d.ts.map +1 -1
  185. package/dist/TxReentrantLock.js +8 -8
  186. package/dist/TxReentrantLock.js.map +1 -1
  187. package/dist/internal/dateTime.js +1 -1
  188. package/dist/internal/dateTime.js.map +1 -1
  189. package/dist/internal/executionPlan.js +51 -3
  190. package/dist/internal/executionPlan.js.map +1 -1
  191. package/dist/internal/hashMap.js +12 -8
  192. package/dist/internal/hashMap.js.map +1 -1
  193. package/dist/internal/matcher.js +1 -1
  194. package/dist/internal/matcher.js.map +1 -1
  195. package/dist/internal/schedule.js.map +1 -1
  196. package/dist/internal/schema/annotations.js +2 -0
  197. package/dist/internal/schema/annotations.js.map +1 -1
  198. package/dist/internal/schema/schema.js +1 -9
  199. package/dist/internal/schema/schema.js.map +1 -1
  200. package/dist/internal/schema/toArbitrary.js +1 -1
  201. package/dist/internal/schema/toArbitrary.js.map +1 -1
  202. package/dist/internal/trie.js +13 -3
  203. package/dist/internal/trie.js.map +1 -1
  204. package/dist/testing/TestClock.d.ts.map +1 -1
  205. package/dist/testing/TestClock.js +11 -1
  206. package/dist/testing/TestClock.js.map +1 -1
  207. package/dist/testing/TestSchema.d.ts +2 -2
  208. package/dist/testing/TestSchema.d.ts.map +1 -1
  209. package/dist/testing/TestSchema.js +8 -7
  210. package/dist/testing/TestSchema.js.map +1 -1
  211. package/dist/unstable/ai/AiError.js +19 -19
  212. package/dist/unstable/ai/AiError.js.map +1 -1
  213. package/dist/unstable/ai/Chat.js +1 -1
  214. package/dist/unstable/ai/Chat.js.map +1 -1
  215. package/dist/unstable/ai/LanguageModel.js +4 -2
  216. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  217. package/dist/unstable/ai/McpSchema.d.ts +132 -132
  218. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  219. package/dist/unstable/ai/McpSchema.js +8 -8
  220. package/dist/unstable/ai/McpSchema.js.map +1 -1
  221. package/dist/unstable/ai/McpServer.js +1 -1
  222. package/dist/unstable/ai/McpServer.js.map +1 -1
  223. package/dist/unstable/ai/Prompt.d.ts +15 -3
  224. package/dist/unstable/ai/Prompt.d.ts.map +1 -1
  225. package/dist/unstable/ai/Prompt.js +10 -7
  226. package/dist/unstable/ai/Prompt.js.map +1 -1
  227. package/dist/unstable/cli/CliError.d.ts +3 -3
  228. package/dist/unstable/cli/CliError.js +11 -11
  229. package/dist/unstable/cli/CliError.js.map +1 -1
  230. package/dist/unstable/cli/Command.d.ts +9 -9
  231. package/dist/unstable/cli/Command.d.ts.map +1 -1
  232. package/dist/unstable/cli/Command.js +8 -6
  233. package/dist/unstable/cli/Command.js.map +1 -1
  234. package/dist/unstable/cli/Param.d.ts +7 -5
  235. package/dist/unstable/cli/Param.d.ts.map +1 -1
  236. package/dist/unstable/cli/Param.js +15 -11
  237. package/dist/unstable/cli/Param.js.map +1 -1
  238. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  239. package/dist/unstable/cli/Primitive.js +31 -24
  240. package/dist/unstable/cli/Primitive.js.map +1 -1
  241. package/dist/unstable/cli/Prompt.d.ts.map +1 -1
  242. package/dist/unstable/cli/Prompt.js +31 -17
  243. package/dist/unstable/cli/Prompt.js.map +1 -1
  244. package/dist/unstable/cli/internal/ansi.js +2 -2
  245. package/dist/unstable/cli/internal/ansi.js.map +1 -1
  246. package/dist/unstable/cli/internal/command.d.ts +2 -2
  247. package/dist/unstable/cli/internal/command.d.ts.map +1 -1
  248. package/dist/unstable/cli/internal/command.js +10 -9
  249. package/dist/unstable/cli/internal/command.js.map +1 -1
  250. package/dist/unstable/cli/internal/completions/bash.js +69 -9
  251. package/dist/unstable/cli/internal/completions/bash.js.map +1 -1
  252. package/dist/unstable/cli/internal/completions/descriptor.js +24 -18
  253. package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
  254. package/dist/unstable/cli/internal/completions/fish.js +5 -5
  255. package/dist/unstable/cli/internal/completions/fish.js.map +1 -1
  256. package/dist/unstable/cli/internal/help.d.ts.map +1 -1
  257. package/dist/unstable/cli/internal/help.js +4 -2
  258. package/dist/unstable/cli/internal/help.js.map +1 -1
  259. package/dist/unstable/cli/internal/parser.js +3 -3
  260. package/dist/unstable/cli/internal/parser.js.map +1 -1
  261. package/dist/unstable/cli/internal/wizard.js +2 -2
  262. package/dist/unstable/cli/internal/wizard.js.map +1 -1
  263. package/dist/unstable/cluster/ClusterError.js +7 -7
  264. package/dist/unstable/cluster/ClusterError.js.map +1 -1
  265. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  266. package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
  267. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  268. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  269. package/dist/unstable/cluster/MessageStorage.js +8 -1
  270. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  271. package/dist/unstable/cluster/Reply.d.ts +8 -0
  272. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  273. package/dist/unstable/cluster/Reply.js +16 -4
  274. package/dist/unstable/cluster/Reply.js.map +1 -1
  275. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  276. package/dist/unstable/cluster/RunnerServer.js +4 -2
  277. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  278. package/dist/unstable/cluster/RunnerStorage.d.ts +1 -2
  279. package/dist/unstable/cluster/RunnerStorage.d.ts.map +1 -1
  280. package/dist/unstable/cluster/RunnerStorage.js +7 -6
  281. package/dist/unstable/cluster/RunnerStorage.js.map +1 -1
  282. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  283. package/dist/unstable/cluster/Sharding.js +22 -4
  284. package/dist/unstable/cluster/Sharding.js.map +1 -1
  285. package/dist/unstable/cluster/internal/entityManager.js +1 -1
  286. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  287. package/dist/unstable/cluster/internal/resourceMap.js +2 -2
  288. package/dist/unstable/cluster/internal/resourceMap.js.map +1 -1
  289. package/dist/unstable/cluster/internal/resourceRef.js +17 -0
  290. package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
  291. package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
  292. package/dist/unstable/devtools/DevToolsClient.js +7 -2
  293. package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
  294. package/dist/unstable/encoding/Ini.d.ts +20 -0
  295. package/dist/unstable/encoding/Ini.d.ts.map +1 -0
  296. package/dist/unstable/encoding/Ini.js +153 -0
  297. package/dist/unstable/encoding/Ini.js.map +1 -0
  298. package/dist/unstable/encoding/Msgpack.d.ts +2 -1
  299. package/dist/unstable/encoding/Msgpack.d.ts.map +1 -1
  300. package/dist/unstable/encoding/Msgpack.js +27 -13
  301. package/dist/unstable/encoding/Msgpack.js.map +1 -1
  302. package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
  303. package/dist/unstable/encoding/Ndjson.js +7 -1
  304. package/dist/unstable/encoding/Ndjson.js.map +1 -1
  305. package/dist/unstable/encoding/Sse.d.ts.map +1 -1
  306. package/dist/unstable/encoding/Sse.js +14 -23
  307. package/dist/unstable/encoding/Sse.js.map +1 -1
  308. package/dist/unstable/encoding/Toml.d.ts +19 -0
  309. package/dist/unstable/encoding/Toml.d.ts.map +1 -0
  310. package/dist/unstable/encoding/Toml.js +434 -0
  311. package/dist/unstable/encoding/Toml.js.map +1 -0
  312. package/dist/unstable/encoding/Yaml.d.ts +19 -0
  313. package/dist/unstable/encoding/Yaml.d.ts.map +1 -0
  314. package/dist/unstable/encoding/Yaml.js +461 -0
  315. package/dist/unstable/encoding/Yaml.js.map +1 -0
  316. package/dist/unstable/encoding/index.d.ts +12 -0
  317. package/dist/unstable/encoding/index.d.ts.map +1 -1
  318. package/dist/unstable/encoding/index.js +12 -0
  319. package/dist/unstable/encoding/index.js.map +1 -1
  320. package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
  321. package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
  322. package/dist/unstable/eventlog/EventJournal.js +13 -5
  323. package/dist/unstable/eventlog/EventJournal.js.map +1 -1
  324. package/dist/unstable/eventlog/EventLogMessage.js +1 -1
  325. package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
  326. package/dist/unstable/eventlog/EventLogServerUnencrypted.js +1 -1
  327. package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
  328. package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
  329. package/dist/unstable/eventlog/SqlEventJournal.js +1 -4
  330. package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
  331. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts +11 -0
  332. package/dist/unstable/http/FindMyWay/internal/queryString.d.ts.map +1 -0
  333. package/dist/unstable/http/FindMyWay/internal/queryString.js +259 -0
  334. package/dist/unstable/http/FindMyWay/internal/queryString.js.map +1 -0
  335. package/dist/unstable/http/FindMyWay/internal/router.d.ts +2 -0
  336. package/dist/unstable/http/FindMyWay/internal/router.d.ts.map +1 -0
  337. package/dist/unstable/http/FindMyWay/internal/router.js +665 -0
  338. package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -0
  339. package/dist/unstable/http/FindMyWay.d.ts +33 -8
  340. package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
  341. package/dist/unstable/http/FindMyWay.js +4 -7
  342. package/dist/unstable/http/FindMyWay.js.map +1 -1
  343. package/dist/unstable/http/HttpClient.d.ts +59 -3
  344. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  345. package/dist/unstable/http/HttpClient.js +33 -19
  346. package/dist/unstable/http/HttpClient.js.map +1 -1
  347. package/dist/unstable/http/HttpClientError.js +1 -1
  348. package/dist/unstable/http/HttpClientError.js.map +1 -1
  349. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  350. package/dist/unstable/http/HttpClientRequest.js +2 -14
  351. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  352. package/dist/unstable/http/HttpClientResponse.js +1 -16
  353. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  354. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  355. package/dist/unstable/http/HttpPlatform.js +21 -3
  356. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  357. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  358. package/dist/unstable/http/HttpServerRequest.js +7 -6
  359. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  360. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  361. package/dist/unstable/http/HttpServerResponse.js +8 -6
  362. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  363. package/dist/unstable/http/Multipart.d.ts +1 -1
  364. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  365. package/dist/unstable/http/Multipart.js +9 -2
  366. package/dist/unstable/http/Multipart.js.map +1 -1
  367. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts +53 -0
  368. package/dist/unstable/http/MultipartParser/HeadersParser.d.ts.map +1 -0
  369. package/dist/unstable/http/MultipartParser/HeadersParser.js +14 -0
  370. package/dist/unstable/http/MultipartParser/HeadersParser.js.map +1 -0
  371. package/dist/unstable/http/MultipartParser/Search.d.ts +11 -0
  372. package/dist/unstable/http/MultipartParser/Search.d.ts.map +1 -0
  373. package/dist/unstable/http/MultipartParser/Search.js +14 -0
  374. package/dist/unstable/http/MultipartParser/Search.js.map +1 -0
  375. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts +5 -0
  376. package/dist/unstable/http/MultipartParser/internal/contentType.d.ts.map +1 -0
  377. package/dist/unstable/http/MultipartParser/internal/contentType.js +82 -0
  378. package/dist/unstable/http/MultipartParser/internal/contentType.js.map +1 -0
  379. package/dist/unstable/http/MultipartParser/internal/headers.d.ts +3 -0
  380. package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -0
  381. package/dist/unstable/http/MultipartParser/internal/headers.js +194 -0
  382. package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -0
  383. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +8 -0
  384. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -0
  385. package/dist/unstable/http/MultipartParser/internal/multipart.js +226 -0
  386. package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -0
  387. package/dist/unstable/http/MultipartParser/internal/search.d.ts +5 -0
  388. package/dist/unstable/http/MultipartParser/internal/search.d.ts.map +1 -0
  389. package/dist/unstable/http/MultipartParser/internal/search.js +120 -0
  390. package/dist/unstable/http/MultipartParser/internal/search.js.map +1 -0
  391. package/dist/unstable/http/MultipartParser.d.ts +98 -0
  392. package/dist/unstable/http/MultipartParser.d.ts.map +1 -0
  393. package/dist/unstable/http/MultipartParser.js +23 -0
  394. package/dist/unstable/http/MultipartParser.js.map +1 -0
  395. package/dist/unstable/http/Template.d.ts.map +1 -1
  396. package/dist/unstable/http/Template.js +2 -2
  397. package/dist/unstable/http/Template.js.map +1 -1
  398. package/dist/unstable/http/index.d.ts +1 -1
  399. package/dist/unstable/http/index.d.ts.map +1 -1
  400. package/dist/unstable/http/index.js +1 -1
  401. package/dist/unstable/http/index.js.map +1 -1
  402. package/dist/unstable/http/internal/httpBody.d.ts +2 -0
  403. package/dist/unstable/http/internal/httpBody.d.ts.map +1 -0
  404. package/dist/unstable/http/internal/httpBody.js +10 -0
  405. package/dist/unstable/http/internal/httpBody.js.map +1 -0
  406. package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
  407. package/dist/unstable/httpapi/HttpApi.js +5 -5
  408. package/dist/unstable/httpapi/HttpApi.js.map +1 -1
  409. package/dist/unstable/httpapi/HttpApiBuilder.js +73 -20
  410. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  411. package/dist/unstable/httpapi/HttpApiClient.d.ts +1 -1
  412. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  413. package/dist/unstable/httpapi/HttpApiClient.js +74 -34
  414. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  415. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +6 -4
  416. package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
  417. package/dist/unstable/httpapi/HttpApiEndpoint.js +73 -16
  418. package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
  419. package/dist/unstable/httpapi/HttpApiError.d.ts +5 -5
  420. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  421. package/dist/unstable/httpapi/HttpApiError.js +17 -17
  422. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  423. package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +1 -1
  424. package/dist/unstable/httpapi/HttpApiMiddleware.js +1 -1
  425. package/dist/unstable/httpapi/HttpApiSchema.d.ts +219 -0
  426. package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
  427. package/dist/unstable/httpapi/HttpApiSchema.js +170 -0
  428. package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
  429. package/dist/unstable/httpapi/OpenApi.d.ts +8 -0
  430. package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
  431. package/dist/unstable/httpapi/OpenApi.js +45 -18
  432. package/dist/unstable/httpapi/OpenApi.js.map +1 -1
  433. package/dist/unstable/observability/OtlpExporter.d.ts +1 -1
  434. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  435. package/dist/unstable/observability/OtlpExporter.js +2 -1
  436. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  437. package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
  438. package/dist/unstable/observability/OtlpLogger.js +2 -2
  439. package/dist/unstable/observability/OtlpLogger.js.map +1 -1
  440. package/dist/unstable/observability/OtlpMetrics.d.ts +2 -2
  441. package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
  442. package/dist/unstable/observability/OtlpMetrics.js +28 -15
  443. package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
  444. package/dist/unstable/observability/OtlpTracer.js +1 -1
  445. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  446. package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
  447. package/dist/unstable/persistence/PersistedQueue.js +9 -9
  448. package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
  449. package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
  450. package/dist/unstable/persistence/Persistence.js +17 -7
  451. package/dist/unstable/persistence/Persistence.js.map +1 -1
  452. package/dist/unstable/persistence/RateLimiter.d.ts +22 -12
  453. package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
  454. package/dist/unstable/persistence/RateLimiter.js +15 -42
  455. package/dist/unstable/persistence/RateLimiter.js.map +1 -1
  456. package/dist/unstable/persistence/Redis.js +1 -1
  457. package/dist/unstable/persistence/Redis.js.map +1 -1
  458. package/dist/unstable/reactivity/AsyncResult.d.ts.map +1 -1
  459. package/dist/unstable/reactivity/AsyncResult.js +4 -4
  460. package/dist/unstable/reactivity/AsyncResult.js.map +1 -1
  461. package/dist/unstable/reactivity/Atom.d.ts +26 -11
  462. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  463. package/dist/unstable/reactivity/Atom.js +9 -22
  464. package/dist/unstable/reactivity/Atom.js.map +1 -1
  465. package/dist/unstable/rpc/RpcClient.d.ts +14 -0
  466. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  467. package/dist/unstable/rpc/RpcClient.js +21 -10
  468. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  469. package/dist/unstable/rpc/RpcClientError.js +2 -2
  470. package/dist/unstable/rpc/RpcClientError.js.map +1 -1
  471. package/dist/unstable/rpc/RpcSerialization.js +3 -1
  472. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  473. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  474. package/dist/unstable/rpc/RpcServer.js +3 -2
  475. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  476. package/dist/unstable/schema/Model.d.ts +1 -1
  477. package/dist/unstable/schema/Model.d.ts.map +1 -1
  478. package/dist/unstable/schema/VariantSchema.d.ts +5 -5
  479. package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
  480. package/dist/unstable/schema/VariantSchema.js +17 -9
  481. package/dist/unstable/schema/VariantSchema.js.map +1 -1
  482. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  483. package/dist/unstable/socket/Socket.js +28 -12
  484. package/dist/unstable/socket/Socket.js.map +1 -1
  485. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  486. package/dist/unstable/sql/SqlClient.js +7 -3
  487. package/dist/unstable/sql/SqlClient.js.map +1 -1
  488. package/dist/unstable/sql/SqlError.js +13 -13
  489. package/dist/unstable/sql/SqlError.js.map +1 -1
  490. package/dist/unstable/sql/SqlResolver.js +8 -6
  491. package/dist/unstable/sql/SqlResolver.js.map +1 -1
  492. package/dist/unstable/sql/Statement.d.ts.map +1 -1
  493. package/dist/unstable/sql/Statement.js +8 -6
  494. package/dist/unstable/sql/Statement.js.map +1 -1
  495. package/dist/unstable/workers/WorkerError.js +5 -5
  496. package/dist/unstable/workers/WorkerError.js.map +1 -1
  497. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  498. package/dist/unstable/workflow/Workflow.js +2 -2
  499. package/dist/unstable/workflow/Workflow.js.map +1 -1
  500. package/dist/unstable/workflow/WorkflowEngine.d.ts +1 -1
  501. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  502. package/dist/unstable/workflow/WorkflowEngine.js +3 -3
  503. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  504. package/package.json +6 -9
  505. package/src/Brand.ts +4 -4
  506. package/src/Cache.ts +1 -1
  507. package/src/Channel.ts +1 -1
  508. package/src/Config.ts +31 -8
  509. package/src/ConfigProvider.ts +4 -1
  510. package/src/Context.ts +6 -28
  511. package/src/Cron.ts +65 -2
  512. package/src/Crypto.ts +17 -8
  513. package/src/Duration.ts +16 -2
  514. package/src/Effect.ts +141 -17
  515. package/src/Equal.ts +10 -2
  516. package/src/ExecutionPlan.ts +78 -1
  517. package/src/FiberSet.ts +1 -1
  518. package/src/FileSystem.ts +2 -2
  519. package/src/Function.ts +6 -6
  520. package/src/Iterable.ts +11 -10
  521. package/src/Layer.ts +7 -5
  522. package/src/Optic.ts +59 -58
  523. package/src/Schedule.ts +13 -13
  524. package/src/Schema.ts +195 -112
  525. package/src/SchemaAST.ts +154 -85
  526. package/src/SchemaError.ts +9 -9
  527. package/src/SchemaGetter.ts +89 -30
  528. package/src/SchemaIssue.ts +285 -80
  529. package/src/SchemaParser.ts +126 -86
  530. package/src/SchemaTransformation.ts +66 -18
  531. package/src/ScopedCache.ts +1 -1
  532. package/src/Sink.ts +1 -1
  533. package/src/Stdio.ts +23 -4
  534. package/src/Stream.ts +77 -10
  535. package/src/SynchronizedRef.ts +1 -1
  536. package/src/Terminal.ts +1 -1
  537. package/src/Tuple.ts +7 -4
  538. package/src/TxReentrantLock.ts +39 -35
  539. package/src/internal/dateTime.ts +1 -1
  540. package/src/internal/executionPlan.ts +105 -10
  541. package/src/internal/hashMap.ts +20 -14
  542. package/src/internal/matcher.ts +2 -2
  543. package/src/internal/schedule.ts +4 -4
  544. package/src/internal/schema/annotations.ts +3 -0
  545. package/src/internal/schema/schema.ts +1 -17
  546. package/src/internal/schema/toArbitrary.ts +3 -1
  547. package/src/internal/trie.ts +12 -2
  548. package/src/testing/TestClock.ts +13 -1
  549. package/src/testing/TestSchema.ts +9 -9
  550. package/src/unstable/ai/AiError.ts +19 -19
  551. package/src/unstable/ai/Chat.ts +1 -1
  552. package/src/unstable/ai/LanguageModel.ts +4 -2
  553. package/src/unstable/ai/McpSchema.ts +17 -16
  554. package/src/unstable/ai/McpServer.ts +1 -1
  555. package/src/unstable/ai/Prompt.ts +35 -10
  556. package/src/unstable/cli/CliError.ts +12 -12
  557. package/src/unstable/cli/Command.ts +12 -10
  558. package/src/unstable/cli/Param.ts +41 -19
  559. package/src/unstable/cli/Primitive.ts +11 -5
  560. package/src/unstable/cli/Prompt.ts +36 -20
  561. package/src/unstable/cli/internal/ansi.ts +2 -2
  562. package/src/unstable/cli/internal/command.ts +15 -10
  563. package/src/unstable/cli/internal/completions/bash.ts +59 -9
  564. package/src/unstable/cli/internal/completions/descriptor.ts +14 -20
  565. package/src/unstable/cli/internal/completions/fish.ts +5 -7
  566. package/src/unstable/cli/internal/help.ts +4 -2
  567. package/src/unstable/cli/internal/parser.ts +3 -3
  568. package/src/unstable/cli/internal/wizard.ts +2 -2
  569. package/src/unstable/cluster/ClusterError.ts +7 -7
  570. package/src/unstable/cluster/ClusterWorkflowEngine.ts +4 -1
  571. package/src/unstable/cluster/MessageStorage.ts +9 -5
  572. package/src/unstable/cluster/Reply.ts +25 -4
  573. package/src/unstable/cluster/RunnerServer.ts +4 -10
  574. package/src/unstable/cluster/RunnerStorage.ts +9 -7
  575. package/src/unstable/cluster/Sharding.ts +35 -7
  576. package/src/unstable/cluster/internal/entityManager.ts +1 -1
  577. package/src/unstable/cluster/internal/resourceMap.ts +5 -2
  578. package/src/unstable/cluster/internal/resourceRef.ts +27 -5
  579. package/src/unstable/devtools/DevToolsClient.ts +3 -2
  580. package/src/unstable/encoding/Ini.ts +174 -0
  581. package/src/unstable/encoding/Msgpack.ts +59 -36
  582. package/src/unstable/encoding/Ndjson.ts +9 -1
  583. package/src/unstable/encoding/Sse.ts +11 -21
  584. package/src/unstable/encoding/Toml.ts +504 -0
  585. package/src/unstable/encoding/Yaml.ts +541 -0
  586. package/src/unstable/encoding/index.ts +15 -0
  587. package/src/unstable/eventlog/EventJournal.ts +14 -6
  588. package/src/unstable/eventlog/EventLogMessage.ts +1 -1
  589. package/src/unstable/eventlog/EventLogServerUnencrypted.ts +1 -1
  590. package/src/unstable/eventlog/SqlEventJournal.ts +6 -4
  591. package/src/unstable/http/FindMyWay/internal/queryString.ts +420 -0
  592. package/src/unstable/http/FindMyWay/internal/router.ts +950 -0
  593. package/src/unstable/http/FindMyWay.ts +65 -6
  594. package/src/unstable/http/HttpClient.ts +132 -23
  595. package/src/unstable/http/HttpClientError.ts +1 -1
  596. package/src/unstable/http/HttpClientRequest.ts +2 -14
  597. package/src/unstable/http/HttpClientResponse.ts +1 -17
  598. package/src/unstable/http/HttpPlatform.ts +34 -6
  599. package/src/unstable/http/HttpServerRequest.ts +14 -6
  600. package/src/unstable/http/HttpServerResponse.ts +9 -7
  601. package/src/unstable/http/Multipart.ts +9 -2
  602. package/src/unstable/http/MultipartParser/HeadersParser.ts +68 -0
  603. package/src/unstable/http/MultipartParser/Search.ts +17 -0
  604. package/src/unstable/http/MultipartParser/internal/contentType.ts +103 -0
  605. package/src/unstable/http/MultipartParser/internal/headers.ts +615 -0
  606. package/src/unstable/http/MultipartParser/internal/multipart.ts +262 -0
  607. package/src/unstable/http/MultipartParser/internal/search.ts +167 -0
  608. package/src/unstable/http/MultipartParser.ts +115 -0
  609. package/src/unstable/http/Template.ts +6 -5
  610. package/src/unstable/http/index.ts +1 -1
  611. package/src/unstable/http/internal/httpBody.ts +15 -0
  612. package/src/unstable/httpapi/HttpApi.ts +6 -7
  613. package/src/unstable/httpapi/HttpApiBuilder.ts +142 -25
  614. package/src/unstable/httpapi/HttpApiClient.ts +130 -49
  615. package/src/unstable/httpapi/HttpApiEndpoint.ts +117 -29
  616. package/src/unstable/httpapi/HttpApiError.ts +33 -39
  617. package/src/unstable/httpapi/HttpApiMiddleware.ts +1 -1
  618. package/src/unstable/httpapi/HttpApiSchema.ts +353 -0
  619. package/src/unstable/httpapi/OpenApi.ts +70 -20
  620. package/src/unstable/observability/OtlpExporter.ts +4 -2
  621. package/src/unstable/observability/OtlpLogger.ts +3 -1
  622. package/src/unstable/observability/OtlpMetrics.ts +32 -18
  623. package/src/unstable/observability/OtlpTracer.ts +1 -1
  624. package/src/unstable/persistence/PersistedQueue.ts +12 -9
  625. package/src/unstable/persistence/Persistence.ts +27 -7
  626. package/src/unstable/persistence/RateLimiter.ts +54 -31
  627. package/src/unstable/persistence/Redis.ts +1 -1
  628. package/src/unstable/reactivity/AsyncResult.ts +11 -6
  629. package/src/unstable/reactivity/Atom.ts +44 -25
  630. package/src/unstable/rpc/RpcClient.ts +42 -13
  631. package/src/unstable/rpc/RpcClientError.ts +2 -2
  632. package/src/unstable/rpc/RpcSerialization.ts +1 -1
  633. package/src/unstable/rpc/RpcServer.ts +4 -2
  634. package/src/unstable/schema/VariantSchema.ts +36 -18
  635. package/src/unstable/socket/Socket.ts +24 -14
  636. package/src/unstable/sql/SqlClient.ts +65 -56
  637. package/src/unstable/sql/SqlError.ts +13 -13
  638. package/src/unstable/sql/SqlResolver.ts +8 -6
  639. package/src/unstable/sql/Statement.ts +13 -8
  640. package/src/unstable/workers/WorkerError.ts +5 -5
  641. package/src/unstable/workflow/Workflow.ts +2 -5
  642. package/src/unstable/workflow/WorkflowEngine.ts +8 -3
  643. package/dist/unstable/http/Multipasta/HeadersParser.d.ts +0 -14
  644. package/dist/unstable/http/Multipasta/HeadersParser.d.ts.map +0 -1
  645. package/dist/unstable/http/Multipasta/HeadersParser.js +0 -14
  646. package/dist/unstable/http/Multipasta/HeadersParser.js.map +0 -1
  647. package/dist/unstable/http/Multipasta/Node.d.ts +0 -14
  648. package/dist/unstable/http/Multipasta/Node.d.ts.map +0 -1
  649. package/dist/unstable/http/Multipasta/Node.js +0 -14
  650. package/dist/unstable/http/Multipasta/Node.js.map +0 -1
  651. package/dist/unstable/http/Multipasta/Search.d.ts +0 -14
  652. package/dist/unstable/http/Multipasta/Search.d.ts.map +0 -1
  653. package/dist/unstable/http/Multipasta/Search.js +0 -14
  654. package/dist/unstable/http/Multipasta/Search.js.map +0 -1
  655. package/dist/unstable/http/Multipasta/Web.d.ts +0 -14
  656. package/dist/unstable/http/Multipasta/Web.d.ts.map +0 -1
  657. package/dist/unstable/http/Multipasta/Web.js +0 -14
  658. package/dist/unstable/http/Multipasta/Web.js.map +0 -1
  659. package/dist/unstable/http/Multipasta.d.ts +0 -15
  660. package/dist/unstable/http/Multipasta.d.ts.map +0 -1
  661. package/dist/unstable/http/Multipasta.js +0 -15
  662. package/dist/unstable/http/Multipasta.js.map +0 -1
  663. package/src/unstable/http/Multipasta/HeadersParser.ts +0 -14
  664. package/src/unstable/http/Multipasta/Node.ts +0 -14
  665. package/src/unstable/http/Multipasta/Search.ts +0 -14
  666. package/src/unstable/http/Multipasta/Web.ts +0 -14
  667. package/src/unstable/http/Multipasta.ts +0 -15
@@ -71,8 +71,8 @@ export type AggregationTemporality = "cumulative" | "delta"
71
71
  *
72
72
  * The exporter snapshots registered Effect metrics on the configured interval, serializes them with the selected aggregation temporality, and flushes during scope finalization up to `shutdownTimeout`.
73
73
  * Manual flushing also triggers a snapshot. With delta temporality, each
74
- * snapshot advances the previous-export state, so frequent flushes narrow the
75
- * delta aggregation windows.
74
+ * successful export advances the previous-export state, so frequent successful
75
+ * flushes narrow the delta aggregation windows.
76
76
  *
77
77
  * @category constructors
78
78
  * @since 4.0.0
@@ -108,15 +108,22 @@ export const make: (options: {
108
108
 
109
109
  // State for delta temporality tracking
110
110
  let previousExportTimeNanos: bigint = startTimeNanos
111
- const previousCounterState = new Map<string, number | bigint>()
112
- const previousHistogramState = new Map<string, PreviousHistogramState>()
113
- const previousFrequencyState = new Map<string, Map<string, number>>()
114
- const previousSummaryState = new Map<string, PreviousSummaryState>()
115
-
116
- const snapshot = (): HttpBody => {
111
+ let previousCounterState = new Map<string, number | bigint>()
112
+ let previousHistogramState = new Map<string, PreviousHistogramState>()
113
+ let previousFrequencyState = new Map<string, Map<string, number>>()
114
+ let previousSummaryState = new Map<string, PreviousSummaryState>()
115
+ let snapshotSequence = 0
116
+ let committedSnapshotSequence = -1
117
+
118
+ const snapshot = (): readonly [body: HttpBody, onSuccess: Effect.Effect<void>] => {
117
119
  const snapshot = Metric.snapshotUnsafe(services)
120
+ const currentSnapshotSequence = snapshotSequence++
118
121
  const nowNanos = clock.currentTimeNanosUnsafe()
119
122
  const nowTime = String(nowNanos)
123
+ const nextCounterState = new Map(previousCounterState)
124
+ const nextHistogramState = new Map(previousHistogramState)
125
+ const nextFrequencyState = new Map(previousFrequencyState)
126
+ const nextSummaryState = new Map(previousSummaryState)
120
127
  const metricData: Array<IMetric> = []
121
128
  const metricDataByName = new Map<string, IMetric>()
122
129
  const addMetricData = (data: IMetric) => {
@@ -162,7 +169,7 @@ export const make: (options: {
162
169
  }
163
170
  }
164
171
  }
165
- previousCounterState.set(metricKey, currentCount)
172
+ nextCounterState.set(metricKey, currentCount)
166
173
  }
167
174
 
168
175
  const dataPoint: INumberDataPoint = {
@@ -253,7 +260,7 @@ export const make: (options: {
253
260
  // Note: This is a limitation - true delta min/max would require tracking
254
261
  // observations within each interval
255
262
  }
256
- previousHistogramState.set(metricKey, {
263
+ nextHistogramState.set(metricKey, {
257
264
  count: state.state.count,
258
265
  sum: state.state.sum,
259
266
  bucketCounts: currentBuckets.counts.slice(),
@@ -314,7 +321,7 @@ export const make: (options: {
314
321
  }
315
322
 
316
323
  if (isDelta) {
317
- previousFrequencyState.set(metricKey, currentOccurrences)
324
+ nextFrequencyState.set(metricKey, currentOccurrences)
318
325
  }
319
326
 
320
327
  if (metricDataByName.has(state.id)) {
@@ -366,7 +373,7 @@ export const make: (options: {
366
373
  reportCount = state.state.count - previousState.count
367
374
  reportSum = state.state.sum - previousState.sum
368
375
  }
369
- previousSummaryState.set(metricKey, {
376
+ nextSummaryState.set(metricKey, {
370
377
  count: state.state.count,
371
378
  sum: state.state.sum
372
379
  })
@@ -426,12 +433,7 @@ export const make: (options: {
426
433
  }
427
434
  }
428
435
 
429
- // Update the previous export time for delta calculations
430
- if (isDelta) {
431
- previousExportTimeNanos = nowNanos
432
- }
433
-
434
- return serialization.metrics({
436
+ const body = serialization.metrics({
435
437
  resourceMetrics: [{
436
438
  resource,
437
439
  scopeMetrics: [{
@@ -440,6 +442,18 @@ export const make: (options: {
440
442
  }]
441
443
  }]
442
444
  })
445
+ const onSuccess = isDelta
446
+ ? Effect.sync(() => {
447
+ if (currentSnapshotSequence < committedSnapshotSequence) return
448
+ previousCounterState = nextCounterState
449
+ previousHistogramState = nextHistogramState
450
+ previousFrequencyState = nextFrequencyState
451
+ previousSummaryState = nextSummaryState
452
+ previousExportTimeNanos = nowNanos
453
+ committedSnapshotSequence = currentSnapshotSequence
454
+ })
455
+ : Effect.void
456
+ return [body, onSuccess]
443
457
  }
444
458
 
445
459
  yield* Exporter.make({
@@ -83,7 +83,7 @@ export const make: (
83
83
  }]
84
84
  }]
85
85
  }
86
- return serialization.traces(data)
86
+ return [serialization.traces(data), Effect.void]
87
87
  },
88
88
  shutdownTimeout: options.shutdownTimeout ?? Duration.seconds(3)
89
89
  })
@@ -217,7 +217,7 @@ export type ErrorTypeId = "~@effect/experimental/PersistedQueue/PersistedQueueEr
217
217
  * @category errors
218
218
  * @since 4.0.0
219
219
  */
220
- export class PersistedQueueError extends Schema.ErrorClass<PersistedQueueError>(
220
+ export class PersistedQueueError extends Schema.Error<PersistedQueueError>(
221
221
  "effect/persistence/PersistedQueue/PersistedQueueError"
222
222
  )({
223
223
  _tag: Schema.tag("PersistedQueueError"),
@@ -294,9 +294,9 @@ export const layerStoreMemory: Layer.Layer<
294
294
  attempts: number
295
295
  readonly element: unknown
296
296
  }
297
- const ids = new Set<string>()
298
297
  const queues = new Map<string, {
299
298
  latch: Latch.Latch
299
+ ids: Set<string>
300
300
  items: Set<Entry>
301
301
  }>()
302
302
  const getOrCreateQueue = (name: string) => {
@@ -304,6 +304,7 @@ export const layerStoreMemory: Layer.Layer<
304
304
  if (!queue) {
305
305
  queue = {
306
306
  latch: Latch.makeUnsafe(false),
307
+ ids: new Set(),
307
308
  items: new Set()
308
309
  }
309
310
  queues.set(name, queue)
@@ -314,9 +315,9 @@ export const layerStoreMemory: Layer.Layer<
314
315
  return PersistedQueueStore.of({
315
316
  offer: (options) =>
316
317
  Effect.sync(() => {
317
- if (ids.has(options.id)) return
318
- ids.add(options.id)
319
318
  const queue = getOrCreateQueue(options.name)
319
+ if (queue.ids.has(options.id)) return
320
+ queue.ids.add(options.id)
320
321
  queue.items.add({ id: options.id, attempts: 0, element: options.element })
321
322
  queue.latch.openUnsafe()
322
323
  }),
@@ -857,9 +858,11 @@ export const makeStoreSql: (
857
858
  yield* sql.onDialectOrElse({
858
859
  mssql: () =>
859
860
  sql`IF NOT EXISTS (SELECT * FROM sys.indexes WHERE name = N'idx_${tableName}_id')
860
- CREATE UNIQUE INDEX idx_${tableNameSql}_id ON ${tableNameSql} (id)`,
861
- mysql: () => sql`CREATE UNIQUE INDEX ${sql(`idx_${tableName}_id`)} ON ${tableNameSql} (id)`.pipe(Effect.ignore),
862
- orElse: () => sql`CREATE UNIQUE INDEX IF NOT EXISTS ${sql(`idx_${tableName}_id`)} ON ${tableNameSql} (id)`
861
+ CREATE UNIQUE INDEX idx_${tableNameSql}_id ON ${tableNameSql} (id, queue_name)`,
862
+ mysql: () =>
863
+ sql`CREATE UNIQUE INDEX ${sql(`idx_${tableName}_id`)} ON ${tableNameSql} (id, queue_name)`.pipe(Effect.ignore),
864
+ orElse: () =>
865
+ sql`CREATE UNIQUE INDEX IF NOT EXISTS ${sql(`idx_${tableName}_id`)} ON ${tableNameSql} (id, queue_name)`
863
866
  })
864
867
 
865
868
  yield* sql.onDialectOrElse({
@@ -894,7 +897,7 @@ export const makeStoreSql: (
894
897
  sql`
895
898
  INSERT INTO ${tableNameSql} (id, queue_name, element, completed, attempts, created_at, updated_at)
896
899
  VALUES (${id}, ${name}, ${element}, FALSE, 0, ${sqlNow}, ${sqlNow})
897
- ON CONFLICT (id) DO NOTHING
900
+ ON CONFLICT (id, queue_name) DO NOTHING
898
901
  `,
899
902
  mysql: () => (id: string, name: string, element: string) =>
900
903
  sql`
@@ -903,7 +906,7 @@ export const makeStoreSql: (
903
906
  `,
904
907
  mssql: () => (id: string, name: string, element: string) =>
905
908
  sql`
906
- IF NOT EXISTS (SELECT 1 FROM ${tableNameSql} WHERE id = ${id})
909
+ IF NOT EXISTS (SELECT 1 FROM ${tableNameSql} WHERE id = ${id} AND queue_name = ${name})
907
910
  BEGIN
908
911
  INSERT INTO ${tableNameSql} (id, queue_name, element, completed, attempts, created_at, updated_at)
909
912
  VALUES (${id}, ${name}, ${element}, 0, 0, ${sqlNow}, ${sqlNow})
@@ -35,7 +35,7 @@ const ErrorTypeId = "~effect/persistence/Persistence/PersistenceError" as const
35
35
  * @category errors
36
36
  * @since 4.0.0
37
37
  */
38
- export class PersistenceError extends Schema.ErrorClass<PersistenceError>(ErrorTypeId)({
38
+ export class PersistenceError extends Schema.Error<PersistenceError>(ErrorTypeId)({
39
39
  _tag: Schema.tag("PersistenceError"),
40
40
  message: Schema.String,
41
41
  cause: Schema.optional(Schema.Defect())
@@ -304,7 +304,8 @@ export const layerBackingSqlMultiTable: Layer.Layer<
304
304
  return BackingPersistence.of({
305
305
  make: Effect.fnUntraced(function*(storeId) {
306
306
  const clock = yield* Clock.Clock
307
- const table = sql(`effect_persistence_${storeId}`)
307
+ const tableName = `effect_persistence_${storeId}`
308
+ const table = sql(tableName)
308
309
  yield* sql.onDialectOrElse({
309
310
  mysql: () =>
310
311
  sql`
@@ -324,7 +325,7 @@ export const layerBackingSqlMultiTable: Layer.Layer<
324
325
  `,
325
326
  mssql: () =>
326
327
  sql`
327
- IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${table} AND xtype='U')
328
+ IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${tableName} AND xtype='U')
328
329
  CREATE TABLE ${table} (
329
330
  id NVARCHAR(450) PRIMARY KEY,
330
331
  value NVARCHAR(MAX) NOT NULL,
@@ -362,6 +363,20 @@ export const layerBackingSqlMultiTable: Layer.Layer<
362
363
  INSERT INTO ${table} ${sql.insert(entries)}
363
364
  ON DUPLICATE KEY UPDATE value=VALUES(value), expires=VALUES(expires)
364
365
  `.unprepared,
366
+ mssql: (): UpsertFn => (entries) =>
367
+ Effect.forEach(
368
+ entries,
369
+ (entry) =>
370
+ sql`
371
+ MERGE ${table} AS target
372
+ USING (SELECT ${entry.id} AS id, ${entry.value} AS value, ${entry.expires} AS expires) AS source
373
+ ON target.id = source.id
374
+ WHEN MATCHED THEN UPDATE SET value = source.value, expires = source.expires
375
+ WHEN NOT MATCHED THEN INSERT (id, value, expires)
376
+ VALUES (source.id, source.value, source.expires);
377
+ `,
378
+ { discard: true }
379
+ ),
365
380
  // sqlite
366
381
  orElse: (): UpsertFn => (entries) =>
367
382
  sql`
@@ -538,7 +553,7 @@ export const layerBackingSql: Layer.Layer<
538
553
  `,
539
554
  mssql: () =>
540
555
  sql`
541
- IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${table} AND xtype='U')
556
+ IF NOT EXISTS (SELECT * FROM sysobjects WHERE name=${"effect_persistence"} AND xtype='U')
542
557
  CREATE TABLE ${table} (
543
558
  store_id NVARCHAR(191) NOT NULL,
544
559
  id NVARCHAR(191) NOT NULL,
@@ -928,7 +943,13 @@ export const layerBackingRedis: Layer.Layer<
928
943
  Effect.mapError(
929
944
  ttl === undefined
930
945
  ? redis.send("SET", prefixed(key), JSON.stringify(value))
931
- : redis.send("SET", prefixed(key), JSON.stringify(value), "PX", String(Duration.toMillis(ttl))),
946
+ : redis.send(
947
+ "SET",
948
+ prefixed(key),
949
+ JSON.stringify(value),
950
+ "PX",
951
+ String(Math.ceil(Duration.toMillis(ttl)))
952
+ ),
932
953
  ({ cause }) =>
933
954
  new PersistenceError({
934
955
  message: `Failed to set key ${key} in Redis`,
@@ -943,7 +964,7 @@ export const layerBackingRedis: Layer.Layer<
943
964
  const pkey = prefixed(key)
944
965
  sets.set(pkey, JSON.stringify(value))
945
966
  if (ttl) {
946
- expires.set(pkey, Duration.toMillis(ttl))
967
+ expires.set(pkey, Math.ceil(Duration.toMillis(ttl)))
947
968
  }
948
969
  }
949
970
  return Effect.mapError(
@@ -1090,7 +1111,6 @@ export const layerBackingKvs: Layer.Layer<
1090
1111
  setMany: (entries) =>
1091
1112
  Effect.forEach(entries, ([key, value, ttl]) => {
1092
1113
  const expires = unsafeTtlToExpires(clock, ttl)
1093
- if (expires === null) return Effect.void
1094
1114
  const encoded = JSON.stringify([value, expires])
1095
1115
  return store.set(key, encoded)
1096
1116
  }, { concurrency: "unbounded", discard: true }).pipe(
@@ -285,7 +285,7 @@ export const makeWithRateLimiter: Effect.Effect<
285
285
  )
286
286
 
287
287
  /**
288
- * Accesses a function that sleeps when the rate limit is exceeded.
288
+ * Sleeps when the rate limit is exceeded.
289
289
  *
290
290
  * **Example** (Sleeping until rate limit permits)
291
291
  *
@@ -294,52 +294,75 @@ export const makeWithRateLimiter: Effect.Effect<
294
294
  * import { RateLimiter } from "effect/unstable/persistence"
295
295
  *
296
296
  * const program = Effect.gen(function*() {
297
- * // Access the `sleep` function from the RateLimiter module
298
- * const sleep = yield* RateLimiter.makeSleep
299
- *
300
- * // Use the `sleep` function with specific rate limiting parameters.
301
- * // This will only sleep if the rate limit has been exceeded.
302
- * const result = yield* sleep({
303
- * key: "some-key",
297
+ * const limiter = yield* RateLimiter.RateLimiter
298
+ * const partiallyApplied = RateLimiter.sleep(limiter)
299
+ * const partial = yield* partiallyApplied({
300
+ * key: "partial",
301
+ * limit: 10,
302
+ * window: "5 seconds",
303
+ * algorithm: "fixed-window"
304
+ * })
305
+ * const direct = yield* RateLimiter.sleep(limiter, {
306
+ * key: "direct",
304
307
  * limit: 10,
305
308
  * window: "5 seconds",
306
309
  * algorithm: "fixed-window"
307
310
  * })
308
- * return result.remaining
311
+ * return [partial.remaining, direct.remaining]
309
312
  * }).pipe(
310
313
  * Effect.provide(RateLimiter.layer.pipe(Layer.provide(RateLimiter.layerStoreMemory)))
311
314
  * )
312
315
  *
313
- * await Effect.runPromise(program) // => 9
316
+ * await Effect.runPromise(program) // => [9, 9]
314
317
  * ```
315
318
  *
316
319
  * @category accessors
317
320
  * @since 4.0.0
318
321
  */
319
- export const makeSleep: Effect.Effect<
320
- ((options: {
322
+ export function sleep(self: RateLimiter): (options: {
323
+ readonly algorithm?: "fixed-window" | "token-bucket" | undefined
324
+ readonly window: Duration.Input
325
+ readonly limit: number
326
+ readonly key: string
327
+ readonly tokens?: number | undefined
328
+ }) => Effect.Effect<ConsumeResult, RateLimiterError>
329
+ export function sleep(self: RateLimiter, options: {
330
+ readonly algorithm?: "fixed-window" | "token-bucket" | undefined
331
+ readonly window: Duration.Input
332
+ readonly limit: number
333
+ readonly key: string
334
+ readonly tokens?: number | undefined
335
+ }): Effect.Effect<ConsumeResult, RateLimiterError>
336
+ export function sleep(self: RateLimiter, options?: {
337
+ readonly algorithm?: "fixed-window" | "token-bucket" | undefined
338
+ readonly window: Duration.Input
339
+ readonly limit: number
340
+ readonly key: string
341
+ readonly tokens?: number | undefined
342
+ }):
343
+ | Effect.Effect<ConsumeResult, RateLimiterError>
344
+ | ((options: {
321
345
  readonly algorithm?: "fixed-window" | "token-bucket" | undefined
322
346
  readonly window: Duration.Input
323
347
  readonly limit: number
324
348
  readonly key: string
325
349
  readonly tokens?: number | undefined
326
- }) => Effect.Effect<ConsumeResult, RateLimiterError>),
327
- never,
328
- RateLimiter
329
- > = RateLimiter.use((limiter) =>
330
- Effect.succeed((options) =>
331
- Effect.flatMap(
332
- limiter.consume({
333
- ...options,
334
- onExceeded: "delay"
335
- }),
336
- (result) => {
337
- if (Duration.isZero(result.delay)) return Effect.succeed(result)
338
- return Effect.as(Effect.sleep(result.delay), result)
339
- }
340
- )
350
+ }) => Effect.Effect<ConsumeResult, RateLimiterError>)
351
+ {
352
+ if (options === undefined) {
353
+ return (options) => sleep(self, options)
354
+ }
355
+ return Effect.flatMap(
356
+ self.consume({
357
+ ...options,
358
+ onExceeded: "delay"
359
+ }),
360
+ (result) => {
361
+ if (Duration.isZero(result.delay)) return Effect.succeed(result)
362
+ return Effect.as(Effect.sleep(result.delay), result)
363
+ }
341
364
  )
342
- )
365
+ }
343
366
 
344
367
  /**
345
368
  * Runtime type identifier for `RateLimiterError`.
@@ -367,7 +390,7 @@ export type ErrorTypeId = "~@effect/experimental/RateLimiter/RateLimiterError"
367
390
  * @category errors
368
391
  * @since 4.0.0
369
392
  */
370
- export class RateLimitExceeded extends Schema.ErrorClass<RateLimitExceeded>(
393
+ export class RateLimitExceeded extends Schema.Error<RateLimitExceeded>(
371
394
  "effect/persistence/RateLimiter/RateLimitExceeded"
372
395
  )({
373
396
  _tag: Schema.tag("RateLimitExceeded"),
@@ -392,7 +415,7 @@ export class RateLimitExceeded extends Schema.ErrorClass<RateLimitExceeded>(
392
415
  * @category errors
393
416
  * @since 4.0.0
394
417
  */
395
- export class RateLimitStoreError extends Schema.ErrorClass<RateLimitStoreError>(
418
+ export class RateLimitStoreError extends Schema.Error<RateLimitStoreError>(
396
419
  "effect/persistence/RateLimiter/RateLimitStoreError"
397
420
  )({
398
421
  _tag: Schema.tag("RateLimitStoreError"),
@@ -426,7 +449,7 @@ export const RateLimiterErrorReason: Schema.Union<[
426
449
  * @category errors
427
450
  * @since 4.0.0
428
451
  */
429
- export class RateLimiterError extends Schema.ErrorClass<RateLimiterError>(ErrorTypeId)({
452
+ export class RateLimiterError extends Schema.Error<RateLimiterError>(ErrorTypeId)({
430
453
  _tag: Schema.tag("RateLimiterError"),
431
454
  reason: RateLimiterErrorReason
432
455
  }) {
@@ -100,7 +100,7 @@ const ErrorTypeId: ErrorTypeId = "~effect/persistence/Redis/RedisError"
100
100
  * @category errors
101
101
  * @since 4.0.0
102
102
  */
103
- export class RedisError extends Schema.ErrorClass<RedisError>(ErrorTypeId)({
103
+ export class RedisError extends Schema.Error<RedisError>(ErrorTypeId)({
104
104
  _tag: Schema.tag("RedisError"),
105
105
  cause: Schema.Defect()
106
106
  }) {
@@ -1101,7 +1101,7 @@ export const Schema = <
1101
1101
  [success_, Schema_.Cause(error, Schema_.Defect())],
1102
1102
  ([value, cause]) => (input, ast, options) => {
1103
1103
  if (!isAsyncResult(input)) {
1104
- return Effect.fail(new SchemaIssue.InvalidType(ast))
1104
+ return Effect.fail(new SchemaIssue.InvalidType(ast, input, options))
1105
1105
  }
1106
1106
  switch (input._tag) {
1107
1107
  case "Initial":
@@ -1111,7 +1111,7 @@ export const Schema = <
1111
1111
  SchemaParser.decodeUnknownEffect(value)(input.value, options),
1112
1112
  {
1113
1113
  onSuccess: (value) => success(value, input),
1114
- onFailure: (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["value"], issue)])
1114
+ onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "value", issue, input, options)
1115
1115
  }
1116
1116
  )
1117
1117
  case "Failure": {
@@ -1122,9 +1122,14 @@ export const Schema = <
1122
1122
  {
1123
1123
  onSuccess: (value) => Option.some(success<A["Type"], E["Type"]>(value, ps)),
1124
1124
  onFailure: (issue) =>
1125
- new SchemaIssue.Composite(ast, [
1126
- new SchemaIssue.Pointer(["previousSuccess", "value"], issue)
1127
- ])
1125
+ new SchemaIssue.Composite(
1126
+ ast,
1127
+ [
1128
+ new SchemaIssue.Pointer(["previousSuccess", "value"], issue)
1129
+ ],
1130
+ input,
1131
+ options
1132
+ )
1128
1133
  }
1129
1134
  )
1130
1135
  ),
@@ -1132,7 +1137,7 @@ export const Schema = <
1132
1137
  )
1133
1138
  const causeEffect = Effect.mapErrorEager(
1134
1139
  SchemaParser.decodeUnknownEffect(cause)(input.cause, options),
1135
- (issue) => new SchemaIssue.Composite(ast, [new SchemaIssue.Pointer(["cause"], issue)])
1140
+ (issue) => SchemaIssue.makeCompositeAtKey(ast, "cause", issue, input, options)
1136
1141
  )
1137
1142
  return Effect.flatMapEager(
1138
1143
  prevSuccessEffect,
@@ -790,7 +790,7 @@ export interface AtomRuntime<R, ER = never> extends Atom<AsyncResult.AsyncResult
790
790
  }
791
791
 
792
792
  /**
793
- * Factory for `AtomRuntime` values that share a `Layer.MemoMap` and a set of global layers.
793
+ * Factory for `AtomRuntime` values that share a set of global layers.
794
794
  *
795
795
  * @category models
796
796
  * @since 4.0.0
@@ -801,7 +801,6 @@ export interface RuntimeFactory {
801
801
  | Layer.Layer<R, E, AtomRegistry | Reactivity.Reactivity>
802
802
  | ((get: AtomContext) => Layer.Layer<R, E, AtomRegistry | Reactivity.Reactivity>)
803
803
  ): AtomRuntime<R, E>
804
- readonly memoMap: Layer.MemoMap
805
804
  readonly addGlobalLayer: <A, E>(layer: Layer.Layer<A, E, AtomRegistry | Reactivity.Reactivity>) => void
806
805
 
807
806
  /**
@@ -814,14 +813,40 @@ export interface RuntimeFactory {
814
813
  }
815
814
 
816
815
  /**
817
- * Creates a `RuntimeFactory` backed by the supplied `Layer.MemoMap`.
816
+ * A `RuntimeFactory` backed by an atom whose memo map is scoped to each registry.
818
817
  *
819
- * @category constructors
818
+ * @category models
820
819
  * @since 4.0.0
821
820
  */
822
- export const context: (options: {
821
+ export interface RegistryRuntimeFactory extends RuntimeFactory {
822
+ readonly memoMap: Atom<Layer.MemoMap>
823
+ }
824
+
825
+ /**
826
+ * A `RuntimeFactory` backed by a concrete memo map shared across registries.
827
+ *
828
+ * @category models
829
+ * @since 4.0.0
830
+ */
831
+ export interface SharedRuntimeFactory extends RuntimeFactory {
823
832
  readonly memoMap: Layer.MemoMap
824
- }) => RuntimeFactory = (options) => {
833
+ }
834
+
835
+ /**
836
+ * Creates a `RuntimeFactory` backed by a registry-scoped memo map by default,
837
+ * or by the supplied atom or concrete `Layer.MemoMap`.
838
+ *
839
+ * @category constructors
840
+ * @since 4.0.0
841
+ */
842
+ export function context(): RegistryRuntimeFactory
843
+ export function context(options: { readonly memoMap: Atom<Layer.MemoMap> }): RegistryRuntimeFactory
844
+ export function context(options: { readonly memoMap: Layer.MemoMap }): SharedRuntimeFactory
845
+ export function context(options?: {
846
+ readonly memoMap: Atom<Layer.MemoMap> | Layer.MemoMap
847
+ }): RegistryRuntimeFactory | SharedRuntimeFactory {
848
+ const memoMap = options?.memoMap ?? removeTtl(make(() => Layer.makeMemoMapUnsafe()))
849
+ const resolveMemoMap = (get: AtomContext): Layer.MemoMap => isAtom(memoMap) ? get(memoMap) : memoMap
825
850
  let globalLayer: Layer.Layer<any, any, AtomRegistry> = Reactivity.layer
826
851
  function factory<E, R>(
827
852
  create:
@@ -843,23 +868,25 @@ export const context: (options: {
843
868
 
844
869
  self.read = function read(get: AtomContext) {
845
870
  const layer = get(layerAtom)
846
- const build = Effect.flatMap(Effect.scope, (scope) => Layer.buildWithMemoMap(layer, options.memoMap, scope))
871
+ const build = Effect.flatMap(Effect.scope, (scope) => Layer.buildWithMemoMap(layer, resolveMemoMap(get), scope))
847
872
  return effect(get, build, { uninterruptible: true })
848
873
  }
849
874
 
850
875
  return self
851
876
  }
852
- factory.memoMap = options.memoMap
877
+ factory.memoMap = memoMap
853
878
  factory.addGlobalLayer = (layer: Layer.Layer<any, any, AtomRegistry | Reactivity.Reactivity>) => {
854
879
  globalLayer = Layer.provideMerge(globalLayer, Layer.provide(layer, Reactivity.layer))
855
880
  }
856
- const reactivityAtom = removeTtl(make(
857
- Effect.contextWith((services: Context.Context<Scope.Scope>) =>
858
- Layer.buildWithMemoMap(Reactivity.layer, options.memoMap, Context.get(services, Scope.Scope))
859
- ).pipe(
860
- Effect.map(Context.get(Reactivity.Reactivity))
881
+ const reactivityAtom = removeTtl(
882
+ make((get) =>
883
+ Effect.contextWith((services: Context.Context<Scope.Scope>) =>
884
+ Layer.buildWithMemoMap(Reactivity.layer, resolveMemoMap(get), Context.get(services, Scope.Scope))
885
+ ).pipe(
886
+ Effect.map(Context.get(Reactivity.Reactivity))
887
+ )
861
888
  )
862
- ))
889
+ )
863
890
  factory.withReactivity =
864
891
  (keys: ReadonlyArray<unknown> | ReadonlyRecord<string, ReadonlyArray<unknown>>) =>
865
892
  <A extends Atom<any>>(atom: A): A =>
@@ -871,24 +898,16 @@ export const context: (options: {
871
898
  get.subscribe(atom, (value) => get.setSelf(value))
872
899
  return get.once(atom)
873
900
  }, { initialValueTarget: atom }) as any as A
874
- return factory
901
+ return factory as any
875
902
  }
876
903
 
877
904
  /**
878
- * Default `Layer.MemoMap` used by the module-level `runtime` factory.
879
- *
880
- * @category context
881
- * @since 4.0.0
882
- */
883
- export const defaultMemoMap: Layer.MemoMap = Layer.makeMemoMapUnsafe()
884
-
885
- /**
886
- * Default `RuntimeFactory` created with `defaultMemoMap`.
905
+ * Default registry-scoped `RuntimeFactory`.
887
906
  *
888
907
  * @category context
889
908
  * @since 4.0.0
890
909
  */
891
- export const runtime: RuntimeFactory = context({ memoMap: defaultMemoMap })
910
+ export const runtime: RegistryRuntimeFactory = context()
892
911
 
893
912
  /**
894
913
  * Returns `Rx.runtime.withReactivity` for refreshing an atom whenever the