@classytic/stage 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (431) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +18 -0
  2. package/dist/atomic/aufbau.d.mts +144 -0
  3. package/dist/atomic/aufbau.mjs +384 -0
  4. package/dist/atomic/elements.d.mts +67 -0
  5. package/dist/atomic/elements.mjs +785 -0
  6. package/dist/atomic/emission.d.mts +112 -0
  7. package/dist/atomic/emission.mjs +179 -0
  8. package/dist/atomic/index.d.mts +8 -0
  9. package/dist/atomic/index.mjs +9 -0
  10. package/dist/atomic/periodic.d.mts +82 -0
  11. package/dist/atomic/periodic.mjs +231 -0
  12. package/dist/atomic/properties.d.mts +100 -0
  13. package/dist/atomic/properties.mjs +574 -0
  14. package/dist/atomic/shells.d.mts +137 -0
  15. package/dist/atomic/shells.mjs +170 -0
  16. package/dist/atomic/trends.d.mts +148 -0
  17. package/dist/atomic/trends.mjs +225 -0
  18. package/dist/chem/chromatography.d.mts +66 -0
  19. package/dist/chem/chromatography.mjs +63 -0
  20. package/dist/chem/complex.d.mts +114 -0
  21. package/dist/chem/complex.mjs +234 -0
  22. package/dist/chem/cycle.d.mts +75 -0
  23. package/dist/chem/cycle.mjs +145 -0
  24. package/dist/chem/equation.d.mts +86 -0
  25. package/dist/chem/equation.mjs +168 -0
  26. package/dist/chem/formula.d.mts +90 -0
  27. package/dist/chem/formula.mjs +201 -0
  28. package/dist/chem/functional-groups.d.mts +31 -0
  29. package/dist/chem/functional-groups.mjs +187 -0
  30. package/dist/chem/hazard.d.mts +94 -0
  31. package/dist/chem/hazard.mjs +329 -0
  32. package/dist/chem/index.d.mts +34 -33
  33. package/dist/chem/index.mjs +34 -28
  34. package/dist/chem/ionic.d.mts +98 -0
  35. package/dist/chem/ionic.mjs +156 -0
  36. package/dist/chem/layout.d.mts +46 -0
  37. package/dist/chem/layout.mjs +342 -0
  38. package/dist/chem/lewis.d.mts +79 -0
  39. package/dist/chem/lewis.mjs +163 -0
  40. package/dist/chem/molecular-orbital.d.mts +114 -0
  41. package/dist/chem/molecular-orbital.mjs +201 -0
  42. package/dist/chem/molecule.d.mts +154 -0
  43. package/dist/chem/molecule.mjs +282 -0
  44. package/dist/chem/nmr.d.mts +153 -0
  45. package/dist/chem/nmr.mjs +165 -0
  46. package/dist/chem/polymer.d.mts +65 -0
  47. package/dist/chem/polymer.mjs +179 -0
  48. package/dist/chem/redox.d.mts +138 -0
  49. package/dist/chem/redox.mjs +328 -0
  50. package/dist/chem/relations.d.mts +183 -0
  51. package/dist/chem/relations.mjs +299 -0
  52. package/dist/chem/skeleton.d.mts +51 -0
  53. package/dist/chem/skeleton.mjs +186 -0
  54. package/dist/chem/solution.d.mts +116 -0
  55. package/dist/chem/solution.mjs +186 -0
  56. package/dist/chem/species.d.mts +47 -0
  57. package/dist/chem/species.mjs +128 -0
  58. package/dist/chem/stereo.d.mts +108 -0
  59. package/dist/chem/stereo.mjs +286 -0
  60. package/dist/chem/stoichiometry.d.mts +95 -0
  61. package/dist/chem/stoichiometry.mjs +145 -0
  62. package/dist/chem/synthesis.d.mts +113 -0
  63. package/dist/chem/synthesis.mjs +281 -0
  64. package/dist/chem/vsepr.d.mts +80 -0
  65. package/dist/chem/vsepr.mjs +247 -0
  66. package/dist/circuit/ac.d.mts +163 -0
  67. package/dist/circuit/ac.mjs +452 -0
  68. package/dist/circuit/dc.d.mts +92 -0
  69. package/dist/circuit/dc.mjs +333 -0
  70. package/dist/circuit/index.d.mts +5 -92
  71. package/dist/circuit/index.mjs +5 -332
  72. package/dist/circuit/network.d.mts +99 -0
  73. package/dist/circuit/network.mjs +440 -0
  74. package/dist/circuit/topology.d.mts +102 -0
  75. package/dist/circuit/topology.mjs +143 -0
  76. package/dist/colour/absorption.d.mts +79 -0
  77. package/dist/colour/absorption.mjs +137 -0
  78. package/dist/colour/index.d.mts +6 -0
  79. package/dist/colour/index.mjs +7 -0
  80. package/dist/colour/name.d.mts +14 -0
  81. package/dist/colour/name.mjs +76 -0
  82. package/dist/colour/observer.d.mts +31 -0
  83. package/dist/colour/observer.mjs +46 -0
  84. package/dist/colour/spectrum.d.mts +61 -0
  85. package/dist/colour/spectrum.mjs +108 -0
  86. package/dist/colour/srgb.d.mts +49 -0
  87. package/dist/colour/srgb.mjs +108 -0
  88. package/dist/core/constants.d.mts +138 -0
  89. package/dist/core/constants.mjs +139 -0
  90. package/dist/core/index.d.mts +3 -1
  91. package/dist/core/index.mjs +3 -1
  92. package/dist/core/vec3.d.mts +94 -0
  93. package/dist/core/vec3.mjs +123 -0
  94. package/dist/core/worked.d.mts +35 -0
  95. package/dist/core/worked.mjs +44 -0
  96. package/dist/electro/cell.d.mts +102 -0
  97. package/dist/electro/cell.mjs +170 -0
  98. package/dist/electro/conductivity.d.mts +157 -0
  99. package/dist/electro/conductivity.mjs +156 -0
  100. package/dist/electro/couples.d.mts +114 -0
  101. package/dist/electro/couples.mjs +334 -0
  102. package/dist/electro/electrolysis.d.mts +96 -0
  103. package/dist/electro/electrolysis.mjs +274 -0
  104. package/dist/electro/faraday.d.mts +150 -0
  105. package/dist/electro/faraday.mjs +118 -0
  106. package/dist/electro/index.d.mts +6 -0
  107. package/dist/electro/index.mjs +7 -0
  108. package/dist/finance/accounting/adjustments.d.mts +17 -0
  109. package/dist/finance/accounting/adjustments.mjs +202 -0
  110. package/dist/finance/accounting/analysis.d.mts +8 -0
  111. package/dist/finance/accounting/analysis.mjs +205 -0
  112. package/dist/finance/accounting/clubs.d.mts +21 -0
  113. package/dist/finance/accounting/clubs.mjs +217 -0
  114. package/dist/finance/accounting/company-statements.d.mts +7 -0
  115. package/dist/finance/accounting/company-statements.mjs +150 -0
  116. package/dist/finance/accounting/harness.d.mts +7 -0
  117. package/dist/finance/accounting/harness.mjs +45 -0
  118. package/dist/finance/accounting/index.d.mts +18 -0
  119. package/dist/finance/accounting/index.mjs +18 -0
  120. package/dist/finance/accounting/journalize.d.mts +16 -0
  121. package/dist/finance/accounting/journalize.mjs +128 -0
  122. package/dist/finance/accounting/manufacturing.d.mts +8 -0
  123. package/dist/finance/accounting/manufacturing.mjs +236 -0
  124. package/dist/finance/accounting/partnership.d.mts +7 -0
  125. package/dist/finance/accounting/partnership.mjs +152 -0
  126. package/dist/finance/accounting/period-case.d.mts +6 -0
  127. package/dist/finance/accounting/period-case.mjs +71 -0
  128. package/dist/finance/accounting/post.d.mts +9 -0
  129. package/dist/finance/accounting/post.mjs +84 -0
  130. package/dist/finance/accounting/precision.d.mts +9 -0
  131. package/dist/finance/accounting/precision.mjs +15 -0
  132. package/dist/finance/accounting/rules.d.mts +21 -0
  133. package/dist/finance/accounting/rules.mjs +37 -0
  134. package/dist/finance/accounting/solve.d.mts +28 -0
  135. package/dist/finance/accounting/solve.mjs +92 -0
  136. package/dist/finance/accounting/statements.d.mts +7 -0
  137. package/dist/finance/accounting/statements.mjs +142 -0
  138. package/dist/finance/accounting/types.d.mts +649 -0
  139. package/dist/finance/accounting/validate.d.mts +7 -0
  140. package/dist/finance/accounting/validate.mjs +67 -0
  141. package/dist/finance/accounting/verification.d.mts +24 -0
  142. package/dist/finance/accounting/verification.mjs +386 -0
  143. package/dist/finance/bizsim.d.mts +21 -39
  144. package/dist/finance/bizsim.mjs +276 -97
  145. package/dist/finance/index.d.mts +20 -43
  146. package/dist/finance/index.mjs +19 -77
  147. package/dist/finance/investment-math.d.mts +7 -0
  148. package/dist/finance/investment-math.mjs +18 -0
  149. package/dist/finance/management-accounting/budgeting.d.mts +7 -0
  150. package/dist/finance/management-accounting/budgeting.mjs +189 -0
  151. package/dist/finance/management-accounting/cash-budget.d.mts +7 -0
  152. package/dist/finance/management-accounting/cash-budget.mjs +154 -0
  153. package/dist/finance/management-accounting/costing.d.mts +8 -0
  154. package/dist/finance/management-accounting/costing.mjs +175 -0
  155. package/dist/finance/management-accounting/decisions.d.mts +8 -0
  156. package/dist/finance/management-accounting/decisions.mjs +164 -0
  157. package/dist/finance/management-accounting/index.d.mts +13 -0
  158. package/dist/finance/management-accounting/index.mjs +13 -0
  159. package/dist/finance/management-accounting/integrated-budget.d.mts +8 -0
  160. package/dist/finance/management-accounting/integrated-budget.mjs +67 -0
  161. package/dist/finance/management-accounting/inventory-costing.d.mts +7 -0
  162. package/dist/finance/management-accounting/inventory-costing.mjs +173 -0
  163. package/dist/finance/management-accounting/investment-appraisal.d.mts +7 -0
  164. package/dist/finance/management-accounting/investment-appraisal.mjs +148 -0
  165. package/dist/finance/management-accounting/management-case.d.mts +8 -0
  166. package/dist/finance/management-accounting/management-case.mjs +91 -0
  167. package/dist/finance/management-accounting/master-budget.d.mts +7 -0
  168. package/dist/finance/management-accounting/master-budget.mjs +137 -0
  169. package/dist/finance/management-accounting/production-costing.d.mts +8 -0
  170. package/dist/finance/management-accounting/production-costing.mjs +214 -0
  171. package/dist/finance/management-accounting/types.d.mts +644 -0
  172. package/dist/finance/management-accounting/variances.d.mts +7 -0
  173. package/dist/finance/management-accounting/variances.mjs +150 -0
  174. package/dist/index.d.mts +6 -6
  175. package/dist/index.mjs +1 -1
  176. package/dist/math/analysis.d.mts +61 -0
  177. package/dist/math/analysis.mjs +187 -0
  178. package/dist/math/answer-check.d.mts +50 -0
  179. package/dist/math/answer-check.mjs +106 -0
  180. package/dist/math/calculus.d.mts +4 -9
  181. package/dist/math/calculus.mjs +216 -7
  182. package/dist/math/complex.d.mts +93 -0
  183. package/dist/math/complex.mjs +239 -0
  184. package/dist/math/expr.d.mts +23 -0
  185. package/dist/math/expr.mjs +36 -0
  186. package/dist/math/index.d.mts +8 -22
  187. package/dist/math/index.mjs +8 -37
  188. package/dist/math/latex.mjs +2 -1
  189. package/dist/math/parse.mjs +1 -1
  190. package/dist/math/poly.d.mts +55 -0
  191. package/dist/math/poly.mjs +273 -0
  192. package/dist/math/rearrange.d.mts +14 -0
  193. package/dist/math/rearrange.mjs +125 -0
  194. package/dist/math/solve.d.mts +21 -0
  195. package/dist/math/solve.mjs +75 -0
  196. package/dist/networking/addressing.d.mts +26 -0
  197. package/dist/networking/addressing.mjs +33 -0
  198. package/dist/networking/cloud/access.d.mts +36 -0
  199. package/dist/networking/cloud/access.mjs +95 -0
  200. package/dist/networking/cloud/containers.d.mts +43 -0
  201. package/dist/networking/cloud/containers.mjs +54 -0
  202. package/dist/networking/cloud/edge.d.mts +17 -0
  203. package/dist/networking/cloud/edge.mjs +31 -0
  204. package/dist/networking/cloud/failure-domains.d.mts +19 -0
  205. package/dist/networking/cloud/failure-domains.mjs +22 -0
  206. package/dist/networking/cloud/geo-routing.d.mts +22 -0
  207. package/dist/networking/cloud/geo-routing.mjs +64 -0
  208. package/dist/networking/cloud/index.d.mts +18 -0
  209. package/dist/networking/cloud/index.mjs +19 -0
  210. package/dist/networking/cloud/inference-reliability.d.mts +30 -0
  211. package/dist/networking/cloud/inference-reliability.mjs +76 -0
  212. package/dist/networking/cloud/inference.d.mts +118 -0
  213. package/dist/networking/cloud/inference.mjs +179 -0
  214. package/dist/networking/cloud/infrastructure.d.mts +45 -0
  215. package/dist/networking/cloud/infrastructure.mjs +96 -0
  216. package/dist/networking/cloud/observability.d.mts +24 -0
  217. package/dist/networking/cloud/observability.mjs +34 -0
  218. package/dist/networking/cloud/orchestration.d.mts +32 -0
  219. package/dist/networking/cloud/orchestration.mjs +38 -0
  220. package/dist/networking/cloud/recovery.d.mts +21 -0
  221. package/dist/networking/cloud/recovery.mjs +27 -0
  222. package/dist/networking/cloud/releases.d.mts +42 -0
  223. package/dist/networking/cloud/releases.mjs +135 -0
  224. package/dist/networking/cloud/scaling.d.mts +25 -0
  225. package/dist/networking/cloud/scaling.mjs +65 -0
  226. package/dist/networking/cloud/secrets.d.mts +39 -0
  227. package/dist/networking/cloud/secrets.mjs +68 -0
  228. package/dist/networking/cloud/server-deployment.d.mts +29 -0
  229. package/dist/networking/cloud/server-deployment.mjs +72 -0
  230. package/dist/networking/cloud/storage.d.mts +16 -0
  231. package/dist/networking/cloud/storage.mjs +58 -0
  232. package/dist/networking/cloud/vpc.d.mts +18 -0
  233. package/dist/networking/cloud/vpc.mjs +100 -0
  234. package/dist/networking/delivery.d.mts +34 -0
  235. package/dist/networking/delivery.mjs +52 -0
  236. package/dist/networking/index.d.mts +47 -0
  237. package/dist/networking/index.mjs +47 -0
  238. package/dist/networking/ipv6.d.mts +28 -0
  239. package/dist/networking/ipv6.mjs +17 -0
  240. package/dist/networking/journeys.d.mts +83 -0
  241. package/dist/networking/journeys.mjs +161 -0
  242. package/dist/networking/models/airtime.d.mts +87 -0
  243. package/dist/networking/models/airtime.mjs +130 -0
  244. package/dist/networking/models/cellular.d.mts +157 -0
  245. package/dist/networking/models/cellular.mjs +252 -0
  246. package/dist/networking/models/encapsulation.d.mts +98 -0
  247. package/dist/networking/models/encapsulation.mjs +132 -0
  248. package/dist/networking/models/handover.d.mts +116 -0
  249. package/dist/networking/models/handover.mjs +209 -0
  250. package/dist/networking/models/handshake.d.mts +90 -0
  251. package/dist/networking/models/handshake.mjs +122 -0
  252. package/dist/networking/models/index.d.mts +14 -0
  253. package/dist/networking/models/index.mjs +15 -0
  254. package/dist/networking/models/media.d.mts +82 -0
  255. package/dist/networking/models/media.mjs +188 -0
  256. package/dist/networking/models/satellite.d.mts +86 -0
  257. package/dist/networking/models/satellite.mjs +121 -0
  258. package/dist/networking/models/spectrum.d.mts +83 -0
  259. package/dist/networking/models/spectrum.mjs +235 -0
  260. package/dist/networking/models/switch.d.mts +80 -0
  261. package/dist/networking/models/switch.mjs +155 -0
  262. package/dist/networking/models/vlan.d.mts +62 -0
  263. package/dist/networking/models/vlan.mjs +100 -0
  264. package/dist/networking/models/vpn.d.mts +66 -0
  265. package/dist/networking/models/vpn.mjs +125 -0
  266. package/dist/networking/models/wifi-privacy.d.mts +82 -0
  267. package/dist/networking/models/wifi-privacy.mjs +130 -0
  268. package/dist/networking/models/wifi.d.mts +240 -0
  269. package/dist/networking/models/wifi.mjs +562 -0
  270. package/dist/networking/nat-traversal.d.mts +24 -0
  271. package/dist/networking/nat-traversal.mjs +38 -0
  272. package/dist/networking/protocols.d.mts +17 -0
  273. package/dist/networking/protocols.mjs +57 -0
  274. package/dist/networking/queue.d.mts +12 -0
  275. package/dist/networking/queue.mjs +18 -0
  276. package/dist/networking/route-learning.d.mts +23 -0
  277. package/dist/networking/route-learning.mjs +43 -0
  278. package/dist/networking/routing.d.mts +11 -0
  279. package/dist/networking/routing.mjs +25 -0
  280. package/dist/networking/signals.d.mts +26 -0
  281. package/dist/networking/signals.mjs +35 -0
  282. package/dist/networking/subnet.d.mts +49 -0
  283. package/dist/networking/subnet.mjs +89 -0
  284. package/dist/networking/tcp-reliability.d.mts +24 -0
  285. package/dist/networking/tcp-reliability.mjs +38 -0
  286. package/dist/networking/topology/contract.d.mts +123 -0
  287. package/dist/networking/topology/index.d.mts +4 -0
  288. package/dist/networking/topology/index.mjs +4 -0
  289. package/dist/networking/topology/presets.d.mts +7 -0
  290. package/dist/networking/topology/presets.mjs +302 -0
  291. package/dist/networking/topology/simulation.d.mts +8 -0
  292. package/dist/networking/topology/simulation.mjs +179 -0
  293. package/dist/networking/wireless.d.mts +11 -0
  294. package/dist/networking/wireless.mjs +17 -0
  295. package/dist/optics/imaging.d.mts +218 -0
  296. package/dist/optics/imaging.mjs +276 -0
  297. package/dist/optics/index.d.mts +7 -0
  298. package/dist/optics/index.mjs +8 -0
  299. package/dist/optics/laws.d.mts +70 -0
  300. package/dist/optics/laws.mjs +195 -0
  301. package/dist/optics/prism.d.mts +148 -0
  302. package/dist/optics/prism.mjs +197 -0
  303. package/dist/optics/refraction.d.mts +201 -0
  304. package/dist/optics/refraction.mjs +270 -0
  305. package/dist/optics/wave-optics.d.mts +171 -0
  306. package/dist/optics/wave-optics.mjs +259 -0
  307. package/dist/physics/ac/index.d.mts +183 -0
  308. package/dist/physics/ac/index.mjs +203 -0
  309. package/dist/physics/dynamics/forces.d.mts +98 -0
  310. package/dist/physics/dynamics/forces.mjs +153 -0
  311. package/dist/physics/dynamics/friction.d.mts +76 -0
  312. package/dist/physics/dynamics/friction.mjs +119 -0
  313. package/dist/physics/dynamics/system.d.mts +68 -0
  314. package/dist/physics/dynamics/system.mjs +125 -0
  315. package/dist/physics/electrostatics/index.d.mts +169 -0
  316. package/dist/physics/electrostatics/index.mjs +249 -0
  317. package/dist/physics/energy/centre-of-mass.d.mts +115 -0
  318. package/dist/physics/energy/centre-of-mass.mjs +180 -0
  319. package/dist/physics/energy/conservation.d.mts +81 -0
  320. package/dist/physics/energy/conservation.mjs +129 -0
  321. package/dist/physics/energy/power.d.mts +90 -0
  322. package/dist/physics/energy/power.mjs +167 -0
  323. package/dist/physics/energy/spring.d.mts +73 -0
  324. package/dist/physics/energy/spring.mjs +129 -0
  325. package/dist/physics/energy/store.d.mts +63 -0
  326. package/dist/physics/energy/store.mjs +108 -0
  327. package/dist/physics/energy/theorem.d.mts +65 -0
  328. package/dist/physics/energy/theorem.mjs +113 -0
  329. package/dist/physics/energy/work.d.mts +114 -0
  330. package/dist/physics/energy/work.mjs +219 -0
  331. package/dist/physics/gravitation/body.d.mts +85 -0
  332. package/dist/physics/gravitation/body.mjs +168 -0
  333. package/dist/physics/gravitation/kepler.d.mts +127 -0
  334. package/dist/physics/gravitation/kepler.mjs +216 -0
  335. package/dist/physics/gravitation/law.d.mts +117 -0
  336. package/dist/physics/gravitation/law.mjs +175 -0
  337. package/dist/physics/gravitation/orbit.d.mts +119 -0
  338. package/dist/physics/gravitation/orbit.mjs +202 -0
  339. package/dist/physics/gravitation/potential.d.mts +114 -0
  340. package/dist/physics/gravitation/potential.mjs +202 -0
  341. package/dist/physics/gravitation/variation.d.mts +97 -0
  342. package/dist/physics/gravitation/variation.mjs +175 -0
  343. package/dist/physics/index.d.mts +35 -0
  344. package/dist/physics/index.mjs +36 -0
  345. package/dist/physics/integral-sweep.d.mts +63 -0
  346. package/dist/physics/integral-sweep.mjs +126 -0
  347. package/dist/physics/kinematics/equations.d.mts +47 -0
  348. package/dist/physics/kinematics/equations.mjs +126 -0
  349. package/dist/physics/kinematics/free-fall.d.mts +53 -0
  350. package/dist/physics/kinematics/free-fall.mjs +71 -0
  351. package/dist/physics/kinematics/given.d.mts +16 -0
  352. package/dist/physics/kinematics/given.mjs +55 -0
  353. package/dist/physics/kinematics/roots.d.mts +41 -0
  354. package/dist/physics/kinematics/roots.mjs +72 -0
  355. package/dist/physics/kinematics/solve.d.mts +52 -0
  356. package/dist/physics/kinematics/solve.mjs +172 -0
  357. package/dist/physics/magnetism/biot-savart.d.mts +161 -0
  358. package/dist/physics/magnetism/biot-savart.mjs +353 -0
  359. package/dist/physics/magnetism/flux.d.mts +94 -0
  360. package/dist/physics/magnetism/flux.mjs +313 -0
  361. package/dist/physics/magnetism/geomagnetism.d.mts +151 -0
  362. package/dist/physics/magnetism/geomagnetism.mjs +184 -0
  363. package/dist/physics/magnetism/index.d.mts +12 -0
  364. package/dist/physics/magnetism/index.mjs +74 -0
  365. package/dist/physics/magnetism/lorentz.d.mts +28 -0
  366. package/dist/physics/magnetism/lorentz.mjs +88 -0
  367. package/dist/physics/magnetism/magnetic-force.d.mts +102 -0
  368. package/dist/physics/magnetism/magnetic-force.mjs +169 -0
  369. package/dist/physics/momentum/collide.d.mts +77 -0
  370. package/dist/physics/momentum/collide.mjs +115 -0
  371. package/dist/physics/momentum/impulse.d.mts +89 -0
  372. package/dist/physics/momentum/impulse.mjs +159 -0
  373. package/dist/physics/momentum/planar.d.mts +60 -0
  374. package/dist/physics/momentum/planar.mjs +110 -0
  375. package/dist/physics/projectile.d.mts +107 -0
  376. package/dist/physics/projectile.mjs +185 -0
  377. package/dist/physics/rotation/angular.d.mts +85 -0
  378. package/dist/physics/rotation/angular.mjs +130 -0
  379. package/dist/physics/rotation/circular.d.mts +79 -0
  380. package/dist/physics/rotation/circular.mjs +131 -0
  381. package/dist/physics/rotation/inertia.d.mts +164 -0
  382. package/dist/physics/rotation/inertia.mjs +332 -0
  383. package/dist/physics/rotation/torque.d.mts +65 -0
  384. package/dist/physics/rotation/torque.mjs +134 -0
  385. package/dist/physics/vectors.d.mts +64 -0
  386. package/dist/physics/vectors.mjs +114 -0
  387. package/dist/quantity/index.d.mts +119 -0
  388. package/dist/quantity/index.mjs +417 -0
  389. package/dist/relation/derive.d.mts +74 -0
  390. package/dist/relation/derive.mjs +73 -0
  391. package/dist/relation/index.d.mts +56 -0
  392. package/dist/relation/index.mjs +234 -0
  393. package/dist/scene/evaluators.mjs +1 -1
  394. package/dist/sim/thermal.mjs +45 -20
  395. package/dist/thermo/calorimetry.d.mts +207 -0
  396. package/dist/thermo/calorimetry.mjs +345 -0
  397. package/dist/thermo/cycles.d.mts +142 -0
  398. package/dist/thermo/cycles.mjs +256 -0
  399. package/dist/thermo/entropy.d.mts +87 -0
  400. package/dist/thermo/entropy.mjs +140 -0
  401. package/dist/thermo/expansion.d.mts +130 -0
  402. package/dist/thermo/expansion.mjs +178 -0
  403. package/dist/thermo/gas.d.mts +197 -0
  404. package/dist/thermo/gas.mjs +279 -0
  405. package/dist/thermo/heat-transfer.d.mts +164 -0
  406. package/dist/thermo/heat-transfer.mjs +217 -0
  407. package/dist/thermo/index.d.mts +9 -82
  408. package/dist/thermo/index.mjs +9 -132
  409. package/dist/thermo/processes.d.mts +95 -0
  410. package/dist/thermo/processes.mjs +154 -0
  411. package/dist/thermo/temperature.d.mts +174 -0
  412. package/dist/thermo/temperature.mjs +236 -0
  413. package/dist/waves/damping.d.mts +224 -0
  414. package/dist/waves/damping.mjs +317 -0
  415. package/dist/waves/doppler.d.mts +72 -0
  416. package/dist/waves/doppler.mjs +125 -0
  417. package/dist/waves/index.d.mts +10 -0
  418. package/dist/waves/index.mjs +10 -0
  419. package/dist/waves/pendulum.d.mts +130 -0
  420. package/dist/waves/pendulum.mjs +211 -0
  421. package/dist/waves/pitch.d.mts +125 -0
  422. package/dist/waves/pitch.mjs +158 -0
  423. package/dist/waves/shm.d.mts +170 -0
  424. package/dist/waves/shm.mjs +279 -0
  425. package/dist/waves/springs.d.mts +103 -0
  426. package/dist/waves/springs.mjs +176 -0
  427. package/dist/waves/superposition.d.mts +124 -0
  428. package/dist/waves/superposition.mjs +196 -0
  429. package/dist/waves/wave.d.mts +154 -0
  430. package/dist/waves/wave.mjs +178 -0
  431. package/package.json +74 -2
@@ -0,0 +1,118 @@
1
+ //#region src/networking/cloud/inference.d.ts
2
+ type ModelSize = "8b" | "70b";
3
+ type Precision = "fp16" | "int8";
4
+ type GpuMemory = 24 | 80;
5
+ type BatchSize = 1 | 8 | 32;
6
+ type ContextSize = 2048 | 8192;
7
+ type PromptTokens = 128 | 1024 | 4096;
8
+ type OutputTokens = 32 | 256 | 1024;
9
+ type InferenceScheduler = "shared" | "prefill-priority" | "decode-priority";
10
+ type PrefixTokens = 0 | 512 | 2048 | 4096;
11
+ type UniquePromptTokens = 128 | 512;
12
+ type PrefixCacheState = "cold" | "warm";
13
+ type PrefixCacheScope = "shared" | "tenant-isolated";
14
+ type PrefixRequester = "same-tenant" | "other-tenant";
15
+ type DistributedStrategy = "replicas" | "tensor-parallel";
16
+ type GpuCount = 1 | 2 | 4 | 8;
17
+ type GpuInterconnect = "local-fast" | "local-limited" | "cross-node";
18
+ type ModelRoutingPolicy = "always-small" | "always-large" | "adaptive";
19
+ type InferenceWorkloadMix = "mostly-simple" | "mixed" | "mostly-complex";
20
+ type ResponseQualityTarget = "standard" | "strict";
21
+ interface InferenceCapacityResult {
22
+ model: ModelSize;
23
+ precision: Precision;
24
+ gpuMemory: GpuMemory;
25
+ gpus: number;
26
+ batch: BatchSize;
27
+ context: ContextSize;
28
+ weightsGb: number;
29
+ kvCacheGb: number;
30
+ requiredGb: number;
31
+ availableGb: number;
32
+ fits: boolean;
33
+ topology: "replicas" | "tensor-parallel" | "cannot-load";
34
+ replicas: number;
35
+ tokensPerSecond: number;
36
+ ttftMs: number;
37
+ memoryHeadroomGb: number;
38
+ diagnosis: string;
39
+ }
40
+ interface InferenceRequestResult {
41
+ promptTokens: PromptTokens;
42
+ outputTokens: OutputTokens;
43
+ concurrentRequests: number;
44
+ scheduler: InferenceScheduler;
45
+ prefillWork: number;
46
+ decodeWork: number;
47
+ ttftMs: number;
48
+ interTokenMs: number;
49
+ completionMs: number;
50
+ activeKvTokens: number;
51
+ bottleneck: "prefill" | "decode" | "balanced";
52
+ diagnosis: string;
53
+ }
54
+ interface PrefixCacheResult {
55
+ prefixTokens: PrefixTokens;
56
+ uniqueTokens: UniquePromptTokens;
57
+ cacheState: PrefixCacheState;
58
+ scope: PrefixCacheScope;
59
+ requester: PrefixRequester;
60
+ reusableTokens: number;
61
+ computedTokens: number;
62
+ hitRatePercent: number;
63
+ prefillMs: number;
64
+ savedPrefillMs: number;
65
+ privacyRisk: boolean;
66
+ outcome: "cold-miss" | "cache-hit" | "isolated-miss" | "no-prefix";
67
+ diagnosis: string;
68
+ }
69
+ interface DistributedInferenceResult {
70
+ model: ModelSize;
71
+ strategy: DistributedStrategy;
72
+ gpus: GpuCount;
73
+ interconnect: GpuInterconnect;
74
+ modelGb: number;
75
+ memoryPerGpuGb: number;
76
+ fits: boolean;
77
+ servingCopies: number;
78
+ ranksPerRequest: number;
79
+ computeMsPerToken: number;
80
+ communicationMsPerToken: number;
81
+ tokenStepMs: number;
82
+ relativeThroughput: number;
83
+ failedGpuImpact: "one-replica" | "whole-shard-group" | "service-offline";
84
+ diagnosis: string;
85
+ }
86
+ interface ModelRoutingResult {
87
+ policy: ModelRoutingPolicy;
88
+ workload: InferenceWorkloadMix;
89
+ qualityTarget: ResponseQualityTarget;
90
+ requests: number;
91
+ simpleRequests: number;
92
+ complexRequests: number;
93
+ smallModelRequests: number;
94
+ largeModelRequests: number;
95
+ usefulResponses: number;
96
+ usefulRatePercent: number;
97
+ requiredUsefulRatePercent: number;
98
+ meetsQualityTarget: boolean;
99
+ totalCostUnits: number;
100
+ costPerRequest: number;
101
+ costPerUsefulResponse: number;
102
+ averageLatencyUnits: number;
103
+ diagnosis: string;
104
+ }
105
+ /** Comparative routing model; cost, latency and quality units are illustrative rather than vendor benchmarks. */
106
+ declare function simulateModelRouting(policy: ModelRoutingPolicy, workload: InferenceWorkloadMix, qualityTarget: ResponseQualityTarget): ModelRoutingResult;
107
+ /** Comparative distributed-serving model; values show topology effects, not vendor benchmarks. */
108
+ declare function simulateDistributedInference(model: ModelSize, strategy: DistributedStrategy, gpus: GpuCount, interconnect: GpuInterconnect): DistributedInferenceResult;
109
+ /** Models full-block KV prefix reuse. It never treats semantic similarity as cache identity. */
110
+ declare function simulatePrefixCache(prefixTokens: PrefixTokens, uniqueTokens: UniquePromptTokens, cacheState: PrefixCacheState, scope: PrefixCacheScope, requester: PrefixRequester): PrefixCacheResult;
111
+ /**
112
+ * Comparative teaching model for the two phases of autoregressive inference.
113
+ * Values are dimensioned and monotonic, but are not claims about a particular model or GPU.
114
+ */
115
+ declare function simulateInferenceRequest(promptTokens: PromptTokens, outputTokens: OutputTokens, concurrentRequests: number, scheduler: InferenceScheduler): InferenceRequestResult;
116
+ declare function planInference(model: ModelSize, precision: Precision, gpuMemory: GpuMemory, gpus: number, batch: BatchSize, context: ContextSize): InferenceCapacityResult;
117
+ //#endregion
118
+ export { BatchSize, ContextSize, DistributedInferenceResult, DistributedStrategy, GpuCount, GpuInterconnect, GpuMemory, InferenceCapacityResult, InferenceRequestResult, InferenceScheduler, InferenceWorkloadMix, ModelRoutingPolicy, ModelRoutingResult, ModelSize, OutputTokens, Precision, PrefixCacheResult, PrefixCacheScope, PrefixCacheState, PrefixRequester, PrefixTokens, PromptTokens, ResponseQualityTarget, UniquePromptTokens, planInference, simulateDistributedInference, simulateInferenceRequest, simulateModelRouting, simulatePrefixCache };
@@ -0,0 +1,179 @@
1
+ //#region src/networking/cloud/inference.ts
2
+ /** Comparative routing model; cost, latency and quality units are illustrative rather than vendor benchmarks. */
3
+ function simulateModelRouting(policy, workload, qualityTarget) {
4
+ const requests = 100;
5
+ const simpleRequests = workload === "mostly-simple" ? 85 : workload === "mixed" ? 60 : 25;
6
+ const complexRequests = requests - simpleRequests;
7
+ const smallModelRequests = policy === "always-small" ? requests : policy === "always-large" ? 0 : Math.round(simpleRequests * .85 + complexRequests * .1);
8
+ const largeModelRequests = requests - smallModelRequests;
9
+ const useful = (count, rate) => count * rate;
10
+ let usefulResponses;
11
+ if (policy === "always-small") usefulResponses = useful(simpleRequests, .94) + useful(complexRequests, .54);
12
+ else if (policy === "always-large") usefulResponses = useful(simpleRequests, .98) + useful(complexRequests, .9);
13
+ else {
14
+ const simpleToSmall = Math.round(simpleRequests * .85);
15
+ const complexToSmall = Math.round(complexRequests * .1);
16
+ usefulResponses = useful(simpleToSmall, .94) + useful(simpleRequests - simpleToSmall, .98) + useful(complexToSmall, .54) + useful(complexRequests - complexToSmall, .9);
17
+ }
18
+ const roundedUseful = Math.round(usefulResponses * 10) / 10;
19
+ const totalCostUnits = smallModelRequests + largeModelRequests * 6;
20
+ const routerLatency = policy === "adaptive" ? .1 : 0;
21
+ const averageLatencyUnits = (smallModelRequests * .8 + largeModelRequests * 2.4) / requests + routerLatency;
22
+ const requiredUsefulRatePercent = qualityTarget === "strict" ? 92 : 80;
23
+ const meetsQualityTarget = roundedUseful >= requiredUsefulRatePercent;
24
+ const costPerUsefulResponse = Math.round(totalCostUnits / Math.max(1, roundedUseful) * 100) / 100;
25
+ const diagnosis = !meetsQualityTarget ? "Cheap requests are not cheap outcomes when too many responses fail the workload quality gate." : policy === "always-large" ? "Quality clears the gate, but simple requests consume the same expensive capacity as complex ones." : policy === "adaptive" ? "The router spends large-model capacity selectively; evaluate its decisions on a representative workload, not prompt anecdotes." : "The small model clears this workload's quality gate, so added routing complexity would not yet earn its cost.";
26
+ return {
27
+ policy,
28
+ workload,
29
+ qualityTarget,
30
+ requests,
31
+ simpleRequests,
32
+ complexRequests,
33
+ smallModelRequests,
34
+ largeModelRequests,
35
+ usefulResponses: roundedUseful,
36
+ usefulRatePercent: roundedUseful,
37
+ requiredUsefulRatePercent,
38
+ meetsQualityTarget,
39
+ totalCostUnits,
40
+ costPerRequest: Math.round(totalCostUnits / requests * 100) / 100,
41
+ costPerUsefulResponse,
42
+ averageLatencyUnits: Math.round(averageLatencyUnits * 100) / 100,
43
+ diagnosis
44
+ };
45
+ }
46
+ /** Comparative distributed-serving model; values show topology effects, not vendor benchmarks. */
47
+ function simulateDistributedInference(model, strategy, gpus, interconnect) {
48
+ const modelGb = model === "8b" ? 17.3 : 151.2;
49
+ const memoryPerGpuGb = strategy === "tensor-parallel" ? modelGb / gpus : modelGb;
50
+ const fits = memoryPerGpuGb + 4 <= 80;
51
+ const servingCopies = fits ? strategy === "replicas" ? gpus : 1 : 0;
52
+ const ranksPerRequest = strategy === "tensor-parallel" ? gpus : 1;
53
+ const baseComputeMs = model === "8b" ? 12 : 34;
54
+ const computeMsPerToken = strategy === "tensor-parallel" ? Math.round(baseComputeMs / Math.pow(gpus, .72) * 10) / 10 : baseComputeMs;
55
+ const communicationMsPerToken = strategy === "tensor-parallel" && gpus > 1 ? Math.round((interconnect === "local-fast" ? .7 : interconnect === "local-limited" ? 2.2 : 6.5) * Math.log2(gpus) * 10) / 10 : 0;
56
+ const tokenStepMs = fits ? Math.round((computeMsPerToken + communicationMsPerToken) * 10) / 10 : 0;
57
+ const relativeThroughput = fits ? Math.round((strategy === "replicas" ? gpus : baseComputeMs / Math.max(1, tokenStepMs)) * 100) / 100 : 0;
58
+ const failedGpuImpact = gpus === 1 ? "service-offline" : strategy === "replicas" ? "one-replica" : "whole-shard-group";
59
+ const diagnosis = !fits ? strategy === "replicas" ? "A complete model copy must fit on every replica. Adding more GPUs does not combine their memory." : "The shard plus runtime workspace still exceeds memory per GPU. Add ranks or reduce model memory." : strategy === "replicas" ? `${gpus} independent copies serve different requests without a collective on every token step.` : communicationMsPerToken >= computeMsPerToken ? "Collective communication costs at least as much as shard compute, so more ranks no longer mean proportional speedup." : "Each token uses every rank: compute is divided, then intermediate results are exchanged before generation continues.";
60
+ return {
61
+ model,
62
+ strategy,
63
+ gpus,
64
+ interconnect,
65
+ modelGb,
66
+ memoryPerGpuGb: Math.round(memoryPerGpuGb * 10) / 10,
67
+ fits,
68
+ servingCopies,
69
+ ranksPerRequest,
70
+ computeMsPerToken,
71
+ communicationMsPerToken,
72
+ tokenStepMs,
73
+ relativeThroughput,
74
+ failedGpuImpact,
75
+ diagnosis
76
+ };
77
+ }
78
+ /** Models full-block KV prefix reuse. It never treats semantic similarity as cache identity. */
79
+ function simulatePrefixCache(prefixTokens, uniqueTokens, cacheState, scope, requester) {
80
+ const fullBlockTokens = Math.floor(prefixTokens / 16) * 16;
81
+ const isolated = scope === "tenant-isolated" && requester === "other-tenant";
82
+ const reusableTokens = cacheState === "warm" && !isolated ? fullBlockTokens : 0;
83
+ const totalPromptTokens = prefixTokens + uniqueTokens;
84
+ const computedTokens = totalPromptTokens - reusableTokens;
85
+ const baselinePrefillMs = 60 + totalPromptTokens * .21;
86
+ const prefillMs = Math.round(60 + computedTokens * .21);
87
+ const savedPrefillMs = Math.round(baselinePrefillMs - prefillMs);
88
+ const hitRatePercent = totalPromptTokens === 0 ? 0 : Math.round(reusableTokens / totalPromptTokens * 100);
89
+ const privacyRisk = scope === "shared" && requester === "other-tenant" && reusableTokens > 0;
90
+ const outcome = prefixTokens === 0 ? "no-prefix" : isolated ? "isolated-miss" : reusableTokens > 0 ? "cache-hit" : "cold-miss";
91
+ return {
92
+ prefixTokens,
93
+ uniqueTokens,
94
+ cacheState,
95
+ scope,
96
+ requester,
97
+ reusableTokens,
98
+ computedTokens,
99
+ hitRatePercent,
100
+ prefillMs,
101
+ savedPrefillMs,
102
+ privacyRisk,
103
+ outcome,
104
+ diagnosis: outcome === "cache-hit" ? privacyRisk ? "Prefill work is reused across tenants, but the latency difference can reveal that another tenant used this exact prefix." : "The identical full prefix blocks skip repeated prefill; the unique suffix still has to be computed." : outcome === "isolated-miss" ? "Tenant isolation prevents cross-tenant reuse, trading some compute for a safer cache boundary." : outcome === "cold-miss" ? "The prefix is not resident yet, so this request computes it and can warm the cache for later requests." : "There is no shared prefix to reuse; every prompt token must be computed."
105
+ };
106
+ }
107
+ /**
108
+ * Comparative teaching model for the two phases of autoregressive inference.
109
+ * Values are dimensioned and monotonic, but are not claims about a particular model or GPU.
110
+ */
111
+ function simulateInferenceRequest(promptTokens, outputTokens, concurrentRequests, scheduler) {
112
+ const requests = Math.max(1, Math.min(32, Math.round(concurrentRequests)));
113
+ const queueFactor = 1 + (requests - 1) * .055;
114
+ const prefillBias = scheduler === "prefill-priority" ? .72 : scheduler === "decode-priority" ? 1.35 : 1;
115
+ const decodeBias = scheduler === "decode-priority" ? .76 : scheduler === "prefill-priority" ? 1.28 : 1;
116
+ const ttftMs = Math.round((70 + promptTokens * .21) * queueFactor * prefillBias);
117
+ const interTokenMs = Math.round((18 + requests * 1.45) * decodeBias);
118
+ const completionMs = ttftMs + interTokenMs * outputTokens;
119
+ const prefillWork = promptTokens * requests;
120
+ const decodeWork = outputTokens * requests;
121
+ const activeKvTokens = (promptTokens + Math.ceil(outputTokens / 2)) * requests;
122
+ const ratio = prefillWork / Math.max(1, decodeWork);
123
+ const bottleneck = ratio > 2 ? "prefill" : ratio < .5 ? "decode" : "balanced";
124
+ return {
125
+ promptTokens,
126
+ outputTokens,
127
+ concurrentRequests: requests,
128
+ scheduler,
129
+ prefillWork,
130
+ decodeWork,
131
+ ttftMs,
132
+ interTokenMs,
133
+ completionMs,
134
+ activeKvTokens,
135
+ bottleneck,
136
+ diagnosis: bottleneck === "prefill" ? "Prompt processing dominates. Time to first token and admission pressure matter most." : bottleneck === "decode" ? "Token generation dominates. Inter-token latency and growing KV state matter most." : "Prompt processing and token generation both materially affect the request."
137
+ };
138
+ }
139
+ function planInference(model, precision, gpuMemory, gpus, batch, context) {
140
+ const count = Math.max(1, Math.min(4, Math.round(gpus)));
141
+ const weightsGb = (model === "8b" ? 8 : 70) * (precision === "fp16" ? 2 : 1) * 1.08;
142
+ const kvPerToken = model === "8b" ? 12e-5 : 32e-5;
143
+ const kvCacheGb = batch * context * kvPerToken;
144
+ const perReplicaNeed = weightsGb + kvCacheGb + 4;
145
+ const topology = perReplicaNeed <= gpuMemory ? "replicas" : perReplicaNeed <= gpuMemory * count ? "tensor-parallel" : "cannot-load";
146
+ const replicas = topology === "replicas" ? count : topology === "tensor-parallel" ? 1 : 0;
147
+ const availableGb = gpuMemory * count;
148
+ const requiredGb = topology === "replicas" ? perReplicaNeed * count : perReplicaNeed;
149
+ const fits = topology !== "cannot-load";
150
+ const base = model === "8b" ? 90 : 28;
151
+ const batchGain = 1 + Math.log2(batch) * .55;
152
+ const parallelGain = topology === "tensor-parallel" ? Math.pow(count, .72) : count;
153
+ const tokensPerSecond = fits ? Math.round(base * batchGain * parallelGain) : 0;
154
+ const ttftMs = fits ? Math.round((model === "8b" ? 180 : 520) + (batch - 1) * 18 + (context / 2048 - 1) * 90 + (topology === "tensor-parallel" ? (count - 1) * 45 : 0)) : 0;
155
+ const memoryHeadroomGb = Math.round((availableGb - requiredGb) * 10) / 10;
156
+ const diagnosis = !fits ? "Model weights, KV cache and runtime workspace exceed aggregate GPU memory. Quantize, shorten context, reduce batch or add memory." : topology === "tensor-parallel" ? `The model is sharded across ${count} GPUs. It fits, but every token requires cross-GPU coordination.` : batch === 32 ? "Large continuous batches raise total throughput while increasing queueing and time to first token." : `Each GPU holds a complete model copy, so ${replicas} independent replicas can serve requests in parallel.`;
157
+ return {
158
+ model,
159
+ precision,
160
+ gpuMemory,
161
+ gpus: count,
162
+ batch,
163
+ context,
164
+ weightsGb: Math.round(weightsGb * 10) / 10,
165
+ kvCacheGb: Math.round(kvCacheGb * 10) / 10,
166
+ requiredGb: Math.round(requiredGb * 10) / 10,
167
+ availableGb,
168
+ fits,
169
+ topology,
170
+ replicas,
171
+ tokensPerSecond,
172
+ ttftMs,
173
+ memoryHeadroomGb,
174
+ diagnosis
175
+ };
176
+ }
177
+
178
+ //#endregion
179
+ export { planInference, simulateDistributedInference, simulateInferenceRequest, simulateModelRouting, simulatePrefixCache };
@@ -0,0 +1,45 @@
1
+ //#region src/networking/cloud/infrastructure.d.ts
2
+ type InfrastructureIntent = "keep" | "scale-four" | "larger-nodes";
3
+ type ExternalChange = "none" | "manual-scale" | "open-admin";
4
+ type DriftResolution = "enforce-config" | "adopt-actual";
5
+ type InfrastructurePhase = "baseline" | "refresh" | "plan" | "apply";
6
+ interface InfrastructureShape {
7
+ replicas: number;
8
+ nodeSize: "small" | "large";
9
+ adminAccess: "private" | "public";
10
+ }
11
+ interface InfrastructurePlan {
12
+ intent: InfrastructureIntent;
13
+ externalChange: ExternalChange;
14
+ resolution: DriftResolution;
15
+ }
16
+ interface InfrastructureSnapshot {
17
+ plan: InfrastructurePlan;
18
+ step: number;
19
+ phase: InfrastructurePhase;
20
+ configuration: InfrastructureShape;
21
+ recordedState: InfrastructureShape;
22
+ actual: InfrastructureShape;
23
+ target: InfrastructureShape;
24
+ driftCount: number;
25
+ remainingDifferences: number;
26
+ plannedChanges: number;
27
+ infrastructureChanged: boolean;
28
+ codeUpdated: boolean;
29
+ converged: boolean;
30
+ unsafeExposure: boolean;
31
+ message: string;
32
+ }
33
+ type InfrastructureCommand = {
34
+ type: "advance";
35
+ } | {
36
+ type: "reset";
37
+ };
38
+ declare function infrastructureSnapshot(plan: InfrastructurePlan, step?: number): InfrastructureSnapshot;
39
+ declare function transitionInfrastructure(current: InfrastructureSnapshot, command: InfrastructureCommand): InfrastructureSnapshot;
40
+ declare function createInfrastructureEngine(plan: InfrastructurePlan): {
41
+ readonly state: InfrastructureSnapshot;
42
+ dispatch(command: InfrastructureCommand): InfrastructureSnapshot;
43
+ };
44
+ //#endregion
45
+ export { DriftResolution, ExternalChange, InfrastructureCommand, InfrastructureIntent, InfrastructurePhase, InfrastructurePlan, InfrastructureShape, InfrastructureSnapshot, createInfrastructureEngine, infrastructureSnapshot, transitionInfrastructure };
@@ -0,0 +1,96 @@
1
+ //#region src/networking/cloud/infrastructure.ts
2
+ const BASE = {
3
+ replicas: 2,
4
+ nodeSize: "small",
5
+ adminAccess: "private"
6
+ };
7
+ const PHASES = [
8
+ "baseline",
9
+ "refresh",
10
+ "plan",
11
+ "apply"
12
+ ];
13
+ function configured(intent) {
14
+ if (intent === "scale-four") return {
15
+ ...BASE,
16
+ replicas: 4
17
+ };
18
+ if (intent === "larger-nodes") return {
19
+ ...BASE,
20
+ nodeSize: "large"
21
+ };
22
+ return { ...BASE };
23
+ }
24
+ function changedOutside(change) {
25
+ if (change === "manual-scale") return {
26
+ ...BASE,
27
+ replicas: 3
28
+ };
29
+ if (change === "open-admin") return {
30
+ ...BASE,
31
+ adminAccess: "public"
32
+ };
33
+ return { ...BASE };
34
+ }
35
+ function difference(left, right) {
36
+ return Number(left.replicas !== right.replicas) + Number(left.nodeSize !== right.nodeSize) + Number(left.adminAccess !== right.adminAccess);
37
+ }
38
+ function describe(snapshot) {
39
+ if (snapshot.phase === "baseline" && snapshot.driftCount > 0) return "Actual infrastructure changed outside the workflow. Recorded state still describes the last apply.";
40
+ if (snapshot.phase === "baseline") return snapshot.remainingDifferences > 0 ? "Configuration declares a new target. State and actual infrastructure still describe the last apply." : "Configuration, recorded state and actual infrastructure begin from a known baseline.";
41
+ if (snapshot.phase === "refresh") return snapshot.driftCount > 0 ? `Refresh observed ${snapshot.driftCount} difference. No remote object changed.` : "Refresh observed the remote objects. No external drift was found and nothing changed.";
42
+ if (snapshot.phase === "plan") return snapshot.plan.resolution === "adopt-actual" && snapshot.codeUpdated ? `Configuration now declares the observed reality. Review the ${snapshot.plannedChanges}-change plan before apply.` : `The plan proposes ${snapshot.plannedChanges} change${snapshot.plannedChanges === 1 ? "" : "s"} to make reality match configuration.`;
43
+ return snapshot.converged ? "Apply completed. Configuration, state and actual infrastructure now agree." : "Apply stopped before convergence; inspect the partial result before planning again.";
44
+ }
45
+ function infrastructureSnapshot(plan, step = 0) {
46
+ const currentStep = Math.max(0, Math.min(PHASES.length - 1, Math.round(step)));
47
+ const phase = PHASES[currentStep];
48
+ const desired = configured(plan.intent);
49
+ const outside = changedOutside(plan.externalChange);
50
+ const planned = currentStep >= 2;
51
+ const applied = currentStep >= 3;
52
+ const adopting = plan.resolution === "adopt-actual" && planned && plan.externalChange !== "none";
53
+ const configuration = adopting ? outside : desired;
54
+ const target = adopting ? outside : desired;
55
+ const actual = applied ? target : outside;
56
+ const recordedState = applied ? target : BASE;
57
+ const snapshot = {
58
+ plan,
59
+ step: currentStep,
60
+ phase,
61
+ configuration,
62
+ recordedState,
63
+ actual,
64
+ target,
65
+ driftCount: difference(BASE, outside),
66
+ remainingDifferences: difference(configuration, actual),
67
+ plannedChanges: planned ? difference(outside, target) : 0,
68
+ infrastructureChanged: applied && difference(outside, target) > 0,
69
+ codeUpdated: adopting,
70
+ converged: applied && difference(configuration, actual) === 0 && difference(recordedState, actual) === 0,
71
+ unsafeExposure: actual.adminAccess === "public"
72
+ };
73
+ return {
74
+ ...snapshot,
75
+ message: describe(snapshot)
76
+ };
77
+ }
78
+ function transitionInfrastructure(current, command) {
79
+ if (command.type === "reset") return infrastructureSnapshot(current.plan);
80
+ return infrastructureSnapshot(current.plan, current.step + 1);
81
+ }
82
+ function createInfrastructureEngine(plan) {
83
+ let current = infrastructureSnapshot(plan);
84
+ return {
85
+ get state() {
86
+ return current;
87
+ },
88
+ dispatch(command) {
89
+ current = transitionInfrastructure(current, command);
90
+ return current;
91
+ }
92
+ };
93
+ }
94
+
95
+ //#endregion
96
+ export { createInfrastructureEngine, infrastructureSnapshot, transitionInfrastructure };
@@ -0,0 +1,24 @@
1
+ //#region src/networking/cloud/observability.d.ts
2
+ type SloTarget = "99" | "99.9";
3
+ type DependencyState = "healthy" | "slow" | "failing";
4
+ type Telemetry = "metrics-only" | "correlated";
5
+ interface SloIncidentResult {
6
+ requestsPerMinute: number;
7
+ sloTarget: SloTarget;
8
+ dependency: DependencyState;
9
+ telemetry: Telemetry;
10
+ errorRatePercent: number;
11
+ p95LatencyMs: number;
12
+ goodRatePercent: number;
13
+ burnRate: number;
14
+ budgetRequests: number;
15
+ badRequestsPerMinute: number;
16
+ minutesToExhaust: number;
17
+ action: "observe" | "ticket" | "page";
18
+ suspect: string;
19
+ evidence: string;
20
+ diagnosis: string;
21
+ }
22
+ declare function observeService(requestsPerMinute: number, sloTarget: SloTarget, dependency: DependencyState, telemetry: Telemetry): SloIncidentResult;
23
+ //#endregion
24
+ export { DependencyState, SloIncidentResult, SloTarget, Telemetry, observeService };
@@ -0,0 +1,34 @@
1
+ //#region src/networking/cloud/observability.ts
2
+ function observeService(requestsPerMinute, sloTarget, dependency, telemetry) {
3
+ const rpm = Math.max(10, Math.min(1e4, Math.round(requestsPerMinute)));
4
+ const errorRatePercent = dependency === "healthy" ? .03 : dependency === "slow" ? .35 : 4.8;
5
+ const p95LatencyMs = dependency === "healthy" ? 180 : dependency === "slow" ? 1450 : 2800;
6
+ const allowedPercent = 100 - Number(sloTarget);
7
+ const goodRatePercent = Math.round((100 - errorRatePercent) * 100) / 100;
8
+ const burnRate = Math.round(errorRatePercent / allowedPercent * 10) / 10;
9
+ const budgetRequests = Math.round(rpm * 60 * 24 * 30 * allowedPercent / 100);
10
+ const badRequestsPerMinute = Math.round(rpm * errorRatePercent / 100);
11
+ const minutesToExhaust = Math.max(1, Math.round(1440 * 30 / burnRate));
12
+ const action = burnRate >= 14.4 ? "page" : burnRate >= 2 ? "ticket" : "observe";
13
+ const suspect = dependency === "healthy" ? "no dominant failing dependency" : dependency === "slow" ? "catalog database latency" : "payment dependency failures";
14
+ return {
15
+ requestsPerMinute: rpm,
16
+ sloTarget,
17
+ dependency,
18
+ telemetry,
19
+ errorRatePercent,
20
+ p95LatencyMs,
21
+ goodRatePercent,
22
+ burnRate,
23
+ budgetRequests,
24
+ badRequestsPerMinute,
25
+ minutesToExhaust,
26
+ action,
27
+ suspect,
28
+ evidence: telemetry === "correlated" ? `Trace spans isolate ${suspect}; linked logs carry the same trace ID.` : "Metrics expose customer symptoms, but no correlated trace identifies the responsible hop.",
29
+ diagnosis: action === "page" ? `Customer-visible failures burn the ${sloTarget}% objective ${burnRate}× faster than allowed. Page an operator and stop risky change.` : action === "ticket" ? `The service is consuming budget faster than planned, but the modeled exhaustion window permits scheduled investigation.` : "The service remains within its planned reliability consumption. Observe trends without paging a human."
30
+ };
31
+ }
32
+
33
+ //#endregion
34
+ export { observeService };
@@ -0,0 +1,32 @@
1
+ //#region src/networking/cloud/orchestration.d.ts
2
+ /**
3
+ * Reconciliation: a declared desired state, the actual state, and a controller closing the gap.
4
+ *
5
+ * The misconception this exists to break is that a deployment is an INSTRUCTION. It is not. It is a
6
+ * declaration the cluster keeps trying to satisfy, which is why a failed Pod comes back on its own
7
+ * and why asking for more replicas than there are slots leaves Pods pending forever rather than
8
+ * failing loudly. Both of those follow from the same loop.
9
+ */
10
+ type ClusterCapacity = "tight" | "ample";
11
+ type ClusterFailure = "none" | "pod" | "node";
12
+ type ReleaseState = "stable" | "rolling";
13
+ interface OrchestrationResult {
14
+ desired: number;
15
+ capacity: ClusterCapacity;
16
+ failure: ClusterFailure;
17
+ release: ReleaseState;
18
+ slots: number;
19
+ /** Slots still schedulable after a failure removed some. */
20
+ usableSlots: number;
21
+ scheduled: number;
22
+ ready: number;
23
+ pending: number;
24
+ oldVersion: number;
25
+ newVersion: number;
26
+ replacementCreated: boolean;
27
+ available: boolean;
28
+ diagnosis: string;
29
+ }
30
+ declare function reconcileWorkload(desired: number, capacity: ClusterCapacity, failure: ClusterFailure, release: ReleaseState): OrchestrationResult;
31
+ //#endregion
32
+ export { ClusterCapacity, ClusterFailure, OrchestrationResult, ReleaseState, reconcileWorkload };
@@ -0,0 +1,38 @@
1
+ //#region src/networking/cloud/orchestration.ts
2
+ function reconcileWorkload(desired, capacity, failure, release) {
3
+ const target = Math.max(1, Math.min(6, Math.round(desired)));
4
+ const slots = capacity === "ample" ? 6 : 3;
5
+ const usableSlots = Math.max(0, slots - (failure === "node" ? 2 : 0));
6
+ const scheduled = Math.min(target, usableSlots);
7
+ const pending = Math.max(0, target - scheduled);
8
+ /**
9
+ * Every scheduled Pod is ready, because the controller has already replaced whatever failed.
10
+ *
11
+ * That is the point of the loop rather than an oversight, and it is now written as one line. It
12
+ * used to read `scheduled - (failure === 'pod' && scheduled === target ? 0 : 0)`, which subtracts
13
+ * zero from zero either way: a conditional with the same value in both branches, dressed up to
14
+ * look like the failure was being accounted for somewhere.
15
+ */
16
+ const ready = scheduled;
17
+ const replacementCreated = failure !== "none" && scheduled > 0;
18
+ const newVersion = release === "rolling" ? Math.min(ready, Math.max(1, Math.ceil(target / 2))) : 0;
19
+ return {
20
+ desired: target,
21
+ capacity,
22
+ failure,
23
+ release,
24
+ slots,
25
+ usableSlots,
26
+ scheduled,
27
+ ready,
28
+ pending,
29
+ oldVersion: ready - newVersion,
30
+ newVersion,
31
+ replacementCreated,
32
+ available: ready >= Math.max(1, target - 1),
33
+ diagnosis: pending ? `The controller still wants ${target} replicas, but only ${usableSlots} schedulable slots remain. ${pending} Pod${pending === 1 ? " is" : "s are"} pending.` : failure !== "none" ? `Actual state fell below the declaration, so the controller created replacement Pods until ${ready}/${target} were ready again.` : release === "rolling" ? `New Pods become ready before more old Pods are removed. ${newVersion} now run the new digest while availability is preserved.` : `Actual state matches the declared ${target} ready replicas.`
34
+ };
35
+ }
36
+
37
+ //#endregion
38
+ export { reconcileWorkload };
@@ -0,0 +1,21 @@
1
+ //#region src/networking/cloud/recovery.d.ts
2
+ type RecoveryStrategy = "backup" | "async-replica" | "sync-replica";
3
+ type Incident = "primary-failure" | "bad-write";
4
+ type WriteLoad = "normal" | "heavy";
5
+ interface RecoveryResult {
6
+ strategy: RecoveryStrategy;
7
+ incident: Incident;
8
+ load: WriteLoad;
9
+ commitLatencyMs: number;
10
+ replicationLagSeconds: number;
11
+ rpoSeconds: number;
12
+ rtoMinutes: number;
13
+ automaticFailover: boolean;
14
+ pointInTimeRecovery: boolean;
15
+ meetsTarget: boolean;
16
+ recoveryAction: string;
17
+ diagnosis: string;
18
+ }
19
+ declare function evaluateRecovery(strategy: RecoveryStrategy, incident: Incident, load: WriteLoad): RecoveryResult;
20
+ //#endregion
21
+ export { Incident, RecoveryResult, RecoveryStrategy, WriteLoad, evaluateRecovery };
@@ -0,0 +1,27 @@
1
+ //#region src/networking/cloud/recovery.ts
2
+ function evaluateRecovery(strategy, incident, load) {
3
+ const heavy = load === "heavy";
4
+ const commitLatencyMs = strategy === "sync-replica" ? heavy ? 92 : 48 : heavy ? 24 : 18;
5
+ const replicationLagSeconds = strategy === "async-replica" ? heavy ? 45 : 4 : strategy === "sync-replica" ? 0 : 3600;
6
+ const pointInTimeRecovery = strategy === "backup";
7
+ const automaticFailover = incident === "primary-failure" && strategy !== "backup";
8
+ const rpoSeconds = incident === "bad-write" ? pointInTimeRecovery ? 300 : Number.POSITIVE_INFINITY : strategy === "backup" ? 3600 : replicationLagSeconds;
9
+ const rtoMinutes = incident === "bad-write" ? pointInTimeRecovery ? 45 : Number.POSITIVE_INFINITY : strategy === "backup" ? 180 : strategy === "async-replica" ? 8 : 5;
10
+ return {
11
+ strategy,
12
+ incident,
13
+ load,
14
+ commitLatencyMs,
15
+ replicationLagSeconds,
16
+ rpoSeconds,
17
+ rtoMinutes,
18
+ automaticFailover,
19
+ pointInTimeRecovery,
20
+ meetsTarget: rpoSeconds <= 300 && rtoMinutes <= 30,
21
+ recoveryAction: incident === "bad-write" ? pointInTimeRecovery ? "restore the last clean recovery point" : "find a clean backup; the replica copied the write" : strategy === "backup" ? "provision a database and restore the backup" : "fence the old primary, promote the standby, and redirect clients",
22
+ diagnosis: incident === "bad-write" && !pointInTimeRecovery ? "Replication preserved availability, not history: the unwanted write reached the replica too." : incident === "bad-write" ? "A point-in-time backup can recover state before the unwanted write, but restoration takes time." : strategy === "backup" ? "Backup and restore is inexpensive, but its older recovery point and rebuild time miss this target." : strategy === "async-replica" ? `Failover is fast, but ${replicationLagSeconds} seconds of unreplicated commits can be lost.` : "A synchronous standby reaches zero modeled RPO by making each commit wait for remote acknowledgement."
23
+ };
24
+ }
25
+
26
+ //#endregion
27
+ export { evaluateRecovery };
@@ -0,0 +1,42 @@
1
+ //#region src/networking/cloud/releases.d.ts
2
+ type ReleaseStrategy = "recreate" | "rolling" | "canary" | "blue-green";
3
+ type CandidateHealth = "healthy" | "faulty";
4
+ type DataCompatibility = "compatible" | "breaking";
5
+ type ReleaseStatus = "running" | "completed" | "rolled-back";
6
+ interface ReleasePlan {
7
+ strategy: ReleaseStrategy;
8
+ replicas: number;
9
+ candidateHealth: CandidateHealth;
10
+ dataCompatibility: DataCompatibility;
11
+ }
12
+ interface ReleaseSnapshot {
13
+ plan: ReleasePlan;
14
+ step: number;
15
+ totalSteps: number;
16
+ oldReplicas: number;
17
+ newReplicas: number;
18
+ newTrafficPercent: number;
19
+ availableReplicas: number;
20
+ observedErrorPercent: number;
21
+ readinessSeconds: number;
22
+ rollbackSeconds: number;
23
+ dataSafe: boolean;
24
+ status: ReleaseStatus;
25
+ safeToContinue: boolean;
26
+ message: string;
27
+ }
28
+ type ReleaseCommand = {
29
+ type: "advance";
30
+ } | {
31
+ type: "rollback";
32
+ } | {
33
+ type: "reset";
34
+ };
35
+ declare function releaseSnapshot(plan: ReleasePlan, step?: number, status?: ReleaseStatus): ReleaseSnapshot;
36
+ declare function transitionRelease(current: ReleaseSnapshot, command: ReleaseCommand): ReleaseSnapshot;
37
+ declare function createReleaseEngine(plan: ReleasePlan): {
38
+ readonly state: ReleaseSnapshot;
39
+ dispatch(command: ReleaseCommand): ReleaseSnapshot;
40
+ };
41
+ //#endregion
42
+ export { CandidateHealth, DataCompatibility, ReleaseCommand, ReleasePlan, ReleaseSnapshot, ReleaseStatus, ReleaseStrategy, createReleaseEngine, releaseSnapshot, transitionRelease };