@mark1russell7/service 0.8.19 → 0.8.20

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 (331) hide show
  1. package/build/backoff.d.ts +44 -2
  2. package/build/{builder-zO48Vgoj.d.ts → builder.d.ts} +14 -101
  3. package/build/builder.js +499 -0
  4. package/build/builder.js.map +1 -0
  5. package/build/{call-context-DDhcVvn5.d.ts → call-context.d.ts} +3 -4
  6. package/build/channel.d.ts +1 -1
  7. package/build/{core-BSzt4RI2.d.ts → client/core.d.ts} +32 -61
  8. package/build/{machine-BhVeHr_m.js → client/core.js} +4 -153
  9. package/build/client/core.js.map +1 -0
  10. package/build/{dial-ChwIcvd4.d.ts → client/dial.d.ts} +3 -4
  11. package/build/client/dial.js +52 -0
  12. package/build/client/dial.js.map +1 -0
  13. package/build/client/machine.js +29 -0
  14. package/build/client/machine.js.map +1 -0
  15. package/build/client/meets.d.ts +35 -0
  16. package/build/client/meets.js +78 -0
  17. package/build/client/meets.js.map +1 -0
  18. package/build/clock.d.ts +1 -1
  19. package/build/conformance.d.ts +122 -0
  20. package/build/conformance.js +470 -0
  21. package/build/conformance.js.map +1 -0
  22. package/build/contract.d.ts +28 -0
  23. package/build/contract.js +184 -0
  24. package/build/contract.js.map +1 -0
  25. package/build/description.d.ts +161 -0
  26. package/build/description.js +11 -0
  27. package/build/description.js.map +1 -0
  28. package/build/drains.js +35 -0
  29. package/build/drains.js.map +1 -0
  30. package/build/events.d.ts +25 -0
  31. package/build/fakes.d.ts +43 -0
  32. package/build/fakes.js +93 -0
  33. package/build/fakes.js.map +1 -0
  34. package/build/grpc/client.d.ts +153 -0
  35. package/build/grpc/client.js +474 -0
  36. package/build/grpc/client.js.map +1 -0
  37. package/build/grpc/connection.d.ts +97 -0
  38. package/build/grpc/connection.js +59 -0
  39. package/build/grpc/connection.js.map +1 -0
  40. package/build/grpc/machine.d.ts +12 -0
  41. package/build/grpc/machine.js +149 -0
  42. package/build/grpc/machine.js.map +1 -0
  43. package/build/grpc/meets.d.ts +14 -0
  44. package/build/grpc/meets.js +105 -0
  45. package/build/grpc/meets.js.map +1 -0
  46. package/build/grpc/starting.d.ts +33 -0
  47. package/build/grpc/starting.js +89 -0
  48. package/build/grpc/starting.js.map +1 -0
  49. package/build/grpc.d.ts +9 -303
  50. package/build/grpc.js +7 -854
  51. package/build/health.d.ts +93 -0
  52. package/build/health.js +223 -0
  53. package/build/health.js.map +1 -0
  54. package/build/heartbeat.d.ts +1 -1
  55. package/build/host/discovery.d.ts +61 -0
  56. package/build/host/discovery.js +113 -0
  57. package/build/host/discovery.js.map +1 -0
  58. package/build/host/env.d.ts +14 -0
  59. package/build/host/env.js +57 -0
  60. package/build/host/env.js.map +1 -0
  61. package/build/host/fakes.d.ts +82 -0
  62. package/build/host/fakes.js +239 -0
  63. package/build/host/fakes.js.map +1 -0
  64. package/build/host/group.d.ts +142 -0
  65. package/build/host/group.js +517 -0
  66. package/build/host/group.js.map +1 -0
  67. package/build/host/install.d.ts +96 -0
  68. package/build/host/install.js +330 -0
  69. package/build/host/install.js.map +1 -0
  70. package/build/host/lock.d.ts +78 -0
  71. package/build/host/lock.js +190 -0
  72. package/build/host/lock.js.map +1 -0
  73. package/build/host/logs.d.ts +26 -0
  74. package/build/host/logs.js +48 -0
  75. package/build/host/logs.js.map +1 -0
  76. package/build/host/node.d.ts +14 -0
  77. package/build/host/node.js +309 -0
  78. package/build/host/node.js.map +1 -0
  79. package/build/{ports-B1ayTL-j.d.ts → host/ports.d.ts} +15 -16
  80. package/build/host/ports.js +17 -0
  81. package/build/host/ports.js.map +1 -0
  82. package/build/host/probes.d.ts +51 -0
  83. package/build/host/probes.js +139 -0
  84. package/build/host/probes.js.map +1 -0
  85. package/build/host/processes.d.ts +32 -0
  86. package/build/host/processes.js +63 -0
  87. package/build/host/processes.js.map +1 -0
  88. package/build/host/render.d.ts +84 -0
  89. package/build/host/render.js +235 -0
  90. package/build/host/render.js.map +1 -0
  91. package/build/host/watch.d.ts +90 -0
  92. package/build/host/watch.js +165 -0
  93. package/build/host/watch.js.map +1 -0
  94. package/build/host.d.ts +13 -671
  95. package/build/host.js +12 -2126
  96. package/build/http/answers.js +29 -0
  97. package/build/http/answers.js.map +1 -0
  98. package/build/http/fake-server.js +61 -0
  99. package/build/http/fake-server.js.map +1 -0
  100. package/build/http/outcome.d.ts +115 -0
  101. package/build/http/outcome.js +325 -0
  102. package/build/http/outcome.js.map +1 -0
  103. package/build/http/probes.d.ts +83 -0
  104. package/build/http/probes.js +232 -0
  105. package/build/http/probes.js.map +1 -0
  106. package/build/http/transport.d.ts +165 -0
  107. package/build/http/transport.js +517 -0
  108. package/build/http/transport.js.map +1 -0
  109. package/build/http-client/client.d.ts +121 -0
  110. package/build/http-client/client.js +330 -0
  111. package/build/http-client/client.js.map +1 -0
  112. package/build/http-client/connection.d.ts +78 -0
  113. package/build/http-client/connection.js +54 -0
  114. package/build/http-client/connection.js.map +1 -0
  115. package/build/http-client/machine.d.ts +14 -0
  116. package/build/http-client/machine.js +109 -0
  117. package/build/http-client/machine.js.map +1 -0
  118. package/build/http-client/meets.d.ts +11 -0
  119. package/build/http-client/meets.js +74 -0
  120. package/build/http-client/meets.js.map +1 -0
  121. package/build/http-client/session.d.ts +87 -0
  122. package/build/http-client/session.js +99 -0
  123. package/build/http-client/session.js.map +1 -0
  124. package/build/http-client/starting.d.ts +25 -0
  125. package/build/http-client/starting.js +65 -0
  126. package/build/http-client/starting.js.map +1 -0
  127. package/build/http-client.d.ts +9 -330
  128. package/build/http-client.js +8 -707
  129. package/build/http.d.ts +5 -353
  130. package/build/http.js +3 -1086
  131. package/build/identity.d.ts +16 -0
  132. package/build/identity.js +44 -0
  133. package/build/identity.js.map +1 -0
  134. package/build/index.d.ts +35 -412
  135. package/build/index.js +24 -3277
  136. package/build/knobs.d.ts +1 -0
  137. package/build/{knobs-BJcz6m01.js → knobs.js} +2 -34
  138. package/build/knobs.js.map +1 -0
  139. package/build/latch.d.ts +29 -0
  140. package/build/latch.js +122 -0
  141. package/build/latch.js.map +1 -0
  142. package/build/{rules-HyFCBStQ.d.ts → law.d.ts} +19 -37
  143. package/build/law.js +149 -0
  144. package/build/law.js.map +1 -0
  145. package/build/lifecycle.d.ts +144 -0
  146. package/build/lifecycle.js +411 -0
  147. package/build/lifecycle.js.map +1 -0
  148. package/build/limiter/machine.d.ts +40 -0
  149. package/build/limiter/machine.js +279 -0
  150. package/build/limiter/machine.js.map +1 -0
  151. package/build/{policy-CBcK2XGg.d.ts → limiter/policy.d.ts} +28 -29
  152. package/build/{policy-UYALkqVq.js → limiter/policy.js} +10 -9
  153. package/build/limiter/policy.js.map +1 -0
  154. package/build/{limiter-BNKnwzeY.d.ts → limiter/quota.d.ts} +32 -74
  155. package/build/{limiter-DrM0PQV9.js → limiter/quota.js} +3 -418
  156. package/build/limiter/quota.js.map +1 -0
  157. package/build/{store-DFwFKrsB.d.ts → limiter/store.d.ts} +10 -11
  158. package/build/limiter/store.js +145 -0
  159. package/build/limiter/store.js.map +1 -0
  160. package/build/limiter.d.ts +4 -3
  161. package/build/limiter.js +4 -2
  162. package/build/lint.d.ts +152 -0
  163. package/build/lint.js +576 -0
  164. package/build/lint.js.map +1 -0
  165. package/build/logger.d.ts +71 -0
  166. package/build/logger.js +183 -0
  167. package/build/logger.js.map +1 -0
  168. package/build/machines.d.ts +41 -0
  169. package/build/machines.js +451 -0
  170. package/build/machines.js.map +1 -0
  171. package/build/metrics.d.ts +53 -0
  172. package/build/metrics.js +111 -0
  173. package/build/metrics.js.map +1 -0
  174. package/build/mongodb/client.d.ts +131 -0
  175. package/build/mongodb/client.js +388 -0
  176. package/build/mongodb/client.js.map +1 -0
  177. package/build/mongodb/connection.d.ts +112 -0
  178. package/build/mongodb/connection.js +12 -0
  179. package/build/mongodb/connection.js.map +1 -0
  180. package/build/mongodb/machine.d.ts +14 -0
  181. package/build/mongodb/machine.js +122 -0
  182. package/build/mongodb/machine.js.map +1 -0
  183. package/build/mongodb/meets.d.ts +15 -0
  184. package/build/mongodb/meets.js +103 -0
  185. package/build/mongodb/meets.js.map +1 -0
  186. package/build/mongodb/starting.d.ts +29 -0
  187. package/build/mongodb/starting.js +77 -0
  188. package/build/mongodb/starting.js.map +1 -0
  189. package/build/mongodb.d.ts +8 -296
  190. package/build/mongodb.js +7 -682
  191. package/build/operation.d.ts +27 -0
  192. package/build/{operation-DF73RZOI.js → operation.js} +2 -2
  193. package/build/operation.js.map +1 -0
  194. package/build/otel.d.ts +2 -2
  195. package/build/pg/client.d.ts +96 -0
  196. package/build/pg/client.js +277 -0
  197. package/build/pg/client.js.map +1 -0
  198. package/build/pg/connection.d.ts +75 -0
  199. package/build/pg/connection.js +11 -0
  200. package/build/pg/connection.js.map +1 -0
  201. package/build/pg/machine.d.ts +13 -0
  202. package/build/pg/machine.js +111 -0
  203. package/build/pg/machine.js.map +1 -0
  204. package/build/pg/meets.d.ts +14 -0
  205. package/build/pg/meets.js +83 -0
  206. package/build/pg/meets.js.map +1 -0
  207. package/build/pg/starting.d.ts +26 -0
  208. package/build/pg/starting.js +62 -0
  209. package/build/pg/starting.js.map +1 -0
  210. package/build/pg.d.ts +8 -219
  211. package/build/pg.js +7 -525
  212. package/build/poller.d.ts +9 -0
  213. package/build/poller.js +152 -0
  214. package/build/poller.js.map +1 -0
  215. package/build/process.d.ts +114 -0
  216. package/build/process.js +170 -0
  217. package/build/process.js.map +1 -0
  218. package/build/profiles.d.ts +68 -0
  219. package/build/profiles.js +120 -0
  220. package/build/profiles.js.map +1 -0
  221. package/build/{queue-DXdw1vLO.d.ts → queue.d.ts} +16 -29
  222. package/build/queue.js +279 -0
  223. package/build/queue.js.map +1 -0
  224. package/build/rabbitmq/client.d.ts +144 -0
  225. package/build/rabbitmq/client.js +426 -0
  226. package/build/rabbitmq/client.js.map +1 -0
  227. package/build/rabbitmq/connection.d.ts +91 -0
  228. package/build/rabbitmq/connection.js +15 -0
  229. package/build/rabbitmq/connection.js.map +1 -0
  230. package/build/rabbitmq/machine.d.ts +13 -0
  231. package/build/rabbitmq/machine.js +159 -0
  232. package/build/rabbitmq/machine.js.map +1 -0
  233. package/build/rabbitmq/meets.d.ts +12 -0
  234. package/build/rabbitmq/meets.js +96 -0
  235. package/build/rabbitmq/meets.js.map +1 -0
  236. package/build/rabbitmq/starting.d.ts +27 -0
  237. package/build/rabbitmq/starting.js +67 -0
  238. package/build/rabbitmq/starting.js.map +1 -0
  239. package/build/rabbitmq.d.ts +8 -283
  240. package/build/rabbitmq.js +7 -742
  241. package/build/redis/client.d.ts +86 -0
  242. package/build/redis/client.js +285 -0
  243. package/build/redis/client.js.map +1 -0
  244. package/build/redis/connection.d.ts +57 -0
  245. package/build/redis/connection.js +11 -0
  246. package/build/redis/connection.js.map +1 -0
  247. package/build/redis/limiter.d.ts +43 -0
  248. package/build/redis/limiter.js +164 -0
  249. package/build/redis/limiter.js.map +1 -0
  250. package/build/redis/machine.d.ts +12 -0
  251. package/build/redis/machine.js +144 -0
  252. package/build/redis/machine.js.map +1 -0
  253. package/build/redis/meets.d.ts +11 -0
  254. package/build/redis/meets.js +75 -0
  255. package/build/redis/meets.js.map +1 -0
  256. package/build/redis/operations.d.ts +5 -0
  257. package/build/redis/operations.js +114 -0
  258. package/build/redis/operations.js.map +1 -0
  259. package/build/redis.d.ts +10 -207
  260. package/build/redis.js +9 -771
  261. package/build/requests.d.ts +66 -0
  262. package/build/requests.js +279 -0
  263. package/build/requests.js.map +1 -0
  264. package/build/retrier.d.ts +62 -0
  265. package/build/{retrier-Dnjhvxol.js → retrier.js} +2 -2
  266. package/build/retrier.js.map +1 -0
  267. package/build/routes.d.ts +35 -0
  268. package/build/routes.js +77 -0
  269. package/build/routes.js.map +1 -0
  270. package/build/rules.d.ts +19 -2
  271. package/build/stops.d.ts +51 -0
  272. package/build/stops.js +86 -0
  273. package/build/stops.js.map +1 -0
  274. package/build/testing.d.ts +8 -270
  275. package/build/testing.js +4 -1027
  276. package/build/testing.js.map +1 -1
  277. package/build/timing.d.ts +63 -0
  278. package/build/{timing-DZl36uXs.js → timing.js} +2 -2
  279. package/build/timing.js.map +1 -0
  280. package/build/units.d.ts +17 -0
  281. package/build/units.js +236 -0
  282. package/build/units.js.map +1 -0
  283. package/build/watchdog.d.ts +34 -0
  284. package/build/watchdog.js +53 -0
  285. package/build/watchdog.js.map +1 -0
  286. package/build/websocket/client.d.ts +136 -0
  287. package/build/websocket/client.js +422 -0
  288. package/build/websocket/client.js.map +1 -0
  289. package/build/websocket/connection.d.ts +83 -0
  290. package/build/websocket/connection.js +57 -0
  291. package/build/websocket/connection.js.map +1 -0
  292. package/build/websocket/machine.d.ts +12 -0
  293. package/build/websocket/machine.js +155 -0
  294. package/build/websocket/machine.js.map +1 -0
  295. package/build/websocket/meets.d.ts +14 -0
  296. package/build/websocket/meets.js +92 -0
  297. package/build/websocket/meets.js.map +1 -0
  298. package/build/websocket/starting.d.ts +25 -0
  299. package/build/websocket/starting.js +69 -0
  300. package/build/websocket/starting.js.map +1 -0
  301. package/build/websocket.d.ts +9 -264
  302. package/build/websocket.js +8 -774
  303. package/build/worker.d.ts +92 -0
  304. package/build/worker.js +153 -0
  305. package/build/worker.js.map +1 -0
  306. package/package.json +4 -3
  307. package/build/backoff-QTRGfkEK.d.ts +0 -45
  308. package/build/clock-DpVgpY4h.d.ts +0 -2
  309. package/build/grpc.js.map +0 -1
  310. package/build/host.js.map +0 -1
  311. package/build/http-client.js.map +0 -1
  312. package/build/http.js.map +0 -1
  313. package/build/index.js.map +0 -1
  314. package/build/knobs-BJcz6m01.js.map +0 -1
  315. package/build/lifecycle-D0J-zwZF.d.ts +0 -374
  316. package/build/limiter-DrM0PQV9.js.map +0 -1
  317. package/build/logger-B6drv9w0.d.ts +0 -488
  318. package/build/machine-BhVeHr_m.js.map +0 -1
  319. package/build/mongodb.js.map +0 -1
  320. package/build/operation-DF73RZOI.js.map +0 -1
  321. package/build/pg.js.map +0 -1
  322. package/build/policy-UYALkqVq.js.map +0 -1
  323. package/build/process-7R9M29wN.js +0 -437
  324. package/build/process-7R9M29wN.js.map +0 -1
  325. package/build/rabbitmq.js.map +0 -1
  326. package/build/redis.js.map +0 -1
  327. package/build/requests-DD2ALv0_.js +0 -583
  328. package/build/requests-DD2ALv0_.js.map +0 -1
  329. package/build/retrier-Dnjhvxol.js.map +0 -1
  330. package/build/timing-DZl36uXs.js.map +0 -1
  331. package/build/websocket.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.js","names":["r"],"sources":["../src/lint.ts"],"sourcesContent":["import type { Extent, Quantity } from \"@mark1russell7/quantity\";\nimport { convertExact, convertible, rationals as r } from \"@mark1russell7/quantity\";\nimport { backoffBand } from \"./backoff.ts\";\nimport type { Check, Dependency, ServiceDescription, Transport } from \"./description.ts\";\nimport type { Binding, Bound, Change, Evaluated, Rule, TimerMarks, Verdict } from \"./law.ts\";\nimport { compression, evaluate, symbolsOf, verdictOf } from \"./law.ts\";\nimport type { Limiter } from \"./limiter/policy.ts\";\nimport { idleSpan, longestRetryAfter, retryAfterSeconds } from \"./limiter/policy.ts\";\nimport { failSpan } from \"./timing.ts\";\n\n/**\n * This module applies the ordering law to a declaration. The declaration binds the symbols of the\n * service, from its primitives: the polls of its checks, the windows of its policies, its drain.\n * The scenario binds the symbols of the platform (preStop, grace, the probes of the kubelet,\n * propagation) and of each dependency (its failover time, the idle close of its server). Thus the\n * service gives the inequalities, and the scenario gives the values.\n *\n * A rule about a client applies one time for each dependency. A rule about a server (`@server`)\n * also applies one time for each server transport of the service. A rule about a consumer applies\n * one time for each consumer and each worker. A rule about a limiter applies one time for each limiter.\n */\n\n/** A statistic of a measured distribution. The law binds p99 (`LAW_STATISTIC`). */\nexport type Statistic = \"p50\" | \"p90\" | \"p99\" | \"p999\" | \"max\";\n\n/** The law binds this statistic of a distribution. */\nexport const LAW_STATISTIC: Statistic = \"p99\";\n\n/**\n * A claim is a value of the scenario that names its epoch: the component and the version that give\n * it, for example \"node@22\" (E2). A default is true only for a version: the keep-alive of Node is\n * 5 s, but 65 s on main. A claim gives a set value, or a measured distribution by its statistics.\n */\nexport type Claim =\n | { readonly epoch: string; readonly value: Extent }\n | { readonly epoch: string; readonly distribution: Readonly<Partial<Record<Statistic, Quantity>>> };\n\n/**\n * A value of the scenario is an amount, or a claim. An amount names no epoch, thus the finding of\n * each rule that reads it gives null for its epoch.\n */\nexport type ScenarioValue = Extent | Claim;\n\n/** A scenario gives the values of the platform and of each dependency, by the `symbol@hop` of the law. */\nexport interface Scenario {\n /** These are the values of the platform: prestop_sleep@pod, termination_grace@pod, probe_period@pod, propagation_bound@cluster. */\n readonly platform: Readonly<Record<string, ScenarioValue>>;\n /**\n * These are the probe windows of the kubelet, period × failure threshold. They add to the\n * windows of the declaration. A probe reads the cached verdict, thus detection is the latch,\n * then the probe.\n */\n readonly probes: { readonly readiness: Quantity; readonly liveness: Quantity };\n /** These are the values of each dependency, by its name: failover_time@dependency, server_idle_close@server. */\n readonly dependencies?: Readonly<Record<string, Readonly<Record<string, ScenarioValue>>>> | undefined;\n /**\n * These are the values of each transport, by its name and by the `symbol@hop` of the law. For a\n * consumer or a worker, they are the values of its source: lease_duration@broker. For a server,\n * they are the values of its clients: request_timeout@client.\n */\n readonly transports?: Readonly<Record<string, Readonly<Record<string, ScenarioValue>>>> | undefined;\n /**\n * These are the values of the callers of each limiter, by its name and by the `symbol@hop` of the\n * law: client_retry_window@caller, retry_delay@caller. A symbol without a hop binds at `caller`.\n */\n readonly limiters?: Readonly<Record<string, Readonly<Record<string, ScenarioValue>>>> | undefined;\n}\n\n/** The epochs of a scope map each symbol that the scenario binds to the epoch of its value, or null when the value names none. */\nexport type Epochs = Readonly<Record<string, string | null>>;\n\n/** A finding is the verdict of one rule for one scope: the service, or the client of a dependency. When a value of the scenario names an epoch, the finding gives the epoch of each value that the rule reads. */\nexport interface Finding {\n readonly rule: string;\n readonly scope: string;\n readonly verdict: Verdict;\n readonly statement: string;\n readonly window?: string | undefined;\n readonly evaluated: readonly Evaluated[];\n /** These are the symbols that have no bound. A \"depends\" verdict waits for them. */\n readonly unbound: readonly string[];\n /** These are the epochs of the symbols of the rule that the scenario binds (E2). Thus a finding is true for these versions. */\n readonly epochs?: Epochs | undefined;\n}\n\n/** These are the identifiers of the rules that each declaration gets. */\nexport const SERVICE_RULES: readonly string[] = [\n \"O04\",\n \"O09\",\n \"O10\",\n \"O11\",\n \"O12\",\n \"O13\",\n \"O14\",\n \"O15\",\n \"O16\",\n \"O17\",\n \"O18\",\n \"O19\",\n \"O20\",\n \"O21\",\n \"O22\",\n \"O23\",\n \"O27\",\n \"O29\",\n \"O30\",\n];\n\n/**\n * These are the two rules of the law for a keyed limiter, as data. The caller of `lint()` gives\n * them, as it gives each other rule. Each one applies one time for each limiter.\n * - O29: the longest `Retry-After` of a limiter is at most the retry window of its caller. Its\n * second inequality applies the same bound to a new key at the cap of keys.\n * Otherwise the caller stops before the limit lets its call in, and a refusal becomes a failure.\n * - O30: the least delay of a caller before it sends a refused call again is at least the longest\n * `Retry-After` of the policy. Otherwise a caller that does not read the header sends again too\n * early, and the limiter refuses each early call again.\n *\n * The identifiers O29 and O30 are provisional. The private corpus of the law (R3, track B) has 28\n * rules, O01 to O28. It does not have these two rules yet, thus they take the next two identifiers.\n */\nexport const LIMITER_RULES: readonly Rule[] = [\n {\n id: \"O29\",\n rule: \"the longest Retry-After of a limiter, at its cap of keys too, is at most the retry window of its caller\",\n window: \"the caller stops before the limit lets its call in, thus a refusal becomes a failure\",\n expr: {\n lhs: { terms: [{ knob: \"retry_after\", coef: 1, at: \"limiter\" }] },\n op: \"<=\",\n rhs: { terms: [{ knob: \"client_retry_window\", coef: 1, at: \"caller\" }] },\n margin: 0,\n },\n expr_more: [\n {\n lhs: { terms: [{ knob: \"retry_after_at_cap\", coef: 1, at: \"limiter\" }] },\n op: \"<=\",\n rhs: { terms: [{ knob: \"client_retry_window\", coef: 1, at: \"caller\" }] },\n margin: 0,\n },\n ],\n },\n {\n id: \"O30\",\n rule: \"the least delay of a caller before it sends a refused call again is at least the longest Retry-After of the limiter\",\n window: \"a caller that does not read Retry-After sends again too early, and the limiter refuses each early call again\",\n expr: {\n lhs: { terms: [{ knob: \"retry_delay\", coef: 1, at: \"caller\" }] },\n op: \">=\",\n rhs: { terms: [{ knob: \"retry_after\", coef: 1, at: \"limiter\" }] },\n margin: 0,\n },\n },\n];\n\n/** This function gives a finite amount in seconds. */\nconst secondsOf = (amount: Quantity): number =>\n r.toNumber(convertExact(r.fromNumber(amount.value), amount.unit, \"s\"));\n/** This function gives an amount, or no bound, as the law binds it. */\nconst boundOf = (amount: Extent): Bound =>\n amount.value === \"infinite\" ? \"inf\" : secondsOf(amount);\n/**\n * This function gives a value of the scenario as the law binds it, with its epoch. A distribution\n * binds its p99. A distribution without a p99 binds nothing, thus each rule that reads it depends.\n */\nconst claimOf = (value: ScenarioValue): { readonly bound: Bound | undefined; readonly epoch: string | null } => {\n if (!(\"epoch\" in value)) return { bound: boundOf(value), epoch: null };\n if (\"value\" in value) return { bound: boundOf(value.value), epoch: value.epoch };\n const statistic = value.distribution[LAW_STATISTIC];\n return { bound: statistic === undefined ? undefined : secondsOf(statistic), epoch: value.epoch };\n};\n/** This function binds each value of a part of the scenario, at the symbol that `at` gives, and records its epoch. */\nconst bindScenario = (\n values: Readonly<Record<string, ScenarioValue>>,\n at: (symbol: string) => string,\n bind: Record<string, Bound>,\n epochs: Record<string, string | null>,\n): void => {\n for (const [symbol, value] of Object.entries(values)) {\n const claim = claimOf(value);\n const key = at(symbol);\n epochs[key] = claim.epoch;\n if (claim.bound !== undefined) bind[key] = claim.bound;\n else delete bind[key];\n }\n};\n/** This function tells if a unit is a time. A unit that the package does not know is not a time. */\nconst isTime = (unit: string): boolean => {\n try {\n return convertible(unit, \"s\");\n } catch {\n return false;\n }\n};\n/** This function gives the largest of some numbers of seconds, or undefined when there are none. */\nconst most = (values: readonly number[]): number | undefined =>\n values.length === 0 ? undefined : Math.max(...values);\n\n/** This function gives what the declaration tells about the service, as symbols of the law, and the source of each. */\nexport const serviceBindings = (\n svc: ServiceDescription,\n scenario: Scenario,\n): { readonly bind: Record<string, Bound>; readonly from: Record<string, string>; readonly epochs: Epochs } => {\n const bind: Record<string, Bound> = {};\n const from: Record<string, string> = {};\n const epochs: Record<string, string | null> = {};\n const set = (symbol: string, bound: Bound | undefined, said: string): void => {\n if (bound === undefined) return;\n bind[symbol] = bound;\n from[symbol] = said;\n };\n const gating = svc.checks.filter((check) => check.gates !== null);\n const readinessChecks = gating.filter((check) => check.gates === \"readiness\");\n const livenessChecks = gating.filter((check) => check.gates === \"liveness\");\n set(\n \"check_poll_interval@service\",\n most(gating.map((check) => secondsOf(check.poll.interval))),\n \"the slowest gating check's interval\",\n );\n set(\n \"check_timeout@service\",\n most(gating.map((check) => secondsOf(check.poll.timeout))),\n \"the longest gating check's timeout\",\n );\n set(\n \"slowest_poll@service\",\n most(\n gating.map(\n (check) =>\n secondsOf(check.poll.timeout) + secondsOf(check.poll.interval) * (1 + check.poll.jitter),\n ),\n ),\n \"a check's timeout plus one jittered interval, at its slowest\",\n );\n // the window of a policy is the time that its latch takes to fail when its slowest check times out\n const windowOf = (checks: typeof gating, policy: \"readiness\" | \"liveness\"): number | undefined =>\n most(\n checks.map((check) => secondsOf(failSpan(svc.policies[policy], check.poll, \"timeout\").max)),\n );\n const readiness = windowOf(readinessChecks, \"readiness\");\n const liveness = windowOf(livenessChecks, \"liveness\");\n set(\"readiness_detection_window@service\", readiness, \"the readiness latch, failing by timeout\");\n if (readiness !== undefined) {\n set(\n \"readiness_detection_window@pod\",\n readiness + secondsOf(scenario.probes.readiness),\n \"the readiness latch, then the kubelet's probe\",\n );\n }\n if (liveness !== undefined) {\n set(\n \"liveness_detection_window@pod\",\n liveness + secondsOf(scenario.probes.liveness),\n \"the liveness window, then the kubelet's probe\",\n );\n }\n set(\"startup_budget@pod\", secondsOf(svc.policies.startup), \"the declared startup budget\");\n set(\n \"process_drain_time@process\",\n svc.shutdown.phases.reduce((total, phase) => total + secondsOf(phase.cap), 0),\n `the shutdown phases' caps, summed (${svc.shutdown.phases.map((phase) => phase.name).join(\", \")})`,\n );\n set(\n \"cooperative_window@process\",\n boundOf(svc.shutdown.cooperativeWindow),\n \"the declared cooperative window\",\n );\n // the hold of \"fail readiness\" keeps the listener open after the signal, as a preStop sleep does\n const hold = svc.shutdown.phases.find((phase) => phase.name === \"fail readiness\");\n set(\n \"readiness_hold@process\",\n hold === undefined ? 0 : secondsOf(hold.cap),\n hold === undefined\n ? \"no fail readiness phase: the intake stops at once after the signal\"\n : \"the cap of the fail readiness phase, which holds while the endpoints update\",\n );\n // the rules of the bounds read the cap of one phase, and `process_drain_time@process` is the sum of all the caps\n const capOf = (name: string): number | undefined => {\n const phase = svc.shutdown.phases.find((each) => each.name === name);\n return phase === undefined ? undefined : secondsOf(phase.cap);\n };\n set(\"drain_phase_cap@process\", capOf(\"drain\"), \"the cap of the drain phase alone\");\n set(\"close_phase_cap@process\", capOf(\"close transports\"), \"the cap of the close transports phase alone\");\n bindScenario(scenario.platform, (symbol) => symbol, bind, epochs);\n for (const [symbol, epoch] of Object.entries(epochs)) {\n if (bind[symbol] === undefined) delete from[symbol];\n else from[symbol] = epoch === null ? \"the scenario\" : `the scenario, for ${epoch}`;\n }\n return { bind, from, epochs };\n};\n\n/** A scope binds its symbols, and records the epoch of each value of the scenario. */\ninterface Scoped {\n readonly bind: Record<string, Bound>;\n readonly epochs: Record<string, string | null>;\n}\n\n/** This function gives the client knobs of a dependency at @client, and the values of the scenario at its own hops. */\nconst dependencyBindings = (dependency: Dependency, scenario: Scenario): Scoped => {\n const bind: Record<string, Bound> = {};\n const epochs: Record<string, string | null> = {};\n for (const [knob, amount] of Object.entries(dependency.knobs))\n bind[`${knob}@client`] = boundOf(amount);\n bindScenario(scenario.dependencies?.[dependency.name] ?? {}, (symbol) => (symbol.includes(\"@\") ? symbol : `${symbol}@dependency`), bind, epochs);\n return { bind, epochs };\n};\n\n/**\n * These are the hops of the law at which the knobs of a transport bind, by its kind. A worker does\n * its units as a consumer does, thus both bind at `consumer` (O20). A server binds at `server`, in a\n * scope of its own. In the scope of a dependency, `@server` is the server of that dependency. Thus\n * the knobs of a server of the service do not bind there, or O19 pairs the wrong two sides.\n */\nconst TRANSPORT_HOPS: Readonly<Record<Transport[\"kind\"], \"server\" | \"consumer\">> = { server: \"server\", consumer: \"consumer\", worker: \"consumer\" };\n\n/**\n * This function gives the time knobs of a transport at the hop of its kind, and the values of the\n * scenario for the transport. These values are of the source of a consumer, or of the clients of a\n * server. A knob with a hop in its name binds at that hop. A count binds no symbol.\n */\nconst transportBindings = (transport: Transport, hop: string, scenario: Scenario): Scoped => {\n const bind: Record<string, Bound> = {};\n const epochs: Record<string, string | null> = {};\n for (const [knob, amount] of Object.entries(transport.knobs)) {\n if (!isTime(amount.unit)) continue;\n bind[knob.includes(\"@\") ? knob : `${knob}@${hop}`] = boundOf(amount);\n }\n bindScenario(scenario.transports?.[transport.name] ?? {}, (symbol) => symbol, bind, epochs);\n return { bind, epochs };\n};\n\n/**\n * This function gives the symbols of a limiter, and the values of the scenario for its callers.\n * - `retry_after@limiter` is the longest `Retry-After` of a refusal by the policy, in whole seconds.\n * It is one interval of the bucket, or one window, as the HTTP edge sends it.\n * - `retry_after_at_cap@limiter` is the longest `Retry-After` of a new key at the cap of keys. It is\n * the idle span, `burst / rate` or one window.\n */\nconst limiterBindings = (limiter: Limiter, scenario: Scenario): Scoped => {\n const bind: Record<string, Bound> = {\n \"retry_after@limiter\": retryAfterSeconds(longestRetryAfter(limiter.policy)),\n \"retry_after_at_cap@limiter\": retryAfterSeconds(idleSpan(limiter.policy)),\n };\n const epochs: Record<string, string | null> = {};\n bindScenario(scenario.limiters?.[limiter.name] ?? {}, (symbol) => (symbol.includes(\"@\") ? symbol : `${symbol}@caller`), bind, epochs);\n return { bind, epochs };\n};\n\nconst SCOPED = /@(client|dependency|server)$/;\nconst SERVER_SCOPED = /@server$/;\nconst TRANSPORT_SCOPED = /@consumer$/;\nconst LIMITER_SCOPED = /@(limiter|caller)$/;\n\n/** This identifier is the rule of the findings about a field that the declaration does not give. */\nexport const DECLARATION_RULE = \"declaration\";\n\n/**\n * This function gives a finding for each field of the shutdown that a description does not give.\n * `describe()` refuses such a declaration. A description from another source, for example the\n * JSON of 0.4, can lack the field. The verdict is `depends`, and `unbound` names the field.\n */\nconst declarationFindings = (svc: ServiceDescription): Finding[] =>\n (svc.shutdown as { onRepeatSignal?: unknown }).onRepeatSignal === undefined\n ? [\n {\n rule: DECLARATION_RULE,\n scope: svc.name,\n verdict: \"depends\",\n statement: \"the declaration tells what a signal does while the shutdown runs: ignore or exit\",\n window: \"a repeat signal has no declared effect\",\n evaluated: [],\n unbound: [\"shutdown.onRepeatSignal\"],\n },\n ]\n : [];\n\n/** This identifier is the rule of the findings for two parts that have one name in the scopes of a rule. */\nexport const NAME_RULE = \"unique-names\";\n\n/**\n * This function gives a finding for each name that two parts share in one set of scopes. A rule\n * about a client applies to each dependency and each server transport. A rule about a consumer\n * applies to each consumer and each worker, and a rule about a limiter to each limiter. Two parts\n * with one name in a set give findings with one scope, thus a reader cannot tell them apart.\n */\nconst nameFindings = (svc: ServiceDescription): Finding[] => {\n const sets: ReadonlyArray<readonly [string, readonly string[]]> = [\n [\n \"the dependencies and the server transports\",\n [...svc.dependencies.map((each) => each.name), ...svc.transports.filter((each) => each.kind === \"server\").map((each) => each.name)],\n ],\n [\"the consumers and the workers\", svc.transports.filter((each) => each.kind !== \"server\").map((each) => each.name)],\n [\"the limiters\", (svc.limiters ?? []).map((each) => each.name)],\n ];\n return sets.flatMap(([set, names]) =>\n [...new Set(names.filter((name, index) => names.indexOf(name) !== index))].map(\n (name): Finding => ({\n rule: NAME_RULE,\n scope: name,\n verdict: \"violated\",\n statement: `each of ${set} has a name of its own`,\n window: `two parts have the name ${name}, thus their findings have one scope`,\n evaluated: [],\n unbound: [],\n }),\n ),\n );\n};\n\n/** This identifier is the rule of the findings about the stall time of a progress check (`Check.marks`). */\nexport const PROGRESS_RULE = \"progress\";\n\n/**\n * This rule compares the stall time of a progress check with the longest gap between two marks of\n * the slowest loop that it names. A shorter stall time trips the check while each loop turns on time.\n */\nconst PROGRESS_LAW: Rule = {\n id: PROGRESS_RULE,\n rule: \"the stall time of a progress check is at least the longest gap between two marks of the slowest loop that it names\",\n window: \"a loop that turns on time can trip the check\",\n expr: {\n lhs: { terms: [{ knob: \"stall\", coef: 1, at: \"check\" }] },\n op: \">=\",\n rhs: { terms: [{ knob: \"mark_gap\", coef: 1, at: \"loop\" }] },\n margin: 0,\n },\n};\n\n/** A gap is the longest time between two marks of one loop, in seconds, or the knobs that it needs. */\ninterface Gap {\n readonly loop: string;\n readonly seconds: number | undefined;\n readonly unbound: readonly string[];\n}\n\n/** These are the knobs of a worker that bound the gap between two of its marks. */\nconst WORKER_GAP_KNOBS = [\"worker_sleep\", \"unit_processing_time\", \"retry_base\", \"retry_cap\"] as const;\n\n/**\n * This function gives the longest gap between two marks of each loop with a name. The rule counts\n * a mark at the end of each turn of the loop, also a turn that fails.\n * - A check polls on a fixed delay from the start of each poll, and each poll ends at its timeout\n * at the latest. Thus the gap is `interval × (1 + jitter) + timeout`.\n * - After an iteration, a lane of a worker waits its sleep, or its backoff after a failure. The\n * longest backoff is `retry_cap` plus its jitter of up to `retry_base`. The next iteration then\n * takes up to `unit_processing_time`. Thus the gap is the longer wait plus that bound.\n *\n * A sleep or a bound without a limit gives a gap without a limit. An iteration that does not end\n * at its abort can take more time, and the rule does not bound it.\n */\nconst gapsOf = (svc: ServiceDescription, loop: string): Gap[] => {\n const gaps: Gap[] = svc.checks\n .filter((check) => check.name === loop)\n .map((check) => ({\n loop,\n seconds: secondsOf(check.poll.interval) * (1 + check.poll.jitter) + secondsOf(check.poll.timeout),\n unbound: [],\n }));\n for (const worker of svc.transports) {\n if (worker.kind !== \"worker\" || worker.name !== loop) continue;\n const knob = (name: string): number | undefined => {\n const amount = worker.knobs[name];\n if (amount === undefined || !isTime(amount.unit)) return undefined;\n return amount.value === \"infinite\" ? Infinity : secondsOf(amount as Quantity);\n };\n const unbound = WORKER_GAP_KNOBS.filter((name) => knob(name) === undefined).map((name) => `${loop}.${name}`);\n if (unbound.length > 0) {\n gaps.push({ loop, seconds: undefined, unbound });\n continue;\n }\n const [sleep, unit, base, cap] = WORKER_GAP_KNOBS.map((name) => knob(name)!) as [number, number, number, number];\n const backoff = Number.isFinite(base) && Number.isFinite(cap)\n ? backoffBand({ base, factor: 2, cap, jitter: { kind: \"add\", amount: base } }).high\n : Infinity;\n gaps.push({ loop, seconds: Math.max(sleep, backoff) + unit, unbound: [] });\n }\n return gaps;\n};\n\n/**\n * This function gives the findings of each check that names the loops that mark it. A name that is\n * not a check or a worker of the service gets a finding of its own, with the verdict `depends`.\n * Without `marks`, a check gets no finding.\n */\nconst progressFindings = (svc: ServiceDescription): Finding[] => {\n const findings: Finding[] = [];\n const finding = (check: Check, fields: Pick<Finding, \"verdict\" | \"evaluated\" | \"unbound\"> & Partial<Finding>): Finding => ({\n rule: PROGRESS_RULE,\n scope: check.name,\n statement: PROGRESS_LAW.rule,\n window: PROGRESS_LAW.window,\n ...fields,\n });\n for (const check of svc.checks) {\n const marks = check.marks;\n if (marks === undefined) continue;\n const gaps: Gap[] = [];\n for (const loop of marks.loops) {\n const found = gapsOf(svc, loop);\n if (found.length > 0) gaps.push(...found);\n else\n findings.push(\n finding(check, {\n verdict: \"depends\",\n statement: \"each loop that a progress check names is a check or a worker of the service\",\n window: `the check waits for the marks of ${loop}, and the service has no loop with that name`,\n evaluated: [],\n unbound: [loop],\n }),\n );\n }\n if (gaps.length === 0) continue;\n const unbound = [\n ...(isTime(marks.stall.unit) ? [] : [`${check.name}.marks.stall`]),\n ...gaps.flatMap((gap) => gap.unbound),\n ];\n const slowest = gaps.reduce((worst, gap) => ((gap.seconds ?? -Infinity) > (worst.seconds ?? -Infinity) ? gap : worst));\n const bind: Record<string, Bound> = {};\n if (isTime(marks.stall.unit)) bind[\"stall@check\"] = boundOf(marks.stall);\n if (unbound.length === 0 && slowest.seconds !== undefined)\n bind[\"mark_gap@loop\"] = Number.isFinite(slowest.seconds) ? slowest.seconds : \"inf\";\n const evaluated = evaluate(PROGRESS_LAW, bind);\n findings.push(\n finding(check, {\n verdict: verdictOf(PROGRESS_LAW, bind, evaluated),\n ...(unbound.length === 0 ? { statement: `${PROGRESS_LAW.rule} (${slowest.loop})` } : {}),\n evaluated,\n unbound,\n }),\n );\n }\n return findings;\n};\n\n/** This identifier is the rule of the findings about the bound of a unit against the cap of the `drain` phase. */\nexport const UNIT_BOUND_RULE = \"unit-bound\";\n\n/** This identifier is the rule of the findings about the close bound against the cap of the `close transports` phase. */\nexport const CLOSE_BOUND_RULE = \"close-bound\";\n\n/**\n * These are the rules of the bounds of a loop. Each one applies one time for each consumer and\n * each worker (S6 A10, A11). `lint()` gives them, as it gives `PROGRESS_RULE`.\n * - unit-bound: `unit_processing_time` is less than the cap of the `drain` phase. Otherwise the\n * drain can cut a unit that ends in its bound. A unit without a bound violates the rule.\n * - close-bound: `close_bound` is less than the cap of the `close transports` phase. Otherwise the\n * phase can end before the loop closes.\n *\n * The corpus of the law (R3) does not have these rules, thus they have identifiers of the service,\n * not O-numbers. The symbols `drain_phase_cap@process` and `close_phase_cap@process` are the caps of\n * one phase. `process_drain_time@process` is the sum of the caps of all the phases. A phase that the\n * declaration does not give binds no symbol, thus its finding is `depends`.\n */\nexport const BOUND_RULES: readonly Rule[] = [\n {\n id: UNIT_BOUND_RULE,\n rule: \"the bound of one unit of a consumer or a worker is less than the cap of the drain phase\",\n window: \"the drain can cut a unit that ends in its bound\",\n expr: {\n lhs: { terms: [{ knob: \"unit_processing_time\", coef: 1, at: \"consumer\" }] },\n op: \"<\",\n rhs: { terms: [{ knob: \"drain_phase_cap\", coef: 1, at: \"process\" }] },\n margin: 0,\n },\n },\n {\n id: CLOSE_BOUND_RULE,\n rule: \"the close bound of a consumer or a worker is less than the cap of the close transports phase\",\n window: \"the phase can end before the loop closes\",\n expr: {\n lhs: { terms: [{ knob: \"close_bound\", coef: 1, at: \"consumer\" }] },\n op: \"<\",\n rhs: { terms: [{ knob: \"close_phase_cap\", coef: 1, at: \"process\" }] },\n margin: 0,\n },\n },\n];\n\n/**\n * This function gives the scopes of a rule that reads these symbols: the service, each client, each\n * consumer and worker, or each limiter. A rule that reads a symbol at `server` applies to each client\n * and to each server transport. In the scope of a server, the scenario gives the client side.\n */\nconst scopesOf = (\n svc: ServiceDescription,\n scenario: Scenario,\n service: { readonly bind: Binding; readonly epochs: Epochs },\n symbols: readonly string[],\n): Array<[string, Binding, Epochs]> => {\n const within = (name: string, scoped: Scoped): [string, Binding, Epochs] => {\n // a value of the scope that binds nothing hides the value of the service, as its epoch does\n const bind: Record<string, Bound | readonly number[] | undefined> = { ...service.bind, ...scoped.bind };\n for (const symbol of Object.keys(scoped.epochs)) if (!(symbol in scoped.bind)) delete bind[symbol];\n return [name, bind, { ...service.epochs, ...scoped.epochs }];\n };\n const transports = (hop: \"server\" | \"consumer\"): Array<[string, Binding, Epochs]> =>\n svc.transports\n .filter((transport) => TRANSPORT_HOPS[transport.kind] === hop)\n .map((transport) => within(transport.name, transportBindings(transport, hop, scenario)));\n return symbols.some((symbol) => LIMITER_SCOPED.test(symbol))\n ? (svc.limiters ?? []).map((limiter) => within(limiter.name, limiterBindings(limiter, scenario)))\n : symbols.some((symbol) => TRANSPORT_SCOPED.test(symbol))\n ? transports(\"consumer\")\n : symbols.some((symbol) => SCOPED.test(symbol))\n ? [\n ...svc.dependencies.map((dependency) => within(dependency.name, dependencyBindings(dependency, scenario))),\n ...(symbols.some((symbol) => SERVER_SCOPED.test(symbol)) ? transports(\"server\") : []),\n ]\n : [[svc.name, service.bind, service.epochs]];\n};\n\n/** This function gives the epochs of the symbols of a rule that the scenario binds. */\nconst epochsOf = (symbols: readonly string[], epochs: Epochs): Epochs =>\n Object.fromEntries(symbols.flatMap((symbol) => (symbol in epochs ? [[symbol, epochs[symbol] ?? null]] : [])));\n\n/**\n * These are the marks of the timers of the platform (E10). Kubernetes takes the probe period, the\n * preStop sleep and the termination grace in whole seconds, thus each is stepped by 1 s. The\n * cluster sets the propagation of the endpoints, thus a compression of the service cannot scale it.\n */\nexport const PLATFORM_MARKS: TimerMarks = {\n \"probe_period@pod\": { kind: \"stepped\", step: 1 },\n \"prestop_sleep@pod\": { kind: \"stepped\", step: 1 },\n \"termination_grace@pod\": { kind: \"stepped\", step: 1 },\n \"propagation_bound@cluster\": { kind: \"fixed\" },\n};\n\n/** A change of a compression of a service: a rule and a scope whose verdict the compression changes. */\nexport interface ScopedChange extends Change {\n readonly scope: string;\n}\n\n/**\n * This function tells which findings of `lint` a compression by k changes (E10). It scales the\n * bindings of each scope by the marks. Thus a harness that runs the service k times faster learns\n * the orderings that its run breaks. The unmarked symbols are the symbols of the rules with no mark.\n * It reads the rules that `lint` applies with their bindings: the service rules and `BOUND_RULES`.\n */\nexport const compressionOf = (\n svc: ServiceDescription,\n scenario: Scenario,\n rules: readonly Rule[],\n k: number,\n marks: TimerMarks,\n): { readonly changed: readonly ScopedChange[]; readonly unmarked: readonly string[] } => {\n const service = serviceBindings(svc, scenario);\n const changed: ScopedChange[] = [];\n const unmarked = new Set<string>();\n for (const rule of [...rules.filter((each) => SERVICE_RULES.includes(each.id)), ...BOUND_RULES]) {\n for (const [scope, bind] of scopesOf(svc, scenario, service, symbolsOf(rule))) {\n const result = compression([rule], bind, k, marks);\n for (const change of result.changed) changed.push({ ...change, scope });\n for (const symbol of result.unmarked) unmarked.add(symbol);\n }\n }\n return { changed, unmarked: [...unmarked] };\n};\n\n/** This function gives the findings of one rule, one for each scope of the rule. */\nconst findingsOf = (\n svc: ServiceDescription,\n scenario: Scenario,\n service: { readonly bind: Binding; readonly epochs: Epochs },\n rule: Rule,\n): Finding[] => {\n const symbols = symbolsOf(rule);\n return scopesOf(svc, scenario, service, symbols).map(([scope, bind, all]) => {\n const evaluated = evaluate(rule, bind);\n const epochs = epochsOf(symbols, all);\n return {\n rule: rule.id,\n scope,\n verdict: verdictOf(rule, bind, evaluated),\n statement: rule.rule,\n ...(rule.window !== undefined ? { window: rule.window } : {}),\n evaluated,\n unbound: symbols.filter((symbol) => bind[symbol] === undefined),\n // a scenario of plain amounts names no epoch, thus its findings stay as they were\n ...(Object.values(epochs).some((epoch) => epoch !== null) ? { epochs } : {}),\n };\n });\n};\n\n/**\n * This function applies each service rule to a declaration and a scenario. A rule applies one time\n * for the service, for each client, for each consumer and worker, or for each limiter. It also\n * gives a finding for each necessary field that the description does not give (`DECLARATION_RULE`).\n * It gives a finding for each name that two parts share in the scopes of a rule (`NAME_RULE`). Each progress check\n * that names its loops also gets its findings (`PROGRESS_RULE`). The findings of the bounds of each\n * consumer and each worker come last (`BOUND_RULES`).\n */\nexport const lint = (\n svc: ServiceDescription,\n scenario: Scenario,\n rules: readonly Rule[],\n): Finding[] => {\n const service = serviceBindings(svc, scenario);\n return [\n ...declarationFindings(svc),\n ...nameFindings(svc),\n ...progressFindings(svc),\n ...rules.filter((rule) => SERVICE_RULES.includes(rule.id)).flatMap((rule) => findingsOf(svc, scenario, service, rule)),\n ...BOUND_RULES.flatMap((rule) => findingsOf(svc, scenario, service, rule)),\n ];\n};\n"],"mappings":";;;;;;;AA0BA,MAAa,gBAA2B;;AA4DxC,MAAa,gBAAmC;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,MAAa,gBAAiC,CAC5C;CACE,IAAI;CACJ,MAAM;CACN,QAAQ;CACR,MAAM;EACJ,KAAK,EAAE,OAAO,CAAC;GAAE,MAAM;GAAe,MAAM;GAAG,IAAI;EAAU,CAAC,EAAE;EAChE,IAAI;EACJ,KAAK,EAAE,OAAO,CAAC;GAAE,MAAM;GAAuB,MAAM;GAAG,IAAI;EAAS,CAAC,EAAE;EACvE,QAAQ;CACV;CACA,WAAW,CACT;EACE,KAAK,EAAE,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AAU,UAAU,IAAI;CAC9B,OAAO,SAAS,KAAK,UAAU,SAAS,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,SAAS;EAC3E,MAAM,YAAY,SAAS,MAAM,IAAI;EACrC,MAAM,SAAS,SAAS,SAAS,GAAG;EACpC,OAAO;GACL,MAAM,KAAK;GACX;GACA,SAAS,UAAU,MAAM,MAAM,SAAS;GACxC,WAAW,KAAK;GAChB,GAAI,KAAK,WAAW,KAAA,IAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;GAC3D;GACA,SAAS,QAAQ,QAAQ,WAAW,KAAK,YAAY,KAAA,CAAS;GAE9D,GAAI,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,UAAU,UAAU,IAAI,IAAI,EAAE,OAAO,IAAI,CAAC;EAC5E;CACF,CAAC;AACH;;;;;;;;;AAUA,MAAa,QACX,KACA,UACA,UACc;CACd,MAAM,UAAU,gBAAgB,KAAK,QAAQ;CAC7C,OAAO;EACL,GAAG,oBAAoB,GAAG;EAC1B,GAAG,aAAa,GAAG;EACnB,GAAG,iBAAiB,GAAG;EACvB,GAAG,MAAM,QAAQ,SAAS,cAAc,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,SAAS,WAAW,KAAK,UAAU,SAAS,IAAI,CAAC;EACrH,GAAG,YAAY,SAAS,SAAS,WAAW,KAAK,UAAU,SAAS,IAAI,CAAC;CAC3E;AACF"}
@@ -0,0 +1,71 @@
1
+ import { ServiceDescription } from "./description.js";
2
+ import { Recorder } from "./events.js";
3
+ /** These are the levels of a log entry, from the least to the most severe. */
4
+ export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
5
+ export type LogLevel = (typeof LOG_LEVELS)[number];
6
+ /** These fields are the structured data of a log entry, for example the machine and the cap of a phase. */
7
+ export type LogFields = Readonly<Record<string, unknown>>;
8
+ /**
9
+ * A logger is the port that receives the log entries of the runtime. It has one method, thus an
10
+ * adapter to another logger is a few lines. For example, `{ log: (level, message, fields) => app[level](message, fields) }`.
11
+ */
12
+ export interface Logger {
13
+ log(level: LogLevel, message: string, fields: LogFields): void;
14
+ }
15
+ /** A log entry is one call of a logger, as a test logger keeps it. */
16
+ export interface LogEntry {
17
+ readonly level: LogLevel;
18
+ readonly message: string;
19
+ readonly fields: LogFields;
20
+ }
21
+ /** This function tells if `level` is at `least` or more severe. */
22
+ export declare const atLeast: (level: LogLevel, least: LogLevel) => boolean;
23
+ /** A console target has one method for each level, as the console of Node and of a browser has. */
24
+ export type ConsoleTarget = Readonly<Record<LogLevel, (...data: unknown[]) => void>>;
25
+ /**
26
+ * A log format tells how the console logger writes an entry.
27
+ * - `text`: the message, and then the fields as an object, when the entry has fields.
28
+ * - `json`: one line of JSON for each entry, with the level, the message and each field.
29
+ */
30
+ export type LogFormat = "text" | "json";
31
+ /** These are the ids of the trace and of the span of a log entry, with the names of the OpenTelemetry log data model. */
32
+ export interface TraceIds {
33
+ readonly trace_id: string;
34
+ readonly span_id: string;
35
+ }
36
+ /**
37
+ * A source of trace ids gives the ids of the active span, or nothing when no span is active. The
38
+ * entry `@mark1russell7/service/otel` has one on the API of OpenTelemetry: `traceIds`.
39
+ */
40
+ export type TraceIdsSource = () => TraceIds | undefined;
41
+ /** These options make the console logger. */
42
+ export interface ConsoleLoggerOptions {
43
+ /** This level is the least severe level that the logger writes. The default is `info`. */
44
+ readonly level?: LogLevel | undefined;
45
+ /** This target receives each entry. The default is the global console. */
46
+ readonly console?: ConsoleTarget | undefined;
47
+ /** This format tells how the logger writes each entry. The default is `text`. */
48
+ readonly format?: LogFormat | undefined;
49
+ /**
50
+ * This source gives the trace ids of each entry. The logger adds them to the fields, but a field
51
+ * of the entry with the same name stays. With no source, or when the source gives nothing, the
52
+ * entry does not change.
53
+ */
54
+ readonly traceIds?: TraceIdsSource | undefined;
55
+ }
56
+ /**
57
+ * This function makes the console logger. It writes each entry at its level or more severe to the
58
+ * method of that level. In the format `text`, it writes the message first and then the fields. In
59
+ * the format `json`, it writes one line of JSON.
60
+ */
61
+ export declare const consoleLogger: (options?: ConsoleLoggerOptions) => Logger;
62
+ /**
63
+ * This function makes a recorder that writes each lifecycle event to a logger. Thus the logger is
64
+ * one sink of the same stream as the recorder, not a second set of calls. The levels are these:
65
+ * - `error`: each error of the lifecycle, and an exit at once on a repeat signal.
66
+ * - `warn`: a phase at its cap, a failed startup, a startup over its budget, a tripped latch and a blocked event loop.
67
+ * - `info`: each step of the startup, the start and the end of each phase, the exit, and each recovery.
68
+ * - `debug`: each other transition, for example each poll of a check.
69
+ * With the description, the entry of a phase also gives its cap. A failure of the logger does not stop the lifecycle.
70
+ */
71
+ export declare const logEvents: (logger: Logger, description?: ServiceDescription) => Recorder;
@@ -0,0 +1,183 @@
1
+ import { valueIn } from "@mark1russell7/quantity";
2
+ // src/logger.ts
3
+ /** These are the levels of a log entry, from the least to the most severe. */
4
+ const LOG_LEVELS = [
5
+ "debug",
6
+ "info",
7
+ "warn",
8
+ "error"
9
+ ];
10
+ /** This function tells if `level` is at `least` or more severe. */
11
+ const atLeast = (level, least) => LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(least);
12
+ /** This function gives the fields with the trace ids of the source added. A field of the entry stays. */
13
+ const withTraceIds = (fields, source) => {
14
+ const ids = source();
15
+ if (ids === void 0) return fields;
16
+ return {
17
+ trace_id: ids.trace_id,
18
+ span_id: ids.span_id,
19
+ ...fields
20
+ };
21
+ };
22
+ /** This function gives a value of a field that JSON can write: an error as its name, message and stack, and a bigint as text. */
23
+ const jsonValue = (_key, value) => {
24
+ if (typeof value === "bigint") return value.toString();
25
+ if (value instanceof Error) return {
26
+ name: value.name,
27
+ message: value.message,
28
+ ...value.stack === void 0 ? {} : { stack: value.stack }
29
+ };
30
+ return value;
31
+ };
32
+ /**
33
+ * This function gives one line of JSON for an entry. A field named `level` or `message` does not
34
+ * replace the level or the message. A field that JSON cannot write, for example a cycle, gives its failure as text.
35
+ */
36
+ const jsonLine = (level, message, fields) => {
37
+ const { level: _level, message: _message, ...rest } = fields;
38
+ try {
39
+ return JSON.stringify({
40
+ level,
41
+ message,
42
+ ...rest
43
+ }, jsonValue);
44
+ } catch (error) {
45
+ return JSON.stringify({
46
+ level,
47
+ message,
48
+ unwritten: error instanceof Error ? error.message : String(error)
49
+ });
50
+ }
51
+ };
52
+ /**
53
+ * This function makes the console logger. It writes each entry at its level or more severe to the
54
+ * method of that level. In the format `text`, it writes the message first and then the fields. In
55
+ * the format `json`, it writes one line of JSON.
56
+ */
57
+ const consoleLogger = (options = {}) => {
58
+ const least = options.level ?? "info";
59
+ const format = options.format ?? "text";
60
+ const source = options.traceIds;
61
+ if (format !== "text" && format !== "json") throw new Error(`the log format ${JSON.stringify(format)} is not "text" or "json"`);
62
+ return { log(level, message, entryFields) {
63
+ if (!atLeast(level, least)) return;
64
+ const fields = source === void 0 ? entryFields : withTraceIds(entryFields, source);
65
+ const target = options.console ?? globalThis.console;
66
+ if (format === "json") target[level](jsonLine(level, message, fields));
67
+ else if (Object.keys(fields).length === 0) target[level](message);
68
+ else target[level](message, fields);
69
+ } };
70
+ };
71
+ const seconds = (cap) => `${valueIn(cap, "s")} s`;
72
+ /** This function gives the exit code from the detail of an exit event, for example `exit 1`. */
73
+ const exitCodeOf = (detail) => {
74
+ const found = /^exit (\d+)$/.exec(detail ?? "");
75
+ return found === null ? null : Number(found[1]);
76
+ };
77
+ /**
78
+ * This function makes a recorder that writes each lifecycle event to a logger. Thus the logger is
79
+ * one sink of the same stream as the recorder, not a second set of calls. The levels are these:
80
+ * - `error`: each error of the lifecycle, and an exit at once on a repeat signal.
81
+ * - `warn`: a phase at its cap, a failed startup, a startup over its budget, a tripped latch and a blocked event loop.
82
+ * - `info`: each step of the startup, the start and the end of each phase, the exit, and each recovery.
83
+ * - `debug`: each other transition, for example each poll of a check.
84
+ * With the description, the entry of a phase also gives its cap. A failure of the logger does not stop the lifecycle.
85
+ */
86
+ const logEvents = (logger, description) => {
87
+ const caps = new Map((description?.shutdown.phases ?? []).map((phase) => [phase.name, phase.cap]));
88
+ const startedAt = /* @__PURE__ */ new Map();
89
+ const write = (level, message, fields) => {
90
+ try {
91
+ logger.log(level, message, fields);
92
+ } catch {}
93
+ };
94
+ const phaseEnd = (event, base) => {
95
+ const phase = event.from;
96
+ const cap = caps.get(phase);
97
+ const begun = startedAt.get(phase);
98
+ const reached = event.on === "phase.cap";
99
+ const fields = {
100
+ ...base,
101
+ phase,
102
+ outcome: reached ? "cap" : "done",
103
+ ...cap === void 0 ? {} : { cap },
104
+ ...begun === void 0 ? {} : { took: {
105
+ value: event.at - begun,
106
+ unit: "ms"
107
+ } }
108
+ };
109
+ if (reached) write("warn", `the phase ${phase} reached its cap${cap === void 0 ? "" : ` of ${seconds(cap)}`}`, fields);
110
+ else write("info", `the phase ${phase} ended in its cap`, fields);
111
+ };
112
+ const phaseStart = (event, base) => {
113
+ const phase = event.to;
114
+ const cap = caps.get(phase);
115
+ startedAt.set(phase, event.at);
116
+ write("info", `the phase ${phase} starts${cap === void 0 ? "" : `, with a cap of ${seconds(cap)}`}`, {
117
+ ...base,
118
+ phase,
119
+ ...cap === void 0 ? {} : { cap }
120
+ });
121
+ };
122
+ return (event) => {
123
+ const { machine, instance, from, to, on, at, detail } = event;
124
+ const base = {
125
+ machine,
126
+ instance,
127
+ from,
128
+ to,
129
+ on,
130
+ at,
131
+ ...detail === void 0 ? {} : { detail }
132
+ };
133
+ switch (machine) {
134
+ case "gate":
135
+ if (on === "component.started") return write("info", `${detail ?? "a component"} started`, {
136
+ ...base,
137
+ component: detail
138
+ });
139
+ if (on === "startup.begin") return write("info", `the startup of ${instance} begins`, base);
140
+ if (on === "mark-ready") return write("info", "the warm-up sweep begins", base);
141
+ if (on === "sweep.done") return write("info", `${instance} is ready: the startup gate is open`, base);
142
+ if (on === "startup.fail") return write("warn", `the startup of ${instance} failed`, base);
143
+ if (on === "startup.over-budget") return write("warn", `the startup of ${instance} is over its budget`, base);
144
+ break;
145
+ case "exit":
146
+ if (on === "error") return write("error", detail ?? "an error of the lifecycle", base);
147
+ if (to === "exited") {
148
+ const code = exitCodeOf(detail);
149
+ const fields = {
150
+ ...base,
151
+ code
152
+ };
153
+ if (on === "exit.repeat") return write("error", `a signal came again, and ${instance} exits at once with the code ${code}`, fields);
154
+ return write("info", `${instance} exited with the code ${code}`, fields);
155
+ }
156
+ if (from === "running" && to === "stopping") return write("info", `the shutdown of ${instance} begins`, {
157
+ ...base,
158
+ cause: detail
159
+ });
160
+ if (on === "exit.repeat") return write("info", "a trigger came again while the shutdown runs", base);
161
+ break;
162
+ case "drain":
163
+ if (on === "signal.abort") return write("info", `the signal of ${instance} aborts`, base);
164
+ if (on === "drain.cooperative-abort") return write("info", "the cooperative abort of the drain", base);
165
+ if (on === "phase.done" || on === "phase.cap") phaseEnd(event, base);
166
+ if (to !== "done" && from !== to) phaseStart(event, base);
167
+ else if (to === "done") write("info", `the shutdown of ${instance} ended its phases`, base);
168
+ return;
169
+ case "latch":
170
+ case "window":
171
+ if (to === "tripped" && from !== "tripped") return write("warn", `the check ${instance} tripped its latch`, base);
172
+ if (to === "released" && (from === "tripped" || from === "recovering")) return write("info", `the check ${instance} released its latch`, base);
173
+ break;
174
+ case "watchdog":
175
+ if (to === "blocked" && from !== "blocked") return write("warn", "the event loop is blocked", base);
176
+ if (to === "watching" && from === "blocked") return write("info", "the event loop is no longer blocked", base);
177
+ }
178
+ write("debug", `${machine} ${instance}: ${from} -> ${to} on ${on}`, base);
179
+ };
180
+ };
181
+ export { LOG_LEVELS, atLeast, consoleLogger, logEvents };
182
+
183
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","names":[],"sources":["../src/logger.ts"],"sourcesContent":["import type { Quantity } from \"@mark1russell7/quantity\";\nimport { valueIn } from \"@mark1russell7/quantity\";\nimport type { ServiceDescription } from \"./description.ts\";\nimport type { LifecycleEvent, Recorder } from \"./events.ts\";\n\n/** These are the levels of a log entry, from the least to the most severe. */\nexport const LOG_LEVELS = [\"debug\", \"info\", \"warn\", \"error\"] as const;\n\nexport type LogLevel = (typeof LOG_LEVELS)[number];\n\n/** These fields are the structured data of a log entry, for example the machine and the cap of a phase. */\nexport type LogFields = Readonly<Record<string, unknown>>;\n\n/**\n * A logger is the port that receives the log entries of the runtime. It has one method, thus an\n * adapter to another logger is a few lines. For example, `{ log: (level, message, fields) => app[level](message, fields) }`.\n */\nexport interface Logger {\n log(level: LogLevel, message: string, fields: LogFields): void;\n}\n\n/** A log entry is one call of a logger, as a test logger keeps it. */\nexport interface LogEntry {\n readonly level: LogLevel;\n readonly message: string;\n readonly fields: LogFields;\n}\n\n/** This function tells if `level` is at `least` or more severe. */\nexport const atLeast = (level: LogLevel, least: LogLevel): boolean => LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(least);\n\n/** A console target has one method for each level, as the console of Node and of a browser has. */\nexport type ConsoleTarget = Readonly<Record<LogLevel, (...data: unknown[]) => void>>;\n\n/**\n * A log format tells how the console logger writes an entry.\n * - `text`: the message, and then the fields as an object, when the entry has fields.\n * - `json`: one line of JSON for each entry, with the level, the message and each field.\n */\nexport type LogFormat = \"text\" | \"json\";\n\n/** These are the ids of the trace and of the span of a log entry, with the names of the OpenTelemetry log data model. */\nexport interface TraceIds {\n readonly trace_id: string;\n readonly span_id: string;\n}\n\n/**\n * A source of trace ids gives the ids of the active span, or nothing when no span is active. The\n * entry `@mark1russell7/service/otel` has one on the API of OpenTelemetry: `traceIds`.\n */\nexport type TraceIdsSource = () => TraceIds | undefined;\n\n/** These options make the console logger. */\nexport interface ConsoleLoggerOptions {\n /** This level is the least severe level that the logger writes. The default is `info`. */\n readonly level?: LogLevel | undefined;\n /** This target receives each entry. The default is the global console. */\n readonly console?: ConsoleTarget | undefined;\n /** This format tells how the logger writes each entry. The default is `text`. */\n readonly format?: LogFormat | undefined;\n /**\n * This source gives the trace ids of each entry. The logger adds them to the fields, but a field\n * of the entry with the same name stays. With no source, or when the source gives nothing, the\n * entry does not change.\n */\n readonly traceIds?: TraceIdsSource | undefined;\n}\n\n/** This function gives the fields with the trace ids of the source added. A field of the entry stays. */\nconst withTraceIds = (fields: LogFields, source: TraceIdsSource): LogFields => {\n const ids = source();\n if (ids === undefined) return fields;\n return { trace_id: ids.trace_id, span_id: ids.span_id, ...fields };\n};\n\n/** This function gives a value of a field that JSON can write: an error as its name, message and stack, and a bigint as text. */\nconst jsonValue = (_key: string, value: unknown): unknown => {\n if (typeof value === \"bigint\") return value.toString();\n if (value instanceof Error) return { name: value.name, message: value.message, ...(value.stack === undefined ? {} : { stack: value.stack }) };\n return value;\n};\n\n/**\n * This function gives one line of JSON for an entry. A field named `level` or `message` does not\n * replace the level or the message. A field that JSON cannot write, for example a cycle, gives its failure as text.\n */\nconst jsonLine = (level: LogLevel, message: string, fields: LogFields): string => {\n const { level: _level, message: _message, ...rest } = fields;\n try {\n return JSON.stringify({ level, message, ...rest }, jsonValue);\n } catch (error) {\n return JSON.stringify({ level, message, unwritten: error instanceof Error ? error.message : String(error) });\n }\n};\n\n/**\n * This function makes the console logger. It writes each entry at its level or more severe to the\n * method of that level. In the format `text`, it writes the message first and then the fields. In\n * the format `json`, it writes one line of JSON.\n */\nexport const consoleLogger = (options: ConsoleLoggerOptions = {}): Logger => {\n const least = options.level ?? \"info\";\n const format = options.format ?? \"text\";\n const source = options.traceIds;\n if (format !== \"text\" && format !== \"json\") throw new Error(`the log format ${JSON.stringify(format)} is not \"text\" or \"json\"`);\n return {\n log(level, message, entryFields) {\n if (!atLeast(level, least)) return;\n const fields = source === undefined ? entryFields : withTraceIds(entryFields, source);\n const target = options.console ?? globalThis.console;\n if (format === \"json\") target[level](jsonLine(level, message, fields));\n else if (Object.keys(fields).length === 0) target[level](message);\n else target[level](message, fields);\n },\n };\n};\n\nconst seconds = (cap: Quantity): string => `${valueIn(cap, \"s\")} s`;\n\n/** This function gives the exit code from the detail of an exit event, for example `exit 1`. */\nconst exitCodeOf = (detail: string | undefined): number | null => {\n const found = /^exit (\\d+)$/.exec(detail ?? \"\");\n return found === null ? null : Number(found[1]);\n};\n\n/**\n * This function makes a recorder that writes each lifecycle event to a logger. Thus the logger is\n * one sink of the same stream as the recorder, not a second set of calls. The levels are these:\n * - `error`: each error of the lifecycle, and an exit at once on a repeat signal.\n * - `warn`: a phase at its cap, a failed startup, a startup over its budget, a tripped latch and a blocked event loop.\n * - `info`: each step of the startup, the start and the end of each phase, the exit, and each recovery.\n * - `debug`: each other transition, for example each poll of a check.\n * With the description, the entry of a phase also gives its cap. A failure of the logger does not stop the lifecycle.\n */\nexport const logEvents = (logger: Logger, description?: ServiceDescription): Recorder => {\n const caps = new Map((description?.shutdown.phases ?? []).map((phase) => [phase.name, phase.cap] as const));\n // the time that each phase started, for the duration in the entry of its end\n const startedAt = new Map<string, number>();\n const write = (level: LogLevel, message: string, fields: LogFields): void => {\n try {\n logger.log(level, message, fields);\n } catch {\n // the lifecycle does not depend on its logger\n }\n };\n const phaseEnd = (event: LifecycleEvent, base: LogFields): void => {\n const phase = event.from;\n const cap = caps.get(phase);\n const begun = startedAt.get(phase);\n const reached = event.on === \"phase.cap\";\n const fields: LogFields = {\n ...base,\n phase,\n outcome: reached ? \"cap\" : \"done\",\n ...(cap === undefined ? {} : { cap }),\n ...(begun === undefined ? {} : { took: { value: event.at - begun, unit: \"ms\" } }),\n };\n if (reached) write(\"warn\", `the phase ${phase} reached its cap${cap === undefined ? \"\" : ` of ${seconds(cap)}`}`, fields);\n else write(\"info\", `the phase ${phase} ended in its cap`, fields);\n };\n const phaseStart = (event: LifecycleEvent, base: LogFields): void => {\n const phase = event.to;\n const cap = caps.get(phase);\n startedAt.set(phase, event.at);\n write(\"info\", `the phase ${phase} starts${cap === undefined ? \"\" : `, with a cap of ${seconds(cap)}`}`, {\n ...base,\n phase,\n ...(cap === undefined ? {} : { cap }),\n });\n };\n return (event) => {\n const { machine, instance, from, to, on, at, detail } = event;\n const base: LogFields = { machine, instance, from, to, on, at, ...(detail === undefined ? {} : { detail }) };\n switch (machine) {\n case \"gate\":\n if (on === \"component.started\") return write(\"info\", `${detail ?? \"a component\"} started`, { ...base, component: detail });\n if (on === \"startup.begin\") return write(\"info\", `the startup of ${instance} begins`, base);\n if (on === \"mark-ready\") return write(\"info\", \"the warm-up sweep begins\", base);\n if (on === \"sweep.done\") return write(\"info\", `${instance} is ready: the startup gate is open`, base);\n if (on === \"startup.fail\") return write(\"warn\", `the startup of ${instance} failed`, base);\n if (on === \"startup.over-budget\") return write(\"warn\", `the startup of ${instance} is over its budget`, base);\n break;\n case \"exit\":\n if (on === \"error\") return write(\"error\", detail ?? \"an error of the lifecycle\", base);\n if (to === \"exited\") {\n const code = exitCodeOf(detail);\n const fields = { ...base, code };\n if (on === \"exit.repeat\") return write(\"error\", `a signal came again, and ${instance} exits at once with the code ${code}`, fields);\n return write(\"info\", `${instance} exited with the code ${code}`, fields);\n }\n if (from === \"running\" && to === \"stopping\") return write(\"info\", `the shutdown of ${instance} begins`, { ...base, cause: detail });\n if (on === \"exit.repeat\") return write(\"info\", \"a trigger came again while the shutdown runs\", base);\n break;\n case \"drain\":\n if (on === \"signal.abort\") return write(\"info\", `the signal of ${instance} aborts`, base);\n if (on === \"drain.cooperative-abort\") return write(\"info\", \"the cooperative abort of the drain\", base);\n if (on === \"phase.done\" || on === \"phase.cap\") phaseEnd(event, base);\n if (to !== \"done\" && from !== to) phaseStart(event, base);\n else if (to === \"done\") write(\"info\", `the shutdown of ${instance} ended its phases`, base);\n return;\n case \"latch\":\n case \"window\":\n if (to === \"tripped\" && from !== \"tripped\") return write(\"warn\", `the check ${instance} tripped its latch`, base);\n if (to === \"released\" && (from === \"tripped\" || from === \"recovering\")) return write(\"info\", `the check ${instance} released its latch`, base);\n break;\n case \"watchdog\":\n if (to === \"blocked\" && from !== \"blocked\") return write(\"warn\", \"the event loop is blocked\", base);\n if (to === \"watching\" && from === \"blocked\") return write(\"info\", \"the event loop is no longer blocked\", base);\n break;\n default:\n break;\n }\n write(\"debug\", `${machine} ${instance}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7/algebra";
4
+ /**
5
+ * The startup gate opens one time. The lifecycle moves it from `closed` to `starting` while its
6
+ * components start. Then one warm-up sweep of each check opens it. A component that does not start
7
+ * fails it for good.
8
+ */
9
+ export declare const GATE_MACHINE: Machine;
10
+ /** A debounce latch counts the polls of its check in sequence. A readiness latch starts tripped. */
11
+ export declare const LATCH_MACHINE: Machine;
12
+ /**
13
+ * A window latch measures time on the monotonic clock from the first failure of a sequence, and
14
+ * from the first pass after a trip.
15
+ */
16
+ export declare const WINDOW_MACHINE: Machine;
17
+ /**
18
+ * A poller starts one check on a jittered loop with a fixed delay. A call that outlives its timeout
19
+ * stays pending (`hung`), and the poller does not start the check again until the call settles.
20
+ */
21
+ export declare const POLLER_MACHINE: Machine;
22
+ /**
23
+ * The exit manager is the only part that ends the process. The first exit request starts the
24
+ * shutdown. A later request has no effect, but a repeat signal exits at once when the declaration
25
+ * says `onRepeatSignal: "exit"`. The exit code is the code of the exit request, else 1 after an
26
+ * error, else 0.
27
+ */
28
+ export declare const EXIT_MACHINE: Machine;
29
+ /** A watchdog measures how late its own tick comes, and a late tick shows a blocked event loop. */
30
+ export declare const WATCHDOG_MACHINE: Machine;
31
+ /** This function gives the name of a knob for the cap of a phase: `drain` gives `drain_cap`. */
32
+ export declare const capKnob: (phase: string) => string;
33
+ /**
34
+ * This function gives the drain of a declaration as a machine. It has one state for each declared
35
+ * phase, in its sequence, and each state has a timer at its cap. The drain also has the cooperative abort: the
36
+ * cap of the drain less the cooperative window. With the floor `half`, it is half that cap at the
37
+ * least. With the floor `none`, it is 0 at the least.
38
+ */
39
+ export declare const drainMachine: (description: ServiceDescription) => Machine;
40
+ /** These are the static machines of the runtime, by the name that their events carry. */
41
+ export declare const MACHINES: Readonly<Record<Exclude<MachineName, "drain" | "client">, Machine>>;